:root {
  --bg: #090d16;
  --bg-gradient: radial-gradient(circle at 50% 0%, #151c30 0%, #090d16 100%);
  --surface: rgba(20, 28, 47, 0.45);
  --surface-hover: rgba(28, 38, 63, 0.65);
  --surface-muted: rgba(11, 16, 28, 0.6);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --text: #f3f4f6;
  --muted: #9ca3af;
  --primary: #6366f1; /* Electric Violet/Indigo */
  --primary-soft: rgba(99, 102, 241, 0.15);
  --primary-glow: rgba(99, 102, 241, 0.4);
  --success: #10b981; /* Emerald Green */
  --success-soft: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b; /* Amber */
  --danger: #f43f5e; /* Rose Red */
  --danger-soft: rgba(244, 63, 94, 0.15);
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
  --glass-blur: blur(16px);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-mode {
  --bg: #f8fafc;
  --bg-gradient: radial-gradient(circle at 50% 0%, #eff6ff 0%, #f8fafc 100%);
  --surface: rgba(255, 255, 255, 0.7);
  --surface-hover: rgba(255, 255, 255, 0.9);
  --surface-muted: rgba(241, 245, 249, 0.8);
  --border: rgba(15, 23, 42, 0.08);
  --border-hover: rgba(15, 23, 42, 0.15);
  --text: #0f172a;
  --muted: #64748b;
  --shadow: 0 8px 32px 0 rgba(15, 23, 42, 0.06);
}

/* Theme Toggle Button Style */
.theme-toggle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
}

.theme-toggle-button:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

body.light-mode .theme-toggle-button:hover {
  color: #000000;
}

body .theme-icon-sun {
  display: block;
  width: 20px;
  height: 20px;
}

body .theme-icon-moon {
  display: none;
  width: 20px;
  height: 20px;
}

body.light-mode .theme-icon-sun {
  display: none;
}

body.light-mode .theme-icon-moon {
  display: block;
}

/* Light Mode Overrides for UI components */
body.light-mode .sidebar {
  background: rgba(248, 250, 252, 0.85);
  color: #334155;
  border-right: 1px solid var(--border);
}

body.light-mode .brand-mark {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(99, 102, 241, 0.02) 100%);
  color: #4f46e5;
  border-color: rgba(99, 102, 241, 0.2);
}

body.light-mode .brand h1 {
  background: linear-gradient(to right, #0f172a, #334155);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

body.light-mode .nav-link {
  color: #475569;
}

body.light-mode .nav-link:hover,
body.light-mode .nav-link:focus {
  background: rgba(15, 23, 42, 0.04);
  color: #0f172a;
}

body.light-mode .nav-link.active {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
}

body.light-mode .sidebar-footer {
  border-top: 1px solid var(--border);
  color: #475569;
}

/* Legacy chart light mode rules removed */

body.light-mode .feature-tile strong {
  color: #0f172a;
}

body.light-mode .feature-tile:hover {
  background: rgba(99, 102, 241, 0.05);
}

body.light-mode .activity-list,
body.light-mode .note-list {
  color: #334155;
}

body.light-mode .activity-time {
  color: #4f46e5;
}


* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  background-image: var(--bg-gradient);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  border: none;
  background: none;
}

/* App Layout Shell */
.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 32px;
  border-right: 1px solid var(--border);
  background: rgba(10, 15, 28, 0.8);
  backdrop-filter: var(--glass-blur);
  padding: 32px 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25) 0%, rgba(99, 102, 241, 0.05) 100%);
  color: #a5b4fc;
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 900;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.15);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.brand .eyebrow {
  color: #818cf8;
}

.brand h1 {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.15;
  background: linear-gradient(to right, #ffffff, #c7d2fe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Nav Menu */
.nav-list {
  display: grid;
  gap: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 10px;
  color: #94a3b8;
  padding: 12px 14px;
  font-weight: 500;
  transition: var(--transition);
}

.nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.7;
  transition: var(--transition);
}

.nav-link:hover,
.nav-link:focus {
  background: rgba(255, 255, 255, 0.04);
  color: #f1f5f9;
  outline: none;
}

.nav-link.active {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.25);
}

.nav-link.active .nav-icon {
  color: #818cf8;
  opacity: 1;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 24px;
  color: #94a3b8;
  font-size: 13px;
}

/* Main Content Area */
.main-content {
  min-width: 0;
  padding: 40px 48px;
}

/* Page Header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
}

.page-header h2 {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: 34px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.page-summary {
  max-width: 720px;
  margin: 8px 0 0;
  color: var(--muted);
}

/* Actions Header */
.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 6px;
}

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

