:root {
  /* Aliased to tokens.css — shared brand foundation */
  --bg: var(--neutral-50);
  --surface: var(--neutral-50);
  --sidebar-bg: var(--neutral-100);
  --border: var(--neutral-200);
  --border-strong: var(--neutral-300);
  --ink: var(--neutral-900);
  --muted: var(--neutral-600);
  --subtle: var(--neutral-400);
  --accent: var(--brand-orange);
  --accent-strong: var(--brand-orange-dark);
  --accent-soft: rgba(var(--brand-orange-rgb), 0.08);
  --success: var(--status-success);
  --success-bg: var(--status-success-bg);
  --warning: var(--status-warning);
  --warning-bg: var(--status-warning-bg);
  --danger: var(--status-danger);
  --danger-bg: var(--status-danger-bg);
  --info: var(--status-info);
  --info-bg: var(--status-info-bg);
  /* Radii — inherited from tokens.css */
  --shadow-hairline: 0 0 0 1px var(--border);
  --shadow-card: var(--shadow-sm);
  --shadow-overlay: var(--shadow-xl);
  /* Motion — inherited from tokens.css */
  --ease: var(--ease-default);
  --sidebar-w: var(--sidebar-w);
  --sidebar-w-collapsed: var(--sidebar-w-collapsed);
  --topbar-h: var(--topbar-h);
  --row-h: var(--row-h);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #E7E5E4;
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
  text-rendering: optimizeLegibility;
}
body { display: flex; flex-direction: column; min-height: 100vh; }

.font-mono { font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace; font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }

button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: var(--ink); }

button, [role="button"] { cursor: pointer; }

a { color: inherit; text-decoration: none; }

::selection { background: var(--accent-soft); color: var(--accent-strong); }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.has-ring:focus-visible {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

.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 {
  position: absolute;
  left: 8px;
  top: -100px;
  z-index: 999;
  background: var(--ink);
  color: white;
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 13px;
  transition: top var(--motion-fast) var(--ease);
}
.skip-link:focus { top: 8px; }

/* ============================================================
   BROWSER CHROME — обёртка-демо: показывает что прототип
   живёт в браузере и одновременно фрейминг подчёркивает,
   что внутри — полноценный продукт.
   ============================================================ */
.browser-window {
  margin: 24px auto;
  max-width: 1440px;
  height: calc(100vh - 48px);
  min-height: 720px;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 30px 80px -20px rgba(28, 25, 23, 0.25),
    0 0 0 0.5px rgba(28, 25, 23, 0.18);
}

.browser-chrome {
  height: 36px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  pointer-events: none;
}
.browser-chrome-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.browser-traffic-lights {
  display: flex;
  gap: 8px;
  padding-bottom: 10px;
  margin-right: 6px;
}
.browser-light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 0.5px solid rgba(0, 0, 0, 0.18);
}
.browser-light.close { background: #FF5F57; }
.browser-light.min { background: #FEBC2E; }
.browser-light.max { background: #28C840; }

.browser-tab {
  background: #fff;
  padding: 8px 14px 8px 12px;
  border-radius: 10px 10px 0 0;
  font-size: 12px;
  color: #1C1917;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 240px;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.browser-tab .favicon {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--accent);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: white;
  font-size: 9px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}
.browser-new-tab {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #5F6368;
  margin-bottom: 4px;
  cursor: pointer;
}
.browser-new-tab:hover { background: rgba(0, 0, 0, 0.06); }

.browser-navbar {
  background: #fff;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #E5E7EB;
}
.browser-nav-btns {
  display: flex;
  gap: 2px;
  color: #5F6368;
}
.browser-nav-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: #5F6368;
}
.browser-nav-btn:hover { background: rgba(0, 0, 0, 0.06); color: #1C1917; }
.browser-nav-btn:disabled { opacity: 0.35; cursor: default; }

.browser-urlbar {
  flex: 1;
  background: #F1F3F4;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  color: #1C1917;
  display: flex;
  align-items: center;
  gap: 8px;
}
.browser-urlbar svg { color: #5F6368; flex-shrink: 0; }
.browser-urlbar .domain { color: #1C1917; }
.browser-urlbar .path { color: #5F6368; }

.browser-extras {
  display: flex;
  gap: 4px;
}

/* ============================================================
   APP SHELL — то, что находится «внутри» вкладки браузера
   ============================================================ */
.app-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  contain: layout;
}

/* TOP BAR */
.topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 10;
}
.app-viewport[data-sidebar="collapsed"] .topbar {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr auto;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: 100%;
  border-right: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
}
.topbar-brand .mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--ink);
  color: white;
  display: grid;
  place-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.04em;
}
.topbar-brand .brand-text { white-space: nowrap; overflow: hidden; }
.topbar-brand .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.topbar-brand .brand:hover .brand-title { color: var(--accent-strong); }
.topbar-brand .brand-title,
.topbar-brand .brand-sub {
  transition: color var(--motion-fast) var(--ease);
}
.app-viewport[data-sidebar="collapsed"] .topbar-brand { padding: 0 12px; justify-content: center; }
.app-viewport[data-sidebar="collapsed"] .topbar-brand .brand-text { display: none; }

.topbar-search-wrap {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 100%;
}
.topbar-search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 460px;
  padding: 7px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  transition: border-color var(--motion-fast) var(--ease), background var(--motion-fast) var(--ease);
}
.topbar-search:hover { border-color: var(--border-strong); background: var(--surface); }
.topbar-search:focus-within {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.topbar-search input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13px;
  color: var(--ink);
}
.topbar-search input::placeholder { color: var(--subtle); }
.topbar-search kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 14px;
  height: 100%;
}
.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  transition: background var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);
}
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn.has-badge { position: relative; }
.icon-btn .dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  border: 1.5px solid var(--surface);
}
.topbar-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 6px;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  transition: background var(--motion-fast) var(--ease);
}
.topbar-user:hover { background: var(--bg); }
.topbar-user .avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #44403C, #1C1917);
  color: white;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
}
.topbar-user .name { font-size: 13px; font-weight: 500; }
.topbar-user .chev { color: var(--subtle); }

.topbar-left,
.topbar-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; position: relative; }
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  justify-content: center;
  overflow: hidden;
}
.topbar-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: background var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);
  white-space: nowrap;
}
.topbar-nav-link:hover { background: var(--surface); color: var(--ink); }
.topbar-nav-link.is-current,
.topbar-nav-link[aria-current="page"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--ink);
}
.topbar-nav-link .nav-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ============================================================
   APP LAYOUT — sidebar + main column
   ============================================================ */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: calc(100% - var(--topbar-h));
  transition: grid-template-columns var(--motion-base) var(--ease);
}
.app-viewport[data-sidebar="collapsed"] .app-layout {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}

/* SIDEBAR */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-inner {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-inner::-webkit-scrollbar { width: 6px; }
.sidebar-inner::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 14px;
}
.sidebar-group-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--subtle);
  letter-spacing: 0.02em;
  padding: 6px 10px 4px;
}
.app-viewport[data-sidebar="collapsed"] .sidebar-group-label { display: none; }
.app-viewport[data-sidebar="collapsed"] .sidebar-group {
  position: relative;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.app-viewport[data-sidebar="collapsed"] .sidebar-group:first-child {
  border-top: 0;
  padding-top: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  border: 0;
  background: transparent;
  text-align: left;
  width: 100%;
  position: relative;
  transition: background var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);
}
.nav-item .nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--subtle);
  transition: color var(--motion-fast) var(--ease);
}
.nav-item .nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item .nav-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--subtle);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  min-width: 22px;
  text-align: center;
}
.nav-item:hover {
  background: rgba(28, 25, 23, 0.04);
  color: var(--ink);
}
.nav-item:hover .nav-icon { color: var(--ink); }
.nav-item[aria-current="page"],
.nav-item.is-active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-hairline);
}
.nav-item[aria-current="page"] .nav-icon,
.nav-item.is-active .nav-icon { color: var(--accent); }
.nav-item[aria-current="page"] .nav-count,
.nav-item.is-active .nav-count {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: rgba(37, 99, 235, 0.15);
}
.app-viewport[data-sidebar="collapsed"] .nav-item {
  padding: 8px 0;
  justify-content: center;
}
.app-viewport[data-sidebar="collapsed"] .nav-item .nav-label,
.app-viewport[data-sidebar="collapsed"] .nav-item .nav-count {
  display: none;
}

/* Sidebar group label для collapsed — оставляем первую букву как подсказку */
.app-viewport[data-sidebar="collapsed"] .sidebar-group {
  position: relative;
  padding-top: 8px;
  margin-bottom: 6px;
}
.app-viewport[data-sidebar="collapsed"] .sidebar-group:first-child {
  padding-top: 0;
  border-top: 0;
}

