/*
 * Маршрут — Precision Logistics Command Design System
 * Dual-theme (Light & Dark), 60-30-10 color balance, zero-pill metadata,
 * Manrope UI + JetBrains Mono tabular figures.
 */

:root {
  --font-sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --sidebar-w: 248px;

  /* 60% Dominant Neutral Canvas (Light) */
  --canvas: #f8fafc;
  --surface: #ffffff;
  --surface-subtle: #f1f5f9;
  --surface-hover: #f8fafc;
  --topbar-bg: rgba(248, 250, 252, 0.86);

  /* 30% Structural Borders & Ink */
  --line: #e2e8f0;
  --line-subtle: #edf2f7;
  --line-strong: #cbd5e1;
  --ink: #0f172a;
  --ink-secondary: #334155;
  --muted: #64748b;
  --muted-soft: #94a3b8;

  /* 10% Signal Accent (WCAG AA contrast with white text >= 4.6:1) */
  --accent: #d94e07;
  --accent-hover: #be4205;
  --accent-soft: #fff4ed;
  --accent-border: #fdba74;
  --accent-text: #c2410c;
  --accent-glow: rgba(217, 78, 7, 0.14);

  /* Semantic Data States (always paired with explicit text) */
  --monitoring: #2563eb;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;
  --neutral-dot: #94a3b8;

  /* Sidebar Obsidian Architecture */
  --rail-bg: #0c111d;
  --rail-surface: #151c2c;
  --rail-hover: #1a2337;
  --rail-border: rgba(255, 255, 255, 0.08);
  --rail-ink: #f8fafc;
  --rail-muted: #94a3b8;
  --rail-dim: #64748b;

  /* Overlays & Elevation */
  --backdrop: rgba(9, 13, 22, 0.54);
  --shadow-popover: 0 18px 42px -12px rgba(15, 23, 42, 0.18), 0 0 0 1px var(--line);
  --shadow-dialog: 0 28px 70px -16px rgba(15, 23, 42, 0.3);
  --shadow-toast: 0 14px 36px -8px rgba(15, 23, 42, 0.28);

  color-scheme: light;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--canvas);
}

:root[data-theme="dark"] {
  --canvas: #090d16;
  --surface: #111827;
  --surface-subtle: #161f30;
  --surface-hover: #182235;
  --topbar-bg: rgba(9, 13, 22, 0.84);

  --line: rgba(255, 255, 255, 0.09);
  --line-subtle: rgba(255, 255, 255, 0.05);
  --line-strong: rgba(255, 255, 255, 0.16);
  --ink: #f1f5f9;
  --ink-secondary: #cbd5e1;
  --muted: #94a3b8;
  --muted-soft: #64748b;

  --accent: #ea580c;
  --accent-hover: #f97316;
  --accent-soft: rgba(234, 88, 12, 0.14);
  --accent-border: rgba(249, 115, 22, 0.35);
  --accent-text: #fb923c;
  --accent-glow: rgba(234, 88, 12, 0.24);

  --monitoring: #60a5fa;
  --ok: #34d399;
  --ok-soft: rgba(16, 185, 129, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --danger-border: rgba(248, 113, 113, 0.32);
  --neutral-dot: #64748b;

  --rail-bg: #070a12;
  --rail-surface: #111827;
  --rail-hover: #161f30;
  --rail-border: rgba(255, 255, 255, 0.08);

  --backdrop: rgba(2, 6, 15, 0.72);
  --shadow-popover: 0 22px 48px -12px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--line-strong);
  --shadow-dialog: 0 32px 80px -16px rgba(0, 0, 0, 0.7);
  --shadow-toast: 0 16px 40px -8px rgba(0, 0, 0, 0.65);

  color-scheme: dark;
  letter-spacing: 0.008em;
}

body {
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

/* Focus rings */
:is(button, a, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Loading screen */
.loading {
  color: var(--muted);
}
.loading-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   SIDEBAR NAVIGATION RAIL
   ============================================================ */
.sidebar {
  background: var(--rail-bg);
  border-right: 1px solid var(--rail-border);
  padding: 22px 14px 20px;
  color: var(--rail-ink);
}

.sidebar .brand {
  padding: 2px 10px 26px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--rail-border);
}
.brand img {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  flex-shrink: 0;
}
.brand strong {
  display: block;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: var(--rail-ink);
}
.brand small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--rail-muted);
  margin-top: 2px;
  letter-spacing: 0;
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--rail-dim);
  padding: 12px 12px 8px;
}

.sidebar .nav button {
  color: var(--rail-muted);
  font-size: 13.5px;
  font-weight: 500;
  padding: 10px 12px;
  min-height: 40px;
  border-radius: 8px;
  position: relative;
  transition: background 140ms var(--ease-out), color 140ms var(--ease-out);
}
.sidebar .nav button svg {
  width: 17px;
  height: 17px;
  color: var(--rail-dim);
  transition: color 140ms var(--ease-out);
}
.sidebar .nav button:hover {
  background: var(--rail-hover);
  color: var(--rail-ink);
}
.sidebar .nav button:hover svg {
  color: var(--rail-ink);
}
.sidebar .nav button.active {
  background: var(--rail-surface);
  color: var(--rail-ink);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.sidebar .nav button.active svg {
  color: #f97316;
}
.sidebar .nav button.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #f97316;
}

.sidebar-bottom {
  margin-top: auto;
  padding: 16px 4px 0;
  border-top: 1px solid var(--rail-border);
}
.sidebar-note {
  padding: 13px 14px;
  background: var(--rail-surface);
  border: 1px solid var(--rail-border);
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--rail-muted);
}
.sidebar-note strong {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--rail-ink);
  margin-bottom: 3px;
}
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 0 8px;
  font-size: 11.5px;
  color: var(--rail-dim);
}
.sidebar-footer svg {
  width: 14px;
  height: 14px;
  color: var(--rail-dim);
}

