/*
 * KG_ROSBOTANIC — общий стиль
 * ВНИМАНИЕ: все цвета/шрифты/spacing/radius — из tokens.css (R16).
 * Ни одного hex-кода в этом файле не должно быть — только var(--token).
 * Все --rb-* — legacy aliases, определены в tokens.css.
 */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--bg-page);
  color: var(--text);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  min-height: 100vh;
}

h1, h2, h3, h4, .brand { font-family: var(--font-body); }

/* Layout: sidebar 240px + main */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  align-items: start;
}

/* ====================================================================
   SIDEBAR v2 — редизайн 2026-10-13 (46 пунктов 1:1, Workspace header,
   поиск-кнопка, Избранное, 4 состояния, user-popover с accordion toggle).
   Источник: _design/sidebar_v2/preview.html (утверждён владельцем).
   ==================================================================== */

/* --- Корневой контейнер --- */
.sidebar {
  background: var(--bg-muted);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 180ms ease;
}
.app.rail { grid-template-columns: var(--sidebar-rail-w, 64px) 1fr; }

@media (prefers-reduced-motion: reduce) {
  .app, .sidebar, .user-popover, .nav-group-items {
    transition: none !important;
    animation-duration: 0.01ms !important;
  }
}

/* --- Workspace header --- */
.ws-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  min-height: 60px;
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.3px;
  text-decoration: none;
}
.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--text-invert);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.brand-txt {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand-txt small {
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--text-subtle);
  text-transform: uppercase;
  font-weight: 500;
}

.rail-toggle {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms;
}
.rail-toggle:hover { background: var(--bg-hover); color: var(--text); }
.rail-toggle:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.app.rail .brand-txt { display: none; }
.app.rail .ws-head { padding: var(--space-3) var(--space-2); justify-content: center; flex-direction: column; gap: 8px; }
.app.rail .rail-toggle { display: inline-flex; }
.app.rail .rail-toggle svg { transform: rotate(180deg); }

/* --- Search button --- */
.sb-search {
  padding: var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--border);
}
.sb-search-input {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 var(--space-3);
  min-height: 36px;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.sb-search-input:hover { background: var(--bg-hover); color: var(--text); }
.sb-search-input:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 1px; }
.sb-search-input .i,
.sb-search-input .icon { width: 14px; height: 14px; opacity: 0.6; flex-shrink: 0; }
.sb-search-input .label { flex: 1; }
.kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-muted);
  color: var(--text-subtle);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
}
.app.rail .sb-search { padding: var(--space-2); }
.app.rail .sb-search-input { justify-content: center; padding: 0; }
.app.rail .sb-search-input .label,
.app.rail .sb-search-input .kbd { display: none; }

/* --- Nav body (scrollable) --- */
.sb-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-2) 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.sb-body::-webkit-scrollbar { width: 6px; }
.sb-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* --- Nav group --- */
.nav-group { padding: var(--space-2) 0; }
.nav-group + .nav-group { border-top: 1px solid var(--border); margin-top: 2px; }

.nav-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 6px var(--space-4) 4px;
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  color: var(--text-nav-label);
  text-transform: uppercase;
  text-align: left;
  min-height: 28px;
  user-select: none;
}
.nav-title:hover { color: var(--text); }
.nav-title:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}
.nav-title .caret {
  font-size: 10px;
  opacity: 0.6;
  transition: transform 180ms ease;
}
.nav-group.collapsed .caret { transform: rotate(-90deg); }
.nav-group-items {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 180ms ease;
}
.nav-group.collapsed .nav-group-items { max-height: 0; }
.nav-group.collapsed .nav-item { display: flex; } /* v2: max-height рулит, не display */

.app.rail .nav-title { display: none; }
.app.rail .nav-group + .nav-group { margin-top: var(--space-2); padding-top: var(--space-2); }
.app.rail .nav-group.collapsed .nav-group-items { max-height: 2000px; }

/* --- Nav item --- */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 68px 0 var(--space-4);   /* резерв: ? (24) + badge/⭐ (24) + gap */
  min-height: 36px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 400;
  position: relative;
  transition: background 120ms;
  border-left: 3px solid transparent;  /* совместимость — ширину держим, но подсветка через box-shadow */
}
.nav-item:hover { background: var(--bg-hover); }
.nav-item:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}
.nav-item .i,
.nav-item .icon {
  width: 16px;
  height: 16px;
  opacity: 0.75;
  flex-shrink: 0;
}
.nav-item .label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ACTIVE STATE — a11y-fixed контраст ≥4.5:1 в обеих темах */
.nav-item.active {
  background: var(--bg-active);
  color: var(--accent);
  font-weight: 500;
  box-shadow: inset 3px 0 0 var(--accent);   /* заменяет border-left, не сдвигает контент */
  border-left-color: transparent;             /* отключаем legacy */
}
.nav-item.active .i,
.nav-item.active .icon { opacity: 1; color: var(--accent); }

/* --- Wiki-hint «?» внутри nav-item (правило R12).
   Абсолютно справа, скрыт пока не hover строки. Опирается на .wl-hint из tokens.css. */
.nav-item .wl-hint {
  position: absolute;
  right: 36px;   /* резерв справа под ⭐ (24px) + gap */
  top: 50%;
  transform: translateY(-50%);
  margin-left: 0;
  z-index: 3;
}
.nav-item .wl-hint::after {
  /* перекрывает ::after из tokens.css — hit-area больше не нужна (уже 44px tap-target родителя) */
  display: none;
}
.app.rail .nav-item .wl-hint { display: none; }

/* --- Favorite button --- */
.nav-fav-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 0;
  cursor: pointer;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  color: var(--text-subtle);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 120ms;
  flex-shrink: 0;
  z-index: 2;
}
.nav-item:hover .nav-fav-btn,
.nav-fav-btn:focus-visible { opacity: 1; }
.nav-fav-btn:hover { background: var(--bg-page); color: var(--warning); }
.nav-fav-btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 1px;
  opacity: 1;
}
.nav-fav-btn.pinned { opacity: 1; color: var(--warning); }

/* --- Badges внутри nav-item (абсолютно справа) --- */
.nav-item .badge {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  transition: opacity 120ms, transform 120ms;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  min-height: 16px;
  line-height: 1;
  flex-shrink: 0;
}
.nav-item:hover .badge,
.nav-item:focus-within .badge {
  opacity: 0;
  transform: translateY(-50%) scale(0.6);
  pointer-events: none;
}
.badge-new { background: var(--success-bg); color: var(--success); }
.badge-soon { background: var(--warning-bg); color: var(--warning); }
.badge-count {
  background: var(--accent);
  color: var(--text-invert);
  min-width: 18px;
  justify-content: center;
  font-family: var(--font-mono);
}

/* Если в пункте есть бейдж — pinned-звезда скрыта пока нет hover */
.nav-item:has(.badge) .nav-fav-btn.pinned { opacity: 0; }
.nav-item:has(.badge):hover .nav-fav-btn.pinned,
.nav-item:has(.badge):hover .nav-fav-btn { opacity: 1; }