/* --- Role-based visibility (data-admin-only) --- */
body[data-user-role="manager"] [data-admin-only],
body[data-user-role="viewer"] [data-admin-only] {
  display: none;
}
/* Если у пользователя вообще нет роли (гость/не staff) — показываем только Обзор */
body:not([data-user-role]) .sidebar-group:not(:first-child) .nav-item,
body:not([data-user-role]) .sidebar-group:not(:first-child) .nav-item ~ * {
  display: none;
}

/* --- Tooltip при collapsed sidebar --- */
.app-viewport[data-sidebar="collapsed"] .nav-item {
  position: relative;
}
.app-viewport[data-sidebar="collapsed"] .nav-item::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--ink);
  color: white;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 9px;
  border-radius: 5px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--motion-fast) var(--ease);
  z-index: 70;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.app-viewport[data-sidebar="collapsed"] .nav-item:hover::after,
.app-viewport[data-sidebar="collapsed"] .nav-item:focus-visible::after {
  opacity: 1;
}

.sidebar-foot {
  padding: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-collapse-btn {
  margin-left: auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  transition: background var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);
}
.sidebar-collapse-btn:hover { background: var(--surface); color: var(--ink); }
.sidebar-collapse-btn .chev-icon { transition: transform var(--motion-base) var(--ease); }
.app-viewport[data-sidebar="collapsed"] .sidebar-foot { justify-content: center; }
.app-viewport[data-sidebar="collapsed"] .sidebar-foot .ws-meta { display: none; }
.app-viewport[data-sidebar="collapsed"] .sidebar-collapse-btn { margin: 0; }
.app-viewport[data-sidebar="collapsed"] .sidebar-collapse-btn .chev-icon { transform: rotate(180deg); }

.ws-meta {
  font-size: 12px;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
}
.ws-meta .ws-name {
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ws-meta .ws-plan {
  color: var(--subtle);
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
}

/* ============================================================
   GLOBAL SVG RESET — иначе inline SVG без width/height рвут layout
   ============================================================ */
svg { display: block; flex-shrink: 0; }
.brand-mark { flex-shrink: 0; }

/* ============================================================
   MAIN COLUMN
   ============================================================ */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.page-head {
  padding: 22px 28px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}
.page-head h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.page-head .crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--subtle);
  margin-bottom: 6px;
}
.page-head .crumbs a { color: var(--muted); }
.page-head .crumbs a:hover { color: var(--ink); }
.page-head .crumbs .sep { color: var(--border-strong); }
.page-head .sub { font-size: 13px; color: var(--muted); margin: 0; }

.page-head-actions { display: flex; gap: 8px; flex-shrink: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  transition: background var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);
}
.btn svg { width: 14px; height: 14px; }
.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}
.btn-secondary:hover { background: var(--bg); border-color: var(--border-strong); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-danger {
  background: var(--surface);
  border-color: var(--border);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-bg); border-color: rgba(185, 28, 28, 0.25); }

/* FILTER BAR */
.filter-bar {
  padding: 0 28px 14px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.chips {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  border: 0;
  background: transparent;
  transition: background var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);
}
.chip:hover { background: var(--bg); color: var(--ink); }
.chip[aria-pressed="true"] {
  background: var(--ink);
  color: white;
}
.chip[aria-pressed="true"] .chip-count {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}
.chip-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  background: var(--bg);
  color: var(--muted);
  padding: 1px 5px;
  border-radius: 3px;
  min-width: 18px;
  text-align: center;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.toolbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 240px;
  color: var(--subtle);
  transition: border-color var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease);
}
.toolbar-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.toolbar-search input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13px;
  color: var(--ink);
}
.toolbar-search input::placeholder { color: var(--subtle); }
.toolbar-search .clear-btn {
  width: 18px;
  height: 18px;
  border: 0;
  background: transparent;
  color: var(--subtle);
  display: none;
  border-radius: 4px;
}
.toolbar-search .clear-btn:hover { background: var(--bg); color: var(--ink); }
.toolbar-search.has-value .clear-btn { display: grid; place-items: center; }

.sort-select {
  height: 32px;
  padding: 0 8px 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink);
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2357534E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 26px;
  transition: border-color var(--motion-fast) var(--ease);
}
.sort-select:hover { border-color: var(--border-strong); }

/* ============================================================
   TABLE — данные тикетов
   ============================================================ */
.table-scroll {
  flex: 1;
  overflow: auto;
  position: relative;
  border-top: 1px solid var(--border);
}

.t {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  color: var(--ink);
}
/* Products page: column widths */
.page[data-page="products"] .t col.col-cb     { width: 36px; }
.page[data-page="products"] .t col.col-prio   { width: 28px; }
.page[data-page="products"] .t col.col-id     { width: 96px; }
.page[data-page="products"] .t col.col-desc   { width: auto; }
.page[data-page="products"] .t col.col-client { width: 180px; }
.page[data-page="products"] .t col.col-qty    { width: 100px; }
.page[data-page="products"] .t col.col-dims   { width: 120px; }
.page[data-page="products"] .t col.col-mgr    { width: 168px; }
.page[data-page="products"] .t col.col-time   { width: 76px; }
.page[data-page="products"] .t col.col-act    { width: 60px; }
.t thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  font-weight: 500;
  font-size: 11px;
  color: var(--muted);
  text-align: left;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.t thead th.num-col,
.t tbody td.num-col { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t thead th.cb-col,
.t tbody td.cb-col {
  width: 36px;
  padding-left: 16px;
  padding-right: 0;
}
.t thead th.actions-col,
.t tbody td.actions-col {
  text-align: right;
  width: 60px;
  padding-right: 16px;
}

.t tbody tr {
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease);
}
.t tbody tr:hover {
  background: var(--bg);
}
.t tbody tr.is-open {
  background: var(--accent-soft);
}
.t tbody tr.is-open td {
  border-bottom-color: rgba(37, 99, 235, 0.18);
}
.t tbody tr.is-selected {
  background: rgba(37, 99, 235, 0.04);
}
.t tbody tr.is-selected.is-open {
  background: var(--accent-soft);
}
.t tbody td {
  padding: 0 14px;
  height: var(--row-h);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

/* Priority dot column — semantic, не декоративная заливка */
.priority-cell {
  width: 16px;
  padding-left: 16px !important;
  padding-right: 0 !important;
}
.priority-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  position: relative;
}
.priority-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid transparent;
}
.priority-dot.urgent { background: var(--danger); }
.priority-dot.urgent::after { border-color: rgba(185, 28, 28, 0.18); }
.priority-dot.high { background: var(--warning); }
.priority-dot.normal { background: var(--subtle); }
.priority-dot.low { background: transparent; border: 1px solid var(--border-strong); }
.priority-dot[data-placement="warehouse"] { background: var(--success); }
.priority-dot[data-placement="warehouse"]::after { border-color: rgba(21, 128, 61, 0.18); }
.priority-dot[data-placement="truck"] { background: var(--info); }
.priority-dot[data-placement="truck"]::after { border-color: rgba(29, 78, 216, 0.18); }
.priority-dot[data-placement="unplaced"] { background: transparent; border: 1px solid var(--border-strong); }