/* ============================================================
   TOP BAR
   ============================================================ */
.topbar {
  height: 68px;
  padding: 0 32px;
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.breadcrumb {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.breadcrumb-sep {
  color: var(--muted-soft);
}
.breadcrumb strong {
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Live Bot Telemetry Control in Topbar */
#header-bot {
  min-width: 0;
  flex-shrink: 0;
}
.bot-header-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 4px 5px 4px 12px;
  background: var(--surface);
  min-height: 36px;
  transition: border-color 150ms var(--ease-out);
}
.bot-header-status strong {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-secondary);
  white-space: nowrap;
}
.bot-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--neutral-dot);
  flex-shrink: 0;
}
.bot-header-status.is-on .bot-status-dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}
.bot-header-status.is-error .bot-status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}
.bot-header-status.is-off strong {
  color: var(--muted);
}

.bot-power {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--surface-subtle);
  color: var(--ink-secondary);
  transition: background 140ms var(--ease-out), color 140ms var(--ease-out);
}
.bot-power:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.bot-power svg {
  width: 14px;
  height: 14px;
}

/* Theme toggle & topbar icon controls */
.topbar-icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  transition: background 140ms var(--ease-out), color 140ms var(--ease-out), border-color 140ms var(--ease-out);
}
.topbar-icon-btn:hover {
  background: var(--surface-subtle);
  color: var(--ink);
  border-color: var(--line-strong);
}
.topbar-icon-btn svg {
  width: 16px;
  height: 16px;
}

.topbar-divider {
  width: 1px;
  height: 22px;
  background: var(--line);
}

.avatar {
  width: 34px;
  height: 34px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line);
  transition: box-shadow 150ms var(--ease-out), border-color 150ms var(--ease-out);
}
.profile-avatar:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.usertext strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
}
.usertext span {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.25;
}
.logout {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--muted);
  margin-left: 2px;
  transition: background 140ms var(--ease-out), color 140ms var(--ease-out);
}
.logout:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
.logout svg {
  width: 16px;
  height: 16px;
}

/* ============================================================
   MAIN CONTENT & TYPOGRAPHY
   ============================================================ */
.content {
  padding: 28px 32px 44px;
}

.pagehead {
  margin-bottom: 24px;
}
.eyebrow {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-text);
  margin-bottom: 6px;
}
h1 {
  font-size: clamp(24px, 2.2vw, 30px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--ink);
  text-wrap: balance;
}
.subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-top: 6px;
  line-height: 1.55;
  max-width: 66ch;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #ffffff;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 0 18px;
  min-height: 40px;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 150ms var(--ease-out), transform 120ms var(--ease-out), box-shadow 150ms var(--ease-out);
}
.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 6px 18px -6px var(--accent-glow);
}
.primary:active:not(:disabled) {
  transform: translateY(1px);
}
.primary svg {
  width: 16px;
  height: 16px;
}

.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--surface);
  color: var(--ink-secondary);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 15px;
  min-height: 40px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out);
}
.secondary:hover:not(:disabled) {
  background: var(--surface-subtle);
  border-color: var(--line-strong);
  color: var(--ink);
}

.refresh {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  min-height: 36px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: background 140ms var(--ease-out), color 140ms var(--ease-out);
}
.refresh:hover {
  background: var(--surface-subtle);
  color: var(--ink);
}
.refresh svg {
  width: 15px;
  height: 15px;
}

.clear-filters {
  padding: 0 10px;
  min-height: 36px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-text);
  white-space: nowrap;
  transition: background 140ms var(--ease-out);
}
.clear-filters:hover {
  background: var(--accent-soft);
}

/* ============================================================
   KPI METRIC STRIP (Unified Architectural Strip, Zero Clutter)
   ============================================================ */
.stats {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 20px;
  overflow: hidden;
}

.stat {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  position: relative;
}
.stat + .stat {
  border-left: 1px solid var(--line);
}
.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.stat-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.stat-hint {
  font-size: 11.5px;
  color: var(--muted-soft);
}
.stat-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--ink);
}
.stat-accent .stat-value {
  color: var(--accent-text);
}

/* ============================================================
   MAIN CARD CONTAINER, TABS & TOOLBAR
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.tabs-row {
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.tabs {
  gap: 20px;
}
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 15px 2px 14px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 140ms var(--ease-out), border-color 140ms var(--ease-out);
}
.tab:hover {
  color: var(--ink);
}
.tab.active {
  color: var(--ink);
  font-weight: 700;
  border-bottom-color: var(--accent);
}
/* Clean unboxed tabular counter — Zero-Pill Discipline */
.tab span {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-soft);
}
.tab.active span {
  color: var(--accent-text);
  font-weight: 600;
}

.toolbar {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line-subtle);
  background: var(--surface);
}
.toolbar input,
.toolbar select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--canvas);
  color: var(--ink);
  font-size: 13px;
  padding: 0 12px;
  transition: border-color 140ms var(--ease-out), background 140ms var(--ease-out), box-shadow 140ms var(--ease-out);
}
.toolbar input::placeholder {
  color: var(--muted-soft);
}
.toolbar input:focus,
.toolbar select:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.search svg {
  width: 15px;
  height: 15px;
  color: var(--muted-soft);
}
.toolbar .search input {
  padding-left: 36px;
}
.toolbar .date-filter {
  width: 162px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}

/* ============================================================
   HIGH-DENSITY DATA TABLES
   ============================================================ */
