/* «Запчасти» — темы и компоненты. Палитра графиков проверена валидатором
   dataviz для обеих тем: тёмная поверхность #1a2128, светлая #ffffff. */
:root {
  color-scheme: dark;
  --bg: #10151a; --panel: #1a2128; --panel2: #232c35; --panel3: #2b3641;
  --line: #31404c; --ink: #e9eff4; --muted: #95a3ae;
  --accent: #3987e5; --accent-ink: #ffffff;
  --series-1: #3987e5; --series-2: #d95926;
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --bad: #e66767;
  --good-text: #4ecb71; --warn-text: #f0c24a; --bad-text: #f08a8a;
  --track: #26313b; --ring: rgba(255,255,255,.10);
  --top-bg: rgba(16,21,26,.94); --nav-bg: rgba(22,29,36,.97); --toast-bg: #2b3742;
  --card-shadow: inset 0 1px 0 rgba(255,255,255,.03);
  --radius: 16px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f5f8; --panel: #ffffff; --panel2: #edf2f7; --panel3: #e2eaf2;
  --line: #d7e0e8; --ink: #101a22; --muted: #5b6b78;
  --accent: #2a78d6; --accent-ink: #ffffff;
  --series-1: #2a78d6; --series-2: #eb6834;
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --bad: #d03b3b;
  --good-text: #08750b; --warn-text: #8a5d00; --bad-text: #b52c2c;
  --track: #e9eef3; --ring: rgba(16,26,34,.08);
  --top-bg: rgba(242,245,248,.94); --nav-bg: rgba(255,255,255,.97); --toast-bg: #24313c;
  --card-shadow: 0 1px 2px rgba(16,26,34,.05), 0 10px 28px rgba(16,26,34,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 16px;
  -webkit-tap-highlight-color: transparent; }
body { min-height: 100vh; }
.hidden { display: none !important; }
.app { padding-bottom: calc(72px + env(safe-area-inset-bottom)); max-width: 820px; margin: 0 auto; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: var(--top-bg);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; letter-spacing: .2px; color: var(--accent); white-space: nowrap; }
.top select { flex: 1; min-width: 0; }
.icon { background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  border-radius: 11px; padding: 8px 10px; font-size: 17px; cursor: pointer; line-height: 1; }
.icon:active { transform: scale(.97); }
main { padding: 12px; }
h2 { font-size: 20px; margin: 4px 0 12px; letter-spacing: -.2px; }
h3 { font-size: 13px; margin: 20px 0 8px; color: var(--muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--bad-text); margin-top: 8px; }
.warn { color: var(--warn-text); }
.good { color: var(--good-text); }
.bad { color: var(--bad-text); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px; box-shadow: var(--card-shadow); }
.card.click { cursor: pointer; transition: border-color .15s, transform .15s; }
.card.click:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.card.click:active { transform: scale(.992); background: var(--panel2); }
.row { display: flex; align-items: center; gap: 10px; }
.row.sb { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.title { font-weight: 700; }
.sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chip { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 10px; font-size: 13px; color: var(--muted); }
.chip.on { border-color: var(--accent); color: var(--ink); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px; }
.stat b { display: block; font-size: 23px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--panel2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 11px; padding: 10px 13px; font-size: 15px; cursor: pointer;
  font-family: inherit; transition: transform .12s, filter .15s; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.btn.sm { padding: 7px 10px; font-size: 13px; border-radius: 9px; }
.btn.danger { color: var(--bad-text); }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
input, select, textarea { width: 100%; background: var(--panel2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; font-size: 16px;
  font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { display: block; color: var(--muted); font-size: 13px; margin: 10px 0 0; }
label input, label select, label textarea { margin-top: 5px; color: var(--ink); }
.search { position: sticky; top: 52px; z-index: 3; background: var(--bg); padding: 6px 0 8px; }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; }
.part-line { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--line); }
.part-line:last-child { border-bottom: 0; }
.part-line .name { font-weight: 600; }
.part-line .meta { color: var(--muted); font-size: 13px; margin-top: 3px; }
.qty { text-align: right; white-space: nowrap; font-weight: 700; }
.qty small { display: block; color: var(--muted); font-weight: 400; }
.bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex;
  background: var(--nav-bg); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.bottom button { flex: 1; background: none; border: 0; color: var(--muted);
  padding: 12px 2px 11px; font-size: 12px; font-family: inherit; cursor: pointer;
  transition: color .15s; }
.bottom button.on { color: var(--accent); font-weight: 700; }
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; position: relative; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 20px; box-shadow: var(--card-shadow); }
.login-card h1 { margin: 0; color: var(--accent); }
.login-card .btn { width: 100%; margin-top: 16px; }
.login-theme { position: absolute; top: 16px; right: 16px; }
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.58);
  display: flex; align-items: flex-end; justify-content: center; padding: 0; }