/* Cell types */
.cell-id {
  font-variant-numeric: tabular-nums;
}
.track-code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--ink);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  border: 1px solid var(--border);
}
.track-code.is-new {
  background: var(--accent-soft, #DBEAFE);
  border-color: rgba(37, 99, 235, 0.25);
  color: var(--accent, #2563EB);
}
.cell-subject { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cell-subject .subject-text {
  font-weight: 500;
  font-size: 13.5px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.cell-subject .subject-meta {
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.cell-subject .subject-meta .dot-sep {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: var(--subtle);
  display: inline-block;
  flex-shrink: 0;
}

.cell-customer { display: flex; align-items: center; gap: 8px; }
.cell-customer .av {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}
.cell-customer .av.c1 { background: #B45309; }
.cell-customer .av.c2 { background: #15803D; }
.cell-customer .av.c3 { background: #1E40AF; }
.cell-customer .av.c4 { background: #6B21A8; }
.cell-customer .av.c5 { background: #B91C1C; }
.cell-customer .av.c6 { background: #44403C; }
.av.c1 { background: #B45309; }
.av.c2 { background: #15803D; }
.av.c3 { background: #1E40AF; }
.av.c4 { background: #6B21A8; }
.av.c5 { background: #B91C1C; }
.av.c6 { background: #44403C; }
.cell-customer .cust-name { font-size: 13px; color: var(--ink); }
.cell-customer .cust-org { font-size: 11.5px; color: var(--subtle); }

.cell-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.cell-assignee { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.cell-assignee .mini-av {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--border-strong);
  display: grid;
  place-items: center;
  font-size: 9.5px;
  font-weight: 600;
  color: white;
}
.cell-assignee.unassigned { color: var(--subtle); font-style: italic; }
.cell-assignee.unassigned .mini-av { background: transparent; border: 1px dashed var(--border-strong); color: var(--subtle); }

/* Status badge — icon + label, контраст AA */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.badge svg { width: 11px; height: 11px; flex-shrink: 0; }
.badge.open    { background: var(--info-bg);    color: var(--info); }
.badge.pending { background: var(--warning-bg); color: var(--warning); }
.badge.resolved{ background: var(--success-bg); color: var(--success); }
.badge.closed  { background: var(--bg);         color: var(--muted); border: 1px solid var(--border); }
.badge.warehouse { background: var(--success-bg); color: var(--success); }
.badge.truck     { background: var(--info-bg);    color: var(--info); }
.badge.unplaced  { background: var(--bg);         color: var(--muted); border: 1px solid var(--border); }

/* Row actions — icon-only, появляются на hover */
.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--motion-fast) var(--ease);
}
.t tbody tr:hover .row-actions,
.t tbody tr.is-open .row-actions,
.t tbody tr:focus-within .row-actions { opacity: 1; }

.row-act-btn {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  border: 0;
  background: transparent;
  color: var(--muted);
}
.row-act-btn:hover { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-hairline); }

/* Custom checkbox */
.cb {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color var(--motion-fast) var(--ease), background var(--motion-fast) var(--ease);
  position: relative;
}
.cb:hover { border-color: var(--muted); }
.cb:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.cb:checked::after {
  content: '';
  width: 9px;
  height: 9px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>");
  background-size: contain;
  background-repeat: no-repeat;
}
.cb:indeterminate {
  background: var(--accent);
  border-color: var(--accent);
}
.cb:indeterminate::after {
  content: '';
  width: 8px;
  height: 2px;
  background: white;
  border-radius: 1px;
}

/* Table footer / pagination */
.table-foot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 28px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  color: var(--muted);
}
.pager { display: flex; align-items: center; gap: 4px; }
.pager-btn {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}
.pager-btn:hover { background: var(--bg); color: var(--ink); }
.pager-btn:disabled { opacity: 0.4; cursor: default; }
.pager-current {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 0 8px;
  color: var(--ink);
}

/* ============================================================
   SIDE PANEL — slide-in ticket detail
   ============================================================ */
.scrim {
  position: absolute;
  inset: 0;
  background: rgba(28, 25, 23, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--motion-base) var(--ease);
  z-index: 20;
}
.app-viewport[data-panel="open"] .scrim {
  opacity: 1;
  pointer-events: auto;
}

.side-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 100%;
  background: var(--bg);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px -8px rgba(28, 25, 23, 0.08);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--motion-base) var(--ease);
  z-index: 25;
}
.app-viewport[data-panel="open"] .side-panel {
  transform: translateX(0);
}

.panel-head {
  padding: 16px 20px 0;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.panel-head-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.panel-head-top .panel-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: var(--subtle);
}
.panel-head-top .spacer { flex: 1; }
.panel-icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  transition: background var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);
}
.panel-icon-btn:hover { background: var(--surface); color: var(--ink); }

.panel-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin: 0 0 4px;
  line-height: 1.35;
}
.panel-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.panel-meta .dot-sep {
  width: 2px; height: 2px; border-radius: 50%; background: var(--subtle);
}
.panel-meta .panel-customer {
  color: var(--ink); font-weight: 500;
}

.panel-tabs {
  display: flex;
  gap: 0;
  margin-top: 8px;
}
.panel-tab {
  padding: 8px 0;
  margin-right: 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border: 0;
  background: transparent;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease);
}
.panel-tab:hover { color: var(--ink); }
.panel-tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
.panel-tab .tab-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  background: var(--surface);
  color: var(--muted);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
}
.panel-tab[aria-selected="true"] .tab-count {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.panel-body::-webkit-scrollbar { width: 6px; }
.panel-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.panel-tab-panel { display: none; }
.panel-tab-panel[aria-hidden="false"] { display: block; }

.thread {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.msg {
  display: flex;
  gap: 10px;
}
.msg .av {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  font-size: 11px; font-weight: 600;
  flex-shrink: 0;
}
.msg .msg-bub {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.msg .msg-bub .msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--subtle);
  margin-bottom: 4px;
}
.msg .msg-bub .msg-meta .msg-author {
  color: var(--ink);
  font-weight: 500;
}
.msg .msg-bub .msg-text {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
}
.status-current {
  display: flex;
  gap: 12px;
  padding: 14px;
  background: linear-gradient(135deg, var(--mint-50) 0%, var(--mint-100) 100%);
  border: 1px solid var(--mint-200);
  border-radius: 10px;
  margin-bottom: 8px;
}
.status-current .av {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  font-size: 12px; font-weight: 600;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--mint-100);
}
.status-current .sc-body { flex: 1; min-width: 0; }
.status-current .sc-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ink-2);
  margin-bottom: 4px;
}
.status-current .sc-author { font-weight: 600; color: var(--ink); }
.status-current .sc-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mint-700);
  margin-bottom: 2px;
}
.status-current .sc-text {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
}
.status-prev-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--subtle);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  border-radius: 6px;
  font-family: inherit;
}
.status-prev-toggle:hover { background: var(--hover); color: var(--ink); }
.status-prev-toggle .sp-chev { transition: transform 0.18s; }
.status-prev-toggle[aria-expanded="true"] .sp-chev { transform: rotate(90deg); }
.status-prev-list {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 8px 0 4px 14px;
  border-left: 2px solid var(--border);
  margin-left: 16px;
}
.status-prev-list.is-open { display: flex; }
.status-prev-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-2);
  padding-left: 4px;
  position: relative;
}
.status-prev-item::before {
  content: '';
  position: absolute;
  left: -10px; top: 9px;
  width: 6px; height: 6px;
  background: var(--border);
  border-radius: 50%;
}
.status-prev-item .sp-time { font-size: 11px; color: var(--subtle); }
.empty-mini {
  padding: 18px;
  text-align: center;
  font-size: 12.5px;
  color: var(--subtle);
  background: var(--hover);
  border-radius: 8px;
  border: 1px dashed var(--border);
}
.msg.customer .msg-bub {
  background: var(--bg);
}

.dl {
  display: grid;
  grid-template-columns: 110px 1fr;
  row-gap: 10px;
  column-gap: 12px;
  font-size: 13px;
}
.dl dt {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 500;
  align-self: center;
}
.dl dd {
  margin: 0;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.dl dd select,
.dl dd input[type="text"] {
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
}
.dl dd select:focus,
.dl dd input[type="text"]:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.field-group { margin-top: 18px; }
.field-group:first-child { margin-top: 0; }
.field-group h4 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--subtle);
}
.reply-box {
  width: 100%;
  min-height: 96px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--surface);
  resize: vertical;
  transition: border-color var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease);
}
.reply-box:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.reply-box.is-dirty {
  border-color: var(--warning);
  background: var(--warning-bg);
}

.sticky-save {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  transform: translateY(100%);
  transition: transform var(--motion-base) var(--ease), background var(--motion-fast) var(--ease);
}
.app-viewport[data-panel="open"] .sticky-save.is-dirty {
  transform: translateY(0);
  background: var(--warning-bg);
}
.sticky-save .ss-msg {
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.sticky-save.is-dirty .ss-msg { color: #78350F; }
.sticky-save .ss-spacer { flex: 1; }

/* ============================================================
   BULK ACTION BAR — appears when rows selected
   ============================================================ */
.bulk-bar {
  position: absolute;
  left: 28px;
  right: 28px;
  bottom: 60px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--ink);
  color: white;
  border-radius: 8px;
  box-shadow: 0 8px 24px -6px rgba(28, 25, 23, 0.4);
  transform: translateY(140%);
  opacity: 0;
  transition: transform var(--motion-base) var(--ease), opacity var(--motion-base) var(--ease);
  z-index: 15;
  pointer-events: none;
}
.app-viewport[data-bulk="active"] .bulk-bar {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.bulk-bar .bulk-count {
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 10px;
  border-right: 1px solid rgba(255, 255, 255, 0.18);
}
.bulk-bar .bulk-count strong {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}
.bulk-bar .bulk-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}
.bulk-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border-radius: 5px;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  font-size: 12.5px;
  font-weight: 500;
}
.bulk-btn:hover { background: rgba(255, 255, 255, 0.1); color: white; }
.bulk-btn svg { width: 13px; height: 13px; }
.bulk-btn.is-danger { color: #FCA5A5; }
.bulk-btn.is-danger:hover { background: rgba(185, 28, 28, 0.3); color: white; }
.bulk-bar .bulk-clear {
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  padding-left: 10px;
}
.bulk-clear-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border-radius: 5px;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  padding-left: 12px;
}
.bulk-clear-btn:hover { background: rgba(255, 255, 255, 0.1); color: white; }
.bulk-clear-btn svg { width: 12px; height: 12px; }

