/* onWatch — Clean Minimal Dashboard Theme
   Inspired by: logip project management UI
   Palette: Teal + Peach accents, soft shadows, rounded cards */

/* ═══════════════════════════════════════════
   1. DESIGN TOKENS
   ═══════════════════════════════════════════ */

:root {
  /* Surfaces */
  --surface-page: #F0F2F5;
  --surface-card: #FFFFFF;
  --surface-card-alt: #F7F8FA;
  --surface-raised: #FFFFFF;
  --surface-inset: #F3F4F6;
  --surface-overlay: rgba(0, 0, 0, 0.45);

  /* Text — all pass WCAG AA 4.5:1 on white */
  --text-primary: #1A1D21;
  --text-secondary: #4B5563;
  --text-muted: #6B7280;
  --text-inverse: #FFFFFF;

  /* Borders */
  --border-default: #E5E7EB;
  --border-light: #F0F1F3;
  --border-focus: #0D9488;

  /* Accent: Teal */
  --accent-teal: #0D9488;
  --accent-teal-light: #CCFBF1;
  --accent-teal-muted: rgba(13, 148, 136, 0.1);
  --accent-teal-text: #065F53;

  /* Accent: Peach / Amber */
  --accent-peach: #F59E0B;
  --accent-peach-light: #FEF3C7;
  --accent-peach-muted: rgba(245, 158, 11, 0.1);
  --accent-peach-text: #92400E;

  /* Accent: Blue */
  --accent-blue: #3B82F6;
  --accent-blue-light: #DBEAFE;
  --accent-blue-muted: rgba(59, 130, 246, 0.1);
  --accent-blue-text: #1E40AF;

  /* Status */
  --status-healthy: #10B981;
  --status-healthy-bg: #D1FAE5;
  --status-healthy-text: #065F46;
  --status-warning: #F59E0B;
  --status-warning-bg: #FEF3C7;
  --status-warning-text: #92400E;
  --status-danger: #EF4444;
  --status-danger-bg: #FEE2E2;
  --status-danger-text: #991B1B;
  --status-critical: #DC2626;
  --status-critical-bg: #FEE2E2;
  --status-critical-text: #7F1D1D;
  --status-info: #3B82F6;
  --status-info-bg: #DBEAFE;
  --status-info-text: #1E40AF;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-card-hover: 0 4px 16px rgba(0, 0, 0, 0.08);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Typography */
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* Accent: Anthropic (Coral) */
  --accent-anthropic: #D97757;
  --accent-anthropic-light: #FEF2EE;
  --accent-anthropic-muted: rgba(217, 119, 87, 0.1);
  --accent-anthropic-text: #9A3412;

  /* Chart colors (same in both modes) */
  --chart-subscription: #0D9488;
  --chart-search: #F59E0B;
  --chart-toolcalls: #3B82F6;
  --chart-anthropic: #D97757;
}

/* ═══════════════════════════════════════════
   2. DARK MODE TOKENS
   ═══════════════════════════════════════════ */

[data-theme="dark"] {
  --surface-page: #0F1117;
  --surface-card: #1A1D24;
  --surface-card-alt: #21242C;
  --surface-raised: #252830;
  --surface-inset: #161921;
  --surface-overlay: rgba(0, 0, 0, 0.65);

  /* Text — all pass WCAG AA 4.5:1 on #1A1D24 */
  --text-primary: #F1F3F5;
  --text-secondary: #ABB5C2;
  --text-muted: #8891A0;
  --text-inverse: #1A1D21;

  --border-default: #2F3440;
  --border-light: #2A2E37;
  --border-focus: #14B8A6;

  --accent-teal: #14B8A6;
  --accent-teal-light: #0F2D2A;
  --accent-teal-muted: rgba(20, 184, 166, 0.12);
  --accent-teal-text: #5EEAD4;

  --accent-peach: #FBBF24;
  --accent-peach-light: #2D2410;
  --accent-peach-muted: rgba(251, 191, 36, 0.12);
  --accent-peach-text: #FDE68A;

  --accent-blue: #60A5FA;
  --accent-blue-light: #172035;
  --accent-blue-muted: rgba(96, 165, 250, 0.12);
  --accent-blue-text: #93C5FD;

  --status-healthy: #34D399;
  --status-healthy-bg: rgba(52, 211, 153, 0.12);
  --status-healthy-text: #6EE7B7;
  --status-warning: #FBBF24;
  --status-warning-bg: rgba(251, 191, 36, 0.12);
  --status-warning-text: #FDE68A;
  --status-danger: #F87171;
  --status-danger-bg: rgba(248, 113, 113, 0.12);
  --status-danger-text: #FCA5A5;
  --status-critical: #EF4444;
  --status-critical-bg: rgba(239, 68, 68, 0.15);
  --status-critical-text: #FCA5A5;
  --status-info: #60A5FA;
  --status-info-bg: rgba(96, 165, 250, 0.12);
  --status-info-text: #93C5FD;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow-card-hover: 0 4px 16px rgba(0, 0, 0, 0.3);

  --chart-subscription: #14B8A6;
  --chart-search: #FBBF24;
  --chart-toolcalls: #60A5FA;
  --chart-anthropic: #E8956F;

  --accent-anthropic: #E8956F;
  --accent-anthropic-light: #2D1A10;
  --accent-anthropic-muted: rgba(232, 149, 111, 0.12);
  --accent-anthropic-text: #FBBAA0;
}

