/* ==================================================================
   BEZBRENDU director dashboard — app.css v2 (компоненти)
   Токени: tokens.css (v2). CSP 'self': без inline-стилів; SVG-графіки
   стилізуються класами (stop-color/stop-opacity — теж через CSS).
   Імена класів v1 збережено (.card .kpi .lrow .seg .chip .chart .hbar ...).
   ================================================================== */

/* ---------- База ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  font: var(--fw-regular) var(--fs-md)/var(--lh-normal) var(--font-sans);
  color: var(--text); background: var(--bg);
  background-image: var(--app-glow); background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "calt";
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: var(--fw-semibold); letter-spacing: var(--ls-tight); line-height: var(--lh-tight); }
.num, .kpi-value, .hero-value, td, .row-val, .tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: var(--r-xs); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { flex: none; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: var(--fs-base); }
.xs { font-size: var(--fs-sm); }
.caps { font-size: var(--fs-xs); font-weight: var(--fw-medium); letter-spacing: var(--ls-caps); text-transform: uppercase; color: var(--text-3); }
.unit { font-size: .58em; font-weight: var(--fw-medium); color: var(--text-3); margin-left: .18em; letter-spacing: 0; }

/* ---------- Каркас: телефон → rail (900) → sidebar (1200) ---------- */
.app { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "header" "main"; grid-template-rows: auto 1fr; }
.app-header {
  grid-area: header; position: sticky; top: 0; z-index: var(--z-header);
  display: flex; align-items: center; gap: var(--sp-2);
  height: calc(var(--header-h) + var(--safe-t)); padding: var(--safe-t) var(--gutter) 0;
  background: var(--surface-glass); border-bottom: 1px solid transparent;
  -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .app-header { background: var(--surface-glass-solid); } }
.app-header .home { display: flex; align-items: center; height: var(--tap); }
.brand-logo { display: block; height: 15px; width: auto; filter: var(--logo-filter); }
.spacer { flex: 1; }
.hdr-date { display: none; font-size: var(--fs-sm); color: var(--text-3); }
.app-header .icon-btn { width: 36px; height: 36px; border-radius: 50%; }
.fresh {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 11px 0 9px;
  border-radius: var(--r-pill); background: var(--surface); box-shadow: var(--shadow-1);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-2); white-space: nowrap;
}
.fresh:hover { text-decoration: none; color: var(--text); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.avatar {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 0; padding: 0;
  background: var(--grad-avatar); color: #fff; font: var(--fw-semibold) var(--fs-sm)/1 var(--font-sans);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--line-strong); cursor: pointer;
}
.wrap {
  grid-area: main; width: 100%; max-width: var(--content-max); margin: 0 auto; min-width: 0;
  padding: var(--sp-3) var(--gutter) calc(var(--tabbar-h) + var(--safe-b) + 40px);
}

/* rail / sidebar */
.rail { display: none; }
.rail ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rail a {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border-radius: var(--r-sm);
  color: var(--text-2); font-size: var(--fs-xs); font-weight: var(--fw-medium); text-align: center;
  transition: background var(--dur-1) var(--ease-std), color var(--dur-1) var(--ease-std);
}
.rail a:hover { text-decoration: none; color: var(--text); background: var(--surface-2); }
.rail a svg { width: 22px; height: 22px; padding: 5px; box-sizing: content-box; border-radius: var(--r-sm); }
.rail a[aria-current="page"] { color: var(--accent-text); font-weight: var(--fw-semibold); }
.rail a[aria-current="page"] svg { background: var(--accent-soft); color: var(--accent-text); }
.rail .caps { margin: var(--sp-5) 0 var(--sp-2); padding: 0 12px; }
.rail-brand { display: flex; justify-content: center; align-items: center; height: var(--header-h); margin-bottom: var(--sp-3); }
.rail-brand .brand-logo { height: 13px; }
.rail-mark { display: none; }
.rail-foot { margin-top: auto; padding-top: var(--sp-4); }
.rail .userbox { display: none; }

@media (min-width: 900px) {
  .app { grid-template-columns: var(--rail-w) minmax(0, 1fr); grid-template-areas: "rail header" "rail main"; }
  .app-header .home { display: none; }
  .app-header { background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; position: static; }
  .rail {
    grid-area: rail; display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; overflow-y: auto;
    padding: 0 8px var(--sp-4); border-right: 1px solid var(--line);
  }
  .rail .brand-logo { display: none; }
  .rail-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--text); color: var(--bg);
    font-weight: 700; font-size: 15px; letter-spacing: -.04em; }
  .rail .caps { text-align: center; padding: 0; }
  .rail .more-group { display: none; }
  .wrap { padding-bottom: var(--sp-9); }
  .app-header { height: 64px; }
  .hdr-date { display: inline; }
  .page-head { margin-top: 0; }
}
@media (min-width: 1200px) {
  .app { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .rail { padding: 0 14px var(--sp-5); }
  .rail-brand { justify-content: flex-start; padding: 0 10px; }
  .rail .brand-logo { display: block; }
  .rail-mark { display: none; }
  .rail a { flex-direction: row; gap: 10px; padding: 7px 10px; font-size: var(--fs-base); text-align: left; }
  .rail a svg { width: 18px; height: 18px; padding: 0; background: none !important; }
  .rail a[aria-current="page"] { background: var(--surface); box-shadow: var(--shadow-1); color: var(--text); }
  .rail a[aria-current="page"] svg { color: var(--accent-text); }
  .rail .caps { text-align: left; padding: 0 10px; }
  .rail .more-group { display: grid; }
  .rail .userbox { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--r-md); background: var(--surface-2); }
  .userbox b { display: block; font-size: var(--fs-base); font-weight: var(--fw-semibold); line-height: 1.2; }
  .userbox div > span { font-size: var(--fs-sm); color: var(--text-3); }
  .userbox .avatar { width: 30px; height: 30px; box-shadow: none; font-size: 12px; color: #fff; }
}

/* ---------- Нижній таб-бар (телефон, планшет до 900) ---------- */
.tabbar {
  position: fixed; z-index: var(--z-tabbar); left: 50%; transform: translateX(-50%);
  bottom: calc(10px + var(--safe-b)); width: min(calc(100% - 2 * var(--gutter) + 8px), 520px);
  display: grid; grid-template-columns: repeat(5, 1fr); height: var(--tabbar-h); padding: 6px;
  border-radius: 24px; background: var(--surface-glass); box-shadow: var(--shadow-3);
  -webkit-backdrop-filter: saturate(1.8) blur(22px); backdrop-filter: saturate(1.8) blur(22px);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .tabbar { background: var(--surface-glass-solid); } }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 18px;
  color: var(--text-3); font-size: var(--fs-xs); font-weight: var(--fw-medium); line-height: 1;
  transition: color var(--dur-2) var(--ease-std), background var(--dur-2) var(--ease-std);
}
.tabbar a:hover { text-decoration: none; color: var(--text); }
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a[aria-current="page"] { color: var(--accent-text); background: var(--accent-soft); font-weight: var(--fw-semibold); }
.tabbar a:active { transform: scale(.96); }
@media (min-width: 900px) { .tabbar { display: none; } }

