/* ============================================================
   VENUECORE INVENTORY — App Styles
   Full app shell: sidebar + content area
   ============================================================ */

/* AI feature gating: when the body has .ai-disabled (set by default, removed
   only when ANTHROPIC_API_KEY is configured), every AI entry point is hidden
   so users never trigger a token-costing call. */
body.ai-disabled .ai-feature { display: none !important; }

:root {
  /* OLED Dark — layered true blacks */
  --bg-primary: #000000;
  --bg-sidebar: #040408;
  --bg-content: #020204;
  --bg-card: #0a0a14;
  --bg-card-hover: #0f0f1a;
  --bg-input: #0e0e18;
  --bg-input-focus: #141420;
  --border: #161624;
  --border-light: #1e1e32;
  --text-primary: #f0f0f8;
  --text-secondary: #8a8aaa;
  --text-muted: #8188a8; /* ≥4.5:1 on card/content backgrounds (WCAG AA) */
  /* Purple — primary actions */
  --accent: #8b5cf6;
  --accent-hover: #a78bfa;
  --accent-dim: rgba(139, 92, 246, 0.08);
  /* Green — live/healthy */
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.07);
  /* Amber — warnings */
  --yellow: #f59e0b;
  --yellow-dim: rgba(245, 158, 11, 0.07);
  --orange: #f97316;
  --orange-dim: rgba(249, 115, 22, 0.07);
  /* Red — critical/loss */
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.07);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.07);
  --cyan: #06b6d4;
  --cyan-dim: rgba(6, 182, 212, 0.07);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --transition: 0.15s ease;
  /* Elevation — theme-aware so light mode doesn't get harsh black shadows */
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-modal: 0 24px 64px rgba(0, 0, 0, 0.7), 0 4px 16px rgba(0, 0, 0, 0.5);
  --scrollbar-thumb: #26263a;
  --scrollbar-thumb-hover: #34344e;
  /* Font stacks */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ---- Light Theme ---- */
[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-sidebar: #e8ecf1;
  --bg-content: #f5f7fa;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f1f5f9;
  --bg-input-focus: #e8ecf1;
  --border: #d1d5db;
  --border-light: #9ca3af;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b; /* ≥4.5:1 on white (WCAG AA) */
  --accent: #7c3aed;
  --accent-hover: #8b5cf6;
  --accent-dim: rgba(124, 58, 237, 0.08);
  --green: #047857;
  --green-dim: rgba(5, 150, 105, 0.1);
  --yellow: #b45309;
  --yellow-dim: rgba(217, 119, 6, 0.1);
  --orange: #c2410c;
  --orange-dim: rgba(234, 88, 12, 0.1);
  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, 0.1);
  --blue: #2563eb;
  --blue-dim: rgba(37, 99, 235, 0.1);
  --cyan: #0e7490;
  --cyan-dim: rgba(8, 145, 178, 0.1);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-pop: 0 8px 24px rgba(15, 23, 42, 0.14);
  --shadow-modal: 0 24px 64px rgba(15, 23, 42, 0.18), 0 4px 16px rgba(15, 23, 42, 0.1);
  --scrollbar-thumb: #c3ccd6;
  --scrollbar-thumb-hover: #a9b4c0;
}

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

html {
  background: #000000;
}
[data-theme="light"] html, html[data-theme="light"] {
  background: #f1f5f9;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-content);
  color: var(--text-primary);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Theme transition — only on key containers, not every element */
body, .sidebar, .content, .card, .btn, .nav-item, .content-header, .landing {
  transition: background-color 0.25s ease, color 0.15s ease, border-color 0.25s ease;
}

/* ============================================================
   APP SHELL
   ============================================================ */

.app {
  display: flex;
  height: 100vh;
  opacity: 1;
  transition: opacity 0.15s ease;
}
.app.fade-hidden {
  opacity: 0;
}

/* ---- Sidebar ---- */

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
}

.sidebar-brand {
  padding: 20px 20px 24px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.sidebar-logo-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: white;
  box-shadow: none;
}

.sidebar-logo-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.sidebar-logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 8px;
}

.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  padding: 12px 12px 6px;
  font-weight: 600;
}

/* Sidebar nav items are <button>s (keyboard accessibility); strip the UA
   button chrome so the .nav-item / .sidebar-status-link classes fully style
   them. Keep this above the .nav-item rules so state rules still win. */