/* ═══════════════════════════════════════════
   3. RESET & BASE
   ═══════════════════════════════════════════ */

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

html {
  font-family: var(--font-primary);
  background: var(--surface-page);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  transition: background-color var(--transition-base), color var(--transition-base);
}

button, input, select { font-family: inherit; }

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent-teal);
  color: var(--text-inverse);
  padding: 8px 16px;
  z-index: 100;
  transition: top var(--transition-base);
}
.skip-link:focus { top: 0; }

:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════
   4. APP LAYOUT
   ═══════════════════════════════════════════ */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ═══════════════════════════════════════════
   5. HEADER
   ═══════════════════════════════════════════ */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-default);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-xs);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}
.header-brand:hover { opacity: 0.8; }

.brand-icon {
  width: 32px;
  height: 32px;
  color: var(--accent-teal);
}

.brand-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* Provider Tabs */
.provider-tabs {
  display: flex;
  gap: 2px;
  background: var(--surface-inset);
  padding: 3px;
  border-radius: var(--radius-sm);
  margin-left: 16px;
}
.provider-tab {
  padding: 6px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.provider-tab:hover {
  color: var(--text-primary);
  background: var(--surface-card);
}
.provider-tab.active {
  background: var(--surface-card);
  color: var(--accent-teal);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}
.provider-tab.active[data-provider="anthropic"] {
  color: var(--accent-anthropic);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.header-btn:hover {
  background: var(--surface-card-alt);
  color: var(--text-primary);
  border-color: var(--accent-teal);
}
.header-btn svg { width: 18px; height: 18px; }
#logout-btn { text-decoration: none; }
#logout-btn:hover { color: #EF4444; border-color: #EF4444; }
.header-btn.spinning svg { animation: spin 800ms linear; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

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

.last-updated {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Timezone Badge + Picker */
.timezone-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--accent-teal-muted);
  color: var(--accent-teal);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
  white-space: nowrap;
}
.timezone-badge:hover {
  background: var(--accent-teal);
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm);
}
.timezone-badge:empty { display: none; }

.tz-picker {
  position: fixed;
  z-index: 50;
  width: 240px;
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.tz-picker-list {
  overflow-y: auto;
  scroll-behavior: auto;
  -ms-overflow-style: none;
  scrollbar-width: thin;
}
.tz-picker-list::-webkit-scrollbar { width: 3px; }
.tz-picker-list::-webkit-scrollbar-track { background: transparent; }
.tz-picker-list::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 2px; }

.tz-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: background var(--transition-fast);
}
.tz-picker-item:hover {
  background: var(--surface-card-alt);
}
.tz-picker-item.active {
  background: var(--accent-teal-muted);
  color: var(--accent-teal);
  font-weight: 600;
}

.tz-picker-label { flex: 1; }
.tz-picker-abbr {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 8px;
}
.tz-picker-item.active .tz-picker-abbr { color: var(--accent-teal); }

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-healthy);
  transition: background var(--transition-base);
  box-shadow: 0 0 0 3px var(--status-healthy-bg);
}
.status-indicator.stale {
  background: var(--status-warning);
  box-shadow: 0 0 0 3px var(--status-warning-bg);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.theme-toggle:hover {
  background: var(--surface-card-alt);
  color: var(--accent-peach);
  border-color: var(--accent-peach);
}
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* ═══════════════════════════════════════════
   6. MAIN CONTENT
   ═══════════════════════════════════════════ */

.main-content {
  flex: 1;
  padding: 28px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Welcome banner */
.welcome-banner {
  margin-bottom: 28px;
}
.welcome-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.welcome-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════
   7. QUOTA CARDS (KPI STYLE)
   ═══════════════════════════════════════════ */

.quota-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
/* Both View — Multi-Column Layout */
.both-view {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 28px;
}
.provider-column {
  min-width: 0;
}
.provider-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  padding-left: 4px;
}
.quota-grid-stacked {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 0;
}
.quota-grid-stacked .quota-card {
  width: 100%;
}

/* Both Charts */
.chart-container.both-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  height: auto;
}
.chart-half {
  position: relative;
  height: 260px;
}
.chart-half canvas {
  width: 100% !important;
  height: 230px !important;
}
.chart-half-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  text-align: center;
}

