/* ========================
   POWERTRACK ENERGY METER
   Professional Design System
   ======================== */

/* ========================
   CSS CUSTOM PROPERTIES
   ======================== */

:root {
  /* Brand Colors */
  --electric-blue: #0066FF;
  --electric-blue-dark: #0052CC;
  --electric-blue-light: #3385FF;
  --electric-blue-alpha: rgba(0, 102, 255, 0.1);

  /* Light Mode Base */
  --bg-primary: #FAFBFC;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #F3F4F6;
  --text-primary: #111827;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;
  --border-color: #E5E7EB;
  --border-color-strong: #D1D5DB;

  /* Semantic Colors */
  --power-on: #10B981;
  --power-on-bg: #D1FAE5;
  --power-on-alpha: rgba(16, 185, 129, 0.1);
  --power-off: #EF4444;
  --power-off-bg: #FEE2E2;
  --power-off-alpha: rgba(239, 68, 68, 0.1);
  --alert-amber: #F59E0B;
  --alert-amber-bg: #FEF3C7;
  --alert-amber-alpha: rgba(245, 158, 11, 0.1);
  --critical: #DC2626;
  --critical-bg: #FEE2E2;
  --critical-alpha: rgba(220, 38, 38, 0.1);

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

  /* Typography */
  --font-family: 'Inter', -apple-system, system-ui, sans-serif;
  --font-size-xs: 13px;
  --font-size-sm: 14px;
  --font-size-base: 15px;
  --font-size-lg: 18px;
  --font-size-xl: 24px;
  --font-size-2xl: 32px;
  --font-size-display: 48px;
  --line-height-tight: 1.2;
  --line-height-base: 1.6;

  /* Layout */
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --border-radius-lg: 16px;
  --radius-sm: var(--border-radius-sm);
  --radius-md: var(--border-radius);
  --radius-lg: var(--border-radius-lg);
  --surface-subtle: rgba(0, 0, 0, 0.04);
  --surface-hover: rgba(0, 0, 0, 0.08);
  --border-subtle: var(--border-color);
  --color-teal: #0D9488;
  --sidebar-width: 260px;
  --topbar-height: 64px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  /* Chart Colors */
  --chart-stroke: var(--electric-blue);
  --chart-fill: var(--electric-blue-alpha);
}

[data-theme="dark"] {
  --bg-primary: #1A1D29;
  --bg-secondary: #232630;
  --bg-tertiary: #2D3142;
  --text-primary: #F9FAFB;
  --text-secondary: #D1D5DB;
  --text-tertiary: #9CA3AF;
  --border-color: #374151;
  --border-color-strong: #4B5563;

  --power-on-bg: #064E3B;
  --power-off-bg: #7F1D1D;
  --alert-amber-bg: #78350F;
  --critical-bg: #7F1D1D;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);

  --surface-subtle: rgba(255, 255, 255, 0.05);
  --surface-hover: rgba(255, 255, 255, 0.1);
  --border-subtle: var(--border-color);
  --color-teal: #14B8A6;
}

[data-theme="hacker"] {
  --bg-primary: #04080F;
  --bg-secondary: #0A111F;
  --bg-tertiary: #101C33;
  --text-primary: #00FF66;
  --text-secondary: #00CC52;
  --text-tertiary: #008837;
  --border-color: rgba(0, 255, 102, 0.25);
  --border-color-strong: rgba(0, 255, 102, 0.5);

  --electric-blue: #00FF66;
  --electric-blue-hover: #33FF85;
  --electric-blue-alpha: rgba(0, 255, 102, 0.15);

  --success: #00FF66;
  --warning: #FFB000;
  --critical: #FF0055;

  --power-on-bg: #003314;
  --power-off-bg: #330011;
  --alert-amber-bg: #332200;
  --critical-bg: #330011;

  --font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  --chart-stroke: #00FF66;
  --chart-fill: rgba(0, 255, 102, 0.2);

  --shadow-sm: 0 0 5px rgba(0, 255, 102, 0.2);
  --shadow-md: 0 0 15px rgba(0, 255, 102, 0.3);
  --shadow-lg: 0 0 25px rgba(0, 255, 102, 0.4);
  --shadow-xl: 0 0 40px rgba(0, 255, 102, 0.5);

  --surface-subtle: rgba(0, 255, 102, 0.05);
  --surface-hover: rgba(0, 255, 102, 0.15);
  --border-subtle: rgba(0, 255, 102, 0.3);
  --color-teal: #00FF66;
}