/* ---------- Заголовок екрана + період (≤ 2 рівні керування) ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3) var(--sp-3); margin: var(--sp-1) 0 var(--sp-4); }
.page-title { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.page-title h1 { font-size: var(--fs-xl); font-weight: var(--fw-semibold); letter-spacing: -0.02em; }
.page-sub { font-size: var(--fs-sm); color: var(--text-3); margin-top: 2px; }
.crumbs { display: flex; gap: 6px; align-items: center; font-size: var(--fs-sm); color: var(--text-3); margin-bottom: 2px; }
.seg {
  display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface-3);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / .04);
}
.seg a {
  display: inline-flex; align-items: center; justify-content: center; height: 30px; padding: 0 12px; border-radius: 9px;
  font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-2); white-space: nowrap;
  transition: background var(--dur-2) var(--ease-std), color var(--dur-2) var(--ease-std);
}
.seg a:hover { text-decoration: none; color: var(--text); }
.seg a[aria-current="page"] { background: var(--surface); color: var(--text); font-weight: var(--fw-semibold); box-shadow: var(--shadow-1); }
.seg.full { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
.period-line { display: flex; align-items: center; gap: var(--sp-2); width: 100%; }
.period-nav { display: inline-flex; align-items: center; gap: 2px; }
.period-label { font-size: var(--fs-base); font-weight: var(--fw-semibold); padding: 0 4px; white-space: nowrap; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-sm); color: var(--text-2);
  background: transparent; border: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.compare { display: inline-flex; gap: 6px; margin-left: auto; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-2); white-space: nowrap;
  background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong);
}
.chip:hover { text-decoration: none; color: var(--text); }
.chip[aria-pressed="true"], .chip.on { background: var(--text); color: var(--bg); box-shadow: none; }
.chip-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 2px var(--gutter); }
.chip-row::-webkit-scrollbar { display: none; }
@media (min-width: 600px) {
  .page-head { margin: var(--sp-4) 0 var(--sp-6); }
  .page-title h1 { font-size: var(--fs-2xl); letter-spacing: -0.025em; }
  .page-sub { font-size: var(--fs-base); }
  .period-line { width: auto; }
}

/* ---------- Сітка ---------- */
.stack { display: grid; gap: var(--stack-gap); min-width: 0; }
.section { margin-top: var(--section-gap); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); margin: 0 2px var(--sp-3); }
.section-title h2 { font-size: var(--fs-lg); }
.grid { display: grid; gap: var(--stack-gap); grid-template-columns: minmax(0, 1fr); }
.grid > * { min-width: 0; }
@media (min-width: 600px) { .grid.two-md { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 900px) {
  .grid.dash { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .g-main { grid-column: span 7; }
  .g-side { grid-column: span 5; }
  .g-half { grid-column: span 6; }
  .g-full { grid-column: 1 / -1; }
}
@media (min-width: 1200px) { .g-main { grid-column: span 8; } .g-side { grid-column: span 4; } }

/* ---------- Картка ---------- */
.card {
  position: relative; background: var(--surface); border-radius: var(--r-lg); padding: var(--card-pad);
  box-shadow: var(--shadow-1); min-width: 0;
}
.card.flat { background: var(--surface-2); box-shadow: none; }
.card.flush { padding-left: 0; padding-right: 0; }
.card.flush > .card-head, .card.flush > .pad { padding-left: var(--card-pad); padding-right: var(--card-pad); }
.card-head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-4); min-height: 24px; }
.card-head h2 { font-size: var(--fs-md); font-weight: var(--fw-semibold); letter-spacing: -0.01em; }
.card-head .sub { font-size: var(--fs-sm); color: var(--text-3); }
.card-head .more {
  margin-left: auto; display: inline-flex; align-items: center; gap: 2px; font-size: var(--fs-sm); font-weight: var(--fw-medium);
  color: var(--text-2); padding: 4px 6px 4px 10px; border-radius: var(--r-pill);
}
.card-head .more:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.card-head .more svg { width: 14px; height: 14px; }
.card-head .ico-soft { width: 28px; height: 28px; }
.card.col { display: flex; flex-direction: column; }
.card.col > .chart-wrap { flex: 1 1 auto; }
.card.col > .chart-wrap > .chart { height: 100%; min-height: 190px; max-height: 340px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: auto; padding-top: var(--sp-5); }
.mini-stats div { padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); min-width: 0; }
.mini-stats span { display: block; font-size: var(--fs-xs); line-height: 1.3; color: var(--text-3); overflow-wrap: anywhere; hyphens: auto; }
.mini-stats div { display: flex; flex-direction: column; justify-content: space-between; }
.mini-stats b { display: block; margin-top: 2px; font-size: var(--fs-md); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.note { font-size: var(--fs-sm); color: var(--text-3); margin-top: var(--sp-3); }
.divider { height: 1px; background: var(--line); margin: var(--sp-4) 0; border: 0; }

/* ---------- Герой (фірмова «чорнильна» картка з авророю) ---------- */
.hero-card {
  position: relative; isolation: isolate; overflow: hidden; color: var(--hero-text);
  border-radius: var(--r-xl); padding: 20px 20px 0; border: 1px solid transparent;
  background: var(--hero-aurora), linear-gradient(165deg, var(--hero-ink) 0%, var(--hero-ink-2) 100%) padding-box, var(--grad-ring) border-box;
  box-shadow: var(--shadow-hero);
}
.hero-card::after { /* тонкий шум-світло зверху: об'єм */
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, rgb(255 255 255 / .07) 0%, transparent 38%);
}
.hero-card a { color: inherit; }
.hero { display: block; color: inherit; }
.hero:hover { text-decoration: none; }
.hero-top { display: flex; align-items: center; gap: var(--sp-2); }
.hero-top .label { font-size: var(--fs-base); font-weight: var(--fw-medium); color: var(--hero-text-2); }
.hero-value {
  margin-top: 6px; font-size: var(--fs-display); font-weight: var(--fw-semibold); line-height: 1.02;
  letter-spacing: var(--ls-display); color: var(--hero-text);
}
.hero-value .unit { color: var(--hero-text-3); font-size: .5em; margin-left: .2em; }
.hero .deltas { margin-top: 10px; }
.hero-card .delta .ref { color: var(--hero-text-2); }
.hero-card .delta.up b { color: #8ff0bf; background: rgb(64 214 140 / .16); }
.hero-card .delta.down b { color: #ffb0ae; background: rgb(255 110 110 / .16); }
.hero-card .badge { background: rgb(255 255 255 / .12); color: var(--hero-text); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .14); }
.hero-spark { margin: 14px -20px 0; position: relative; }
.hero-axis { display: flex; justify-content: space-between; padding: 0 20px 14px; font-size: var(--fs-xs); color: var(--hero-text-3); font-variant-numeric: tabular-nums; }
.hero-stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0 -20px; padding: 14px 20px 16px;
  border-top: 1px solid rgb(255 255 255 / .08); background: rgb(255 255 255 / .03);
}
.hero-stats div { min-width: 0; }
@media (max-width: 399px) { .hero-stats b { font-size: var(--fs-base); } .hero-stats div + div { padding-left: 10px !important; } }
.hero-stats div + div { padding-left: 14px; border-left: 1px solid rgb(255 255 255 / .08); }
.hero-stats span { display: block; font-size: var(--fs-xs); color: var(--hero-text-3); }
.hero-stats b { display: block; margin-top: 2px; white-space: nowrap; font-size: var(--fs-md); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
@media (min-width: 600px) {
  .hero-card { padding: 26px 28px 0; }
  .hero-spark { margin: 18px -28px 0; }
  .hero-axis { padding: 0 28px 16px; }
  .hero-stats { margin: 0 -28px; padding: 16px 28px 18px; }
  .hero-stats div + div { padding-left: 20px; }
}
@media (min-width: 1200px) { .hero-value { font-size: var(--fs-display-lg); } }

/* ---------- Дельти, бейджі ---------- */
.deltas { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.delta { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); line-height: 1.2; min-width: 0; }
.delta b {
  display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 7px; border-radius: var(--r-pill);
  font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.delta b i { font-style: normal; font-size: .72em; }
.delta.up b { color: var(--good); background: var(--good-soft); }
.delta.down b { color: var(--bad); background: var(--bad-soft); }
.delta.flat-d b { color: var(--text-2); background: var(--surface-2); }
.delta .ref { color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up { color: var(--good); } .down { color: var(--bad); }
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-semibold); white-space: nowrap; background: var(--surface-2); color: var(--text-2);
}
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn, .badge.prelim { background: var(--warn-soft); color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.badge.neutral { background: var(--surface-2); color: var(--text-2); }
.badge .dot { width: 6px; height: 6px; box-shadow: none; }

/* ---------- KPI-плитки (число + одиниця + дельта + спарклайн) ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--stack-gap); }
@media (min-width: 900px) { .kpi-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi {
  container-type: inline-size; position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0;
  padding: 14px 14px 12px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1); color: var(--text);
  transition: box-shadow var(--dur-1) var(--ease-std), transform var(--dur-1) var(--ease-std);
}
a.kpi:hover { text-decoration: none; box-shadow: var(--shadow-2); }
a.kpi:active { transform: scale(.985); }
.kpi-label { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-2); }
.kpi-value { font-size: 1.5rem; font-weight: var(--fw-semibold); letter-spacing: -0.025em; line-height: 1.1; white-space: nowrap; }
.kpi-value small, .kpi-value .unit { font-size: .6em; font-weight: var(--fw-medium); color: var(--text-3); margin-left: .15em; letter-spacing: 0; }
.kpi .delta { font-size: var(--fs-xs); }
.kpi .delta b { height: 20px; padding: 0 6px; }
.kpi-spark { display: block; width: 100%; height: 30px; margin-top: 2px; overflow: visible; }
.kpi.wide { grid-column: 1 / -1; }
.bench { font-size: var(--fs-xs); color: var(--text-3); display: inline-flex; align-items: center; gap: 5px; }
.bench::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--good); }
.bench.no::before { background: var(--warn); }
@container (max-width: 150px) { .kpi-spark { display: none; } .kpi .delta .ref { display: none; } }
@media (min-width: 600px) { .kpi { padding: 16px 18px 14px; } .kpi-value { font-size: var(--fs-2xl); } }

/* ---------- Сигнали / AI-підсумок ---------- */
.ai-head { display: flex; align-items: center; gap: 10px; margin-bottom: var(--sp-3); }
.ai-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--grad-signature); color: #fff; box-shadow: 0 4px 12px -4px var(--focus); }
.ai-mark svg { width: 16px; height: 16px; }
.ai-head h2 { font-size: var(--fs-md); }
.ai-head .sub { margin-left: auto; font-size: var(--fs-xs); color: var(--text-3); }
.signals { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.signal {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) 16px; align-items: start; gap: 12px; padding: 10px 8px;
  margin: 0 -8px; border-radius: var(--r-md); color: var(--text);
}
a.signal:hover { background: var(--surface-2); text-decoration: none; }
.signal .ico { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); }
.signal .ico svg { width: 17px; height: 17px; }
.signal .ico.good { background: var(--good-soft); color: var(--good); }
.signal .ico.bad { background: var(--bad-soft); color: var(--bad); }
.signal .ico.warn { background: var(--warn-soft); color: var(--warn); }
.signal .ico.info { background: var(--accent-soft); color: var(--accent-text); }
.signal-text { font-size: var(--fs-base); line-height: 1.45; color: var(--text-2); padding-top: 1px; }
.signal-text b { color: var(--text); font-weight: var(--fw-semibold); }
.signal .chev { width: 16px; height: 16px; margin-top: 8px; color: var(--text-3); }

