/* Marketing panel — design tokens follow the validated data-viz palette (light + dark, selected per mode). */
:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --raised: #ffffff; --ink: #0b0b0b; --ink2: #52514e; --muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11,11,11,.10); --wash: rgba(11,11,11,.045);
  --accent: #256abf; --accent-ink: #ffffff; --accent-soft: #e6f0fb;
  --s0: #9a9890; --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b; --good-text: #006300; --bad-text: #b32d2d;
  --shadow: 0 1px 2px rgba(11,11,11,.05), 0 6px 18px rgba(11,11,11,.04);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --raised: #222221; --ink: #ffffff; --ink2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,.10); --wash: rgba(255,255,255,.06);
    --accent: #3987e5; --accent-ink: #0b0b0b; --accent-soft: #14263d;
    --s0: #6f6e68; --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --good-text: #0ca30c; --bad-text: #ec6a6a; --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --raised: #222221; --ink: #ffffff; --ink2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,.10); --wash: rgba(255,255,255,.06);
  --accent: #3987e5; --accent-ink: #0b0b0b; --accent-soft: #14263d;
  --s0: #6f6e68; --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --good-text: #0ca30c; --bad-text: #ec6a6a; --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 15px; }
.sub { margin: 2px 0 0; color: var(--ink2); font-size: 13px; }
.strong { font-weight: 650; } .muted { color: var(--muted); } .r { text-align: right; } .nowrap { white-space: nowrap; }
.ic { width: 18px; height: 18px; flex: none; }

/* shell */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 14px; background: var(--surface); border-right: 1px solid var(--border); }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; }
.brand b { display: block; font-size: 15px; } .brand small { color: var(--muted); font-size: 12px; }
.logo { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a, .side-foot .ghost { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--ink2); font-weight: 500; background: none; border: 0; cursor: pointer; font: inherit; text-align: left; width: 100%; }
.side nav a:hover, .side-foot .ghost:hover { background: var(--wash); text-decoration: none; color: var(--ink); }
.side nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--border); padding-top: 10px; }
.main { padding: 22px 28px 60px; min-width: 0; max-width: 1480px; width: 100%; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 16px; }
.filters .hint { color: var(--muted); font-size: 12px; }
details.dd { position: relative; }
details.dd > summary { list-style: none; display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; cursor: pointer; font-weight: 600; }
details.dd > summary::-webkit-details-marker { display: none; }
details.dd > summary em { font-style: normal; color: var(--muted); font-weight: 400; font-size: 12.5px; }
details.dd[open] > summary { border-color: var(--accent); }
.menu { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; min-width: 250px; background: var(--raised); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 34px rgba(0,0,0,.18); padding: 6px; }
.menu a { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; color: var(--ink); } .menu a:hover { background: var(--wash); text-decoration: none; }
.menu a.on { font-weight: 700; } .menu a i, .menu a .ic { width: 16px; height: 16px; } .menu a .ic { stroke-width: 2.6; }
.menu .custom { display: flex; gap: 8px; align-items: flex-end; margin: 6px 4px 2px; padding-top: 10px; border-top: 1px solid var(--border); }
.menu .custom label { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 3px; flex: 1; }
.seg { display: inline-flex; background: var(--wash); border-radius: 9px; padding: 3px; }
.seg a, .viewswitch button { padding: 5px 12px; border-radius: 7px; color: var(--ink2); font-weight: 600; font-size: 13px; border: 0; background: none; cursor: pointer; font-family: inherit; }
.seg a:hover { text-decoration: none; color: var(--ink); } .seg a.on, .viewswitch button.on { background: var(--raised); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

/* cards + grid */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px 18px; box-shadow: var(--shadow); min-width: 0; }
.card + .card, .grid + .card, .card + .grid, .kpis + .card, .kpis + .grid { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-actions { display: flex; gap: 8px; align-items: center; }
.grid { display: grid; gap: 16px; } .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } .g12 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }

/* KPI */
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.kpi { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px 12px; min-height: 112px; overflow: hidden; }
.kpi-label { color: var(--ink2); font-size: 12.5px; font-weight: 550; }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin: 2px 0 3px; }
.kpi.hero { grid-column: span 2; } .kpi.hero .kpi-value { font-size: 48px; line-height: 1.1; }
.kpi-hint { color: var(--muted); font-size: 12px; } .kpi-spark { position: absolute; right: 12px; bottom: 10px; }
.spark { width: 96px; height: 28px; } .spark polyline { fill: none; stroke: var(--muted); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; opacity: .7; } .spark circle { fill: var(--s1); stroke: var(--surface); stroke-width: 2; }
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 650; } .delta .ic { width: 13px; height: 13px; stroke-width: 2.6; } .delta em { font-style: normal; font-weight: 400; color: var(--muted); }
.delta.good { color: var(--good-text); } .delta.bad { color: var(--bad-text); } .delta.none { color: var(--muted); font-weight: 400; }