.refresh-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
  color: #ffffff;
  cursor: pointer;
  font-weight: 600;
  padding: 0 18px;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.25);
  transition: var(--transition);
}

.refresh-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.refresh-button:active:not(:disabled) {
  transform: translateY(0);
}

.refresh-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.refresh-icon {
  width: 15px;
  height: 15px;
  transition: transform 0.5s ease;
}

.refresh-button:hover .refresh-icon {
  transform: rotate(180deg);
}

/* KPI Cards Section */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  backdrop-filter: var(--glass-blur);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

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

.kpi-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.kpi-value {
  font-family: 'Outfit', sans-serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  margin-top: 6px;
}

.kpi-detail {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

/* Accent Card colors based on health/value */
.edge-card,
.backend-card {
  border-left: 3px solid #475569;
}

.kpi-card.ok-kpi {
  border-left: 3px solid var(--success);
}

.kpi-card.warn-kpi {
  border-left: 3px solid var(--warning);
}

.kpi-card.error-kpi {
  border-left: 3px solid var(--danger);
}

/* Legacy stock profit card rules removed */

/* Dashboard Columns Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: 20px;
  align-items: start;
}

.dashboard-column-left,
.dashboard-column-right {
  display: grid;
  gap: 20px;
}

/* Panels Styling */
.panel {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  backdrop-filter: var(--glass-blur);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.panel:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.panel h3 {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.panel p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  padding: 0 12px;
  white-space: nowrap;
}

.badge.ok {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge.warn {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge.error {
  background: rgba(244, 63, 94, 0.12);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.2);
}

/* Service Health Columns */
.health-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.health-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-muted);
  padding: 20px;
}

.health-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.health-value-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #64748b;
  box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.2);
}

.status-dot.ok {
  background: var(--success);
  box-shadow: 0 0 12px var(--success), 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.status-dot.warn {
  background: var(--warning);
  box-shadow: 0 0 12px var(--warning), 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.status-dot.error {
  background: var(--danger);
  box-shadow: 0 0 12px var(--danger), 0 0 0 3px rgba(244, 63, 94, 0.2);
}

.health-metric {
  font-family: 'Outfit', sans-serif;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
}

.health-detail {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

/* Linear Meters */
.meter {
  overflow: hidden;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(to right, #818cf8, var(--primary));
  transition: width 0.35s ease;
}

.meter span.warn {
  background: linear-gradient(to right, #fbbf24, var(--warning));
}

.meter span.error {
  background: linear-gradient(to right, #f43f5e, var(--danger));
}

/* Legacy stock allocation and table styles removed */

/* Right Navigation Cards */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.feature-tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 86px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-muted);
  padding: 16px;
  transition: var(--transition);
}

.feature-tile:hover {
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.08);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.08);
  transform: translateY(-1px);
}

.feature-tile strong {
  color: #ffffff;
  font-weight: 600;
}

.feature-tile span {
  color: var(--muted);
  font-size: 12px;
}

/* Activity logs and Operational Notes styling */
.activity-list,
.note-list {
  margin: 0;
  padding-left: 18px;
  color: #cbd5e1;
}

.activity-list li,
.note-list li {
  margin-top: 12px;
  font-size: 13.5px;
}

.activity-list li:first-child,
.note-list li:first-child {
  margin-top: 0;
}

.activity-time {
  display: inline-block;
  min-width: 48px;
  color: #818cf8;
  font-weight: 700;
  font-size: 12px;
}

.note-list {
  color: var(--muted);
}

/* Utility classes for colors */
.color-gain {
  color: var(--success) !important;
}

.color-loss {
  color: var(--danger) !important;
}

.badge-gain {
  background: rgba(16, 185, 129, 0.12) !important;
  color: #34d399 !important;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-loss {
  background: rgba(244, 63, 94, 0.12) !important;
  color: #fb7185 !important;
  border: 1px solid rgba(244, 63, 94, 0.2);
}

/* Responsive Breakpoints */
@media (max-width: 1240px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .nav-list {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }

  .sidebar-footer {
    margin-top: 16px;
    padding-top: 16px;
  }

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

@media (max-width: 768px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Legacy allocation layout media rule removed */
  
  .main-content {
    padding: 32px 24px;
  }
}

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

  .health-grid {
    grid-template-columns: 1fr;
  }
  
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .header-actions {
    flex-direction: column;
    align-items: stretch;
  }
  
  .refresh-button {
    justify-content: center;
  }
}
