/* ==========================================================================
   AI Price Radar — FinTech Trading-Terminal Design System
   Antigravity Typography (Google Sans + Google Sans Code + Tabular Nums)
   Minimum font-size >= 12px (0.75rem) enforced across all visible elements.
   ========================================================================== */

:root,
html[data-theme="light"] {
  --font-sans: 'Google Sans', 'Google Sans Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
  --font-mono: 'Google Sans Code', 'Google Sans', ui-monospace, SFMono-Regular, 'Segoe UI', sans-serif;

  /* Surfaces */
  --bg-app: #f4f6fa;
  --bg-surface: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-elevated: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-hover: #f1f5f9;
  --bg-active-nav: #eff6ff;
  --bg-input: #ffffff;
  --bg-code: #f1f5f9;

  /* Borders */
  --border-subtle: #e5eaf2;
  --border-strong: #cbd5e1;
  --border-focus: #2563eb;

  /* Typography */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  /* Brand & Semantic Accents */
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #eff6ff;
  --accent-border: #bfdbfe;

  --emerald: #047857;
  --emerald-bright: #10b981;
  --emerald-soft: #ecfdf5;
  --emerald-border: #a7f3d0;

  --amber: #b45309;
  --amber-bright: #f59e0b;
  --amber-soft: #fffbeb;
  --amber-border: #fde68a;

  --rose: #be123c;
  --rose-bright: #f43f5e;
  --rose-soft: #fff1f2;
  --rose-border: #fecdd3;

  --indigo: #4338ca;
  --indigo-soft: #eef2ff;
  --indigo-border: #c7d2fe;

  --orange: #c2410c;
  --orange-soft: #fff7ed;
  --orange-border: #fed7aa;

  /* Market Series Colors */
  --series-vntg: #10b981;
  --series-vnweb: #2563eb;
  --series-cn: #f59e0b;
  --series-global: #8b5cf6;

  /* Shadows & Radii */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px -4px rgba(15, 23, 42, 0.1), 0 2px 6px rgba(15, 23, 42, 0.05);
  --shadow-drawer: -12px 0 36px rgba(15, 23, 42, 0.16);
  --scrim: rgba(15, 23, 42, 0.45);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 999px;

  --sidebar-width: 280px;
  --sidebar-collapsed: 74px;
}

html[data-theme="dark"] {
  --bg-app: #0b1120;
  --bg-surface: #11192b;
  --bg-subtle: #162136;
  --bg-elevated: #1a263f;
  --bg-sidebar: #0e1526;
  --bg-hover: #1a2740;
  --bg-active-nav: rgba(59, 130, 246, 0.16);
  --bg-input: #0e1628;
  --bg-code: #18243b;

  --border-subtle: #1e2d47;
  --border-strong: #324669;
  --border-focus: #60a5fa;

  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverse: #0b1120;

  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-soft: rgba(59, 130, 246, 0.15);
  --accent-border: rgba(96, 165, 250, 0.35);

  --emerald: #34d399;
  --emerald-bright: #10b981;
  --emerald-soft: rgba(16, 185, 129, 0.14);
  --emerald-border: rgba(52, 211, 153, 0.32);

  --amber: #fbbf24;
  --amber-bright: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --amber-border: rgba(251, 191, 36, 0.32);

  --rose: #fb7185;
  --rose-bright: #f43f5e;
  --rose-soft: rgba(244, 63, 94, 0.15);
  --rose-border: rgba(251, 113, 133, 0.35);

  --indigo: #a5b4fc;
  --indigo-soft: rgba(99, 102, 241, 0.16);
  --indigo-border: rgba(165, 180, 252, 0.35);

  --orange: #fdba74;
  --orange-soft: rgba(249, 115, 22, 0.15);
  --orange-border: rgba(253, 186, 116, 0.35);

  --series-vntg: #34d399;
  --series-vnweb: #60a5fa;
  --series-cn: #fbbf24;
  --series-global: #a78bfa;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.34);
  --shadow-md: 0 12px 28px rgba(0, 0, 0, 0.45);
  --shadow-drawer: -14px 0 42px rgba(0, 0, 0, 0.6);
  --scrim: rgba(2, 6, 23, 0.68);
}

