/* ========================================
   AI Orchestrator Dashboard Styles
   Modern glassmorphism with dark theme
   ======================================== */

:root {
  /* Colors */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a24;
  --surface: rgba(255, 255, 255, 0.03);
  --surface-hover: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-active: rgba(255, 255, 255, 0.15);

  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.4);

  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-purple: #8b5cf6;
  --accent-orange: #f59e0b;
  --accent-red: #ef4444;
  --accent-cyan: #06b6d4;

  --gradient-primary: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(59, 130, 246, 0.15);

  /* Sidebar */
  --sidebar-width: 260px;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* App Layout */
.app {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* Animated Background */
.bg-gradient {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(
      ellipse 80% 50% at 50% -20%,
      rgba(59, 130, 246, 0.15),
      transparent
    ),
    radial-gradient(
      ellipse 60% 40% at 80% 100%,
      rgba(139, 92, 246, 0.1),
      transparent
    ),
    radial-gradient(
      ellipse 40% 30% at 10% 80%,
      rgba(6, 182, 212, 0.08),
      transparent
    );
  pointer-events: none;
  z-index: 0;
}

.bg-grid {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: rgba(18, 18, 26, 0.8);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: var(--gradient-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
}

.logo-icon svg {
  width: 22px;
  height: 22px;
  color: white;
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 600;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Navigation */
.nav {
  flex: 1;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

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

.nav-item:hover svg {
  opacity: 1;
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
}

.nav-item.active svg {
  opacity: 1;
}

.sidebar-footer {
  padding: var(--space-lg);
  border-top: 1px solid var(--border);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

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

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }
  50% {
    opacity: 0.8;
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
}

/* Main Content */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: var(--space-xl);
  position: relative;
  z-index: 1;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-xl);
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.page-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn svg {
  width: 16px;
  height: 16px;
}

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

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: var(--border-active);
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 50px rgba(59, 130, 246, 0.25);
}

.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.8125rem;
}

/* Profile Badge */
.profile-badge {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.profile-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.profile-select {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  min-width: 120px;
}

.profile-select:focus {
  outline: none;
  border-color: var(--accent-blue);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--surface);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stat-card:hover {
  border-color: var(--border-active);
  transform: translateY(-2px);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon svg {
  width: 24px;
  height: 24px;
}

.stat-icon.blue {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
}

.stat-icon.green {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

.stat-icon.purple {
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent-purple);
}

.stat-icon.orange {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-orange);
}

.stat-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.stat-trend {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
}

.stat-trend svg {
  width: 14px;
  height: 14px;
}

.stat-trend.up {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

.stat-trend.down {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}

/* Main Grid */
.main-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

/* Panel */
.panel {
  background: var(--surface);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.panel-header h2 {
  font-size: 1.0625rem;
  font-weight: 600;
}

.badge {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  font-size: 0.75rem;
  font-weight: 500;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
}

/* Rankings List */
.rankings-list {
  padding: var(--space-md);
  max-height: 400px;
  overflow-y: auto;
}

.ranking-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  transition: background 0.2s ease;
}

.ranking-item:hover {
  background: var(--surface-hover);
}

.ranking-position {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.ranking-position.top-3 {
  background: var(--gradient-primary);
  color: white;
}

.ranking-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ranking-name {
  font-weight: 500;
  font-size: 0.9375rem;
}

.ranking-provider {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.ranking-score {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.score-bar {
  width: 80px;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.score-value {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 40px;
  text-align: right;
}

/* Profiles Grid */
.profiles-grid {
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.profile-card {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.profile-card:hover {
  border-color: var(--border-active);
}

.profile-card.active {
  border-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.1);
}

.profile-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.profile-card-name {
  font-weight: 600;
  font-size: 0.9375rem;
  text-transform: capitalize;
}

.profile-card-icon {
  width: 24px;
  height: 24px;
  color: var(--text-muted);
}

.profile-weights {
  display: flex;
  gap: var(--space-xs);
}

.weight-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.weight-fill {
  height: 100%;
  border-radius: 2px;
}

.weight-fill.quality {
  background: var(--accent-blue);
}
.weight-fill.latency {
  background: var(--accent-green);
}
.weight-fill.cost {
  background: var(--accent-orange);
}

/* Activity List */
.activity-panel {
  margin-bottom: var(--space-xl);
}

.activity-list {
  padding: var(--space-md);
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  transition: background 0.2s ease;
}

.activity-item:hover {
  background: var(--surface-hover);
}

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.activity-icon svg {
  width: 16px;
  height: 16px;
}

.activity-icon.success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

.activity-icon.info {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
}

.activity-icon.warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-orange);
}

.activity-content {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.activity-text {
  font-size: 0.9375rem;
}

.activity-time {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Loading Skeleton */
.loading-skeleton {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-md);
}

.skeleton-row {
  height: 48px;
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 25%,
    var(--surface-hover) 50%,
    var(--bg-tertiary) 75%
  );
  background-size: 200% 100%;
  border-radius: var(--radius-md);
  animation: shimmer 1.5s infinite;
}

.skeleton-card {
  height: 80px;
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 25%,
    var(--surface-hover) 50%,
    var(--bg-tertiary) 75%
  );
  background-size: 200% 100%;
  border-radius: var(--radius-md);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Hidden */
.hidden {
  display: none !important;
}

/* Models Table */
.models-table-container {
  overflow-x: auto;
}

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

.models-table th,
.models-table td {
  padding: var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.models-table th {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-tertiary);
}

.models-table td {
  font-size: 0.9375rem;
}

.models-table tbody tr {
  transition: background 0.2s ease;
}

.models-table tbody tr:hover {
  background: var(--surface-hover);
}

.search-input {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  min-width: 200px;
}

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

.search-input:focus {
  outline: none;
  border-color: var(--accent-blue);
}

/* Status Tag */
.status-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 2px var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
}

.status-tag.healthy {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

.status-tag.degraded {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-orange);
}

.status-tag.offline {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}

/* Routing Page */
.routing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

.profile-config {
  padding: var(--space-lg);
}

.config-group {
  margin-bottom: var(--space-xl);
}

.config-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.config-slider {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  appearance: none;
  outline: none;
}

.config-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent-blue);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.weights-chart {
  padding: var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

/* Playground */
.playground-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  min-height: calc(100vh - 200px);
}

.playground-input,
.playground-output {
  display: flex;
  flex-direction: column;
}

.prompt-input {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9375rem;
  resize: none;
  min-height: 200px;
  margin: var(--space-md);
}

.prompt-input:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.playground-controls {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  border-top: 1px solid var(--border);
}

.routing-result {
  flex: 1;
  padding: var(--space-lg);
  overflow-y: auto;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: var(--space-md);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: 0.5;
}

/* Result Card */
.result-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
}

.result-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.result-card-title {
  font-weight: 600;
  font-size: 1.125rem;
}

.result-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.result-metric {
  text-align: center;
  padding: var(--space-md);
  background: var(--surface);
  border-radius: var(--radius-md);
}

.result-metric-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent-blue);
}

.result-metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* Responsive */
@media (max-width: 1400px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1200px) {
  .main-grid {
    grid-template-columns: 1fr;
  }

  .routing-grid,
  .playground-container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .main {
    margin-left: 0;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Analytics Page */
.usage-chart {
  padding: var(--space-lg);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-placeholder {
  width: 100%;
  text-align: center;
}

.mini-chart {
  width: 100%;
  height: 120px;
  margin-bottom: var(--space-md);
}

.chart-note {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.model-breakdown {
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.breakdown-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.breakdown-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.breakdown-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.breakdown-percent {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.breakdown-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.breakdown-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.profile-usage {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  padding: var(--space-lg);
}

.profile-usage-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  text-align: center;
  transition: all 0.2s ease;
}

.profile-usage-card:hover {
  border-color: var(--border-active);
  transform: translateY(-2px);
}

.profile-usage-value {
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--space-xs);
}

.profile-usage-name {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-transform: capitalize;
}

@media (max-width: 900px) {
  .profile-usage {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-lg);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-xs);
  line-height: 1;
  transition: color var(--transition-fast);
}

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

/* Form Styles */
.modal form {
  padding: var(--space-lg);
}

.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
}

.form-group input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  transition: border-color var(--transition-fast);
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

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

.form-group small {
  display: block;
  margin-top: var(--space-xs);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border);
}

/* Button Variants */
.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.875rem;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.panel-actions .btn {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* ===== Budget Widget (Header) ===== */
.budget-widget {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 160px;
}

.budget-widget:hover {
  border-color: var(--border-active);
  background: var(--surface-hover);
}

.budget-widget-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 185, 129, 0.15);
  border-radius: var(--radius-sm);
}

.budget-widget-icon svg {
  width: 18px;
  height: 18px;
  color: var(--accent-green);
}

.budget-widget.warning .budget-widget-icon {
  background: rgba(245, 158, 11, 0.15);
}

.budget-widget.warning .budget-widget-icon svg {
  color: var(--accent-orange);
}

.budget-widget.exceeded .budget-widget-icon {
  background: rgba(239, 68, 68, 0.15);
}

.budget-widget.exceeded .budget-widget-icon svg {
  color: var(--accent-red);
}

.budget-widget-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.budget-widget-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.budget-widget-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.budget-widget-bar {
  width: 60px;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
  margin-left: auto;
}

.budget-widget-fill {
  height: 100%;
  background: var(--accent-green);
  border-radius: 2px;
  transition:
    width 0.3s ease,
    background 0.3s ease;
}

.budget-widget.warning .budget-widget-fill {
  background: var(--accent-orange);
}

.budget-widget.exceeded .budget-widget-fill {
  background: var(--accent-red);
}

/* ===== Settings Page ===== */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

.settings-form {
  padding: var(--space-lg);
}

.settings-form .form-group {
  margin-bottom: var(--space-lg);
}

.settings-form label {
  display: block;
  font-weight: 500;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.settings-form input[type="number"] {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-family: inherit;
}

.settings-form input[type="number"]:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.settings-form input[type="range"] {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  -webkit-appearance: none;
  appearance: none;
}

.settings-form input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent-blue);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-xs);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.range-labels span:nth-child(2) {
  font-weight: 600;
  color: var(--accent-blue);
}