/* Inline bulk-bar (not floating) — for cards with their own toolbar */
.bulk-bar.is-inline {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  transform: translateY(-8px);
  opacity: 0;
  max-height: 0;
  padding: 0 14px;
  overflow: hidden;
  pointer-events: none;
  transition: transform 200ms ease, opacity 200ms ease, max-height 200ms ease, padding 200ms ease;
  margin: 0;
  border-radius: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--ink);
  color: white;
}
.app-viewport[data-bulk="active"] .bulk-bar.is-inline {
  transform: translateY(0);
  opacity: 1;
  max-height: 60px;
  padding: 10px 14px;
  pointer-events: auto;
}

/* ============================================================
   EMPTY / TOAST
   ============================================================ */
.toast {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translate(-50%, 140%);
  background: var(--ink);
  color: white;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 24px -6px rgba(28, 25, 23, 0.4);
  opacity: 0;
  transition: transform var(--motion-base) var(--ease), opacity var(--motion-base) var(--ease);
  z-index: 30;
  pointer-events: none;
}
.toast.is-on {
  transform: translate(-50%, 0);
  opacity: 1;
}
.toast .toast-icon {
  width: 16px; height: 16px;
  color: var(--success);
}

/* ============================================================
   PAGE ROUTING — show only one .page at a time
   ============================================================ */
.page[hidden] { display: none !important; }
.page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}
.page::-webkit-scrollbar { width: 8px; }
.page::-webkit-scrollbar-track { background: transparent; }
.page::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
  border: 2px solid var(--bg);
}
.page::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ============================================================
   KPI DASHBOARD GRID
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 0 28px 20px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}
.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--subtle);
  letter-spacing: 0.005em;
}
.kpi-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi-value .kpi-of {
  font-size: 16px;
  font-weight: 500;
  color: var(--subtle);
  letter-spacing: 0;
}
.kpi-delta {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }
.kpi-spark {
  margin-top: 4px;
  height: 32px;
  display: flex;
  align-items: flex-end;
}
.kpi-spark svg { width: 100%; height: 100%; }

.kpi-secondary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 0 28px 28px;
}

/* ============================================================
   TRUCKS PAGE — Fleet Operations Control Panel
   ============================================================ */
.fleet-hero {
  margin: 0 28px 20px;
  padding: 18px 20px;
  background:
    radial-gradient(ellipse 80% 60% at 0% 0%, rgba(37, 99, 235, 0.04), transparent 60%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 24px;
  position: relative;
  overflow: hidden;
}
.fleet-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(28, 25, 23, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(28, 25, 23, 0.025) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -1px -1px;
  pointer-events: none;
  mask-image: linear-gradient(135deg, transparent 50%, black 100%);
  -webkit-mask-image: linear-gradient(135deg, transparent 50%, black 100%);
  opacity: 0.5;
}
.fleet-hero-content { position: relative; z-index: 1; flex: 1; }
.fleet-hero-eyebrow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
}
.fleet-hero-eyebrow::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.15);
  animation: fleetPulse 2.4s ease-in-out infinite;
}
@keyframes fleetPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.fleet-hero-title {
  margin: 4px 0 2px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.fleet-hero-title strong { font-weight: 700; color: var(--ink); }
.fleet-hero-title .muted-count {
  font-weight: 500;
  color: var(--subtle);
  font-size: 18px;
  margin-left: 4px;
}
.fleet-hero-sub {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}
.fleet-bar {
  position: relative;
  z-index: 1;
  flex: 1.4;
  min-width: 0;
}
.fleet-bar-track {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--border);
  gap: 2px;
}
.fleet-bar-seg {
  height: 100%;
  transition: filter 200ms ease;
  position: relative;
}
.fleet-bar-seg:hover { filter: brightness(1.08); }
.fleet-bar-seg[data-status="В пути"] { background: linear-gradient(90deg, var(--info), #60A5FA); }
.fleet-bar-seg[data-status="Прибыл на разгрузку"] { background: linear-gradient(90deg, var(--warning), #FBBF24); }
.fleet-bar-seg[data-status="Загружен"] { background: linear-gradient(90deg, var(--ink), #44403C); }
.fleet-bar-seg[data-status="На складе"], .fleet-bar-seg[data-status="Свободен"], .fleet-bar-seg[data-status="Разгружен"] {
  background: linear-gradient(90deg, var(--success), #4ADE80);
}
.fleet-bar-seg[data-status="empty"] { background: var(--border); }
.fleet-bar-legend {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--muted);
  flex-wrap: wrap;
}
.fleet-bar-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.fleet-bar-legend-dot {
  width: 8px; height: 8px; border-radius: 2px;
  background: var(--border);
  flex-shrink: 0;
}
.fleet-bar-legend-dot[data-status="В пути"] { background: var(--info); }
.fleet-bar-legend-dot[data-status="Прибыл на разгрузку"] { background: var(--warning); }
.fleet-bar-legend-dot[data-status="Загружен"] { background: var(--ink); }
.fleet-bar-legend-dot[data-status="Свободен"] { background: var(--success); }
.fleet-bar-legend-item strong {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-right: 2px;
}

/* Route progress (in table + active routes card) */
.route-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 140px;
}
.route-progress-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--border);
  position: relative;
  overflow: hidden;
}
.route-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #60A5FA);
  border-radius: 999px;
  transition: width 200ms ease;
}
.route-progress-fill.is-low { background: linear-gradient(90deg, var(--success), #4ADE80); }
.route-progress-fill.is-high { background: linear-gradient(90deg, var(--warning), #FBBF24); }
.route-progress-fill.is-full { background: linear-gradient(90deg, var(--danger), #F87171); }
.route-progress-pct {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
  text-align: right;
}

/* Active routes card (right of table) */
.trucks-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  padding: 0 28px 28px;
  align-items: start;
  min-height: 0;
}
.trucks-layout .table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.trucks-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
}
.active-routes {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.active-routes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.active-routes-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}
.active-route-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.active-route-item:first-of-type { border-top: 0; padding-top: 0; }
.active-route-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
}
.active-route-truck {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(37, 99, 235, 0.15);
}
.active-route-arrow {
  color: var(--subtle);
  font-size: 12px;
}
.active-route-dest {
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.active-route-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--subtle);
}
.fleet-composition {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.fleet-comp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
}
.fleet-comp-row + .fleet-comp-row { padding-top: 8px; border-top: 1px solid var(--border); }
.fleet-comp-label { color: var(--muted); }
.fleet-comp-value { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.fleet-comp-bar {
  height: 4px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--border);
}
.fleet-comp-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #60A5FA);
  transition: width 200ms ease;
}

/* Tighten the filter-bar inside trucks */
.page[data-page="trucks"] .filter-bar {
  margin: 0 28px 14px;
}
.page[data-page="trucks"] .filter-bar .toolbar { margin-left: auto; }

@media (max-width: 1100px) {
  .trucks-layout { grid-template-columns: 1fr; }
  .trucks-side { position: static; flex-direction: row; flex-wrap: wrap; }
  .trucks-side > * { flex: 1 1 280px; }
}
@media (max-width: 767px) {
  .fleet-hero { flex-direction: column; align-items: stretch; gap: 16px; margin: 0 16px 16px; padding: 16px; }
  .fleet-hero-title { font-size: 22px; }
  .trucks-layout { padding: 0 16px 16px; }
  .page[data-page="trucks"] .filter-bar { margin: 0 16px 12px; }
}

/* ============================================================
   CARD (generic container)
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card-head h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.card-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid rgba(37, 99, 235, 0.15);
  padding: 1px 7px;
  border-radius: 4px;
  min-width: 22px;
  text-align: center;
}

/* ============================================================
   ACTION LIST / ACTIVITY LIST
   ============================================================ */
.action-list,
.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.action-list li,
.activity-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.4;
}
.action-list li a {
  color: var(--accent);
  font-weight: 500;
  margin-left: auto;
  text-decoration: none;
  flex-shrink: 0;
}
.action-list li a:hover { color: var(--accent-strong); }
.action-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--subtle);
  flex-shrink: 0;
}
.action-dot.info { background: var(--info); }
.action-dot.success { background: var(--success); }
.action-dot.warning { background: var(--warning); }
.action-dot.danger { background: var(--danger); }
.act-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--subtle);
  min-width: 44px;
  flex-shrink: 0;
  text-align: right;
}
.act-time strong {
  color: var(--muted);
  font-weight: 600;
}

/* ============================================================
   WAREHOUSE GRID
   ============================================================ */
.wh-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 0 28px 28px;
}
.wh-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.wh-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.wh-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.wh-loc {
  font-size: 11.5px;
  color: var(--subtle);
  margin-top: 2px;
}
.wh-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
  flex-shrink: 0;
}
.wh-tag.high { background: var(--danger-bg); color: var(--danger); }
.wh-tag.mid { background: var(--warning-bg); color: var(--warning); }
.wh-tag.low { background: var(--success-bg); color: var(--success); }
.wh-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.wh-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width var(--motion-slow) var(--ease);
}
.wh-bar-fill.high { background: var(--danger); }
.wh-bar-fill.mid { background: var(--warning); }
.wh-bar-fill.low { background: var(--success); }
.wh-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.wh-stats span strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}

