/* ==========================================================================
   SolarPulse AI - Industrial IoT Solar Monitoring Dashboard
   Design System & Master Stylesheet
   ========================================================================== */

:root {
  /* Color Palette: Dark Industrial Navy / Emerald / Alert Accents */
  --bg-base: #070b14;
  --bg-surface: #0c1222;
  --bg-card: #111a2e;
  --bg-card-hover: #15223c;
  --bg-card-alt: #162038;
  --bg-header: rgba(11, 18, 34, 0.85);
  --bg-sidebar: #0a1020;
  --bg-input: #090e1a;
  
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-medium: rgba(255, 255, 255, 0.12);
  --border-focus: rgba(16, 185, 129, 0.5);

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-slate: #cbd5e1;

  /* Accents */
  --accent-emerald: #10b981;
  --accent-emerald-hover: #059669;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-emerald-subtle: rgba(16, 185, 129, 0.12);

  --accent-red: #ef4444;
  --accent-red-hover: #dc2626;
  --accent-red-glow: rgba(239, 68, 68, 0.25);
  --accent-red-subtle: rgba(239, 68, 68, 0.12);

  --accent-amber: #f59e0b;
  --accent-amber-glow: rgba(245, 158, 11, 0.25);
  --accent-amber-subtle: rgba(245, 158, 11, 0.12);

  --accent-blue: #3b82f6;
  --accent-blue-glow: rgba(59, 130, 246, 0.25);
  --accent-blue-subtle: rgba(59, 130, 246, 0.12);

  /* Layout */
  --header-height: 64px;
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 72px;
  --border-radius-sm: 6px;
  --border-radius-md: 10px;
  --border-radius-lg: 14px;
  --border-radius-full: 9999px;

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

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
  --shadow-emerald: 0 0 15px rgba(16, 185, 129, 0.2);
}

/* Light Theme Overrides */
body.theme-light {
  --bg-base: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-card-alt: #f8fafc;
  --bg-header: rgba(255, 255, 255, 0.9);
  --bg-sidebar: #f1f5f9;
  --bg-input: #ffffff;

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-medium: rgba(0, 0, 0, 0.15);
  --border-focus: rgba(16, 185, 129, 0.6);

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --text-slate: #334155;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);
}

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

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Typography Helpers */
.font-mono { font-family: var(--font-mono); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-slate { color: var(--text-slate); }
.text-emerald { color: var(--accent-emerald); }
.text-red { color: var(--accent-red); }
.text-amber { color: var(--accent-amber); }
.text-blue { color: var(--accent-blue); }

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.p-0 { padding: 0 !important; }

/* Material Symbols */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
  line-height: 1;
}
.icon-xs { font-size: 16px !important; }
.icon-sm { font-size: 18px !important; }
.icon-md { font-size: 22px !important; }
.icon-lg { font-size: 28px !important; }

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

/* ==========================================================================
   Fixed Top Header
   ========================================================================== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: var(--bg-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 100;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  cursor: pointer;
}

.brand-icon-wrapper {
  position: relative;
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.05));
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-pulse-icon {
  color: var(--accent-emerald);
  font-size: 22px;
}

.pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--accent-emerald);
  opacity: 0.6;
  animation: pulseAnimation 2.4s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes pulseAnimation {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 0; }
  100% { transform: scale(0.95); opacity: 0; }
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.brand-badge-ai {
  font-size: 0.65rem;
  font-weight: 800;
  background-color: var(--accent-emerald);
  color: #042f1a;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.brand-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: -0.01em;
}

/* Header Center Controls */
.header-center {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-control-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-md);
  padding: 0.25rem 0.6rem;
}

.control-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.styled-select {
  background: transparent;
  color: var(--text-main);
  border: none;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  outline: none;
  padding: 0.2rem 0.25rem;
}

.styled-select option {
  background-color: var(--bg-card);
  color: var(--text-main);
}

/* Header Right */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--border-radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--border-subtle);
}

.status-demo {
  background-color: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--accent-emerald);
}