/* Toggle Switch */
.toggle-label {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  cursor: pointer;
}

.toggle-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-switch {
  width: 44px;
  height: 24px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  position: relative;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: all 0.2s ease;
}

.toggle-label input:checked + .toggle-switch {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
}

.toggle-label input:checked + .toggle-switch::after {
  left: 23px;
  background: white;
}

/* Spending Cards */
.spending-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-lg);
}

.spending-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.spending-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.spending-card-label {
  font-weight: 500;
  color: var(--text-secondary);
}

.spending-card-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
}

.spending-card-status.ok {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

.spending-card-status.warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-orange);
}

.spending-card-status.exceeded {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}

.spending-card-value {
  display: flex;
  align-items: baseline;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
}

.spending-card-value > span:first-child {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.spending-card-limit {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.spending-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.spending-fill {
  height: 100%;
  background: var(--accent-green);
  border-radius: 3px;
  transition:
    width 0.3s ease,
    background 0.3s ease;
}

.spending-fill.warning {
  background: var(--accent-orange);
}

.spending-fill.exceeded {
  background: var(--accent-red);
}

/* Spending Alert */
.spending-alert {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  margin: var(--space-lg);
  margin-top: 0;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-md);
  color: var(--accent-orange);
}

.spending-alert svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.spending-alert.exceeded {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--accent-red);
}

