/* ancora-stats · Farben aus der Ancora-Marke: Navy #002169, Lime #93D500, Black #101820, Off-White #F6F6F4, Grey #D9D8D6 */
:root {
  color-scheme: light;
  --page: #F6F6F4;
  --surface: #FFFFFF;
  --surface-2: #EFEFEC;
  --line: #E4E3E0;
  --grid: #ECEBE8;
  --text: #101820;
  --text-2: #4A5260;
  --text-3: #6B7280;
  --accent: #002169;          /* Navy: Hauptlinie, Auswahl */
  --accent-wash: rgba(0, 33, 105, .10);
  --accent-ink: #FFFFFF;
  --lime: #93D500;
  --bar: rgba(0, 33, 105, .08);
  --good: #1E7A34;
  --bad: #B42318;
  --focus: #002169;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0C1218;
    --surface: #131C26;
    --surface-2: #1B2632;
    --line: #243140;
    --grid: #1E2935;
    --text: #F2F2EF;
    --text-2: #B8BFC9;
    --text-3: #8B95A3;
    --accent: #7D9BFF;
    --accent-wash: rgba(125, 155, 255, .12);
    --accent-ink: #0C1218;
    --bar: rgba(125, 155, 255, .12);
    --good: #5CC27A;
    --bad: #FF7A6E;
    --focus: #93D500;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--text);
  font: 15px/1.45 var(--font);
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ---------------------------------------------------------------- Kopf */
.top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.01em; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 5px; background: var(--accent);
  box-shadow: inset 0 -6px 0 var(--lime);
}
.sites { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.sites button {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid transparent; background: none; padding: 6px 12px; border-radius: 6px;
  cursor: pointer; color: var(--text-2); white-space: nowrap;
}
.sites button:hover { background: var(--surface-2); color: var(--text); }
.sites button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.sites .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px var(--surface); }
.sites button[aria-pressed="true"] .dot { box-shadow: 0 0 0 2px var(--accent-ink); }
.top-right { display: flex; align-items: center; gap: 16px; margin-left: auto; }
.top-right form { margin: 0; }
.live { font-size: 13px; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.live.on::before { background: var(--lime); box-shadow: 0 0 0 3px rgba(147, 213, 0, .25); }
.link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--text); }

/* ---------------------------------------------------------------- Filterzeile */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 16px 24px 0; max-width: 1280px; margin: 0 auto; }
.periods { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 3px; gap: 2px; flex-wrap: wrap; }
.periods button { border: 0; background: none; padding: 6px 10px; border-radius: 6px; cursor: pointer; color: var(--text-2); }
.periods button:hover { background: var(--surface-2); color: var(--text); }
.periods button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.custom { display: none; align-items: center; gap: 6px; }
.custom.on { display: inline-flex; }
.custom input { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px;
  background: var(--accent-wash); border-radius: 999px; font-size: 13px; max-width: 360px;
}
.chip b { font-weight: 600; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { border: 0; background: none; cursor: pointer; width: 22px; height: 22px; border-radius: 50%; color: var(--text-2); font-size: 15px; line-height: 1; }
.chip button:hover { background: var(--surface); color: var(--text); }

/* ---------------------------------------------------------------- Inhalt */
main { max-width: 1280px; margin: 0 auto; padding: 16px 24px 40px; }
main.loading .kpis, main.loading .card { opacity: .55; transition: opacity .15s; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 14px; font-weight: 600; margin: 0 0 12px; color: var(--text); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow); }
.kpi .label { font-size: 13px; color: var(--text-2); }
.kpi .value { font-size: 30px; font-weight: 650; letter-spacing: -.02em; margin: 2px 0 2px; }
.kpi .delta { font-size: 13px; color: var(--text-3); display: flex; align-items: center; gap: 4px; }
.kpi .delta.good { color: var(--good); }
.kpi .delta.bad { color: var(--bad); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; padding: 2px; }
.seg button { border: 0; background: none; padding: 4px 10px; border-radius: 4px; cursor: pointer; color: var(--text-2); font-size: 13px; }
.seg button.on { background: var(--surface-2); color: var(--text); font-weight: 600; }

