/*
 * KG_ROSBOTANIC — Design Tokens
 * Правило R16: единая точка правды по цветам/шрифтам/размерам.
 * Ни один hex не должен появляться в других файлах — только через var(--token).
 *
 * Референс: VS Code 2026 (Default Light + Default Dark, Microsoft 2025+).
 * Принцип: минимализм, спокойные цвета, компактность, high data density.
 * Утверждено владельцем 2026-09-24.
 */

/* ============================================================
   LIGHT THEME — VS Code Light 2026 (Default Light, Microsoft 2025+)
   Возврат по запросу владельца 2026-09-25. Warm Linear откачен.
   focus/accent — VS Code синий #005fb8.
   ============================================================ */
:root {
  --bg-page:      #ffffff;   /* editor.background — чисто-белый */
  --bg-card:      #f8f8f8;   /* elevated (list, panel, editorWidget) */
  --bg-hover:     #e8e8e8;   /* list.hoverBackground */
  --bg-active:    #cce5ff;   /* list.activeSelectionBackground */
  --bg-muted:     #f8f8f8;   /* sidebar / activity bar / title bar */

  --text:         #3b3b3b;   /* editor.foreground */
  --text-muted:   #616161;
  --text-subtle:  #8b8b8b;
  --text-invert:  #ffffff;

  --border:       #e5e5e5;
  --border-strong:#cecece;
  --border-focus: #005fb8;
  --divider:      #e5e5e5;   /* alias на border — для страниц Волны 2 */
  --warm-beige:   #8b8b8b;   /* alias на text-subtle */

  --accent:       #005fb8;   /* VS Code Light blue — button/focus */
  --accent-hover: #004a9e;
  --accent-bg:    #cce5ff;
  --accent-text:  #ffffff;

  --success:      #1a7f37;   /* GitHub-стиль зелёный */
  --success-bg:   #dafbe1;
  --mint:         #1a7f37;   /* alias на success */
  --warning:      #9a6700;   /* тёплая охра */
  --warning-bg:   #fff8c5;
  --ochre:        #9a6700;   /* alias на warning */
  --danger:       #cf222e;   /* VS Code error красный */
  --danger-bg:    #ffebe9;
  --info:         #0969da;   /* VS Code info синий */
  --info-bg:      #ddf4ff;

  /* Shadow — почти нет, только для popover/modal */
  --shadow-sm:    0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md:    0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg:    0 8px 24px rgba(0, 0, 0, 0.12);

  /* Motion — оставлены (полезны для tooltip и других страниц Волны 2) */
  --motion-fast:  120ms;
  --motion-base:  200ms;
  --motion-slow:  240ms;
  --motion-page:  400ms;
  --easing:       cubic-bezier(.22, .61, .36, 1);

  /* Typography */
  --font-body:    'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', 'Menlo', 'Consolas', monospace;
  --font-size-base:   14px;
  --font-size-sm:     12px;
  --font-size-xs:     11px;
  --font-size-md:     15px;
  --font-size-lg:     16px;
  --font-size-xl:     18px;
  --line-height:      1.5;
  --line-height-tight: 1.3;

  /* Spacing (8px grid) */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  24px;
  --space-6:  32px;
  --space-7:  48px;
  --space-8:  64px;

  /* Radius */
  --radius-sm: 4px;
  --radius:    6px;    /* базовый */
  --radius-lg: 8px;    /* карточки, модалки */
  --radius-full: 999px;

  /* Layout */
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --max-content-width: 1440px;

  /* Transitions */
  --transition-fast: 120ms ease;
  --transition:      180ms ease;
  --transition-slow: 280ms ease;

  /* Sidebar v2 — заголовки групп. Light: более контрастный чем text-subtle. */
  --text-nav-label: #616161;
}

/* ============================================================
   DARK THEME — VS Code Dark 2026 (Default Dark, Microsoft 2025+)
   Новейшая дефолтная тема VS Code. Ещё темнее чем Dark Modern (2023).
   Sidebar #141414 темнее editor #181818 (VS Code паттерн).
   Плоские глубокие тёмные тона без синевы.
   ============================================================ */