/* Font scale switcher (base 16px => 0.75rem == 12px floor!) */
html { font-size: 16px; }
html[data-font-scale="100"] { font-size: 16px; }
html[data-font-scale="110"] { font-size: 17.6px; }
html[data-font-scale="120"] { font-size: 19.2px; }

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Enforce >= 12px floor even on sub/sup/small/kbd */
sub, sup, small, kbd, code {
  font-size: 0.75rem;
  line-height: 1.2;
}
sub { vertical-align: baseline; position: relative; top: 0.18em; }

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button, input, select, textarea {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

.mono-code {
  font-family: var(--font-mono) !important;
  font-variant-numeric: tabular-nums;
}

.is-hidden {
  display: none !important;
}

.text-right { text-align: right; }
.text-emerald { color: var(--emerald); }
.text-rose { color: var(--rose); }
.text-amber { color: var(--amber); }
.text-muted { color: var(--text-muted); }

/* ==========================================================================
   APP SHELL & LEFT SIDEBAR
   ========================================================================== */
.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 40;
  height: 56px;
  padding: 0 14px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-subtle);
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.9375rem;
}

.brand-logo-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
}

.btn-sync-mini {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
}

.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: 48;
}
.sidebar-scrim.is-open {
  display: block;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: width 0.2s ease, transform 0.22s ease;
}

.app-shell.is-collapsed .sidebar {
  width: var(--sidebar-collapsed);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border-subtle);
  gap: 8px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #1d4ed8 0%, #0ea5e9 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(29, 78, 216, 0.28);
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
  white-space: nowrap;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-close-mobile {
  display: none;
}

/* Sidebar Sync Card */
.sidebar-sync-panel {
  margin: 12px 12px 8px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sync-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald-bright);
  box-shadow: 0 0 0 3px var(--emerald-soft);
  flex-shrink: 0;
}
.live-dot.is-syncing {
  background: var(--amber-bright);
  box-shadow: 0 0 0 3px var(--amber-soft);
  animation: pulseDot 1.2s infinite;
}
.live-dot.is-error {
  background: var(--rose-bright);
  box-shadow: 0 0 0 3px var(--rose-soft);
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.65; }
}