/* Hacker Theme HUD effects */
[data-theme="hacker"] .metric-card,
[data-theme="hacker"] .panel,
[data-theme="hacker"] .sidebar {
  border: 1px solid rgba(0, 255, 102, 0.3);
  box-shadow: 0 0 12px rgba(0, 255, 102, 0.1);
  position: relative;
}

[data-theme="hacker"] .metric-card::after,
[data-theme="hacker"] .panel::after {
  content: '';
  position: absolute;
  top: 0; right: 0; width: 6px; height: 6px;
  border-top: 2px solid #00FF66;
  border-right: 2px solid #00FF66;
  pointer-events: none;
}

[data-theme="hacker"] .metric-value strong,
[data-theme="hacker"] .brand-icon,
[data-theme="hacker"] .section-heading h2 {
  text-shadow: 0 0 8px rgba(0, 255, 102, 0.6);
}

/* Matrix Background Canvas */
.matrix-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  pointer-events: none;
  z-index: 2;        /* sit above opaque bg, below content (app-layout is z-index 3+) */
  opacity: 0;
  transition: opacity 0.5s ease;
}

[data-theme="hacker"] .matrix-canvas {
  opacity: 0.12;
}

/* Hacker theme: give layout layers semi-transparent backgrounds so matrix shows */
[data-theme="hacker"] .app-layout {
  position: relative;
  z-index: 3;
}

[data-theme="hacker"] .sidebar {
  background: rgba(4, 8, 15, 0.88) !important;
  backdrop-filter: blur(4px);
}

[data-theme="hacker"] .workspace {
  background: transparent;
}

[data-theme="hacker"] .topbar {
  background: rgba(4, 8, 15, 0.92) !important;
  backdrop-filter: blur(6px);
}

[data-theme="hacker"] .panel {
  background: rgba(10, 17, 31, 0.85) !important;
  backdrop-filter: blur(4px);
}

[data-theme="hacker"] .metric-card {
  background: rgba(10, 17, 31, 0.85) !important;
  backdrop-filter: blur(4px);
}

/* CRT Scanlines Overlay */
.scanlines {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  pointer-events: none;
  z-index: 9999;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
  background-size: 100% 4px;
  opacity: 0;
  transition: opacity 0.5s ease;
}

[data-theme="hacker"] .scanlines {
  opacity: 0.4;
}

/* CLI Dialog Terminal Modal */
.cli-dialog {
  border: 1px solid var(--electric-blue);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.8), 0 0 15px var(--electric-blue-alpha);
  padding: 0;
  max-width: 720px;
  width: 90vw;
  margin: auto;
}

