:root {
  --page: #f9f9f7; --surface: #fcfcfb; --border: #e4e3de;
  --ink: #0b0b0b; --ink-2: #52514e; --ink-3: #7a7974;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --track: #ecebe6;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b; --info: #2a78d6;
  --up-ink: #006300; --down-ink: #b42828;
  --grid: #ecebe6;
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d; --surface: #1a1a19; --border: #2c2c2a;
    --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #8f8e86;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --track: #2e2e2b;
    --info: #3987e5; --up-ink: #4cc24c; --down-ink: #ef7a7a;
    --grid: #2a2a28;
  }
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
h1 { font-size: 19px; margin: 0; }
h2 { font-size: 13px; margin: 0; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
h3 { font-size: 14px; margin: 14px 0 6px; font-weight: 650; }
h4 { font-size: 13px; margin: 12px 0 2px; font-weight: 600; color: var(--ink-2); }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.up { color: var(--up-ink); } .down { color: var(--down-ink); }
button { font: inherit; border-radius: 10px; border: 1px solid var(--border); background: var(--series-1); color: #fff; padding: 10px 16px; cursor: pointer; }
button.ghost { background: transparent; color: var(--ink); padding: 6px 12px; }
button:disabled { opacity: .5; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 16px 6px; max-width: 1320px; margin: 0 auto; }
.top p { margin: 2px 0 0; font-size: 12.5px; }
.top-actions { display: flex; gap: 8px; flex: none; }

.attention { max-width: 1320px; margin: 6px auto 0; padding: 0 16px; }
.attention h2 { margin-bottom: 6px; }
.attention ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
@media (min-width: 900px) { .attention ul { grid-template-columns: 1fr 1fr; } }
.attention li { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-left-width: 4px; border-radius: 10px; padding: 9px 12px; }
.attention li.lvl-red { border-left-color: var(--critical); }
.attention li.lvl-amber { border-left-color: var(--warning); }
.attention li.lvl-info { border-left-color: var(--info); }
.attention li.lvl-green { border-left-color: var(--good); }

.grid { max-width: 1320px; margin: 12px auto 24px; padding: 0 16px; display: grid; gap: 12px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 980px) { .grid { grid-template-columns: 1fr 1fr; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 14px 16px; min-width: 0; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.hero { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.num-xl { font-size: 32px; font-weight: 750; letter-spacing: -.01em; }
.num-l { font-size: 22px; font-weight: 750; display: block; }
.delta { font-size: 14px; font-weight: 600; }
.lead { margin: 0 0 6px; font-weight: 600; }
.advice { margin: 0 0 10px; padding: 8px 10px; border-radius: 8px; background: var(--page); border-left: 3px solid var(--warning); font-size: 13.5px; }
.kv3, .kv2 { display: grid; gap: 10px; margin: 10px 0; }
.kv3 { grid-template-columns: repeat(3, 1fr); }
.kv2 { grid-template-columns: repeat(2, 1fr); }
.kv3 > div, .kv2 > div { display: flex; flex-direction: column; min-width: 0; }
.kv3 b { font-size: 15.5px; }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mob-only { display: none; }
@media (max-width: 520px) {
  .mob-only { display: block; padding-left: 18px; }
  .bar-cell { min-width: 0; flex-wrap: wrap; gap: 2px 6px; }
  .bar-cell i { max-width: 36px; }
  .bar-cell em { white-space: nowrap; }
  #r-table td:nth-child(3), #r-table td:nth-child(4) { white-space: normal; }
  #r-table { font-size: 12.5px; }
  #r-table td, #r-table th { padding: 6px 3px; }
  #r-table th { white-space: normal !important; }
  #r-table td:first-child { width: 40%; } .two { grid-template-columns: 1fr; } }
.sub-h { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-2); border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.sub-h b { color: var(--ink); font-size: 14px; }
.flows { list-style: none; margin: 0; padding: 0; }
.flows li { padding: 6px 0; border-bottom: 1px solid var(--grid); }
.flows li:last-child { border-bottom: 0; }
.fl-h { display: flex; justify-content: space-between; gap: 8px; }
.fl-h .who { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fl-h b { white-space: nowrap; }
.what { font-size: 12px; color: var(--ink-2); line-height: 1.3; }

/* статус: цвет + значок + слово */
.badge { font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; }
.st { display: inline-flex; align-items: flex-start; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; display: inline-grid; place-items: center; font-size: 9px; font-weight: 800; color: #fff; margin-top: 3px; }
.dot.green { background: var(--good); } .dot.green::after { content: "✓"; }
.dot.amber { background: var(--warning); color: #0b0b0b; } .dot.amber::after { content: "!"; }
.dot.red { background: var(--critical); } .dot.red::after { content: "×"; }
.dot.grey { background: var(--ink-3); } .dot.grey::after { content: "?"; }
.dot.info { background: var(--info); } .dot.info::after { content: "i"; }
.badge .dot { margin-top: 0; }

.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 4px; }
.tbl th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 12px; padding: 6px 5px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 6px 5px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.tbl td.n, .tbl th.n { text-align: right; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.strong td { font-weight: 600; }
.tbl tr.muted td { color: var(--ink-2); }
details summary { cursor: pointer; color: var(--ink-2); font-size: 13px; margin-top: 10px; }

.bar-cell { display: inline-flex; align-items: center; gap: 6px; min-width: 70px; justify-content: flex-end; }
.bar-cell i { display: block; height: 6px; border-radius: 3px; background: var(--series-1); max-width: 40px; }
.bar-cell em { font-style: normal; min-width: 32px; }

/* графики */
.chart { width: 100%; margin: 6px 0 4px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
svg text { fill: var(--ink-2); font-size: 11px; }
.line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; }
.pt { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.cross { stroke: var(--ink-3); stroke-width: 1; }
.min-l { stroke: var(--critical); stroke-width: 1.5; stroke-dasharray: 4 3; }
.hit { fill: transparent; }

.sales-top { display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: center; }
@media (max-width: 520px) { .sales-top { grid-template-columns: 1fr; justify-items: stretch; } .donut { width: 170px; margin: 0 auto; } }
.sales-kpi { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.kpi-main { display: flex; flex-direction: column; }
.kpi-list { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; font-size: 13px; }
.kpi-list dt { color: var(--ink-2); }
.kpi-list dd { margin: 0; font-weight: 600; text-align: right; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.donut svg { width: 100%; height: auto; display: block; }
.ring-bg { fill: none; stroke: var(--track); }
.ring { fill: none; stroke: var(--series-1); stroke-linecap: round; }
.tick { stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; }
.donut-n { fill: var(--ink); font-size: 30px; font-weight: 750; }
.donut-s { fill: var(--ink-2); font-size: 11px; }

.stack, .split { display: flex; height: 14px; border-radius: 7px; overflow: hidden; gap: 2px; margin: 8px 0 4px; background: var(--surface); }
.seg-materials { background: var(--track); }
.seg-delivery { background: var(--series-2); }
.seg-gp { background: var(--series-1); }
.seg-own { background: var(--series-1); }
.seg-ext { background: var(--track); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

.tip { position: fixed; z-index: 10; pointer-events: none; background: var(--ink); color: var(--page); font-size: 12.5px; padding: 6px 9px; border-radius: 8px; max-width: 260px; white-space: pre-line; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 22px; display: grid; gap: 12px; }
.login-card label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); }
.login-card input { font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--page); color: var(--ink); }
.err { color: var(--down-ink); min-height: 1em; margin: 0; font-size: 13px; }
.warnline { color: var(--ink-2); font-size: 12.5px; margin: 6px 0 0; }

@media (max-width: 520px) {
  .num-xl { font-size: 28px; }
  #r-table th:nth-child(2), #r-table td:nth-child(2), #r-table th:nth-child(5), #r-table td:nth-child(5), #p-table th:nth-child(2), #p-table td:nth-child(2) { display: none; }
  .tbl { font-size: 13px; }
}
.limline { margin: 4px 0 8px; font-size: 13.5px; font-weight: 600; }
.tbl tr.over td { background: color-mix(in srgb, var(--critical) 8%, transparent); }
.bar-cell { min-width: 120px; }
.bar-cell i { max-width: 50px; }
.bar-cell.near i { background: var(--warning); }

.wide { grid-column: 1 / -1; }
.news { list-style: none; margin: 0; padding: 0; }
.news li { padding: 8px 0; border-bottom: 1px solid var(--grid); font-size: 13.5px; }
.news li:last-child { border-bottom: 0; }
.news .tag { display: inline-block; font-size: 11px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
.news .src { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.news a { color: var(--series-1); text-decoration: none; }
