/* Admin analytics. Colour roles from the validated reference palette (light/dark). */
:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --ink: #0b0b0b; --ink2: #52514e; --muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11, 11, 11, 0.10); --wash: rgba(11, 11, 11, 0.04);
  --accent: #2a78d6; --good: #006300; --critical: #d03b3b;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --o1: #86b6ef; --o2: #5598e7; --o3: #2a78d6; --o4: #1c5cab; --o5: #184f95;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --ink: #ffffff; --ink2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10); --wash: rgba(255, 255, 255, 0.05);
    --accent: #3987e5; --good: #0ca30c; --critical: #d03b3b;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --o1: #184f95; --o2: #1c5cab; --o3: #2a78d6; --o4: #5598e7; --o5: #86b6ef;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --ink: #ffffff; --ink2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10); --wash: rgba(255, 255, 255, 0.05);
  --accent: #3987e5; --good: #0ca30c; --critical: #d03b3b;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --o1: #184f95; --o2: #1c5cab; --o3: #2a78d6; --o4: #5598e7; --o5: #86b6ef;
}

* { box-sizing: border-box; }
body.admin { margin: 0; background: var(--page); color: var(--ink); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
.admin-header { display: flex; align-items: center; gap: 20px; padding: 16px 24px; border-bottom: 1px solid var(--border); background: var(--surface); }
.admin-brand { font-weight: 700; font-size: 22px; color: var(--ink); text-decoration: none; }
.admin-header h1 { font-size: 16px; font-weight: 600; margin: 0; color: var(--ink2); }
.admin-header nav { margin-left: auto; display: flex; gap: 16px; }
.admin-header nav a { color: var(--ink2); text-decoration: none; font-size: 13px; }
.admin-main { max-width: 1240px; margin: 0 auto; padding: 20px 24px 60px; }

.admin-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 20px; }
.admin-presets { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.admin-presets button { border: 0; background: none; color: var(--ink2); padding: 6px 12px; border-radius: 7px; font: inherit; font-size: 13px; cursor: pointer; }
.admin-presets button:hover { background: var(--wash); }
.admin-presets button[aria-checked="true"] { background: var(--ink); color: var(--surface); font-weight: 600; }
.admin-filters label { display: flex; align-items: center; gap: 6px; color: var(--ink2); font-size: 13px; }
.admin-filters input, .plan-form input, .plan-form select { font: inherit; font-size: 13px; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; }
.admin-apply, .plan-form button { font: inherit; font-size: 13px; font-weight: 600; border: 0; border-radius: 8px; padding: 7px 14px; background: var(--ink); color: var(--surface); cursor: pointer; }
.admin-status { font-size: 12px; color: var(--muted); }
#dashboard.loading { opacity: 0.55; transition: opacity 0.2s; }

.kpis { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi span { font-size: 12px; color: var(--ink2); }
.kpi strong { font-size: 28px; font-weight: 600; letter-spacing: -0.5px; }
.kpi-hero strong { font-size: 52px; line-height: 1.05; }
.kpi small { font-size: 12px; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px 22px; margin-bottom: 16px; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 12px; }
.card h2 { font-size: 16px; font-weight: 600; margin: 0; }
.card-head p, .card-note { margin: 0; font-size: 12px; color: var(--muted); }
.card h3 { font-size: 14px; font-weight: 600; margin: 22px 0 4px; }
.card-note { margin-bottom: 10px; }

.chart-legend { display: flex; min-width: 0; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px; font-size: 12px; color: var(--ink2); }
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.chart-key-line, .chart-tooltip .chart-key { width: 12px; height: 2px; border-radius: 1px; }
.chart-frame { position: relative; width: 100%; }
.chart-frame svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-empty { position: absolute; inset: 40% 0 auto; text-align: center; color: var(--muted); font-size: 13px; margin: 0; }
.chart-grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart-baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart-axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-hit { fill: transparent; cursor: default; outline: none; }
.chart-hit.active, .chart-hit:focus-visible { fill: var(--wash); }
.chart-tooltip { position: absolute; z-index: 50; display: none; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12); font-size: 12px; min-width: 140px; }
.chart-tooltip-title { color: var(--ink2); margin-bottom: 4px; }
.chart-tooltip-row { display: flex; align-items: center; gap: 6px; line-height: 1.7; }
.chart-tooltip-row strong { font-variant-numeric: tabular-nums; min-width: 44px; }
.chart-tooltip-row span:last-child { color: var(--ink2); }

.chart-table { margin-top: 8px; font-size: 12px; }
.chart-table summary { cursor: pointer; color: var(--ink2); width: max-content; }
.chart-table table, .data-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.chart-table table { margin-top: 8px; display: block; max-height: 280px; overflow: auto; max-width: 100%; }
.chart-table th, .chart-table td, .data-table th, .data-table td { padding: 6px 10px 6px 0; border-top: 1px solid var(--grid); text-align: right; white-space: nowrap; }
.chart-table th:first-child, .data-table th:first-child, .data-table td:first-child { text-align: left; }
.chart-table thead th, .data-table thead th { color: var(--muted); font-weight: 500; border-top: 0; }
.chart-table-total th, .chart-table-total td, .data-table tfoot td, .data-table tfoot th { font-weight: 600; }
.data-table { margin-top: 14px; font-size: 13px; }
.data-table .key-cell { display: inline-flex; align-items: center; gap: 8px; }
.data-table td.muted { color: var(--muted); }
.table-scroll { overflow-x: auto; }
.share-bar { display: inline-block; vertical-align: middle; height: 6px; border-radius: 3px; background: var(--s1); margin-right: 8px; }
.styles-table td small { color: var(--muted); margin-left: 4px; }

.plan-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.plan-tile { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.plan-tile span { font-size: 12px; color: var(--ink2); }
.plan-tile strong { display: block; font-size: 24px; font-weight: 600; }
.plan-tile small { color: var(--muted); font-size: 12px; }
.plan-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--grid); }
.plan-form h3 { width: 100%; margin: 0; }
.plan-form label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink2); }

