/* Profiler UI — Design-Tokens (hell/dunkel) */
:root {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-2: #1baf7a;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  /* Kategoriale Palette (feste Reihenfolge, CVD-geprüft) für Mehr-Serien-Charts */
  --cat-1: #2a78d6; --cat-2: #1baf7a; --cat-3: #eda100; --cat-4: #008300;
  --cat-5: #4a3aa7; --cat-6: #e34948; --cat-7: #e87ba4; --cat-8: #eb6834;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #199e70;
    --cat-1: #3987e5; --cat-2: #199e70; --cat-3: #c98500; --cat-4: #008300;
    --cat-5: #9085e9; --cat-6: #e66767; --cat-7: #d55181; --cat-8: #d95926;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

/* ---- Navigation ---- */
header.nav {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
header.nav .brand { font-weight: 700; font-size: 16px; color: var(--ink); }
header.nav a { color: var(--ink-2); text-decoration: none; padding: 4px 0; }
header.nav a:hover, header.nav a.active { color: var(--ink); }
header.nav .nav-menu { display: flex; flex: 1; align-items: center; gap: 20px; }
header.nav .spacer { flex: 1; }
header.nav .user { color: var(--muted); }
/* Burger-Button: nur auf schmalen Screens sichtbar (siehe Media-Query). */
.nav-toggle {
  display: none;
  background: transparent; color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 12px; font-size: 18px; line-height: 1.2; cursor: pointer;
}
.nav-toggle:hover { filter: none; border-color: var(--baseline); }

main { max-width: 1200px; margin: 0 auto; padding: 24px; }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 24px 0 10px; }
a { color: var(--series-1); }

/* ---- Karten / Grid ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
a.card { color: inherit; text-decoration: none; display: block; }
a.card:hover { border-color: var(--baseline); }

/* Handlungsbedarf-Kachel (orange), erscheint nur bei aktiven Alerts. */
.alert-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  background: color-mix(in srgb, var(--warning) 12%, var(--surface));
  border: 1px solid var(--warning);
  border-left: 4px solid var(--warning);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  color: var(--ink);
  text-decoration: none;
}
.alert-tile:hover { background: color-mix(in srgb, var(--warning) 20%, var(--surface)); }
.alert-tile-icon { color: var(--warning); font-size: 20px; line-height: 1; }
.card .card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.card .card-head .name { font-weight: 600; font-size: 15px; flex: 1; }
.card .meta { color: var(--muted); font-size: 12px; margin-top: 8px; }
.card .kv { display: flex; justify-content: space-between; color: var(--ink-2); margin: 2px 0; }

/* ---- Status-Badges (Farbe nie allein: Punkt + Text) ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--ink-2);
  padding: 2px 8px; border: 1px solid var(--border); border-radius: 999px;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.badge.online::before { background: var(--good); }
.badge.offline::before { background: var(--critical); }
.badge.pending::before { background: var(--warning); }
.badge.revoked::before { background: var(--muted); }

/* ---- Fortschrittsbalken ---- */
.bar { position: relative; height: 8px; background: var(--grid); border-radius: 4px; overflow: hidden; margin: 4px 0 10px; }
.bar > i { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--series-1); }
.bar > i.warn { background: var(--warning); }
.bar > i.crit { background: var(--critical); }
.bar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); }
.bar-label b { color: var(--ink); font-weight: 600; }

/* ---- Verfügbarkeit: Tages-Balken (Uptime-Kuma-Stil) ---- */
.uptime-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; }
.uptime-row + .uptime-row { border-top: 1px solid var(--grid); }
.uptime-name {
  flex: 0 0 auto; max-width: 240px; min-width: 100px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink); text-decoration: none; font-size: 13px;
}
.uptime-name:hover { text-decoration: underline; }
/* Pillenreihe: nimmt den Platz, scrollt bei Bedarf horizontal (Seite selbst nicht). */
.uptime-bars { flex: 1 1 auto; display: flex; gap: 3px; overflow-x: auto; padding-bottom: 2px; justify-content: end; }
.uptime-pill { flex: 0 0 auto; width: 9px; height: 26px; border-radius: 3px; background: var(--grid); }
.uptime-pill:hover { outline: 1px solid var(--border); }
.uptime-pill.up-ok { background: var(--good); }
.uptime-pill.up-warn { background: var(--warning); }
.uptime-pill.up-crit { background: var(--critical); }
.uptime-pill.up-none { background: var(--grid); }
.uptime-avg { flex: 0 0 auto; width: 64px; text-align: right; font-size: 13px; font-weight: 600; color: var(--ink); }
.uptime-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; align-items: center; }
.uptime-legend span { display: inline-flex; align-items: center; gap: 6px; }
.uptime-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; background: var(--grid); }
.uptime-legend i.up-ok { background: var(--good); }
.uptime-legend i.up-warn { background: var(--warning); }
.uptime-legend i.up-crit { background: var(--critical); }
.uptime-legend i.up-none { background: var(--grid); }