/* --- Rail mode: tooltip on hover --- */
.app.rail .nav-item { justify-content: center; padding: 0; }
.app.rail .nav-item .label,
.app.rail .nav-item .badge,
.app.rail .nav-item .nav-fav-btn,
.app.rail .nav-item .wl-hint { display: none; }
.app.rail .nav-item .i,
.app.rail .nav-item .icon { width: 18px; height: 18px; }
.rail-tooltip {
  position: absolute;
  left: calc(var(--sidebar-rail-w, 64px) + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: var(--font-size-sm);
  white-space: nowrap;
  z-index: 50;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms;
}
.app.rail .nav-item:hover .rail-tooltip,
.app.rail .nav-item:focus-visible .rail-tooltip { opacity: 1; }

/* --- Divider между core и system --- */
.sb-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-2) var(--space-4);
}

/* --- Legacy badge-new/badge-soon для .nav-title (как было в текущем коде) --- */
.nav-title .badge-new,
.nav-title .badge-soon {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-left: 6px;
  vertical-align: middle;
}

/* --- User card --- */
.user-card {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 60px;
  position: relative;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: var(--text-invert);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 13px; color: var(--text); }
.user-role { font-size: 11px; color: var(--text-muted); }
.app.rail .user-info,
.app.rail .user-menu-btn { display: none; }
.app.rail .user-card { justify-content: center; padding: var(--space-3) var(--space-2); }

/* --- User menu button + popover --- */
.user-menu-btn {
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--text-muted);
  min-height: 32px;
  min-width: 32px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.user-menu-btn:hover { background: var(--bg-hover); color: var(--text); }
.user-menu-btn:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.user-menu-btn[aria-expanded="true"] { background: var(--bg-hover); color: var(--text); }

.user-popover {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 8px;
  width: 300px;
  max-width: calc(100vw - 24px);
  background: var(--bg-page);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 4px 0;
  z-index: 80;
  display: none;
}
.user-popover.open { display: block; }
.app.rail .user-popover { display: none !important; }

.pop-section-label {
  padding: 8px var(--space-4) 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  text-transform: uppercase;
}
.pop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--space-4);
  min-height: 44px;
  color: var(--text);
  font-size: 13px;
  background: none;
  border: 0;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
  text-decoration: none;
}
.pop-item:hover { background: var(--bg-hover); }
.pop-item:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; border-radius: var(--radius-sm); }
.pop-item .i,
.pop-item .icon { width: 16px; height: 16px; opacity: 0.75; flex-shrink: 0; }
.pop-item-text { flex: 1; min-width: 0; }
.pop-item-text .title { font-weight: 500; color: var(--text); }
.pop-item-text .sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; line-height: 1.3; }
.pop-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* --- iOS-style toggle switch (role="switch") --- */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
  background: var(--border-strong);
  border-radius: 999px;
  border: 0;
  padding: 0;
  cursor: pointer;
  transition: background 160ms;
}
.switch::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-invert);
  top: 2px;
  left: 2px;
  transition: transform 160ms;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::before { transform: translateX(16px); }
.switch:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .switch, .switch::before { transition: none; }
}

/* --- screen-reader only (live-region) --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Skip link (a11y P0) --- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--text-invert);
  padding: 10px 16px;
  z-index: 9999;
  border-radius: 0 0 var(--radius) 0;
  font-weight: 600;
}
.skip-link:focus { left: 0; outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* --- Legacy user-actions (на случай переходного периода) --- */
.user-actions { font-size: 11px; margin-top: 2px; }
.user-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 4px 8px;
  margin: -4px -8px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
}
.user-actions a:hover { color: var(--accent); background: var(--bg-hover); }

/* --- Mobile drawer (<768px) --- */
.menu-toggle { display: none; }
.sb-overlay { display: none; }

@media (max-width: 767px) {
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
  }
  .menu-toggle:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
  .app { grid-template-columns: 1fr; }
  .app.rail { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 200ms ease;
    box-shadow: var(--shadow-lg);
  }
  .app.drawer-open .sidebar { transform: translateX(0); }
  .sb-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms;
  }
  .app.drawer-open .sb-overlay { opacity: 1; pointer-events: auto; }
  .app.drawer-open { overflow: hidden; }
}

/* Main */
.main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
}

.topbar {
  background: var(--bg-muted);   /* title bar как в VS Code — темнее editor */
  border-bottom: 1px solid var(--border);
  padding: 14px 30px;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 56px;
}

.topbar h1 {
  font-size: 19px;
  font-weight: 600;
  color: var(--rb-ink);
}

.topbar-sub {
  color: var(--rb-muted);
  font-size: 13px;
  margin-left: 4px;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;           /* R14 tap-target */
  padding: 10px 15px;
  border: none;
  border-radius: 7px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  color: inherit;
}

.btn-primary { background: var(--rb-coral); color: white; }
.btn-primary:hover { background: var(--rb-coral-dark); }
.btn-outline { background: transparent; border: 1px solid var(--rb-line); color: var(--rb-ink); }
.btn-outline:hover { background: var(--rb-cream); }
.btn-mint { background: var(--rb-mint); color: white; }
.btn-ghost { background: transparent; color: var(--rb-muted); padding: 7px 10px; }
.btn-ghost:hover { background: var(--rb-cream); color: var(--rb-ink); }

.content { flex: 1; padding: 30px; overflow-y: auto; }