/* ---------- Списки з drill-down ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li + li { border-top: 1px solid var(--line); }
.lrow {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "av name val" "av meta d" "av bar bar";
  align-items: center; column-gap: 12px; row-gap: 3px; padding: 12px 0; color: var(--text);
}
.lrow.nobar { grid-template-areas: "av name val" "av meta d"; }
a.lrow:hover { text-decoration: none; }
a.lrow:hover .row-name { color: var(--accent-text); }
.lrow .av { grid-area: av; align-self: center; }
.row-name { grid-area: name; font-size: var(--fs-base); font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-val { grid-area: val; font-size: var(--fs-base); font-weight: var(--fw-semibold); text-align: right; white-space: nowrap; }
.row-meta { grid-area: meta; font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta.r { grid-area: d; justify-self: end; }
.row-meta.r .delta b { height: 18px; padding: 0 5px; font-size: var(--fs-xs); }
.lrow .hbar { grid-area: bar; margin-top: 6px; }
.av {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; flex: none;
  font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-2); background: var(--surface-2);
}
.av svg { width: 18px; height: 18px; }
.av.a1 { background: var(--accent-soft); color: var(--accent-text); }
.av.a2 { background: color-mix(in srgb, var(--chart-2) 16%, transparent); color: var(--text); }
.av.a3 { background: color-mix(in srgb, var(--chart-3) 16%, transparent); color: var(--text); }
.av.a4 { background: color-mix(in srgb, var(--chart-4) 18%, transparent); color: var(--text); }
.av.a5 { background: color-mix(in srgb, var(--chart-5) 16%, transparent); color: var(--text); }
.av.prod { width: 40px; height: 48px; border-radius: 10px; background: linear-gradient(160deg, var(--surface-3), var(--surface-2)); color: var(--text-2); }

/* горизонтальні бари (SVG, ширина — атрибутом %) */
.hbar { display: block; width: 100%; height: 6px; overflow: visible; }
.hbar .track { fill: var(--surface-2); }
.hbar .bar { fill: url(#g-hbar); }
.hbar .bar.c2 { fill: var(--chart-2); } .hbar .bar.c3 { fill: var(--chart-3); } .hbar .bar.c4 { fill: var(--chart-4); }
.hbar .bar.c5 { fill: var(--chart-5); } .hbar .bar.c6, .hbar .bar.c8 { fill: var(--chart-cmp); }
.hbar .bar.good { fill: var(--good); } .hbar .bar.bad { fill: var(--bad); } .hbar .bar.warn { fill: var(--warn); }
.hbar .target { stroke: var(--text); stroke-width: 2; stroke-linecap: round; }
.hbar.tall { height: 10px; }

/* ---------- Графіки (серверний SVG; % по X, px по Y; градієнти — класами) ---------- */
.chart-wrap { position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 8px; }
.chart.yaxis { width: 44px; }
.yax { display: flex; flex-direction: column; justify-content: space-between; padding: 6px 0 26px; font-size: var(--fs-xs); color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; line-height: 1; }
.chart { display: block; width: 100%; overflow: visible; }
.chart text { font: var(--fw-medium) var(--fs-xs) var(--font-sans); fill: var(--text-3); font-variant-numeric: tabular-nums; }
.chart .val { fill: var(--text); font-weight: var(--fw-semibold); }
.chart .grid { stroke: var(--chart-grid); stroke-dasharray: 2 4; }
.chart .base { stroke: var(--line-strong); }
.chart .s1 { fill: url(#g-bar); }
.chart .s1.dim { fill: var(--chart-bar-dim); }
.chart .s1.hl { fill: url(#g-bar-hl); }
.chart .l1, .chart .l2, .chart .l3, .chart .lt, .chart .lc {
  fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke;
}
.chart .l1 { stroke: url(#g-line); }
.chart .l3, .chart .lc { stroke: var(--chart-cmp); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .lt { stroke: var(--warn); stroke-width: 1.25; stroke-dasharray: 2 3; }
.chart .area1 { fill: url(#g-area); stroke: none; }
.chart .dotm { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; }
.chart .halo { fill: var(--accent); opacity: .18; }
.chart .now { stroke: var(--line-strong); stroke-dasharray: 2 3; vector-effect: non-scaling-stroke; }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--accent-softer); }
.chart .sep { stroke: var(--surface); stroke-width: 2; }
.chart .neg { fill: color-mix(in srgb, var(--bad) 72%, var(--surface)); }
.chart .pos { fill: url(#g-bar); }
.chart .sub { fill: url(#g-bar-hl); }
.chart .wf-link { stroke: var(--line-strong); stroke-dasharray: 2 2; }
.xax { display: flex; justify-content: space-between; margin-top: 8px; font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.xax.cols { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; text-align: center; }
.xax .now-l { color: var(--text); font-weight: var(--fw-semibold); }

/* градієнти: <stop> отримують колір класом, тож тема і акцент перемикаються CSS */
.gs-a0 { stop-color: var(--accent); stop-opacity: var(--area-top); }
.gs-a1 { stop-color: var(--accent); stop-opacity: 0; }
.gs-l0 { stop-color: var(--accent-3); }
.gs-l1 { stop-color: var(--accent); }
.gs-l2 { stop-color: var(--accent-2); }
.gs-b0 { stop-color: var(--accent); stop-opacity: var(--bar-top); }
.gs-b1 { stop-color: var(--accent); stop-opacity: var(--bar-bottom); }
.gs-h0 { stop-color: var(--accent-3); }
.gs-h1 { stop-color: var(--accent); }
.gs-hl0 { stop-color: var(--accent); }
.gs-hl1 { stop-color: var(--accent-2); }
.gs-w0 { stop-color: #ffffff; stop-opacity: .24; }
.gs-w1 { stop-color: #ffffff; stop-opacity: 0; }
.gs-hw0 { stop-color: var(--hero-line); stop-opacity: .65; }
.gs-hw1 { stop-color: #ffffff; }
/* графік на герої */
.hero-card .chart .l1 { stroke: url(#g-hero-line); stroke-width: 2.5; }
.hero-card .chart .area1 { fill: url(#g-hero-area); }
.hero-card .chart .l3 { stroke: rgb(255 255 255 / .38); }
.hero-card .chart .grid { stroke: rgb(255 255 255 / .08); }
.hero-card .chart .dotm { fill: #fff; stroke: none; }
.hero-card .chart .halo { fill: #fff; opacity: .22; }
.hero-card .chart .now { stroke: rgb(255 255 255 / .22); }
.spark .l1 { stroke-width: 1.75; }
.spark .area1 { opacity: .9; }
.spark.bad .l1 { stroke: var(--bad); }
.spark.bad .area1 { fill: url(#g-area-bad); }
.gs-r0 { stop-color: var(--bad); stop-opacity: .18; }
.gs-r1 { stop-color: var(--bad); stop-opacity: 0; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; list-style: none; margin: 0 0 var(--sp-3); padding: 0; font-size: var(--fs-sm); color: var(--text-2); }
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.legend b { color: var(--text); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.sw { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); flex: none; }
.sw.line { height: 3px; border-radius: 2px; width: 14px; background: var(--grad-signature); }
.sw.dash { height: 0; width: 14px; border-top: 2px dashed var(--chart-cmp); background: none; border-radius: 0; }
.sw.c1 { background: var(--accent); } .sw.c2 { background: var(--chart-2); } .sw.c3 { background: var(--chart-3); }
.sw.c4 { background: var(--chart-4); } .sw.c5 { background: var(--chart-5); } .sw.c8 { background: var(--chart-cmp); }
.share { display: flex; gap: 3px; height: 10px; margin: 4px 0 var(--sp-4); }
.share .chart { height: 10px; }
.share-svg rect { rx: 0; }
.share-svg .c1 { fill: var(--accent); } .share-svg .c2 { fill: var(--chart-2); } .share-svg .c3 { fill: var(--chart-3); }
.share-svg .c4 { fill: var(--chart-4); } .share-svg .c5 { fill: var(--chart-5); } .share-svg .c8 { fill: var(--chart-cmp); }
.share-svg .sep { stroke: var(--surface); stroke-width: 3; }

details.table-view { margin-top: var(--sp-3); }
details.table-view summary { cursor: pointer; list-style: none; font-size: var(--fs-sm); color: var(--text-3); display: inline-flex; align-items: center; gap: 6px; }
details.table-view summary::-webkit-details-marker { display: none; }
details.table-view summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform var(--dur-2); }
details.table-view[open] summary::before { transform: rotate(45deg); }

/* ---------- Таблиці ---------- */
.tbl-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--card-pad)); padding: 0 var(--card-pad); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
th { text-align: left; font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--text-3); padding: 0 8px 10px; white-space: nowrap; }
td { padding: 11px 8px; border-top: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
th.r, td.r { text-align: right; }
tbody tr { transition: background var(--dur-1); }
tbody tr:hover td { background: var(--surface-2); }
tfoot td { font-weight: var(--fw-semibold); border-top: 1px solid var(--line-strong); }
.cell-name { display: flex; align-items: center; gap: 10px; white-space: normal; min-width: 0; }
.cell-name b { display: block; font-weight: var(--fw-medium); line-height: 1.25; }
.cell-sub { display: block; font-size: var(--fs-xs); color: var(--text-3); }

/* P&L */
.pnl { list-style: none; margin: 0; padding: 0; }
.pnl li { display: grid; grid-template-columns: minmax(0, 1fr) auto 52px; align-items: center; gap: 4px 12px; padding: 10px 0; font-size: var(--fs-base); }
.pnl li + li { border-top: 1px solid var(--line); }
.pnl .lbl { color: var(--text-2); }
.pnl .v { font-weight: var(--fw-medium); text-align: right; font-variant-numeric: tabular-nums; }
.pnl .p { text-align: right; font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.pnl .hbar { grid-column: 1 / -1; height: 4px; }
.pnl li.sub { padding: 12px 0; }
.pnl li.sub .lbl { color: var(--text); font-weight: var(--fw-semibold); }
.pnl li.sub .v { font-weight: var(--fw-semibold); }
.pnl li.total { margin-top: 6px; padding: 14px 14px; border: 0; border-radius: var(--r-md); background: var(--accent-softer); box-shadow: inset 0 0 0 1px var(--accent-soft); }
.pnl li.total .lbl { color: var(--text); font-weight: var(--fw-semibold); }
.pnl li.total .v { font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--accent-text); }
.pnl li.total + li { border-top: 0; }
.pnl .minus { color: var(--text-2); }

/* Теплокарта розмірів: одна послідовна шкала акценту (не конкурує з героєм) */
.heat { border-collapse: separate; border-spacing: 4px; margin: -4px; width: calc(100% + 8px); font-size: var(--fs-sm); }
.heat th, .heat td { border: 0; padding: 0; text-align: center; background: none !important; }
.heat thead th { padding-bottom: 4px; }
.heat th.model { text-align: left; font-weight: var(--fw-medium); color: var(--text); font-size: var(--fs-sm); padding-right: 6px; white-space: nowrap; }
.heat td span { display: grid; place-items: center; height: 36px; border-radius: 8px; font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; }
.h0 { background: var(--surface-2); color: var(--text-3); }
.h1 { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); color: var(--text-2); }
.h2 { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); color: var(--text); }
.h3 { background: color-mix(in srgb, var(--accent) 40%, var(--surface)); color: var(--text); }
.h4 { background: var(--accent-solid); color: var(--on-accent); }
.hx { background: var(--bad-soft); color: var(--bad); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bad) 30%, transparent); }
.heat-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: var(--sp-3); font-size: var(--fs-xs); color: var(--text-3); }
.heat-legend .k { display: inline-flex; align-items: center; gap: 6px; }
.heat-legend .sq { width: 12px; height: 12px; border-radius: 4px; }

/* Прогрес-кільце / план */
.progress { height: 8px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.progress svg { display: block; width: 100%; height: 8px; }
.progress .bar { fill: url(#g-line); }

/* ---------- Кнопки, форми ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 18px;
  border: 0; border-radius: var(--r-sm); cursor: pointer; font: var(--fw-semibold) var(--fs-base)/1 var(--font-sans);
  color: var(--on-accent); background: var(--accent-solid);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .18), 0 1px 2px rgb(0 0 0 / .12), 0 6px 16px -6px var(--focus);
  transition: transform var(--dur-1) var(--ease-std), filter var(--dur-1);
}
.btn:hover { text-decoration: none; filter: brightness(1.06); }
.btn:active { transform: scale(.98); }
.btn.block { width: 100%; }
.btn.secondary { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.btn.ghost { background: transparent; color: var(--text-2); box-shadow: none; }
.btn.tg { background: linear-gradient(180deg, #127cbf, #0b72b3); color: #fff; box-shadow: inset 0 1px 0 rgb(255 255 255 / .2), 0 6px 16px -6px rgb(15 120 186 / .55); }
.btn.tg:hover { background: #096aa6; }
.btn svg { width: 18px; height: 18px; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-4); }
.form { display: grid; gap: var(--sp-4); }
.field { display: grid; gap: 6px; }
.field label, .field .lbl { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-2); }
.field .hint { font-size: var(--fs-xs); color: var(--text-3); }
.input, select.input {
  width: 100%; min-height: var(--tap); padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line-input);
  background: var(--surface); color: var(--text); font: var(--fw-regular) var(--fs-md) var(--font-sans);
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
.input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input::placeholder { color: var(--text-3); }
.err { color: var(--bad); font-size: var(--fs-sm); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: 12px 0; border-top: 1px solid var(--line); }
.toggle-row:first-child { border-top: 0; }
.switch { appearance: none; width: 42px; height: 26px; border-radius: var(--r-pill); background: var(--surface-3); position: relative; cursor: pointer; transition: background var(--dur-2); flex: none; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform var(--dur-2) var(--ease-out); }
.switch:checked { background: var(--accent-solid); }
.switch:checked::after { transform: translateX(16px); }

/* ---------- Порожні стани, скелетони ---------- */
.empty { display: grid; justify-items: center; text-align: center; gap: 6px; padding: var(--sp-6) var(--sp-4); }
.empty .orb {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; margin-bottom: var(--sp-2);
  background: radial-gradient(circle at 30% 20%, var(--accent-soft), transparent 70%), var(--surface-2);
  color: var(--accent-text); box-shadow: inset 0 0 0 1px var(--line);
}
.empty .orb svg { width: 24px; height: 24px; }
.empty b { font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.empty p { max-width: 34ch; font-size: var(--fs-base); color: var(--text-2); }
.sk { display: block; border-radius: 8px; background: var(--skeleton); background-size: 200% 100%; animation: sk 1.4s linear infinite; }
.sk.t { height: 12px; width: 40%; } .sk.v { height: 28px; width: 70%; margin-top: 8px; } .sk.c { height: 120px; margin-top: 14px; border-radius: 12px; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Логін ---------- */
.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: var(--sp-6) var(--gutter);
  background:
    radial-gradient(700px 420px at 85% -10%, var(--accent-soft), transparent 70%),
    radial-gradient(600px 400px at 0% 110%, color-mix(in srgb, var(--accent-2) 16%, transparent), transparent 70%),
    var(--bg);
}
.auth-card { width: min(100%, 400px); padding: 32px 24px 28px; border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow-3); }
.auth-card .brand-logo { height: 16px; margin-bottom: var(--sp-8); }
.auth-card h1 { font-size: var(--fs-2xl); letter-spacing: -0.03em; }
.auth-card .lead { margin: 8px 0 var(--sp-6); color: var(--text-2); font-size: var(--fs-base); }
.or { display: flex; align-items: center; gap: 12px; margin: var(--sp-5) 0; font-size: var(--fs-xs); color: var(--text-3); }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line-strong); }
.auth-foot { display: flex; gap: 8px; align-items: flex-start; margin-top: var(--sp-6); font-size: var(--fs-xs); color: var(--text-3); }
.auth-foot svg { width: 14px; height: 14px; margin-top: 1px; }
.crumbs svg { width: 14px; height: 14px; }
.auth-preview { display: none; }
@media (min-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0; padding: 0; place-items: stretch; }
  .auth > .auth-side { display: grid; place-items: center; padding: var(--sp-8); }
  .auth-card { padding: 40px 36px 32px; }
  .auth-preview { display: grid; place-items: center; padding: var(--sp-8); position: relative; overflow: hidden;
    background: var(--hero-aurora), linear-gradient(165deg, var(--hero-ink), var(--hero-ink-2)); color: var(--hero-text); }
  .auth-preview .hero-card { width: min(100%, 440px); box-shadow: 0 40px 80px -20px rgb(0 0 0 / .6); }
  .auth-quote { position: absolute; left: var(--sp-8); right: var(--sp-8); bottom: var(--sp-8); font-size: var(--fs-lg); color: var(--hero-text-2); letter-spacing: -0.01em; }
  .auth-quote b { color: var(--hero-text); font-weight: var(--fw-semibold); }
}

/* ---------- Рух ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes reveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes pulse { 0% { transform: scale(1); opacity: .28; } 100% { transform: scale(2.6); opacity: 0; } }
.rise { animation: rise var(--dur-3) var(--ease-out) both; }
.d1 { animation-delay: 40ms; } .d2 { animation-delay: 80ms; } .d3 { animation-delay: 120ms; }
.d4 { animation-delay: 160ms; } .d5 { animation-delay: 200ms; } .d6 { animation-delay: 240ms; }
.chart .draw { animation: reveal var(--dur-draw) var(--ease-out) both; }
.chart .halo { transform-box: fill-box; transform-origin: center; animation: pulse 2.4s var(--ease-out) infinite; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
/* Telegram на слабких Android (tg.js ставить .tg-low): без blur і анімацій */
.tg-low .app-header, .tg-low .tabbar { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--surface-glass-solid); }
.tg-low * { animation: none !important; }

/* ---------- Службові ---------- */
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); }
.row-flex { display: flex; align-items: center; gap: var(--sp-2); }
.ml-auto { margin-left: auto; }
.hide-sm { display: none; }
@media (min-width: 600px) { .hide-sm { display: revert; } .only-sm { display: none; } }
@media (min-width: 900px) { .o1 { order: 1; } .o2 { order: 2; } .o3 { order: 3; } }


/* ==================================================================
   Шар сумісності v1 → v2 (класи екранів, яких немає в прототипах) + правки аудитів 08.11
   (AUDIT_IMPL_visual / AUDIT_IMPL_a11y). Лише токени v2; жодних inline-стилів.
   ================================================================== */

/* ---------- a11y: фокус не ховається під шапкою/таб-баром (WCAG 2.4.11) ---------- */
html { scroll-padding-top: calc(var(--header-h) + 8px); scroll-padding-bottom: calc(var(--tabbar-h) + 28px + var(--safe-b)); }
@media (min-width: 900px) { html { scroll-padding-top: 16px; scroll-padding-bottom: 16px; } }
input:focus-visible, select:focus-visible, textarea:focus-visible, iframe:focus-visible, summary:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
[hidden] { display: none !important; }
.hero-value { color: var(--text); }
.hero-card .hero-value { color: var(--hero-text); }

/* ---------- Шапка: свіжість + меню аватара (тема і вихід) ---------- */
.app-header .home { flex: none; }
.app-header .fresh { min-width: 0; height: 32px; }
.app-header .fresh:hover { text-decoration: none; }
.fresh-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.umenu { position: relative; flex: none; }
.umenu > summary { list-style: none; display: grid; place-items: center; width: var(--tap); height: var(--tap); cursor: pointer; border-radius: 50%; }
.umenu > summary::-webkit-details-marker { display: none; }
.umenu > summary .avatar { pointer-events: none; }
.umenu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: var(--z-sheet); min-width: 220px; padding: 8px;
  border-radius: var(--r-md); background: var(--surface-raised); box-shadow: var(--shadow-3); display: grid; gap: 2px;
}
.umenu-who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.umenu-who b { display: block; font-size: var(--fs-base); font-weight: var(--fw-semibold); }
.umenu-who span { font-size: var(--fs-sm); color: var(--text-3); }
.umenu-pop .theme-btn, .umenu-pop .logout button, .umenu-pop a {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--tap); padding: 0 10px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text); font: var(--fw-medium) var(--fs-base) var(--font-sans); cursor: pointer; text-align: left;
}
.umenu-pop .theme-btn:hover, .umenu-pop .logout button:hover, .umenu-pop a:hover { background: var(--surface-2); text-decoration: none; }
.umenu-pop .theme-label { margin-left: auto; color: var(--text-3); }
.logout { margin: 0; }
.theme-ico { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid currentColor; background: linear-gradient(90deg, currentColor 50%, transparent 50%); flex: none; }
.theme-btn[data-current="light"] .theme-ico { background: transparent; }
.theme-btn[data-current="dark"] .theme-ico { background: currentColor; }
.demo-badge { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--on-accent); background: var(--accent-solid); padding: 2px 8px; border-radius: var(--r-pill); }
@media (max-width: 380px) { .app-header { gap: 6px; } .app-header .fresh { padding: 0 8px; } }

/* rail: на 900–1199 видно лише головні розділи + «Ще»; від 1200 — повний сайдбар */
.rail .rail-more { display: none; }
@media (min-width: 900px) and (max-width: 1199px) { .rail .rail-more { display: grid; } .rail .more-group { display: none; } }
.rail .more-group .caps { margin-top: var(--sp-5); }
.rail-foot .userbox b, .rail-foot .userbox span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Telegram Mini App: компактна неприлипла шапка, тему задає Telegram ---------- */
html.tg .app-header { position: static; height: auto; min-height: 44px; padding-top: max(var(--safe-t), 4px); }
html.tg .umenu { display: none; }

/* ---------- Керування: таргети дотику ≥ 44 px (видимий розмір менший, зона — ::after) ---------- */
.seg a, .chip, .icon-btn, .card-head .more, .back { position: relative; }
.seg a::after, .chip::after, .card-head .more::after { content: ""; position: absolute; inset: -7px -2px; }
.seg a { height: 36px; }
.chip { height: 36px; flex: none; }
.chip-row .chip { flex: none; }
.chip-row { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
.period-nav .icon-btn, .icon-btn { width: var(--tap); height: var(--tap); }
.seg.three { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.seg-scroll { overflow-x: auto; scrollbar-width: none; max-width: 100%; margin: 0 calc(-1 * var(--gutter)); padding: 8px var(--gutter); }
.seg-scroll::-webkit-scrollbar { display: none; }
.seg-scroll .seg { min-width: max-content; }
@media (min-width: 600px) { .seg-scroll { margin: 0; padding: 8px 0; } }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap); font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-2); }
.back svg { width: 16px; height: 16px; }
.back:hover { color: var(--text); text-decoration: none; }
.custom-period { display: none; width: 100%; }
.custom-period.on, .custom-period:target { display: grid; }
.custom-period { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: var(--sp-2); align-items: end; }
.custom-period label { font-size: var(--fs-xs); }

/* ---------- Сітки v1 ---------- */
.grid-2, .grid-3 { display: grid; gap: var(--stack-gap); }
.grid-2 > *, .grid-3 > * { min-width: 0; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .span-2 { grid-column: span 2; } }
@media (min-width: 640px) { .kpi-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.wrap > h1 { margin: var(--sp-1) 0 var(--sp-3); font-size: var(--fs-xl); }
.card > h2 { margin-bottom: var(--sp-3); font-size: var(--fs-md); }
.wrap > .card + .card, .wrap > .card { margin-bottom: var(--stack-gap); }
.card.narrow { max-width: 420px; margin: var(--sp-6) auto; }
.section-title { margin: var(--sp-3) 2px var(--sp-2); }
.card-head { justify-content: flex-start; }
.card-head > .caps:last-child, .card-head > .badge:last-child { margin-left: auto; }

/* ---------- Список: без аватара — 2 колонки (v1); з аватаром — v2 ---------- */
.lrow { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: none; align-items: baseline; column-gap: var(--sp-3); min-height: var(--tap); }
.lrow > * { grid-area: auto; }
.lrow .hbar { grid-area: auto; grid-column: 1 / -1; }
.lrow .row-meta.r { justify-self: end; text-align: right; }
.lrow.has-av { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "av name val" "av meta d" "av bar bar"; align-items: center; }
.lrow.has-av.nobar { grid-template-areas: "av name val" "av meta d"; }
.lrow.has-av .av { grid-area: av; } .lrow.has-av .row-name { grid-area: name; } .lrow.has-av .row-val { grid-area: val; }
.lrow.has-av .row-meta { grid-area: meta; } .lrow.has-av .row-meta.r { grid-area: d; } .lrow.has-av .hbar { grid-area: bar; grid-column: auto; }
.row-val.neg { color: var(--bad); }
.rows > li > .lrow { padding: 10px 0; }

/* ---------- Графіки: класи v1, яких немає в прототипі ---------- */
.chart .ylab { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.card.flat .chart .ylab { stroke: var(--surface-2); }
.chart .s2 { fill: var(--chart-2); } .chart .s3 { fill: var(--chart-3); } .chart .s4 { fill: var(--chart-4); }
.chart .s5 { fill: var(--chart-5); } .chart .s6, .chart .s8 { fill: var(--chart-cmp); }
.chart .l2 { stroke: var(--chart-2); } .chart .l8 { stroke: var(--chart-cmp); stroke-dasharray: 4 4; }
.chart .l2, .chart .l8 { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart .area3 { fill: var(--chart-3); opacity: .1; }
.chart .band { fill: var(--good); opacity: .1; }
.chart .a1 { fill: color-mix(in srgb, var(--chart-2) 35%, var(--surface)); }
.chart .a2 { fill: color-mix(in srgb, var(--chart-2) 65%, var(--surface)); }
.chart .a3 { fill: var(--chart-2); }
.chart .s1.dotm, .chart .s3.dotm { fill: var(--surface); }
.chart .s3.dotm { stroke: var(--chart-cmp); stroke-width: 2; }
.sw.tgt { height: 0; width: 14px; border-top: 2px dashed var(--warn); background: none; border-radius: 0; }
.sw.bandsw { background: var(--good-soft); box-shadow: inset 0 0 0 1px var(--good); }
.sw.a1 { background: color-mix(in srgb, var(--chart-2) 35%, var(--surface)); }
.sw.a2 { background: color-mix(in srgb, var(--chart-2) 65%, var(--surface)); }
.sw.a3 { background: var(--chart-2); }
.sw.c6 { background: var(--chart-cmp); } .sw.c7 { background: var(--chart-5); }
.sw.line.c3 { background: var(--chart-cmp); }
.share > .chart { height: 10px; }
.share .chart rect.s1 { fill: var(--accent); }
.hbar.h4 { height: 4px; }

/* ---------- Таблиці v1: перенос у клітинках, числа — без переносу ---------- */
td { white-space: normal; vertical-align: top; }
td.r, th.r, td.num, th.num, .num { white-space: nowrap; }
td a { display: inline-block; padding-block: 6px; }
tbody tr:last-child td { border-bottom: 0; }
.cell-sub { font-weight: var(--fw-regular); }

/* ---------- Форми v1 ---------- */
label { display: grid; gap: 6px; font-size: var(--fs-sm); color: var(--text-2); }
input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=range]), textarea, select {
  font: var(--fw-regular) var(--fs-md) var(--font-sans); color: var(--text); background: var(--surface);
  border: 1px solid var(--line-input); border-radius: var(--r-sm); padding: 0 12px; min-height: var(--tap); width: 100%; min-width: 0;
}
input:not([type=checkbox]):not([type=radio]):focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
textarea { padding: 10px 12px; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent-solid); }
label.cb { display: flex; flex-direction: row; align-items: center; gap: var(--sp-2); min-height: var(--tap); font-size: var(--fs-sm); }
.input.mono, .code-box { font-family: var(--font-mono); font-size: var(--fs-sm); }
.code-box { word-break: break-all; }
.input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-2); }
.form.two { grid-template-columns: 1fr 1fr; } .form.two .btn { grid-column: 1 / -1; }
.status-line { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); }
.toggle-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; min-height: 56px; cursor: pointer; }
.toggle-row .t { font-size: var(--fs-md); color: var(--text); }
.toggle-row .d { display: block; font-size: var(--fs-sm); color: var(--text-3); }
.btn.sm { min-height: var(--tap); padding: 0 14px; }
.btn.danger { background: transparent; color: var(--bad); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn[disabled] { opacity: .5; cursor: default; }
a.btn { text-decoration: none; }
.link { background: none; border: 0; color: var(--accent-text); text-decoration: underline; font: inherit; min-height: var(--tap); cursor: pointer; }
.row { border-top: 1px solid var(--line); padding: var(--sp-3) 0; display: grid; gap: var(--sp-2); }
.row:first-of-type { border-top: 0; }
.row-h { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.inline { display: flex; gap: var(--sp-2); } .inline input { flex: 1; min-width: 0; }
.actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; height: 24px; font-size: var(--fs-xs); font-weight: var(--fw-semibold); padding: 0 10px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--text-2); }
.pill.good { color: var(--good); background: var(--good-soft); } .pill.bad { color: var(--bad); background: var(--bad-soft); }
details > summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; }
details.table-view summary { min-height: var(--tap); }
.ok { color: var(--good); }
.err { color: var(--bad); }
.check { color: var(--good); font-size: var(--fs-sm); margin-top: var(--sp-2); }
.nw { white-space: nowrap; }
.clip { overflow-wrap: anywhere; min-width: 0; }
.doc-type { display: block; font-size: var(--fs-xs); color: var(--text-3); }
td.neg, .neg, .kpi-value.neg { color: var(--bad); }
.kpi.neg .kpi-value { color: var(--bad); }
.kpi-sub { display: block; font-size: var(--fs-xs); color: var(--text-3); overflow-wrap: anywhere; }
.unit { margin-left: .15em; }
.toggle-row .unit, .tgt .unit, label .unit { font-size: var(--fs-sm); color: var(--text-3); }

/* ---------- Статистики, журнали v1 ---------- */
.log { list-style: none; padding: 0; margin: 0; font-size: var(--fs-sm); }
.log li { padding: 8px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; } .log span { color: var(--text-3); }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-3); }
.stats > div { padding: 12px 14px; border-radius: var(--r-md); background: var(--surface); }
.card.flat .stats > div { background: var(--surface); }
.stat-v { font-size: var(--fs-lg); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.kpi-l { font-size: var(--fs-sm); color: var(--text-2); }
.kv { display: flex; justify-content: space-between; gap: var(--sp-3); } .kv b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.settings-nav, .recips, .more-list { list-style: none; margin: 0; padding: 0; }
.settings-nav a { display: grid; grid-template-columns: minmax(0, 1fr) auto 16px; gap: var(--sp-2); align-items: center; min-height: 52px; color: var(--text); border-top: 1px solid var(--line); }
.settings-nav li:first-child a { border-top: 0; }
.settings-nav svg { width: 16px; height: 16px; color: var(--text-3); }
.recips li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-2); padding: 10px 0; border-top: 1px solid var(--line); align-items: center; }
.recips li:first-child { border-top: 0; }
.code { font-family: var(--font-mono); font-size: var(--fs-sm); background: var(--surface-2); padding: 2px 6px; border-radius: var(--r-xs); }
.more-list a { display: grid; grid-template-columns: 36px minmax(0, 1fr) 16px; gap: var(--sp-3); align-items: center; min-height: 60px; color: var(--text); border-top: 1px solid var(--line); }
.more-list a:hover { text-decoration: none; }
.more-list a:hover > span { color: var(--accent-text); }
.more-list li:first-child a { border-top: 0; }
.more-list a > svg:first-child { width: 36px; height: 36px; padding: 8px; border-radius: 11px; background: var(--surface-2); color: var(--text-2); }
.more-list svg.chev { width: 16px; height: 16px; color: var(--text-3); }
.more-list .d { display: block; font-size: var(--fs-sm); color: var(--text-3); }

/* ---------- Стани v1 ---------- */
.callout { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: var(--sp-3); padding: var(--sp-3) 14px; border-radius: var(--r-md); font-size: var(--fs-sm); line-height: 1.45; }
.callout svg { width: 20px; height: 20px; }
.callout.info { background: var(--surface-2); }
.callout.warn { background: var(--warn-soft); } .callout.warn svg { color: var(--warn); }
.callout.bad { background: var(--bad-soft); } .callout.bad svg { color: var(--bad); }
.callout.good { background: var(--good-soft); } .callout.good svg { color: var(--good); }
.callout b { font-weight: var(--fw-semibold); }
.skel { background: var(--skeleton); background-size: 200% 100%; border-radius: 8px; height: 14px; animation: sk 1.4s linear infinite; }
.skel.big { height: 34px; width: 60%; margin: var(--sp-2) 0; }
.skel.w40 { width: 40%; } .skel.w80 { width: 80%; } .skel.chart-sk { height: 120px; margin-top: var(--sp-3); }
.state-label { margin-bottom: var(--sp-2); }
.empty .btn-row { justify-content: center; }
.empty > svg { width: 24px; height: 24px; color: var(--accent-text); }
.install { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: var(--sp-3); align-items: center; padding: var(--sp-3); border-radius: var(--r-lg); box-shadow: inset 0 0 0 1px var(--line-strong); }
.install img { width: 40px; height: 40px; border-radius: var(--r-md); background: var(--surface-2); }
.install .btn-row { grid-column: 1 / -1; margin-top: 0; }
@media (min-width: 900px) { .install { display: none; } }
.foot { margin-top: var(--sp-6); font-size: var(--fs-xs); color: var(--text-3); text-align: center; }

/* ---------- Теплокарта: клітинка-посилання 44 px ---------- */
.heat td a { display: block; padding: 0; border-radius: 8px; }
.heat td a:hover { text-decoration: none; }
.heat td a:hover span { box-shadow: inset 0 0 0 2px var(--text); }
.heat th.model { white-space: normal; line-height: 1.25; width: 34%; }
.heat { table-layout: fixed; }

/* ---------- Налаштування: правила каналів, орієнтири ---------- */
.rules { display: grid; gap: var(--sp-2); }
.rule { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "c c" "f ch"; gap: var(--sp-2); padding: var(--sp-2) 0; border-top: 1px solid var(--line); }
.rule:first-child { border-top: 0; }
.rule input { grid-area: c; } .rule .rf { grid-area: f; } .rule .rc { grid-area: ch; }
@media (min-width: 640px) { .rule { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr); grid-template-areas: "f c ch"; border-top: 0; padding: 0; } }
.rule select, .rule input { min-width: 0; width: 100%; }
.tgt { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-2); align-items: end; padding: var(--sp-2) 0; border-top: 1px solid var(--line); }
.tgt:first-child { border-top: 0; }
.tgt .t { grid-column: 2 / -1; font-weight: var(--fw-semibold); font-size: var(--fs-sm); color: var(--text); }
.tgt .on { grid-row: 1 / span 2; align-self: center; }
.tgt label { font-size: var(--fs-xs); }
.tgt label.cb, .tgt .on-wrap { min-width: var(--tap); min-height: var(--tap); display: grid; place-items: center; }