/* charts */
.chartbox { position: relative; padding-top: 34px; }
.viewswitch { position: absolute; right: 0; top: 0; display: inline-flex; background: var(--wash); border-radius: 9px; padding: 3px; z-index: 2; }
.view[hidden] { display: none; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; padding: 0; margin: 0 0 8px; color: var(--ink2); font-size: 12.5px; max-width: 100%; }
.legend li { display: flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--s0); flex: none; }
.sw.s1 { background: var(--s1); } .sw.s2 { background: var(--s2); } .sw.s3 { background: var(--s3); } .sw.s4 { background: var(--s4); } .sw.s5 { background: var(--s5); } .sw.s6 { background: var(--s6); } .sw.s7 { background: var(--s7); } .sw.s8 { background: var(--s8); }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; } .chart-svg .axis { stroke: var(--axis); stroke-width: 1; }
.chart-svg text { fill: var(--muted); font-size: 11.5px; font-family: inherit; }
.chart-svg .seg { fill: var(--s0); } .seg.s1 { fill: var(--s1); } .seg.s2 { fill: var(--s2); } .seg.s3 { fill: var(--s3); } .seg.s4 { fill: var(--s4); } .seg.s5 { fill: var(--s5); } .seg.s6 { fill: var(--s6); } .seg.s7 { fill: var(--s7); } .seg.s8 { fill: var(--s8); }
.chart-svg .line { fill: none; stroke: var(--s0); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line.s1 { stroke: var(--s1); } .line.s2 { stroke: var(--s2); } .line.s3 { stroke: var(--s3); } .line.s4 { stroke: var(--s4); } .line.s5 { stroke: var(--s5); } .line.s6 { stroke: var(--s6); } .line.s7 { stroke: var(--s7); } .line.s8 { stroke: var(--s8); }
.chart-svg .dot { fill: var(--s0); stroke: var(--surface); stroke-width: 2; }
.dot.s1 { fill: var(--s1); } .dot.s2 { fill: var(--s2); } .dot.s3 { fill: var(--s3); } .dot.s4 { fill: var(--s4); } .dot.s5 { fill: var(--s5); } .dot.s6 { fill: var(--s6); } .dot.s7 { fill: var(--s7); } .dot.s8 { fill: var(--s8); }
.chart-svg .hit { fill: transparent; outline: none; cursor: default; } .chart-svg .hit:hover, .chart-svg .hit:focus { fill: var(--wash); }
.chart-svg .xhair { stroke: var(--axis); stroke-width: 1; pointer-events: none; display: none; } .chart-svg .xhair.on { display: inline; }
.tooltip { position: fixed; z-index: 100; pointer-events: none; min-width: 170px; max-width: 280px; background: var(--raised); color: var(--ink); border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; box-shadow: 0 10px 30px rgba(0,0,0,.22); font-size: 12.5px; }
.tooltip .t { color: var(--ink2); margin-bottom: 5px; font-size: 12px; } .tooltip .row { display: flex; align-items: center; gap: 8px; padding: 2px 0; } .tooltip .key { width: 12px; height: 2px; border-radius: 2px; background: var(--s0); flex: none; }
.tooltip .key.s1 { background: var(--s1); } .tooltip .key.s2 { background: var(--s2); } .tooltip .key.s3 { background: var(--s3); } .tooltip .key.s4 { background: var(--s4); } .tooltip .key.s5 { background: var(--s5); } .tooltip .key.s6 { background: var(--s6); } .tooltip .key.s7 { background: var(--s7); } .tooltip .key.s8 { background: var(--s8); }
.tooltip .v { font-weight: 700; margin-left: auto; padding-left: 10px; } .tooltip .n { color: var(--ink2); } .tooltip .tot { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 5px; display: flex; justify-content: space-between; font-weight: 700; }
.empty { color: var(--muted); padding: 26px 0; text-align: center; }

/* tables */
.tablewrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th { text-align: left; font-size: 11.5px; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
table.data th a { color: inherit; } table.data th.r { text-align: right; }
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; } table.data tbody tr:hover td { background: var(--wash); }
table.data.compact td, table.data.compact th { padding: 6px 8px; font-size: 12.5px; }
table.data td.name { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barcell { position: relative; min-width: 90px; } .barcell .bar { position: absolute; left: 0; top: 50%; height: 6px; transform: translateY(-50%); border-radius: 3px; background: var(--s1); opacity: .22; max-width: 100%; }
.chip { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--wash); color: var(--ink2); }
.pill.good { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good-text); } .pill.bad { background: color-mix(in srgb, var(--critical) 14%, transparent); color: var(--bad-text); } .pill.warn { background: color-mix(in srgb, var(--warning) 22%, transparent); color: var(--ink); } .pill .ic { width: 13px; height: 13px; stroke-width: 2.4; }