button.nav-item,
button.sidebar-status-link {
  background: none;
  border: none;
  font-family: inherit;
  margin: 0;
  text-align: left;
  color: inherit;
}
button.nav-item { color: var(--text-secondary); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  user-select: none;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.nav-item.active .nav-icon {
  color: var(--accent);
}

.nav-icon {
  width: 20px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
  background: var(--red-dim);
  color: var(--red);
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-demo-btn {
  width: 100%;
  margin-top: 4px;
  font-size: 12px;
  gap: 6px;
  padding: 6px 10px;
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  justify-content: center;
}

.sidebar-demo-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.sidebar-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.sidebar-footer-text {
  font-size: 12px;
  color: var(--text-muted);
}

.sidebar-status-link {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  padding: 4px 6px;
  margin: -4px -6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.sidebar-status-link:hover {
  background: var(--bg-card-hover);
}

.sidebar-status-chevron {
  margin-left: auto;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity var(--transition);
}

.sidebar-status-link:hover .sidebar-status-chevron {
  opacity: 1;
}

/* ---- App Footer ---- */

.app-footer {
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 12px;
}

.app-footer-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.app-footer-links a {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.app-footer-links a:hover {
  color: var(--accent);
}

.app-footer-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.4;
}

.app-footer-version {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.6;
  white-space: nowrap;
}

/* ---- Connection Health Page ---- */

.conn-status-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.conn-status-banner.conn-ok { background: var(--green-dim); border-color: rgba(34,197,94,0.2); }
.conn-status-banner.conn-warn { background: var(--yellow-dim); border-color: rgba(245,158,11,0.2); }
.conn-status-banner.conn-error { background: var(--red-dim); border-color: rgba(239,68,68,0.2); }

.conn-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse 2s infinite;
}

.conn-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.conn-detail-card {
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.conn-detail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.conn-detail-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.conn-detail-value.mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

.conn-sync-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.conn-sync-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.conn-sync-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.conn-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  flex-wrap: wrap;
}

/* ---- Content Area ---- */

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
  flex-shrink: 0;
}

.content-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.content-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin: 0; /* page titles are <h1>s; neutralize UA heading margins */
}

.content-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.content-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---- Theme Toggle ---- */
.theme-toggle {
  width: 42px;
  height: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: var(--transition);
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
}
[data-theme="light"] .theme-toggle-thumb { transform: translateX(18px); }

.content-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

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

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}

.card-body { padding: 0; }

/* ============================================================
   GRID LAYOUTS
   ============================================================ */

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.grid-6 { grid-template-columns: repeat(6, 1fr); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-full { grid-column: 1 / -1; }

/* ============================================================
   STAT CARDS
   ============================================================ */

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1.15;
  margin-top: 2px;
}

.stat-value.green, .green { color: var(--green); }
.stat-value.yellow, .yellow { color: var(--yellow); }
.stat-value.orange, .orange { color: var(--orange); }
.stat-value.red, .red { color: var(--red); }
.stat-value.blue, .blue { color: var(--blue); }
.stat-value.cyan, .cyan { color: var(--cyan); }

/* ============================================================
   LIST ITEMS
   ============================================================ */

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--bg-card-hover); }

.list-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.list-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.list-item-text { min-width: 0; }

.list-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-detail {
  font-size: 12px;
  color: var(--text-muted);
}

.list-item-right {
  text-align: right;
  flex-shrink: 0;
  margin-left: 16px;
}

.list-value {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
}

.list-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */

.progress-bar {
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 5px;
  width: 100px;
}

.progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}

/* ============================================================
   SEVERITY / STATUS TAGS
   ============================================================ */

.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: inline-block;
}

.tag-critical { background: var(--red-dim); color: var(--red); }
.tag-high { background: var(--orange-dim); color: var(--orange); }
.tag-medium { background: var(--yellow-dim); color: var(--yellow); }
.tag-accent { background: var(--accent-dim); color: var(--accent); }
.tag-low { background: var(--green-dim); color: var(--green); }
.tag-deduction { background: var(--blue-dim); color: var(--blue); }
.tag-waste { background: var(--red-dim); color: var(--red); }
.tag-receive { background: var(--green-dim); color: var(--green); }
.tag-info { background: var(--cyan-dim); color: var(--cyan); }

/* ============================================================
   WASTE SUMMARY BAR
   ============================================================ */

.waste-totals {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1px;
  background: var(--border);
}

.waste-period {
  background: var(--bg-card);
  padding: 16px 20px;
  text-align: center;
}