.modal-box { width: 100%; max-width: 640px; max-height: 88vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px 18px 0 0;
  padding: 16px 14px calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .modal { align-items: center; padding: 20px; } .modal-box { border-radius: 18px; } }
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 30; background: var(--toast-bg); border: 1px solid var(--line);
  color: #fff; padding: 10px 14px; border-radius: 12px; max-width: 90vw; font-size: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.25); }
:root[data-theme="light"] .toast { color: #fff; }
.coverage { font-family: ui-monospace, Consolas, monospace; font-size: 12px; white-space: pre-wrap; color: var(--muted); }
.bar { height: 7px; border-radius: 99px; background: var(--track); overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--accent); }
.split { display: grid; gap: 10px; }

/* ── обзор: KPI, полосы, сегменты, движения ─────────────────────────────── */
.site-line { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.site-line .name { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 4px; }
.kpi { font: inherit; color: inherit; text-align: left; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 13px; cursor: pointer;
  box-shadow: var(--card-shadow); transition: border-color .15s, transform .12s; }
.kpi:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.kpi:active { transform: scale(.985); }
.kpi .v { font-size: 27px; font-weight: 700; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi .h { color: var(--muted); font-size: 11px; margin-top: 6px; opacity: .85; }
.kpi .v small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }

.hbars { display: grid; gap: 4px; }
.hbar { font: inherit; color: inherit; background: none; border: 0; cursor: pointer;
  display: grid; grid-template-columns: 96px 1fr 44px; align-items: center; gap: 8px;
  padding: 7px 0; text-align: left; border-radius: 8px; }
.hbar:hover .hbar-track { filter: brightness(1.12); }
.hbar:active { transform: scale(.995); }
.hbar-name { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 10px; background: var(--track); border-radius: 5px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; transition: width .35s ease; }
.hbar-val { font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }

.segbar { display: flex; gap: 2px; height: 28px; margin: 6px 0 12px; }
.seg { border-radius: 4px; min-width: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; overflow: hidden; font-variant-numeric: tabular-nums; }
.seg.good { background: var(--good); } .seg.warn { background: var(--warn); color: #221a00; }
.seg.bad { background: var(--bad); }
.seg.empty { background: var(--track); }
.legend { display: grid; gap: 7px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend-item .dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.legend-item .n { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }

.moves { display: grid; grid-template-columns: repeat(14, 1fr); gap: 3px; align-items: end;
  height: 92px; padding-top: 8px; border-bottom: 1px solid var(--line); }
.moves .day { display: flex; align-items: flex-end; justify-content: center; gap: 2px;
  height: 100%; border-radius: 6px 6px 0 0; position: relative; }
.moves .day:hover { background: var(--panel2); }
.moves .b { width: 5px; border-radius: 4px 4px 0 0; min-height: 2px; }
.moves .b.in { background: var(--series-1); }
.moves .b.out { background: var(--series-2); }
.moves-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 5px; }
.details { margin-top: 10px; }
.details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.details table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.details td, .details th { padding: 5px 0; text-align: left; border-bottom: 1px solid var(--line); }
.details td:last-child, .details th:last-child { text-align: right; font-variant-numeric: tabular-nums; }

.attn { display: grid; gap: 8px; }
.attn-item { font: inherit; color: inherit; text-align: left; width: 100%; cursor: pointer;
  display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 13px; padding: 11px 12px; }
.attn-item:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.attn-item .ic { width: 28px; height: 28px; border-radius: 9px; display: flex; align-items: center;
  justify-content: center; background: var(--panel2); flex: 0 0 28px; font-size: 14px; }
.attn-item .t { display: block; font-weight: 600; font-size: 14px; }
.attn-item .s { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.attn-item .n { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }

button:focus-visible, .card.click:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (min-width: 620px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .split { grid-template-columns: 1fr 1fr; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .bottom button { font-size: 13px; }
}