.status-live {
  background-color: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--accent-blue);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: currentColor;
  box-shadow: 0 0 8px currentColor;
  animation: blinkDot 1.6s infinite ease-in-out;
}

@keyframes blinkDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.header-icon-btn {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.header-icon-btn:hover {
  color: var(--text-main);
  border-color: var(--border-medium);
  background-color: var(--bg-card-hover);
}

.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background-color: var(--accent-red);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}

/* ==========================================================================
   Fixed Left Sidebar
   ========================================================================== */
.app-sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.25rem 0.75rem;
  z-index: 90;
  transition: width 0.2s ease, background-color 0.2s ease;
}

.sidebar-nav-container {
  display: flex;
  flex-direction: column;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-item {
  width: 100%;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--border-radius-md);
  border: 1px solid transparent;
  transition: all 0.18s ease;
  position: relative;
  user-select: none;
}

.nav-link:hover {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.04);
}

.nav-link.active {
  color: #ffffff;
  background-color: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
  font-weight: 600;
}

.nav-link.active .nav-icon {
  color: var(--accent-emerald);
}

.nav-icon {
  font-size: 20px;
  color: var(--text-dim);
  transition: color 0.18s ease;
}

.nav-label {
  flex-grow: 1;
}

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

.system-health-mini {
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-md);
  padding: 0.75rem;
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.system-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */
.app-main {
  flex-grow: 1;
  margin-top: var(--header-height);
  margin-left: var(--sidebar-width);
  padding: 2rem 2.25rem 4rem 2.25rem;
  min-height: calc(100vh - var(--header-height));
  transition: margin-left 0.2s ease;
}

/* Section Switching Rules */
.page-section {
  display: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.page-section.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* Section Hero */
.section-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.75rem;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-slate);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 0.2rem 0.6rem;
  border-radius: var(--border-radius-full);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hero-title {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.25;
}

.hero-description {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  max-width: 720px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.timestamp-display {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-md);
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-slate);
}

/* ==========================================================================
   Buttons & Form Components
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.48rem 0.95rem;
  border-radius: var(--border-radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
}

.btn-xs {
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  border-radius: var(--border-radius-sm);
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background-color: var(--accent-emerald);
  color: #032112;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
  background-color: var(--accent-emerald-hover);
  box-shadow: var(--shadow-emerald);
}

.btn-secondary {
  background-color: var(--bg-surface);
  border-color: var(--border-subtle);
  color: var(--text-slate);
}

.btn-secondary:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-medium);
}

.btn-emerald-glass {
  background-color: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--accent-emerald);
}

.btn-emerald-glass:hover {
  background-color: rgba(16, 185, 129, 0.2);
  border-color: var(--accent-emerald);
}

.btn-danger-glass {
  background-color: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--accent-red);
}

.btn-danger-glass:hover {
  background-color: rgba(239, 68, 68, 0.2);
  border-color: var(--accent-red);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--border-radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-emerald { background-color: rgba(16, 185, 129, 0.18); color: var(--accent-emerald); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-red { background-color: rgba(239, 68, 68, 0.18); color: var(--accent-red); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-amber { background-color: rgba(245, 158, 11, 0.18); color: var(--accent-amber); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-blue { background-color: rgba(59, 130, 246, 0.18); color: var(--accent-blue); border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-slate { background-color: rgba(148, 163, 184, 0.15); color: var(--text-slate); border: 1px solid var(--border-subtle); }

.badge-emerald-pill {
  border-radius: var(--border-radius-full);
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-red-pill {
  border-radius: var(--border-radius-full);
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.badge-emerald-subtle { background: rgba(16, 185, 129, 0.1); color: var(--accent-emerald); }
.badge-blue-subtle { background: rgba(59, 130, 246, 0.1); color: var(--accent-blue); }
.badge-amber-subtle { background: rgba(245, 158, 11, 0.1); color: var(--accent-amber); }
.badge-red-subtle { background: rgba(239, 68, 68, 0.1); color: var(--accent-red); }

/* Segmented Control */
.segmented-control {
  display: flex;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-md);
  padding: 0.2rem;
  gap: 0.2rem;
}

