/* Демо-дашборд «Вира». Токены - ../assets/tokens.css (тёмная тема уже переопределена под .app). */
.app {
  --page: var(--bg-alt);
  --seg: rgba(118, 118, 128, .12);
  --thumb: #ffffff;
  --accent-solid: #0071e3;         /* заливка кнопок: белый текст 4.7:1 в обеих темах */
  --pad: 32px;
  --top-h: 60px;
  --side-w: 240px;
}
@media (prefers-color-scheme: dark) {
  .app { --page: var(--bg); --seg: rgba(118, 118, 128, .24); --thumb: #636366; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top-h) + 12px); }
body.app {
  margin: 0; background: var(--page); color: var(--text);
  font: 400 15px/1.45 var(--font); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased; caret-color: var(--accent);
}
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
h1, h2, h3, p { margin: 0; }
a { color: var(--link); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--surface); padding: 8px 14px; border-radius: var(--r-pill); }
.skip:focus { left: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- баннер и шапка ---------- */
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 10px var(--pad); background: var(--surface); border-bottom: 1px solid var(--hairline); font-size: 14px; }
.banner p { flex: 1 1 260px; color: var(--text); }
.banner .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 16px; border-radius: var(--r-pill); font-size: 14px; font-weight: 600; text-decoration: none; border: 1px solid transparent; white-space: nowrap; }
.btn.primary { background: var(--accent-solid); color: #fff; }
.btn.primary:hover { background: #0066cc; } /* белый на #0077ed даёт 4.3:1, на #0066cc - 5.6:1 */
.btn.ghost { border-color: var(--accent); color: var(--link); }
.btn.ghost:hover { background: var(--fill); }

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; min-height: var(--top-h); padding: 8px var(--pad); background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-bottom: 1px solid var(--hairline); }
.top-name { flex: 1; display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 16px; min-width: 0; }
.venue { font-size: 20px; font-weight: 600; letter-spacing: var(--track-display); }
.date { font-size: 14px; color: var(--text-2); }
.tag { padding: 3px 10px; border-radius: var(--r-pill); background: var(--fill); color: var(--text-2); font-size: 12px; font-weight: 600; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-solid); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 600; }

/* ---------- каркас ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); align-items: start; }
.side { position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); overflow-y: auto; padding: 14px 12px 24px var(--pad); }
.side a { display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; margin-bottom: 2px; border-radius: 10px; color: var(--text); text-decoration: none; font-size: 15px; font-weight: 500; }
.side a:hover { background: var(--fill); }
.side a[aria-current="page"] { background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--link); font-weight: 600; }
.ic { flex: none; }
#view { padding: 22px var(--pad) 72px 8px; max-width: 1120px; width: 100%; outline: none; }

/* ---------- заголовок экрана ---------- */
.page-head h1 { font-size: 34px; line-height: 1.1; font-weight: 600; letter-spacing: var(--track-display); outline: none; }
.page-head .sub { margin-top: 6px; color: var(--text-2); font-size: 15px; max-width: 70ch; }
.explain { margin: 14px 0 4px; }
.explain summary { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 28px; color: var(--link); font-size: 14px; font-weight: 500; list-style: none; }
.explain summary::-webkit-details-marker { display: none; }
.explain summary::before { content: ''; width: 6px; height: 6px; border-right: 1.75px solid currentColor; border-bottom: 1.75px solid currentColor; transform: rotate(-45deg); transition: transform .2s var(--ease); }
.explain[open] summary::before { transform: rotate(45deg); }
.explain > div { margin-top: 8px; padding: 14px 16px; background: var(--surface); border-radius: var(--r-md); color: var(--text-2); font-size: 14px; max-width: 78ch; }
.explain > div p + p { margin-top: 8px; }
.explain b { color: var(--text); font-weight: 600; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 16px 0 18px; }
.seg { display: inline-flex; padding: 2px; background: var(--seg); border-radius: 10px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg a, .seg button { display: inline-flex; align-items: center; min-height: 32px; padding: 0 14px; border: 0; background: none; border-radius: 8px; color: var(--text); font-size: 13px; font-weight: 500; text-decoration: none; white-space: nowrap; cursor: pointer; }
.seg a[aria-current="true"], .seg button[aria-pressed="true"] { background: var(--thumb); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .14), 0 0 0 .5px rgba(0, 0, 0, .04); }
.seg a:hover:not([aria-current="true"]), .seg button:hover:not([aria-pressed="true"]) { background: var(--fill); }

