/* =============================================================================
   Cloudpuncher — Design System
   =============================================================================
   Structure:
     1. Fonts
     2. Custom properties (design tokens)
     3. Base reset
     4. Layout primitives
     5. Glass cards
     6. KPI components
     7. Status utilities
     8. Navigation (sidebar + mobile)
     9. Topbar
    10. Skeleton loading
    11. Buttons & forms
    12. Chart containers
    13. Animations & transitions
    14. Scrollbar
   ============================================================================= */


/* -----------------------------------------------------------------------------
   1. Fonts
   ----------------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Barlow:ital,wght@0,300;0,400;0,500;0,600;1,300&family=Barlow+Condensed:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/*
  Barlow          — body, labels, UI text. Workhorse. Slightly condensed feel.
  Barlow Condensed — headings, section titles, nav. Punchy, industrial.
  JetBrains Mono  — all numeric data values. Makes numbers look like readings.
*/


/* -----------------------------------------------------------------------------
   2. Custom properties
   ----------------------------------------------------------------------------- */
:root {
  /* Palette — warm industrial dark */
  --bg-base:        #0f0e0c;   /* near-black, warm */
  --bg-surface:     #171612;   /* card background */
  --bg-raised:      #1e1c18;   /* elevated surface */
  --bg-overlay:     #252320;   /* hover states, active rows */

  /* Amber solar accent — the sun */
  --accent:         #f5a623;   /* primary amber */
  --accent-bright:  #ffc654;   /* hover / highlight */
  --accent-dim:     #b87b18;   /* muted / secondary */
  --accent-glow:    rgba(245, 166, 35, 0.15);

  /* Status colours */
  --status-ok:      #4caf7d;   /* generating, healthy */
  --status-warn:    #f5a623;   /* warning (reuses accent) */
  --status-error:   #e05c5c;   /* fault, offline */
  --status-idle:    #6b6760;   /* night, standby */
  --status-charge:  #5b9cf6;   /* battery charging */
  --status-discharge: #a78bfa; /* battery discharging */

  /* Text */
  --text-primary:   #f0ece4;   /* headings, values */
  --text-secondary: #a09b90;   /* labels, meta */
  --text-tertiary:  #635f58;   /* disabled, placeholder */
  --text-accent:    var(--accent);

  /* Borders */
  --border:         rgba(240, 236, 228, 0.07);
  --border-accent:  rgba(245, 166, 35, 0.3);
  --border-focus:   rgba(245, 166, 35, 0.7);

  /* Typography */
  --font-ui:        'Barlow', sans-serif;
  --font-display:   'Barlow Condensed', sans-serif;
  --font-mono:      'JetBrains Mono', monospace;

  /* Spacing */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Shadows */
  --shadow-card:  0 2px 12px rgba(0,0,0,0.4), 0 1px 3px rgba(0,0,0,0.3);
  --shadow-glow:  0 0 24px rgba(245, 166, 35, 0.12);
  --shadow-focus: 0 0 0 3px rgba(245, 166, 35, 0.25);

  /* Layout */
  --sidebar-width:      220px;
  --topbar-height:      56px;
  --mobile-nav-height:  60px;
  --content-max:        1280px;

  /* Transitions */
  --ease:       cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out:   cubic-bezier(0.0, 0.0, 0.2, 1);
  --duration:   180ms;
}


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

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

body {
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 0.9375rem;   /* 15px */
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-base);
  min-height: 100vh;

  /* Subtle warm grain texture — gives depth without noise */
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(245,166,35,0.06) 0%, transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--duration) var(--ease);
}
a:hover { color: var(--accent-bright); }

img, svg { display: block; max-width: 100%; }

button {
  font-family: var(--font-ui);
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: var(--font-ui);
  font-size: inherit;
}

::selection {
  background: rgba(245, 166, 35, 0.3);
  color: var(--text-primary);
}


/* -----------------------------------------------------------------------------
   4. Layout primitives
   ----------------------------------------------------------------------------- */

/* App shell — sidebar + main */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Main content area — offset for sidebar on desktop */
.main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-height);
  padding-bottom: var(--space-8);
}

/* Page wrapper — constrains content width */
.page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-6) var(--space-6) var(--space-10);
}

/* Page header */
.page-header {
  margin-bottom: var(--space-6);
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-primary);
  line-height: 1.1;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

/* Section divider */
.section-label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--space-3);
}

/* KPI grid — responsive, auto-filling */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-4);
}

.kpi-grid-wide {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
}

/* Two-column layout for dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--space-5);
  align-items: start;
}

/* Generic stack spacing */
.stack > * + * { margin-top: var(--space-5); }
.stack-sm > * + * { margin-top: var(--space-3); }