.sync-status-text {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sync-meta-row {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-sync-primary {
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-size: 0.8125rem;
  font-weight: 600;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}
html[data-theme="dark"] .btn-sync-primary {
  background: #2563eb;
  border-color: #3b82f6;
  color: #ffffff;
}
.btn-sync-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}
.btn-sync-primary:disabled {
  opacity: 0.7;
  cursor: wait;
}

.is-spinning {
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Sidebar Search */
.sidebar-search-wrap {
  position: relative;
  margin: 4px 12px 8px;
}
.search-lead-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.sidebar-search-input {
  width: 100%;
  padding: 7px 10px 7px 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  font-size: 0.8125rem;
  color: var(--text-primary);
}
.sidebar-search-input:focus {
  border-color: var(--border-focus);
  outline: none;
}

/* Sidebar Nav Groups */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 12px;
}

.nav-group {
  margin-bottom: 14px;
}

.nav-group-label {
  padding: 6px 10px 5px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: left;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.is-active {
  background: var(--bg-active-nav);
  border-color: var(--accent-border);
  color: var(--accent);
  font-weight: 600;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: var(--bg-hover);
  color: var(--text-secondary);
  flex-shrink: 0;
}
.nav-item.is-active .nav-badge {
  background: var(--accent);
  color: #ffffff;
}
html[data-theme="dark"] .nav-item.is-active .nav-badge {
  background: #2563eb;
  color: #ffffff;
}

.seg-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  margin: 0 5px;
}
.seg-ultra20x { background: #1d4ed8; }
.seg-ultra5x { background: #3b82f6; }
.seg-pro { background: #0ea5e9; }
.seg-ag { background: #10b981; }
.seg-chatgpt { background: #059669; }
.seg-claude { background: #d97706; }
.seg-cursor { background: #6366f1; }
.seg-grok { background: #64748b; }
.seg-token { background: #ec4899; }
.seg-other { background: #94a3b8; }

/* Sidebar Footer */
.sidebar-footer {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.control-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 600;
}
.theme-toggle-btn:hover {
  border-color: var(--border-strong);
}
html[data-theme="light"] .theme-icon-dark { display: none; }
html[data-theme="dark"] .theme-icon-light { display: none; }

.font-scale-group {
  display: inline-flex;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-surface);
}
.scale-btn {
  border: none;
  background: transparent;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.scale-btn + .scale-btn {
  border-left: 1px solid var(--border-subtle);
}
.scale-btn.is-active {
  background: var(--accent);
  color: #ffffff;
}
html[data-theme="dark"] .scale-btn.is-active {
  background: #2563eb;
  color: #ffffff;
}

/* Desktop Collapsed Sidebar State */
.app-shell.is-collapsed .brand-text,
.app-shell.is-collapsed .sync-status-row,
.app-shell.is-collapsed .sync-meta-row,
.app-shell.is-collapsed .btn-sync-label,
.app-shell.is-collapsed .sidebar-search-wrap,
.app-shell.is-collapsed .nav-group-label,
.app-shell.is-collapsed .nav-label,
.app-shell.is-collapsed .nav-badge,
.app-shell.is-collapsed .control-label,
.app-shell.is-collapsed .theme-label-text,
.app-shell.is-collapsed .font-scale-group {
  display: none;
}
.app-shell.is-collapsed .sidebar-header {
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  padding: 12px 8px;
}
.app-shell.is-collapsed .sidebar-sync-panel {
  margin: 8px;
  padding: 6px;
}
.app-shell.is-collapsed .nav-item {
  justify-content: center;
  padding: 10px 8px;
}
.app-shell.is-collapsed .control-row {
  justify-content: center;
}

/* ==========================================================================
   MAIN WORKSPACE & HEADER
   ========================================================================== */
.main-workspace {
  flex: 1;
  min-width: 0;
  padding: 20px 26px 40px;
  max-width: 1580px;
  margin: 0 auto;
  width: 100%;
}

.workspace-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.workspace-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.mode-switcher {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-xs);
}

.mode-btn {
  border: none;
  background: transparent;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.14s ease;
}

.mode-btn.is-active {
  background: var(--accent);
  color: #ffffff;
}
html[data-theme="dark"] .mode-btn.is-active {
  background: #2563eb;
  color: #ffffff;
}

.watchlist-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.workspace-title {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.workspace-subtitle {
  margin: 4px 0 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.workspace-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.fx-ticker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.fx-pill {
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.fx-pill strong {
  color: var(--text-primary);
  margin-left: 3px;
}

.btn-outline-sm,
.btn-ghost-sm,
.btn-primary-sm,
.btn-danger-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  transition: background-color 0.14s ease, border-color 0.14s ease;
  white-space: nowrap;
}

.btn-outline-sm {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
}
.btn-outline-sm:hover {
  background: var(--bg-hover);
}

.btn-ghost-sm {
  background: transparent;
  border: 1px solid transparent;
  color: var(--accent);
}
.btn-ghost-sm:hover {
  background: var(--accent-soft);
}

.btn-primary-sm {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #ffffff;
}
html[data-theme="dark"] .btn-primary-sm {
  background: #2563eb;
  border-color: #3b82f6;
}
.btn-primary-sm:hover {
  background: var(--accent-hover);
}

.btn-danger-sm {
  background: var(--rose-soft);
  border: 1px solid var(--rose-border);
  color: var(--rose);
}
.btn-danger-sm:hover {
  filter: brightness(0.96);
}

.kbd-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.global-error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius-md);
  background: var(--rose-soft);
  border: 1px solid var(--rose-border);
  color: var(--rose);
  font-size: 0.875rem;
  font-weight: 500;
}
.global-error-banner span { flex: 1; }

.view-section {
  display: none;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  max-width: 100%;
}
.view-section.is-active {
  display: flex;
}

/* ==========================================================================
   COMMON CARDS, BANNERS & KPI GRID
   ========================================================================== */
.panel-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  min-width: 0;
  max-width: 100%;
}

.panel-card.table-panel {
  padding: 0;
  overflow: hidden;
}
.panel-card.table-panel .panel-header {
  padding: 16px 20px 12px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border-subtle);
}

.filter-panel-compact {
  padding: 12px 16px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.panel-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.panel-desc {
  margin: 3px 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.panel-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 16px 0 12px;
}

.panel-subheader {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

/* Purge Health Banner */
.purge-banner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--emerald-border);
  background: var(--emerald-soft);
}
.purge-banner.status-elevated {
  border-color: var(--amber-border);
  background: var(--amber-soft);
}
.purge-banner.status-purge_alert {
  border-color: var(--rose-border);
  background: var(--rose-soft);
}

.purge-banner-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--bg-surface);
  color: var(--emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}
.purge-banner.status-elevated .purge-banner-icon { color: var(--amber); }
.purge-banner.status-purge_alert .purge-banner-icon { color: var(--rose); }

.purge-banner-body {
  flex: 1;
  min-width: 0;
}
.purge-banner-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.purge-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--emerald);
  color: #ffffff;
}
.purge-banner.status-elevated .purge-badge { background: var(--amber); }
.purge-banner.status-purge_alert .purge-badge { background: var(--rose); }

.purge-headline {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}
.purge-metrics {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}
.kpi-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.kpi-card.is-clickable {
  cursor: pointer;
}
.kpi-card.is-clickable:hover {
  border-color: var(--accent-border);
  transform: translateY(-1px);
}

.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.kpi-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}
.kpi-icon-dot {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  color: var(--accent);
}
.kpi-icon-dot.is-emerald { background: var(--emerald-soft); color: var(--emerald); }
.kpi-icon-dot.is-amber { background: var(--amber-soft); color: var(--amber); }
.kpi-icon-dot.is-rose { background: var(--rose-soft); color: var(--rose); }
.kpi-icon-dot.is-indigo { background: var(--indigo-soft); color: var(--indigo); }

.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Skeleton Loader */
.skeleton-card { gap: 10px; }
.skeleton-line {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-subtle) 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}
.skeleton-line.w-40 { width: 45%; }
.skeleton-line.w-70 { width: 75%; }
.skeleton-line.h-lg { height: 28px; }
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==========================================================================
   OVERVIEW ANALYTICS: SVG CHART & REGION BREAKDOWN
   ========================================================================== */
.overview-analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr);
  gap: 16px;
}

.segmented-control {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
}
.seg-tab {
  border: none;
  background: transparent;
  padding: 5px 11px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.seg-tab.is-active {
  background: var(--bg-surface);
  color: var(--accent);
  box-shadow: var(--shadow-xs);
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  display: inline-block;
}
.swatch-vntg { background: var(--series-vntg); }
.swatch-vnweb { background: var(--series-vnweb); }
.swatch-cn { background: var(--series-cn); }
.swatch-global { background: var(--series-global); }

.svg-chart-wrap {
  position: relative;
  width: 100%;
  overflow-x: auto;
}
.svg-chart-wrap svg {
  display: block;
  width: 100%;
  height: auto;
  min-width: 560px;
}
.chart-axis-text {
  fill: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
}
.chart-bar-label {
  fill: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
}
.chart-grid-line {
  stroke: var(--border-subtle);
  stroke-dasharray: 3 3;
}
.chart-bar-rect {
  cursor: pointer;
  transition: opacity 0.14s ease;
}
.chart-bar-rect:hover {
  opacity: 0.82;
}
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 20;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  font-size: 0.75rem;
  color: var(--text-primary);
  min-width: 190px;
}

/* Region bars & Brand chips */
.region-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.region-bar-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
}
.region-bar-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8125rem;
}
.region-bar-name {
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.region-bar-track {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--bg-hover);
  overflow: hidden;
}
.region-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.brand-chip-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.brand-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.14s ease;
}
.brand-chip:hover {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
}
.brand-chip-count {
  color: var(--text-muted);
}