.cli-container {
  display: flex;
  flex-direction: column;
  height: 480px;
  background: var(--bg-primary);
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

.cli-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.cli-title {
  color: var(--electric-blue);
}

.cli-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

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

.cli-output {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.cli-welcome {
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.cli-cmd {
  color: var(--electric-blue);
  font-weight: 600;
}

.cli-line {
  margin-bottom: 6px;
}

.cli-line.input-line {
  color: var(--text-secondary);
}

.cli-line.success-line {
  color: var(--success);
}

.cli-line.error-line {
  color: var(--critical);
}

.cli-line.warning-line {
  color: var(--warning);
}

.cli-form {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  gap: 10px;
}

.cli-prompt {
  color: var(--electric-blue);
  font-weight: bold;
  font-size: 13px;
  white-space: nowrap;
}

.cli-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
}

/* Oscilloscope Canvas */
.oscilloscope-panel {
  margin-top: 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 12px;
  border: 1px solid var(--border-color);
}

[data-theme="hacker"] .oscilloscope-panel {
  background: rgba(10, 17, 31, 0.85) !important;
  border: 1px solid rgba(0, 255, 102, 0.35);
  box-shadow: 0 0 10px rgba(0, 255, 102, 0.12);
  position: relative;
}

[data-theme="hacker"] .oscilloscope-panel::after {
  content: '';
  position: absolute;
  top: 0; right: 0; width: 6px; height: 6px;
  border-top: 2px solid #00FF66;
  border-right: 2px solid #00FF66;
  pointer-events: none;
}

.oscilloscope-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.oscilloscope-canvas {
  width: 100%;
  height: 80px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  display: block;
}

/* Telemetry Payload Inspector */
.payload-inspector {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-primary);
  max-height: 250px;
  overflow-y: auto;
  white-space: pre-wrap;
}

[data-theme="hacker"] .payload-inspector {
  background: #020408 !important;
  border: 1px solid rgba(0, 255, 102, 0.35);
  box-shadow: 0 0 10px rgba(0, 255, 102, 0.1);
  color: #00CC52;
}

/* CLI Dialog backdrop */
.cli-dialog::backdrop {
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(3px);
}

[data-theme="hacker"] .cli-dialog {
  border: 1px solid #00FF66;
  box-shadow: 0 0 40px rgba(0, 255, 102, 0.25), 0 0 80px rgba(0, 255, 102, 0.1);
}

[data-theme="hacker"] .cli-dialog::backdrop {
  background: rgba(0, 4, 8, 0.92);
  backdrop-filter: blur(4px);
}

/* Connection dialog backdrop */
.connection-dialog::backdrop,
.confirmation-dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

[data-theme="hacker"] .connection-dialog::backdrop,
[data-theme="hacker"] .confirmation-dialog::backdrop {
  background: rgba(0, 4, 8, 0.9);
}

/* Hacker theme topbar button glow */
[data-theme="hacker"] .icon-button,
[data-theme="hacker"] .button-secondary {
  border-color: rgba(0, 255, 102, 0.4);
  color: #00FF66;
}

[data-theme="hacker"] .icon-button:hover,
[data-theme="hacker"] .button-secondary:hover {
  background: rgba(0, 255, 102, 0.12);
  border-color: #00FF66;
  box-shadow: 0 0 8px rgba(0, 255, 102, 0.3);
}

/* Hacker theme nav links */
[data-theme="hacker"] .nav-link.is-active {
  background: rgba(0, 255, 102, 0.12);
  color: #00FF66;
  box-shadow: inset 2px 0 0 #00FF66;
}

[data-theme="hacker"] .nav-link {
  color: #008837;
}

[data-theme="hacker"] .nav-link:hover {
  background: rgba(0, 255, 102, 0.06);
  color: #00CC52;
}

/* Hacker theme connection status */
[data-theme="hacker"] .connection-status[data-state="online"] {
  color: #00FF66;
}

[data-theme="hacker"] .connection-status[data-state="online"] .status-dot {
  background: #00FF66;
  box-shadow: 0 0 8px #00FF66;
}

/* Hacker scrollbar */
[data-theme="hacker"] ::-webkit-scrollbar-thumb {
  background: rgba(0, 255, 102, 0.35);
}

[data-theme="hacker"] ::-webkit-scrollbar-track {
  background: rgba(0, 255, 102, 0.05);
}

/* Hacker theme hero balance card */
[data-theme="hacker"] .hero-metric strong,
[data-theme="hacker"] .metric-value strong {
  animation: hacker-flicker 4s infinite;
}

@keyframes hacker-flicker {
  0%, 96%, 100% { opacity: 1; }
  97% { opacity: 0.85; }
  98% { opacity: 1; }
  99% { opacity: 0.9; }
}

/* Hacker primary button */
[data-theme="hacker"] .button-primary {
  background: rgba(0, 255, 102, 0.15);
  border: 1px solid #00FF66;
  color: #00FF66;
  box-shadow: 0 0 10px rgba(0, 255, 102, 0.2);
}

[data-theme="hacker"] .button-primary:hover:not(:disabled) {
  background: rgba(0, 255, 102, 0.25);
  box-shadow: 0 0 20px rgba(0, 255, 102, 0.35);
}

/* Hacker input/form fields */
[data-theme="hacker"] input,
[data-theme="hacker"] select {
  background: rgba(0, 4, 8, 0.8) !important;
  border-color: rgba(0, 255, 102, 0.4) !important;
  color: #00FF66 !important;
}

[data-theme="hacker"] input:focus,
[data-theme="hacker"] select:focus {
  border-color: #00FF66 !important;
  box-shadow: 0 0 8px rgba(0, 255, 102, 0.3) !important;
  outline: none;
}

/* Hacker table rows */
[data-theme="hacker"] table th {
  color: #008837;
  border-bottom-color: rgba(0, 255, 102, 0.2);
}

[data-theme="hacker"] table tr:hover td {
  background: rgba(0, 255, 102, 0.04);
}

/* Hacker footer */
[data-theme="hacker"] .workspace-footer {
  border-top-color: rgba(0, 255, 102, 0.15);
  color: #008837;
}

/* ========================
   RESET & BASE
   ======================== */

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: background-color var(--transition-base), color var(--transition-base);
  overflow-x: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

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

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

/* ========================
   LAYOUT
   ======================== */

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

.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  transition: all var(--transition-base);
}

.workspace {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-base);
}

.topbar {
  height: var(--topbar-height);
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 var(--space-lg);
  gap: var(--space-lg);
  position: sticky;
  top: 0;
  z-index: 90;
  transition: all var(--transition-base);
}