.seg-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.seg-btn:hover {
  color: var(--text-main);
}

.seg-btn.active {
  background-color: var(--bg-card-hover);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Card Component System
   ========================================================================== */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

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

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.card-body {
  padding: 1.25rem;
  flex-grow: 1;
}

.card-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  background-color: rgba(0, 0, 0, 0.15);
}

.chart-tag {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

/* ==========================================================================
   KPI Cards Grid (8 Cards)
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-md);
  padding: 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  position: relative;
  overflow: hidden;
}

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

.kpi-card-highlight {
  border-color: rgba(16, 185, 129, 0.35);
  background: linear-gradient(145deg, var(--bg-card) 60%, rgba(16, 185, 129, 0.08));
}

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.kpi-title {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi-icon {
  font-size: 20px;
}

.kpi-value-container {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  margin-bottom: 0.4rem;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-main);
  letter-spacing: -0.03em;
}

.kpi-unit {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dim);
}

.kpi-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding-top: 0.35rem;
}

.kpi-subtext {
  color: var(--text-dim);
}

/* ==========================================================================
   Dashboard Middle Grid (Health & Quick Thermal)
   ========================================================================== */
.dashboard-middle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

/* Solar Array Health Card */
.health-card .card-body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.25rem;
}

.health-overview {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.health-score-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 90px;
  height: 90px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0) 70%);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--border-radius-full);
}

.health-score-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent-emerald);
  line-height: 1;
}

.health-score-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-top: 0.2rem;
}

.health-details {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.health-bar-container {
  width: 100%;
}

.health-bar-track {
  width: 100%;
  height: 10px;
  background-color: var(--bg-surface);
  border-radius: var(--border-radius-full);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.health-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #34d399);
  border-radius: var(--border-radius-full);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.health-metric-pills {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.metric-mini-pill {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-sm);
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.diagnostic-flags {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-md);
  padding: 0.75rem 1rem;
}

.diag-flag-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-slate);
}

/* Quick Thermal Summary Card */
.thermal-summary-body {
  display: flex;
  gap: 1.25rem;
}

.thermal-thumb-wrapper {
  position: relative;
  width: 170px;
  height: 140px;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
  background-color: #000;
}

.thermal-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-hotspot-pin {
  position: absolute;
  top: 48%;
  left: 49%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
  animation: pingHotspot 1.6s infinite ease-out;
}

