/* ═══════════════════════════════════════════════════════
   品品 V2 — Design System v3
   Dark theme, indigo accent, 4px spacing grid
   ═══════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ──────────────────────────── */
:root {
  --bg-root: #0b1120;
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-elevated: #1a2332;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  --brand: #6366f1;
  --brand-light: #818cf8;
  --brand-dark: #4f46e5;
  --brand-bg: rgba(99, 102, 241, 0.12);
  --brand-border: rgba(99, 102, 241, 0.3);

  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --info: #60a5fa;
  --info-bg: rgba(96, 165, 250, 0.12);

  --chart-1: #6366f1;
  --chart-2: #34d399;
  --chart-3: #f59e0b;
  --chart-4: #ec4899;
  --chart-5: #06b6d4;
  --chart-6: #8b5cf6;
  --chart-7: #f87171;

  --s-xs: 4px; --s-sm: 8px; --s-md: 12px;
  --s-lg: 16px; --s-xl: 24px; --s-2xl: 32px; --s-3xl: 48px;

  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.6);

  --sidebar-w: 228px;
  --sidebar-collapsed-w: 54px;
  --topbar-h: 0px;

  --font-sans: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --fast: 150ms;
  --normal: 250ms;
}

/* ── Reset ──────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg-root);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,0.03); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; border: 1px solid rgba(255,255,255,0.05); }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
::-webkit-scrollbar-corner { background: transparent; }

/* Firefox scrollbar */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.12) transparent; }

/* ── App Layout ─────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════
   SIDEBAR — Enhanced v2
   ═══════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--bg-elevated) 0%, #161e30 100%);
  border-right: 1px solid var(--bg-tertiary);
  display: flex; flex-direction: column;
  transition: width var(--normal) var(--ease), min-width var(--normal) var(--ease);
  overflow: hidden; z-index: 100;
  position: relative;
}
.sidebar::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 1px; height: 100%;
  background: linear-gradient(180deg, transparent 0%, var(--brand-border) 50%, transparent 100%);
  opacity: 0.3;
}
.sidebar.collapsed { width: var(--sidebar-collapsed-w); min-width: var(--sidebar-collapsed-w); }

/* Brand area */
.sidebar-brand {
  display: flex; align-items: center;
  padding: var(--s-lg) var(--s-md); gap: var(--s-sm);
  flex-shrink: 0;
  min-height: 56px;
  position: relative;
}
.sidebar-brand .brand-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border-radius: var(--r-md);
}
.sidebar-brand .brand-icon svg {
  width: 20px; height: 20px;
  fill: #fff;
  stroke: none;
}
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; background: var(--brand-bg); border-radius: var(--r-lg); flex-shrink: 0;
  color: var(--brand-light);
}
.sidebar-brand .brand-info { flex: 1; min-width: 0; overflow: hidden; }
.sidebar-brand .brand-text { font-size: 15px; font-weight: 700; color: var(--text-primary); white-space: nowrap; }
.sidebar-brand .brand-sub { font-size: 11px; color: var(--text-muted); }
.sidebar-brand .collapse-btn {
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 10px; border-radius: var(--r-sm); flex-shrink: 0;
  transition: all var(--fast) var(--ease);
}
.sidebar-brand .collapse-btn:hover { background: var(--bg-secondary); color: var(--text-primary); }

.sidebar.collapsed .sidebar-brand { padding: var(--s-md) var(--s-sm); justify-content: center; }
.sidebar.collapsed .brand-info,
.sidebar.collapsed .collapse-btn { display: none; }

/* Glow line under brand */
.sidebar-glow {
  height: 1px;
  margin: 0 var(--s-md);
  background: linear-gradient(90deg, transparent 0%, var(--brand-border) 50%, transparent 100%);
  opacity: 0.5;
  flex-shrink: 0;
}

/* Navigation scroll area */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--s-sm) 0;
}

/* Section */
.nav-section { margin-bottom: 1px; }

.nav-section-toggle {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 7px var(--s-md); background: transparent; border: none;
  color: var(--text-muted); cursor: pointer; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.6px;
  transition: color var(--fast) var(--ease);
}
.nav-section-toggle:hover { color: var(--text-secondary); }
.nav-section-toggle .nav-section-arrow {
  font-size: 7px; width: 14px; flex-shrink: 0; text-align: center;
  transition: transform var(--fast) var(--ease);
}
.nav-section-toggle.collapsed .nav-section-arrow { transform: rotate(0deg); }
.nav-section-toggle:not(.collapsed) .nav-section-arrow { transform: rotate(90deg); }
.nav-section-toggle .nav-section-label { flex: 1; text-align: left; }
.nav-section-toggle .nav-section-count {
  font-size: 10px; background: var(--bg-tertiary); color: var(--text-muted);
  border-radius: 10px; padding: 0 6px; min-width: 18px; text-align: center;
}

