:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --s1: #2a78d6; /* 3D Card */
  --s2: #eb6834; /* MathIQ */
  --s3: #1baf7a; /* SongGiftAI */
  --good: #0ca30c;
  --critical: #d03b3b;
  --good-text: #006300;
  --accent: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --good-text: #0ca30c; --accent: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --good-text: #0ca30c; --accent: #3987e5;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 600; }
button, select, input, .btn {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { border-color: var(--axis); }
button:focus-visible, select:focus-visible, input:focus-visible, .btn:focus-visible, .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.brand { display: flex; flex-direction: column; }
.brand span { color: var(--ink-2); font-size: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters label { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); }
.rangewrap { position: relative; }
.rangebtn { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; font-variant-numeric: tabular-nums; }
.rangebtn .chev { color: var(--muted); font-size: 11px; }
.pop[hidden] { display: none; }
.pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: flex; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18); overflow: hidden; }
.pop__presets { list-style: none; margin: 0; padding: 8px; border-right: 1px solid var(--grid); min-width: 130px; }
.pop__presets button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 6px; color: var(--ink-2); }
.pop__presets button:hover { background: var(--page); color: var(--ink); }
.pop__presets button.is-on { background: var(--ink); color: var(--surface); font-weight: 600; }
.pop__cal { padding: 10px 12px 10px; width: 300px; }
.cal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal__head button { border: 0; background: none; font-size: 18px; line-height: 1; padding: 2px 8px; color: var(--ink-2); }
.cal__months { font-weight: 600; }
.cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px 0; font-variant-numeric: tabular-nums; }
.cal__grid .dow { text-align: center; color: var(--muted); font-size: 11px; padding: 2px 0 4px; }
.cal__grid button { border: 0; background: none; padding: 0; height: 32px; color: var(--ink); border-radius: 0; font-size: 13px; }
.cal__grid button.other { color: var(--muted); opacity: 0.55; }
.cal__grid button.future { color: var(--muted); opacity: 0.35; cursor: default; }
.cal__grid button:not(.future):hover { background: var(--page); }
.cal__grid button.in { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.cal__grid button.start, .cal__grid button.end { background: var(--accent); color: #fff; font-weight: 600; }
.cal__grid button.start { border-radius: 8px 0 0 8px; }
.cal__grid button.end { border-radius: 0 8px 8px 0; }
.cal__grid button.start.end { border-radius: 8px; }
.cal__grid button.today { text-decoration: underline; text-underline-offset: 3px; }
.cal__foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }
@media (max-width: 640px) { .pop { position: fixed; left: 8px; right: 8px; top: 110px; flex-direction: column; } .pop__presets { display: flex; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--grid); } .pop__cal { width: auto; } }
button.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.tile__delta { font-size: 12px; margin-top: 4px; color: var(--ink-2); }
.tile__delta.up { color: var(--good-text); }
.tile__delta.down { color: var(--critical); }

.tabs { display: flex; gap: 4px; padding: 8px 16px 0; overflow-x: auto; border-bottom: 1px solid var(--border); background: var(--surface); }
.tab { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 10px; color: var(--ink-2); white-space: nowrap; }
.tab.is-on { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }

main { padding: 16px; max-width: 1200px; margin: 0 auto; }
.note { color: var(--ink-2); margin: 0 0 12px; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.tile__label { color: var(--ink-2); font-size: 12px; }
.tile__value { font-size: 24px; font-weight: 600; margin-top: 2px; }
.tile__sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.card__head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.card__head h2 { margin: 0; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--ink-2); font-size: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend i.line { height: 2px; border-radius: 1px; vertical-align: 3px; width: 14px; }

.chart { width: 100%; min-height: 220px; position: relative; }
.chart svg { display: block; width: 100%; height: 240px; overflow: visible; }
.chart .axis text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--axis); stroke-width: 1; }
.chart .empty { fill: var(--muted); font-size: 13px; }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--grid); fill-opacity: 0.5; }

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--ink-2); font-weight: 600; font-size: 12px; }
td.n, th.n { text-align: right; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

.funnel-row { display: grid; grid-template-columns: 110px 1fr 90px; gap: 10px; align-items: center; margin: 6px 0; }
.funnel-bar { height: 18px; background: var(--s1); border-radius: 0 4px 4px 0; min-width: 2px; }
.funnel-row span:last-child { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

.status-ok::before, .status-bad::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-ok::before { background: var(--good); }
.status-bad::before { background: var(--critical); }

.tip { position: fixed; z-index: 10; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); min-width: 140px; }
.tip b { display: block; margin-bottom: 4px; }
.tip div { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .top { padding: 12px 16px; }
  main { padding: 12px 16px; }
  .tile__value { font-size: 20px; }
  .funnel-row { grid-template-columns: 90px 1fr 70px; }
}