/* ---------- Telegram Mini App (TG v1) ---------- */
.tg-boot { margin-top: var(--sp-5); }
.tg-spin { display: inline-block; width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: tg-spin .8s linear infinite; }
@keyframes tg-spin { to { transform: rotate(360deg); } }
.tg-close { justify-content: center; }
.tg-users .kv { gap: var(--sp-2); }

/* ---------- «Сьогодні»: картка P&L місяця ---------- */
.pnl-tile { display: block; color: inherit; }
.pnl-tile:hover { text-decoration: none; }
.pnl-tile .pnl-tile-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--sp-2); }
.pnl-tile .pnl-tile-v { font-size: var(--fs-2xl); font-weight: var(--fw-semibold); letter-spacing: -0.025em; font-variant-numeric: tabular-nums; }
.pnl-tile .pnl-tile-v.neg { color: var(--bad); }
.pnl-tile .pnl-mini { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: var(--sp-3) 0 0; padding: 0; list-style: none; }
.pnl-tile .pnl-mini li { min-width: 0; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); }
.pnl-tile .pnl-mini b { display: block; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: var(--fw-semibold); }
.pnl-tile .pnl-mini span { display: block; font-size: var(--fs-xs); color: var(--text-3); line-height: 1.3; }

/* ---------- Герой: дрібниці для реальних даних ---------- */
.hero-card .note { color: var(--hero-text-2); }
.hero-card .hero-empty { margin: 12px 0 18px; color: var(--hero-text-2); font-size: var(--fs-base); }
.hero-card .hero-empty a { text-decoration: underline; text-underline-offset: 3px; }
.hero-card .chart-wrap { grid-template-columns: minmax(0, 1fr); }
.hero-card .chart.yaxis { display: none; }
.hero-card .chart text { fill: var(--hero-text-3); }
.hero-card .chart .s1 { fill: url(#g-hero-area); }
.hero-card .chart .s1.hl { fill: #fff; }
.hero-card .chart .base { stroke: rgb(255 255 255 / .16); }
.hero-card .chart .lc { stroke: rgb(255 255 255 / .38); }
.hero-card .badge.prelim, .hero-card .badge.warn { background: rgb(255 196 120 / .16); color: #ffd9a6; box-shadow: none; }
.hero-card .badge.good { background: rgb(64 214 140 / .16); color: #8ff0bf; box-shadow: none; }
.hero-card .badge.bad { background: rgb(255 110 110 / .18); color: #ffb0ae; box-shadow: none; }
.hero-card .delta.flat-d b { color: var(--hero-text); background: rgb(255 255 255 / .12); }
.hero-card .hero-cols { padding: 0 20px 6px; }
.hero-card .hero-top .ml-auto { margin-left: auto; }
.hero-card .hero-top a.chip { color: var(--hero-text); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .25); }
.hero-value.neg { color: #ffb0ae; }
@media (min-width: 600px) { .hero-card .hero-cols { padding: 0 28px 6px; } }
.hero-stats a { display: block; color: inherit; }
.hero-stats a:hover { text-decoration: none; }
.hero-stats a:hover b { text-decoration: underline; text-underline-offset: 3px; }

/* KPI зі спарклайном */
.kpi .kpi-spark { margin-top: auto; }
.kpi-grid.dense .kpi { padding: 12px 12px 10px; }
.money-trend .chart { height: 88px; }
.chip { min-width: var(--tap); justify-content: center; }
.delta b i { font-size: 12px; }
.period-line { flex-wrap: wrap; row-gap: 4px; }
.compare { flex-wrap: wrap; }
.pnl-tile .pnl-mini.one { grid-template-columns: minmax(0, 1fr); }
.hero-note { font-size: var(--fs-xs); color: var(--hero-text-3); margin-bottom: 4px; }
.hero-empty:empty { display: none; }
.grid.dash { align-items: start; }
/* теплокарта basdash: h0 = розмір у ряду закінчився (червона рамка — ряд розбитий), hx = поза рядом */
.heat .h0, .heat-legend .h0 { background: var(--bad-soft); color: var(--bad); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--bad) 70%, transparent); }
.heat .hx { background: transparent; color: var(--text-3); box-shadow: none; font-weight: var(--fw-regular); }
/* усе, що нижче main (і додане скриптами в кінець body), не ховається під плаваючим таб-баром */
@media (max-width: 899px) {
  body.app { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px); }
  .app .wrap { padding-bottom: 24px; }
}
/* a11y: дрібні цілі дотику, знайдені вимірюванням 08.11 */
.ops-wk-head > a { display: inline-flex; align-items: center; min-height: var(--tap); }
.crumbs a { display: inline-flex; align-items: center; min-height: var(--tap); }
td > a:first-child { min-height: var(--tap); display: inline-flex; align-items: center; padding-block: 0; }
.chip-row .chip { min-width: var(--tap); }
input[type=checkbox].on, .tgt input[type=checkbox] { width: 24px; height: 24px; margin: 10px; }
.custom-period label, .cash-form label, form label:has(> input[type=checkbox]) { min-height: var(--tap); }


/* ==================================================================
   UX2 (08.11): доопрацювання після аудиту UX2_TZ.md — компоненти kpi/kpi-info, lrow, subnav, crumbs,
   empty, model-card, статус BAS, безпечні зони Telegram. Лише класи й токени (CSP 'self').
   ================================================================== */

/* безпечні зони: системна (tg-safe-area) + контентна (tg-content-safe-area) — tg.js ставить змінні з подій Telegram */
:root {
  --safe-b: max(env(safe-area-inset-bottom, 0px), calc(var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px)));
  --safe-t: max(env(safe-area-inset-top, 0px), calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)));
}
html.tg-browser { --safe-b: calc(max(env(safe-area-inset-bottom, 0px), 12px) + 8px); }
html.tg .app-header { justify-content: flex-end; min-height: 40px; }
html.tg .app-header .spacer { display: none; }
@media (max-width: 899px) { body.app { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 26px); } }

