/* dashboard.kaikas.net
   Design uebernommen von expert.kaikas.net: weisser Grund, ein Akzentblau,
   Systemschrift, 6px Radien, Trennlinien statt Kaesten. Ergaenzt um die Rollen,
   die ein Dashboard zusaetzlich braucht (Kacheln, Diagramme, Status).

   Die Serienfarben sind eine validierte kategoriale Palette mit dem Akzent der
   Seite auf Platz 1 — geprueft auf Helligkeitsband, Buntheit, Farbfehlsichtigkeit
   und Kontrast, in hell wie dunkel. */

:root {
  --bg: #ffffff;
  --bg-alt: #f5f7fa;
  --fg: #1c2430;
  --fg-muted: #5a6472;
  --accent: #2166a5;
  --accent-soft: #cde2fb;
  --border: #e2e6ec;
  --max-width: 1180px;

  /* Diagrammflaeche und Text darauf */
  --surface: #ffffff;
  --grid: #e9edf2;
  --text-primary: #1c2430;
  --text-secondary: #5a6472;
  --text-muted: #8a94a3;

  /* kategoriale Serienfarben, feste Reihenfolge, nie zyklisch vergeben */
  --series-1: #2166a5;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;

  /* Status: reserviert, nie als "Serie 4" zweckentfremdet */
  --good: #157347;
  --warn: #b26a00;
  --bad: #c0392b;
  --good-bg: #e8f4ee;
  --warn-bg: #fdf3e2;
  --bad-bg: #fbeceb;
}

:root[data-theme="dark"] {
  --bg: #12161c;
  --bg-alt: #191e26;
  --fg: #eef1f5;
  --fg-muted: #a7b0bd;
  --accent: #3987e5;
  --accent-soft: #1d3350;
  --border: #2a323d;

  --surface: #161a20;
  --grid: #262e39;
  --text-primary: #eef1f5;
  --text-secondary: #a7b0bd;
  --text-muted: #7d8796;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;

  --good: #4cbf85;
  --warn: #e0a44a;
  --bad: #e8776a;
  --good-bg: #16281f;
  --warn-bg: #2b2114;
  --bad-bg: #2c1a18;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

/* ---------- Kopf und Navigation ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.9rem 1.5rem 0;
}

.brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand h1 {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.01em;
}
.brand h1 .hl { color: var(--accent); }

.brand-meta {
  color: var(--fg-muted);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.icon-btn {
  font: inherit;
  font-size: 0.82rem;
  color: var(--fg-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  margin-top: 0.7rem;
}

/* Auf schmalen Schirmen bleibt die Leiste einzeilig und wird gewischt —
   umgebrochen fraesse sie dort die halbe Seitenhoehe. */
@media (max-width: 640px) {
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
  }
}

.tab {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--fg-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--fg); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab img { width: 18px; height: 18px; object-fit: contain; }
:root[data-theme="dark"] .tab img { filter: brightness(1.6); }

/* ---------- Rumpf ---------- */

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.view-head { margin-bottom: 1.75rem; }

.view-head h2 {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0 0 0.6rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.view-head h2 .hl { color: var(--accent); }
.view-head h2 img { width: 26px; height: 26px; object-fit: contain; }
:root[data-theme="dark"] .view-head h2 img { filter: brightness(1.6); }

.view-head p {
  color: var(--fg-muted);
  margin: 0;
  font-size: 0.92rem;
}

.hero-img {
  width: 100%;
  height: 132px;
  object-fit: cover;
  object-position: center 45%;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 1.75rem;
  background: var(--bg-alt);
}
:root[data-theme="dark"] .hero-img { opacity: 0.85; }

section.block { margin-bottom: 2.5rem; }

h3.block-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  margin: 0 0 0.9rem;
  font-weight: 700;
}

/* ---------- Kacheln ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 1rem;
}

.tile {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.1rem 0.9rem;
  background: var(--bg);
  text-align: left;
  font: inherit;
  color: inherit;
  display: block;
  width: 100%;
}
button.tile { cursor: pointer; }
button.tile:hover { border-color: var(--accent); }

.tile-label {
  color: var(--fg-muted);
  font-size: 0.82rem;
  margin: 0 0 0.15rem;
}

.tile-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0;
}
.tile-value .unit {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fg-muted);
  margin-left: 0.25rem;
}

.tile-sub {
  color: var(--fg-muted);
  font-size: 0.8rem;
  margin: 0.2rem 0 0;
  min-height: 1.2em;
}

.delta { font-weight: 700; }
.delta.gut { color: var(--good); }
.delta.schlecht { color: var(--bad); }
.delta.neutral { color: var(--fg-muted); }

.hero-figure {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0;
}
.hero-figure .unit {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--fg-muted);
  margin-left: 0.35rem;
}

/* ---------- Diagramme ---------- */

.chart-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.1rem 1.2rem 0.9rem;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.2rem;
}

.chart-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
}
.chart-sub {
  color: var(--fg-muted);
  font-size: 0.82rem;
  margin: 0.1rem 0 0.8rem;
}

.legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 0.6rem;
}
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend i {
  width: 11px; height: 11px; border-radius: 3px; flex: none;
}

.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis-text { font-size: 11px; fill: var(--text-muted); }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .label-text { font-size: 11px; font-weight: 600; fill: var(--text-secondary); }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(16, 26, 40, 0.12);
  padding: 0.5rem 0.65rem;
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 5;
}
.tooltip.on { opacity: 1; }
.tooltip b { font-weight: 700; }
.tooltip .row { display: flex; align-items: center; gap: 0.45rem; }
.tooltip .row i { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.tooltip .val { font-variant-numeric: tabular-nums; }

.chart-tools {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.3rem;
}
.chart-tools button {
  font: inherit;
  font-size: 0.78rem;
  color: var(--fg-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.15rem 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.chart-tools button:hover { color: var(--accent); }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.25rem;
}

/* ---------- Tabellen und Listen ---------- */

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.data th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  font-weight: 700;
  padding: 0.4rem 0.6rem 0.4rem 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td {
  padding: 0.5rem 0.6rem 0.5rem 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  padding-right: 0;
}
table.data td.muted { color: var(--fg-muted); }

.rows { border-top: 1px solid var(--border); }
.row-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.row-item .sub { color: var(--fg-muted); font-size: 0.82rem; }
.row-item .num { font-variant-numeric: tabular-nums; white-space: nowrap; }

ul.checklist { list-style: none; margin: 0; padding: 0; }
ul.checklist li {
  position: relative;
  padding: 0.35rem 0 0.35rem 1.6rem;
  font-size: 0.92rem;
  border-bottom: 1px solid var(--border);
}
ul.checklist li:last-child { border-bottom: none; }
ul.checklist li::before {
  content: "";
  position: absolute;
  left: 0.15rem;
  top: 0.75em;
  width: 8px;
  height: 8px;
  border: 2px solid var(--accent);
  border-radius: 2px;
}
ul.checklist li.done { color: var(--fg-muted); text-decoration: line-through; }
ul.checklist li.done::before { background: var(--accent); }

/* ---------- Status ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  white-space: nowrap;
}
.pill.gut { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.neutral { background: var(--bg-alt); color: var(--fg-muted); }
.pill::before { content: "●"; font-size: 0.7em; }
.pill.gut::before { content: "✓"; }
.pill.bad::before { content: "✕"; }
.pill.warn::before { content: "!"; }

.meter {
  height: 8px;
  border-radius: 4px;
  background: var(--accent-soft);
  overflow: hidden;
  margin-top: 0.35rem;
}
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.meter.warn > i { background: var(--warn); }
.meter.bad > i { background: var(--bad); }

.note {
  font-size: 0.85rem;
  color: var(--fg-muted);
  border-left: 2px solid var(--border);
  padding-left: 0.8rem;
  margin: 1rem 0 0;
}
.note.hinweis { border-left-color: var(--accent); }
.note.fehler { border-left-color: var(--bad); color: var(--bad); }

.empty {
  text-align: center;
  color: var(--fg-muted);
  padding: 2rem 1rem;
}
.empty img { width: 130px; height: auto; opacity: 0.9; margin-bottom: 0.5rem; }

.cover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1.1rem;
}
.cover-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-alt);
}
.cover-card .t {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0.5rem 0 0;
  line-height: 1.35;
}
.cover-card .a { font-size: 0.78rem; color: var(--fg-muted); margin: 0.1rem 0 0; }

/* ---------- Login ---------- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-card img.art {
  width: 200px;
  height: auto;
  margin-bottom: 1.25rem;
  border-radius: 8px;
}
.login-card h1 {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0 0 0.35rem;
  letter-spacing: -0.01em;
}
.login-card h1 .hl { color: var(--accent); }
.login-card p.sub { color: var(--fg-muted); font-size: 0.9rem; margin: 0 0 1.6rem; }

.login-card form { display: flex; flex-direction: column; gap: 0.7rem; }
.login-card input {
  font: inherit;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
}
.login-card input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.login-card button {
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  padding: 0.7rem 1.3rem;
  cursor: pointer;
}
.login-card button:hover { opacity: 0.9; }
.login-error {
  background: var(--bad-bg);
  color: var(--bad);
  border-radius: 6px;
  padding: 0.55rem 0.8rem;
  font-size: 0.85rem;
  margin: 0;
}
.login-foot { color: var(--fg-muted); font-size: 0.78rem; margin-top: 1.5rem; }

/* ---------- Kleinkram ---------- */

.stale { color: var(--warn); }
.skeleton {
  background: linear-gradient(90deg, var(--bg-alt), var(--border), var(--bg-alt));
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: 6px;
  height: 1em;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  .tooltip { transition: none; }
}

@media (max-width: 640px) {
  main { padding: 1.5rem 1rem 3rem; }
  .topbar-inner { padding: 0.8rem 1rem 0; }
  .tile-value { font-size: 1.5rem; }
  .hero-figure { font-size: 2.25rem; }
  .hero-img { height: 96px; }
}

@media print {
  .topbar, .chart-tools { display: none; }
  main { max-width: none; }
}