.page-wrap {
  flex: 1;
  padding: var(--space-xl);
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ========================
   SIDEBAR
   ======================== */

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  transition: all var(--transition-fast);
}

.sidebar-brand:hover {
  background-color: var(--bg-tertiary);
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--electric-blue), var(--electric-blue-light));
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
}

.nav-caption {
  padding: var(--space-lg) var(--space-lg) var(--space-sm);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}

.side-nav {
  display: flex;
  flex-direction: column;
  padding: 0 var(--space-sm);
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
  text-align: left;
}

.nav-link:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-link.is-active {
  background-color: var(--electric-blue-alpha);
  color: var(--electric-blue);
  font-weight: 600;
}

.nav-icon {
  font-size: 18px;
  width: 20px;
  text-align: center;
}

.sidebar-bottom {
  margin-top: auto;
  padding: var(--space-lg);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.sidebar-meter {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
}

.sidebar-meter small {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.sidebar-meter strong {
  display: block;
  color: var(--text-secondary);
  font-weight: 500;
}

.meter-mini-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-tertiary);
  flex-shrink: 0;
}

.sidebar-version {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
}

/* ========================
   TOPBAR
   ======================== */

.mobile-brand {
  display: none;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 700;
  font-size: var(--font-size-lg);
}

.topbar-context {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.context-kicker {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.context-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  background-color: var(--bg-tertiary);
  border-radius: 100px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  transition: all var(--transition-base);
}

.connection-status[data-state="online"] {
  background-color: var(--power-on-bg);
  color: var(--power-on);
}

.connection-status[data-state="error"] {
  background-color: var(--power-off-bg);
  color: var(--power-off);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
}

.connection-status[data-state="online"] .status-dot {
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.header-relay {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  background-color: var(--bg-tertiary);
  border-radius: 100px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  transition: all var(--transition-base);
}

.header-relay[data-state="on"] {
  background-color: var(--power-on-bg);
  color: var(--power-on);
}

.header-relay[data-state="off"] {
  background-color: var(--power-off-bg);
  color: var(--power-off);
}

.header-relay-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
}

.topbar-divider {
  width: 1px;
  height: 24px;
  background-color: var(--border-color);
}

.updated-label {
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-sm);
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.icon-button:hover {
  background-color: var(--bg-primary);
  border-color: var(--border-color-strong);
  color: var(--text-primary);
}

.icon-button:focus-visible {
  outline: 2px solid var(--electric-blue);
  outline-offset: 2px;
}

/* ========================
   BUTTONS
   ======================== */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--font-size-base);
  font-weight: 600;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
  white-space: nowrap;
  border: 1px solid transparent;
}

.button:focus-visible {
  outline: 2px solid var(--electric-blue);
  outline-offset: 2px;
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button-primary {
  background-color: var(--electric-blue);
  color: white;
}

.button-primary:hover:not(:disabled) {
  background-color: var(--electric-blue-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

.button-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.button-secondary:hover:not(:disabled) {
  background-color: var(--bg-primary);
  border-color: var(--border-color-strong);
}

.button-on {
  background-color: var(--power-on);
  color: white;
}

.button-on:hover:not(:disabled) {
  background-color: #059669;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.button-off {
  background-color: var(--power-off);
  color: white;
}

.button-off:hover:not(:disabled) {
  background-color: #DC2626;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.button-danger {
  background-color: var(--critical);
  color: white;
}

.button-danger:hover:not(:disabled) {
  background-color: #B91C1C;
}

.action-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
}

.inline-link {
  color: var(--electric-blue);
  font-weight: 600;
  font-size: var(--font-size-sm);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.inline-link:hover {
  color: var(--electric-blue-dark);
  text-decoration: underline;
}

.connect-meter-button {
  padding: var(--space-sm) var(--space-lg);
  background-color: var(--electric-blue-alpha);
  color: var(--electric-blue);
  border-radius: var(--border-radius-sm);
  font-weight: 600;
  font-size: var(--font-size-base);
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.connect-meter-button:hover {
  background-color: var(--electric-blue);
  color: white;
}

.round-arrow {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--electric-blue);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all var(--transition-fast);
}

.round-arrow:hover {
  background-color: var(--electric-blue-dark);
  transform: translateX(2px);
}

/* ========================
   PANELS & CARDS
   ======================== */

.panel {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: var(--space-lg);
  transition: all var(--transition-base);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.eyebrow {
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: var(--space-xs);
}

.section-heading h2 {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  line-height: var(--line-height-tight);
}

.panel-description {
  color: var(--text-secondary);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  margin-bottom: var(--space-lg);
}

/* ========================
   PAGE HEADING
   ======================== */

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
}

.page-heading h1 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-xs);
}

.page-subtitle {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  line-height: var(--line-height-base);
}

/* ========================
   METRICS GRID
   ======================== */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.metric-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: var(--space-lg);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--electric-blue), var(--electric-blue-light));
  opacity: 0;
  transition: opacity var(--transition-fast);
}

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

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.balance-card::before {
  background: linear-gradient(90deg, var(--electric-blue), var(--electric-blue-light));
  opacity: 1;
}

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

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