@keyframes pingHotspot {
  0% { transform: translate(-50%, -50%) scale(0.8); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
}

.thumb-badge {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.thermal-summary-data {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.35rem;
}

.ts-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.ts-label {
  color: var(--text-muted);
}

/* ==========================================================================
   Charts Grid & Canvas Wrappers
   ========================================================================== */
.charts-double-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.chart-card {
  min-height: 310px;
}

.chart-canvas-wrapper {
  position: relative;
  width: 100%;
  height: 230px;
}

.analytics-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

/* ==========================================================================
   Live Telemetry Table
   ========================================================================== */
.table-card {
  margin-bottom: 1.5rem;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.telemetry-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.8125rem;
}

.telemetry-table th {
  background-color: var(--bg-surface);
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.telemetry-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.telemetry-table tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.table-row-new {
  animation: flashNewRow 1s ease-out;
}

@keyframes flashNewRow {
  0% { background-color: rgba(16, 185, 129, 0.2); }
  100% { background-color: transparent; }
}

.table-stream-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ==========================================================================
   AI Thermal Inspection Page
   ========================================================================== */
.thermal-inspection-workspace {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 1.5rem;
}

.thermal-display-container {
  position: relative;
  width: 100%;
  height: 480px;
  background-color: #03060d;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.thermal-main-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

/* Scanning Laser Animation Line */
.scanner-laser-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent-emerald), #ffffff, var(--accent-emerald), transparent);
  box-shadow: 0 0 15px var(--accent-emerald), 0 0 30px var(--accent-emerald);
  opacity: 0;
  pointer-events: none;
  z-index: 10;
}

.scanner-laser-line.scanning {
  opacity: 1;
  animation: laserScan 2s infinite ease-in-out;
}

@keyframes laserScan {
  0% { top: 2%; }
  50% { top: 96%; }
  100% { top: 2%; }
}

/* Bounding Box Anomaly Overlay */
.ai-hotspot-box {
  position: absolute;
  top: 41%;
  left: 45%;
  width: 120px;
  height: 100px;
  transform: translate(-50%, -50%);
  border: 2px dashed var(--accent-red);
  background-color: rgba(239, 68, 68, 0.15);
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.4);
  pointer-events: none;
  z-index: 5;
  transition: opacity 0.3s ease;
}

.ai-hotspot-box .box-corner {
  position: absolute;
  width: 8px;
  height: 8px;
  border-color: #ffffff;
  border-style: solid;
}

.ai-hotspot-box .tl { top: -2px; left: -2px; border-width: 2px 0 0 2px; }
.ai-hotspot-box .tr { top: -2px; right: -2px; border-width: 2px 2px 0 0; }
.ai-hotspot-box .bl { bottom: -2px; left: -2px; border-width: 0 0 2px 2px; }
.ai-hotspot-box .br { bottom: -2px; right: -2px; border-width: 0 2px 2px 0; }

.hotspot-tag {
  position: absolute;
  top: -24px;
  left: -2px;
  background-color: var(--accent-red);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}

/* Scan Overlay State Modal */
.scan-overlay-state {
  position: absolute;
  inset: 0;
  background-color: rgba(7, 11, 20, 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.scan-overlay-state.active {
  opacity: 1;
  pointer-events: auto;
}

.scanner-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(16, 185, 129, 0.2);
  border-top-color: var(--accent-emerald);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.scanner-status-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
}

.scanner-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Thermal Color Legend */
.thermal-color-legend {
  padding: 0.85rem 1.25rem;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
}

.legend-scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 0.35rem;
}

.ironbow-gradient-bar {
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, #0d0887 0%, #4b03a1 20%, #7e03a8 40%, #b83289 60%, #e56b5d 80%, #fca636 90%, #f0f921 100%);
  border: 1px solid var(--border-subtle);
}

/* Thermal Sidebar Details */
.thermal-sidebar-info {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.ai-diagnostic-rows {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.ai-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.ai-label {
  color: var(--text-muted);
}

.conf-bar-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.conf-bar-track {
  width: 70px;
  height: 6px;
  background-color: var(--bg-surface);
  border-radius: 3px;
  overflow: hidden;
}

.conf-bar-fill {
  height: 100%;
  background-color: var(--accent-emerald);
}

.ai-recommendation-box {
  background-color: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--border-radius-md);
  padding: 0.85rem 1rem;
}

.ai-rec-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-amber);
  margin-bottom: 0.35rem;
}

.ai-rec-text {
  font-size: 0.78rem;
  color: var(--text-slate);
  line-height: 1.45;
}

.spec-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.spec-row {
  display: flex;
  justify-content: space-between;
}

.hidden-file-input {
  display: none;
}

/* ==========================================================================
   Maintenance Page
   ========================================================================== */
.maintenance-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.maint-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.maint-card-high { border-top: 3px solid var(--accent-red); }
.maint-card-med { border-top: 3px solid var(--accent-amber); }
.maint-card-low { border-top: 3px solid var(--accent-blue); }

.maint-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.75rem;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-subtle);
}

.maint-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.maint-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
}

.maint-value {
  font-size: 0.825rem;
}

.maint-recommendation {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-md);
  padding: 0.75rem;
  font-size: 0.8rem;
}

.rec-header {
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
}

.rec-body {
  color: var(--text-slate);
  line-height: 1.4;
}

.maint-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

/* ==========================================================================
   Alerts Page
   ========================================================================== */
.alerts-feed-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.alert-item-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-md);
  padding: 1.15rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  transition: all 0.2s ease;
}

.alert-item-card:hover {
  border-color: var(--border-medium);
}

.alert-item-card.alert-high {
  border-left: 4px solid var(--accent-red);
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.06), var(--bg-card) 30%);
}

.alert-item-card.alert-med {
  border-left: 4px solid var(--accent-amber);
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.06), var(--bg-card) 30%);
}