.nav-section-items {
  overflow: hidden;
  transition: max-height var(--normal) var(--ease), opacity var(--normal) var(--ease);
  max-height: 600px;
  opacity: 1;
}
.nav-section-items.hidden {
  max-height: 0 !important;
  opacity: 0;
}

.sidebar.collapsed .nav-section-toggle .nav-section-label,
.sidebar.collapsed .nav-section-toggle .nav-section-count { display: none; }
.sidebar.collapsed .nav-section-toggle { justify-content: center; padding: 6px 0; }

/* Nav items */
.nav-item {
  display: flex; align-items: center; gap: var(--s-sm); width: 100%;
  padding: 8px var(--s-md) 8px calc(var(--s-md) + 16px);
  background: transparent; border: none;
  color: var(--text-secondary);
  cursor: pointer; font-size: 13px; text-align: left;
  transition: all var(--fast) var(--ease);
  position: relative;
  border-left: 2px solid transparent;
}
.nav-item:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
}
.nav-item.active {
  background: linear-gradient(90deg, var(--brand-bg) 0%, transparent 100%);
  color: var(--brand-light);
  border-left-color: var(--brand);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -1px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 55%;
  background: var(--brand);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
}
.nav-item .nav-icon {
  width: 22px; height: 22px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.nav-item .nav-icon svg {
  width: 16px; height: 16px;
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.15s;
}
.nav-item:hover .nav-icon svg { stroke: var(--text-secondary); }
.nav-item.active .nav-icon svg { stroke: var(--brand-light); }
.nav-item .nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .nav-badge {
  background: var(--danger); color: #fff; font-size: 10px;
  min-width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
  border-radius: 10px; padding: 0 5px; font-weight: 600;
}
.nav-item .nav-badge.warn { background: var(--warning); color: #000; }
.nav-item .nav-badge.severe { background: #7c3aed; color: #fff; box-shadow: 0 0 6px rgba(124,58,237,0.5); animation: badgePulse 2s infinite; }
@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 4px rgba(124,58,237,0.3); }
  50% { box-shadow: 0 0 10px rgba(124,58,237,0.7); }
}

/* Collapsed sidebar nav items */
.sidebar.collapsed .nav-item {
  padding: 10px 0; justify-content: center; border-left: none;
}
.sidebar.collapsed .nav-item .nav-icon svg { width: 18px; height: 18px; }
.sidebar.collapsed .nav-item .nav-icon { width: auto; }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge { display: none; }
.sidebar.collapsed .nav-item.active::before { display: none; }
.sidebar.collapsed .nav-item.active {
  background: var(--brand-bg);
  box-shadow: inset 0 0 12px rgba(99, 102, 241, 0.15);
}

/* Mobile overlay */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
}

/* ── Main Content ───────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.page-container {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-xl);
  scroll-behavior: smooth;
}

.page-header {
  margin-bottom: var(--s-xl);
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--s-xs);
  display: flex;
  align-items: center;
  gap: var(--s-sm);
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── AI Quick Bar ───────────────────────────────────── */
.ai-quick-bar {
  background: var(--bg-secondary);
  border-top: 1px solid var(--bg-tertiary);
  padding: var(--s-md) var(--s-xl);
  display: flex;
  gap: var(--s-md);
  align-items: center;
  min-height: 52px;
}
.ai-quick-bar .quick-hints {
  display: flex;
  gap: var(--s-sm);
  flex: 1;
  overflow-x: auto;
}
.quick-hint {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  padding: var(--s-xs) var(--s-md);
  border-radius: var(--r-sm);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  border: none;
  transition: all var(--fast) var(--ease);
}
.quick-hint:hover {
  background: var(--brand-bg);
  color: var(--brand-light);
}
.quick-input-wrap {
  display: flex;
  gap: var(--s-sm);
  align-items: center;
  flex-shrink: 0;
}
.quick-input {
  background: var(--bg-primary);
  border: 1px solid var(--bg-tertiary);
  color: var(--text-primary);
  padding: var(--s-sm) var(--s-md);
  border-radius: var(--r-md);
  font-size: 13px;
  width: 280px;
  outline: none;
  transition: border var(--fast) var(--ease);
}
.quick-input:focus { border-color: var(--brand); }
.quick-input::placeholder { color: var(--text-muted); }