/* Utility */
.card {
  background: var(--rb-white);
  border: 1px solid var(--rb-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.tag {
  display: inline-block;
  padding: 2px 9px;
  background: var(--rb-cream);
  border: 1px solid var(--rb-line);
  border-radius: 12px;
  font-size: 11px;
  color: var(--rb-muted);
  font-weight: 500;
}
.tag-mint { background: rgba(122,154,122,0.14); border-color: rgba(122,154,122,0.3); color: var(--rb-mint); }
.tag-coral { background: var(--rb-coral-light); border-color: rgba(200,90,90,0.3); color: var(--rb-coral-dark); }
.tag-warn { background: rgba(212,168,66,0.14); border-color: rgba(212,168,66,0.3); color: var(--warning); }
.tag-danger { background: rgba(199,74,58,0.14); border-color: rgba(199,74,58,0.3); color: var(--rb-danger); }

/* SVG icon */
.i {
  display: inline-block;
  width: 16px; height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -3px;
}

/* Bento grid (dashboard) */
.bento {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: minmax(120px, auto);
  gap: 16px;
}
.bx {
  background: var(--rb-white);
  border: 1px solid var(--rb-line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
.bx-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.bx-head h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--rb-muted);
  font-weight: 700;
  font-family: 'Inter', sans-serif;
}
.bx-head svg { color: var(--rb-coral); width: 15px; height: 15px; }
.bx-head .more {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--rb-coral);
  text-decoration: none;
  font-weight: 500;
}

.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-9 { grid-column: span 9; }
.col-12 { grid-column: span 12; }
.row-2 { grid-row: span 2; }
.row-3 { grid-row: span 3; }

/* Hero */
.hero {
  grid-column: span 12;
  background: var(--accent);
  color: white;
  border: none;
  padding: 22px 28px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-sm);
}
.hero h2 { font-family: var(--font-mono); font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.hero p { opacity: 0.9; font-size: 14px; }
.hero-right { display: flex; gap: 24px; margin-left: auto; align-items: center; flex-shrink: 0; }
.hero-stat { text-align: right; }
.hero-stat b { display: block; font-family: var(--font-mono); font-size: 22px; }
.hero-stat small { font-size: 11px; opacity: 0.8; text-transform: uppercase; letter-spacing: 0.7px; }

/* KPI */
.kpi-value { font-family: var(--font-mono); font-size: 32px; font-weight: 700; color: var(--rb-ink); line-height: 1; }
.kpi-delta { font-size: 12px; font-weight: 600; margin-top: 6px; display: inline-flex; align-items: center; gap: 4px; }
.kpi-delta.up { color: var(--rb-mint); }
.kpi-delta.down { color: var(--rb-danger); }
.kpi-label { font-size: 11.5px; color: var(--rb-muted); margin-top: 8px; text-transform: uppercase; letter-spacing: 0.7px; }
.kpi-bar { margin-top: 12px; height: 4px; background: var(--rb-cream); border-radius: 2px; overflow: hidden; }
.kpi-bar-inner { height: 100%; background: linear-gradient(90deg, var(--rb-mint), var(--rb-coral)); }

/* Activity feed */
.feed-item { display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rb-line); }
.feed-item:last-child { border-bottom: none; }
.feed-icon { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: white; flex-shrink: 0; }
.fi-add { background: var(--rb-mint); }
.fi-edit { background: var(--rb-warm-beige); }
.fi-alert { background: var(--rb-warn); }
.fi-chat { background: var(--rb-coral); }
.fi-fix { background: var(--info); }
.feed-body strong { font-weight: 600; font-size: 13.5px; display: block; }
.feed-body small { color: var(--rb-muted); font-size: 11.5px; }
.feed-time { color: var(--rb-muted); font-size: 11px; margin-top: 2px; }

/* Alerts */
.alert-item { display: grid; grid-template-columns: 8px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--rb-line); align-items: start; }
.alert-item:last-child { border-bottom: none; }
.alert-line { width: 3px; height: 100%; border-radius: 2px; min-height: 30px; }
.al-danger { background: var(--rb-danger); }
.al-warn { background: var(--rb-warn); }
.al-info { background: var(--rb-mint); }
.alert-body strong { display: block; font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.alert-body small { color: var(--rb-muted); font-size: 11.5px; }

/* Farm ring */
.farm-ring {
  width: 100px; height: 100px;
  border-radius: 50%;
  background: conic-gradient(var(--rb-mint) 0% var(--farm-pct, 89%), var(--rb-cream) var(--farm-pct, 89%) 100%);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  margin: 0 auto;
}
.farm-ring::after {
  content: '';
  position: absolute; inset: 8px;
  background: var(--rb-white);
  border-radius: 50%;
}
.farm-ring b {
  position: relative;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  z-index: 2;
  color: var(--rb-ink);
}
.farm-label { text-align: center; margin-top: 8px; font-size: 12px; color: var(--rb-muted); }
.farm-mini-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-top: 14px; text-align: center; }
.farm-mini-stats div b { display: block; font-family: var(--font-mono); font-size: 16px; color: var(--rb-coral); }
.farm-mini-stats div small { font-size: 10px; color: var(--rb-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* Trend rows */
.trend-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--rb-line); font-size: 13px; }
.trend-row:last-child { border-bottom: none; }
.trend-name { font-weight: 500; }
.trend-arrow { font-family: var(--font-mono); font-weight: 700; }
.arrow-up { color: var(--rb-mint); }
.arrow-down { color: var(--rb-danger); }

/* Cashflow */
.cash-bar-row { display: grid; grid-template-columns: 100px 1fr auto; gap: 10px; align-items: center; padding: 6px 0; font-size: 12.5px; }
.cash-label { color: var(--rb-muted); }
.cash-bar { height: 8px; background: var(--rb-cream); border-radius: 4px; overflow: hidden; }
.cash-bar-inner { height: 100%; background: var(--rb-coral); border-radius: 4px; }
.cash-bar-inner.mint { background: var(--rb-mint); }
.cash-value { font-family: var(--font-mono); font-weight: 600; text-align: right; }

/* Tasks */
.task-item {
  padding: 12px;
  background: var(--rb-cream);
  border-radius: 8px;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 10px;
  border-left: 3px solid var(--rb-coral);
}
.task-item:last-child { margin-bottom: 0; }
.task-body { flex: 1; }
.task-body strong { display: block; font-size: 13px; font-weight: 600; }
.task-body small { color: var(--rb-muted); font-size: 11px; }

/* Chat mini */
.chat-preview {
  background: var(--rb-cream);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--rb-muted);
  margin-bottom: 12px;
  border-left: 3px solid var(--rb-coral);
}
.chat-input-mini {
  display: flex; gap: 8px;
  border: 1px solid var(--rb-line);
  border-radius: 22px;
  padding: 6px 6px 6px 16px;
  align-items: center;
  background: var(--rb-white);
}
.chat-input-mini input {
  flex: 1; border: none; outline: none;
  font-family: inherit; font-size: 13.5px;
  color: var(--rb-ink); background: transparent;
}
.chat-input-mini input::placeholder { color: var(--rb-muted); }
.chat-send-btn {
  background: var(--rb-coral); color: white;
  width: 32px; height: 32px; border: none;
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* Quick links grid */
.quick-links {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 10px;
}
.ql {
  padding: 12px 10px; border-radius: 8px;
  background: var(--rb-cream);
  text-align: center;
  text-decoration: none; color: var(--rb-ink);
  font-size: 12px; font-weight: 500;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: all 0.15s;
}
.ql:hover { background: var(--rb-coral-light); color: var(--rb-coral-dark); }
.ql svg { width: 20px; height: 20px; color: var(--rb-coral); }

/* Data table */
table.data {
  width: 100%; background: var(--rb-white);
  border-collapse: collapse; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--rb-line); box-shadow: var(--shadow-sm);
}
table.data th {
  background: var(--rb-cream); padding: 12px 16px; text-align: left;
  font-size: 11px; color: var(--rb-muted);
  text-transform: uppercase; letter-spacing: 0.7px;
  border-bottom: 1px solid var(--rb-line); font-weight: 700;
}
table.data td { padding: 12px 16px; border-bottom: 1px solid var(--rb-line); font-size: 13.5px; vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover { background: var(--rb-cream); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Empty state */
.empty {
  text-align: center; padding: 60px 20px;
  color: var(--rb-muted);
  background: var(--rb-white); border-radius: var(--radius);
  border: 1px dashed var(--rb-line);
}
.empty h3 { color: var(--rb-ink); margin-bottom: 8px; }

/* Filters */
.filters {
  background: var(--rb-white); border: 1px solid var(--rb-line);
  border-radius: var(--radius); padding: 16px;
  display: flex; gap: 12px; flex-wrap: wrap;
  align-items: end; margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.filters label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11px; color: var(--rb-muted);
  text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
}
.filters input, .filters select {
  padding: 7px 10px; border: 1px solid var(--rb-line);
  border-radius: 6px; font-size: 13px;
  background: white; min-width: 140px; font-family: inherit;
}

/* ═══ Knowledge Graph viz (эталон 03) ═══ */
.kg-layout {
  display: grid;
  grid-template-columns: 240px 1fr 320px;
  gap: 16px;
  height: calc(100vh - 116px);
}
@media (max-width: 1200px) { .kg-layout { grid-template-columns: 220px 1fr; } .kg-detail { display: none; } }
@media (max-width: 900px) { .kg-layout { grid-template-columns: 1fr; height: auto; } .kg-filters { max-height: 200px; } }

.kg-filters, .kg-detail {
  display: flex; flex-direction: column; gap: 12px;
  overflow-y: auto;
}
.kg-block {
  background: var(--rb-white);
  border: 1px solid var(--rb-line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.kg-block h3 {
  font-size: 11px;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--rb-muted);
  margin-bottom: 10px;
}

.filter-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0;
  font-size: 13px;
  cursor: pointer;
}
.filter-item input { accent-color: var(--rb-coral); cursor: pointer; }
.filter-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.filter-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--rb-muted);
  background: var(--rb-cream);
  padding: 1px 7px;
  border-radius: 10px;
}