[data-theme="dark"] {
  --bg-page:      #181818;   /* editor.background */
  --bg-card:      #1f1f1f;   /* elevated (list, panel) */
  --bg-hover:     #252525;
  --bg-active:    #2a2a2a;
  --bg-muted:     #141414;   /* sidebar / activity bar / title bar */

  --text:         #cccccc;   /* editor.foreground */
  --text-muted:   #9d9d9d;
  --text-subtle:  #6e7681;
  --text-invert:  #181818;

  --border:       #2b2b2b;
  --border-strong:#3c3c3c;
  --border-focus: #0078d4;
  --divider:      #2b2b2b;
  --warm-beige:   #6e7681;

  --accent:       #0078d4;   /* VS Code blue */
  --accent-hover: #005fa3;
  --accent-bg:    #062f4a;
  --accent-text:  #ffffff;

  --success:      #4ec9b0;   /* teal — VS Code type/class */
  --success-bg:   #1a332f;
  --mint:         #4ec9b0;
  --warning:      #dcdcaa;   /* yellow — VS Code function */
  --warning-bg:   #2b2818;
  --ochre:        #dcdcaa;
  --danger:       #f48771;   /* red — VS Code error */
  --danger-bg:    #331b17;
  --info:         #4fc1ff;   /* cyan — VS Code var */
  --info-bg:      #0a2438;

  --shadow-sm:    0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md:    0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg:    0 8px 24px rgba(0, 0, 0, 0.6);

  /* Sidebar v2 — заголовки групп в тёмной теме (явный запрос владельца 2026-10-13). */
  --text-nav-label: #c8cac9;
}

/* ============================================================
   Автопереключение по системной теме (первый заход, до localStorage)
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-page:      #181818;
    --bg-card:      #1f1f1f;
    --bg-hover:     #252525;
    --bg-active:    #2a2a2a;
    --bg-muted:     #141414;

    --text:         #cccccc;
    --text-muted:   #9d9d9d;
    --text-subtle:  #6e7681;
    --text-invert:  #181818;

    --border:       #2b2b2b;
    --border-strong:#3c3c3c;
    --border-focus: #0078d4;
    --divider:      #2b2b2b;
    --warm-beige:   #6e7681;

    --accent:       #0078d4;
    --accent-hover: #005fa3;
    --accent-bg:    #062f4a;
    --accent-text:  #ffffff;

    --success:      #4ec9b0;
    --success-bg:   #1a332f;
    --mint:         #4ec9b0;
    --warning:      #dcdcaa;
    --warning-bg:   #2b2818;
    --ochre:        #dcdcaa;
    --danger:       #f48771;
    --danger-bg:    #331b17;
    --info:         #4fc1ff;
    --info-bg:      #0a2438;

    --shadow-sm:    0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md:    0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg:    0 8px 24px rgba(0, 0, 0, 0.6);

    --text-nav-label: #c8cac9;
  }
}

/* ============================================================
   LEGACY ALIASES — --rb-* → новые токены
   Позволяет старому CSS (app.css) автоматически работать с dark/light
   без переписывания. Постепенно уходим на прямые var(--bg-page) etc.
   ============================================================ */
:root {
  --rb-bg:          var(--bg-page);
  --rb-white:       var(--bg-card);
  --rb-cream:       var(--bg-hover);
  --rb-ink:         var(--text);
  --rb-dark:        var(--text);
  --rb-muted:       var(--text-muted);
  --rb-subtle:      var(--text-subtle);
  --rb-line:        var(--border);
  --rb-coral:       var(--accent);
  --rb-coral-dark:  var(--accent-hover);
  --rb-coral-light: var(--accent-bg);
  --rb-mint:        var(--success);
  --rb-warm-beige:  var(--text-muted);
  --rb-warn:        var(--warning);
  --rb-danger:      var(--danger);
}

/* Legacy shadows и radius */
:root {
  --shadow:  var(--shadow-md);
  --radius:  var(--radius);
}

/* ============================================================
   БАЗОВЫЕ ПРИМИТИВЫ (минимум для новой стилевой системы)
   Более сложные компоненты — в app.css (постепенная миграция).
   ============================================================ */

html, body {
  background: var(--bg-page);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--transition), color var(--transition);
}