.mini-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.mini-kpis div { border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; }
.mini-kpis span { font-size: 12px; color: var(--ink2); }
.mini-kpis strong { display: block; font-size: 22px; font-weight: 600; }
.mini-kpis small { font-size: 12px; color: var(--muted); }
.funnel-row { display: grid; grid-template-columns: 220px 1fr 120px; align-items: center; gap: 12px; padding: 6px 0; }
.funnel-label { font-size: 13px; color: var(--ink2); }
.funnel-label small { display: block; color: var(--muted); font-size: 11px; }
.funnel-track { height: 14px; }
.funnel-bar { height: 100%; min-width: 2px; border-radius: 0 4px 4px 0; }
.funnel-value { font-variant-numeric: tabular-nums; font-size: 13px; }
.funnel-value span { color: var(--muted); }

.edits-split { margin-bottom: 4px; }
.edits-bar { display: flex; height: 14px; gap: 2px; margin: 8px 0; }
.edits-bar div { min-width: 2px; }
.edits-bar div:first-child { border-radius: 4px 0 0 4px; }
.edits-bar div:last-child { border-radius: 0 4px 4px 0; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi-hero { grid-column: 1 / -1; }
  .plan-tiles, .mini-kpis { grid-template-columns: repeat(2, 1fr); }
  .funnel-row { grid-template-columns: 1fr 90px; }
  .funnel-track { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 560px) {
  .admin-header { padding: 12px 16px; gap: 12px; }
  .admin-header h1 { display: none; }
  .admin-main { padding: 16px 16px 48px; }
  .card { padding: 16px; }
  .kpi-hero strong { font-size: 44px; }
}

/* Оплати й звірка */
.pay-filters { margin-top: 0; padding-top: 0; border-top: 0; }
.pay-table td { white-space: normal; text-align: left; }
.pay-table th { text-align: left; }
.pay-table td.num { text-align: right; white-space: nowrap; }
.pay-table code { font-size: 12px; word-break: break-all; }
.pay-table button { font: inherit; font-size: 12px; border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; background: var(--surface); color: var(--ink); cursor: pointer; }