/* ===== Responsive Adjustments ===== */
@media (max-width: 1200px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .budget-widget {
    display: none;
  }
}

/* ===== Local Models Page ===== */
.local-models-status-panel {
  margin-bottom: var(--space-lg);
}

.local-status-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.local-status-icon svg {
  color: var(--text-muted);
}

.local-status-icon.available {
  background: rgba(16, 185, 129, 0.15);
}

.local-status-icon.available svg {
  color: var(--accent-green);
}

.local-status-icon.offline {
  background: rgba(239, 68, 68, 0.15);
}

.local-status-icon.offline svg {
  color: var(--accent-red);
}

.local-status-content {
  flex: 1;
}

.local-status-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
}

.local-status-message {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Local Model Cards */
.local-model-card {
  padding: var(--space-md);
}

.local-model-card .model-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.local-model-card .model-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
}

.local-model-card .tag-local {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  font-size: 0.6875rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.local-model-card .tag-free {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  font-size: 0.6875rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.local-model-card .model-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.local-model-card .model-actions {
  display: flex;
  gap: var(--space-sm);
}

/* Empty State */
.local-model-empty {
  grid-column: 1 / -1;
}

.empty-state {
  padding: var(--space-xl);
  text-align: center;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.empty-state h3 {
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.empty-state p {
  margin-bottom: var(--space-md);
}

.empty-state code {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 0.875rem;
}

/* Popular Models Grid */
.popular-models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-sm);
}

.popular-model-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.popular-model-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-blue);
  transform: translateY(-2px);
}

.popular-model-btn .model-name {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.popular-model-btn .model-size {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.local-models-pull-panel {
  margin-top: var(--space-lg);
}