/* Arbitrage Opportunity Cards */
.arb-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.arb-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.arb-card:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-sm);
}

.arb-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.arb-card-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  min-width: 0;
  overflow-wrap: anywhere;
}
.arb-margin-pill {
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--emerald-soft);
  color: var(--emerald);
  border: 1px solid var(--emerald-border);
  white-space: nowrap;
  flex-shrink: 0;
}

.arb-route {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  min-width: 0;
}
.arb-route > div {
  min-width: 0;
}
.arb-leg-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.arb-leg-price {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.arb-leg-source {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.arb-arrow {
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
}

.arb-card-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-secondary);
  gap: 8px;
}

.arb-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  min-width: 0;
}
.arb-card-actions button {
  flex: 1;
  min-width: 0;
}

/* ==========================================================================
   CATALOG FILTERS & DATA TABLES
   ========================================================================== */
.filter-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.filter-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.search-field-lg {
  position: relative;
  flex: 1;
  min-width: 260px;
}
.input-search-main {
  width: 100%;
  padding: 9px 34px 9px 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  font-size: 0.875rem;
}
.input-search-main:focus {
  border-color: var(--border-focus);
  outline: none;
}

.btn-clear-input {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.region-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.14s ease;
}
.filter-pill:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.filter-pill.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
html[data-theme="dark"] .filter-pill.is-active {
  background: #2563eb;
  border-color: #3b82f6;
}