.metric-reset-btn {
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 2px 7px;
  line-height: 1.4;
  transition: all var(--transition-fast);
}

.metric-reset-btn:hover {
  background: var(--surface-hover);
  color: var(--color-teal);
  border-color: var(--color-teal);
}

.metric-top span:first-child {
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}

.metric-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
}

.metric-icon.icon-blue {
  background-color: var(--electric-blue-alpha);
  color: var(--electric-blue);
}

.metric-icon.icon-teal {
  background-color: rgba(20, 184, 166, 0.1);
  color: #14B8A6;
}

.metric-icon.icon-amber {
  background-color: var(--alert-amber-alpha);
  color: var(--alert-amber);
}

.balance-card .metric-icon {
  background: linear-gradient(135deg, var(--electric-blue), var(--electric-blue-light));
  color: white;
}

.metric-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: var(--space-xs);
}

.metric-value strong {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: var(--line-height-tight);
  font-variant-numeric: tabular-nums;
  transition: color var(--transition-fast);
}

.balance-card .metric-value {
  font-size: var(--font-size-display);
  font-weight: 700;
}

.balance-card .metric-value span:first-child {
  font-size: var(--font-size-xl);
  color: var(--text-secondary);
}

.balance-card .metric-value strong {
  font-size: var(--font-size-display);
  letter-spacing: -0.02em;
}

.metric-value span {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  font-weight: 500;
}

.metric-card p {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

/* Real-time burn rate & deduction badges */
.live-burn-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 100px;
  background-color: var(--bg-tertiary);
  color: var(--text-tertiary);
  border: 1px solid var(--border-color);
  transition: all var(--transition-base);
}

.live-burn-badge .pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
}

.live-burn-badge.is-burning {
  background-color: rgba(245, 158, 11, 0.14);
  color: var(--alert-amber);
  border-color: rgba(245, 158, 11, 0.35);
}

.live-burn-badge.is-burning .pulse-dot {
  animation: pulse-burn 1.2s ease-in-out infinite;
}

@keyframes pulse-burn {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}

.live-burn-badge.is-idle {
  background-color: var(--bg-tertiary);
  color: var(--text-tertiary);
}

.deduction-tracker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  padding: 4px 0;
  border-top: 1px dashed var(--border-color);
  margin-top: var(--space-xs);
  margin-bottom: var(--space-xs);
}

.deduction-label {
  color: var(--text-tertiary);
  font-weight: 500;
}

.deduction-value {
  color: var(--electric-blue);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.energy-submetrics {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  margin-top: 4px;
}

.submetric-item strong {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.energy-cost-tag {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  margin-top: 4px;
}

.energy-cost-tag strong {
  color: var(--electric-blue);
  font-weight: 600;
}

/* ========================
   DASHBOARD GRID
   ======================== */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.status-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.status-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border-radius: var(--border-radius-sm);
  transition: background-color var(--transition-fast);
}

.status-row:hover {
  background-color: var(--bg-tertiary);
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--text-tertiary);
  flex-shrink: 0;
}

.status-row[data-state="on"] .status-indicator {
  background-color: var(--power-on);
  box-shadow: 0 0 0 3px var(--power-on-alpha);
}

.status-row[data-state="off"] .status-indicator {
  background-color: var(--text-tertiary);
}

.status-row[data-state="alert"] .status-indicator {
  background-color: var(--critical);
  box-shadow: 0 0 0 3px var(--critical-alpha);
  animation: pulse-dot 2s ease-in-out infinite;
}

.status-indicator.warning {
  background-color: var(--alert-amber);
  box-shadow: 0 0 0 3px var(--alert-amber-alpha);
}

.status-indicator.danger {
  background-color: var(--critical);
  box-shadow: 0 0 0 3px var(--critical-alpha);
}

.status-row span:nth-child(2) {
  flex: 1;
  font-size: var(--font-size-base);
  color: var(--text-secondary);
}