.table-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.data-table th {
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
}
.data-table th:first-child,
.data-table td:first-child {
  padding-left: 20px;
}
.data-table th:last-child,
.data-table td:last-child {
  padding-right: 20px;
}
.data-table td {
  padding: 13px 18px;
  font-size: 13.5px;
  color: var(--ink);
  border-bottom: 1px solid var(--line-subtle);
  vertical-align: middle;
  line-height: 1.45;
}
.data-table tbody tr {
  transition: background 120ms var(--ease-out);
}
.data-table tbody tr:hover {
  background: var(--surface-hover);
}
.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.route-id {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent-text);
  letter-spacing: -0.01em;
}
.mono-cell {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--ink);
}
.cell-sub {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  font-family: var(--font-sans);
}
.cell-sub.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
}

.mini-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  color: var(--ink-secondary);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.driver-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vehicle-plate {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.vehicle-plate svg {
  width: 14px;
  height: 14px;
  color: var(--muted-soft);
}

/* Zero-Pill Semantic Status Indicators (clean unboxed text + precision marker) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  padding: 0;
  background: transparent;
}
.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 2px;
  flex-shrink: 0;
}
.badge.waiting {
  color: var(--monitoring);
}
.badge.waiting::before {
  background: currentColor;
}
.badge.paused {
  color: var(--warn);
}
.badge.paused::before {
  background: var(--warn);
}
.badge.archived {
  color: var(--muted);
}
.badge.archived::before {
  background: var(--muted-soft);
}

/* Clean unboxed staff role typography */
.staff-role {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.staff-role.role-super_admin {
  color: var(--accent-text);
}
.staff-role.role-admin {
  color: var(--ink);
}
.staff-role.role-logist {
  color: var(--muted);
}

.team-avatar {
  width: 34px;
  height: 34px;
}

.activity-action {
  font-weight: 600;
  color: var(--ink);
}
.note-preview {
  white-space: normal;
  max-width: 380px;
  color: var(--muted);
  line-height: 1.5;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  color: var(--muted);
  transition: background 140ms var(--ease-out), color 140ms var(--ease-out);
}
.icon-btn:hover {
  background: var(--surface-subtle);
  color: var(--ink);
}
.icon-btn[data-status="archived"]:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
.icon-btn svg {
  width: 15px;
  height: 15px;
}

.table-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.pager button {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 7px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid transparent;
  transition: background 140ms var(--ease-out), color 140ms var(--ease-out), border-color 140ms var(--ease-out);
}
.pager button:hover {
  background: var(--surface-subtle);
  color: var(--ink);
}
.pager button.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent-border);
  font-weight: 600;
}

.footnote {
  margin-top: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}
.footnote svg {
  width: 15px;
  height: 15px;
  color: var(--muted-soft);
  margin-top: 2px;
}

/* Empty State */
.empty {
  padding: 56px 24px 60px;
  text-align: center;
}
.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-subtle);
  color: var(--muted);
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
}
.empty-icon svg {
  width: 22px;
  height: 22px;
}
.empty h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.empty p {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.6;
  margin: 8px auto 22px;
  max-width: 440px;
}

/* ============================================================
   PANELS, CATALOG & BOT SETTINGS
   ============================================================ */
.panel-intro {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.panel-intro h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.panel-intro p,
.panel-intro > span {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.5;
}
.panel-intro > svg {
  color: var(--muted-soft);
}

.bot-form {
  padding: 4px 22px 24px;
}
.bot-events-card {
  margin-top: 20px;
}

.toggle-row {
  padding: 18px 0;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line-subtle);
}
.toggle-row strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.toggle-row small {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 3px;
}
.toggle-track {
  width: 42px;
  height: 24px;
  background: var(--line-strong);
  border-radius: 999px;
  position: relative;
  flex: none;
  pointer-events: none;
  transition: background 160ms var(--ease-out);
}
.toggle-track::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  transition: transform 160ms var(--ease-out);
}
.toggle-row > input:checked + .toggle-track {
  background: var(--accent);
}
.toggle-row > input:checked + .toggle-track::after {
  transform: translateX(18px);
}
.toggle-row > input:focus-visible + .toggle-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.bot-state {
  padding: 18px 20px;
}
.bot-state > svg {
  width: 38px;
  height: 38px;
  padding: 9px;
  border-radius: 10px;
  background: var(--surface-subtle);
  color: var(--muted);
  border: 1px solid var(--line);
}
.bot-state.is-on > svg {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: transparent;
}
.bot-state strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.bot-state p {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

.runtime-list {
  padding: 0 20px;
}
.runtime-list > div {
  padding: 12px 0;
  border-top: 1px solid var(--line-subtle);
}
.runtime-list dt {
  font-size: 12.5px;
  color: var(--muted);
}
.runtime-list dd {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  text-align: right;
  overflow-wrap: anywhere;
}

.bot-status-card .error-box {
  margin: 0 20px 14px;
}
.test-alert-controls {
  margin: 8px 20px 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line-subtle);
  display: grid;
  gap: 10px;
}
.test-alert-controls label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-secondary);
}
.test-alert-controls select {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--canvas);
  color: var(--ink);
  font-size: 13px;
}
.bot-explanation {
  margin: 0 20px 20px;
  padding: 14px;
  background: var(--surface-subtle);
  border: 1px solid var(--line-subtle);
  border-radius: 10px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.65;
}