.kg-canvas {
  background: var(--bg-hover);
  border: 1px solid var(--rb-line);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  min-height: 400px;
}
.kg-canvas svg { width: 100%; height: 100%; display: block; }

.canvas-toolbar {
  position: absolute;
  top: 12px; left: 12px;
  display: flex; gap: 6px;
  z-index: 10;
}
.canvas-toolbar .btn {
  padding: 5px 10px;
  font-size: 12px;
  background: var(--rb-white);
  border: 1px solid var(--rb-line);
}

.canvas-legend {
  position: absolute;
  bottom: 12px; left: 12px;
  background: var(--rb-white);
  border: 1px solid var(--rb-line);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 11px;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}
.canvas-legend .lg-row { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; }
.canvas-legend .lg-row:last-child { margin-bottom: 0; }
.canvas-legend .lg-dot { width: 10px; height: 10px; border-radius: 50%; }

.detail-title {
  font-size: 15px; font-weight: 700;
  margin-bottom: 4px;
  font-family: var(--font-mono);
}
.detail-id {
  font-size: 11px; color: var(--rb-muted);
  font-family: 'SFMono-Regular', Consolas, monospace;
  margin-bottom: 12px; word-break: break-all;
}
.detail-meta {
  padding: 10px 0;
  border-top: 1px solid var(--rb-line);
  font-size: 12.5px;
}
.detail-meta strong {
  display: block;
  color: var(--rb-muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
  font-weight: 700;
}

/* Zone colors */
.zone-brand    { fill: #c85a5a; stroke: #c85a5a; }
.zone-warehouse{ fill: #7a9a7a; stroke: #7a9a7a; }
.zone-site     { fill: #a99686; stroke: #a99686; }
.zone-equipment{ fill: #d4a842; stroke: #d4a842; }
.zone-legal    { fill: #7d8ea8; stroke: #7d8ea8; }
.zone-integr   { fill: #b878b8; stroke: #b878b8; }

/* ═══ Service registry (эталон 04) ═══ */
.svc-topcards { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 22px; }
.svc-topcard {
  background: var(--rb-white);
  border: 1px solid var(--rb-line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.svc-topcard b { display: block; font-family: var(--font-mono); font-size: 24px; color: var(--rb-coral); margin-bottom: 4px; }
.svc-topcard small { color: var(--rb-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.7px; }
.svc-topcard.ok b { color: var(--rb-mint); }
.svc-topcard.warn b { color: var(--rb-warn); }

.grp-title {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  margin: 22px 0 12px;
  color: var(--rb-ink);
  display: flex; align-items: center; gap: 10px;
}
.grp-title .grp-count {
  background: var(--rb-cream);
  color: var(--rb-muted);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 12px;
}

.svc-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
@media (max-width: 900px) { .svc-grid { grid-template-columns: 1fr; } }

.svc-card {
  background: var(--rb-white);
  border: 1px solid var(--rb-line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 12px;
  transition: all 0.15s;
}
.svc-card:hover { box-shadow: var(--shadow-md); border-color: var(--rb-coral-light); }

.svc-head { display: flex; align-items: center; gap: 12px; }
.svc-logo {
  width: 40px; height: 40px;
  background: var(--rb-cream);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 700;
  font-size: 15px;
  color: var(--rb-coral);
  flex-shrink: 0;
  border: 1px solid var(--rb-line);
}
.svc-info h4 { font-size: 14px; font-family: 'Inter', sans-serif; font-weight: 600; margin-bottom: 2px; }
.svc-info small { color: var(--rb-muted); font-size: 11.5px; }

.svc-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 12px;
  margin-left: auto;
}
.status-ok { background: rgba(122,154,122,0.14); color: var(--rb-mint); }
.status-warn { background: rgba(212,168,66,0.14); color: var(--warning); }
.status-err { background: rgba(199,74,58,0.14); color: var(--rb-danger); }
.status-off { background: var(--rb-cream); color: var(--rb-muted); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.svc-body { font-size: 12.5px; color: var(--rb-muted); line-height: 1.55; }
.svc-body b { color: var(--rb-ink); font-weight: 600; }
.svc-row { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--rb-line); }
.svc-row:last-child { border-bottom: none; }
.svc-row .row-label { color: var(--rb-muted); font-size: 11.5px; }
.svc-row .row-value { color: var(--rb-ink); font-size: 12px; font-weight: 500; text-align: right; }

.svc-actions { display: flex; gap: 6px; margin-top: 4px; }
.svc-actions .btn { padding: 6px 11px; font-size: 12px; flex: 1; justify-content: center; }

/* ═══ Process map (эталон 09_process_centric) ═══ */

.proc-list { padding: 6px 0; }
.proc-item {
  display: grid;
  grid-template-columns: 4px 1fr auto;
  gap: 10px;
  padding: 9px 14px 9px 10px;
  align-items: center;
  cursor: pointer;
  border-left: 4px solid transparent;
  text-decoration: none;
  color: var(--rb-ink);
}
.proc-item:hover { background: var(--rb-cream); }
.proc-item.active {
  background: var(--rb-coral-light);
  border-left-color: var(--rb-coral);
}
.proc-item .p-strip { width: 4px; height: 22px; border-radius: 2px; grid-column: 1; }
.p-strip.mint { background: var(--rb-mint); }
.p-strip.warn { background: var(--rb-warn); }
.p-strip.danger { background: var(--rb-danger); }
.proc-item .p-info { grid-column: 2; font-size: 12.5px; line-height: 1.3; min-width: 0; }
.p-info strong { display: block; font-weight: 600; font-size: 13px; color: var(--rb-ink); }
.p-info small { color: var(--rb-muted); font-size: 11px; }
.proc-item .p-pct {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  grid-column: 3;
  color: var(--rb-muted);
}
.p-pct.mint { color: var(--rb-mint); }
.p-pct.warn { color: var(--rb-warn); }
.p-pct.danger { color: var(--rb-danger); }

.proc-header {
  padding: 18px 26px 14px;
  background: var(--rb-white);
  border-bottom: 1px solid var(--rb-line);
  display: flex;
  align-items: center;
  gap: 22px;
}
.health-ring {
  width: 92px; height: 92px;
  border-radius: 50%;
  background: conic-gradient(var(--ring-color, var(--rb-mint)) 0% var(--ring-pct, 100%), var(--rb-cream) var(--ring-pct, 100%) 100%);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.health-ring::before {
  content: '';
  position: absolute; inset: 8px;
  background: var(--rb-white);
  border-radius: 50%;
}
.health-ring b {
  position: relative;
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--ring-color, var(--rb-mint));
}
.proc-header .p-title h1 {
  font-family: var(--font-mono);
  font-size: 22px;
  margin-bottom: 2px;
}
.proc-header .p-title .p-id {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 11px;
  color: var(--rb-muted);
}
.p-badges { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.canvas {
  padding: 24px 26px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  background: linear-gradient(180deg, var(--rb-cream), var(--rb-bg));
}
.flow-wrap {
  background: var(--rb-white);
  border: 1px solid var(--rb-line);
  border-radius: var(--radius);
  padding: 22px 24px 28px;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.flow-caption {
  text-align: center;
  font-size: 11px;
  color: var(--rb-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  margin-bottom: 16px;
}
.flow-grid {
  display: grid;
  grid-template-columns: 1fr 260px 1fr;
  gap: 60px;
  align-items: center;
  position: relative;
  min-height: 380px;
}
@media (max-width: 900px) {
  .flow-grid { grid-template-columns: 1fr; gap: 20px; }
}
.col-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--rb-warm-beige);
  font-weight: 700;
  margin-bottom: 12px;
  padding: 0 4px;
}
.col-inputs { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.col-inputs .col-label { text-align: right; }
.col-outputs { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.col-outputs .col-label { text-align: left; }
.col-process { display: flex; flex-direction: column; align-items: center; }

.input-card {
  background: var(--rb-white);
  border: 1px solid var(--rb-line);
  border-left: 4px solid var(--rb-mint);
  border-radius: 8px;
  padding: 8px 12px;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 320px;
}
.input-card.warn { border-left-color: var(--rb-warn); }
.input-card.danger { border-left-color: var(--rb-danger); }
.input-icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--rb-cream);
  display: flex; align-items: center; justify-content: center;
  color: var(--rb-warm-beige);
  flex-shrink: 0;
}
.input-body strong { display: block; font-weight: 600; font-size: 12.5px; }
.input-body small { color: var(--rb-muted); font-size: 10.5px; }
.input-weight {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  color: var(--rb-coral);
  text-align: right;
  white-space: nowrap;
}
.input-weight small {
  display: block;
  font-size: 9px;
  color: var(--rb-muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  font-weight: 700;
}

.process-node {
  background: var(--accent-bg);
  border: 3px solid var(--rb-warn);
  border-radius: 20px;
  padding: 26px 22px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(200,90,90,0.16);
  width: 100%;
  max-width: 260px;
}
.process-node.ok { border-color: var(--rb-mint); }
.process-node.danger { border-color: var(--rb-danger); }
.process-node .process-title {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--rb-ink);
  margin-bottom: 4px;
}
.process-node .process-sub {
  font-size: 11.5px;
  color: var(--rb-muted);
  margin-bottom: 14px;
}
.process-health-big {
  font-family: var(--font-mono);
  font-size: 46px;
  font-weight: 700;
  color: var(--proc-color, var(--rb-warn));
  line-height: 1;
}
.process-status {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 12px;
  background: var(--proc-bg, rgba(212,168,66,0.14));
  color: var(--proc-color-strong, var(--warning));
  border: 1px solid var(--proc-border, rgba(212,168,66,0.3));
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.process-formula {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--rb-line);
  font-size: 10.5px;
  color: var(--rb-muted);
  font-family: 'SFMono-Regular', Consolas, monospace;
  line-height: 1.5;
  text-align: left;
}

.output-card {
  background: var(--rb-white);
  border: 1px solid var(--rb-line);
  border-right: 4px solid var(--rb-mint);
  border-radius: 8px;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 320px;
}
.output-card.warn { border-right-color: var(--rb-warn); }
.output-card.danger { border-right-color: var(--rb-danger); }
.output-body strong { display: block; font-weight: 600; font-size: 12.5px; }
.output-body .metric {
  font-size: 10.5px;
  color: var(--rb-muted);
  margin-top: 2px;
}
.output-body .metric b { color: var(--rb-ink); font-weight: 600; }
.output-delta {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  text-align: right;
  white-space: nowrap;
}
.output-delta.up { color: var(--rb-mint); }
.output-delta.down { color: var(--rb-danger); }
.output-delta.warn { color: var(--rb-warn); }

/* ═══ Shared blocks (registry / tree / rating / history) ═══ */

/* Metric cards row (Trend Radar, Assets top) */
.metric-cards { display: grid; gap: 14px; margin-bottom: 22px; }
.metric-cards.c5 { grid-template-columns: repeat(5,1fr); }
.metric-cards.c4 { grid-template-columns: repeat(4,1fr); }
.metric-cards.c3 { grid-template-columns: repeat(3,1fr); }
/* Mobile responsive для метрик — правило R14 */
@media (max-width: 900px) {
  .metric-cards.c5,
  .metric-cards.c4 { grid-template-columns: repeat(2, 1fr); }
  .metric-cards.c3 { grid-template-columns: repeat(2, 1fr); }
  .metric-cards { gap: 10px; margin-bottom: 16px; }
}
@media (max-width: 480px) {
  .metric-cards.c5,
  .metric-cards.c4,
  .metric-cards.c3 { grid-template-columns: 1fr 1fr; }
  .mc { padding: 10px 12px; }
  .mc b { font-size: clamp(18px, 5vw, 22px); }
  .mc small { font-size: 10px; letter-spacing: 0.3px; }
  .mc .sub { font-size: 10.5px; }
}
/* Универсальный wrapper для широких таблиц — R14 */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  border-radius: 8px;
  position: relative;
}
.table-scroll::after {
  content: '';
  position: sticky;
  right: 0; top: 0; bottom: 0;
  width: 24px;
  pointer-events: none;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.85));
  display: block;
}
@media (min-width: 900px) {
  .table-scroll::after { display: none; }
}
.mc {
  background: var(--rb-white);
  border: 1px solid var(--rb-line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.mc b { display: block; font-family: var(--font-mono); font-size: 22px; color: var(--rb-coral); margin-bottom: 3px; }
.mc.mint b { color: var(--rb-mint); }
.mc.warn b { color: var(--rb-warn); }
.mc.danger b { color: var(--rb-danger); }
.mc small { color: var(--rb-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px; }
.mc .sub { font-size: 11.5px; color: var(--rb-muted); margin-top: 4px; }

/* Box container (page section) */
.box {
  background: var(--rb-white);
  border: 1px solid var(--rb-line);
  border-radius: var(--radius);
  overflow: hidden;
}
.box-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--rb-line);
  display: flex; align-items: center; gap: 8px;
}
.box-head h2 { font-size: 14px; font-family: 'Inter', sans-serif; font-weight: 600; }
.box-head .sub { margin-left: auto; font-size: 11px; color: var(--rb-muted); }
.box-head .more, .box-head a.more {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  min-height: 44px;               /* R14 tap-target */
  padding: 6px 12px;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.box-head .more:hover { background: var(--bg-hover); text-decoration: none; }

/* 2-col registry layout: tree/list + detail */
.reg-layout { display: grid; grid-template-columns: 320px 1fr; gap: 20px; margin-bottom: 22px; }
@media (max-width: 900px) { .reg-layout { grid-template-columns: 1fr; } }

/* Tree navigation */
.tree { padding: 10px 0; font-size: 13px; max-height: 620px; overflow-y: auto; }
.tree-node {
  min-height: 44px;           /* R14 tap-target */
  padding: 10px 16px; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  color: inherit; text-decoration: none;
  border-left: 3px solid transparent;
}
.tree-node:hover { background: var(--rb-cream); }
.tree-node.selected {
  background: var(--rb-coral-light);
  color: var(--rb-coral-dark);
  font-weight: 600;
  border-left-color: var(--rb-coral);
}
.tree-level-1 { font-family: var(--font-mono); font-weight: 600; padding-left: 12px; font-size: 13.5px; }
.tree-level-2 { padding-left: 26px; }
.tree-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--rb-muted);
  background: var(--rb-cream);
  padding: 1px 7px;
  border-radius: 10px;
}
.health-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.health-ok { background: var(--rb-mint); }
.health-warn { background: var(--rb-warn); }
.health-danger { background: var(--rb-danger); }
.health-off { background: var(--rb-muted); opacity: 0.4; }

/* Rating list (Trend Radar) */
.rating-tabs {
  display: flex; gap: 4px;
  padding: 12px 12px 0;
  border-bottom: 1px solid var(--rb-line);
}
.rating-tab {
  display: inline-flex;
  align-items: center;
  min-height: 44px;           /* R14 tap-target */
  padding: 10px 14px;
  font-size: 12.5px;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  color: var(--rb-muted);
  font-weight: 500;
  text-decoration: none;
}
.rating-tab.active {
  background: var(--rb-cream);
  color: var(--rb-coral-dark);
  font-weight: 600;
}
.rating-list { max-height: 560px; overflow-y: auto; }
.rating-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--rb-line);
  align-items: center;
  text-decoration: none; color: inherit;
}
.rating-row:hover { background: var(--rb-cream); cursor: pointer; }
.rating-num { font-family: var(--font-mono); font-weight: 600; color: var(--rb-muted); }
.rating-name { font-size: 13px; font-weight: 500; }
.rating-meta { font-size: 11px; color: var(--rb-muted); }
.rating-score {
  text-align: right;
  font-family: var(--font-mono); font-weight: 700; font-size: 15px;
  color: var(--rb-coral);
}
.rating-score.mid { color: var(--rb-warm-beige); }
.rating-score.warn { color: var(--rb-warn); }
.rating-trend { font-size: 10px; margin-left: 4px; }
.rating-trend.up { color: var(--rb-mint); }
.rating-trend.down { color: var(--rb-danger); }

/* History rows (Trend Radar history, changelog) */
.hist-row {
  display: grid;
  grid-template-columns: 80px 100px 1fr;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--rb-line);
  font-size: 12.5px;
  align-items: center;
}
.hist-row:last-child { border-bottom: none; }
.hist-date { color: var(--rb-muted); font-size: 11px; }
.hist-badge {
  text-align: center;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}
.hist-badge.up { background: rgba(122,154,122,0.14); color: var(--rb-mint); }
.hist-badge.down { background: rgba(199,74,58,0.14); color: var(--rb-danger); }
.hist-badge.warn { background: rgba(212,168,66,0.14); color: var(--warning); }
.hist-badge.info { background: rgba(200,90,90,0.14); color: var(--rb-coral-dark); }
.hist-badge.neutral { background: var(--rb-cream); color: var(--rb-muted); }
.hist-text b { font-weight: 600; }

/* Asset/proposal hero header */
.detail-hero {
  padding: 20px 22px;
  border-bottom: 1px solid var(--rb-line);
  background: var(--bg-hover);
}
.detail-hero h1 { font-family: var(--font-mono); font-size: 22px; margin-bottom: 2px; }
.detail-hero .id-line {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 11px; color: var(--rb-muted);
  margin-bottom: 12px;
}
.detail-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 12px; }
.detail-meta-item small {
  display: block; font-size: 10.5px;
  color: var(--rb-muted);
  text-transform: uppercase; letter-spacing: 0.7px; font-weight: 600;
}
.detail-meta-item b { display: block; font-size: 13px; margin-top: 2px; }

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--rb-line);
  background: var(--rb-white);
}
.tab {
  padding: 12px 18px;
  font-size: 13px; cursor: pointer;
  color: var(--rb-muted);
  border-bottom: 2.5px solid transparent;
  font-weight: 500;
  text-decoration: none;
}
.tab.active {
  color: var(--rb-coral-dark);
  border-bottom-color: var(--rb-coral);
  font-weight: 600;
}
.tab-content { padding: 20px 24px; }

/* Spec grid (asset details, proposal state) */
.spec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 30px; }
@media (max-width: 700px) { .spec-grid { grid-template-columns: 1fr; } }
.spec-item {
  display: flex; justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--rb-line);
  font-size: 13px;
}
.spec-item strong { color: var(--rb-ink); font-weight: 500; }
.spec-item span { color: var(--rb-muted); text-align: right; }
.spec-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--rb-muted); margin-bottom: 8px; margin-top: 18px; font-weight: 700;
}
.spec-title:first-child { margin-top: 0; }