.quota-card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  padding: 22px;
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
  opacity: 0;
  animation: cardEntrance 400ms ease forwards;
  position: relative;
  overflow: hidden;
}
.quota-card:nth-child(1) { animation-delay: 0ms; }
.quota-card:nth-child(2) { animation-delay: 60ms; }
.quota-card:nth-child(3) { animation-delay: 120ms; }
.quota-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--border-focus);
}
.quota-card:active { transform: translateY(0); }
.quota-card.anthropic-card:hover { border-color: var(--accent-anthropic); }

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

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.quota-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.quota-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.countdown {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-inset);
}
.countdown.imminent {
  color: var(--status-info);
  background: var(--status-info-bg);
}

.quota-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  display: none;
}

.usage-percent {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 4px;
  transition: opacity var(--transition-fast);
}

.usage-fraction {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: block;
}

.progress-wrapper { margin-bottom: 16px; }

.progress-bar {
  height: 6px;
  background: var(--surface-inset);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 500ms ease-out, background var(--transition-base);
}
.progress-fill[data-status="healthy"] { background: var(--status-healthy); }
.progress-fill[data-status="warning"] { background: var(--status-warning); }
.progress-fill[data-status="danger"] { background: var(--status-danger); }
.progress-fill[data-status="critical"] { background: var(--status-critical); animation: pulse 2s infinite; }

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

.progress-stats {
  display: flex;
  flex-direction: column;
  margin-bottom: 6px;
}

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

/* Per-tool usage breakdown (Z.ai Time Limit card) */
.usage-details {
  margin: 8px 0 4px;
  padding: 8px 10px;
  background: var(--surface-container);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.usage-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
}
.usage-detail-row + .usage-detail-row {
  border-top: 1px solid var(--outline-variant);
}
.usage-detail-model {
  color: var(--on-surface-variant);
  font-family: 'Roboto Mono', monospace;
}
.usage-detail-count {
  font-weight: 600;
  color: var(--on-surface);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  transition: background var(--transition-base);
}
.status-badge[data-status="healthy"] {
  background: var(--status-healthy-bg);
  color: var(--status-healthy-text);
}
.status-badge[data-status="warning"] {
  background: var(--status-warning-bg);
  color: var(--status-warning-text);
}
.status-badge[data-status="danger"] {
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
}
.status-badge[data-status="critical"] {
  background: var(--status-critical-bg);
  color: var(--status-critical-text);
}
.status-icon { width: 12px; height: 12px; }

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

/* Beta and Unlimited badges */
.beta-badge {
  display: inline-block;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #6e40c9 0%, #a371f7 100%);
  color: #fff;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

.unlimited-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 12px;
  font-weight: 700;
  background: var(--status-healthy-bg);
  color: var(--status-healthy-text);
  border-radius: 50%;
  margin-left: 6px;
}


/* ═══════════════════════════════════════════
   8. SECTION PANELS
   ═══════════════════════════════════════════ */

.insights-panel, .chart-section, .cycle-overview-section, .cycles-section, .sessions-section {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
  opacity: 0;
  animation: sectionEntrance 400ms ease forwards;
}
.insights-panel { animation-delay: 150ms; }
.chart-section { animation-delay: 200ms; }
.cycle-overview-section { animation-delay: 225ms; }
.cycles-section { animation-delay: 250ms; }
.sessions-section { animation-delay: 300ms; }

/* Cycle Overview threshold colors */
.threshold-healthy { color: var(--status-healthy); }
.threshold-warning { color: var(--status-warning); }
.threshold-danger { color: var(--status-danger); }
.threshold-critical { color: var(--status-critical); font-weight: 700; }
.overview-primary-col { font-weight: 600; border-bottom: 2px solid var(--accent-teal); }
.overview-primary-val { font-weight: 600; }

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

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.section-icon {
  width: 20px;
  height: 20px;
  color: var(--accent-teal);
}

/* ═══════════════════════════════════════════
   9. INSIGHTS
   ═══════════════════════════════════════════ */

.insights-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.insights-stats:empty { display: none; }

.insight-stat {
  text-align: center;
  padding: 16px 12px;
  background: var(--accent-teal-muted);
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--accent-teal) 15%, var(--border-light));
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.insight-stat:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  border-color: var(--accent-teal);
}