/* P0-9 lrow: число праворуч у 1-му рядку, мета/бар у 2-му; назва не обрізається до 1 літери */
.lrow .row-meta.r { grid-area: auto; justify-self: end; text-align: right; }
.lrow.has-av .row-meta.r { grid-area: d; }
.lrow .row-name { white-space: normal; overflow: hidden; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; }
.lrow .row-meta { white-space: normal; }
.lrow .row-meta.r { white-space: nowrap; }
.row-val .badge { white-space: nowrap; }
form.inline-x { display: inline; margin: 0; }

/* §5 kpi: підпис ≤ 2 рядки без трикрапки, текстові значення меншим кеглем, ⓘ 44×44 */
.kpi-label { display: block; white-space: normal; overflow-wrap: anywhere; line-height: 1.3; padding-right: 30px; }
.kpi .delta { flex-wrap: wrap; }
.kpi .delta .ref { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; line-height: 1.3; }
@container (max-width: 150px) { .kpi .delta .ref { display: inline; } }
.kpi { container-type: normal; }   /* без containment: bottom-sheet ⓘ має бути position:fixed відносно екрана */
.kpi-value { font-size: clamp(1.25rem, 5.6vw, 1.5rem); }
@media (min-width: 600px) { .kpi-value { font-size: clamp(1.5rem, 2.2vw, var(--fs-2xl)); } }
.kpi-i[open] { z-index: 60; }
.kpi.txt .kpi-value { font-size: var(--fs-md); white-space: normal; line-height: 1.3; }
.kpi.has-link { padding: 0; }
.kpi-link { display: flex; flex-direction: column; gap: 6px; padding: 14px 14px 12px; color: inherit; border-radius: inherit; height: 100%; }
.kpi-link:hover { text-decoration: none; }
.kpi.has-link:hover { box-shadow: var(--shadow-2); }
@media (min-width: 600px) { .kpi-link { padding: 16px 18px 14px; } }
.kpi-i { position: absolute; top: 2px; right: 2px; z-index: 2; }
.kpi-i > summary { list-style: none; display: grid; place-items: center; width: var(--tap); height: var(--tap); min-height: var(--tap); border-radius: 50%; cursor: pointer; }
.kpi-i > summary::-webkit-details-marker { display: none; }
.kpi-i > summary span { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line-strong);
  font: italic var(--fw-semibold) 12px/1 Georgia, serif; color: var(--text-3); }