/* Progress / bar row (planning, forecast) */
.bar-row {
  padding: 10px 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--rb-line);
}
.bar-row:last-child { border-bottom: none; }
.bar-name { font-size: 13px; font-weight: 500; }
.bar-hint { font-size: 11px; color: var(--rb-muted); }
.bar-outer { width: 160px; height: 8px; background: var(--rb-cream); border-radius: 4px; overflow: hidden; }
.bar-inner { height: 100%; background: linear-gradient(90deg, var(--rb-mint), var(--rb-coral)); border-radius: 4px; }

/* AI Chat layout */
.chat-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  height: calc(100vh - 116px);
}
.chat-main {
  display: flex; flex-direction: column;
  background: var(--rb-white);
  border: 1px solid var(--rb-line);
  border-radius: var(--radius);
  overflow: hidden;
}
.chat-thread { flex: 1; padding: 24px 28px; overflow-y: auto; }

.msg { margin-bottom: 22px; max-width: 720px; }
.msg-user { margin-left: auto; }
.msg-user .msg-bubble {
  background: var(--rb-coral);
  color: white;
  border-radius: 16px 16px 4px 16px;
}
.msg-user .msg-meta { text-align: right; }

.msg-bubble {
  padding: 13px 17px;
  background: var(--rb-cream);
  border: 1px solid var(--rb-line);
  border-radius: 4px 16px 16px 16px;
  font-size: 14px; line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg-meta {
  font-size: 11px; color: var(--rb-muted);
  margin-bottom: 5px;
  display: flex; align-items: center; gap: 6px;
}
.msg-ai .msg-meta { font-weight: 600; color: var(--rb-coral-dark); }
.msg-ai .msg-bubble h4 { font-size: 14px; margin-bottom: 8px; color: var(--rb-ink); }
.msg-ai .msg-bubble p { margin-bottom: 10px; }
.msg-ai .msg-bubble p:last-child { margin-bottom: 0; }
.msg-ai .msg-bubble ul { padding-left: 20px; margin: 8px 0; }
.msg-ai .msg-bubble li { margin-bottom: 5px; }

.msg-tool {
  max-width: 720px;
  background: rgba(122,154,122,0.08);
  border-left: 3px solid var(--rb-mint);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--rb-muted);
  margin: 10px 0;
  font-family: 'Inter', monospace;
}
.msg-tool code { color: var(--rb-mint); font-weight: 600; }