.insight-stat-value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  line-height: 1.2;
}

.insight-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.insight-stat-sublabel {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  opacity: 0.7;
}

/* Insight Cards Grid */
.insights-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.insights-cards:empty { display: none; }

/* Provider Insights Boxes (Both mode) */
.provider-insights-box {
  background: var(--surface-card-alt);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}
.provider-insights-box:last-child { margin-bottom: 0; }

.provider-insights-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent-teal);
}
.provider-insights-box[data-provider="zai"] .provider-insights-label {
  border-bottom-color: var(--accent-peach);
}
.provider-insights-box[data-provider="anthropic"] .provider-insights-label {
  border-bottom-color: var(--accent-anthropic);
}

.insight-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  padding: 12px;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
  background: var(--surface-card-alt);
  display: flex;
  flex-direction: column;
}
.insight-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.insight-card:active { transform: translateY(0); }
.insight-card.severity-positive {
  background: color-mix(in srgb, var(--status-healthy) 14%, var(--surface-card-alt));
  border-color: color-mix(in srgb, var(--status-healthy) 30%, var(--border-light));
}
.insight-card.severity-warning {
  background: color-mix(in srgb, var(--status-warning) 14%, var(--surface-card-alt));
  border-color: color-mix(in srgb, var(--status-warning) 30%, var(--border-light));
}
.insight-card.severity-negative {
  background: color-mix(in srgb, var(--status-danger) 14%, var(--surface-card-alt));
  border-color: color-mix(in srgb, var(--status-danger) 30%, var(--border-light));
}
.insight-card.severity-info {
  background: color-mix(in srgb, var(--status-info) 14%, var(--surface-card-alt));
  border-color: color-mix(in srgb, var(--status-info) 30%, var(--border-light));
}

.insight-card-header {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  grid-template-rows: auto 1fr auto;
  gap: 4px 6px;
  align-items: center;
  flex: 1;
}

.insight-card-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  grid-row: 1;
  grid-column: 1;
}
.insight-card.severity-positive .insight-card-icon { color: var(--status-healthy); }
.insight-card.severity-warning .insight-card-icon { color: var(--status-warning); }
.insight-card.severity-negative .insight-card-icon { color: var(--status-danger); }
.insight-card.severity-info .insight-card-icon { color: var(--status-info); }

.insight-card-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  grid-row: 1;
  grid-column: 2;
}
.insight-card-values {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  grid-row: 2;
  grid-column: 1 / -1;
  align-self: center;
  padding: 6px 0 4px;
}

.insight-card-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  transition: transform var(--transition-base);
  flex-shrink: 0;
  grid-row: 1;
  grid-column: 4;
}
.insight-card.expanded .insight-card-chevron { transform: rotate(180deg); }

.insight-card-metric {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  line-height: 1.1;
  text-align: center;
}

.insight-card-sublabel {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  font-weight: 500;
  text-align: center;
}

.insight-card-detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height 250ms ease, margin 250ms ease, opacity 200ms ease;
  opacity: 0;
}
.insight-card.expanded .insight-card-detail {
  max-height: 200px;
  margin-top: 12px;
  opacity: 1;
}

.insight-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

/* Insight Eye Toggle Button */
.insight-eye-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  grid-row: 1;
  grid-column: 3;
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
  flex-shrink: 0;
  margin-left: auto;
}
.insight-eye-btn svg { width: 14px; height: 14px; }
.insight-card:hover .insight-eye-btn { opacity: 0.6; }
.insight-eye-btn:hover {
  opacity: 1 !important;
  color: var(--status-danger);
  background: var(--status-danger-bg);
}

/* Hidden Insights Badge */
.hidden-insights-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--surface-inset);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.hidden-badge-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.hidden-badge-show {
  border: none;
  background: none;
  color: var(--accent-teal);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background var(--transition-fast);
}
.hidden-badge-show:hover {
  background: var(--accent-teal-muted);
}