/* ---------- карточки ---------- */
.card { background: var(--surface); border-radius: var(--r-md); padding: 20px; box-shadow: inset 0 0 0 1px var(--hairline); min-width: 0; }
.card h2 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.card .hint { margin-top: 3px; color: var(--text-2); font-size: 13px; }
.card .body { margin-top: 14px; }
.stack > * + * { margin-top: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.foot-note { margin-top: 12px; color: var(--text-2); font-size: 13px; max-width: 80ch; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.kpis.c5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpis.c5 .k-val { font-size: 28px; }
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; }
.k-label { color: var(--text-2); font-size: 13px; font-weight: 500; }
.k-val { font-size: 34px; line-height: 1.1; font-weight: 600; letter-spacing: var(--track-display); white-space: nowrap; }
.k-val .u { margin-left: 5px; font-size: 15px; font-weight: 500; letter-spacing: 0; color: var(--text-2); }
.k-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; color: var(--text-2); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: var(--r-pill); background: var(--fill); color: var(--text-2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.up { background: var(--up-bg); color: var(--up); }
.badge.down { background: var(--down-bg); color: var(--down); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.neg { color: var(--down); }
.pos { color: var(--up); }
.muted { color: var(--text-2); }

/* ---------- статус и потенциал ---------- */
.status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 0 0 16px; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 14px; border-radius: var(--r-pill); background: var(--surface); box-shadow: inset 0 0 0 1px var(--hairline); font-size: 13px; font-weight: 500; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.g { background: var(--up); } .dot.y { background: var(--warn); } .dot.r { background: var(--down); }
.reasons { margin-top: 10px; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; }
.reasons li { padding: 3px 10px; border-radius: var(--r-pill); background: var(--warn-bg); color: var(--warn); font-weight: 500; }
.potential { background: color-mix(in srgb, var(--up) 10%, var(--surface)); display: grid; grid-template-columns: 1fr auto; gap: 16px 32px; align-items: end; }
.potential .big { margin-top: 6px; font-size: 52px; line-height: 1.05; font-weight: 600; letter-spacing: var(--track-display); color: var(--up); }
.potential .big .u { font-size: 20px; letter-spacing: 0; margin-left: 4px; }
.potential p { margin-top: 8px; font-size: 14px; color: var(--text); max-width: 54ch; }
.potential .side-fig { text-align: right; }
.potential .side-fig b { display: block; font-size: 28px; font-weight: 600; letter-spacing: var(--track-display); color: var(--up); }
.potential .side-fig span { font-size: 13px; color: var(--text-2); }
.reserve { list-style: none; margin: 0; padding: 0; }
.reserve li { border-top: 1px solid var(--hairline); }
.reserve li:first-child { border-top: 0; }
.reserve a { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 48px; color: var(--text); text-decoration: none; }
.reserve a:hover .rl { color: var(--link); }
.reserve .rl { font-size: 15px; }
.reserve .rl small { display: block; color: var(--text-2); font-size: 13px; }
.reserve .rv { font-weight: 600; white-space: nowrap; }

/* ---------- графики ---------- */
.chart { position: relative; width: 100%; min-height: 40px; }
.c-svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.c-grid { stroke: var(--hairline); stroke-width: 1; }
.c-axis { fill: var(--text-2); font: 500 11px var(--font); font-variant-numeric: tabular-nums; }
.c-axis.strong { fill: var(--text); font-weight: 700; }
.c-lab { fill: var(--text); font: 500 13px var(--font); }
.c-val { fill: var(--text); font: 600 12px var(--font); }
.c-bar { fill: var(--accent); opacity: .42; transition: opacity .15s; }
.c-bar.pk { opacity: 1; }
.c-ghost { fill: none; stroke: var(--text-3); stroke-width: 1.25; stroke-dasharray: 3 3; }
.col:hover .c-bar, .col:has(.hit:focus-visible) .c-bar { opacity: .78; }
.hit { fill: transparent; outline-offset: -2px; }
.hit:focus-visible { outline: 2px solid var(--accent); }
.c-track { fill: var(--fill); }
.hb-ok { fill: var(--accent); } .hb-acc { fill: var(--accent); } .hb-mid { fill: var(--warn); } .hb-low, .hb-down { fill: var(--down); } .hb-up { fill: var(--up); } .hb-na { fill: var(--text-3); }
.c-ref { stroke: var(--text); stroke-width: 1.25; stroke-dasharray: 3 3; }
.c-cell { fill: var(--accent); }
.c-cell.pk { stroke: var(--text); stroke-width: 1.5; }
.c-cv { fill: var(--text); font: 500 10px var(--font); pointer-events: none; }
.c-cv.on { fill: #fff; }
.pf-plan { fill: var(--accent); fill-opacity: .16; }
.pf-plan.future { fill-opacity: .1; }
.pf-fact { fill: var(--accent); }
.pf-fact.over { fill: var(--up); }
.tip { position: absolute; z-index: 5; transform: translateX(-50%); padding: 6px 10px; border-radius: 8px; background: var(--text); color: var(--bg); font-size: 12px; font-weight: 500; line-height: 1.35; white-space: pre-line; pointer-events: none; }
.tip[hidden] { display: none; }
.chart-cap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin: 4px 0 10px; font-size: 13px; color: var(--text-2); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 10px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .ramp { display: inline-block; width: 120px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 7%, transparent), var(--accent)); box-shadow: inset 0 0 0 1px var(--hairline); }
.sw-acc { background: var(--accent); } .sw-mid { background: var(--warn); } .sw-low { background: var(--down); } .sw-na { background: var(--text-3); } .sw-up { background: var(--up); }
.sw-plan { background: color-mix(in srgb, var(--accent) 22%, transparent); }

/* ---------- таблицы ---------- */
.tw { position: relative; overflow-x: auto; margin: 0 -4px; padding: 0 4px; scrollbar-width: thin; scrollbar-color: var(--text-3) transparent; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 520px; }
th, td { padding: 10px 10px; text-align: left; border-bottom: 1px solid var(--hairline); white-space: nowrap; vertical-align: middle; }
td.wrap { white-space: normal; min-width: 150px; }
th { padding: 4px 6px; font-weight: 600; font-size: 12px; color: var(--text-2); }
th.num, td.num { text-align: right; }
th button { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 0 4px; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; border-radius: 6px; }
th.num button { flex-direction: row-reverse; }
th button:hover { color: var(--text); }
th button::after { content: ''; width: 0; height: 0; border: 4px solid transparent; opacity: 0; }
th[aria-sort="descending"] button::after { border-top-color: currentColor; border-bottom: 0; opacity: 1; }
th[aria-sort="ascending"] button::after { border-bottom-color: currentColor; border-top: 0; opacity: 1; }
th[aria-sort] { color: var(--text); }
tbody tr:last-child td { border-bottom: 0; }
tr.dim td { color: var(--text-2); }
td .sub { display: block; color: var(--text-2); font-size: 12px; }
.more { margin-top: 10px; min-height: 36px; padding: 0 4px; border: 0; background: none; color: var(--link); font-size: 14px; font-weight: 500; cursor: pointer; }
.ci { display: inline-flex; align-items: center; justify-content: center; gap: 4px; color: var(--text-2); }

/* ---------- меню (матрица) ---------- */
.classes { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.cls { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 14px 14px 12px; background: var(--surface); border: 0; border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--hairline); cursor: pointer; }
.cls:hover { box-shadow: inset 0 0 0 1px var(--text-3); }
.cls[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--accent); }
.cls .n { font-size: 28px; font-weight: 600; letter-spacing: var(--track-display); line-height: 1.1; }
.cls .t { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; }
.cls .d { color: var(--text-2); font-size: 12px; }
.cls .dot { width: 10px; height: 10px; }
.dot.star { background: var(--up); } .dot.horse { background: var(--accent); } .dot.puzzle { background: var(--warn); } .dot.dog { background: var(--text-3); } .dot.loss { background: var(--down); } .dot.nocost { background: transparent; box-shadow: inset 0 0 0 2px var(--text-3); }
.recs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.rec-total { margin-top: 10px; font-size: 22px; font-weight: 600; letter-spacing: var(--track-display); }
.rec-list { list-style: none; padding: 0; margin: 12px 0 0; }
.rec-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--hairline); font-size: 14px; }
.rec-list li small { display: block; color: var(--text-2); font-size: 12px; }
.rec-list .v { font-weight: 600; white-space: nowrap; }
.rec-more { margin-top: 8px; font-size: 13px; color: var(--text-2); }
.banner-line { padding: 14px 20px; border-radius: var(--r-md); background: var(--up-bg); color: var(--text); font-size: 15px; }
.banner-line b { color: var(--up); font-weight: 600; }