.waste-period-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.waste-period-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 800;
  color: var(--red);
  letter-spacing: -1px;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  /* Fixed hex (not var(--accent)): white-on-#8b5cf6 is 4.23:1 in the dark
     theme; #7c3aed clears 4.5:1 on both themes, #6d28d9 keeps hover ≥4.5. */
  background: #7c3aed;
  color: white;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.btn-primary:hover { background: #6d28d9; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.loading { opacity: 0.6; pointer-events: none; }

/* ============================================================
   SEARCH / INPUT
   ============================================================ */

.search-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 14px;
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
  width: 240px;
}

.search-input:focus {
  border-color: var(--accent);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.search-input::placeholder { color: var(--text-muted); }

/* ============================================================
   TABLE
   ============================================================ */

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 10px 20px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 20px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tr:hover td { background: var(--bg-card-hover); }
tr:last-child td { border-bottom: none; }

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {
  padding: 44px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  line-height: 1.5;
}

.empty-state svg {
  opacity: 0.2;
  stroke: var(--text-muted);
}

.empty-state-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.2px;
}

/* ============================================================
   LOADING
   ============================================================ */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 1000;
  transition: opacity 0.3s;
}

.loading-overlay.hidden { opacity: 0; pointer-events: none; }

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   PAGE: hidden by default, shown when active
   ============================================================ */

.page {
  display: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.page.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  opacity: 1;
}
.page.fade-out {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  opacity: 0;
}
.page.active > .content-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1100px) {
  .grid-4, .grid-6 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 800px) {
  .sidebar { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4, .grid-6 { grid-template-columns: repeat(2, 1fr); }
  .span-2, .span-3 { grid-column: span 1; }
  .content-body { padding: 16px; }
}

/* ============================================================
   MODALS
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.15s;
}

.modal-overlay.open { opacity: 1; }
.modal-overlay.closing { opacity: 0; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 480px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  transform: translateY(10px) scale(0.98);
  transition: transform 0.15s;
  box-shadow: var(--shadow-modal);
}

.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-lg { width: 640px; }
.modal-xl { width: 820px; }
.modal-sm { width: 380px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.modal-close:hover { color: var(--text-primary); }

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

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */

.form-group { margin-bottom: 0; }

/* Auth/login modal builds plain <input>s inside .form-group without the
   .form-input class, so without these they render as white browser-default
   boxes on the dark theme and sit flush against each other. Style them to
   match .form-input and give the fields breathing room. */
.modal-body .form-group { margin-bottom: 16px; }
.modal-body .form-group:last-of-type { margin-bottom: 0; }

.modal-body .form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.modal-body .form-group input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}

.modal-body .form-group input::placeholder { color: var(--text-muted); }

.modal-body .form-group input:focus {
  border-color: var(--accent);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}

.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}

.form-input:focus {
  border-color: var(--accent);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238a8aaa'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

[data-theme="light"] select.form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23475569'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

/* ============================================================
   TOASTS
   ============================================================ */

#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 280px;
  max-width: 400px;
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.3s;
  box-shadow: var(--shadow-pop);
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast strong { font-size: 13px; }
.toast span { font-size: 12px; color: var(--text-secondary); }

/* ============================================================
   DEMO BANNER
   ============================================================ */

.demo-banner {
  background: linear-gradient(90deg, var(--orange-dim), var(--yellow-dim));
  border-bottom: 1px solid rgba(249,115,22,0.2);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--orange);
  flex-shrink: 0;
  gap: 16px;
}

.demo-banner-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.demo-banner-label {
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.5px;
  background: var(--orange);
  color: #000;
  padding: 2px 8px;
  border-radius: 4px;
}

.demo-banner-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.demo-banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.demo-simulate-btn {
  display: inline-flex;
  align-items: center;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-ui);
  color: #fff;
  background: #c2410c; /* white-on-orange was 2.8:1 in dark theme; this is 5.2:1 */
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease;
  white-space: nowrap;
}

.demo-simulate-btn:hover {
  background: #9a3412;
}

.demo-simulate-btn:active {
  background: #7c2d12;
}

/* ============================================================
   TOUR TOOLTIPS
   ============================================================ */

.tour-tooltip {
  position: fixed;
  z-index: 4000;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 0;
  width: 340px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4), 0 0 0 2000px rgba(0,0,0,0.6);
  opacity: 0;
  transform: translateY(6px);
  transition: all 0.25s;
}