.insight-text {
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════
   10. CHART
   ═══════════════════════════════════════════ */

.range-selector {
  display: flex;
  gap: 4px;
  background: var(--surface-inset);
  padding: 3px;
  border-radius: var(--radius-sm);
}

.range-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.range-btn:hover {
  color: var(--text-primary);
  background: var(--surface-card);
}
.range-btn.active {
  background: var(--surface-card);
  color: var(--accent-teal);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.chart-container {
  height: 300px;
  position: relative;
}

/* ═══════════════════════════════════════════
   11. CYCLE FILTERS
   ═══════════════════════════════════════════ */

.cycles-filters-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.filter-pills {
  display: flex;
  gap: 2px;
  background: var(--surface-inset);
  padding: 2px;
  border-radius: 6px;
}

.filter-pill {
  padding: 4px 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.filter-pill:hover {
  color: var(--text-primary);
  background: var(--surface-card);
}
.filter-pill.active {
  background: var(--surface-card);
  color: var(--accent-teal);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

/* ═══════════════════════════════════════════
   12. TABLES
   ═══════════════════════════════════════════ */

.table-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.quota-select, .page-size-select {
  padding: 7px 14px;
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  color: var(--text-primary);
  font-size: 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition-fast);
}
.quota-select:hover, .page-size-select:hover {
  border-color: var(--accent-teal);
}

.table-wrapper { overflow-x: auto; }
.table-wrapper::-webkit-scrollbar { height: 5px; }
.table-wrapper::-webkit-scrollbar-track { background: transparent; }
.table-wrapper::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 3px; }

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

.data-table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-default);
  background: var(--surface-card-alt);
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}

/* Model name cells should wrap to prevent horizontal scroll */
.data-table td.model-name,
.data-table td:first-child {
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 200px;
  white-space: normal;
  line-height: 1.4;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover {
  background: var(--surface-card-alt);
}

.data-table tr.session-row {
  cursor: pointer;
  transition: background var(--transition-fast);
}
.data-table tr.session-row:hover {
  background: var(--surface-card-alt);
}

/* Sortable Table Headers */
.data-table th[data-sort-key] {
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: color var(--transition-fast), background var(--transition-fast);
  padding-right: 24px;
}
.data-table th[data-sort-key]:hover {
  color: var(--accent-teal);
  background: var(--surface-card-alt);
}
.sort-arrow {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  opacity: 0.3;
  transition: opacity var(--transition-fast);
}
/* Show ↕ on hover when not sorted */
.data-table th[data-sort-key]:not([data-sort-dir]) .sort-arrow::after { content: '\21C5'; }
.data-table th[data-sort-key]:not([data-sort-dir]):hover .sort-arrow { opacity: 0.7; }
/* Active sort direction */
.data-table th[data-sort-key][data-sort-dir="asc"] .sort-arrow::after { content: '\2191'; }
.data-table th[data-sort-key][data-sort-dir="desc"] .sort-arrow::after { content: '\2193'; }
.data-table th[data-sort-key][data-sort-dir] .sort-arrow { opacity: 1; color: var(--accent-teal); }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
  font-size: 14px;
}

/* Delta indicator for inline percentage changes */
.delta {
  color: var(--text-muted);
  font-size: 0.85em;
}

/* Rate indicator with lightning bolt */
.rate-indicator {
  color: var(--text-muted);
  font-size: 0.85em;
  margin-left: 4px;
}

/* Table legend for explaining symbols */
.table-legend {
  color: var(--text-muted);
  font-size: 12px;
  margin-left: auto;
  margin-right: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-teal-muted);
  color: var(--accent-teal);
}

.table-info {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* Table Footer */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  gap: 12px;
}

/* Session Expansion Row */
.session-detail-row td {
  padding: 0;
  border-bottom: 1px solid var(--border-light);
}
.session-detail-row .session-detail-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 300ms ease, padding 300ms ease;
}
.session-detail-row.expanded .session-detail-content {
  max-height: 300px;
  padding: 16px 14px;
}
.session-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.detail-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.detail-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.detail-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

/* ═══════════════════════════════════════════
   13. PAGINATION
   ═══════════════════════════════════════════ */

.table-pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.table-pagination:empty { display: none; }