.cite {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px;
  background: rgba(122,154,122,0.14);
  color: var(--rb-mint);
  border-radius: 10px;
  font-size: 11px; font-weight: 600;
  vertical-align: middle;
  cursor: pointer; text-decoration: none;
}

.action-row {
  display: flex; gap: 8px;
  margin-top: 12px; flex-wrap: wrap;
}

.chat-input {
  border-top: 1px solid var(--rb-line);
  padding: 14px 20px;
  background: var(--rb-white);
  display: flex; gap: 10px;
  align-items: flex-end;
}
.chat-input textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--rb-line);
  border-radius: 10px;
  padding: 10px 14px;
  font-family: inherit; font-size: 14px;
  outline: none;
  min-height: 42px; max-height: 120px;
}
.chat-input textarea:focus { border-color: var(--rb-coral); }

.side-panel {
  display: flex; flex-direction: column;
  gap: 16px; overflow-y: auto;
}
.side-block {
  background: var(--rb-white);
  border: 1px solid var(--rb-line);
  border-radius: var(--radius);
  padding: 16px;
}
.side-block h3 {
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--rb-muted);
  margin-bottom: 12px;
}

.source-item {
  display: flex; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--rb-line);
  font-size: 12.5px;
}
.source-item:last-child { border-bottom: none; }
.source-item .source-num {
  background: var(--rb-mint); color: white;
  border-radius: 4px;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}