/* ============================================================
   WIZARD STEPPER
   ============================================================ */
.wizard {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0 28px 18px;
}
.wizard-step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 2px solid var(--border);
  color: var(--subtle);
  font-size: 13px;
  transition: color var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease);
}
.wizard-step.is-done { border-top-color: var(--accent); }
.wizard-step.is-done .ws-num {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.wizard-step.is-current { border-top-color: var(--accent-strong); color: var(--ink); }
.wizard-step.is-current .ws-num {
  background: var(--accent-strong);
  color: white;
  border-color: var(--accent-strong);
}
.ws-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--subtle);
  flex-shrink: 0;
}
.ws-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}
.ws-text strong {
  font-size: 12.5px;
  font-weight: 600;
  color: inherit;
}
.ws-text span {
  font-size: 11.5px;
  color: var(--subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wizard-step.is-current .ws-text span { color: var(--muted); }

/* ============================================================
   FORM GRID
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--muted);
}
.field-wide { grid-column: 1 / -1; }
.field > span { font-weight: 500; }
.field input,
.field select,
.field textarea {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  transition: border-color var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease);
}
.field textarea {
  height: auto;
  padding: 8px 10px;
  min-height: 80px;
  line-height: 1.5;
  resize: vertical;
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  font-size: 12.5px;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   TRUCK PICK LIST
   ============================================================ */
.truck-pick {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.truck-pick li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 13px;
  cursor: pointer;
  transition: border-color var(--motion-fast) var(--ease), background var(--motion-fast) var(--ease);
}
.truck-pick li:hover { border-color: var(--border-strong); background: var(--surface); }
.truck-pick li.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}
.mono { font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace; font-size: 12.5px; }

/* ============================================================
   DROPZONE
   ============================================================ */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 36px 24px;
  text-align: center;
  background: var(--bg);
  transition: border-color var(--motion-fast) var(--ease), background var(--motion-fast) var(--ease);
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-icon {
  width: 36px;
  height: 36px;
  margin: 0 auto 10px;
  color: var(--subtle);
}
.dropzone-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}
.dropzone-hint {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ============================================================
   UNLOAD CARDS
   ============================================================ */
.unload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 0 28px 28px;
}
.unload-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.unload-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.unload-route {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.unload-goods {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.unload-goods li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--muted);
}
.unload-goods li strong { color: var(--ink); font-weight: 500; }

/* ============================================================
   PRICING DL
   ============================================================ */
.dl-pricing {
  grid-template-columns: 1fr auto;
}
.dl-pricing dt { color: var(--muted); font-size: 12.5px; }
.dl-pricing dd { font-size: 13px; }
.dl-pricing .total {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 6px;
}
.dl-pricing dt.total { font-weight: 600; font-size: 14px; color: var(--ink); }

/* ============================================================
   BTN-SM
   ============================================================ */
.btn-sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn-sm svg { width: 12px; height: 12px; }

/* ============================================================
   GENERIC UTILS
   ============================================================ */
.muted { color: var(--muted); }

/* ============================================================
   UX ADDITIONS v2 — SELF-TEACHING INTERFACE
   ============================================================ */