.chart-card { margin-bottom: 12px; }
.chart { position: relative; height: 260px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .area { fill: var(--accent-wash); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .cross { stroke: var(--text-3); stroke-width: 1; shape-rendering: crispEdges; }
.chart .dotmark { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .empty { fill: var(--text-3); font-size: 13px; }
.tip {
  position: absolute; pointer-events: none; background: var(--text); color: var(--page);
  padding: 8px 10px; border-radius: 6px; font-size: 12px; line-height: 1.35; white-space: nowrap;
  transform: translate(-50%, -100%); margin-top: -10px; z-index: 3;
}
.tip strong { font-size: 15px; display: block; }
.tip .muted { opacity: .75; }
.chart-table { margin-top: 12px; max-height: 280px; overflow: auto; }
.legend { font-size: 12px; color: var(--text-3); margin-top: 6px; display: flex; justify-content: space-between; gap: 12px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid .wide { grid-column: 1 / -1; }

/* ---------------------------------------------------------------- Ranglisten */
.rows { list-style: none; margin: 0; padding: 0; }
.rows-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); padding: 0 8px 6px; }
.rows-head span:last-child { display: flex; gap: 16px; }
.row {
  position: relative; display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 6px 8px; border: 0; background: none; text-align: left;
  border-radius: 4px; cursor: pointer; min-height: 32px;
}
.row:hover { background: var(--surface-2); }
.row .fill { position: absolute; inset: 2px auto 2px 0; background: var(--bar); border-radius: 0 4px 4px 0; pointer-events: none; }
.row .name { position: relative; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.row .name > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.row .tag { flex: none; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--text-2); }
.row .num { position: relative; font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; }
.row .num.second { color: var(--text-3); min-width: 56px; }
.row .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.row .spark { position: relative; flex: none; width: 90px; height: 22px; }
.spark path { fill: none; stroke: var(--text-3); stroke-width: 1.5; stroke-linejoin: round; }
.more { margin-top: 6px; }
.none { color: var(--text-3); font-size: 13px; padding: 8px; margin: 0; }

.foot { color: var(--text-3); font-size: 12px; text-align: center; margin-top: 24px; }

table.plain { width: 100%; border-collapse: collapse; font-size: 13px; }
table.plain th, table.plain td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.plain th { color: var(--text-3); font-weight: 500; }
table.plain .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- System */
.system { display: grid; gap: 12px; max-width: 800px; }
.system dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.system dt { color: var(--text-2); }
.system dd { margin: 0; }
.system pre { background: var(--surface-2); padding: 10px 12px; border-radius: 6px; overflow: auto; font-size: 13px; }

/* ---------------------------------------------------------------- Anmeldung */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-box { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 28px; box-shadow: var(--shadow); }
.login-box h1 { font-size: 22px; margin: 20px 0 16px; }
.login-box form { display: grid; gap: 14px; }
.login-box label { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); }
.login-box input { background: var(--page); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; color: var(--text); }
.login-box button { margin-top: 6px; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 6px; padding: 11px; font-weight: 600; cursor: pointer; }
.login-box button:hover { filter: brightness(1.12); }
.error { background: rgba(180, 35, 24, .08); color: var(--bad); padding: 10px 12px; border-radius: 6px; margin: 0 0 14px; font-size: 14px; }

/* ---------------------------------------------------------------- schmal */
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .row .spark { display: none; }
}
@media (max-width: 560px) {
  .top { padding: 10px 16px; }
  .toolbar, main { padding-left: 16px; padding-right: 16px; }
  .kpi .value { font-size: 24px; }
  .kpi .delta .ctx { display: none; }
  .chart { height: 200px; }
  .sites { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