.source-item .source-info strong { display: block; font-weight: 600; color: var(--rb-ink); font-size: 12.5px; }
.source-item .source-info small { color: var(--rb-muted); font-size: 11px; }

.impact-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; font-size: 12.5px;
}
.impact-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rb-mint); }

.history-item {
  padding: 8px 10px; border-radius: 6px;
  font-size: 12.5px; color: var(--rb-muted);
  cursor: pointer;
  text-decoration: none; display: block;
  margin-bottom: 2px;
}
.history-item:hover { background: var(--rb-cream); color: var(--rb-ink); }
.history-item.current {
  background: var(--rb-coral-light);
  color: var(--rb-coral-dark);
  font-weight: 600;
}

/* Mobile tablet (768-900px). ВНИМАНИЕ: sidebar v2 управляет собой через свой
   @media (max-width: 767px) выше по файлу. Legacy sidebar overrides удалены
   2026-10-13 (ломали mobile drawer и tablet layout). */
@media (max-width: 900px) {
  .content { padding: 16px; }
  .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9 { grid-column: span 12; }
  .hero { flex-direction: column; align-items: flex-start; gap: 16px; }
  .hero-right { margin-left: 0; }
  .quick-links { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .topbar h1 { font-size: 17px; }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .side-panel { order: 2; }
  .chat-thread { min-height: 400px; }
}

/* =========================================================================
   DIALOG SYSTEM (VS Code 2026, глобальные правила)
   Fix: * { margin: 0 } (строка 8) убил центрирование <dialog>.
   Восстанавливаем + добавляем полный стиль header/body/footer.
   ========================================================================= */

/* CRITICAL: dialog БЕЗ [open] должен быть display:none (нативный UA style).
   Без [open]-guard все диалоги на странице сразу видны одновременно. */
dialog:not([open]) { display: none !important; }

dialog[open] {
  margin: auto;                         /* центрирование, перебивает reset */
  inset: 0;
  padding: 0;
  max-width: min(560px, 94vw);
  max-height: 90vh;
  width: fit-content;
  height: fit-content;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 8px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

dialog::backdrop {
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(1px);
}

[data-theme="dark"] dialog::backdrop {
  background: rgba(0,0,0,0.6);
}

.dlg-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.dlg-head h3 {
  margin: 0;
  font-size: var(--font-size-md, 15px);
  font-weight: 500;
}

.dlg-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.dlg-body label {
  display: block;
  margin-bottom: 12px;
  font-size: var(--font-size-sm, 13px);
}

.dlg-body label small {
  display: block;
  color: var(--text-muted);
  font-size: 10px;
  margin-top: 2px;
}

.dlg-body input,
.dlg-body select,
.dlg-body textarea {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 4px);
  font-size: var(--font-size-sm, 13px);
  background: var(--bg-card);
  color: var(--text);
  margin-top: 4px;
  box-sizing: border-box;
  font-family: var(--font-body);
}

.dlg-body input[readonly],
.dlg-body textarea[readonly] {
  background: var(--bg-page);
  color: var(--text-muted);
  cursor: default;
}

.dlg-actions {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-shrink: 0;
  background: var(--bg-card);
}

.dlg-close {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm, 4px);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dlg-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.dlg-warn {
  background: var(--danger-bg, #fdf2f2);
  padding: 10px 12px;
  border-radius: var(--radius-sm, 4px);
  font-size: var(--font-size-sm, 13px);
  color: var(--danger, #c85a5a);
  margin-bottom: 12px;
}

@media (max-width: 640px) {
  dialog {
    max-width: 100vw;
    width: 100vw;
    max-height: 92vh;
    inset: auto 0 0 0;
    margin: 0;
    border-radius: 16px 16px 0 0;
  }
}

/* =========================================================================
   DROPDOWN CONTEXT MENU (three-dots, position:fixed чтобы не ломало overflow-x)
   ========================================================================= */

.wl-dropdown {
  position: fixed;
  z-index: 9000;
  min-width: 220px;
  max-width: 320px;
  padding: 6px 0;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius, 6px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: none;
}

.wl-dropdown[data-open="true"] {
  display: block;
}

.wl-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  min-height: 36px;
  font-size: var(--font-size-sm, 13px);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
}

.wl-dropdown-item:hover {
  background: var(--bg-hover);
}

.wl-dropdown-item.danger {
  color: var(--danger, #c85a5a);
}

.wl-dropdown-item.danger:hover {
  background: var(--danger-bg, #fdf2f2);
}

.wl-dropdown-item i,
.wl-dropdown-item .icon {
  width: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.wl-dropdown-item.danger i {
  color: var(--danger, #c85a5a);
}

.wl-dropdown-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}

@media (max-width: 640px) {
  .wl-dropdown {
    position: fixed;
    inset: auto 0 0 0;
    min-width: 100vw;
    max-width: 100vw;
    max-height: 60vh;
    border-radius: 12px 12px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 16px);
    overflow-y: auto;
  }

  .wl-dropdown-item {
    min-height: 44px;
    padding: 12px 20px;
  }
}

/* =========================================================================
   WIKI-HINT (.wh) — global popup tooltip по КЛИКУ (не hover)
   ========================================================================= */

.wh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  margin-left: 4px;
  vertical-align: middle;
  border: none;
  padding: 0;
  font-family: var(--font-body);
  line-height: 14px;
  transition: background 100ms, color 100ms;
}

.wh:hover,
.wh:focus-visible {
  background: var(--accent, #005fb8);
  color: white;
  outline: none;
}

/* =========================================================================
   Wiki-hint popup (по консенсусу 3 агентов: UI-reviewer + wiki_writer + IA)
   Center-modal on desktop/tablet + bottom-sheet on mobile ≤640
   ========================================================================= */

#wh-popup {
  max-width: min(520px, calc(100vw - 24px));
  max-height: min(80vh, calc(100vh - 48px));
  border-radius: var(--radius-lg, 8px);
  animation: wh-in 140ms cubic-bezier(0.16, 1, 0.3, 1);
}

#wh-popup::backdrop {
  animation: wh-backdrop-in 100ms ease-out;
}

@keyframes wh-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes wh-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  #wh-popup, #wh-popup::backdrop { animation: none; }
}

@media (max-width: 640px) {
  #wh-popup {
    max-width: 100vw;
    width: 100vw;
    inset: auto 0 0 0;
    margin: 0;
    border-radius: 12px 12px 0 0;
    max-height: 85vh;
    animation: wh-slide-up 220ms cubic-bezier(0.32, 0.72, 0, 1);
  }
  @keyframes wh-slide-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
  #wh-popup::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 8px auto 0;
    flex-shrink: 0;
  }
}