/* Numbers with tabular-nums (столбики цифр выравниваются) */
.num, .mono, code, kbd, samp {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Wiki-tooltips «?» (Шаг 20 A1) — Popover API + Warm Linear
   Правило feedback_wiki_tooltips_default: везде «?» без кружка.
   Триггер = текстовый символ, popup = 280px тёплый, fade 120ms.
   Совместимо с Chrome 114+ / Safari 17+ / Firefox 125+ (~93%).
   ============================================================ */
.wl-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  font: 600 13px/1 var(--font-body);
  color: var(--text-subtle);
  cursor: help;
  background: none;
  border: 0;
  padding: 0;
  opacity: 0.35;
  transition: opacity var(--motion-fast, 120ms) var(--easing, ease-out),
              color var(--motion-fast, 120ms) var(--easing, ease-out);
  vertical-align: baseline;
  position: relative;
  top: -1px;
}
.wl-hint:hover { opacity: 1; }
.wl-hint::before { content: "?"; }
.wl-hint::after {
  /* Расширение hit-area до ≥40x40 (правило №0.2 mobile-first tap-targets) */
  content: "";
  position: absolute;
  inset: -12px;
}
.wl-hint:hover,
.wl-hint:focus-visible,
.wl-hint[aria-expanded="true"] {
  color: var(--accent);
  outline: none;
}
.wl-hint:focus-visible {
  box-shadow: 0 0 0 2px rgba(200, 90, 90, 0.18);
  border-radius: 3px;
}

.wl-hint-pop {
  max-width: 280px;
  padding: 12px 14px;
  margin: 0;
  border: 1px solid var(--divider);
  border-radius: 10px;
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
  font: 400 13px/1.5 var(--font-body);
  color: var(--text);
  inset: unset;
  position: fixed;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--motion-fast, 120ms) var(--easing),
              transform var(--motion-fast, 120ms) var(--easing);
}
.wl-hint-pop:popover-open {
  opacity: 1;
  transform: translateY(0);
}
.wl-hint-pop strong { color: var(--text); font-weight: 600; }
.wl-hint-pop code,
.wl-hint-pop kbd {
  font: 500 12px/1 var(--font-mono);
  background: var(--bg-hover);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 3px;
}
.wl-hint-pop a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(200, 90, 90, 0.3);
}
.wl-hint-pop a:hover { border-bottom-color: currentColor; }

/* В sidebar: «?» скрыт по умолчанию, появляется на hover строки */
.nav-item .wl-hint,
.nav-title .wl-hint {
  opacity: 0;
  transition: opacity var(--motion-fast, 120ms) var(--easing);
}
.nav-item:hover .wl-hint,
.nav-item .wl-hint:focus-visible,
.nav-title:hover .wl-hint,
.nav-title .wl-hint:focus-visible {
  opacity: 0.7;
}

/* CSS-only tooltip через data-tip (простой инлайн-вариант, без JS).
   Работает на desktop hover + mobile tap (через :focus).
   Используется в sidebar-пунктах, лабелах полей, заголовках секций. */
.wl-hint[data-tip] { position: relative; }
.wl-hint[data-tip]:hover::after,
.wl-hint[data-tip]:focus::after,
.wl-hint[data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  max-width: 280px;
  min-width: 180px;
  width: max-content;
  padding: 10px 12px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  font: 400 12.5px/1.5 var(--font-body);
  text-align: left;
  white-space: normal;
  z-index: 10000;
  pointer-events: none;
  animation: wlHintIn 120ms var(--easing, ease-out);
}
@keyframes wlHintIn {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
/* Для sidebar tooltip показывается справа через position:fixed
   (иначе overflow-y sidebar обрезает). Координаты ставит JS-shim
   через CSS custom properties --tip-top / --tip-left. */
.sidebar .wl-hint[data-tip]:hover::after,
.sidebar .wl-hint[data-tip]:focus::after {
  position: fixed;
  top: var(--tip-top, 50%);
  left: var(--tip-left, calc(100% + 12px));
  bottom: auto;
  transform: translateY(-50%);
  z-index: 999999;
  animation: wlHintInSide 120ms var(--easing, ease-out);
}
@keyframes wlHintInSide {
  from { opacity: 0; transform: translateY(-50%) translateX(-4px); }
  to   { opacity: 1; transform: translateY(-50%) translateX(0); }
}

/* ============================================================
   Полосы прокрутки (webkit + Firefox) — под текущую тему.
   VS Code паттерн: track = bg-page, thumb = border-strong.
   ============================================================ */
html {
  scrollbar-color: var(--border-strong) var(--bg-page);  /* Firefox */
  scrollbar-width: thin;
}
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
  background: var(--bg-page);
}
::-webkit-scrollbar-track {
  background: var(--bg-page);
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid var(--bg-page);   /* «отступ» — плюшка тоньше track */
  border-radius: 999px;
  min-height: 32px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-subtle);
}
::-webkit-scrollbar-corner {
  background: var(--bg-page);
}