.tour-tooltip.show { opacity: 1; transform: translateY(0); }

.tour-tooltip-header {
  padding: 14px 18px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.tour-tooltip-step {
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

.tour-tooltip-title {
  font-size: 15px;
  font-weight: 700;
}

.tour-tooltip-text {
  padding: 10px 18px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.tour-tooltip-keys {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 6px 18px 0;
  font-size: 11px;
  color: var(--text-muted);
}

.tour-tooltip-footer {
  padding: 10px 18px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
}

.tour-btn { font-size: 12px !important; padding: 5px 12px !important; }

.tour-highlight {
  position: relative;
  z-index: 3999;
  box-shadow: 0 0 0 3px var(--accent);
  border-radius: var(--radius-sm);
}

/* ============================================================
   LANDING PAGE
   ============================================================ */

.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  gap: 32px;
  padding: 48px 20px;
  position: relative;
  overflow: hidden;
  opacity: 1;
  transition: opacity 0.15s ease;
}
.landing.fade-hidden {
  opacity: 0;
}

/* Ambient purple glow behind the hero */
.landing-glow {
  position: absolute;
  top: -18%;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 700px;
  max-width: 150vw;
  background: radial-gradient(closest-side, rgba(139,92,246,0.20), rgba(139,92,246,0.05) 58%, transparent 74%);
  pointer-events: none;
  z-index: 0;
}

.landing-hero {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 540px;
  gap: 18px;
}

.landing-logo-icon {
  width: 68px;
  height: 68px;
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 26px;
  color: #fff;
  box-shadow: 0 12px 40px rgba(139,92,246,0.35);
}

.landing-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 13px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.02);
}
.landing-badge-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.landing-title {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.05;
  margin: 0;
  background: linear-gradient(180deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.landing-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.6;
  margin: 0;
  max-width: 450px;
}

.landing-features {
  list-style: none;
  padding: 0;
  margin: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
  text-align: left;
}
.landing-features li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-primary);
}
.lf-check {
  width: 20px; height: 20px;
  flex: none;
  border-radius: 50%;
  background: var(--green-dim);
  color: var(--green);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
}

.landing-ctas {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: 100%;
  max-width: 340px;
  margin-top: 12px;
}

.landing-cta-primary {
  padding: 14px 40px;
  font-size: 16px;
  font-weight: 700;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 30px rgba(139,92,246,0.30);
}

.landing-cta-alt {
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}
.landing-cta-alt:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
}

.landing-cta-secondary {
  padding: 10px 28px;
  font-size: 14px;
  color: var(--text-secondary);
  border-color: transparent;
}

.landing-cta-secondary:hover {
  color: var(--accent);
}

.landing-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.landing-footer a {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.landing-footer a:hover {
  color: var(--accent);
}

/* ============================================================
   ONBOARDING WIZARD
   ============================================================ */

.onboarding {
  min-height: 100vh;
  background: var(--bg-primary);
  display: flex;
  opacity: 1;
  transition: opacity 0.15s ease;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  overflow-y: auto;
}

.onboarding-container {
  width: 680px;
  max-width: 95vw;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
}

@media (max-width: 600px) {
  .onboarding {
    align-items: flex-start;
    padding: 12px;
  }
  .onboarding-container {
    max-height: none;
    width: 100%;
  }
  .ob-title { font-size: 22px; }
  .ob-subtitle { font-size: 14px; margin-bottom: 20px; }
  .onboarding-nav {
    position: sticky;
    bottom: 0;
    background: var(--bg-primary);
    padding: 16px 0 12px;
    margin-top: 20px;
  }
}

.onboarding-progress {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 24px;
}

.onboarding-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #7c3aed, #a78bfa);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.onboarding-steps-indicator {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 32px;
}

.ob-step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: all 0.3s;
}

.ob-step-dot.active {
  background: var(--accent);
  width: 24px;
  border-radius: 4px;
}

.ob-step-dot.done {
  background: var(--green);
}

.onboarding-content {
  flex: 1;
  overflow-y: auto;
  animation: obFadeIn 0.3s ease;
}

@keyframes obFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.onboarding-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.ob-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.ob-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 28px;
}

.ob-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 12px;
  transition: all 0.15s;
}

.ob-card:hover {
  border-color: var(--border-light);
}

.ob-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ob-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 16px;
}

.ob-card-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ob-card-text h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.ob-card-text p {
  font-size: 13px;
  color: var(--text-muted);
}