/* -----------------------------------------------------------------------------
   5. Glass cards
   ----------------------------------------------------------------------------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;

  /* Scanline texture — barely visible, industrial feel */
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(255,255,255,0.008) 2px,
    rgba(255,255,255,0.008) 4px
  );
}

.card-inner {
  padding: var(--space-5);
}

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

.card-title {
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* Accent left border variant */
.card--accent {
  border-left: 2px solid var(--accent);
}

/* Glowing variant for the live reading */
.card--live {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-card), var(--shadow-glow);
}


/* -----------------------------------------------------------------------------
   6. KPI components
   ----------------------------------------------------------------------------- */
.kpi-card {
  composes: card;  /* fallback for non-supporting browsers handled below */
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  position: relative;
  overflow: hidden;
  transition: border-color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease);
}

.kpi-card:hover {
  border-color: rgba(240, 236, 228, 0.12);
}

.kpi-label {
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.kpi-value--large {
  font-size: 2.5rem;
}

.kpi-value--small {
  font-size: 1.25rem;
}

.kpi-unit {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
}

.kpi-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

/* The live PAC reading — hero of the dashboard */
.kpi-live {
  animation: pulse-live 3s ease-in-out infinite;
}

/* Trend indicator */
.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.8125rem;
  font-weight: 500;
}

.kpi-trend--up   { color: var(--status-ok); }
.kpi-trend--down { color: var(--status-error); }
.kpi-trend--flat { color: var(--text-tertiary); }


/* -----------------------------------------------------------------------------
   7. Status utilities
   ----------------------------------------------------------------------------- */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-ok        { color: var(--status-ok); }
.status-warn      { color: var(--status-warn); }
.status-error     { color: var(--status-error); }
.status-idle      { color: var(--status-idle); }
.status-charge    { color: var(--status-charge); }
.status-discharge { color: var(--status-discharge); }

.status-dot-ok        { background: var(--status-ok);    box-shadow: 0 0 6px var(--status-ok); }
.status-dot-warn      { background: var(--status-warn);  box-shadow: 0 0 6px var(--status-warn); }
.status-dot-error     { background: var(--status-error); box-shadow: 0 0 6px var(--status-error); animation: blink 1.2s step-end infinite; }
.status-dot-idle      { background: var(--status-idle); }
.status-dot-charge    { background: var(--status-charge); }
.status-dot-discharge { background: var(--status-discharge); }

/* Battery bar */
.battery-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--bg-overlay);
  overflow: hidden;
}

.battery-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--status-ok);
  transition: width 0.6s var(--ease);
}

.battery-bar-fill--low    { background: var(--status-error); }
.battery-bar-fill--medium { background: var(--status-warn); }

/* String efficiency bar */
.string-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--bg-overlay);
  overflow: hidden;
}

.string-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.6s var(--ease);
}


/* -----------------------------------------------------------------------------
   8. Navigation — sidebar
   ----------------------------------------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo-mark {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  line-height: 1;
}

.sidebar-logo-mark svg,
.sidebar-logo-mark .logo-icon {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) var(--space-3);
}

.nav-group {
  margin-bottom: var(--space-6);
}

.nav-group-label {
  font-family: var(--font-display);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background var(--duration) var(--ease),
              color var(--duration) var(--ease);
  line-height: 1.3;
}

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

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 500;
  border: 1px solid var(--border-accent);
}

.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

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

.sidebar-footer {
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Mobile nav — bottom bar */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mobile-nav-height);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding: 0 var(--space-2);
}

.mobile-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 100%;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: color var(--duration) var(--ease);
  min-width: 52px;
  text-align: center;
}

.mobile-nav-item svg {
  width: 20px;
  height: 20px;
}

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


/* -----------------------------------------------------------------------------
   9. Topbar
   ----------------------------------------------------------------------------- */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: rgba(15, 14, 12, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  z-index: 90;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

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

/* System switcher */
.system-switcher {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-raised);
  cursor: pointer;
  transition: border-color var(--duration) var(--ease),
              background var(--duration) var(--ease);
  font-size: 0.875rem;
  color: var(--text-primary);
}

.system-switcher:hover {
  border-color: var(--border-accent);
  background: var(--bg-overlay);
}

.system-switcher-name {
  font-weight: 500;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.system-switcher-status {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Notification bell */
.notif-btn {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: background var(--duration), color var(--duration);
}

.notif-btn:hover {
  background: var(--bg-overlay);
  color: var(--text-primary);
}

.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-error);
  border: 2px solid var(--bg-base);
}

/* Avatar */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-glow);
  border: 1px solid var(--border-accent);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  cursor: pointer;
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Date navigation */
.date-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.date-nav-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all var(--duration) var(--ease);
}

