/* ============================================================
   INSYRO – Rechnungsprogramm – Globales Stylesheet
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Lato', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 17px;
  background: #c8d8e8;
  color: #222;
}

a { color: inherit; text-decoration: none; }

/* ---- Kopfzeile / Navigation ---- */
.topnav {
  display: flex;
  align-items: stretch;
  background: #dce8f5;
  border-bottom: 1px solid #a8bdd0;
  height: 44px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topnav nav { display: flex; flex: 1; }

.nav-tab {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 14px;
  border-right: 1px solid #b0c8e0;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
  color: #334;
  transition: background .15s;
}
.nav-tab:hover { background: #c8daf0; }
.nav-tab.active {
  background: linear-gradient(180deg, #ffd060, #e8a800);
  color: #333;
  font-weight: bold;
}
.nav-tab.disabled { color: #888; cursor: default; }
.nav-tab.disabled:hover { background: none; }

.topnav-user {
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 15px;
  color: #446;
}
.topnav-user a { color: #1a4a9a; }
.topnav-user a:hover { text-decoration: underline; }

/* ---- Seitenlayout ---- */
.page-layout {
  display: flex;
  height: calc(100vh - 44px);
  overflow: hidden;
}

.panel-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #dce8f5;
  border-right: 2px solid #b0c4d8;
  min-width: 0;
}

.panel-right {
  width: 418px;
  min-width: 352px;
  max-width: 484px;
  display: flex;
  flex-direction: column;
  background: #d0dff0;
  overflow: hidden;
}

.panel-header {
  background: #c0d4e8;
  border-bottom: 1px solid #a8bdd0;
  padding: 6px 10px;
  font-weight: bold;
  font-size: 13px;
  color: #1a3a6a;
}

/* ---- Toolbar ---- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  background: #dce8f5;
  border-bottom: 1px solid #c0d4e8;
}

.filter-area { display: flex; align-items: center; gap: 8px; }
.filter-label { font-size: 15px; color: #445; white-space: nowrap; }
.filter-input {
  width: 260px;
  padding: 5px 8px;
  border: 1px solid #a8b8c8;
  border-radius: 3px;
  font-family: inherit;
  font-size: 15px;
  background: #fff;
}
.filter-input::placeholder { color: #27a; font-size: 14px; }

/* ---- Icon-Buttons (Toolbar) ---- */
.icon-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 10px;
  background: linear-gradient(180deg, #e8e8e8, #c8c8c8);
  border: 1px solid #aaa;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  color: #333;
  min-width: 64px;
}
.icon-btn:hover { background: linear-gradient(180deg,#f5f5f5,#ddd); }
.icon-btn:disabled { opacity:.5; cursor:default; }

.icon-plus {
  display: block;
  width: 24px; height: 24px;
  background: radial-gradient(circle, #f5a623, #e07800);
  border-radius: 50%;
  position: relative;
}
.icon-plus::before, .icon-plus::after {
  content:'';
  position:absolute;
  background:#fff;
  border-radius:2px;
}
.icon-plus::before { width:2px; height:12px; top:6px; left:11px; }
.icon-plus::after  { width:12px; height:2px; top:11px; left:6px; }

.icon-notiz { position: relative; }
.icon-notiz::before {
  content: '📋';
  font-size: 20px;
  display: block;
  line-height: 1;
}

.icon-save::before {
  content: '💾';
  font-size: 20px;
  display: block;
  line-height: 1;
}

.btn-label { font-size: 14px; }

.detail-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: #d0dff0;
  border-bottom: 1px solid #b8cce0;
  flex-wrap: wrap;
}

.unsaved-counter {
  text-align: right;
  padding: 2px 8px;
  font-size: 11px;
  color: #888;
}

/* ---- DataGrid ---- */
.grid-wrapper { flex: 1; overflow-y: auto; }

.data-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

.data-grid thead th {
  background: #c4d8ec;
  border: 1px solid #a8bdd0;
  padding: 5px 8px;
  text-align: left;
  font-weight: normal;
  position: sticky;
  top: 0;
  white-space: nowrap;
}

.data-grid tbody tr { cursor: pointer; }
.data-grid tbody tr:nth-child(even) { background: #e4eef8; }
.data-grid tbody tr:hover { background: #b8d4f0; }
.data-grid tbody tr.selected { background: #4a90d0; color: #fff; }

.data-grid td {
  border-bottom: 1px solid #ccd8e4;
  padding: 8px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.col-nr   { width: 80px; }
.col-name { width: auto; }
.col-money { width: 110px; text-align: right; }
.col-ma   { width: 120px; }

.loading { text-align: center; padding: 20px; color: #667; }

/* ---- Grid-Footer ---- */
.grid-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 10px;
  background: #c8d8e8;
  border-top: 1px solid #a8bdd0;
  font-size: 15px;
  color: #445;
}
.pagination { display: flex; align-items: center; gap: 8px; }
.pagination button {
  background: #d0e0f0;
  border: 1px solid #a0b4c8;
  border-radius: 3px;
  padding: 2px 8px;
  cursor: pointer;
}
.pagination button:hover { background: #b8d0e8; }

/* ---- Akkordeon ---- */
.accordion {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.acc-section {
  border-bottom: 1px solid #b0c4d8;
  flex-shrink: 0;
}

.acc-section.acc-expanded {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.acc-header {
  padding: 6px 10px;
  background: #c8d8ec;
  cursor: pointer;
  font-size: 15px;
  font-weight: bold;
  color: #1a3a6a;
  user-select: none;
  border-bottom: 1px solid #b0c4d8;
  flex-shrink: 0;
}
.acc-header:hover { background: #b8cce0; }
.acc-header.acc-active { background: #a8c0dc; }

.acc-body { display: none; }
.acc-body.acc-open {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  min-height: 0;
}

/* ---- Formularfelder im Detail-Panel ---- */
.form-group {
  background: #dce8f5;
  border: 1px solid #b8cce0;
  border-radius: 4px;
  padding: 8px 10px;
  margin-bottom: 8px;
}

.hint-text {
  font-size: 12px;
  color: #27a;
  margin-bottom: 6px;
  line-height: 1.4;
}

.field-row {
  display: flex;
  align-items: flex-start;
  margin-bottom: 4px;
  gap: 6px;
}

.field-row label {
  min-width: 140px;
  text-align: right;
  font-size: 13px;
  color: #334;
  padding-top: 3px;
  flex-shrink: 0;
}

.field-row input[type=text],
.field-row input[type=number],
.field-row input[type=date],
.field-row select,
.field-row textarea {
  flex: 1;
  padding: 4px 6px;
  border: 1px solid #a8b8c8;
  border-radius: 2px;
  font-family: inherit;
  font-size: 15px;
  background: #fff;
}

.multi-input { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.multi-input input { width: 100%; }

.inline-group { display: flex; gap: 4px; flex: 1; min-width: 0; }
.inline-group input:not(.input-sm),
.inline-group select:not(.input-sm) { flex: 1; min-width: 0; }
.input-sm { width: 70px !important; flex: 0 0 70px !important; }

.checkbox-label { display: flex; align-items: center; gap: 6px; padding-top: 3px; font-size: 12px; }

.notiz-textarea {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid #a8b8c8;
  border-radius: 2px;
  font-family: inherit;
  font-size: 12px;
  resize: vertical;
}

/* ---- Ansprechpartner-Block ---- */
.ap-block {
  background: #d8e8f8;
  border: 1px solid #b0c4d8;
  border-radius: 4px;
  padding: 8px;
  margin-bottom: 8px;
  position: relative;
}
.ap-block .ap-remove {
  position: absolute;
  top: 4px; right: 6px;
  background: none;
  border: none;
  color: #a00;
  cursor: pointer;
  font-size: 14px;
}

.btn-small {
  font-size: 11px;
  padding: 3px 8px;
  background: #c8d8ec;
  border: 1px solid #a0b4c8;
  border-radius: 3px;
  cursor: pointer;
}
.btn-small:hover { background: #b0c8e0; }

/* ---- Notizen-Liste ---- */
.notizen-liste { padding: 4px 0; }
.notiz-item {
  background: #e0ecf8;
  border: 1px solid #b8cce0;
  border-radius: 3px;
  padding: 5px 8px;
  margin-bottom: 5px;
  font-size: 14px;
}
.notiz-item .notiz-meta { color: #668; font-size: 13px; margin-bottom: 2px; }
.notiz-item .notiz-kurz { font-weight: bold; margin-bottom: 2px; }
.notiz-item .notiz-text { color: #334; white-space: pre-wrap; }

/* ---- Modal (Notiz-Dialog) ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-box {
  background: #dce8f5;
  border: 1px solid #90a8c0;
  border-radius: 6px;
  width: 520px;
  max-width: 96vw;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #c0d4e8;
  border-bottom: 1px solid #a0b8d0;
  border-radius: 6px 6px 0 0;
  font-weight: bold;
  font-size: 13px;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: #446;
}

.modal-body { padding: 14px 16px; }
.modal-body .field-row { margin-bottom: 8px; }
.modal-body .field-row label { min-width: 120px; }

.radio-group { display: flex; flex-direction: column; gap: 4px; }
.radio-group label { display: flex; align-items: center; gap: 6px; font-size: 12px; min-width: unset; }

.modal-textarea { margin-top: 10px; width: 100%; border-radius: 2px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid #b0c4d8;
}

.btn-cancel, .btn-ok {
  padding: 6px 20px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
}
.btn-cancel {
  background: #d0d8e4;
  border: 1px solid #a0aab8;
}
.btn-cancel:hover { background: #c0c8d4; }
.btn-ok {
  background: linear-gradient(180deg, #ffd060, #e8a800);
  border: 1px solid #c07800;
  font-weight: bold;
}
.btn-ok:hover { background: linear-gradient(180deg,#ffe080,#ffc030); }
