/* Andromeda – BEE & I · dark-first, black with purple + blitzblau accents */
:root {
  color-scheme: light;
  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #f1f1f4;
  --ink: #0b0b0f;
  --ink-2: #52525b;
  --muted: #71717a;
  --grid: #ececf0;
  --axis: #d4d4d8;
  --line: rgba(11, 11, 15, 0.08);
  --purple: #7c3aed;
  --blue: #2563eb;
  --accent-grad: linear-gradient(90deg, #7c3aed, #2563eb);
  --on-accent: #ffffff;
  --wash: rgba(124, 58, 237, 0.07);
  --glow: transparent;
  --shadow: 0 1px 2px rgba(11, 11, 15, .04), 0 8px 24px rgba(11, 11, 15, .05);
  /* data colors – validated with validate_palette.js */
  --umsatz: #2563eb;
  --kosten: #d97706;
  --vj: #a1a1aa;
  --pipe: #7c3aed;
  --p1: #b6a3fa; --p2: #9b7bf7; --p3: #7c3aed; --p4: #4c1d95;
  --good: #047857;
  --bad: #dc2626;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09090b;
  --surface: #131317;
  --surface-2: #1b1b21;
  --ink: #f4f4f5;
  --ink-2: #a1a1aa;
  --muted: #8b8b94;
  --grid: #222229;
  --axis: #34343c;
  --line: rgba(255, 255, 255, 0.07);
  --purple: #8c6cf0;
  --blue: #4c86ff;
  --accent-grad: linear-gradient(90deg, #8b5cf6, #3d7bff);
  --on-accent: #ffffff;
  --wash: rgba(140, 108, 240, 0.07);
  --glow: radial-gradient(60% 50% at 15% 0%, rgba(124, 58, 237, .22), transparent 70%), radial-gradient(50% 40% at 90% 5%, rgba(61, 123, 255, .16), transparent 70%);
  --shadow: none;
  --umsatz: #4c86ff;
  --kosten: #d27a1e;
  --vj: #6b6b76;
  --pipe: #8c6cf0;
  --p1: #4b3a8f; --p2: #6a50c9; --p3: #8c6cf0; --p4: #b9a2ff;
  --good: #34d399;
  --bad: #f87171;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
.glow { position: fixed; inset: 0 0 auto 0; height: 520px; background: var(--glow); pointer-events: none; z-index: 0; }
body > *:not(.glow) { position: relative; z-index: 1; }
body > .top { position: sticky; z-index: 10; }
body.loading #dash { opacity: .55; transition: opacity .2s; }
button, select { font: inherit; color: inherit; }

/* logo per theme */
.logo { display: block; height: 40px; width: auto; }
.logo-light { display: none; }
:root:not([data-theme="dark"]) .logo-dark { display: none; }
:root:not([data-theme="dark"]) .logo-light { display: block; }
.logo.big { height: 72px; margin: 0 auto 20px; }

/* ---------- header */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(140%) blur(12px); -webkit-backdrop-filter: saturate(140%) blur(12px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  top: 0;
}
.top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--accent-grad); opacity: .6; }
.brand { display: flex; align-items: center; gap: 14px; }
.divider { width: 1px; height: 32px; background: var(--line); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.product { font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.tagline { font-size: 12px; color: var(--ink-2); }
.who { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.demo { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; color: var(--purple); background: var(--wash); border: 1px solid color-mix(in srgb, var(--purple) 35%, transparent); }
.icon-btn { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: grid; place-items: center; color: var(--ink-2); padding: 0; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--surface-2); }
.user { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.user select { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; max-width: 220px; }

/* ---------- filters */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding: 18px clamp(16px, 4vw, 40px) 8px; max-width: 1440px; margin: 0 auto; }
.filter { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.segs { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; flex-wrap: wrap; gap: 2px; }
.seg { border: 0; background: transparent; padding: 6px 14px; border-radius: 9px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--ink-2); transition: background .15s, color .15s; }
.seg:hover { background: var(--surface-2); color: var(--ink); }
.seg.on { background: var(--accent-grad); color: var(--on-accent); font-weight: 600; }
.seg:focus-visible, .tbl-toggle:focus-visible, select:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.lock { font-size: 13px; color: var(--ink-2); }
.lock::before { content: "🔒 "; }
.stand { margin-left: auto; font-size: 13px; color: var(--muted); }

/* ---------- layout */
main { padding: 4px clamp(16px, 4vw, 40px) 32px; max-width: 1440px; margin: 0 auto; }
.scope { font-weight: 800; font-size: clamp(24px, 3.2vw, 34px); letter-spacing: -.03em; margin: 10px 0 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px 14px; min-width: 0; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.tile-label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.tile-value { font-size: clamp(24px, 2.4vw, 30px); font-weight: 700; letter-spacing: -.03em; margin: 4px 0 6px; }
.tile-delta { font-size: 13px; font-weight: 600; }
.tile-delta.good { color: var(--good); }
.tile-delta.bad { color: var(--bad); }
.tile-delta.neutral { color: var(--ink-2); }
.tile-note { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.spark { display: block; width: 100%; height: 34px; margin-top: auto; padding-top: 10px; overflow: visible; box-sizing: content-box; }
.spark path { fill: none; stroke: var(--vj); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { stroke: var(--surface); stroke-width: 2; }
.spark circle.s-umsatz { fill: var(--umsatz); } .spark circle.s-kosten { fill: var(--kosten); } .spark circle.s-ergebnis { fill: var(--purple); }

.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px 20px 20px; min-width: 0; box-shadow: var(--shadow); }
.card.wide { grid-column: 1 / -1; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.card h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.card-sub { margin: 2px 0 0; font-size: 13px; color: var(--ink-2); }
.tbl-toggle { flex: none; border: 1px solid var(--line); background: var(--surface-2); border-radius: 9px; padding: 4px 12px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--ink-2); }
.tbl-toggle:hover { color: var(--ink); }
.card-body { position: relative; }
.card .table-wrap.alt { display: none; }
.card.show-table .table-wrap.alt { display: block; }
.card.show-table .chart, .card.show-table .legend { display: none; }

@media (max-width: 860px) { .cards { grid-template-columns: minmax(0, 1fr); } .stand { margin-left: 0; } }

/* ---------- legend */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; flex: none; }
.key.line { width: 16px; height: 2px; border-radius: 1px; }
.key.rect { width: 10px; height: 10px; border-radius: 3px; }
.key.s-umsatz { background: var(--umsatz); } .key.s-kosten { background: var(--kosten); } .key.s-vj { background: var(--vj); }
.key.s-pipe { background: var(--pipe); }
.key.p1 { background: var(--p1); } .key.p2 { background: var(--p2); } .key.p3 { background: var(--p3); } .key.p4 { background: var(--p4); }

/* ---------- charts */
.chart { position: relative; width: 100%; min-height: 40px; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .vlabel { fill: var(--ink-2); font-size: 12px; font-weight: 600; }
.chart .band { fill: var(--wash); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.muted { stroke-width: 1.5; }
.chart .line.s-umsatz { stroke: var(--umsatz); } .chart .line.s-kosten { stroke: var(--kosten); } .chart .line.s-vj { stroke: var(--vj); }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .dot.s-umsatz { fill: var(--umsatz); } .chart .dot.s-kosten { fill: var(--kosten); } .chart .dot.s-vj { fill: var(--vj); }
.chart .cross { stroke: var(--axis); stroke-width: 1; }
.chart .bar.s-pipe { fill: var(--pipe); }
.chart .hit { outline: none; }
.chart .hit.on, .chart .hit:focus-visible { fill: var(--wash); }

.hbars { display: flex; flex-direction: column; gap: 4px; }
.hbar { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; align-items: center; gap: 12px; padding: 7px 6px; border-radius: 10px; outline: none; }
.hbar:hover, .hbar:focus-visible { background: var(--wash); }
.hbar-label { display: flex; flex-direction: column; min-width: 0; font-size: 14px; font-weight: 500; }
.hbar-label small { color: var(--ink-2); font-size: 12px; font-weight: 400; }
.hbar-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hbar-fill { height: 16px; border-radius: 0 4px 4px 0; flex: none; }
.hbar-fill.p1 { background: var(--p1); } .hbar-fill.p2 { background: var(--p2); } .hbar-fill.p3 { background: var(--p3); } .hbar-fill.p4 { background: var(--p4); }
.hbar-fill.s-kosten { background: var(--kosten); }
.hbar-value { font-size: 13px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* tooltip */
.tip {
  display: none; position: absolute; z-index: 4; pointer-events: none; min-width: 180px;
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .25); padding: 9px 11px; font-size: 13px;
}
.tip-title { font-weight: 700; margin-bottom: 4px; }
.tip-row { display: grid; grid-template-columns: 14px auto 1fr; align-items: center; gap: 6px; }
.tip-row strong { font-variant-numeric: tabular-nums; }
.tip-label { color: var(--ink-2); }
.tip-key { width: 12px; height: 2px; border-radius: 1px; }
.tip-key.none { background: transparent; }
.tip-key.rect { width: 10px; height: 10px; border-radius: 3px; }
.tip-key.s-umsatz { background: var(--umsatz); } .tip-key.s-kosten { background: var(--kosten); } .tip-key.s-vj { background: var(--vj); }
.tip-key.s-pipe { background: var(--pipe); }
.tip-key.p1 { background: var(--p1); } .tip-key.p2 { background: var(--p2); } .tip-key.p3 { background: var(--p3); } .tip-key.p4 { background: var(--p4); }

/* ---------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; font-size: 11px; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--axis); white-space: nowrap; text-transform: uppercase; letter-spacing: .05em; }
td { padding: 9px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
tbody tr:hover td { background: var(--wash); }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.empty { color: var(--muted); text-align: center; padding: 18px; }
.chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.status { white-space: nowrap; }
.status.bad { color: var(--bad); font-weight: 600; }
.firm { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); }

/* ---------- no access + footer */
.noaccess { max-width: 560px; margin: 14vh auto; padding: 0 16px; text-align: center; }
.noaccess h2 { font-size: 28px; font-weight: 800; letter-spacing: -.03em; margin: 0 0 8px; }
.noaccess p { font-size: 16px; }
.muted { color: var(--ink-2); font-size: 14px !important; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 8px 16px 28px; }

@media (max-width: 520px) {
  .user span { display: none; }
  .divider, .tagline { display: none; }
  .hbar { grid-template-columns: 1fr; gap: 4px; }
  .seg { padding: 6px 11px; }
}
@media (forced-colors: active) {
  .hbar-fill, .chart .bar { forced-color-adjust: none; }
  .seg.on { outline: 2px solid; }
}