/* ── Cards ──────────────────────────────────────────── */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--r-lg);
  padding: var(--s-xl);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-lg);
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}
.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Metric Cards ───────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--s-lg);
  margin-bottom: var(--s-xl);
}
.metric-card {
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--r-lg);
  padding: var(--s-xl);
  display: flex;
  flex-direction: column;
  gap: var(--s-sm);
  transition: all var(--fast) var(--ease);
  cursor: default;
  position: relative;
  overflow: hidden;
}
.metric-card:hover {
  border-color: var(--brand-border);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}
.metric-card .metric-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.metric-card .metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.metric-card .metric-delta {
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.metric-card .metric-delta.up { color: var(--success); }
.metric-card .metric-delta.down { color: var(--danger); }
.metric-card .metric-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Chart Containers ───────────────────────────────── */
.chart-box {
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--r-lg);
  padding: var(--s-xl);
  margin-bottom: var(--s-lg);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.chart-box:hover {
  border-color: var(--brand-border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.chart-box .chart-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--s-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chart-box .chart-title .chart-actions {
  display: flex;
  gap: var(--s-sm);
}
.chart-container {
  width: 100%;
  height: 280px;
}

/* ── Dash Layouts ───────────────────────────────────── */
.dash-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-lg);
  margin-bottom: var(--s-lg);
}
.dash-full { margin-bottom: var(--s-lg); }

/* ── Alert List ─────────────────────────────────────── */
.alert-list { list-style: none; display: flex; flex-direction: column; gap: var(--s-sm); }
.alert-item {
  display: flex;
  align-items: center;
  gap: var(--s-md);
  padding: var(--s-md) var(--s-lg);
  background: var(--bg-primary);
  border-radius: var(--r-md);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--fast) var(--ease);
  border: 1px solid transparent;
  text-decoration: none;
  color: var(--text-primary);
}
.alert-item:hover {
  border-color: var(--bg-tertiary);
  background: var(--bg-elevated);
}
.alert-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.alert-dot.red { background: var(--danger); box-shadow: 0 0 6px rgba(248,113,113,0.4); }
.alert-dot.yellow { background: var(--warning); box-shadow: 0 0 6px rgba(251,191,36,0.3); }
.alert-dot.blue { background: var(--info); box-shadow: 0 0 6px rgba(96,165,250,0.3); }
.alert-count {
  margin-left: auto;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
}

/* ── Activity Feed ──────────────────────────────────── */
.activity-list { list-style: none; display: flex; flex-direction: column; }
.activity-item {
  display: flex;
  gap: var(--s-md);
  padding: var(--s-md) 0;
  border-bottom: 1px solid var(--bg-tertiary);
  font-size: 13px;
}
.activity-item:last-child { border-bottom: none; }
.activity-time {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
  width: 45px;
}
.activity-text { color: var(--text-secondary); }

/* ── Skeleton loading ───────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    var(--bg-tertiary) 25%,
    #3b4f6d 50%,
    var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-text { height: 14px; margin-bottom: var(--s-sm); }
.skeleton-text.short { width: 60%; }
.skeleton-value { height: 32px; width: 50%; margin-bottom: var(--s-sm); }
.skeleton-chart { height: 280px; border-radius: var(--r-md); }

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-sm);
  padding: var(--s-sm) var(--s-lg);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--fast) var(--ease);
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); }
.btn-secondary:hover:not(:disabled) { background: var(--text-muted); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-secondary); color: var(--text-primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #000; }
.btn-sm { padding: 3px 10px; font-size: 12px; border-radius: var(--r-sm); }
.btn-xs { padding: 2px 8px; font-size: 11px; border-radius: 4px; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--bg-tertiary);
  color: var(--text-secondary);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--brand-border);
  color: var(--brand-light);
  background: var(--brand-bg);
}

/* ── Forms ──────────────────────────────────────────── */
.form-group { margin-bottom: var(--s-lg); }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--s-xs);
}
.form-input, .form-select {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--bg-tertiary);
  color: var(--text-primary);
  padding: var(--s-sm) var(--s-md);
  border-radius: var(--r-md);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border var(--fast) var(--ease);
}
.form-input:focus, .form-select:focus { border-color: var(--brand); }
.form-select { cursor: pointer; }

