:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --border: #e4e3df;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --accent: #2a78d6;
  --accent-soft: rgba(42, 120, 214, .12);
  --bar: rgba(42, 120, 214, .13);
  --prev: #a9a8a2;
  --grid: #ecebe7;
  --good: #1a7f37;
  --bad: #c4312f;
  --heat-0: #f0f0ed;
  --s1: #cde2fb; --s2: #9ec5f4; --s3: #6da7ec; --s4: #3987e5; --s5: #256abf; --s6: #104281;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --border: #2c2c2a;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e88;
    --accent: #3987e5;
    --accent-soft: rgba(57, 135, 229, .18);
    --bar: rgba(57, 135, 229, .2);
    --prev: #6b6a65;
    --grid: #262624;
    --good: #4cb867;
    --bad: #e66767;
    --heat-0: #232321;
    --s1: #0d366b; --s2: #184f95; --s3: #256abf; --s4: #3987e5; --s5: #6da7ec; --s6: #b7d3f6;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); padding: 8px 12px; border-radius: 8px; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 11l3-3 2 2 5-5' stroke='white' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/16px no-repeat, linear-gradient(100deg, #12b9bf, #a116bf); }

/* Login – Design wie rechnung.agile-unternehmen.de */
.login-page {
  min-height: 100vh; color: #121418; -webkit-font-smoothing: antialiased;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at 15% 10%, rgba(20, 185, 191, .13), transparent 32%), radial-gradient(circle at 90% 85%, rgba(163, 23, 191, .12), transparent 34%), #f2f3f5;
  color-scheme: light;
}
.login-shell { min-height: 100vh; padding: 32px 18px; display: grid; place-items: center; }
.login-card { width: min(440px, 100%); padding: 42px; border: 1px solid #dedfe4; border-radius: 22px; background: #fff; box-shadow: 0 24px 60px rgba(28, 30, 39, .08); }
.login-card img { display: block; width: 255px; max-width: 100%; margin: 0 0 36px; }
.login-card .eyebrow { margin: 0 0 10px; color: #75128d; font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.login-card h1 { margin: 0 0 14px; font-size: 36px; line-height: 1.05; letter-spacing: -.04em; }
.login-card > p:not(.eyebrow) { margin: 0 0 24px; color: #62666f; font-size: 14px; line-height: 1.55; }
.login-card .login-err { color: #a3293d !important; background: rgba(163, 41, 61, .08); padding: 10px 14px; border-radius: 10px; }
.login-card .field { display: grid; gap: 8px; margin-bottom: 20px; }
.login-card .field > span { font-size: 12px; font-weight: 750; letter-spacing: .015em; }
.login-card input { width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid #d5d7dc; border-radius: 10px; color: #121418; background: #fafafa; outline: none; transition: border-color .18s, box-shadow .18s, background .18s; }
.login-card input:focus { border-color: #a317bf; background: #fff; box-shadow: 0 0 0 4px rgba(163, 23, 191, .09); }
.primary-button { width: 100%; min-height: 53px; border: 0; border-radius: 11px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; color: #fff; font-weight: 750; cursor: pointer; background: linear-gradient(100deg, #12b9bf, #a116bf); box-shadow: 0 12px 28px rgba(115, 21, 154, .2); transition: transform .15s, box-shadow .15s; }
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 16px 34px rgba(115, 21, 154, .27); }
@media (max-width: 480px) { .login-card { padding: 28px 22px; } }

/* Kopfzeile */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 12px max(16px, calc((100vw - 1200px) / 2)); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.top select, .top input { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
#site { font-weight: 600; max-width: 100%; }
.range { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.custom input { width: 140px; }
.live { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 12px; cursor: pointer; color: var(--text-2); }
.live b { color: var(--text); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 50%, transparent); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.logout { color: var(--muted); text-decoration: none; font-size: 13px; }
.logout:hover { color: var(--text); }

.wrap { max-width: 1200px; margin: 0 auto; padding: 18px 16px 40px; display: grid; gap: 16px; }

/* Filter-Chips */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--text); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 13px; max-width: 100%; }
.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); }
.chip button:hover { background: var(--surface); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.kpi { padding: 14px 16px; border: 0; border-right: 1px solid var(--border); background: none; text-align: left; display: grid; gap: 2px; }
.kpi:last-child { border-right: 0; }
.kpi[data-metric] { cursor: pointer; }
.kpi[data-metric]:hover { background: var(--bg); }
.kpi.on { box-shadow: inset 0 -3px 0 var(--accent); }
.kpi .k-label { font-size: 12px; color: var(--text-2); }
.kpi .k-val { font-size: 24px; font-weight: 650; letter-spacing: -.02em; }
.kpi .k-delta { font-size: 12px; color: var(--muted); }
.k-delta.up { color: var(--good); }
.k-delta.down { color: var(--bad); }

/* Karten */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card h2 { font-size: 15px; margin: 0; font-weight: 650; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.tabs { display: flex; gap: 2px; background: var(--bg); border-radius: 8px; padding: 2px; }
.tabs button { border: 0; background: none; padding: 4px 10px; border-radius: 6px; font-size: 12px; color: var(--text-2); cursor: pointer; }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 14px; height: 0; border-top: 2px solid var(--accent); vertical-align: middle; margin-right: 6px; }
.legend i.prev { border-top: 2px dashed var(--prev); }

/* Chart */
.chart { position: relative; height: 260px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .gl { stroke: var(--grid); }
.chart .ax { fill: var(--muted); font-size: 11px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent-soft); }
.chart .pline { fill: none; stroke: var(--prev); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .cross { stroke: var(--text-2); stroke-width: 1; }
.chart .pt { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.empty { display: grid; place-items: center; height: 100%; color: var(--muted); }

/* Listen */
.list { display: grid; gap: 2px; }
.lh, .row { display: grid; grid-template-columns: minmax(0, 1fr) 72px 72px; gap: 8px; align-items: center; }
.lh { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 0 8px 4px; }
.lh span, .row .n { text-align: right; }
.row { position: relative; padding: 6px 8px; border-radius: 6px; cursor: pointer; min-height: 32px; }
.row:hover { background: var(--bg); }
.row .bar { position: absolute; inset: 2px auto 2px 0; background: var(--bar); border-radius: 6px; pointer-events: none; }
.row .lbl { position: relative; min-width: 0; display: flex; align-items: center; gap: 8px; }
.row .lbl .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .lbl .sub { display: block; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .lbl .tx { min-width: 0; }
.row .n { position: relative; }
.row .n.dim { color: var(--text-2); }
.row a.ext { color: var(--muted); text-decoration: none; opacity: 0; font-size: 12px; }
.row:hover a.ext { opacity: 1; }
.more { margin-top: 6px; border: 0; background: none; color: var(--accent); cursor: pointer; padding: 6px 8px; font-size: 13px; }
.none { color: var(--muted); padding: 18px 8px; text-align: center; }
.flag { font-size: 16px; line-height: 1; }

/* Heatmap */
.heat { display: grid; grid-template-columns: 28px repeat(24, minmax(0, 1fr)); gap: 3px; font-size: 11px; color: var(--muted); }
.heat .c { aspect-ratio: 1.6; border-radius: 3px; background: var(--heat-0); min-height: 12px; }
.heat .hl { text-align: center; }
.heat .dl { align-self: center; }

.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.12); max-width: 280px; }
.tip b { font-weight: 650; }
.tip .tr { display: flex; justify-content: space-between; gap: 14px; }

dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); width: min(560px, calc(100vw - 32px)); padding: 16px; }
dialog::backdrop { background: rgba(0,0,0,.3); }
.x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.foot { text-align: center; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi:nth-child(3) { border-right: 0; }
  .kpi:nth-child(-n+3) { border-bottom: 1px solid var(--border); }
  .grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { border-right: 1px solid var(--border) !important; border-bottom: 1px solid var(--border); }
  .kpi:nth-child(2n) { border-right: 0 !important; }
  .kpi .k-val { font-size: 20px; }
  .live { margin-left: 0; }
  .lh, .row { grid-template-columns: minmax(0, 1fr) 56px 56px; }
  .heat { grid-template-columns: 24px repeat(24, minmax(0, 1fr)); gap: 1px; }
  .heat .hl:nth-child(odd) { visibility: hidden; }
}
.foot a { color: inherit; }
