/* ============================================================
   GenTrack AI — style.css
   Industrial IoT Monitoring Dashboard — Dark Theme
   ============================================================ */

/* ===== GOOGLE FONTS ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ===== CSS VARIABLES ===== */
:root {
  /* Core Colors */
  --bg-base: #0a0d12;
  --bg-surface: #111620;
  --bg-elevated: #161c2a;
  --bg-card: #141927;
  --bg-card-hover: #1a2033;
  --border: rgba(255, 255, 255, 0.07);
  --border-light: rgba(255, 255, 255, 0.04);

  /* Accent Palette */
  --green: #00c97a;
  --green-dim: rgba(0, 201, 122, 0.12);
  --green-glow: rgba(0, 201, 122, 0.25);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.12);
  --blue-glow: rgba(59, 130, 246, 0.25);
  --yellow: #f59e0b;
  --yellow-dim: rgba(245, 158, 11, 0.12);
  --yellow-glow: rgba(245, 158, 11, 0.25);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);
  --red-glow: rgba(239, 68, 68, 0.25);
  --orange: #f97316;
  --purple: #8b5cf6;

  /* Text */
  --text-primary: #e8edf5;
  --text-secondary: #8896ae;
  --text-muted: #55637a;
  --text-dim: #3d4d60;

  /* Sizes */
  --nav-height: 68px;
  --header-height: 60px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;

  /* Shadows */
  --shadow-card: 0 2px 16px rgba(0, 0, 0, 0.4);
  --shadow-elevated: 0 8px 32px rgba(0, 0, 0, 0.5);

  /* Transitions */
  --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.12s ease;
  --transition-spring: all 0.35s cubic-bezier(0.3, 1.4, 0.5, 1);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }

/* ===== HEADER ===== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-height);
  background: rgba(10, 13, 18, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.app-logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.4));
}

.header-titles {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.app-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  white-space: nowrap;
  background: linear-gradient(90deg, #ffffff, #a0b4d0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.device-name {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Status Pill */
.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.status-pill.running {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(0, 201, 122, 0.2);
}

.status-pill.stopped {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-pill.warning {
  background: var(--yellow-dim);
  color: var(--yellow);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulseDot 1.6s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.7); }
}

.sync-info {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  padding-top: var(--header-height);
  padding-bottom: calc(var(--nav-height) + 12px);
  min-height: 100vh;
  position: relative;
}

/* ===== PAGES ===== */
.page {
  display: none;
  animation: pageFadeIn 0.28s ease;
}

.page.active {
  display: block;
}

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

.page-inner {
  padding: 16px 16px 8px;
  max-width: 760px;
  margin: 0 auto;
}

/* ===== SECTION LABEL ===== */
.section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 20px 0 10px;
}

.section-label:first-child {
  margin-top: 4px;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

[role="button"], .card[role="button"] {
  cursor: pointer;
}

[role="button"]:hover, .card[role="button"]:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

[role="button"]:active, .card[role="button"]:active {
  transform: translateY(0);
  transition: var(--transition-fast);
}

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Card Header */
.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.fuel-icon { background: var(--yellow-dim); color: var(--yellow); }
.power-icon { background: var(--blue-dim); color: var(--blue); }
.energy-icon { background: var(--green-dim); color: var(--green); }
.eff-icon { background: var(--green-dim); color: var(--green); }

.card-title-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.card-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
}

.card-badge.normal { background: var(--green-dim); color: var(--green); }
.card-badge.warning { background: var(--yellow-dim); color: var(--yellow); }
.card-badge.critical { background: var(--red-dim); color: var(--red); }

/* Card Values */
.card-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin: 4px 0;
}
.card-value.sm { margin: 2px 0; }