/* ── Tables ─────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: var(--s-sm) var(--s-md);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--bg-tertiary);
  white-space: nowrap;
  user-select: none;
}
.data-table th.sortable { cursor: pointer; }
.data-table th.sortable:hover { color: var(--text-primary); background: var(--bg-secondary); }
.data-table th.sortable::after {
  content: ' ↕'; font-size: 10px; opacity: 0.4;
}
.data-table th.sortable.sort-asc::after { content: ' ↑'; opacity: 1; color: var(--brand); }
.data-table th.sortable.sort-desc::after { content: ' ↓'; opacity: 1; color: var(--brand); }
.data-table td {
  padding: var(--s-sm) var(--s-md);
  border-bottom: 1px solid var(--bg-tertiary);
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
.data-table tr:hover td { background: var(--bg-elevated); }
.data-table tr.selected td { background: var(--brand-bg); border-bottom-color: var(--brand-border); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .center { text-align: center; }
.data-table .col-check { width: 36px; text-align: center; }
.data-table input[type="checkbox"] {
  accent-color: var(--brand); width: 14px; height: 14px; cursor: pointer;
}
.data-table.compact th { padding: 4px 8px; font-size: 10px; }
.data-table.compact td { padding: 4px 8px; font-size: 12px; }

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-sm) 0; font-size: 12px; color: var(--text-muted);
}
.pagination .page-btns { display: flex; gap: 4px; }
.pagination .page-btn {
  padding: 4px 10px; background: transparent; border: 1px solid var(--bg-tertiary);
  border-radius: var(--r-sm); color: var(--text-secondary); cursor: pointer; font-size: 12px;
}
.pagination .page-btn:hover { background: var(--bg-secondary); }
.pagination .page-btn.active { background: var(--brand-bg); color: var(--brand-light); border-color: var(--brand-border); }
.pagination .page-btn:disabled { opacity: 0.3; cursor: default; }

.selection-bar {
  display: flex; align-items: center; gap: var(--s-sm);
  padding: var(--s-sm) var(--s-md); background: var(--brand-bg);
  border-radius: var(--r-md); margin-bottom: var(--s-sm);
  font-size: 12px; color: var(--brand-light);
}

/* ── Tags / Badges ──────────────────────────────────── */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.tag-success { background: var(--success-bg); color: var(--success); }
.tag-warning { background: var(--warning-bg); color: var(--warning); }
.tag-danger { background: var(--danger-bg); color: var(--danger); }
.tag-info { background: var(--info-bg); color: var(--info); }
.tag-brand { background: var(--brand-bg); color: var(--brand-light); }

/* ── Toast ──────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: var(--s-lg);
  right: var(--s-lg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--s-sm);
}
.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--r-md);
  padding: var(--s-md) var(--s-lg);
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  animation: toastSlideIn 0.3s var(--ease);
  max-width: 360px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }
.toast.warn { border-left: 3px solid var(--warning); }
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── Filter Bar ─────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: var(--s-md);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--s-lg);
  padding: var(--s-md) var(--s-lg);
  background: var(--bg-secondary);
  border-radius: var(--r-md);
  border: 1px solid var(--bg-tertiary);
}
.filter-bar .filter-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}
.filter-bar select {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--bg-tertiary);
  padding: var(--s-xs) var(--s-md);
  border-radius: var(--r-sm);
  font-size: 12px;
  cursor: pointer;
  outline: none;
}
.filter-bar select:focus { border-color: var(--brand); }
.filter-bar .filter-group {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
}

/* ── Status Dot ─────────────────────────────────────── */
.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.green { background: var(--success); }
.status-dot.yellow { background: var(--warning); }
.status-dot.red { background: var(--danger); }

/* ── Tab Bar ────────────────────────────────────────── */
.tab-bar {
  display: flex; gap: var(--s-xs); margin-bottom: var(--s-lg);
  flex-wrap: wrap; border-bottom: 1px solid var(--bg-tertiary);
  padding-bottom: var(--s-sm);
}
.tab-item {
  padding: 6px 14px; background: transparent; border: none;
  color: var(--text-muted); cursor: pointer; font-size: 13px;
  border-radius: var(--r-md); display: flex; align-items: center; gap: 6px;
  transition: all var(--fast) var(--ease); white-space: nowrap;
}
.tab-item:hover { background: var(--bg-secondary); color: var(--text-secondary); }
.tab-item.active { background: var(--brand-bg); color: var(--brand-light); font-weight: 600; }
.tab-item .tab-count {
  font-size: 10px; background: var(--bg-tertiary); color: var(--text-muted);
  border-radius: 10px; padding: 0 6px; min-width: 18px; text-align: center;
}
.tab-item .tab-count.has { background: var(--danger-bg); color: var(--danger); }