.kpi-i[open] > summary span, .kpi-i > summary:hover span { color: var(--accent-text); box-shadow: inset 0 0 0 1.5px var(--accent); }
.kpi-i:not([open]) > .kpi-sheet { display: none; }   /* INT 08.11: закритий ⓘ не розширює сторінку (/pnl 390 px) */
.kpi-sheet { position: absolute; right: 6px; top: 40px; width: min(300px, 80vw); padding: 14px 16px; border-radius: var(--r-md);
  background: var(--surface-raised); box-shadow: var(--shadow-3); color: var(--text); font-size: var(--fs-sm); line-height: 1.45; display: grid; gap: 6px; z-index: var(--z-sheet); }
.kpi-sheet b { font-size: var(--fs-base); }
.kpi-sheet p { margin: 0; color: var(--text-2); }
.kpi-sheet .faint { color: var(--text-3); }
@media (max-width: 599px) {
  .kpi-i[open]::before { content: ""; position: fixed; inset: 0; background: rgb(0 0 0 / .32); z-index: calc(var(--z-sheet) - 1); }
  .kpi-sheet { position: fixed; left: 0; right: 0; top: auto; bottom: 0; width: auto; border-radius: 20px 20px 0 0;
    padding: 20px var(--gutter) calc(20px + var(--safe-b)); font-size: var(--fs-base); }
  .kpi-sheet b { font-size: var(--fs-md); }
}
/* непарна остання плитка — на всю ширину (телефон, 2 колонки) */
@media (max-width: 639px) { .kpi-grid > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; } }
@media (min-width: 640px) and (max-width: 899px) { .kpi-grid:not(.three) > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; } }
.kpi.wide-sm { }
details.more-kpi > summary { list-style: none; display: inline-flex; gap: 6px; align-items: center; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-2); }
details.more-kpi > summary::-webkit-details-marker { display: none; }
details.more-kpi > summary::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); margin-top: -3px; }
details.more-kpi[open] > summary::after { transform: rotate(-135deg); margin-top: 3px; }
details.more-kpi[open] > .kpi-grid { margin-top: var(--sp-2); }