.filter-controls-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.select-field,
.input-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field-caption {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.select-field select,
.text-input,
.inline-select select,
.page-size-wrap select {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.8125rem;
  min-width: 0;
}

.filter-toggles-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}

.toggle-group {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.switch-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  user-select: none;
}
.switch-chip input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.switch-track {
  position: relative;
  width: 34px;
  height: 19px;
  border-radius: var(--radius-full);
  background: var(--border-strong);
  transition: background-color 0.16s ease;
  flex-shrink: 0;
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.16s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.switch-chip input:checked + .switch-track {
  background: var(--accent);
}
.switch-chip input:checked + .switch-track::after {
  transform: translateX(15px);
}
.switch-chip input:focus-visible + .switch-track {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.filter-summary-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.result-counter {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Tables */
.table-scroll-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  padding: 11px 14px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}
.data-table thead th.text-right {
  text-align: right;
}

.data-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.catalog-row {
  cursor: pointer;
  transition: background-color 0.12s ease;
}
.catalog-row:hover {
  background: var(--bg-hover);
}

.product-cell-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 440px;
}

.product-cell-meta {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.price-primary {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}
.price-orig {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.stock-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.tags-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  max-width: 290px;
}

/* Semantic Status Pills (strictly >= 12px) */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill-emerald { background: var(--emerald-soft); color: var(--emerald); border-color: var(--emerald-border); }
.pill-rose { background: var(--rose-soft); color: var(--rose); border-color: var(--rose-border); }
.pill-amber { background: var(--amber-soft); color: var(--amber); border-color: var(--amber-border); }
.pill-orange { background: var(--orange-soft); color: var(--orange); border-color: var(--orange-border); }
.pill-indigo { background: var(--indigo-soft); color: var(--indigo); border-color: var(--indigo-border); }
.pill-blue { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-border); }
.pill-slate { background: var(--bg-subtle); color: var(--text-secondary); border-color: var(--border-subtle); }

.row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.btn-pin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-muted);
  transition: all 0.14s ease;
}
.btn-pin:hover {
  border-color: var(--accent-border);
  color: var(--accent);
}
.btn-pin.is-pinned {
  background: var(--amber-soft);
  border-color: var(--amber-border);
  color: var(--amber);
}

.table-empty-cell {
  text-align: center;
  padding: 36px 16px !important;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.empty-inline {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Pagination */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  flex-wrap: wrap;
}
.pagination-info {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.page-size-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.page-buttons {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-weight: 600;
}
.page-btn:hover:not(:disabled) {
  border-color: var(--accent-border);
  color: var(--accent);
}
.page-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
html[data-theme="dark"] .page-btn.is-active {
  background: #2563eb;
  border-color: #3b82f6;
}
.page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ==========================================================================
   MATRIX VIEW
   ========================================================================== */
.matrix-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.search-field-sm {
  position: relative;
  min-width: 250px;
  flex: 1;
  max-width: 420px;
}
.input-search-sm {
  width: 100%;
  padding: 7px 12px 7px 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  font-size: 0.8125rem;
}
.inline-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.matrix-cell-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  text-align: right;
  transition: all 0.14s ease;
}
.matrix-cell-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.matrix-cell-btn.is-winner {
  background: var(--emerald-soft);
  border-color: var(--emerald-border);
}
.matrix-cell-price {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
}
.matrix-cell-btn.is-winner .matrix-cell-price {
  color: var(--emerald);
}
.matrix-cell-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 155px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.matrix-dash {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ==========================================================================
   RESELLER P&L CALCULATOR VIEW
   ========================================================================== */
.calc-top-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.slider-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.slider-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.slider-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.875rem;
  font-weight: 600;
}
.slider-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.num-input-sm {
  width: 72px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  text-align: right;
  font-weight: 700;
}
.unit-suffix {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

.range-slider {
  width: 100%;
  accent-color: var(--accent);
  height: 6px;
  cursor: pointer;
}
.slider-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.formula-box {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.formula-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
}
.formula-line {
  font-size: 0.8125rem;
  color: var(--text-primary);
}

.sim-inputs-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.sim-results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.sim-metric {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sim-metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}
.sim-metric-value {
  font-size: 1.1875rem;
  font-weight: 700;
}

.safety-meter-wrap {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.safety-meter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8125rem;
}
.safety-meter-track {
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--bg-hover);
  overflow: hidden;
}
.safety-meter-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--emerald-bright);
  transition: width 0.25s ease, background-color 0.25s ease;
}
.sim-monthly-projection {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.875rem;
}