/* forms */
.form { display: grid; gap: 14px; } .row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; } .row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; } .row4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
label.f { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 12.5px; color: var(--ink2); }
label.f small { font-weight: 400; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=email], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; background: var(--raised); color: var(--ink); border: 1px solid var(--border); border-radius: 9px; font: inherit; }
textarea { min-height: 78px; resize: vertical; } input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input.cost { max-width: 120px; text-align: right; }
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 9px; border: 1px solid transparent; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 650; cursor: pointer; }
.btn:hover { filter: brightness(1.06); text-decoration: none; } .btn.small { padding: 6px 12px; font-size: 13px; } .btn.sec { background: var(--raised); color: var(--ink); border-color: var(--border); } .btn.danger { background: var(--critical); color: #fff; } .btn.linkish { background: none; color: var(--accent); padding: 4px 6px; }
.formbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.flash { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 10px; margin: 0 0 14px; border: 1px solid var(--border); background: var(--surface); }
.flash.ok { border-left: 4px solid var(--good); } .flash.err { border-left: 4px solid var(--critical); } .flash.info { border-left: 4px solid var(--accent); }
.callout { display: flex; gap: 10px; padding: 11px 14px; border-radius: 10px; background: var(--accent-soft); color: var(--ink); font-size: 13px; } .callout.warn { background: color-mix(in srgb, var(--warning) 18%, var(--surface)); }
.steps { margin: 6px 0 0; padding-left: 18px; color: var(--ink2); } .steps li { margin: 3px 0; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--wash); padding: 1px 6px; border-radius: 5px; word-break: break-all; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; } .tabs a { padding: 7px 14px; border-radius: 9px; color: var(--ink2); font-weight: 600; } .tabs a.on { background: var(--accent-soft); color: var(--accent); } .tabs a:hover { text-decoration: none; background: var(--wash); }
.platform { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: var(--surface); } .platform header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; } .platform h3 { font-size: 14.5px; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--page); }
.auth .box { width: 100%; max-width: 390px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth h1 { font-size: 21px; margin: 10px 0 4px; } .auth .logo { width: 44px; height: 44px; border-radius: 12px; }

@media (max-width: 1100px) { .g3, .g21, .g12 { grid-template-columns: minmax(0, 1fr); } .kpi.hero { grid-column: span 1; } .row4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 6px; }
  .brand { padding: 0 8px 0 0; } .side nav { flex-direction: row; flex-wrap: wrap; } .side nav a span { display: none; } .side nav a { padding: 8px; width: auto; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; border: 0; padding: 0; } .side-foot .ghost span { display: none; } .side-foot .ghost { width: auto; }
  .main { padding: 16px 14px 50px; } .g2, .row2, .row3 { grid-template-columns: minmax(0, 1fr); } .legend { max-width: 100%; } .viewswitch { position: static; margin-bottom: 8px; }
}
@media print { .side, .filters, .viewswitch { display: none; } .shell { display: block; } body { background: #fff; } }

/* meters (width classes keep the CSP free of inline styles) */
.meter { margin: 6px 0 12px; } .meter-top { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink2); margin-bottom: 5px; } .meter-top b { color: var(--ink); }
.meter-track { height: 8px; background: var(--accent-soft); border-radius: 99px; overflow: hidden; } .meter-fill { height: 100%; border-radius: 99px; background: var(--accent); } .meter-fill.warn { background: var(--warning); } .meter-fill.bad { background: var(--serious); } .meter-fill.good { background: var(--good); }
.meter-fill.w0{width:0%}.meter-fill.w5{width:5%}.meter-fill.w10{width:10%}.meter-fill.w15{width:15%}.meter-fill.w20{width:20%}.meter-fill.w25{width:25%}.meter-fill.w30{width:30%}.meter-fill.w35{width:35%}.meter-fill.w40{width:40%}.meter-fill.w45{width:45%}.meter-fill.w50{width:50%}.meter-fill.w55{width:55%}.meter-fill.w60{width:60%}.meter-fill.w65{width:65%}.meter-fill.w70{width:70%}.meter-fill.w75{width:75%}.meter-fill.w80{width:80%}.meter-fill.w85{width:85%}.meter-fill.w90{width:90%}.meter-fill.w95{width:95%}.meter-fill.w100{width:100%}
.bar.w0{width:0}
.bar.w0{width:0%}.bar.w5{width:5%}.bar.w10{width:10%}.bar.w15{width:15%}.bar.w20{width:20%}.bar.w25{width:25%}.bar.w30{width:30%}.bar.w35{width:35%}.bar.w40{width:40%}.bar.w45{width:45%}.bar.w50{width:50%}.bar.w55{width:55%}.bar.w60{width:60%}.bar.w65{width:65%}.bar.w70{width:70%}.bar.w75{width:75%}.bar.w80{width:80%}.bar.w85{width:85%}.bar.w90{width:90%}.bar.w95{width:95%}.bar.w100{width:100%}

/* narrow tables + mobile charts */
.grid.g2 table.data.compact td.name { max-width: 200px; }
table.data td.name a { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 860px) { .view-chart { overflow-x: auto; } .chart-svg { min-width: 640px; } .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpi.hero { grid-column: span 2; } }
.card-actions .formbar { flex-wrap: nowrap; } .card-actions input[type=search] { min-width: 210px; }