.val-big {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.val-big.val-blue { color: var(--blue); }
.val-big.val-green { color: var(--green); }
.val-big.val-yellow { color: var(--yellow); }
.val-big.val-red { color: var(--red); }

.card-value.sm .val-big { font-size: 18px; }

.val-unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.card-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Progress Bar */
.progress-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.fuel-fill {
  background: linear-gradient(90deg, var(--yellow), #fbbf24);
  box-shadow: 0 0 8px var(--yellow-glow);
}

.progress-pct {
  font-size: 11px;
  font-weight: 600;
  color: var(--yellow);
  min-width: 30px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Trend */
.card-trend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 500;
  margin-top: 4px;
}

.trend-down { color: var(--red); }
.trend-up { color: var(--green); }
.trend-flat { color: var(--text-muted); }

/* Meta Row */
.card-meta-row {
  display: flex;
  gap: 12px;
  margin: 8px 0;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meta-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.meta-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Dual Stat */
.dual-stat {
  display: flex;
  gap: 12px;
  align-items: center;
}

.stat-item {
  flex: 1;
}

.stat-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-bottom: 2px;
}

.stat-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
}

/* Mini Sparkline */
.mini-sparkline {
  height: 32px;
  margin-top: 6px;
}

/* Efficiency Gauge */
.efficiency-gauge {
  margin-top: 8px;
}

.gauge-bar {
  position: relative;
  display: flex;
  height: 8px;
  border-radius: 6px;
  overflow: visible;
  gap: 2px;
}

.gauge-zone {
  height: 100%;
  border-radius: 6px;
  flex: 1;
}

.zone-green { background: linear-gradient(90deg, var(--green), #00a85f); }
.zone-yellow { background: linear-gradient(90deg, var(--yellow), #e88a00); }
.zone-red { background: linear-gradient(90deg, var(--orange), var(--red)); }

.gauge-needle {
  position: absolute;
  top: -3px;
  width: 3px;
  height: 14px;
  background: white;
  border-radius: 2px;
  transform: translateX(-50%);
  box-shadow: 0 0 6px rgba(255,255,255,0.6);
  transition: left 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.gauge-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
}
.gauge-labels span {
  font-size: 9px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ===== QUICK ACTIONS ===== */
.actions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.action-btn {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition-spring);
  color: var(--text-secondary);
}

.action-btn:hover {
  background: var(--bg-card-hover);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--blue);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.action-btn:active {
  transform: translateY(-1px) scale(0.97);
}

.action-icon {
  width: 40px;
  height: 40px;
  background: var(--bg-elevated);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.action-btn:hover .action-icon {
  background: var(--blue-dim);
}

.action-btn span:last-child {
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
}

.action-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--red);
  color: white;
  font-size: 9px;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== RUNTIME CARD ===== */
.runtime-card {
  margin-top: 4px;
}

.runtime-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.runtime-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.runtime-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.runtime-val {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* ===== CHARTS ===== */
.chart-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.chart-tab {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 8px 4px;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.chart-tab.active {
  background: var(--blue-dim);
  border-color: rgba(59, 130, 246, 0.35);
  color: var(--blue);
}

.chart-tab:not(.active):hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.chart-card {
  padding: 14px 16px;
}

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

.chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-range {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 3px 8px;
  border-radius: 6px;
}

.canvas-wrap {
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-sm);
}

.canvas-wrap canvas {
  width: 100%;
  height: auto;
  display: block;
}

.chart-x-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  padding: 0 4px;
}

.chart-x-labels span {
  font-size: 9px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.chart-legend {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===== METRICS ROW ===== */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.metric-pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.metric-val {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.metric-val.green { color: var(--green); }
.metric-val.blue { color: var(--blue); }
.metric-val.yellow { color: var(--yellow); }
.metric-val.red { color: var(--red); }

/* ===== DATA FEED ===== */
.data-feed { display: flex; flex-direction: column; gap: 12px; }

.feed-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.feed-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 60px;
  flex-shrink: 0;
}

.feed-bar-wrap {
  flex: 1;
}

.feed-bar {
  height: 6px;
  background: rgba(255,255,255,0.05);
  border-radius: 4px;
  overflow: hidden;
}

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

.green-fill { background: linear-gradient(90deg, var(--green), #00a85f); }
.blue-fill { background: linear-gradient(90deg, var(--blue), #1d4ed8); }
.yellow-fill { background: linear-gradient(90deg, var(--yellow), #d97706); }

.feed-val {
  font-size: 11px;
  font-weight: 700;
  min-width: 42px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.feed-val.green { color: var(--green); }
.feed-val.blue { color: var(--blue); }

/* ===== ALERTS ===== */
.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
}

.filter-chips::-webkit-scrollbar { display: none; }

.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
  font-family: inherit;
}

.chip.active {
  background: var(--blue-dim);
  border-color: rgba(59, 130, 246, 0.35);
  color: var(--blue);
}

.chip:not(.active):hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.chip-count {
  background: rgba(255,255,255,0.08);
  border-radius: 9px;
  padding: 1px 6px;
  font-size: 10px;
}

.chip.active .chip-count {
  background: rgba(59, 130, 246, 0.2);
}

/* Alert Cards */
.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.alert-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: var(--transition-spring);
  border-left: 3px solid transparent;
}

.alert-card:hover {
  background: var(--bg-card-hover);
  transform: translateX(4px);
}

.alert-card.critical { border-left-color: var(--red); }
.alert-card.warning { border-left-color: var(--yellow); }
.alert-card.normal { border-left-color: var(--green); }

.alert-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.alert-card.critical .alert-icon { background: var(--red-dim); }
.alert-card.warning .alert-icon { background: var(--yellow-dim); }
.alert-card.normal .alert-icon { background: var(--green-dim); }

.alert-content {
  flex: 1;
  min-width: 0;
}

.alert-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.alert-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.alert-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.alert-time {
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.alert-sev {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 2px 7px;
  border-radius: 4px;
}

.alert-card.critical .alert-sev { background: var(--red-dim); color: var(--red); }
.alert-card.warning .alert-sev { background: var(--yellow-dim); color: var(--yellow); }
.alert-card.normal .alert-sev { background: var(--green-dim); color: var(--green); }

.alert-arrow {
  color: var(--text-dim);
  align-self: center;
  flex-shrink: 0;
}

/* ===== ANALYTICS ===== */
.analytics-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 4px;
}

.anal-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px;
  text-align: center;
}

.anal-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.anal-val {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.anal-val.green { color: var(--green); }
.anal-val.blue { color: var(--blue); }
.anal-val.yellow { color: var(--yellow); }
.anal-val.red { color: var(--red); }

.delta-card.critical-delta { border-color: rgba(239, 68, 68, 0.2); }

.comp-legend {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-top: 10px;
}

.blue-dot { background: var(--blue); }
.yellow-dot { background: var(--yellow); }

.hourly-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  padding: 0 2px;
}

.hourly-labels span {
  font-size: 9px;
  color: var(--text-dim);
}

/* Insights */
.insights-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.insight-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.insight-card.insight-warn { border-left: 3px solid var(--yellow); }
.insight-card.insight-info { border-left: 3px solid var(--blue); }
.insight-card.insight-ok { border-left: 3px solid var(--green); }

.insight-icon { font-size: 22px; line-height: 1; }

.insight-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.insight-body {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ===== REPORTS ===== */
.report-tabs {
  display: flex;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 5px;
  margin-bottom: 12px;
}

.report-tab {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 4px;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.report-tab.active {
  background: var(--blue);
  color: white;
  box-shadow: 0 2px 12px rgba(59, 130, 246, 0.35);
}

.report-tab:not(.active):hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* Report Table */
.table-card { padding: 0; overflow: hidden; }

.table-header-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr 1fr;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  gap: 6px;
}

.table-header-row span {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.table-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr 1fr;
  padding: 12px 14px;
  gap: 6px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: var(--transition);
  align-items: center;
}

.table-row:last-child { border-bottom: none; }

.table-row:hover {
  background: var(--bg-elevated);
}

.table-row span {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.table-row .row-date {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 13px;
}

.table-row .row-eff.good { color: var(--green); font-weight: 700; }
.table-row .row-eff.bad { color: var(--red); font-weight: 700; }

/* Summary Row */
.summary-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.summary-pill {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
}

.sumpill-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.sumpill-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.sumpill-val.green { color: var(--green); }

/* ===== SETTINGS ===== */
.settings-card {
  padding: 0;
  overflow: hidden;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}

.setting-row:last-child { border-bottom: none; }

.setting-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.setting-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.setting-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.setting-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: right;
  flex-shrink: 0;
}

.setting-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
  flex-shrink: 0;
}

.setting-badge.normal { background: var(--green-dim); color: var(--green); }
.setting-badge.warning { background: var(--yellow-dim); color: var(--yellow); }

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch input { display: none; }

.toggle-track {
  width: 44px;
  height: 24px;
  background: rgba(255,255,255,0.08);
  border-radius: 12px;
  position: relative;
  transition: var(--transition);
  border: 1px solid var(--border);
}

.toggle-switch input:checked + .toggle-track {
  background: var(--green);
  border-color: rgba(0, 201, 122, 0.5);
  box-shadow: 0 0 12px var(--green-glow);
}

.toggle-thumb {
  position: absolute;
  width: 18px;
  height: 18px;
  background: #6b7a8d;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: var(--transition-spring);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.toggle-switch input:checked + .toggle-track .toggle-thumb {
  transform: translateX(20px);
  background: white;
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--nav-height);
  background: rgba(14, 18, 28, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  transition: var(--transition);
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  position: relative;
  font-family: inherit;
}

.nav-item.active {
  color: var(--blue);
}

.nav-item:not(.active):hover {
  color: var(--text-secondary);
  background: rgba(255,255,255,0.03);
}

.nav-icon {
  position: relative;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.nav-badge {
  position: absolute;
  top: -4px;
  right: -7px;
  background: var(--red);
  color: white;
  font-size: 9px;
  font-weight: 700;
  min-width: 15px;
  height: 15px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
}

/* Active indicator dot */
.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 2px;
  width: 18px;
  height: 2px;
  background: var(--blue);
  border-radius: 2px;
  animation: navSlideIn 0.3s ease;
}

@keyframes navSlideIn {
  from { width: 0; opacity: 0; }
  to { width: 18px; opacity: 1; }
}

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal-overlay.open {
  display: flex;
  animation: overlayFadeIn 0.2s ease;
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-sheet {
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  background: var(--bg-elevated);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 16px 20px 32px;
  overflow-y: auto;
  animation: sheetSlideUp 0.32s cubic-bezier(0.3, 1.1, 0.5, 1);
}

@keyframes sheetSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: rgba(255,255,255,0.12);
  border-radius: 3px;
  margin: 0 auto 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.modal-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 4px 12px;
  border-radius: 6px;
}

.modal-badge.critical-badge, #modal-badge.critical { background: var(--red-dim); color: var(--red); }
.modal-badge.warning-badge, #modal-badge.warning { background: var(--yellow-dim); color: var(--yellow); }
.modal-badge.normal-badge, #modal-badge.normal { background: var(--green-dim); color: var(--green); }
.modal-badge.blue-badge, #modal-badge.blue { background: var(--blue-dim); color: var(--blue); }

.modal-close {
  width: 32px;
  height: 32px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
  font-family: inherit;
}

.modal-close:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
}

.modal-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.4px;
  line-height: 1.2;
  margin-bottom: 4px;
}

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

.modal-body {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.modal-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.modal-meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.modal-meta-row .meta-key {
  color: var(--text-muted);
  font-weight: 500;
}

.modal-meta-row .meta-v {
  color: var(--text-primary);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-btn {
  flex: 1;
  padding: 13px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  font-family: inherit;
}

.modal-btn.primary {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: white;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

.modal-btn.primary:hover {
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.5);
  transform: translateY(-1px);
}

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

.modal-btn.secondary:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* Report Detail Grid */
.report-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.detail-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.detail-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

.detail-val.green { color: var(--green); }
.detail-val.blue { color: var(--blue); }

/* ===== RESPONSIVE — TABLET ===== */
@media (min-width: 540px) {
  .page-inner { padding: 20px 24px 12px; }
  .cards-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .actions-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .val-big { font-size: 28px; }
  .analytics-stats { gap: 12px; }
  .metrics-row { grid-template-columns: repeat(4, 1fr); }
}

/* ===== RESPONSIVE — DESKTOP ===== */
@media (min-width: 768px) {
  .app-header { padding: 0 28px; }
  .page-inner { padding: 24px 28px; max-width: 900px; }
  .cards-grid { grid-template-columns: repeat(4, 1fr); }
  .actions-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .runtime-row { grid-template-columns: repeat(4, 1fr); }
  .analytics-stats { grid-template-columns: repeat(6, 1fr); }
  .summary-row { grid-template-columns: repeat(4, 1fr); }
  .metrics-row { grid-template-columns: repeat(4, 1fr); }

  /* Side nav on desktop */
  body.desktop-nav .bottom-nav {
    position: fixed;
    left: 0;
    top: var(--header-height);
    right: auto;
    bottom: 0;
    width: 80px;
    height: auto;
    flex-direction: column;
    border-top: none;
    border-right: 1px solid var(--border);
    padding: 12px 4px;
  }

  body.desktop-nav .main-content {
    margin-left: 80px;
  }

  body.desktop-nav .nav-item::after {
    bottom: auto;
    left: 2px;
    width: 2px;
    height: 18px;
    border-radius: 2px;
    top: 50%;
    transform: translateY(-50%);
  }
}

@media (min-width: 1024px) {
  .page-inner { max-width: 1100px; }
  .cards-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .val-big { font-size: 30px; }
  .modal-sheet { max-width: 520px; border-radius: var(--radius-xl); border: 1px solid var(--border); }
  .modal-overlay { align-items: center; padding: 20px; }
}

/* ===== LOADING SKELETON (initial state) ===== */
@keyframes skeleton {
  0% { opacity: 0.4; }
  50% { opacity: 0.7; }
  100% { opacity: 0.4; }
}

/* ===== TOAST NOTIFICATION ===== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  max-width: 90vw;
  box-shadow: var(--shadow-elevated);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

/* Animation for data update */
@keyframes valueFlash {
  0% { opacity: 0.3; }
  50% { opacity: 1; }
  100% { opacity: 1; }
}

.value-updated {
  animation: valueFlash 0.4s ease;
}