.status-pill {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.status-pill.is-alert {
  color: var(--critical);
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background-color: var(--power-on-bg);
  color: var(--power-on);
  border-radius: 100px;
  font-size: var(--font-size-xs);
  font-weight: 600;
}

.live-pill span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
  animation: pulse-dot 2s ease-in-out infinite;
}

.relay-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.quick-account {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background-color: var(--bg-tertiary);
  border-radius: var(--border-radius);
  transition: all var(--transition-fast);
}

.quick-account:hover {
  background-color: var(--electric-blue-alpha);
}

.quick-account-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-sm);
  background: linear-gradient(135deg, var(--electric-blue), var(--electric-blue-light));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.quick-account strong {
  display: block;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  margin-bottom: 2px;
}

.quick-account small {
  display: block;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

/* ========================
   CHART
   ======================== */

.trend-panel {
  margin-bottom: var(--space-xl);
}

.trend-range {
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
  padding: var(--space-xs) var(--space-md);
  background-color: var(--bg-tertiary);
  border-radius: 100px;
}

.trend-summary {
  display: flex;
  align-items: baseline;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.trend-summary strong {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.trend-summary span {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 150px;
  margin-bottom: var(--space-sm);
}

.trend-chart {
  width: 100%;
  height: 100%;
}

.chart-line {
  fill: none;
  stroke: var(--electric-blue);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke var(--transition-base);
}

.chart-area {
  fill: url(#chartFill);
  transition: fill var(--transition-base);
}

.chart-axis {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
}

/* ========================
   SAFETY ALERTS
   ======================== */

.safety-alert-panel {
  margin-bottom: var(--space-xl);
  border-left: 4px solid var(--critical);
  background-color: var(--critical-alpha);
}

.alert-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 var(--space-xs);
  background-color: var(--critical);
  color: white;
  border-radius: 100px;
  font-size: var(--font-size-sm);
  font-weight: 700;
}

.safety-alert-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.safety-alert-list li {
  padding: var(--space-md);
  background-color: var(--bg-secondary);
  border-radius: var(--border-radius-sm);
  border-left: 3px solid var(--critical);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  animation: slide-in 0.3s ease;
}

.safety-alert-list li[data-level="warning"] {
  border-left-color: var(--alert-amber);
}

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

/* ========================
   BANNER & TOAST
   ======================== */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background-color: var(--power-off-alpha);
  border: 1px solid var(--power-off);
  border-radius: var(--border-radius);
  margin-bottom: var(--space-lg);
}

.alert-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: var(--power-off);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.alert strong {
  display: block;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  margin-bottom: 4px;
}

.alert p {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.alert-close {
  margin-left: auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.alert-close:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.telemetry-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background-color: var(--alert-amber-alpha);
  border: 1px solid var(--alert-amber);
  border-radius: var(--border-radius);
  margin-bottom: var(--space-lg);
}

.telemetry-banner[data-level="danger"] {
  background-color: var(--critical-alpha);
  border-color: var(--critical);
}

.telemetry-banner-mark {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: var(--alert-amber);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.telemetry-banner[data-level="danger"] .telemetry-banner-mark {
  background-color: var(--critical);
  animation: pulse-dot 2s ease-in-out infinite;
}

.telemetry-banner strong {
  display: block;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  margin-bottom: 4px;
}

.telemetry-banner p {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.toast {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-xl);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  z-index: 1000;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: all var(--transition-base);
  max-width: 400px;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ========================
   FORMS
   ======================== */

.field {
  margin-bottom: var(--space-lg);
}

.field label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

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

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--electric-blue);
  background-color: var(--bg-secondary);
  box-shadow: 0 0 0 3px var(--electric-blue-alpha);
}

.field input:disabled,
.field select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.field-with-unit {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.field-with-unit input {
  flex: 1;
}

.field-with-unit span {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.field-help {
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
  margin-top: var(--space-xs);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-lg);
}

.input-action {
  display: flex;
  align-items: center;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  overflow: hidden;
  transition: all var(--transition-fast);
  margin-bottom: var(--space-md);
}

.input-action:focus-within {
  border-color: var(--electric-blue);
  background-color: var(--bg-secondary);
  box-shadow: 0 0 0 3px var(--electric-blue-alpha);
}

.input-prefix,
.input-suffix {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-tertiary);
  background-color: var(--bg-primary);
  border-right: 1px solid var(--border-color);
}

.input-suffix {
  border-right: none;
  border-left: 1px solid var(--border-color);
}

.input-action input {
  flex: 1;
  border: none;
  background: none;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-base);
  color: var(--text-primary);
}

.input-action input:focus {
  outline: none;
  box-shadow: none;
}

.form-note {
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
}

.recharge-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
}

.settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  margin-top: var(--space-xl);
}