/* ==========================================================================
   FORENSIC CLUSTERS VIEW
   ========================================================================== */
.clusters-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.cluster-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cluster-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.cluster-title {
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.3;
}
.cluster-root-box {
  padding: 11px 12px;
  border-radius: var(--radius-md);
  background: var(--emerald-soft);
  border: 1px solid var(--emerald-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
}
.cluster-clone-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.cluster-clone-row {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.14s ease;
}
.cluster-clone-row:hover {
  border-color: var(--accent-border);
}

/* ==========================================================================
   WATCHLIST VIEW
   ========================================================================== */
.watchlist-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.watch-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 15px 16px;
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.watch-card.is-target-hit {
  border-color: var(--emerald-border);
  box-shadow: inset 3px 0 0 var(--emerald-bright);
}
.watch-card.is-oos {
  border-color: var(--rose-border);
  box-shadow: inset 3px 0 0 var(--rose-bright);
}
.watch-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.watch-metric-box {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}
.watch-metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.watch-metric-val {
  font-size: 0.9375rem;
  font-weight: 700;
}
.watch-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==========================================================================
   SOURCES VIEW
   ========================================================================== */
.source-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}
.status-dot-sm {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-ok { background: var(--emerald-bright); }
.dot-warn { background: var(--amber-bright); }
.dot-err { background: var(--rose-bright); }

.mini-stock-bar {
  width: 90px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--bg-hover);
  overflow: hidden;
  margin-left: auto;
  margin-top: 4px;
}
.mini-stock-fill {
  height: 100%;
  background: var(--emerald-bright);
  border-radius: var(--radius-full);
}

.sync-runs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sync-run-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  font-size: 0.8125rem;
}

/* ==========================================================================
   SLIDE-OVER PRODUCT DETAIL DRAWER
   ========================================================================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(580px, 100vw);
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-drawer);
  z-index: 90;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}
.detail-drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
}
.drawer-header-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drawer-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.35;
}

.drawer-price-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
}
.drawer-price-main {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.specs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.spec-item {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.spec-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.spec-value {
  font-size: 0.875rem;
  font-weight: 600;
}

.drawer-section-title {
  margin: 0 0 8px;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
}

.drawer-desc-box {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  font-size: 0.875rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
  color: var(--text-primary);
}

.sparkline-box {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
}
.sparkline-box svg {
  display: block;
  width: 100%;
  height: auto;
}

.drawer-watch-form {
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.drawer-watch-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 110;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.toast-item {
  padding: 11px 15px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.2s ease;
}
.toast-item.is-success { border-color: var(--emerald-border); color: var(--emerald); }
.toast-item.is-error { border-color: var(--rose-border); color: var(--rose); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================== */
@media (max-width: 1280px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .filter-controls-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .arb-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1024px) {
  .mobile-topbar {
    display: flex;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(300px, 86vw) !important;
    transform: translateX(-100%);
    box-shadow: var(--shadow-md);
  }
  .sidebar.is-mobile-open {
    transform: translateX(0);
  }
  .sidebar-collapse-btn {
    display: none;
  }
  .sidebar-close-mobile {
    display: inline-flex;
  }
  .main-workspace {
    padding: 16px 14px 36px;
  }
  .overview-analytics-grid,
  .calc-top-grid,
  .clusters-grid,
  .watchlist-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .kpi-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .kpi-grid,
  .kpi-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .arb-cards-grid,
  .filter-controls-grid,
  .sim-inputs-grid,
  .drawer-price-strip,
  .drawer-watch-inputs,
  .watch-metrics,
  .specs-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .workspace-title {
    font-size: 1.25rem;
  }
  .fx-ticker {
    display: none;
  }
}