.page-btn {
  padding: 6px 11px;
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.page-btn:hover {
  background: var(--surface-card-alt);
  border-color: var(--accent-teal);
  color: var(--accent-teal);
}
.page-btn.active {
  background: var(--accent-teal);
  color: var(--text-inverse);
  border-color: var(--accent-teal);
}
.page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.page-ellipsis {
  padding: 6px 4px;
  color: var(--text-muted);
  font-size: 12px;
  user-select: none;
}

/* ═══════════════════════════════════════════
   14. MODAL
   ═══════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--surface-overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  transition: opacity var(--transition-base);
}
.modal-overlay:not([hidden]) { opacity: 1; }
.modal-overlay[hidden] { pointer-events: none; }

.modal-content {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 800px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(8px);
  transition: transform var(--transition-base);
}
.modal-overlay:not([hidden]) .modal-content { transform: translateY(0); }
.modal-content::-webkit-scrollbar { width: 5px; }
.modal-content::-webkit-scrollbar-track { background: transparent; }
.modal-content::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 3px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  background: var(--surface-card);
  z-index: 1;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.modal-close:hover {
  background: var(--surface-card-alt);
  color: var(--text-primary);
}
.modal-close svg { width: 16px; height: 16px; }

.modal-body { padding: 24px; }

.modal-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.modal-kpi {
  text-align: center;
  padding: 16px 12px;
  background: var(--surface-inset);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.modal-kpi-value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.modal-kpi-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.modal-chart-container {
  height: 240px;
  margin-bottom: 24px;
  position: relative;
}

.modal-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.modal-insight {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
  padding: 14px 16px;
  background: var(--surface-inset);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  border: 1px solid var(--border-light);
}

/* ═══════════════════════════════════════════
   15. LOGIN PAGE
   ═══════════════════════════════════════════ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--surface-page);
}

.login-card {
  background: var(--surface-card);
  border-radius: var(--radius-xl);
  padding: 48px;
  width: 100%;
  max-width: 400px;
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-md);
  position: relative;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}
.login-header .brand-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--accent-teal);
}
.login-header h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.login-header p {
  color: var(--text-secondary);
  font-size: 14px;
}

.form-group { margin-bottom: 20px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.input-wrapper input {
  width: 100%;
  padding: 12px 12px 12px 44px;
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  font-size: 14px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input-wrapper input:focus {
  outline: none;
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 3px var(--accent-teal-muted);
}

.toggle-password {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}
.toggle-password svg { width: 18px; height: 18px; display: none; }
.toggle-password .icon-eye { display: block; }
.toggle-password.showing .icon-eye { display: none; }
.toggle-password.showing .icon-eye-off { display: block; }

.error-message {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 20px;
  border: 1px solid var(--status-danger);
}
.error-message svg { width: 16px; height: 16px; flex-shrink: 0; }

.login-button {
  width: 100%;
  padding: 13px;
  background: var(--accent-teal);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}
.login-button:hover { opacity: 0.92; }
.login-button:active { transform: scale(0.99); }
.login-button svg { width: 18px; height: 18px; }

.login-card .theme-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
}

/* ═══════════════════════════════════════════
   16a. FOOTER
   ═══════════════════════════════════════════ */

.app-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-default);
  background: var(--surface-card);
}

.footer-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.footer-brand {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

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

.footer-links {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.footer-sep {
  color: var(--text-muted);
}

.footer-link {
  color: var(--accent-teal);
  text-decoration: none;
  transition: opacity var(--transition-fast);
}
.footer-link:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.footer-support {
  color: var(--text-muted);
}
.footer-support:hover {
  color: #FFDD00;
  opacity: 1;
}

.footer-update {
  display: inline-flex;
  align-items: center;
}
.footer-update[hidden] {
  display: none;
}

.footer-update-btn {
  background: var(--accent-coral, #D97757);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  animation: update-pulse 2s ease-in-out infinite;
}
.footer-update-btn:hover {
  opacity: 0.9;
  transform: scale(1.05);
}
.footer-update-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  animation: none;
}
@keyframes update-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 119, 87, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(217, 119, 87, 0); }
}

/* ═══════════════════════════════════════════
   16b. PASSWORD CHANGE MODAL
   ═══════════════════════════════════════════ */

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  font-size: 14px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-sizing: border-box;
}
.form-input:focus {
  outline: none;
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 3px var(--accent-teal-muted);
}

.password-submit-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent-teal);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition-fast);
  margin-top: 8px;
}
.password-submit-btn:hover { opacity: 0.92; }
.password-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.password-error {
  padding: 10px 14px;
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
  border: 1px solid var(--status-danger);
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 12px;
}

.password-success {
  padding: 10px 14px;
  background: var(--status-healthy-bg);
  color: var(--status-healthy-text);
  border: 1px solid var(--status-healthy);
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 12px;
}

/* ═══════════════════════════════════════════
   16. RESPONSIVE
   ═══════════════════════════════════════════ */

@media (min-width: 1400px) {
  .main-content { max-width: 1400px; }
}

@media (min-width: 1024px) and (max-width: 1399px) {
  .main-content { max-width: 1100px; }
}