.muted-copy {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: var(--line-height-base);
}

/* ========================
   DIALOGS
   ======================== */

dialog {
  border: none;
  padding: 0;
  background: none;
  max-width: 500px;
  width: calc(100% - var(--space-xl));
}

dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.dialog-card {
  background-color: var(--bg-secondary);
  border-radius: var(--border-radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-xl);
}

.dialog-mark {
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius);
  background: linear-gradient(135deg, var(--electric-blue), var(--electric-blue-light));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: var(--space-lg);
}

.dialog-mark.danger-mark {
  background: linear-gradient(135deg, var(--critical), #EF4444);
}

.dialog-card h2 {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.dialog-card label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-xs);
}

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

.dialog-card input:focus {
  outline: none;
  border-color: var(--electric-blue);
  background-color: var(--bg-secondary);
  box-shadow: 0 0 0 3px var(--electric-blue-alpha);
}

.dialog-submit {
  width: 100%;
  margin-top: var(--space-xl);
}

.dialog-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-xl);
}

.dialog-actions button {
  flex: 1;
}

.dialog-error {
  padding: var(--space-sm) var(--space-md);
  background-color: var(--critical-alpha);
  border: 1px solid var(--critical);
  border-radius: var(--border-radius-sm);
  color: var(--critical);
  font-size: var(--font-size-sm);
  font-weight: 600;
  margin-top: var(--space-md);
}

/* ========================
   TABLES
   ======================== */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.activity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.activity-table thead th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.activity-table tbody td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

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

.activity-table tbody tr:hover {
  background-color: var(--bg-tertiary);
}

.empty-row td {
  text-align: center;
  padding: var(--space-xl) !important;
  color: var(--text-tertiary) !important;
}

.activity-status {
  color: var(--power-on);
  font-weight: 600;
}

/* ========================
   ACCOUNT PAGE
   ======================== */

.account-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.account-balance-panel {
  position: relative;
  overflow: hidden;
}

.large-account-balance {
  font-size: var(--font-size-display);
  font-weight: 700;
  color: var(--text-primary);
  line-height: var(--line-height-tight);
  font-variant-numeric: tabular-nums;
  margin: var(--space-lg) 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.large-account-balance span {
  font-size: var(--font-size-2xl);
  color: var(--text-secondary);
}

.balance-emblem {
  position: absolute;
  bottom: -20px;
  right: -20px;
  font-size: 120px;
  color: var(--border-color);
  opacity: 0.3;
  pointer-events: none;
}

.consumption-number {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: var(--space-xs);
  margin: var(--space-md) 0;
}

.consumption-number small {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
}

.consumption-track {
  height: 8px;
  background-color: var(--bg-tertiary);
  border-radius: 100px;
  overflow: hidden;
  margin: var(--space-md) 0;
}

.consumption-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--electric-blue), var(--electric-blue-light));
  border-radius: 100px;
  transition: width var(--transition-slow);
  width: 0%;
}

.estimate-copy {
  font-size: var(--font-size-sm);
  color: var(--electric-blue);
  font-weight: 600;
}

.secure-note {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: var(--space-xs) var(--space-sm);
  background-color: var(--power-on-bg);
  color: var(--power-on);
  border-radius: 100px;
  font-size: var(--font-size-xs);
  font-weight: 600;
}

/* Real-time tariff & lifetime ledger panels */
.realtime-deduction-card,
.lifetime-summary-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.tariff-rate-row,
.burn-rate-row,
.session-deducted-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: var(--font-size-sm);
}

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

.tariff-badge {
  padding: 2px 8px;
  background-color: var(--bg-tertiary);
  border-radius: var(--border-radius-sm);
  font-weight: 600;
  font-size: var(--font-size-xs);
  color: var(--electric-blue);
  font-variant-numeric: tabular-nums;
}

.burn-highlight {
  color: var(--alert-amber);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.deducted-highlight {
  color: var(--electric-blue);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.lifetime-meta-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: var(--space-md);
  padding-top: var(--space-sm);
  border-top: 1px dashed var(--border-color);
  font-size: var(--font-size-sm);
}

.lifetime-meta-grid div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-secondary);
}