/* Внутренние скроллеры (Kanban row, table wrappers и т.п.) — на карточках */
.dash-phases::-webkit-scrollbar-track,
.kanban-row::-webkit-scrollbar-track,
.kanban-board::-webkit-scrollbar-track,
[data-scroll="x"]::-webkit-scrollbar-track {
  background: var(--bg-card);
}
.dash-phases::-webkit-scrollbar-thumb,
.kanban-row::-webkit-scrollbar-thumb,
.kanban-board::-webkit-scrollbar-thumb,
[data-scroll="x"]::-webkit-scrollbar-thumb {
  border-color: var(--bg-card);
}

/* Ссылки */
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* Focus-ring для клавиатурной навигации (WCAG) */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Утилитарные классы для быстрого доступа к токенам */
.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }
.text-accent { color: var(--accent); }

/* Тонкий разделитель */
.rule { border: 0; border-top: 1px solid var(--border); margin: var(--space-4) 0; }

/* Стандартная кнопка (минимум) */
.btn-mini {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;                  /* R14 tap-target */
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: var(--font-size-base);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.btn-mini:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.btn-mini.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}
.btn-mini.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* ============================================================
   DASHBOARD v2 — компоненты (правило R16 через tokens)
   ============================================================ */

/* Hero card */
.dash-hero {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 160px;
}
.dash-hero .label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.dash-hero .value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(28px, 5vw, 40px);
  color: var(--text);
  font-weight: 600;
  line-height: 1;
}
.dash-hero .delta { font-size: var(--font-size-sm); color: var(--text-muted); }
.dash-hero .delta.up { color: var(--success); }
.dash-hero .delta.down { color: var(--danger); }
.dash-hero .spark { margin-top: auto; height: 48px; }

/* Alerts card */
.dash-alerts {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  min-height: 160px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.dash-alerts.ok { border-color: var(--success); background: var(--success-bg); }
.dash-alerts.ok .status { color: var(--success); }
.dash-alerts.warn { border-color: var(--danger); background: var(--danger-bg); }
.dash-alerts.warn .status { color: var(--danger); }
.dash-alerts .label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.dash-alerts .status {
  font-family: var(--font-mono);
  font-size: var(--font-size-xl);
  font-weight: 600;
}
.dash-alerts .list a {
  display: block;
  padding: var(--space-1) 0;
  font-size: var(--font-size-sm);
  color: var(--text);
  border-bottom: 1px dashed var(--border);
}
.dash-alerts .list a:last-child { border-bottom: 0; }

/* Row: Hero + Alerts (2fr 1fr → 1fr on tablet) */
.dash-row-hero {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
@media (max-width: 900px) {
  .dash-row-hero { grid-template-columns: 1fr; }
  .dash-alerts { order: -1; }  /* alerts выше на mobile */
}

/* 6 supporting KPI grid */
.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
@media (max-width: 900px) { .dash-kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 380px) { .dash-kpi-grid { grid-template-columns: 1fr; } }

.dash-kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-height: 100px;
}
.dash-kpi:hover { border-color: var(--border-strong); text-decoration: none; }
.dash-kpi .label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.dash-kpi .value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(20px, 3vw, 26px);
  color: var(--text);
  font-weight: 600;
  line-height: 1.1;
}
.dash-kpi .sub { font-size: var(--font-size-xs); color: var(--text-muted); margin-top: auto; }
.dash-kpi .delta.up { color: var(--success); }
.dash-kpi .delta.down { color: var(--danger); }
.dash-kpi .delta.flat { color: var(--text-subtle); }
.dash-kpi .spark { margin-top: auto; height: 20px; }