.bot-form-footer {
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.status-message {
  font-size: 12.5px;
  color: var(--muted);
}

/* Catalog incremental viewport */
.catalog-viewport thead {
  background: var(--surface-subtle);
}
.catalog-load-status {
  padding: 13px 20px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.catalog-placeholder {
  padding: 48px !important;
  text-align: center;
  color: var(--muted);
}
.catalog-error,
.combo-error,
.combo-load-error {
  color: var(--danger);
}
.combo-load-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
}
.combo-load-error button {
  color: var(--accent-text);
  font-weight: 600;
}

/* ============================================================
   FIELDS, INPUTS & COMBOBOX
   ============================================================ */
.field {
  margin-bottom: 18px;
}
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
  margin-bottom: 7px;
}
.field label span {
  font-weight: 500;
  color: var(--muted-soft);
  font-size: 12px;
  margin-left: 6px;
}
.required {
  color: var(--accent);
}
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--canvas);
  color: var(--ink);
  min-height: 42px;
  padding: 10px 13px;
  font-size: 14px;
  transition: border-color 140ms var(--ease-out), background 140ms var(--ease-out), box-shadow 140ms var(--ease-out);
}
.field input:focus,
.field select:focus,
.field textarea:focus,
.combo-control input[aria-expanded="true"] {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.field input::placeholder,
.field textarea::placeholder {
  color: var(--muted-soft);
}
.field textarea {
  min-height: 76px;
  resize: vertical;
  line-height: 1.5;
}
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-position: right 12px center;
  background-repeat: no-repeat;
  padding-right: 36px;
}
.field-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  margin-top: 6px;
}

.token-input input {
  padding-right: 94px;
  font-family: var(--font-mono);
  font-size: 13px;
}
.token-show {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  background: var(--surface-subtle);
  transition: background 140ms var(--ease-out), color 140ms var(--ease-out);
}
.token-show:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.field label.clear-token {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  margin-top: 10px;
  cursor: pointer;
}
.clear-token input {
  width: 16px;
  height: 16px;
  min-height: 0;
  accent-color: var(--accent);
}

.password-control input {
  padding-right: 44px;
}
.password-eye {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  color: var(--muted);
  transition: background 140ms var(--ease-out), color 140ms var(--ease-out);
}
.password-eye:hover {
  background: var(--surface-subtle);
  color: var(--ink);
}

.combo-control input {
  padding-right: 42px;
}
.combo-toggle {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--muted);
}
.combo-options {
  background: var(--surface);
  border: 0;
  border-radius: 10px;
  box-shadow: var(--shadow-popover);
  padding: 6px;
  color: var(--ink);
}
.combo-option {
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink-secondary);
  cursor: pointer;
  white-space: normal;
  overflow-wrap: anywhere;
  transition: background 100ms var(--ease-out), color 100ms var(--ease-out);
}
.combo-option:hover,
.combo-option.highlight {
  background: var(--surface-subtle);
  color: var(--ink);
}
.combo-option[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.combo-loading,
.combo-no-results {
  padding: 12px;
  font-size: 12.5px;
  color: var(--muted);
}

.weekday-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.field .weekday-list label {
  position: relative;
  margin: 0;
  cursor: pointer;
}
.weekday-list input {
  position: absolute;
  inset: 0;
  opacity: 0;
  min-height: 0;
  cursor: pointer;
}
.weekday-list span {
  display: block !important;
  margin: 0 !important;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px !important;
  font-weight: 600 !important;
  color: var(--muted) !important;
  background: var(--canvas);
}
.weekday-list input:checked + span {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent-text) !important;
}

.error-box {
  padding: 12px 14px;
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  border-radius: 9px;
  font-size: 13px;
  line-height: 1.5;
  margin: 14px 0;
}

/* ============================================================
   TABULATOR MODERN GRID THEME (Light & Dark Synced)
   ============================================================ */
#bot-events,
#bot-logs {
  padding: 0;
}
.tabulator {
  background: var(--surface);
  border: 0;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13px;
}
.tabulator .tabulator-header {
  background: var(--surface-subtle);
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.tabulator .tabulator-header .tabulator-col {
  background: var(--surface-subtle);
  border-right: 0;
  min-height: 42px;
}
.tabulator .tabulator-header .tabulator-col .tabulator-col-content {
  padding: 11px 14px;
}
.tabulator .tabulator-header .tabulator-col .tabulator-col-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.tabulator .tabulator-header .tabulator-col.tabulator-sortable:hover {
  background: var(--surface-hover);
}
.tabulator .tabulator-header .tabulator-col .tabulator-arrow {
  border-bottom-color: var(--muted-soft) !important;
  border-top-color: var(--muted-soft) !important;
}
.tabulator .tabulator-header .tabulator-header-filter {
  margin-top: 8px !important;
}
.tabulator .tabulator-header .tabulator-header-filter input,
.tabulator .tabulator-header .tabulator-header-filter select {
  width: 100% !important;
  border: 1px solid var(--line) !important;
  border-radius: 6px !important;
  background: var(--surface) !important;
  color: var(--ink) !important;
  padding: 5px 8px !important;
  font-size: 12px !important;
  font-family: var(--font-sans) !important;
  min-height: 28px;
  outline: none;
}
.tabulator .tabulator-header .tabulator-header-filter input:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-glow);
}
.tabulator .tabulator-header input::placeholder {
  color: var(--muted-soft);
}
.tabulator .tabulator-tableholder {
  background: var(--surface);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.tabulator .tabulator-tableholder .tabulator-table {
  background: var(--surface);
  color: var(--ink);
}
.tabulator-row {
  background: var(--surface);
  border-bottom: 1px solid var(--line-subtle);
  min-height: 48px;
}
.tabulator-row.tabulator-row-even {
  background: var(--surface);
}
.tabulator-row.tabulator-selectable:hover {
  background: var(--surface-hover);
}
.tabulator-row .tabulator-cell {
  font-size: 13px;
  line-height: 1.5;
  border-right: 0;
  padding: 12px 14px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.tabulator-row .route-id {
  font-size: 13px;
  text-decoration: none;
}
.tabulator-row .route-id:hover {
  text-decoration: underline;
}
.tabulator .tabulator-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 10px 16px;
  color: var(--muted);
  font-size: 12px;
  font-family: var(--font-sans);
}
.tabulator .tabulator-footer .tabulator-footer-contents {
  padding: 0;
  gap: 10px;
  flex-wrap: wrap;
}
.tabulator .tabulator-footer .tabulator-page {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  padding: 4px 9px;
  min-width: 28px;
  min-height: 28px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  margin: 0 2px;
}
.tabulator .tabulator-footer .tabulator-page.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent-border);
}
.tabulator .tabulator-footer .tabulator-page:not(:disabled):hover {
  background: var(--surface-subtle);
  color: var(--ink);
}
.tabulator .tabulator-footer .tabulator-page-size {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 4px 8px;
  min-height: 28px;
}
.tabulator-placeholder span {
  font-size: 13.5px !important;
  color: var(--muted) !important;
  font-weight: 500 !important;
}