.ob-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.ob-check.done {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.ob-feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.ob-feature {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.ob-feature h4 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.ob-feature p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.ob-inline-form {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 10px;
  align-items: end;
  margin-bottom: 8px;
}

.ob-inline-form-4 {
  grid-template-columns: 2fr 1fr 1fr auto;
}

.ob-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.ob-item-row:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
}

.ob-item-row.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* ============================================================
   AI ASSISTANT CHAT
   ============================================================ */

.ai-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px 40px;
}

.ai-welcome-icon {
  width: 48px;
  height: 48px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 20px;
  color: var(--text-secondary);
}

.ai-suggestion-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  padding: 8px 16px;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}

.ai-suggestion-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.ai-chat-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color var(--transition);
}

.ai-chat-input:focus {
  border-color: var(--accent);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.ai-send-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: var(--radius);
}

.ai-msg {
  display: flex;
  gap: 12px;
  max-width: 85%;
  animation: aiMsgIn 0.25s ease;
}

@keyframes aiMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ai-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.ai-msg.assistant .ai-msg-avatar {
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  color: white;
}

.ai-msg.user .ai-msg-avatar {
  background: var(--green-dim);
  color: var(--green);
}

.ai-msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-primary);
}

.ai-msg.user .ai-msg-bubble {
  background: var(--accent-dim);
  border-color: rgba(99, 102, 241, 0.2);
}

.ai-msg-bubble p { margin-bottom: 8px; }
.ai-msg-bubble p:last-child { margin-bottom: 0; }
.ai-msg-bubble ul, .ai-msg-bubble ol { padding-left: 18px; margin-bottom: 8px; }
.ai-msg-bubble li { margin-bottom: 4px; }
.ai-msg-bubble strong { color: var(--accent); font-weight: 600; }
.ai-msg-bubble code {
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.ai-msg-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  gap: 10px;
}

.ai-typing {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.ai-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: aiTyping 1.2s infinite;
}

.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aiTyping {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* ============================================================
   PREMIUM DASHBOARD COMPONENTS
   ============================================================ */

/* ---- Live Pill ---- */
.dash-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--green-dim);
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dash-live-pill-sm {
  padding: 2px 8px;
  font-size: 10px;
}

.dash-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: dashPulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes dashPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* ---- KPI Cards Row ---- */
.dash-kpi-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.dash-kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 18px 14px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.dash-kpi::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--kpi-color, var(--accent));
  /* no glow — just the color bar */
}

.dash-kpi:hover {
  border-color: var(--border-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-card);
}

.dash-kpi-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.dash-kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--kpi-dim, var(--accent-dim));
  color: var(--kpi-color, var(--accent));
}

.dash-kpi-icon svg {
  stroke: var(--kpi-color, var(--accent));
}

.dash-kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.dash-kpi-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.dash-kpi-footer {
  margin-top: 8px;
}

.dash-kpi-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.2px;
}

.dash-kpi-status.good { background: var(--green-dim); color: var(--green); }
.dash-kpi-status.warn { background: var(--yellow-dim); color: var(--yellow); }
.dash-kpi-status.bad { background: var(--red-dim); color: var(--red); }
.dash-kpi-status.neutral { background: var(--bg-input); color: var(--text-muted); }

/* ---- Enhanced Card Headers ---- */
.dash-card .card-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dash-card .card-title svg {
  opacity: 0.5;
}

/* ---- Card Visual Weight System ---- */
.dash-card--critical {
  border-left: 3px solid var(--red);
  box-shadow: inset 3px 0 12px -4px rgba(239, 68, 68, 0.08);
}

.dash-card--critical .card-header {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.03) 0%, transparent 60%);
}

.dash-card--warning {
  border-left: 3px solid var(--yellow);
  box-shadow: inset 3px 0 12px -4px rgba(245, 158, 11, 0.08);
}

.dash-card--warning .card-header {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.03) 0%, transparent 60%);
}

.dash-card--live {
  border-left: 3px solid var(--green);
  box-shadow: inset 3px 0 12px -4px rgba(34, 197, 94, 0.08);
}

.dash-card--live .card-header {
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.03) 0%, transparent 60%);
}

.dash-card--info {
  border-left: 2px solid var(--blue);
  box-shadow: inset 2px 0 10px -4px rgba(59, 130, 246, 0.06);
}