/* ── Data Status ────────────────────────────────────── */
.data-status {
  font-size: 11px; color: var(--text-muted); margin-left: auto;
  padding: 2px 8px; background: var(--bg-secondary);
  border-radius: var(--r-sm); white-space: nowrap;
  animation: fadeIn 0.3s var(--ease);
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Helpers ────────────────────────────────────────── */
.flex { display: flex; }

/* ── Nav Buttons (page subtitle navigation) ────────── */
.page-subtitle .nav-btn {
  cursor: pointer;
  color: var(--text-muted);
  padding: var(--s-xs) var(--s-sm);
  border-radius: var(--r-sm);
  font-size: 13px;
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
}
.page-subtitle .nav-btn.active {
  background: var(--brand-bg);
  color: var(--brand-light);
  border-color: var(--brand-border);
}
.page-subtitle .nav-btn:hover {
  background: var(--bg-tertiary);
}
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--s-sm); }
.gap-md { gap: var(--s-md); }
.gap-lg { gap: var(--s-lg); }
.flex-1 { flex: 1; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-mono { font-family: var(--font-mono); }
.mb-sm { margin-bottom: var(--s-sm); }
.mb-md { margin-bottom: var(--s-md); }
.mb-lg { margin-bottom: var(--s-lg); }
.mb-xl { margin-bottom: var(--s-xl); }
.page-enter {
  animation: pageFadeIn 0.35s var(--ease);
}
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Modal ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s var(--ease);
}
.modal-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--r-xl);
  width: 90vw; max-width: 720px; max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalSlideIn 0.25s var(--ease);
}
@keyframes modalSlideIn { from { opacity: 0; transform: translateY(-20px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-lg) var(--s-xl);
  border-bottom: 1px solid var(--bg-tertiary);
  flex-shrink: 0;
}
.modal-header .modal-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.modal-header .modal-code { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }
.modal-close {
  width: 32px; height: 32px;
  border: none; background: none;
  color: var(--text-muted); font-size: 20px;
  cursor: pointer; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--fast) var(--ease);
}
.modal-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.modal-body { flex: 1; overflow-y: auto; padding: var(--s-xl); }
.modal-body .info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--s-md);
  margin-bottom: var(--s-lg);
}
.modal-body .info-item {
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  padding: var(--s-md);
}
.modal-body .info-item .info-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.modal-body .info-item .info-value { font-size: 14px; font-weight: 600; color: var(--text-primary); }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    z-index: 200;
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
  }
  .sidebar.open ~ .sidebar-overlay { display: block; }

  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-2col { grid-template-columns: 1fr; }
  .page-container { padding: var(--s-lg); }
  .ai-quick-bar { padding: var(--s-sm) var(--s-lg); }
  .quick-input { width: 160px; }
}

/* ── Empty State ────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--s-3xl) var(--s-xl);
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: var(--s-lg); opacity: 0.5; }
.empty-state .empty-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: var(--s-sm); }
.empty-state .empty-desc { font-size: 13px; color: var(--text-muted); }

/* ── OTB Month Chips ── */
.month-chip {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 3px 10px; border-radius: 14px; font-size: 11px;
  cursor: pointer; border: 1px solid var(--bg-tertiary);
  background: transparent; color: var(--text-muted);
  transition: all var(--fast) var(--ease);
  font-family: var(--font-sans);
  user-select: none;
  min-width: 52px;
}
.month-chip:hover {
  border-color: var(--brand-border);
  color: var(--text-secondary);
  background: var(--brand-bg);
}
.month-chip.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  font-weight: 600;
}
.otb-page .filter-bar {
  /* Specific OTB filter bar refinements */
}
.otb-quick-stat {
  display: inline-flex;
  align-items: center;
  gap: var(--s-xs);
}
@media (max-width: 640px) {
  .month-chip {
    min-width: auto;
    padding: 2px 7px;
    font-size: 10px;
  }
}