/* ---------- прочее ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 11px 0; border-top: 1px solid var(--hairline); font-size: 14px; }
.rows li:first-child { border-top: 0; }
.rows .v { font-weight: 600; white-space: nowrap; }
.rows small { display: block; color: var(--text-2); font-size: 12px; }
.hits { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.hit-card { padding: 18px 20px; border-radius: var(--r-md); background: var(--down-bg); }
.hit-card .nm { font-size: 15px; font-weight: 600; }
.hit-card .loss { margin-top: 8px; font-size: 26px; font-weight: 600; letter-spacing: var(--track-display); color: var(--down); }
.hit-card .meta { margin-top: 4px; font-size: 13px; color: var(--text-2); }
.empty { padding: 22px 8px; text-align: center; color: var(--text-2); font-size: 14px; }
.collapse > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: 32px; font-size: 17px; font-weight: 600; }
.collapse > summary::-webkit-details-marker { display: none; }
.collapse > summary::after { content: ''; width: 7px; height: 7px; border-right: 1.75px solid var(--text-2); border-bottom: 1.75px solid var(--text-2); transform: rotate(45deg); transition: transform .2s var(--ease); }
.collapse[open] > summary::after { transform: rotate(-135deg); }
.traffic { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.inv-badges { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.inv-badges .badge { font-size: 14px; padding: 6px 14px; }
.skel { border-radius: var(--r-md); background: linear-gradient(90deg, var(--fill), color-mix(in srgb, var(--fill) 40%, transparent), var(--fill)); background-size: 200% 100%; animation: sh 1.1s linear infinite; }
@keyframes sh { to { background-position: -200% 0; } }
.skel-h { height: 38px; width: 180px; margin-bottom: 14px; }
.skel-k { height: 120px; }

/* ---------- нижняя панель и лист (мобильная версия) ---------- */
.tabbar { display: none; }
.sheet { width: 100%; max-width: none; margin: auto 0 0; border: 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); background: var(--surface); color: var(--text); border-radius: 24px 24px 0 0; }
.sheet::backdrop { background: rgba(0, 0, 0, .4); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sheet-head h2 { font-size: 17px; font-weight: 600; }
.sheet-close { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: var(--fill); border-radius: 50%; cursor: pointer; }
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sheet-grid a { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 14px; border-radius: 14px; background: var(--fill); color: var(--text); text-decoration: none; font-weight: 500; }
.sheet-grid a[aria-current="page"] { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--link); font-weight: 600; }