.lifetime-meta-grid strong {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

[data-theme="hacker"] .burn-highlight {
  color: #FFCC00;
  text-shadow: 0 0 8px rgba(255, 204, 0, 0.4);
}

[data-theme="hacker"] .deducted-highlight,
[data-theme="hacker"] .tariff-badge {
  color: #00FF66;
  text-shadow: 0 0 8px rgba(0, 255, 102, 0.4);
}

[data-theme="hacker"] .live-burn-badge.is-burning {
  background: rgba(255, 204, 0, 0.15);
  border-color: rgba(255, 204, 0, 0.4);
  color: #FFCC00;
}

/* ========================
   CONTROL PAGE
   ======================== */

.control-page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.relay-state-badge {
  padding: var(--space-xs) var(--space-md);
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: 100px;
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.relay-state-badge[data-state="on"] {
  background-color: var(--power-on-bg);
  color: var(--power-on);
}

.relay-state-badge[data-state="off"] {
  background-color: var(--power-off-bg);
  color: var(--power-off);
}

.control-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.control-note {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md);
  background-color: var(--electric-blue-alpha);
  border-radius: var(--border-radius-sm);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.control-note span:first-child {
  flex-shrink: 0;
  color: var(--electric-blue);
  font-weight: 700;
}

/* ========================
   SETTINGS PAGE
   ======================== */

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

.settings-symbol {
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius);
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.security-symbol {
  background-color: var(--alert-amber-alpha);
  color: var(--alert-amber);
}

.billing-symbol {
  background: linear-gradient(135deg, var(--electric-blue), var(--electric-blue-light));
  color: white;
}

.reset-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xl);
}

.maintenance-actions {
  display: flex;
  gap: var(--space-sm);
  flex-shrink: 0;
}

/* ========================
   REPORTS PAGE
   ======================== */

.report-tools {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.filter-caption {
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: var(--space-xs);
  display: block;
}

.date-filter {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}

.date-filter label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

.date-filter input {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
}

.report-period-note {
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
}

.report-actions {
  display: flex;
  gap: var(--space-sm);
}

.report-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.report-summary {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
}

.report-summary strong {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.report-summary small {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  font-weight: 500;
}

.print-report-meta {
  display: none;
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
  margin-bottom: var(--space-lg);
}

/* ========================
   HELP PAGE
   ======================== */

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-lg);
}

.help-icon,
.safety-mark {
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius);
  background: linear-gradient(135deg, var(--electric-blue), var(--electric-blue-light));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: var(--space-md);
}

.help-safety .safety-mark {
  background: linear-gradient(135deg, var(--critical), #EF4444);
}

.security-note .safety-mark {
  background-color: var(--bg-tertiary);
  color: var(--electric-blue);
}

.help-grid h2 {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.help-step {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.help-step span {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--electric-blue-alpha);
  color: var(--electric-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--font-size-sm);
  flex-shrink: 0;
}

.help-step p {
  color: var(--text-secondary);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
}

/* ========================
   VIEW TRANSITIONS
   ======================== */

.view-page {
  display: none;
  animation: fade-in 0.3s ease;
}

.view-page.is-visible {
  display: block;
}

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

/* ========================
   FOOTER
   ======================== */

.workspace-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-xl) 0;
  margin-top: var(--space-2xl);
  border-top: 1px solid var(--border-color);
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
}

/* ========================
   PRINT STYLES
   ======================== */

@media print {
  .sidebar,
  .topbar,
  .connect-meter-button,
  .button,
  .workspace-footer,
  .alert,
  .telemetry-banner,
  .safety-alert-panel {
    display: none !important;
  }

  .workspace {
    margin-left: 0;
  }

  .print-report-meta {
    display: block;
  }

  .panel {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

/* ========================
   RESPONSIVE
   ======================== */

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
  }

  .workspace {
    margin-left: 0;
  }

  .mobile-brand {
    display: flex;
  }

  .topbar-context {
    display: none;
  }
}

@media (max-width: 768px) {
  .page-wrap {
    padding: var(--space-lg) var(--space-md);
  }

  .page-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
  }

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

  .balance-card .metric-value strong {
    font-size: var(--font-size-2xl);
  }

  .dashboard-grid,
  .account-summary-grid,
  .control-page-grid,
  .help-grid {
    grid-template-columns: 1fr;
  }

  .relay-buttons {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    gap: var(--space-sm);
  }

  .topbar-actions .button span:last-child,
  .updated-label,
  .topbar-divider {
    display: none;
  }

  .report-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .date-filter {
    flex-direction: column;
    align-items: stretch;
  }

  .report-actions {
    flex-direction: column;
  }

  .recharge-footer,
  .settings-actions,
  .reset-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .maintenance-actions {
    flex-direction: column;
  }
}

/* ========================
   REDUCED MOTION
   ======================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================
   UTILITY CLASSES
   ======================== */

[hidden] {
  display: none !important;
}

.text-center {
  text-align: center;
}