/* Quick Actions row */
.dash-actions {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
@media (max-width: 1200px) { .dash-actions { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .dash-actions { grid-template-columns: 1fr; } }

.dash-action {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 52px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  text-decoration: none;
  font-size: var(--font-size-base);
  font-weight: 500;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.dash-action svg { width: 18px; height: 18px; color: var(--text-muted); flex: 0 0 auto; }
.dash-action:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
  text-decoration: none;
}
.dash-action:hover svg { color: var(--accent); }
.dash-action.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}
.dash-action.primary svg { color: var(--accent-text); }
.dash-action.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.dash-action.primary:hover svg { color: var(--accent-text); }

/* Phases mini-cards row */
.dash-phases {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: var(--space-2);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
}
@media (max-width: 1100px) { .dash-phases { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 640px) {
  .dash-phases {
    grid-template-columns: none;
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }
  .dash-phase { flex: 0 0 130px; scroll-snap-align: start; }
}

.dash-phase {
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  border-left: 3px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dash-phase:hover { background: var(--bg-active); text-decoration: none; }
.dash-phase .order { font-size: 10px; color: var(--text-subtle); text-transform: uppercase; letter-spacing: 0.5px; }
.dash-phase .name  { font-size: var(--font-size-sm); color: var(--text); font-weight: 500; }
.dash-phase .count { font-family: var(--font-mono); font-size: var(--font-size-lg); color: var(--text); font-variant-numeric: tabular-nums; }
.dash-phase .qty   { font-size: var(--font-size-xs); color: var(--text-muted); }

/* Section titles between blocks */
.dash-section-title {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: var(--space-5) 0 var(--space-3) 0;
  font-weight: 600;
}
.dash-section-title:first-of-type { margin-top: 0; }

/* Sparkline SVG helper (в атрибуты polyline sets attrs) */
.sparkline {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
.sparkline polyline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Details/summary в стиле tokens */
details.dash-collapse {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  margin-top: var(--space-4);
}
details.dash-collapse summary {
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  font-weight: 500;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
details.dash-collapse summary::-webkit-details-marker { display: none; }
details.dash-collapse summary::before {
  content: '▸';
  color: var(--text-subtle);
  transition: transform var(--transition-fast);
}
details.dash-collapse[open] summary::before { content: '▾'; }
details.dash-collapse[open] summary { border-bottom: 1px solid var(--border); }
details.dash-collapse .content { padding: var(--space-4); }

/* Theme-toggle кнопка */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline-block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: inline-block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }


/* ============================================================
   Wiki-tooltip JS-shim (2026-10-19 fix) — универсальный tooltip
   через position:fixed на body. Решает 3 проблемы:
   1. Overflow:hidden больше не обрезает (fixed to viewport)
   2. Контрастный фон (не --bg-card который сливается с темой)
   3. text-transform:none — не наследуется от parent <th> uppercase

   Активен когда wiki-tooltip.js загрузился и поставил на body
   класс .wl-tooltip-js-active. CSS-only ::after автоматически
   отключается чтобы не было двойных подсказок.
   ============================================================ */
body.wl-tooltip-js-active .wl-hint[data-tip]:hover::after,
body.wl-tooltip-js-active .wl-hint[data-tip]:focus::after,
body.wl-tooltip-js-active .wl-hint[data-tip]:focus-visible::after,
body.wl-tooltip-js-active .sidebar .wl-hint[data-tip]:hover::after,
body.wl-tooltip-js-active .sidebar .wl-hint[data-tip]:focus::after {
  content: none !important;
  display: none !important;
}

.wl-tooltip-global {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2147483647; /* MAX int32 — гарантированно над всем, включая modal/drawer/popover */
  max-width: 320px;
  min-width: 180px;
  padding: 10px 14px;
  background: #1f2937; /* явный тёмно-серый для light theme */
  color: #f3f4f6; /* светлый текст */
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.2);
  font: 400 13px/1.55 var(--font-body, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
  text-transform: none !important; /* сброс inherit от parent <th> uppercase */
  letter-spacing: normal !important;
  text-align: left;
  white-space: normal;
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 120ms ease-out, transform 120ms ease-out, visibility 120ms;
}
.wl-tooltip-global.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Dark theme — чуть светлее фон чтобы отличался от page bg */
[data-theme="dark"] .wl-tooltip-global {
  background: #374151;
  color: #f9fafb;
  border-color: rgba(255, 255, 255, 0.18);
}


/* 2026-10-19 fix mobile tap-targets для .wl-hint (Правило №0.2) */
@media (max-width: 900px) {
  .wl-hint {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
  }
}