@media (min-width: 769px) and (max-width: 1023px) {
  .quota-grid { grid-template-columns: repeat(2, 1fr); }
  .quota-card:nth-child(3) { grid-column: 1 / -1; }
  .table-controls { flex-wrap: wrap; }
  .both-view { grid-template-columns: 1fr; }
  .chart-container.both-charts { grid-template-columns: 1fr; }
  .insights-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .app-header { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .brand-text { font-size: 18px; }
  .main-content { padding: 16px; }
  .quota-grid { grid-template-columns: 1fr; gap: 14px; }
  .quota-card { padding: 18px; }
  .range-selector { width: 100%; }
  .range-btn { flex: 1; padding: 8px; font-size: 12px; }
  .login-card { padding: 32px 24px; }
  .table-controls { flex-direction: column; align-items: stretch; }
  .section-header { flex-direction: column; align-items: flex-start; }
  .header-meta { gap: 8px; }
  .session-detail-grid { grid-template-columns: repeat(2, 1fr); }
  .cycles-filters-inline { gap: 6px; }
  .cycles-filters-inline .filter-group { width: 100%; }
  .cycles-filters-inline .filter-pills { flex: 1; }
  .filter-pill { flex: 1; text-align: center; padding: 5px 6px; font-size: 11px; }
  .insights-stats { grid-template-columns: repeat(2, 1fr); }
  .insights-cards { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .welcome-title { font-size: 22px; }
  .both-view { grid-template-columns: 1fr; gap: 16px; }
  .chart-container.both-charts { grid-template-columns: 1fr; }
  .provider-tabs { margin-left: 0; }
  .provider-tab { padding: 5px 12px; font-size: 12px; }
}

@media (max-width: 480px) {
  .app-header { padding: 10px 12px; }
  .brand-text { font-size: 16px; }
  .brand-icon { width: 26px; height: 26px; }
  .main-content { padding: 12px; }
  .quota-card { padding: 16px; border-radius: var(--radius-md); }
  .usage-percent { font-size: 26px; }
  .countdown { font-size: 12px; }
  .section-title { font-size: 15px; }
  .insights-panel, .chart-section, .cycle-overview-section, .cycles-section, .sessions-section {
    padding: 16px;
    border-radius: var(--radius-md);
  }
  .insights-stats { grid-template-columns: 1fr; }
  .chart-container { height: 220px; }
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 6px; }
  .modal-content { width: 100%; max-width: 100%; max-height: 100vh; border-radius: 0; }
  .modal-header { border-radius: 0; }
  .modal-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .session-detail-grid { grid-template-columns: 1fr; }
  .last-updated { font-size: 11px; }
  .timezone-badge { font-size: 10px; }
  .welcome-title { font-size: 20px; }
}

/* ═══════════════════════════════════════════
   18. SETTINGS PAGE
   ═══════════════════════════════════════════ */

.settings-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface-page);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-default);
  position: sticky;
  top: 0;
  z-index: 100;
}

.settings-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.settings-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition-fast);
}
.settings-back:hover {
  background: var(--surface-card-alt);
  color: var(--text-primary);
}
.settings-back svg { width: 20px; height: 20px; }

.settings-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin: 0;
}

.settings-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 2px 0 0;
}

.beta-tag {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-blue-light);
  color: var(--accent-blue-text);
  vertical-align: middle;
  margin-left: 6px;
}

.settings-main {
  flex: 1;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

/* Tabs */
.settings-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-inset);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.settings-tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.settings-tab:hover {
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.03);
}
.settings-tab.active {
  background: var(--surface-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

[data-theme="dark"] .settings-tab:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Panels */
.settings-panel {
  display: none;
  animation: settingsFadeIn 200ms ease;
}
.settings-panel.active { display: block; }

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

/* Sections */
.settings-section {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
}

.settings-section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px;
}

.settings-section-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 20px;
}

/* Fields */
.settings-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.settings-field {
  grid-column: span 2;
}

.settings-field-half {
  grid-column: span 1;
}

.settings-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.settings-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-sizing: border-box;
}
.settings-input:focus {
  outline: none;
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 3px var(--accent-teal-muted);
}

.settings-input-sm {
  width: 72px;
  text-align: center;
  flex-shrink: 0;
}

select.settings-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.settings-field-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Threshold slider group */
.threshold-input-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.threshold-slider {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-default);
  border-radius: 3px;
  outline: none;
}
.threshold-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent-teal);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--surface-card);
  box-shadow: var(--shadow-xs);
}
.threshold-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--accent-teal);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--surface-card);
  box-shadow: var(--shadow-xs);
}

/* Checkboxes */
.settings-checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  grid-column: span 2;
}
.settings-checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-teal);
  cursor: pointer;
}

/* Toggle switches */
.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface-inset);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  grid-column: span 2;
}

.settings-toggle-row-dual {
  flex-wrap: wrap;
  gap: 12px;
}

.settings-toggle-info {
  flex: 1;
  min-width: 140px;
}