.grid-action {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  transition: background 140ms var(--ease-out), color 140ms var(--ease-out), border-color 140ms var(--ease-out);
}
.grid-action svg {
  width: 14px;
  height: 14px;
}
.grid-action:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent-border);
}
.grid-action.is-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-border);
}

.outcome-text {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: 12.5px;
}
.outcome-ok {
  color: var(--ok);
  font-weight: 700;
}
.outcome-error {
  color: var(--danger);
  font-weight: 700;
}
.outcome-neutral {
  color: var(--muted);
  font-size: 12.5px;
}
.outcome-description {
  display: block;
  white-space: normal;
  max-width: 320px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11.5px;
}

/* ============================================================
   DIALOGS & OVERLAYS
   ============================================================ */
dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-dialog);
  width: min(560px, calc(100vw - 32px));
  max-height: 92vh;
  overflow-y: auto;
}
dialog[open] {
  animation: dialogIn 180ms var(--ease-out);
}
@keyframes dialogIn {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
dialog::backdrop {
  background: var(--backdrop);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.dialog-head {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line-subtle);
}
.dialog-head h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--ink);
}
.dialog-head p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.5;
}
.close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--surface-subtle);
  color: var(--muted);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 140ms var(--ease-out), color 140ms var(--ease-out);
}
.close:hover {
  background: var(--line);
  color: var(--ink);
}
.close svg {
  width: 15px;
  height: 15px;
}

.request-form {
  padding: 20px 24px 24px;
}
.dialog-buttons {
  border-top: 1px solid var(--line-subtle);
  padding-top: 18px;
  margin-top: 20px;
}

#curl-log-dialog {
  width: min(860px, calc(100vw - 32px));
}
.curl-body {
  padding: 20px 24px 24px;
}
#curl-log-dialog pre {
  margin: 0;
  padding: 16px;
  border-radius: 10px;
  background: var(--canvas);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 50vh;
  overflow: auto;
  user-select: text;
}

#avatar-dialog {
  width: min(500px, calc(100vw - 24px));
}
.avatar-preview {
  display: grid;
  place-items: center;
  margin: 0 auto 20px;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--surface-subtle);
  border: 2px solid var(--line);
  overflow: hidden;
}
.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-presets {
  margin-bottom: 20px;
}
.avatar-presets button {
  background: var(--canvas);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 5px;
  transition: border-color 140ms var(--ease-out), background 140ms var(--ease-out);
}
.avatar-presets button:hover {
  border-color: var(--line-strong);
}
.avatar-presets button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

#acceptance-alert-dialog {
  width: min(520px, calc(100vw - 24px));
  padding: 26px;
  overflow-x: hidden;
}
#acceptance-alert-dialog > h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
#acceptance-alert-dialog > p {
  color: var(--muted);
  font-size: 13.5px;
  margin-top: 6px;
}
#acceptance-alert-dialog .runtime-list {
  padding: 0;
  margin-top: 18px;
}
#acceptance-alert-dialog .runtime-list > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.8fr);
  gap: 12px;
}
#acceptance-alert-dialog .primary,
#acceptance-alert-dialog .secondary {
  width: 100%;
  margin-top: 12px;
}
.acceptance-success-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--ok-soft);
  color: var(--ok);
  border-radius: 12px;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 14px;
}

/* ============================================================
   TOASTS
   ============================================================ */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(14px);
  opacity: 0;
  pointer-events: none;
  background: #0c111d;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 11px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow-toast);
  font-size: 13.5px;
  font-weight: 500;
  z-index: 1000;
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
  max-width: min(520px, calc(100vw - 32px));
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#toast.toast-error {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  pointer-events: auto;
  white-space: normal;
  overflow-wrap: anywhere;
}
.toast-close {
  color: inherit;
  font-size: 20px;
  line-height: 1;
  padding: 2px 6px;
}

/* ============================================================
   AUTH / LOGIN ARCHITECTURE
   ============================================================ */
.auth-art {
  background: #090d16;
  color: #f8fafc;
  padding: 48px 56px;
}
.auth-grid-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 75% at 50% 45%, #000 40%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 75% at 50% 45%, #000 40%, transparent 100%);
  pointer-events: none;
}
.auth-glow {
  position: absolute;
  right: -120px;
  bottom: -140px;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(234, 88, 12, 0.16) 0%, rgba(234, 88, 12, 0.03) 45%, transparent 72%);
  pointer-events: none;
}
.auth-art .brand {
  position: relative;
  z-index: 1;
}
.auth-hero {
  position: relative;
  z-index: 1;
  max-width: 520px;
}
.auth-art .eyebrow {
  color: #fb923c;
  margin-bottom: 14px;
}
.auth-art h1 {
  font-size: clamp(34px, 3.8vw, 48px);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.08;
  color: #ffffff;
  text-wrap: balance;
}
.auth-description {
  color: #94a3b8;
  font-size: 15.5px;
  line-height: 1.7;
  margin-top: 18px;
  max-width: 44ch;
}
.auth-pillars {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin-top: 38px;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}
.auth-pillar strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 4px;
}
.auth-pillar span {
  display: block;
  font-size: 12px;
  color: #64748b;
  line-height: 1.45;
}
.auth-caption {
  position: relative;
  z-index: 1;
  font-size: 12.5px;
  color: #64748b;
}