.alert-item-card.alert-low {
  border-left: 4px solid var(--accent-blue);
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.06), var(--bg-card) 30%);
}

.alert-content-left {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.alert-icon-wrapper {
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.alert-high .alert-icon-wrapper { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
.alert-med .alert-icon-wrapper { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.alert-low .alert-icon-wrapper { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }

.alert-text-block {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.alert-top-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.alert-title-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.alert-desc-text {
  font-size: 0.825rem;
  color: var(--text-muted);
}

.alert-actions-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Empty Alerts State */
.empty-alerts-state {
  text-align: center;
  padding: 4rem 2rem;
  background-color: var(--bg-card);
  border: 1px dashed var(--border-medium);
  border-radius: var(--border-radius-lg);
}

.empty-alerts-state .material-symbols-outlined {
  font-size: 48px;
  color: var(--accent-emerald);
  margin-bottom: 0.75rem;
}

/* ==========================================================================
   Settings Page
   ========================================================================== */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

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

.setting-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.setting-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.setting-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.theme-switch-group {
  display: flex;
  gap: 0.4rem;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 24px;
  transition: 0.2s;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-muted);
  border-radius: 50%;
  transition: 0.2s;
}

input:checked + .toggle-slider {
  background-color: rgba(16, 185, 129, 0.2);
  border-color: var(--accent-emerald);
}

input:checked + .toggle-slider:before {
  transform: translateX(20px);
  background-color: var(--accent-emerald);
}

/* Threshold Inputs */
.threshold-input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.thresh-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.input-with-unit {
  position: relative;
  width: 120px;
}

.styled-input {
  width: 100%;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-sm);
  color: var(--text-main);
  padding: 0.4rem 2rem 0.4rem 0.6rem;
  font-size: 0.825rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.styled-input:focus {
  border-color: var(--border-focus);
}

.styled-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.input-unit {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: var(--text-dim);
  pointer-events: none;
}

.cloud-input-group {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.hw-spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.hw-item {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.hw-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-slate);
}

.hw-val {
  font-size: 0.85rem;
  font-weight: 700;
}

.hw-desc {
  font-size: 0.7rem;
}

/* ==========================================================================
   Mobile Bottom Navigation (Responsive)
   ========================================================================== */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background-color: var(--bg-header);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-subtle);
  z-index: 100;
  justify-content: space-around;
  align-items: center;
  padding: 0 0.5rem;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 500;
  padding: 0.35rem 0.6rem;
  border-radius: var(--border-radius-sm);
  transition: all 0.15s ease;
  user-select: none;
}

.mobile-nav-item .material-symbols-outlined {
  font-size: 20px;
}

.mobile-nav-item.active {
  color: var(--accent-emerald);
  font-weight: 700;
}

/* ==========================================================================
   Toast Notification System
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background-color: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--border-radius-md);
  padding: 0.75rem 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow-lg);
  font-size: 0.825rem;
  color: var(--text-main);
  animation: slideInToast 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 260px;
}

.toast.toast-success {
  border-left: 4px solid var(--accent-emerald);
}

.toast.toast-error {
  border-left: 4px solid var(--accent-red);
}

.toast.toast-info {
  border-left: 4px solid var(--accent-blue);
}

@keyframes slideInToast {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   Media Queries & Responsive Breakpoints
   ========================================================================== */
@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .maintenance-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .thermal-inspection-workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 992px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-middle-grid,
  .charts-double-grid,
  .analytics-charts-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .app-sidebar {
    display: none !important;
  }
  .app-main {
    margin-left: 0;
    padding: 1.25rem 1rem 5.5rem 1rem;
  }
  .mobile-bottom-nav {
    display: flex;
  }
  .header-center {
    display: none; /* Can be accessed via settings / top dropdown */
  }
  .brand-subtitle {
    display: none;
  }
  .maintenance-cards-grid {
    grid-template-columns: 1fr;
  }
  .thermal-thumb-wrapper {
    width: 120px;
    height: 100px;
  }
  .thermal-display-container {
    height: 320px;
  }
}