/* ---- Responsive KPI ---- */
@media (max-width: 1200px) {
  .dash-kpi-row { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 800px) {
  .dash-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .dash-kpi-value { font-size: 22px; }
}

/* Skip-to-content link: hidden offscreen until keyboard-focused. */
.skip-link {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 3000;
  background: #6d28d9;
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus {
  transform: none;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Screen-reader-only utility for accessible labels on icon-only
   controls. Visible to assistive tech, invisible to sighted users. */
.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;
}

/* ============================================================
   MOBILE & TABLET RESPONSIVENESS
   Required for Clover App Market review — merchants run POS on
   iPad in landscape (~1024px) and phones (320-414px). Without
   these rules, the modal overflows the viewport on phones, the
   action-button row escapes off-screen, and inventory tables
   are unreachable past the visible columns.
   ============================================================ */

/* Phones: ≤600px ------------------------------------------------ */
@media (max-width: 600px) {
  /* Modal must fit the viewport. Hard 480px width on a 360px phone
     left the right edge unreachable. */
  .modal,
  .modal-sm,
  .modal-lg,
  .modal-xl {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
  }
  .modal-body { padding: 14px 16px; }
  .modal-header, .modal-footer { padding: 12px 16px; }

  /* Action button rows: let buttons wrap instead of escaping the
     viewport. Was display:flex with no flex-wrap, so the third
     button slid off the right edge. */
  .content-header-right {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
  }
  .content-header-right .btn { flex: 1 1 auto; min-width: 0; }

  /* Inventory and other data tables: scroll horizontally with a
     visible scrollbar so users know there's more content. The
     `overflow-x: auto` was already set but the scrollbar was hidden
     in some browsers. */
  .table-wrap {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .table-wrap::after {
    content: '';
    display: block;
    height: 4px;
  }

  /* Form fields gain breathing room so 16px+ tap targets aren't
     cramped on a phone. */
  input, select, textarea, .btn {
    min-height: 40px;
    font-size: 16px; /* iOS Safari does not auto-zoom on focus when font-size ≥ 16px */
  }

  /* Toasts pinned bottom-right slip off-screen on narrow phones. */
  .toast, .toast-container { max-width: calc(100vw - 24px); }

  /* Page padding compressed so the content gets the most width. */
  .content-body { padding: 12px; }
}

/* Tablets in portrait + landscape: 601-1024px ------------------- */
@media (min-width: 601px) and (max-width: 1024px) {
  /* iPad landscape is 1024px — the sidebar-hidden breakpoint at 800px
     skips it. Re-show the sidebar for tablets that have room. */
  .content-header-right {
    flex-wrap: wrap;
    gap: 10px;
  }
  /* Modal capped at 90vw so it doesn't push past landscape iPad
     bezels in some browser chromes. */
  .modal, .modal-lg, .modal-xl { max-width: 90vw; }
}

/* ============================================================
   FINISH — scrollbars, selection, focus rings, numerals, motion
   ============================================================ */

::selection {
  background: rgba(139, 92, 246, 0.35);
}
[data-theme="light"] ::selection {
  background: rgba(124, 58, 237, 0.18);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

/* Keyboard focus — visible ring on interactive elements, none on click */
.btn:focus-visible,
.nav-item:focus-visible,
.theme-toggle:focus-visible,
.modal-close:focus-visible,
.ai-suggestion-btn:focus-visible,
.sidebar-status-link:focus-visible,
.demo-simulate-btn:focus-visible,
.ob-item-row:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Numbers align in columns everywhere they're compared vertically */
.stat-value,
.list-value,
.waste-period-value,
.conn-detail-value,
.dash-kpi-value,
td {
  font-variant-numeric: tabular-nums;
}

th {
  background: rgba(255, 255, 255, 0.02);
}
[data-theme="light"] th {
  background: rgba(15, 23, 42, 0.03);
}

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

/* ---- Location switcher (multi-location sessions, locations.js) ---- */
.loc-switch { position: relative; margin: 2px 12px 10px; }
.loc-switch-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: border-color var(--transition);
}
.loc-switch-btn:hover { border-color: var(--border-light); }
.loc-switch-btn > svg:last-child { margin-left: auto; color: var(--text-muted); flex-shrink: 0; }
.loc-switch-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loc-switch-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 5px;
  z-index: 300;
  box-shadow: var(--shadow-card);
}
.loc-switch-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 7px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.loc-switch-item:hover { background: var(--bg-card-hover); }
.loc-switch-item .loc-check { color: var(--accent); margin-left: auto; font-weight: 800; }
.loc-switch-item .loc-remove {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  padding: 0 3px;
  border-radius: 4px;
}
.loc-switch-item .loc-remove:hover { color: var(--red); background: var(--red-dim); }
.loc-switch-add { color: var(--accent); border-top: 1px solid var(--border); border-radius: 0 0 7px 7px; margin-top: 4px; padding-top: 10px; }

/* ============================================================
   SETUP GUIDE — the always-available step-by-step onboarding page.
   Distinct from the first-run wizard (#onboarding-page): this lives in
   the main app nav so a merchant can finish setup over days and always
   see exactly what to do next. It reuses the existing add/edit modals;
   loadSetup() in dashboard.js renders into #page-setup.
   ============================================================ */
.setup-hero { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }
.setup-progress-ring { --pct: 0; width: 66px; height: 66px; border-radius: 50%; flex-shrink: 0;
  background: conic-gradient(var(--green) calc(var(--pct) * 1%), var(--bg-input) 0);
  display: flex; align-items: center; justify-content: center; }
.setup-progress-ring > span { width: 52px; height: 52px; border-radius: 50%; background: var(--bg-card);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; color: var(--text-primary); }
.setup-hero-copy h1 { font-size: 20px; margin: 0 0 4px; }
.setup-hero-copy p { font-size: 13px; color: var(--text-muted); margin: 0; max-width: 60ch; line-height: 1.5; }

.setup-steps { display: flex; flex-direction: column; gap: 12px; }
.setup-step { display: flex; gap: 16px; padding: 18px 20px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-lg); transition: border-color .2s, opacity .2s; }
.setup-step.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.setup-step.done { opacity: .82; }
.setup-step.locked { opacity: .55; }
.setup-step-num { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; display: flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
  background: var(--bg-input); color: var(--text-muted); border: 1px solid var(--border); }
.setup-step.active .setup-step-num { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
.setup-step.done .setup-step-num { background: var(--green-dim); color: var(--green); border-color: var(--green); }
.setup-step-body { flex: 1; min-width: 0; }
.setup-step-title { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; }
.setup-step-why { font-size: 12.5px; color: var(--text-muted); line-height: 1.55; margin: 5px 0 0; max-width: 68ch; }
.setup-step-stat { font-size: 12px; color: var(--text-secondary); margin-top: 10px; }
.setup-step-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.setup-bar { height: 7px; background: var(--bg-primary); border-radius: 4px; overflow: hidden; margin-top: 10px; max-width: 340px; }
.setup-bar > span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.setup-punch { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.setup-punch-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg-primary);
  border: 1px solid var(--border); border-radius: var(--radius-sm); }
.setup-punch-row .name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.setup-done-banner { display: flex; align-items: center; gap: 14px; padding: 20px 24px; margin-bottom: 20px;
  background: var(--green-dim); border: 1px solid var(--green); border-radius: var(--radius-lg); }
.setup-done-banner .tick { width: 40px; height: 40px; border-radius: 50%; background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* ============================================================
   BILLING — lock overlay (402 from billingGate) + checkout return.
   Full-viewport and above everything: a locked tenant must not be able
   to interact with the app behind it.
   ============================================================ */
.billing-lock { position: fixed; inset: 0; z-index: 4000; display: flex; align-items: center;
  justify-content: center; padding: 24px; background: var(--bg-primary); }
.billing-lock-card { max-width: 420px; width: 100%; text-align: center; padding: 36px 32px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.billing-lock-logo { width: 52px; height: 52px; margin: 0 auto 16px; border-radius: 13px;
  background: linear-gradient(135deg, #7c3aed, #a78bfa); color: #fff; font-weight: 800;
  font-size: 19px; display: flex; align-items: center; justify-content: center; }
.billing-lock-card h2 { font-size: 20px; margin: 0 0 10px; }
.billing-lock-card p { font-size: 13.5px; color: var(--text-secondary); line-height: 1.6; margin: 0 0 18px; }
.billing-lock-price { font-size: 14px; color: var(--text-muted); margin-bottom: 18px; }
.billing-lock-price span { font-size: 30px; font-weight: 800; color: var(--text-primary); }
.billing-lock-card .btn { width: 100%; padding: 12px; font-size: 14px; }
.billing-lock-foot { margin-top: 16px; font-size: 12px; color: var(--text-muted);
  display: flex; gap: 8px; justify-content: center; }
.billing-lock-foot a { color: var(--text-secondary); }
.billing-activating { position: fixed; inset: 0; z-index: 4000; display: flex; align-items: center;
  justify-content: center; background: var(--bg-primary); color: var(--text-secondary); font-size: 14px; }

/* Dashboard nudge — rendered into #dash-ops-bar by refreshSetupBadge() when
   setup is unfinished; drives merchants back into the Setup Guide. */
.setup-nudge { display: flex; align-items: center; gap: 14px; padding: 14px 18px;
  background: var(--accent-dim); border: 1px solid var(--accent); border-radius: var(--radius-lg); }
.setup-nudge > svg { color: var(--accent); flex-shrink: 0; }
.setup-nudge-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.setup-nudge-copy strong { font-size: 14px; }
.setup-nudge-copy span { font-size: 12.5px; color: var(--text-secondary); }
.setup-nudge .btn { margin-left: auto; flex-shrink: 0; }
/* ======== REPORTS PAGE ======== */
.report-filter-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.report-range-pill {
  padding: 7px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--bg-card); color: var(--text-secondary);
  border: 1px solid var(--border); cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.report-range-pill:hover { color: var(--text-primary); border-color: var(--accent); }
.report-range-pill.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.report-custom-range { display: inline-flex; align-items: center; gap: 6px; margin-left: 4px; }
.report-custom-range input[type="date"] {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-primary);
  border-radius: 8px; padding: 6px 10px; font-size: 12.5px; font-family: inherit;
  color-scheme: dark;
}
:root[data-theme="light"] .report-custom-range input[type="date"] { color-scheme: light; }
.report-range-sep { color: var(--text-muted); font-size: 12px; }

.card-subtitle { font-size: 12px; color: var(--text-muted); }

.report-tabs { display: inline-flex; gap: 4px; background: var(--bg-elevated); border-radius: 999px; padding: 3px; }
.report-tab {
  border: none; background: transparent; color: var(--text-secondary);
  font-size: 12.5px; font-weight: 600; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  transition: color .15s, background .15s;
}
.report-tab:hover { color: var(--text-primary); }
.report-tab.active { background: var(--accent); color: #fff; }

/* Daily chart: plain-HTML column chart. Bars are the only saturated ink;
   grid hairlines and axis text stay recessive per the marks spec. */
.report-chart { position: relative; height: 220px; }
.report-chart-empty {
  height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 13px;
}
.report-chart svg { display: block; width: 100%; height: 100%; }
.report-chart .rc-grid { stroke: var(--border); stroke-width: 1; }
.report-chart .rc-bar { fill: var(--accent); }
.report-chart .rc-bar-hit { fill: transparent; cursor: pointer; }
.report-chart .rc-axis-label { fill: var(--text-muted); font-size: 10.5px; font-family: inherit; }
.report-chart .rc-tick-label { fill: var(--text-muted); font-size: 10.5px; font-family: inherit; font-variant-numeric: tabular-nums; }
.report-chart .rc-direct-label { fill: var(--text-secondary); font-size: 11px; font-weight: 600; font-family: inherit; }
.report-tooltip {
  position: fixed; z-index: 300; pointer-events: none;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-size: 12px; color: var(--text-primary);
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  opacity: 0; transition: opacity .1s;
}
.report-tooltip.visible { opacity: 1; }
.report-tooltip .rt-day { color: var(--text-muted); font-size: 11px; margin-bottom: 3px; }
.report-tooltip .rt-line { display: flex; justify-content: space-between; gap: 16px; }
.report-tooltip .rt-val { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Breakdown table: share bar carries magnitude; text stays in text tokens. */
.report-table { width: 100%; border-collapse: collapse; }
.report-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); padding: 8px 12px; border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.report-table td { padding: 10px 12px; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.report-table tr:last-child td { border-bottom: none; }
.report-table td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.report-table th.num { text-align: right; }
.report-share-cell { min-width: 120px; }
.report-share-track {
  height: 6px; border-radius: 4px; background: var(--bg-elevated); overflow: hidden;
}
.report-share-fill { height: 100%; border-radius: 4px; background: var(--accent); }
.report-empty {
  padding: 32px; text-align: center; color: var(--text-muted); font-size: 13px;
}
@media (max-width: 720px) {
  .report-custom-range { margin-left: 0; }
  .report-tabs { margin-top: 8px; }
  .report-share-cell { min-width: 70px; }
}