@media (max-width: 1100px) {
  .recs, .hits { grid-template-columns: 1fr; }
  .classes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis.c5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 899px) {
  .app { --pad: 16px; --top-h: 64px; }
  .btn { min-height: 44px; }
  .shell { display: block; }
  .side { display: none; }
  #view { padding: 16px var(--pad) 120px; max-width: none; }
  .top { flex-wrap: wrap; }
  .venue { font-size: 18px; }
  .page-head h1 { font-size: 30px; }
  .seg a, .seg button { min-height: 38px; padding: 0 12px; }
  .kpis, .kpis.c5 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpis.long { grid-template-columns: minmax(0, 1fr); }
  .kpis.c5 .kpi:nth-child(n+4) { grid-column: 1 / -1; }
  .kpi { padding: 14px 16px; }
  .k-val { font-size: 28px; }
  .k-val .u { font-size: 13px; margin-left: 3px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .potential { grid-template-columns: 1fr; }
  .potential .big { font-size: 40px; }
  .potential .side-fig { text-align: left; }
  .classes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tabbar { display: flex; position: fixed; z-index: 30; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); height: 64px; padding: 6px; background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-radius: 24px; box-shadow: 0 0 0 1px var(--hairline), var(--shadow); }
  .tabbar a, .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0; border: 0; background: none; border-radius: 18px; color: var(--text-2); text-decoration: none; font-size: 11px; font-weight: 500; cursor: pointer; }
  .tabbar a[aria-current="page"], .tabbar button[aria-current="page"] { color: var(--link); background: color-mix(in srgb, var(--accent) 13%, transparent); font-weight: 600; }
}
@media (max-width: 420px) {
  .k-val { font-size: 26px; }
  table { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; }
}
@media print { .banner .btns, .side, .tabbar { display: none; } }