/* §5 subnav: підкреслені вкладки розділу під H1, скрол із fade-краєм */
.subnav { position: relative; margin: calc(-1 * var(--sp-2)) calc(-1 * var(--gutter)) var(--sp-4); border-bottom: 1px solid var(--line); }
.subnav-in { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 0 var(--gutter); }
.subnav-in::-webkit-scrollbar { display: none; }
.subnav::after { content: ""; position: absolute; right: 0; top: 0; bottom: 1px; width: 28px; pointer-events: none; background: linear-gradient(90deg, transparent, var(--bg)); }
.subnav a { flex: none; display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 12px; font-size: var(--fs-base); font-weight: var(--fw-medium);
  color: var(--text-2); white-space: nowrap; box-shadow: inset 0 -2px 0 transparent; }
.subnav a:hover { color: var(--text); text-decoration: none; }
.subnav a[aria-current="page"] { color: var(--text); font-weight: var(--fw-semibold); box-shadow: inset 0 -2px 0 var(--accent); }
.page-head + .subnav { margin-top: calc(-1 * var(--sp-2)); }
.page-head .subnav { flex-basis: 100%; margin-bottom: 0; }
@media (min-width: 600px) { .subnav { margin-left: 0; margin-right: 0; } .subnav-in { padding: 0; } }