/* --- Bot health chip in topbar --- */
.bot-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px 0 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
  position: relative;
}
.bot-chip:hover { border-color: var(--border-strong); background: var(--bg); }
.bot-chip .bot-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #10B981;
  box-shadow: 0 0 0 0 rgba(16,185,129,0.6);
  flex-shrink: 0;
}
.bot-chip .bot-dot.is-online { animation: botPulse 2.4s ease-in-out infinite; }
.bot-chip .bot-dot.is-offline { background: #EF4444; }
.bot-chip .bot-dot.is-warn { background: #F59E0B; }
@keyframes botPulse {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,0.6); }
  70%  { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}
.bot-chip .bot-label { color: var(--muted); }
.bot-chip .bot-count {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-weight: 600;
  padding: 1px 6px;
  background: var(--bg);
  border-radius: 4px;
  font-size: 11.5px;
}

/* Bot popover */
.bot-popover {
  position: fixed;
  top: 56px;
  right: 24px;
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.04);
  padding: 16px;
  z-index: 50;
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.bot-popover.is-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.bot-popover-head {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.bot-popover-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: #2AABEE;
  color: white;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.bot-popover-icon svg { width: 18px; height: 18px; }
.bot-popover-title { font-size: 14px; font-weight: 600; color: var(--ink); margin: 0; }
.bot-popover-sub { font-size: 12px; color: var(--muted); margin: 1px 0 0; }
.bot-popover-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.bot-popover-stat {
  text-align: center;
  padding: 10px 6px;
  background: var(--bg);
  border-radius: 8px;
}
.bot-popover-stat .val { font-size: 17px; font-weight: 600; color: var(--ink); line-height: 1.1; }
.bot-popover-stat .lbl { font-size: 11px; color: var(--muted); margin-top: 3px; }
.bot-popover-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 0;
  font-size: 12.5px;
}
.bot-popover-row + .bot-popover-row { border-top: 1px solid var(--border); }
.bot-popover-row .k { color: var(--muted); }
.bot-popover-row .v { color: var(--ink); font-weight: 500; }
.bot-popover-row .v.is-ok { color: #059669; }
.bot-popover-actions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px;
}
.bot-popover-actions .btn { flex: 1; }

/* --- Modal dialog (new product / new client) --- */
.modal-scrim {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.32);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity 160ms ease;
  padding: 20px;
}
.modal-scrim.is-open { opacity: 1; pointer-events: auto; }
.modal-scrim .modal {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.18), 0 4px 12px rgba(0,0,0,0.06);
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow: hidden;
  display: flex; flex-direction: column;
  transform: translateY(8px) scale(0.98);
  transition: transform 160ms ease;
}
.modal-scrim.is-open .modal { transform: translateY(0) scale(1); pointer-events: auto; }
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title { margin: 0; font-size: 16px; font-weight: 600; color: var(--ink); flex: 1; }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-body .form-row { margin-bottom: 14px; }
.modal-body label.field-label {
  display: block;
  font-size: 12px; font-weight: 500;
  color: var(--muted);
  margin-bottom: 5px;
}
.modal-body input[type="text"],
.modal-body input[type="tel"],
.modal-body input[type="number"],
.modal-body select,
.modal-body textarea {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus {
  outline: none;
  border-color: var(--accent, #2563EB);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.modal-body .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-body .code-preview {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #ECFDF5 0%, #D1FAE5 100%);
  border: 1px solid #A7F3D0;
  border-radius: 8px;
  margin-bottom: 14px;
}
.modal-body .code-preview .code-label {
  font-size: 11.5px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.04em;
}
.modal-body .code-preview .code-value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 17px; font-weight: 600;
  color: #059669;
  font-variant-numeric: tabular-nums;
}
.modal-body .code-preview svg { color: #059669; }
.modal-body .form-help {
  font-size: 11.5px; color: var(--muted);
  margin-top: 4px;
}
.modal-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* --- Telegram Users page --- */
.tg-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 0 28px 16px;
}
.tg-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.tg-stat-card .tg-stat-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.tg-stat-card .tg-stat-value { font-size: 22px; font-weight: 600; color: var(--ink); line-height: 1.1; }
.tg-stat-card .tg-stat-meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.tg-stat-card .tg-stat-value.is-up { color: #059669; }
.tg-stat-card .tg-stat-value.is-down { color: #DC2626; }

.tg-filters {
  display: flex; gap: 8px; align-items: center;
  margin: 0 28px 14px;
}
.tg-filters .chip {
  padding: 5px 12px;
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
}
.tg-filters .chip.is-active { background: var(--accent); color: white; border-color: var(--accent); }
.tg-filters .search-input {
  flex: 1; max-width: 280px;
  padding: 5px 10px;
  font-size: 12.5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  color: var(--ink);
}

.tg-row { cursor: pointer; }
.tg-row:hover { background: var(--bg); }
.tg-row td { padding: 10px 12px; }

.tg-lang {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--muted);
  text-transform: uppercase;
}
.tg-lang.is-ru { color: #1E40AF; }
.tg-lang.is-uz { color: #047857; }

.tg-online {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--muted);
}
.tg-online::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #9CA3AF;
}
.tg-online.is-recent::before { background: #10B981; }
.tg-online.is-week::before   { background: #F59E0B; }
.tg-online.is-inactive::before { background: #DC2626; }

/* --- Bot health widget on dashboard --- */
.bot-widget {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
  margin: 0 28px 16px;
  background: linear-gradient(135deg, #ECFDF5 0%, #D1FAE5 100%);
  border: 1px solid #A7F3D0;
  border-radius: 10px;
}
.bot-widget-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: #2AABEE;
  color: white;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.bot-widget-icon svg { width: 22px; height: 22px; }
.bot-widget-body { min-width: 0; }
.bot-widget-title { font-size: 14px; font-weight: 600; color: var(--ink); margin: 0; }
.bot-widget-sub { font-size: 12.5px; color: var(--muted); margin: 2px 0 0; }
.bot-widget-stats {
  display: flex; gap: 18px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}
.bot-widget-stats b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
.bot-widget-cta { display: flex; gap: 6px; }
@media (prefers-reduced-motion: reduce) {
  .bot-chip .bot-dot.is-online { animation: none; }
}

/* --- Greeting line (dashboard) --- */
.greeting {
  padding: 0 28px 4px;
  font-size: 13px;
  color: var(--muted);
}
.greeting strong { color: var(--ink); font-weight: 600; }

/* --- Action queue (replaces "Ожидают действий") --- */
.action-queue {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.queue-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 150ms ease, transform 150ms ease;
}
.queue-item:hover {
  border-color: var(--border-strong);
  transform: translateX(2px);
}
.queue-priority {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
}
.queue-priority.urgent { background: #FEE2E2; color: #B91C1C; }
.queue-priority.warning { background: #FEF3C7; color: #B45309; }
.queue-priority.info { background: #DBEAFE; color: #1E40AF; }
.queue-priority svg { width: 16px; height: 16px; }
.queue-body { flex: 1; min-width: 0; }
.queue-title { font-size: 14px; font-weight: 500; color: var(--ink); }
.queue-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.queue-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--ink);
  color: white;
  border: 0;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 150ms ease;
}
.queue-cta:hover { background: #0C0A09; }
.queue-cta svg { width: 12px; height: 12px; }

/* --- Undo toast --- */
.toast {
  position: absolute;
}
.toast.is-undo {
  padding: 12px 14px;
  gap: 12px;
  overflow: hidden;
}
.toast .toast-undo-progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: var(--accent);
  transform-origin: left;
  animation: toastUndoShrink 5000ms linear forwards;
}
@keyframes toastUndoShrink {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}
.toast .toast-undo-btn {
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.24);
  color: white;
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 150ms ease;
}
.toast .toast-undo-btn:hover { background: rgba(255,255,255,0.24); }

/* --- Floating help button --- */
.help-fab {
  position: absolute;
  right: 24px;
  bottom: 130px;
  z-index: 20;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  transition: color 200ms ease, border-color 200ms ease, transform 200ms ease, box-shadow 200ms ease;
  font-family: inherit;
}
.help-fab:hover {
  color: var(--ink);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}
.help-fab svg { width: 20px; height: 20px; }
.help-fab.is-pulsing { animation: helpPulse 2.4s ease-in-out infinite; }
@keyframes helpPulse {
  0%, 100% { box-shadow: 0 4px 12px rgba(0,0,0,0.06), 0 0 0 0 rgba(37, 99, 235, 0.4); }
  50% { box-shadow: 0 4px 12px rgba(0,0,0,0.06), 0 0 0 10px rgba(37, 99, 235, 0); }
}

/* --- Help drawer --- */
.help-drawer {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 380px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px -8px rgba(0,0,0,0.08);
  transform: translateX(100%);
  transition: transform 350ms cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 25;
  display: flex;
  flex-direction: column;
}
.help-drawer.is-open { transform: translateX(0); }
.help-drawer-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.help-drawer-title { font-size: 14px; font-weight: 600; color: var(--ink); margin: 0; }
.help-drawer-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.help-drawer-close {
  border: 0; background: transparent;
  color: var(--muted);
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-family: inherit;
}
.help-drawer-close:hover { background: var(--bg); color: var(--ink); }
.help-drawer-close svg { width: 14px; height: 14px; }
.help-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.help-faq-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--surface);
  overflow: hidden;
}
.help-faq-q {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-family: inherit;
}
.help-faq-q:hover { background: var(--bg); }
.help-faq-q svg { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; transition: transform 200ms ease; }
.help-faq-item[open] .help-faq-q svg { transform: rotate(180deg); }
.help-faq-a {
  display: none;
  padding: 0 14px 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}
.help-faq-item[open] .help-faq-a { display: block; }
.help-faq-a kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ink);
}

/* --- Status badge tooltip --- */
.badge-help { position: relative; cursor: help; }
.help-tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--ink);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  white-space: normal;
  width: max-content;
  max-width: 260px;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.help-tip::after {
  content: '';
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--ink);
}
.badge-help:hover .help-tip,
.badge-help:focus-visible .help-tip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Empty bulk-bar hint (when 0 selected) --- */
/* --- Empty state component --- */
.empty-state-card {
  text-align: center;
  padding: 40px 24px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  margin: 0 28px 14px;
}
.empty-state-icon {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  background: var(--bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.empty-state-icon svg { width: 26px; height: 26px; }
.empty-state-title { font-size: 15px; font-weight: 600; color: var(--ink); margin: 0 0 6px; }
.empty-state-desc { font-size: 13px; color: var(--muted); max-width: 440px; margin: 0 auto 16px; line-height: 1.55; }
.empty-state-actions { display: inline-flex; gap: 8px; }
.empty-state-tip {
  margin-top: 16px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.empty-state-tip svg { width: 13px; height: 13px; color: var(--info); }

/* --- Onboarding banner --- */
.onboard-banner {
  margin: 0 28px 14px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
  border: 1px solid #BFDBFE;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 14px;
  animation: onboardSlide 400ms cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes onboardSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.onboard-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.onboard-icon svg { width: 18px; height: 18px; }
.onboard-body { flex: 1; min-width: 0; }
.onboard-title { font-size: 13.5px; font-weight: 600; color: var(--ink); margin: 0 0 2px; }
.onboard-desc { font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.5; }
.onboard-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.onboard-btn-primary {
  background: var(--accent);
  color: white;
  border: 0;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 150ms ease;
}
.onboard-btn-primary:hover { background: var(--accent-strong); }
.onboard-btn-skip {
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  font-family: inherit;
}
.onboard-btn-skip:hover { background: rgba(0,0,0,0.04); color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  .onboard-banner { animation: none; }
  .toast .toast-undo-progress { animation: none; transition: width 100ms linear; }
  .help-fab.is-pulsing { animation: none; }
  .help-tip { transition: none; }
}

/* Sidebar scrim: скрыт на десктопе, показывается на мобилке */
.sidebar-scrim { display: none; }

/* ============================================================
   RESPONSIVE — tablet (≤1023px) и mobile (≤767px)
   ============================================================ */

/* ---- Tablet ---- */
@media (max-width: 1023px) {
  :root { --sidebar-w: 220px; }

  /* Topbar: прячем горизонтальную навигацию (sidebar покрывает) */
  .topbar-nav { display: none; }
  .topbar { padding: 0 12px; gap: 10px; }
  .topbar-right { gap: 6px; }
  .topbar-user .name { display: none; }
  .topbar-user .chev { display: none; }
  .bot-chip .bot-label { display: none; }

  /* Page head: компактнее */
  .page-head { padding: 18px 20px 14px; }
  .page-head h1 { font-size: 20px; }
  .filter-bar { padding: 0 20px 12px; }

  /* KPI: 2 колонки */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    padding: 0 20px 16px;
    gap: 12px;
  }
  .kpi-value { font-size: 24px; }

  /* Warehouse grid: 1 колонка */
  .wh-grid { grid-template-columns: 1fr; padding: 0 20px 20px; }

  /* Tables: оставляем горизонтальный скролл */
  .table-scroll { overflow-x: auto; }
  .t { min-width: 720px; }

  /* Side panel: чуть ýже */
  .side-panel { width: 380px; }

  /* Help drawer: чуть ýже */
  .help-drawer { width: 320px; }

  /* Bot popover: ширина по вьюпорту */
  .bot-popover { right: 12px; left: 12px; width: auto; max-width: 360px; margin-left: auto; }

  /* Modal: почти на всю ширину */
  .modal-scrim .modal { max-width: calc(100vw - 32px); }

  /* Onboard banner: компактнее */
  .onboard-banner { margin: 0 12px; padding: 10px 14px; }
  .onboard-banner h3 { font-size: 13px; }
  .onboard-banner p { font-size: 12px; }
}

/* ---- Mobile ---- */
@media (max-width: 767px) {
  :root {
    --sidebar-w: 280px;
    --topbar-h: 48px;
  }
  html, body { font-size: 13.5px; }

  /* Topbar: компактный, без подписей */
  .topbar { padding: 0 10px; gap: 6px; }
  .topbar-left { gap: 6px; }
  .brand-title, .brand-sub { display: none; }
  .brand { gap: 0; }
  .topbar-right { gap: 4px; }
  .topbar-divider { display: none; }
  .topbar-user { padding: 0; }
  .topbar-user .av { width: 28px; height: 28px; font-size: 11px; }
  .icon-btn { width: 32px; height: 32px; }
  .bot-chip { padding: 0 8px; height: 32px; }

  /* Layout: sidebar становится off-canvas overlay */
  .app-layout {
    display: block;
    height: calc(100% - var(--topbar-h));
  }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    z-index: 60;
    transform: translateX(-100%);
    transition: transform var(--motion-base) var(--ease);
    box-shadow: 8px 0 24px -8px rgba(28, 25, 23, 0.18);
  }
  .app-viewport[data-sidebar="expanded"] .sidebar {
    transform: translateX(0);
  }
  /* Скrim за sidebar */
  .sidebar-scrim {
    position: fixed;
    top: var(--topbar-h);
    left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.32);
    z-index: 55;
    opacity: 0;
    pointer-events: none;
    display: none;
    transition: opacity var(--motion-base) var(--ease);
  }
  .app-viewport[data-sidebar="expanded"] .sidebar-scrim {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  /* Sidebar: упрощённый контент */
  .sidebar-inner { padding: 12px 8px; }
  .sidebar-group { margin-bottom: 10px; }
  .sidebar-group-label { padding: 6px 8px 4px; font-size: 10.5px; }
  .nav-item { padding: 10px 10px; font-size: 14px; }
  .nav-item .nav-icon { width: 18px; height: 18px; }
  .sidebar-foot { padding: 10px 12px; }
  .ws-meta .ws-name { font-size: 13px; }
  .ws-meta .ws-plan { font-size: 10.5px; }

  /* Page head: вертикальный стек */
  .page-head {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 16px 10px;
    gap: 10px;
  }
  .page-head h1 { font-size: 18px; }
  .page-head .sub { font-size: 12px; }
  .page-head-actions {
    flex-wrap: wrap;
    gap: 6px;
  }
  .page-head-actions .btn { flex: 1; justify-content: center; min-width: 0; }
  .page-head-actions .btn .btn-label { display: inline; }

  /* Filter bar: всё в колонку */
  .filter-bar { padding: 0 16px 10px; gap: 8px; }
  .chips { overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
  .chips::-webkit-scrollbar { display: none; }
  .toolbar { width: 100%; margin-left: 0; }
  .toolbar-search { width: 100%; flex: 1; }

  /* KPI: 1 колонка */
  .kpi-grid {
    grid-template-columns: 1fr;
    padding: 0 16px 14px;
    gap: 10px;
  }
  .kpi-value { font-size: 22px; }

  /* Warehouse card: компактнее */
  .wh-grid { padding: 0 16px 16px; gap: 10px; }
  .wh-card { padding: 14px; }

  /* Tables: на всю ширину с горизонтальным скроллом */
  .table-scroll {
    margin: 0 -16px;
    border-top: 1px solid var(--border);
  }
  .t { min-width: 640px; font-size: 12.5px; }
  .t thead th { padding: 10px 8px; }
  .t tbody td { padding: 10px 8px; }

  /* Side panel: full-screen */
  .side-panel { width: 100%; }
  .panel-head { padding: 14px 16px 0; }
  .panel-body { padding: 14px 16px; }

  /* Help drawer: full-screen */
  .help-drawer { width: 100%; }

  /* Modal: full-screen */
  .modal-scrim { padding: 0; }
  .modal-scrim .modal {
    max-width: 100%;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }
  .modal-panel .modal-head { padding: 14px 16px; }
  .modal-panel .modal-body { padding: 16px; }
  .modal-panel .modal-foot { padding: 12px 16px; }

  /* Bot popover: full width, под topbar */
  .bot-popover {
    top: calc(var(--topbar-h) + 4px);
    right: 8px; left: 8px;
    width: auto;
    max-width: none;
  }

  /* Toast: ýже, ниже */
  .toast { right: 12px; left: 12px; bottom: 12px; }

  /* Onboard banner: упрощённый */
  .onboard-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin: 0 12px;
    padding: 12px;
  }
  .onboard-actions { width: 100%; justify-content: flex-end; }

  /* Help fab: меньше, не перекрывает контент */
  .help-fab { width: 40px; height: 40px; bottom: 16px; right: 16px; }
  .help-fab svg { width: 18px; height: 18px; }

  /* Sticky save: компактнее */
  .sticky-save { padding: 10px 12px; }
  .ss-msg { font-size: 12px; }
  .sticky-save .btn { padding: 0 10px; height: 30px; }
}

/* Django ModelForm widgets (BootstrapFormMixin) inside panel pages */
.page .form-control,
.page select.form-control,
.page textarea.form-control {
  width: 100%;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
}
.page textarea.form-control {
  min-height: 80px;
  padding: 8px 10px;
  resize: vertical;
}
.form-section { padding: 20px 24px 0; }
.form-section-title {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.form-grid-muted {
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.form-help { margin: 8px 0 0; font-size: 12px; color: var(--subtle); }
.form-foot {
  display: flex;
  gap: 10px;
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.form-error-banner {
  margin: 16px 24px 0;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13px;
}
.field-error { color: var(--danger); font-size: 12px; }

.topbar-user-wrap { position: relative; }
.user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-overlay);
  padding: 6px;
  z-index: 80;
}
.user-menu a,
.user-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  background: none;
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}
.user-menu a:hover,
.user-menu button:hover { background: var(--bg); }

/* Notification popover */
.notif-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: 320px;
  max-height: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-overlay);
  z-index: 80;
  overflow: hidden;
}
.notif-popover[hidden] { display: none; }
.notif-popover-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.notif-mark-all {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}
.notif-mark-all:hover { text-decoration: underline; }
.notif-popover-body {
  padding: 6px 0;
  max-height: 340px;
  overflow-y: auto;
}
.notif-empty { color: var(--subtle); font-size: 13px; margin: 0; padding: 12px; text-align: center; }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  transition: background 120ms;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg); }
.notif-item.is-read { opacity: 0.55; }
.notif-title { font-size: 13px; font-weight: 500; }
.notif-msg { font-size: 12px; color: var(--subtle); margin-top: 2px; }
.notif-time { font-size: 11px; color: var(--subtle); margin-top: 3px; }

