/* === Fixline Dashboard — helles, klares Admin-Theme === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #f1f5f9;
  --surface:     #ffffff;
  --surface-2:   #f8fafc;
  --border:      #e2e8f0;
  --border-hi:   #cbd5e1;
  --text:        #0f172a;
  --text-dim:    #475569;
  --text-muted:  #94a3b8;
  --brand:       #2563eb;
  --brand-dark:  #1d4ed8;
  --brand-soft:  #eff6ff;
  --accent:      #06b6d4;
  --green:       #16a34a;
  --green-soft:  #dcfce7;
  --red:         #dc2626;
  --red-soft:    #fee2e2;
  --amber:       #d97706;
  --amber-soft:  #fef3c7;
  --font:        'Inter', system-ui, sans-serif;
  --font-num:    'Space Grotesk', system-ui, sans-serif;
  --radius:      14px;
  --radius-sm:   9px;
  --shadow:      0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-lg:   0 10px 30px rgba(15,23,42,0.12);
}

html { font-size: 16px; }
body { background: var(--bg); color: var(--text); font-family: var(--font); min-height: 100vh; min-height: 100dvh; }

/* === HEADER === */
.header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-num); font-weight: 700; font-size: 18px; color: #fff;
}
.app-title { font-family: var(--font-num); font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.app-sub { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

#sync-badge {
  font-size: 12px; font-weight: 500; padding: 5px 10px; border-radius: 20px; white-space: nowrap;
  background: var(--green-soft); color: var(--green);
}
#sync-badge[data-state="busy"] { background: var(--amber-soft); color: var(--amber); }

.btn-icon {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
  width: 38px; height: 38px; border-radius: 9px; cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: var(--border); }

/* === TABS === */
.tabs {
  display: flex; gap: 4px; padding: 8px 16px; background: var(--surface);
  border-bottom: 1px solid var(--border); overflow-x: auto;
  position: sticky; top: 65px; z-index: 90; -webkit-overflow-scrolling: touch;
}
.tab {
  flex-shrink: 0; padding: 9px 16px; border-radius: 9px; border: none; background: none;
  color: var(--text-dim); font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 7px; white-space: nowrap;
}
.tab:hover { background: var(--surface-2); }
.tab.active { background: var(--brand-soft); color: var(--brand); }
.tab .tab-ic { font-size: 15px; }

/* === MAIN === */
.main { padding: 20px 16px 96px; max-width: 1280px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; animation: fade 0.18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.view-head h2 { font-family: var(--font-num); font-size: 22px; font-weight: 700; }
.view-head .view-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* === KPI CARDS === */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.kpi-label { font-size: 12px; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-family: var(--font-num); font-size: 34px; font-weight: 700; line-height: 1; }
.kpi-value.green { color: var(--green); }
.kpi-value.red { color: var(--red); }
.kpi-value.brand { color: var(--brand); }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* === PANEL / CARD === */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 18px; }
.panel-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.panel-head h3 { font-size: 15px; font-weight: 700; }
.panel-body { padding: 4px 0; }

/* === TOOLBAR (Suche, Filter) === */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.search-input {
  flex: 1; min-width: 180px; padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px;
  font-family: inherit; font-size: 15px; background: var(--surface); color: var(--text); outline: none;
}
.search-input:focus { border-color: var(--brand); }

/* === MONTH SWITCHER === */
.month-switch { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px; }
.month-switch button { background: none; border: none; cursor: pointer; font-size: 18px; width: 34px; height: 34px; border-radius: 7px; color: var(--text-dim); }
.month-switch button:hover { background: var(--surface-2); }
.month-switch .month-label { font-family: var(--font-num); font-weight: 600; font-size: 15px; min-width: 130px; text-align: center; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; }
.seg button { border: none; background: none; padding: 7px 14px; border-radius: 7px; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--text-dim); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }

/* === TABLE === */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; padding: 11px 14px; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-muted); border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap; position: sticky; top: 0;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-family: var(--font-num); white-space: nowrap; }
td.strong { font-weight: 600; }
.muted { color: var(--text-muted); }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.pill.in { background: var(--green-soft); color: var(--green); }
.pill.out { background: var(--red-soft); color: var(--red); }
.pill.low { background: var(--red-soft); color: var(--red); }
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.warn { background: var(--amber-soft); color: var(--amber); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.mini-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 7px; padding: 6px 9px; font-size: 13px; cursor: pointer; color: var(--text-dim); }
.mini-btn:hover { background: var(--surface-2); border-color: var(--border-hi); }
.mini-btn.danger:hover { background: var(--red-soft); border-color: #fca5a5; color: var(--red); }

/* === BUTTONS === */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 16px; border-radius: 10px;
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: var(--surface); color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-hi); }

/* === EMPTY STATE === */
.empty { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty .em-ic { font-size: 40px; margin-bottom: 12px; }
.empty p { font-size: 15px; margin-bottom: 16px; }

/* === MODAL === */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5); z-index: 1000;
  display: none; align-items: flex-end; justify-content: center; padding: 0;
}
.modal-overlay.show { display: flex; }
@media (min-width: 640px) { .modal-overlay { align-items: center; padding: 24px; } }
.modal {
  background: var(--surface); width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg);
  animation: slideup 0.22s ease;
}
@media (min-width: 640px) { .modal { border-radius: 18px; } }
@keyframes slideup { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--surface); }
.modal-head h3 { font-family: var(--font-num); font-size: 18px; font-weight: 700; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; position: sticky; bottom: 0; background: var(--surface); }

/* === FORM === */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: 9px;
  font-family: inherit; font-size: 16px; background: var(--surface); color: var(--text); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); }
.field textarea { resize: vertical; min-height: 64px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* === AUSWERTUNG === */
.eval-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
@media (max-width: 560px) { .eval-grid { grid-template-columns: 1fr; } }
.eval-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.eval-card .e-label { font-size: 13px; color: var(--text-dim); font-weight: 600; margin-bottom: 8px; }
.eval-card .e-val { font-family: var(--font-num); font-size: 28px; font-weight: 700; }

/* === RESPONSIVE === */
@media (max-width: 600px) {
  .header { padding: 10px 14px; }
  .app-title { font-size: 18px; }
  .main { padding: 16px 12px 96px; }
  .view-head h2 { font-size: 19px; }
  .kpi-value { font-size: 28px; }
  thead th, tbody td { padding: 10px 11px; }
  #sync-badge { display: none; }
}