/* §5 crumbs — окремий рядок над H1 */
.crumbs-line { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin: var(--sp-1) 0 calc(-1 * var(--sp-2)); font-size: var(--fs-sm); color: var(--text-3); }
.crumbs-line a { color: var(--text-2); display: inline-flex; align-items: center; min-height: 32px; }
.crumbs-line .sep { color: var(--text-3); }
html.tg .crumbs-line { display: none; }

/* P0-10 теплокарта: однакові пігулки, фіксована колонка розміру; на телефоні — картки моделей */
.heat td span { min-width: 48px; padding: 0 8px; height: 36px; white-space: nowrap; }
.heat col.c-model { width: auto; }
.heat col.c-size { width: 60px; }
.heat-wrap { overflow-x: auto; }
.heat th.model { width: auto; }
.only-wide { display: none; }
@media (min-width: 768px) { .only-wide { display: block; } .only-narrow { display: none; } }
.model-cards { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: grid; gap: 0; }
.model-card { padding: 12px 0; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.model-card:first-child { border-top: 0; }
.mc-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: baseline; color: var(--text); }
.mc-head:hover { text-decoration: none; }
.mc-head:hover .mc-name { color: var(--accent-text); }
.mc-name { font-size: var(--fs-base); font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-total { font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mc-total small { font-size: var(--fs-xs); color: var(--text-3); margin-left: 3px; font-weight: var(--fw-medium); }
.mc-sizes { display: flex; flex-wrap: wrap; gap: 6px; }
.sz { display: inline-flex; align-items: baseline; gap: 5px; min-height: 32px; padding: 6px 10px; border-radius: var(--r-pill); background: var(--surface-2);
  color: var(--text); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; position: relative; }
.sz::after { content: ""; position: absolute; inset: -6px -2px; }
.sz span { color: var(--text-3); font-weight: var(--fw-medium); }
.sz b { font-weight: var(--fw-semibold); }
.sz.zero { background: var(--bad-soft); color: var(--bad); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bad) 40%, transparent); }
.sz.zero span { color: var(--bad); }
.sz:hover { text-decoration: none; box-shadow: inset 0 0 0 1.5px var(--text); }
.mc-x { margin: -4px 0 0; justify-self: start; }
.link.xs { font-size: var(--fs-xs); color: var(--text-3); text-decoration: none; min-height: 32px; padding: 0; }
.link.xs:hover { color: var(--bad); text-decoration: underline; }
.state-line { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; align-items: start; font-size: var(--fs-base); line-height: 1.45; }
.state-line > svg { width: 40px; height: 40px; padding: 9px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); }
.state-line .btn-row { margin-top: var(--sp-3); }
p.callout { margin: 0; }
p.callout > span a { font-weight: var(--fw-semibold); }

/* P0-11 статус BAS: чип у шапці (3 стани) + банер під шапкою */
.fresh.st-bad { color: var(--bad); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bad) 35%, transparent), var(--shadow-1); }
.fresh.st-warn { color: var(--text); }
.fresh-banner { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px; align-items: start; margin: 0 0 var(--sp-4);
  padding: 10px 14px; border-radius: var(--r-md); font-size: var(--fs-sm); line-height: 1.45; background: var(--warn-soft); color: var(--text); }
.fresh-banner.bad { background: var(--bad-soft); }
.fresh-banner svg { width: 20px; height: 20px; color: var(--warn); }
.fresh-banner.bad svg { color: var(--bad); }
.fresh-banner a { font-weight: var(--fw-semibold); white-space: nowrap; display: inline-flex; min-height: 28px; align-items: center; }
.tg-open { display: grid; gap: 10px; margin: 0 0 var(--sp-4); padding: 12px 14px; border-radius: var(--r-md); background: var(--accent-softer);
  box-shadow: inset 0 0 0 1px var(--accent-soft); font-size: var(--fs-sm); }
.tg-open .btn { justify-self: start; }
@media (min-width: 900px) { .tg-open { display: none; } }

/* empty: тематична іконка, primary-дія */
.empty .btn-row .btn { min-width: 160px; }

/* «Ще»: сітка 2–3 колонки з описами-питаннями (≥ 900) */
.more-list .badge { margin-left: 6px; vertical-align: 1px; }
@media (min-width: 900px) {
  .more-list.grid-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 24px; }
  .more-list.grid-list li a { border-top: 1px solid var(--line); }
  .more-list.grid-list li:nth-child(2) a { border-top: 0; }
}
@media (min-width: 1200px) { .more-list.grid-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } .more-list.grid-list li:nth-child(3) a { border-top: 0; } }

/* Головна: «Потребує уваги» */
.attn { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.attn a { display: grid; grid-template-columns: 36px minmax(0, 1fr) 16px; gap: 12px; align-items: center; padding: 10px 8px; margin: 0 -8px; border-radius: var(--r-md); color: var(--text); }
.attn a:hover { background: var(--surface-2); text-decoration: none; }
.attn .ico { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--surface-2); color: var(--text-2); }
.attn .ico svg { width: 18px; height: 18px; }
.attn .ico.bad { background: var(--bad-soft); color: var(--bad); } .attn .ico.warn { background: var(--warn-soft); color: var(--warn); }
.attn .ico.info { background: var(--accent-soft); color: var(--accent-text); }
.attn b { display: block; font-size: var(--fs-base); font-weight: var(--fw-semibold); line-height: 1.3; }
.attn span.d { display: block; font-size: var(--fs-sm); color: var(--text-3); line-height: 1.35; }
.attn .chev { width: 16px; height: 16px; color: var(--text-3); }
.hero-today { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 10px; font-size: var(--fs-sm); color: var(--hero-text-2); }
.hero-today a { text-decoration: underline; text-underline-offset: 3px; }

/* форми налаштувань */
.form-narrow { max-width: 720px; }
.form .hint { display: block; font-size: var(--fs-xs); color: var(--text-3); }
.settings-group + .settings-group { margin-top: var(--sp-2); }

/* таблиці: числа праворуч */
th.num, td.num { text-align: right; }

/* темна тема: межі KPI-карток контрастніші */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .kpi { box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow-1); } }
:root[data-theme="dark"] .kpi { box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow-1); }
.kpi-i.inline-i { position: relative; display: inline-block; top: auto; right: auto; vertical-align: middle; margin: -12px 0; }
.kpi-i.inline-i .kpi-sheet { right: auto; left: 0; }
.hero-value.faint { color: var(--text-3); }
td.held { color: var(--text-3); }
details.pnl-checks-d > summary { list-style: none; margin-bottom: 0; }
details.pnl-checks-d > summary::-webkit-details-marker { display: none; }
details.pnl-checks-d[open] > summary { margin-bottom: var(--sp-4); }
tr.row-warn th, tr.row-warn td { background: var(--warn-soft); }
/* UX2 P1-5: профіцит — «добре», дефіцит — «погано» (не колір тривоги для позитиву) */
svg.chart .cf-up, span.sw.cf-up { fill: var(--good); background: var(--good); }
svg.chart .cf-down, span.sw.cf-down { fill: var(--bad); background: var(--bad); }
.cash-chart .ylab { font-size: var(--fs-xs); }
.rules, form.form, .wrap > .card > form { max-width: 720px; }
.page-head .subnav { margin: 0; flex: 1 1 100%; min-width: 0; }
.page-head .subnav .subnav-in { padding: 0; }
.hero-card .chart .s1.hl { fill: #b9bcff; }
dl.cash-kv { grid-template-columns: minmax(0, 1fr) auto; }
dl.cash-kv dd .kpi-sub { white-space: nowrap; }
@media (min-width: 768px) { .model-cards.only-narrow { display: none; } }
.heat-wrap { margin-top: var(--sp-3); }

/* UX2 re-audit: KPI всередині картки на вузькому екрані — менший кегль, щоб «24,57 млн ₴» не впиралось у край (A2) */
@media (max-width: 420px) { .card .kpi-grid .kpi-value { font-size: clamp(1.05rem, 5vw, 1.3rem); } }
/* UX2 re-audit (A3): рядок без числа (назва + опис, напр. «Чого бракує в даних») — опис на всю ширину під назвою, назва не стискається до «Ро з…» */
.lrow > .row-name + .row-meta { grid-column: 1 / -1; }