.settings-toggle-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.settings-toggle-sublabel {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.settings-toggle-group {
  display: flex;
  gap: 20px;
  align-items: center;
}

.settings-toggle-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.settings-toggle-item-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.settings-toggle-item-hint {
  font-size: 10px;
  color: var(--text-muted);
  max-width: 120px;
  text-align: center;
  line-height: 1.3;
}

.settings-toggle-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.settings-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.settings-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.settings-toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border-default);
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.settings-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition-fast);
  box-shadow: var(--shadow-xs);
}
.settings-toggle input:checked + .settings-toggle-track {
  background: var(--accent-teal);
}
.settings-toggle input:checked + .settings-toggle-track::after {
  transform: translateX(20px);
}

/* Override list */
.override-list {
  margin-bottom: 12px;
}

.settings-override-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}
.settings-override-row:last-child { border-bottom: none; }
.settings-override-row select { flex: 1; min-width: 0; }
.settings-override-row input[type="number"] { width: 72px; }
.settings-override-row .override-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--status-danger);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.settings-override-row .override-remove:hover {
  background: var(--status-danger-bg);
}
.settings-override-row .override-remove svg { width: 16px; height: 16px; }

.settings-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px dashed var(--border-default);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.settings-add-btn:hover {
  border-color: var(--accent-teal);
  color: var(--accent-teal);
}
.settings-add-btn svg { width: 14px; height: 14px; }

/* Divider */
.settings-divider {
  height: 0;
  margin: 0;
}

/* Actions (test button row) */
.settings-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

.settings-test-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.settings-test-btn:hover {
  border-color: var(--accent-teal);
  color: var(--accent-teal);
}
.settings-test-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.settings-test-btn svg { width: 16px; height: 16px; }
.settings-test-btn-sm { padding: 6px 12px; font-size: 12px; }
.settings-toggle-actions-wrap { display: flex; align-items: center; gap: 12px; }

.settings-test-result {
  font-size: 13px;
}
.settings-test-result.success { color: var(--status-healthy); }
.settings-test-result.error { color: var(--status-danger); }

/* Save bar */
.settings-save-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-default);
}

.settings-save-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  background: var(--accent-teal);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}
.settings-save-btn:hover { opacity: 0.92; }
.settings-save-btn:active { transform: scale(0.98); }
.settings-save-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.settings-save-btn svg { width: 16px; height: 16px; }

.settings-save-btn-secondary {
  background: var(--surface-card);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  margin-top: 16px;
}
.settings-save-btn-secondary:hover {
  border-color: var(--accent-teal);
  color: var(--accent-teal);
  opacity: 1;
}

/* Feedback messages */
.settings-feedback {
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
}
.settings-feedback.success {
  background: var(--status-healthy-bg);
  color: var(--status-healthy-text);
  border: 1px solid var(--status-healthy);
}
.settings-feedback.error {
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
  border: 1px solid var(--status-danger);
}

/* Settings page responsive */
@media (max-width: 768px) {
  .settings-main { padding: 16px; }
  .settings-fields { grid-template-columns: 1fr; }
  .settings-field-half { grid-column: span 1; }
  .settings-tabs { flex-wrap: wrap; }
  .settings-tab { flex: none; padding: 8px 14px; font-size: 12px; }
  .settings-header { padding: 12px 16px; }
  .settings-title { font-size: 18px; }
  .settings-actions { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .settings-section { padding: 16px; }
  .settings-tabs { gap: 2px; padding: 3px; }
  .settings-tab { padding: 7px 10px; font-size: 11px; }
  .threshold-input-group { flex-direction: column; align-items: stretch; }
  .settings-input-sm { width: 100%; }
}

/* ═══════════════════════════════════════════
   17. CODEX PROFILE TABS
   ═══════════════════════════════════════════ */

.codex-profile-tabs {
  display: flex;
  gap: 2px;
  background: var(--surface-inset);
  padding: 2px;
  border-radius: var(--radius-sm);
  margin-left: 8px;
}

.codex-profile-tabs::before {
  content: '';
  width: 1px;
  background: var(--border-default);
  margin: 4px 6px 4px 0;
}

.profile-tab {
  padding: 4px 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.profile-tab:hover {
  color: var(--text-primary);
  background: var(--surface-card);
}

.profile-tab.active {
  background: var(--surface-card);
  color: var(--accent-codex);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

/* Codex account headers for "both" view */
.codex-account-header {
  grid-column: 1 / -1;
  padding: 8px 0 4px;
  margin-top: 8px;
}

.codex-account-header:first-child {
  margin-top: 0;
}

.codex-account-name {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-codex);
  opacity: 0.8;
}

.codex-account-cards {
  display: contents;
}

/* ═══════════════════════════════════════════
   18. REDUCED MOTION
   ═══════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .progress-fill { transition: none; }
  .quota-card, .insights-panel, .chart-section, .cycle-overview-section, .cycles-section, .sessions-section {
    opacity: 1;
    animation: none;
  }
}