#wh-popup .dlg-head {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
  flex-shrink: 0;
}

#wh-popup .wh-popup-title {
  font-size: 15px;
  font-weight: 500;
  margin: 0;
  color: var(--text);
  flex: 1;
  margin-right: 12px;
  line-height: 1.4;
}

#wh-popup .wh-popup-body {
  padding: 16px 20px 20px;
  font-size: var(--font-size-sm, 13px);
  line-height: 1.6;
  color: var(--text);
  overflow-y: auto;
  flex: 1;
}

@media (max-width: 640px) {
  #wh-popup .wh-popup-body { font-size: 14px; }
}

#wh-popup .wh-popup-body p { margin: 0 0 10px; }
#wh-popup .wh-popup-body p:last-child { margin-bottom: 0; }
#wh-popup .wh-popup-body strong { font-weight: 500; color: var(--text); }

#wh-popup .wh-popup-body code {
  background: var(--bg-hover);
  padding: 1px 4px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
}

#wh-popup .wh-popup-body pre {
  background: var(--bg-hover);
  padding: 10px 12px;
  border-radius: var(--radius-sm, 4px);
  overflow-x: auto;
  margin: 10px 0;
  font-size: 11px;
  line-height: 1.5;
}

#wh-popup .wh-popup-body ul,
#wh-popup .wh-popup-body ol { margin: 8px 0 8px 20px; }

#wh-popup .wh-popup-body a {
  color: var(--accent, #005fb8);
  text-decoration: none;
}

#wh-popup .wh-popup-body a:hover { text-decoration: underline; }

#wh-popup .wh-popup-body kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  box-shadow: inset 0 -1px 0 var(--border);
}

#wh-popup .wh-popup-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm, 4px);
  margin: 8px 0;
  display: block;
}

#wh-popup .wh-popup-body mark {
  background: var(--warning-bg, #fdf2e0);
  color: var(--text);
  padding: 0 3px;
  border-radius: 2px;
  font-weight: 500;
}

#wh-popup .wh-popup-body blockquote.wh-note {
  border-left: 3px solid var(--accent, #005fb8);
  background: var(--accent-bg, #e6f0fa);
  padding: 10px 12px;
  margin: 10px 0;
  border-radius: 0 var(--radius-sm, 4px) var(--radius-sm, 4px) 0;
}

#wh-popup .wh-popup-body blockquote.wh-warn {
  border-left: 3px solid var(--warning, #b8873c);
  background: var(--warning-bg, #fdf2e0);
  color: var(--text);
  padding: 10px 12px;
  margin: 10px 0;
  border-radius: 0 var(--radius-sm, 4px) var(--radius-sm, 4px) 0;
  font-size: 12px;
}

#wh-popup .wh-example {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent, #005fb8);
  padding: 10px 14px;
  border-radius: var(--radius-sm, 4px);
  margin: 12px 0 0;
  font-size: 12px;
}

#wh-popup .wh-example-label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

#wh-popup .wh-popup-footer {
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-page);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

#wh-popup .wh-see-also {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: baseline;
}

#wh-popup .wh-see-label {
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 4px;
}

#wh-popup .wh-see-also button,
#wh-popup .wh-see-also a {
  color: var(--accent, #005fb8);
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font-body);
  padding: 0;
  font-size: 11px;
}

#wh-popup .wh-see-also button:hover,
#wh-popup .wh-see-also a:hover { text-decoration: underline; }

#wh-popup .wh-see-also button:not(:last-child)::after,
#wh-popup .wh-see-also a:not(:last-child)::after {
  content: '·';
  margin-left: 10px;
  color: var(--text-subtle);
}

#wh-popup .wh-full-doc {
  align-self: flex-end;
  color: var(--accent, #005fb8);
  text-decoration: none;
  font-size: 11px;
}

#wh-popup .wh-full-doc:hover { text-decoration: underline; }

/* =========================================================================
   TOAST NOTIFICATIONS (глобальные)
   ========================================================================= */

#toast {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-item {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 4px solid var(--success, #4a7f5c);
  padding: 10px 16px;
  border-radius: var(--radius-sm, 4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  font-size: var(--font-size-sm, 13px);
  max-width: 320px;
  pointer-events: auto;
  animation: toastIn 200ms;
}

.toast-item.error { border-left-color: var(--danger, #c85a5a); }
.toast-item.warn { border-left-color: var(--warning, #b8873c); }

@keyframes toastIn {
  from { transform: translateX(400px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* =========================================================================
   P1 fixes от agent_kg_ui_reviewer 2026-09-26
   ========================================================================= */

/* Fix WARN9: dark theme body background */
[data-theme="dark"] body { background: var(--bg-page); color: var(--text); }

/* Fix FAIL7: tap-targets ≥44px на mobile (Правило №0.2) */
@media (max-width: 900px) {
  .grow-card-actions button,
  .grow-add-btn,
  .btn-primary-inline,
  .btn-next-stage-mobile,
  .btn-fab {
    min-height: 44px;
    min-width: 44px;
  }
  .grow-card-actions button {
    padding: 8px 12px;
    font-size: 18px;
  }
  .grow-add-btn {
    padding: 12px 8px;
  }
}