.auth-right {
  background: var(--canvas);
  padding: 40px 28px;
  position: relative;
}
.auth-theme-corner {
  position: absolute;
  top: 24px;
  right: 24px;
}
.auth-form {
  width: 100%;
  max-width: 410px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 34px 32px;
}
.auth-form h2 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.auth-form .subtitle {
  margin-top: 6px;
  margin-bottom: 24px;
  font-size: 13.5px;
}
.auth-form .primary {
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
}
.auth-demo-box {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.auth-demo-box .secondary {
  width: 100%;
}
.auth-demo-note {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}
.auth-caption-small {
  text-align: center;
  color: var(--muted-soft);
  font-size: 12px;
  line-height: 1.6;
  margin-top: 20px;
}

/* Boot Error Card */
.boot-error-card {
  width: 100%;
  max-width: 460px;
  padding: 36px 28px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.boot-error-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  background: var(--danger-soft);
  color: var(--danger);
}
.boot-error-card h1 {
  font-size: 20px;
}
.boot-error-card p {
  margin: 10px 0 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */
@media (max-width: 1120px) {
  :root { --sidebar-w: 220px; }
  .topbar { padding: 0 22px; }
  .content { padding: 24px 22px 40px; }
  .bot-layout { grid-template-columns: minmax(0, 1fr); }
  .bot-status-card { position: static; }
  .auth-art { padding: 40px 36px; }
}

@media (max-width: 860px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .mobile-brand { display: flex; margin-bottom: 26px; }
  .mobile-brand .brand strong { color: var(--ink); }
  .mobile-brand .brand small { color: var(--muted); }
}

@media (max-width: 800px) {
  .shell { display: block; min-height: 100dvh; }
  .sidebar {
    position: static;
    width: 100%;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
  }
  .sidebar .brand {
    padding: 0;
    margin: 0;
    border: 0;
  }
  .sidebar .brand strong { color: var(--ink); font-size: 17px; }
  .sidebar .brand small,
  .sidebar .nav-label,
  .sidebar .nav,
  .sidebar-bottom {
    display: none;
  }

  .topbar {
    height: auto;
    min-height: 58px;
    padding: 10px 16px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .topbar-divider { display: none; }
  .content { padding: 20px 16px 28px; }
  .main { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }

  .pagehead { align-items: flex-start; gap: 12px; margin-bottom: 18px; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat { padding: 14px 12px; }
  .stat-value { font-size: 24px; }
  .stat-hint { display: none; }

  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    inset: auto 0 var(--mobile-nav-bottom, 0px) 0;
    z-index: 50;
    flex-direction: row;
    align-items: stretch;
    justify-content: space-around;
    gap: 2px;
    padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    background: var(--topbar-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
  }
  .mobile-bottom-nav button {
    flex: 1 1 0;
    min-width: 0;
    min-height: 48px;
    padding: 6px 2px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    border-radius: 8px;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--muted);
  }
  .mobile-bottom-nav button svg { width: 19px; height: 19px; }
  .mobile-bottom-nav button.active {
    color: var(--accent-text);
    background: var(--accent-soft);
  }
  .mobile-bottom-nav .nav-title { display: none; }
  .mobile-bottom-nav .nav-short { display: block; white-space: nowrap; }
  body:has(.shell) #toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
}

@media (max-width: 600px) {
  .requests-table,
  .team-table {
    display: block;
    width: 100%;
  }
  .requests-table thead,
  .team-table thead {
    display: none;
  }
  .requests-table tbody,
  .team-table tbody {
    display: grid;
    gap: 10px;
    padding: 12px;
    background: var(--canvas);
  }
  .requests-table tr,
  .team-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
  }
  .requests-table td,
  .team-table td {
    display: block;
    min-width: 0;
    padding: 0 !important;
    border: 0 !important;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .requests-table td:nth-child(1) { grid-column: 1; }
  .requests-table td:nth-child(5) { grid-column: 2; grid-row: 1; justify-self: end; align-self: start; }
  .requests-table td:nth-child(2) { grid-column: 1; }
  .requests-table td:nth-child(2)::before { content: "Начало мониторинга"; display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
  .requests-table td:nth-child(6) { grid-column: 2; grid-row: 2; justify-self: end; text-align: right; }
  .requests-table td:nth-child(6)::before { content: "Приоритет"; display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
  .requests-table td:nth-child(3) { grid-column: 1 / -1; grid-row: 3; }
  .requests-table td:nth-child(4) { grid-column: 1 / -1; grid-row: 4; }
  .requests-table td:nth-child(7) { grid-column: 1 / -1; grid-row: 5; border-top: 1px solid var(--line-subtle) !important; padding-top: 10px !important; }
  .requests-table .driver-name { max-width: 100%; }
  .requests-table .row-actions { justify-content: flex-end; gap: 8px; }
  .requests-table .icon-btn { width: 38px; height: 38px; border: 1px solid var(--line); }

  .team-table td:nth-child(1) { grid-column: 1 / -1; }
  .team-table td:nth-child(3) { justify-self: end; }
  .team-table td:nth-child(5) { justify-self: end; }
  .table-scroll:has(> .requests-table),
  .table-scroll:has(> .team-table) { overflow: visible; }
}

@media (max-width: 480px) {
  .topbar .breadcrumb,
  .topbar .usertext { display: none; }
  .pagehead .primary { width: 42px; padding: 0; }
  .pagehead .primary span { display: none; }
  .two-fields { grid-template-columns: 1fr; }
  .auth-form { padding: 24px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.bot-settings-fields{border:0;padding:0;margin:0;min-width:0}.bot-settings-fields:disabled{opacity:.58}.bot-rate-control{display:flex;align-items:center;gap:12px}.bot-rate-control input{max-width:130px}.bot-rate-control span{font-size:14px;color:var(--muted)}
/* Operational overview */
.dashboard{display:grid;gap:24px}.dashboard-stats{grid-template-columns:repeat(4,minmax(0,1fr));margin:0}.dashboard-grid{display:grid;grid-template-columns:1fr 1fr;gap:24px}.dashboard-panel{min-width:0}.dashboard-panel .panel-intro{padding:20px 24px;gap:16px}.dashboard-body{padding:24px}.dashboard-metrics{margin:0}.dashboard-metrics>div{display:flex;justify-content:space-between;gap:20px;padding:12px 0;border-bottom:1px solid var(--line);font-size:14px}.dashboard-metrics dt{color:var(--muted)}.dashboard-metrics dd{margin:0;text-align:right;font-weight:600;overflow-wrap:anywhere}.dashboard-wide{width:100%;margin-top:20px}.dashboard-actions{display:flex;gap:10px;flex-wrap:wrap}.dashboard-notice{display:flex;gap:12px;padding:14px;border-radius:10px;background:var(--surface-subtle);margin-bottom:10px}.dashboard-notice svg{width:20px;height:20px}.dashboard-notice.warning{border-left:3px solid #f68338}.dashboard-notice.error{border-left:3px solid #e55555}.dashboard-notice strong{font-size:14px}.dashboard-notice p{font-size:13px;margin:6px 0 0;color:var(--muted);line-height:1.6;overflow-wrap:anywhere}.dashboard-clear{text-align:center;padding:20px;color:var(--muted)}.dashboard-clear>svg{display:block;width:32px;height:32px;margin:0 auto 14px;color:var(--accent)}.dashboard-clear strong{color:var(--ink);display:block}.dashboard-clear p{font-size:13px}.dashboard-plan{display:grid;grid-template-columns:1fr 1.5fr auto;gap:20px;align-items:center;width:100%;padding:20px 24px;text-align:left;background:transparent;color:var(--ink);border-top:1px solid var(--line)}.dashboard-plan:hover{background:var(--surface-subtle)}.dashboard-plan small{display:block;color:var(--muted);font-size:12px;margin-top:6px}.dashboard-route svg{width:18px;height:18px;vertical-align:middle;margin-right:8px;color:var(--accent)}.dashboard-crew{min-width:0;overflow-wrap:anywhere}.dashboard-crew strong{font-size:14px}.dashboard-date{font-size:14px;text-align:right;white-space:nowrap}.dashboard-recent{display:grid;grid-template-columns:1fr auto;gap:6px 16px;padding:16px 24px;border-top:1px solid var(--line);font-size:13px}.dashboard-recent span{grid-column:1;color:var(--muted)}.dashboard-recent small{grid-column:2;grid-row:1/3;align-self:center;color:var(--muted)}.dashboard-loading{padding:48px;text-align:center;color:var(--muted)}.dashboard-count{font-size:13px;color:var(--muted)}.dashboard-updated{text-align:right;color:var(--muted);font-size:12px}.empty-icon svg{width:28px;height:28px;flex:none}
@media(max-width:1000px){.dashboard-stats{grid-template-columns:repeat(2,minmax(0,1fr))}.dashboard-grid{grid-template-columns:1fr}}@media(max-width:600px){.dashboard{gap:16px}.dashboard-actions{width:100%}.dashboard-actions button{flex:1}.dashboard-plan{grid-template-columns:1fr auto;gap:12px;padding:18px}.dashboard-crew{grid-row:2;grid-column:1/3}.dashboard-date{grid-column:2;grid-row:1}.dashboard-body{padding:18px}.dashboard-panel .panel-intro{padding:18px}.dashboard-stats .stat{padding:16px}.mobile-bottom-nav button{min-width:0;flex:1;padding-left:2px;padding-right:2px}.mobile-bottom-nav .nav-short{font-size:9px}}
.dashboard-stats .stat-top{display:flex;flex-direction:column;align-items:flex-start;gap:8px}.dashboard-stats .stat-hint{font-size:11px;text-align:left}.dashboard-stats .stat-value{margin-top:16px}
@media(max-width:600px){.pagehead:has(.dashboard-actions){display:flex;flex-direction:column;align-items:stretch;gap:16px}.pagehead:has(.dashboard-actions)>div:first-child{width:100%;min-width:0}.pagehead .dashboard-actions{position:static;width:100%;max-width:100%;display:grid;grid-template-columns:1fr 1.4fr}.pagehead .dashboard-actions button{position:static;width:auto!important;height:auto;min-width:0;max-width:none;padding:11px 12px;white-space:normal;font-size:12px;overflow:visible}.pagehead .dashboard-actions svg{width:16px;height:16px;flex:none}}
/* Keep acceptance title and explanation stacked inside one cell. */
.tabulator-row .tabulator-cell.acceptance-outcome-cell{display:inline-block!important;white-space:normal!important;vertical-align:middle}.acceptance-outcome{display:grid;gap:5px;width:100%;min-width:0}.acceptance-outcome .outcome-text{display:flex;align-items:center;gap:7px;white-space:normal;overflow-wrap:normal}.acceptance-outcome .outcome-text b{flex:0 0 auto}.acceptance-outcome .outcome-label{white-space:nowrap;flex:0 0 auto}.acceptance-outcome .outcome-description{display:block;margin:0;max-width:100%;white-space:normal;word-break:normal;overflow-wrap:break-word}.badge.accepted{color:var(--ok,#159c72)}.badge.accepted::before{background:currentColor}
.watch-request{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--line);background:var(--surface);color:var(--muted);border-radius:8px;padding:7px 9px;font-size:12px;white-space:nowrap}.watch-request svg{width:16px;height:16px;flex:none}.watch-request.is-watching{color:var(--accent-text);background:var(--accent-soft);border-color:var(--accent-border,var(--line))}.watch-request:hover{color:var(--accent)}.requests-table .row-actions{flex-wrap:wrap;justify-content:flex-end}
.badge.pending{color:var(--muted);background:transparent}.badge.pending::before{background:currentColor}
/* Dedicated compact watch column and a successful processing mark. */
.requests-table .watch-column,.requests-table .watch-cell{text-align:center;width:76px}.watch-cell .watch-request{width:32px;height:32px;padding:0;justify-content:center}.badge.accepted::before{content:'✓';width:auto;height:auto;font-size:14px;line-height:1;border-radius:0;background:none;flex:none}
@media(max-width:600px){.requests-table td.watch-cell:nth-child(7){grid-column:1;grid-row:5;justify-self:start;text-align:left;width:auto}.requests-table td.watch-cell::before{content:'Следить';display:inline-block;font-size:11px;color:var(--muted);margin-right:10px}.requests-table td:nth-child(8){grid-column:2;grid-row:5;justify-self:end;border-top:1px solid var(--line-subtle)!important;padding-top:10px!important}.requests-table td:nth-child(8) .row-actions{justify-content:flex-end}}

/* Fit the desktop overview to the available viewport, including browser chrome. */
@media (min-width:1100px) and (min-height:800px) {
 .content:has(>.dashboard){height:auto;box-sizing:border-box;display:block;padding:16px 28px}
 .content:has(>.dashboard)>.pagehead{flex:none;margin-bottom:16px}
 .content:has(>.dashboard)>.pagehead h1{font-size:28px}
 .dashboard{min-height:0;gap:12px;grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:none;align-content:start}
 .dashboard>.dashboard-stats,.dashboard>.dashboard-grid,.dashboard>.dashboard-updated{grid-column:1/-1}
 .dashboard>.dashboard-panel{grid-column:1/-1;max-height:140px}
 .dashboard>.dashboard-grid:nth-child(2){height:auto;min-height:260px}
 .dashboard>.dashboard-grid:last-of-type{height:auto;min-height:220px}
 .dashboard>.dashboard-grid:last-of-type .dashboard-list{max-height:172px}
 .dashboard-panel:has(#dashboard-monitor)>.dashboard-body, .dashboard>.dashboard-grid:last-of-type .dashboard-body{flex:none;overflow:visible;scrollbar-gutter:auto}
 .dashboard:has(>.dashboard-panel:nth-of-type(2))>.dashboard-panel{grid-column:auto}
 .dashboard-grid{min-height:0;gap:12px}
 .dashboard-panel{display:flex;flex-direction:column;min-height:0;overflow:hidden}
 .dashboard-panel .panel-intro{flex:none;padding:12px 18px;min-height:48px;box-sizing:border-box}
 .dashboard-panel .panel-intro p{margin-top:4px;font-size:12px}
 .dashboard-panel .panel-intro h2{font-size:14px}
 .dashboard-body,.dashboard-list{min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable}
 .dashboard-body{padding:10px 18px;flex:1}
 .dashboard-list{flex:1}
 .dashboard-metrics>div{padding:8px 0;font-size:13px}
 .dashboard-wide{margin-top:10px;min-height:34px;padding:7px 12px}
 .dashboard-stats .stat{padding:12px 18px;gap:6px;justify-content:flex-start}
 .dashboard-stats{min-height:96px}
 .dashboard-stats .stat-top{gap:3px}
 .dashboard-stats .stat-value{margin-top:0;font-size:28px;line-height:30px}
 .dashboard-clear{padding:10px}
 .dashboard-clear>svg{width:26px;height:26px;margin-bottom:8px}
 .dashboard-clear p{margin:4px 0}
 .dashboard-plan{padding:10px 18px;gap:14px}
 .dashboard-plan small{margin-top:3px}
 .dashboard-recent{padding:9px 18px;gap:4px 12px}
 .dashboard-updated{margin:0;font-size:11px;line-height:18px}
}

.dashboard-recent{color:var(--ink);text-decoration:none;text-align:left}
.dashboard-recent:hover{background:var(--surface-subtle)}
.dashboard-recent:hover strong{color:var(--accent-text);text-decoration:underline}
.dashboard-recent:focus-visible{outline:2px solid var(--accent);outline-offset:-3px}

.history-filters{display:flex;align-items:flex-end;gap:12px;flex-wrap:wrap;padding:16px 20px;border-bottom:1px solid var(--line)}
.history-filters label{display:grid;gap:6px;font-size:12px;color:var(--muted);min-width:0}
.history-filters input{min-height:38px;padding:8px 10px;border:1px solid var(--line);border-radius:8px;background:var(--surface);color:var(--ink);max-width:100%;box-sizing:border-box}
.history-filters .history-search{flex:1;min-width:180px}.history-filters .field-hint,.history-error{flex-basis:100%;margin:0}.history-error{color:var(--danger);font-size:13px}.history-error:empty{display:none}
@media(max-width:600px){.history-filters{padding:12px;gap:10px}.history-filters label{flex:1 1 100%}.history-filters button{flex:1}}

.notification-sound-settings{border-top:1px solid var(--line);margin-top:20px;padding-top:20px}
.sound-preview-actions{display:flex;gap:10px;flex-wrap:wrap}.sound-settings-error:empty{display:none}
.notification-sound-settings input[type=range]{width:100%;padding:0;accent-color:var(--accent)}
@media(max-width:600px){.sound-preview-actions button{flex:1}}