/* ---- Small mobile (≤480px) — дополнительные ужесточения ---- */
@media (max-width: 480px) {
  .kpi-value { font-size: 20px; }
  .page-head h1 { font-size: 17px; }
  .btn { height: 30px; padding: 0 10px; font-size: 12.5px; }
  .toolbar-search { height: 30px; }
  .t { min-width: 560px; }
}

/* ============================================================
   UPDATE STATUS PAGE — двухколоночный wizard + sticky footer
   ============================================================ */
.page[data-page="update-status"] .page-head .sub { max-width: 60ch; }

.page[data-page="update-status"] .card-hint {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.page[data-page="update-status"] .us-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.page[data-page="update-status"] .us-card-head > div:first-child { min-width: 0; }

.us-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.us-counter strong {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--ink);
}
.us-counter.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}
.us-counter.is-active strong { color: var(--accent-strong); }
.us-counter-sep { color: var(--border-strong); }

.us-grid {
  display: grid;
  grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin-top: 4px;
}
@media (max-width: 960px) {
  .us-grid { grid-template-columns: 1fr; }
}

.us-params .form-grid { grid-template-columns: 1fr; }

.loc-control { display: flex; flex-direction: column; gap: 6px; }
.loc-control select,
.loc-control input[type="text"] {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  width: 100%;
  transition: border-color var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease);
}
.loc-control select:focus,
.loc-control input[type="text"]:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.field-hint {
  font-size: 11.5px;
  color: var(--warning);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}
.field-hint::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warning);
  flex-shrink: 0;
}

.field[data-loc].is-required select,
.field[data-loc].is-required input[type="text"] {
  border-color: var(--warning);
}

.us-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 12px;
  flex-wrap: wrap;
}
.us-toolbar .toolbar-search { flex: 1; min-width: 200px; }
.us-toolbar-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.placement-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px 2px 7px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.placement-pill.is-muted { color: var(--subtle); }
.placement-pill .placement-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.placement-pill .placement-dot[data-placement="warehouse"] { background: var(--success); }
.placement-pill .placement-dot[data-placement="truck"] { background: var(--info); }
.placement-pill .placement-dot[data-placement="unplaced"] { background: var(--subtle); }

.us-empty {
  text-align: center;
  padding: 48px 20px !important;
  color: var(--subtle);
  font-size: 13px;
}
.us-empty-link {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
  margin-left: 6px;
}
.us-empty-link:hover { text-decoration: underline; }