/* ---- Tabellen ---- */
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--grid); }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* ---- Formulare / Buttons ---- */
input, select {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--baseline); border-radius: 6px;
  padding: 8px 10px; font-size: 14px; font-family: inherit;
}
input:focus { outline: 2px solid var(--series-1); outline-offset: -1px; }
label { display: block; margin: 12px 0 4px; color: var(--ink-2); font-size: 13px; }
button {
  background: var(--series-1); color: #fff; border: none; border-radius: 6px;
  padding: 8px 14px; font-size: 14px; font-family: inherit; cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--baseline); }
button.danger { background: var(--critical); }
button:disabled { opacity: 0.5; cursor: default; }
.form-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.error { color: var(--critical); margin: 10px 0; }
.success { color: var(--good); margin: 10px 0; }
.hint { color: var(--muted); font-size: 12px; }

/* ---- Login ---- */
.login-wrap { display: flex; justify-content: center; padding-top: 12vh; }
.login-box { width: 340px; }
.login-box h1 { text-align: center; }
.login-box input { width: 100%; }
.login-box button { width: 100%; margin-top: 16px; }

/* ---- Token-Anzeige (einmalig) ---- */
.token-box {
  background: var(--page); border: 1px dashed var(--baseline); border-radius: 8px;
  padding: 12px; margin: 12px 0; font-family: ui-monospace, monospace; font-size: 12px;
  word-break: break-all;
}

/* Monospace-Inline (z.B. Integritäts-Hashes) */
.mono { font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; }

/* ---- Charts ---- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .tooltip {
  position: absolute; pointer-events: none; display: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; font-size: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  white-space: nowrap; z-index: 5;
}
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-2); margin-top: 6px; }
.chart-legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.range-picker { display: flex; gap: 6px; margin: 10px 0; }
.range-picker button { background: transparent; color: var(--ink-2); border: 1px solid var(--border); padding: 4px 12px; }
.range-picker button.active { color: var(--ink); border-color: var(--series-1); font-weight: 600; }

/* ---- Tabs (Admin) ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button {
  background: transparent; color: var(--ink-2); border: none; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 8px 14px;
}
.tabs button.active { color: var(--ink); border-bottom-color: var(--series-1); font-weight: 600; }

.pill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.pill { border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: 12px; color: var(--ink-2); }
.pill b { color: var(--ink); }

/* ---- Fleet-Übersicht (Stat-Kacheln) ---- */
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 4px 0 10px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 26px; font-weight: 600; margin: 4px 0 2px; line-height: 1.1; }
.stat .sub { color: var(--ink-2); font-size: 12px; }
.stat .sub .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 3px; vertical-align: 0; }
.dot.online { background: var(--good); } .dot.offline { background: var(--critical); }
.dot.pending { background: var(--warning); } .dot.revoked { background: var(--muted); }

/* ---- Temperatur-Card (Sensor-Balken) ---- */
.temp-row { margin: 8px 0; }
.temp-row .temp-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); margin-bottom: 3px; }
.temp-row .temp-head b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.temp-bar { position: relative; height: 8px; background: var(--grid); border-radius: 4px; overflow: hidden; }
.temp-bar > i { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--series-1); }
.temp-bar > i.warn { background: var(--warning); }
.temp-bar > i.crit { background: var(--critical); }

/* ---- Container-Zähler (farbcodiert) ---- */
.c-run { color: var(--good); }
.c-stop { color: var(--muted); }
.c-crash { color: var(--critical); font-weight: 600; }

/* ---- Responsive: Burger-Menü auf Smartphones ---- */
@media (max-width: 640px) {
  header.nav { flex-wrap: wrap; padding: 10px 16px; }
  .nav-toggle { display: block; margin-left: auto; }
  header.nav .nav-menu {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding-top: 8px;
  }
  header.nav.open .nav-menu { display: flex; }
  header.nav .nav-menu .spacer { display: none; }
  header.nav .nav-menu a { padding: 4px 0; }
  main { padding: 16px; }
}