.date-nav-btn:hover:not(:disabled) {
  border-color: var(--border-accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.date-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.date-nav-label {
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  min-width: 120px;
  text-align: center;
}


/* -----------------------------------------------------------------------------
   10. Skeleton loading
   ----------------------------------------------------------------------------- */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  color: transparent !important;
  background: linear-gradient(
    90deg,
    var(--bg-raised) 25%,
    var(--bg-overlay) 50%,
    var(--bg-raised) 75%
  );
  background-size: 800px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
  pointer-events: none;
  user-select: none;
}

/* Skeleton shapes */
.skeleton-text {
  height: 1em;
  border-radius: var(--radius-sm);
  display: inline-block;
}

.skeleton-text-sm  { width: 60px; }
.skeleton-text-md  { width: 120px; }
.skeleton-text-lg  { width: 200px; }

.skeleton-value {
  /* Applied to kpi-value elements while loading */
  min-width: 80px;
  min-height: 1.2em;
  display: inline-block;
}


/* -----------------------------------------------------------------------------
   11. Buttons & forms
   ----------------------------------------------------------------------------- */

/* Primary button */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
  border: 1px solid transparent;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #0f0e0c;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-bright);
  border-color: var(--accent-bright);
  color: #0f0e0c;
  box-shadow: 0 0 16px rgba(245, 166, 35, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--bg-overlay);
  color: var(--text-primary);
  border-color: rgba(240, 236, 228, 0.12);
}

.btn-danger {
  background: transparent;
  color: var(--status-error);
  border-color: rgba(224, 92, 92, 0.3);
}

.btn-danger:hover {
  background: rgba(224, 92, 92, 0.1);
  border-color: var(--status-error);
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: 0.75rem;
}

/* Form elements */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.form-input {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  color: var(--text-primary);
  font-size: 0.9375rem;
  transition: border-color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease);
  width: 100%;
}

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

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

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

.form-hint {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

.form-error {
  font-size: 0.8125rem;
  color: var(--status-error);
}

/* Google sign-in button */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  text-decoration: none;
}

.btn-google:hover {
  background: var(--bg-overlay);
  border-color: rgba(240, 236, 228, 0.15);
  color: var(--text-primary);
}

/* Auth divider */
.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  color: var(--text-tertiary);
  font-size: 0.8125rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Flash messages */
.flash {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  border: 1px solid;
}

.flash-error {
  background: rgba(224, 92, 92, 0.08);
  border-color: rgba(224, 92, 92, 0.3);
  color: #f08080;
}

.flash-success {
  background: rgba(76, 175, 125, 0.08);
  border-color: rgba(76, 175, 125, 0.3);
  color: var(--status-ok);
}


/* -----------------------------------------------------------------------------
   12. Chart containers
   ----------------------------------------------------------------------------- */
.chart-container {
  position: relative;
  width: 100%;
}

.chart-container canvas {
  width: 100% !important;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex-wrap: wrap;
  margin-top: var(--space-3);
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

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


/* -----------------------------------------------------------------------------
   13. Animations & transitions
   ----------------------------------------------------------------------------- */

/* The heartbeat — live PAC reading pulses very gently */
@keyframes pulse-live {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.82; }
}

/* Status dot blink for faults */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.2; }
}

/* Page fade in on load */
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fade-up 0.35s var(--ease) both;
}

/* Staggered card entrance */
.kpi-card:nth-child(1) { animation-delay: 0ms; }
.kpi-card:nth-child(2) { animation-delay: 40ms; }
.kpi-card:nth-child(3) { animation-delay: 80ms; }
.kpi-card:nth-child(4) { animation-delay: 120ms; }
.kpi-card:nth-child(5) { animation-delay: 160ms; }
.kpi-card:nth-child(6) { animation-delay: 200ms; }

/* Notification slide in */
@keyframes slide-in-right {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.notif-panel {
  animation: slide-in-right 0.25s var(--ease);
}


/* -----------------------------------------------------------------------------
   14. Scrollbar
   ----------------------------------------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(240, 236, 228, 0.12);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(240, 236, 228, 0.2);
}


/* -----------------------------------------------------------------------------
   Responsive — mobile
   ----------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .mobile-nav {
    display: flex;
  }

  .topbar {
    left: 0;
  }

  .main-content {
    margin-left: 0;
    padding-bottom: calc(var(--mobile-nav-height) + var(--space-4));
  }

  .page {
    padding: var(--space-4) var(--space-4) var(--space-8);
  }

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

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .kpi-value { font-size: 1.4rem; }
  .kpi-value--large { font-size: 2rem; }
}