.us-sticky {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 18px;
  z-index: 30;
  display: flex;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--motion-base) var(--ease), transform var(--motion-base) var(--ease);
}
.us-sticky.is-active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.us-sticky-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 14px 12px 18px;
  background: var(--ink);
  color: white;
  border-radius: 12px;
  box-shadow: 0 12px 32px -8px rgba(28, 25, 23, 0.4);
  min-width: 460px;
  max-width: 720px;
  width: 100%;
}
.us-sticky-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
.us-sticky-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
  background: rgba(255, 255, 255, 0.12);
  padding: 8px 12px;
  border-radius: 8px;
  min-width: 48px;
  text-align: center;
}
.us-sticky-label {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}
.us-sticky-label strong {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.us-sticky-label span {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.65);
}
.us-sticky-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.us-sticky-actions .btn-ghost {
  color: rgba(255, 255, 255, 0.85);
  border-color: rgba(255, 255, 255, 0.18);
}
.us-sticky-actions .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}
.us-sticky-actions .btn-primary {
  background: white;
  color: var(--ink);
  border-color: white;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.us-sticky-actions .btn-primary:hover { background: #f4f4f5; border-color: #f4f4f5; }
.us-sticky-actions .btn-primary:disabled {
  background: rgba(255, 255, 255, 0.4);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.6);
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .us-sticky-inner { flex-direction: column; align-items: stretch; min-width: 0; padding: 10px 12px; }
  .us-sticky-info { justify-content: space-between; }
  .us-sticky-actions { justify-content: flex-end; }
  .us-sticky-label span { display: none; }
}

/* ============================================================
   PHASE 4 — Loading Drawer + Split Product
   ============================================================ */

/* Drawer — fixed to escape overflow:hidden containers */
.load-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 420px;
  max-width: 90vw;
  background: var(--bg);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px -8px rgba(28, 25, 23, 0.12);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 30;
}
.load-drawer[x-show="true"] { transform: translateX(0); }

/* Scrim for drawer — fixed to match */
#load-drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.32);
  z-index: 29;
}

/* Alpine.js transition helpers for drawer */
.td-drawer-enter { transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1); }
.td-drawer-leave { transition: transform 0.2s cubic-bezier(0.4, 0, 1, 1); }
.td-scrim-enter { transition: opacity 0.25s ease; }
.td-scrim-leave { transition: opacity 0.2s ease; }

/* Drawer internals */
.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-title { font-size: 15px; font-weight: 600; color: var(--ink); margin: 0; }
.drawer-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.drawer-close {
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--subtle); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.drawer-close:hover { background: var(--bg-alt); color: var(--ink); }
.drawer-close svg { width: 14px; height: 14px; }

.drawer-body {
  flex: 1; overflow-y: auto; padding: 16px 20px;
  display: flex; flex-direction: column; gap: 16px;
}
.drawer-section { display: flex; flex-direction: column; gap: 6px; }
.drawer-section--grow { flex: 1; min-height: 0; }
.drawer-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.drawer-select {
  width: 100%; padding: 8px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); color: var(--ink);
  font-size: 13px; font-family: inherit;
}
.drawer-products {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 320px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 8px; padding: 4px;
}
.drawer-product {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  transition: background 0.12s;
}
.drawer-product:hover { background: var(--bg-alt); }
.drawer-product input[type="checkbox"] { flex-shrink: 0; }
.drawer-product-body { flex: 1; min-width: 0; }
.drawer-product-track { font-size: 12px; color: var(--ink); font-weight: 500; }
.drawer-product-desc { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-product-avail { font-size: 12px; color: var(--subtle); flex-shrink: 0; }
.drawer-qty {
  width: 56px; padding: 4px 6px; border-radius: 4px;
  border: 1px solid var(--border); font-size: 12px; text-align: right;
  background: var(--bg); color: var(--ink);
}
.drawer-qty:disabled { opacity: 0.4; background: var(--bg-alt); }
.drawer-empty { font-size: 13px; color: var(--muted); padding: 24px 0; text-align: center; }

.drawer-foot {
  padding: 12px 20px; border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-submit {
  width: 100%; padding: 10px; border-radius: 8px;
  background: var(--ink); color: var(--bg);
  font-size: 13px; font-weight: 600; border: none; cursor: pointer;
  transition: opacity 0.15s;
}
.drawer-submit:hover { opacity: 0.85; }
.drawer-submit:disabled { opacity: 0.4; cursor: not-allowed; }

/* Split product — inline form */
.td-cargo-item {
  display: grid;
  grid-template-columns: 1fr;
}
.td-cargo-row .td-cargo-split-btn {
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--subtle); cursor: pointer; font-size: 14px;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.td-cargo-row .td-cargo-split-btn:hover { background: var(--bg-alt); color: var(--ink); border-color: var(--ink); }

.td-split-inline {
  padding: 12px 16px 12px 40px;
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.td-split-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; flex-wrap: wrap; gap: 4px;
}
.td-split-title { font-size: 12px; font-weight: 600; color: var(--ink); }
.td-split-remain { font-size: 11px; color: var(--muted); }

.td-split-children { display: flex; flex-direction: column; gap: 6px; }
.td-split-child {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 8px; border-radius: 6px; background: var(--bg);
  border: 1px solid var(--border);
}
.td-split-fields { flex: 1; display: flex; gap: 6px; flex-wrap: wrap; }
.td-split-field { display: flex; flex-direction: column; gap: 2px; min-width: 80px; flex: 1; }
.td-split-fk { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.td-split-field input {
  padding: 5px 6px; border-radius: 4px;
  border: 1px solid var(--border); font-size: 12px;
  background: var(--bg); color: var(--ink);
  transition: border-color 0.15s;
}
.td-split-field input:focus { outline: none; border-color: var(--ink); }
.td-split-field input.td-input-error { border-color: #ef4444; background: #fef2f2; }

.td-split-remove {
  width: 24px; height: 24px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--subtle); cursor: pointer;
  font-size: 14px; flex-shrink: 0;
}
.td-split-remove:hover { background: #fef2f2; color: #ef4444; }

.td-split-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; gap: 8px; flex-wrap: wrap;
}
.td-split-add {
  padding: 5px 10px; border-radius: 5px;
  border: 1px dashed var(--border); background: transparent;
  color: var(--muted); cursor: pointer; font-size: 12px;
  transition: border-color 0.12s, color 0.12s;
}
.td-split-add:hover { border-color: var(--ink); color: var(--ink); }

.td-split-status { font-size: 11px; }
.td-split-ok { color: #10b981; }
.td-split-err { color: #ef4444; }

.td-split-submit {
  padding: 6px 14px; border-radius: 6px;
  background: var(--ink); color: var(--bg);
  font-size: 12px; font-weight: 600; border: none; cursor: pointer;
  transition: opacity 0.15s;
}
.td-split-submit:hover { opacity: 0.85; }
.td-split-submit:disabled { opacity: 0.35; cursor: not-allowed; }

/* Drawer capacity indicator */
.drawer-cap {
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-cap-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.drawer-cap-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.drawer-cap-val { font-size: 13px; color: var(--ink); }
.drawer-cap-sep { color: var(--muted); margin: 0 2px; }
.drawer-cap-bar {
  display: flex; align-items: center; gap: 8px;
}
.drawer-cap-bar-track {
  flex: 1; height: 6px; border-radius: 3px;
  background: var(--bg-alt); overflow: hidden;
}
.drawer-cap-bar-fill {
  height: 100%; border-radius: 3px;
  background: var(--ink); transition: width 0.2s ease, background 0.2s ease;
}
.drawer-cap-bar-fill.is-over { background: #ef4444; }
.drawer-cap-bar-pct { font-size: 11px; color: var(--muted); min-width: 32px; text-align: right; }
.text-red-500 { color: #ef4444 !important; }

/* Transition helpers */
[x-cloak] { display: none !important; }

/* ---- Audit log modal ---- */
.modal-panel .modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
}
.modal-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; width: 90%; max-width: 560px; max-height: 80vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
}
.modal-panel .modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-panel .modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-panel .modal-close {
  background: none; border: none; cursor: pointer; font-size: 18px;
  color: var(--muted); padding: 4px 8px; border-radius: 6px;
}
.modal-panel .modal-close:hover { background: var(--bg-alt); color: var(--ink); }
.modal-panel .modal-body {
  padding: 16px 20px; overflow-y: auto; flex: 1;
}
.audit-log-loading { text-align: center; padding: 24px; color: var(--muted); }
.audit-log-list { list-style: none; margin: 0; padding: 0; }
.audit-log-item {
  padding: 10px 0; border-bottom: 1px solid var(--border-light, var(--border));
}
.audit-log-item:last-child { border-bottom: none; }
.audit-log-head { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.audit-log-action { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.audit-log-ts { font-size: 11px; color: var(--muted); margin-left: auto; }
.audit-log-actor { font-size: 13px; color: var(--ink); }
.audit-log-meta { font-size: 11px; color: var(--muted); margin-top: 2px; display: flex; gap: 6px; flex-wrap: wrap; }
.audit-log-empty { text-align: center; padding: 32px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
