:root {
  --bg: #F2F2F7; --card: #FFFFFF; --ink: #1C1C1E; --muted: #5F6368; --faint: #8E8E93; --line: #E5E5EA;
  --track: #EFEFF4; --ok: #157F3D; --ok-soft: #D8F0E0; --ok-bar: #A7D9B7; --bad: #B42318; --bad-ink: #8A1C12;
  --bad-soft: #FDECEA; --bad-bar: #F4B4AE; --warn: #B54708; --warn-ink: #7A2E05; --warn-soft: #FDEBD3;
  --warn-bar: #F5C99B; --link: #0A58CA; --h1: #CDEBD6; --h2: #FBD9B4;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { background: var(--card); border-radius: 20px; padding: 28px; max-width: 380px; width: 100%;
  display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { font-size: 28px; font-weight: 800; }
.login-card p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.45; }

/* каркас */
.shell { display: flex; min-height: 100vh; }
.side { display: none; }
.main { flex: 1; min-width: 0; padding: 20px 16px 104px; display: flex; flex-direction: column; gap: 18px;
  max-width: 560px; margin: 0 auto; width: 100%; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.97);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  padding: 6px 4px calc(10px + env(safe-area-inset-bottom)); z-index: 5; }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 48px; color: var(--faint); font-size: 10px; font-weight: 600; }
.tabbar a.on { color: var(--ink); font-weight: 700; }
.tabbar svg, .side svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }

.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.head .sub { font-size: 13px; color: var(--muted); font-weight: 500; }
.head h1 { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; }
.pill { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 4px 9px; white-space: nowrap;
  background: #E5E5EA; color: var(--muted); }
.pill.warn { background: var(--warn-soft); color: var(--warn-ink); }
.pill.bad { background: var(--bad-soft); color: var(--bad-ink); }
.pill.ok { background: var(--ok-soft); color: #0B5B2A; }

.card { background: var(--card); border-radius: 20px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.card h2 { font-size: 18px; font-weight: 700; }
.card .row { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 4px 0; }
.card .row .k { color: var(--muted); }
.card .row b { font-weight: 600; }
.card .row.total { border-top: 1px solid var(--line); padding-top: 9px; font-size: 15px; font-weight: 700; }
.sect-title { display: flex; justify-content: space-between; align-items: baseline; margin: 0 4px; gap: 8px; }
.sect-title h2 { font-size: 20px; font-weight: 700; }
.note { font-size: 12px; color: var(--muted); }
.big { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.label { font-size: 13px; color: var(--muted); font-weight: 600; }
.bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > div { height: 8px; background: var(--ink); border-radius: 999px; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { background: var(--bg); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile .t { font-size: 11px; color: var(--muted); font-weight: 600; }
.tile .v { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .s { font-size: 11px; color: var(--muted); }
.red { color: var(--bad); } .green { color: var(--ok); } .orange { color: var(--warn); }

.banner { border-radius: 16px; padding: 14px 16px; font-size: 14px; line-height: 1.45; display: flex; flex-direction: column; gap: 4px; }
.banner.bad { background: var(--bad-soft); color: var(--bad-ink); }
.banner.warn { background: var(--warn-soft); color: var(--warn-ink); }
.banner b { font-weight: 700; }

.list { background: var(--card); border-radius: 16px; display: flex; flex-direction: column; }
.item { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.dot { flex: none; width: 10px; height: 10px; border-radius: 999px; margin-top: 5px; background: var(--faint); }
.dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }
.item .body { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.item .top { display: flex; justify-content: space-between; gap: 8px; font-size: 15px; font-weight: 700; }
.item .desc { font-size: 13px; color: var(--muted); }
.item .act { font-size: 13px; font-weight: 600; }

.mgr { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.mgr:last-child { border-bottom: 0; }
.mgr .top { display: flex; justify-content: space-between; align-items: center; font-size: 16px; font-weight: 700; }
.mgr .rank { font-size: 13px; color: var(--muted); width: 14px; display: inline-block; margin-right: 10px; }
.segs { display: flex; gap: 3px; }
.segs span { flex: 1; height: 6px; border-radius: 2px; background: var(--bad-bar); }
.segs span.on { background: var(--ok); }
.mgr .foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); gap: 8px; }
.mgr .foot b { color: var(--ink); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin: 2px 4px; font-size: 11px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 8px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.chips button { border: 0; background: var(--card); border-radius: 999px; padding: 10px 14px; min-height: 40px;
  font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chips button.on { background: var(--ink); color: #fff; }
.pos { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.pos:last-child { border-bottom: 0; }
.pos .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; }
.pos .tag { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 3px 8px; margin-left: 8px; }
.track { position: relative; height: 10px; background: var(--track); border-radius: 999px; }
.track > .fc, .track > .fact { position: absolute; left: 0; top: 0; height: 10px; border-radius: 999px; }
.track > .mark { position: absolute; top: -3px; width: 2px; height: 16px; background: var(--ink); }
.track > .mark.goal { background: var(--faint); }
.pos .foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); gap: 8px; }
.pos .hint { font-size: 12px; font-weight: 600; }
.lvl-below .tag { color: var(--bad-ink); background: var(--bad-soft); }
.lvl-below .fact { background: var(--bad); } .lvl-below .fc { background: var(--bad-bar); }
.lvl-ok .tag { color: #0B5B2A; background: var(--ok-soft); }
.lvl-ok .fact { background: var(--ok); } .lvl-ok .fc { background: var(--ok-bar); }

.hbar { display: flex; flex-direction: column; gap: 5px; }
.hbar .lbl { display: flex; justify-content: space-between; font-size: 14px; gap: 8px; }
.hbar .tr { height: 8px; background: var(--track); border-radius: 999px; }
.hbar .tr > div { height: 8px; border-radius: 999px; background: #636366; }
.hbar .tr > div.red { background: var(--bad); }
.cols { display: flex; align-items: flex-end; gap: 4px; height: 140px; }
.cols > div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; min-width: 0; }
.cols .c { width: 100%; background: #4F86CF; border-radius: 4px 4px 0 0; min-height: 2px; }
.cols .c.top { background: #1F56A8; }
.cols .x { font-size: 10px; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; white-space: nowrap; }
td { padding: 12px 10px; border-top: 1px solid var(--line); white-space: nowrap; }
td.num, th.num { text-align: right; }
tr.click { cursor: pointer; } tr.click:hover td { background: #FAFAFC; }
.heat td { text-align: center; font-size: 12px; font-weight: 600; padding: 8px 4px; }
.heat td.name { text-align: left; font-size: 14px; }
.heat th { text-align: center; font-size: 11px; white-space: normal; min-width: 64px; }
.h0 { background: var(--bad-soft); color: var(--bad-ink); } .h1 { background: var(--h2); color: var(--warn-ink); }
.h2 { background: var(--h1); color: #0B5B2A; } .h3 { background: var(--ok); color: #fff; }
.grid-cards { display: flex; flex-direction: column; gap: 18px; }
.loading, .error { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 15px; }
.btn { border: 0; background: var(--bg); border-radius: 12px; min-height: 44px; padding: 0 16px; font-weight: 700; cursor: pointer; }

/* компьютер: боковое меню, широкая сетка */
@media (min-width: 1024px) {
  .tabbar { display: none; }
  .side { display: flex; flex-direction: column; gap: 4px; width: 240px; flex: none; background: var(--card);
    border-right: 1px solid var(--line); padding: 24px 12px; position: sticky; top: 0; height: 100vh; }
  .side .brand { font-size: 15px; font-weight: 800; padding: 0 12px 18px; }
  .side a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; font-size: 14px;
    font-weight: 600; color: var(--muted); min-height: 44px; }
  .side a.on { background: var(--bg); color: var(--ink); }
  .side .grow { flex: 1; }
  .main { max-width: 1400px; padding: 28px 32px 48px; }
  .wide-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
  .wide-tiles .card { padding: 16px; gap: 6px; }
  .wide-tiles .v { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
  .grid2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
  .grid-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
}
