/* ==========================================================================
   MUTECH SOLAR DASHBOARD - PREMIUM 16:9 ENERGY MONITORING SYSTEM
   ========================================================================== */

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

/* Color Themes & CSS Custom Properties */
:root {
  /* Default Theme: ORANGE */
  --accent-color: #ff7300;
  --accent-gradient: linear-gradient(135deg, #ff8c1a 0%, #ff5500 100%);
  --accent-glow: rgba(255, 115, 0, 0.45);
  --accent-glow-subtle: rgba(255, 115, 0, 0.15);
  --accent-rgb: 255, 115, 0;

  /* Global Dark Palette */
  --bg-darkest: #070b12;
  --bg-dashboard: #0a0f18;
  --bg-sidebar: #060a10;
  --card-bg: #0d1522;
  --card-bg-gradient: linear-gradient(180deg, rgba(16, 26, 42, 0.95) 0%, rgba(10, 17, 28, 0.98) 100%);
  --card-border: #1a2638;
  --card-hover-border: #2c3e59;

  /* Text Colors */
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-dim: #475569;

  /* Indicator Colors */
  --color-solar: #10b981;
  --color-solar-glow: rgba(16, 185, 129, 0.4);
  --color-load: #ef4444;
  --color-load-glow: rgba(239, 68, 68, 0.4);
  --color-inverter: #38bdf8;
  --color-grid: #f59e0b;
  --color-online: #22c55e;
  --color-offline: #ef4444;

  /* Typography (Modern Thai + Latin) */
  --font-main: 'Prompt', 'Kanit', 'Outfit', 'Inter', 'Leelawadee UI', 'Thonburi', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Dimensions */
  --header-height: 52px;
  --sidebar-width: 140px;
  --ticker-font-size: 19px;
  --ticker-height: 26px;
  --ticker-safe-gap: 10px;
}

/* 5 Theme Variations */
body[data-theme="orange"] {
  --accent-color: #ff7300;
  --accent-gradient: linear-gradient(135deg, #ff8c1a 0%, #ff5500 100%);
  --accent-glow: rgba(255, 115, 0, 0.45);
  --accent-glow-subtle: rgba(255, 115, 0, 0.15);
  --accent-rgb: 255, 115, 0;
}

body[data-theme="blue"] {
  --accent-color: #2563eb;
  --accent-gradient: linear-gradient(135deg, #38bdf8 0%, #1d4ed8 100%);
  --accent-glow: rgba(37, 99, 235, 0.45);
  --accent-glow-subtle: rgba(37, 99, 235, 0.15);
  --accent-rgb: 37, 99, 235;
}

body[data-theme="green"] {
  --accent-color: #10b981;
  --accent-gradient: linear-gradient(135deg, #34d399 0%, #059669 100%);
  --accent-glow: rgba(16, 185, 129, 0.45);
  --accent-glow-subtle: rgba(16, 185, 129, 0.15);
  --accent-rgb: 16, 185, 129;
}

body[data-theme="cyan"] {
  --accent-color: #06b6d4;
  --accent-gradient: linear-gradient(135deg, #22d3ee 0%, #0891b2 100%);
  --accent-glow: rgba(6, 182, 212, 0.45);
  --accent-glow-subtle: rgba(6, 182, 212, 0.15);
  --accent-rgb: 6, 182, 212;
}

body[data-theme="purple"] {
  --accent-color: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #a78bfa 0%, #7c3aed 100%);
  --accent-glow: rgba(139, 92, 246, 0.45);
  --accent-glow-subtle: rgba(139, 92, 246, 0.15);
  --accent-rgb: 139, 92, 246;
}

/* Customer-facing Production privacy: presentation only; telemetry remains intact. */
html.production-customer #nav-settings,
html.production-customer #modal-settings,
html.production-customer #production-cloud-mqtt-row,
html.production-customer #production-gateway-ip-row,
html.production-customer #ota-update-btn,
html.production-customer .report-download-card,
html.production-customer #btn-export-tier3,
html.production-customer #btn-export-tier2,
html.production-customer #btn-export-csv,
html.production-customer #btn-export-json,
html.production-customer #file-import-json,
html.production-customer #btn-clear-db {
  display: none !important;
}

html.production-customer #btn-open-tariff-settings {
  cursor: default !important;
  pointer-events: none;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-darkest);
  font-family: var(--font-main);
  color: var(--text-primary);
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* 16:9 Viewport Container & Auto Scaler */
#viewport-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #03060a;
  overflow: hidden;
}

#dashboard-scaler {
  width: 1920px;
  height: 1080px;
  min-width: 1920px;
  min-height: 1080px;
  max-width: 1920px;
  max-height: 1080px;
  transform-origin: center center;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-dashboard);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.9), 0 0 1px rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   TOP HEADER
   -------------------------------------------------------------------------- */
.top-header {
  height: var(--header-height);
  background: rgba(8, 13, 22, 0.95);
  border-bottom: 1px solid #141e2e;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  backdrop-filter: blur(10px);
}

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

.mutech-logo {
  display: flex;
  align-items: center;
  font-size: 26px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.5px;
  color: #ffffff;
}

.mutech-logo .m-symbol {
  color: var(--accent-color);
  margin-right: 2px;
  position: relative;
  text-shadow: 0 0 15px var(--accent-glow);
  transition: color 0.3s ease;
}

.mutech-logo .brand-text {
  font-family: var(--font-main);
  font-weight: 800;
}

.mutech-logo .brand-text .logo-mu,
.sidebar-footer-brand .logo-mu {
  color: #ffe600;
  text-shadow: 0 0 12px rgba(255, 230, 0, 0.6);
  font-weight: 900;
}

.header-divider {
  width: 1px;
  height: 20px;
  background-color: #243247;
}

.header-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: #7e8c9f;
  text-transform: uppercase;
}

.header-title span {
  color: #4b5563;
  margin: 0 8px;
}

/* Center-Right: Theme Switcher */
.header-controls {
  display: flex;
  align-items: center;
  gap: 28px;
}

.theme-selector {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-label {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
}

.theme-options {
  display: flex;
  align-items: center;
  gap: 14px;
}

.theme-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 20px;
  transition: all 0.2s ease;
}

.theme-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.theme-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  display: inline-block;
  position: relative;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
  transition: transform 0.2s ease;
}

.theme-btn[data-theme-choice="orange"] .theme-dot { background: #ff7300; }
.theme-btn[data-theme-choice="blue"] .theme-dot { background: #2563eb; }
.theme-btn[data-theme-choice="green"] .theme-dot { background: #10b981; }
.theme-btn[data-theme-choice="cyan"] .theme-dot { background: #06b6d4; }
.theme-btn[data-theme-choice="purple"] .theme-dot { background: #8b5cf6; }

.theme-btn.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.theme-btn.active .theme-dot {
  box-shadow: 0 0 0 2px var(--bg-dashboard), 0 0 0 4px var(--accent-color), 0 0 12px var(--accent-glow);
}

/* Header Live Status */
.live-status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 4px 12px;
  border-radius: 20px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-online);
  box-shadow: 0 0 10px var(--color-online);
  animation: pulse-glow 2s infinite ease-in-out;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.live-text-group {
  display: flex;
  flex-direction: column;
}

.live-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-online);
  letter-spacing: 0.8px;
}

.live-sub {
  font-size: 8px;
  color: #64748b;
  letter-spacing: 0.5px;
}

/* Header Clock & Actions */
.header-clock-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  border-left: 1px solid #1a2638;
  padding-left: 20px;
}

.clock-date {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 500;
}

.clock-time-group {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.clock-time {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 1px;
}

.clock-tz {
  font-size: 10px;
  color: #64748b;
  font-weight: 500;
}

.header-icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid #1e293b;
  color: #94a3b8;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.header-icon-btn:hover {
  background: var(--accent-glow-subtle);
  color: var(--accent-color);
  border-color: var(--accent-color);
}

.header-dashboard-control-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.header-exit-control,
.header-window-control {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid #1e293b;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.header-exit-control {
  color: #f87171;
}

.header-window-control {
  color: #94a3b8;
}

.header-exit-control:hover,
.header-exit-control:focus-visible {
  color: #fca5a5;
  background: rgba(255, 255, 255, 0.08);
  border-color: #334155;
  outline: none;
}

.header-window-control:hover,
.header-window-control:focus-visible {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  border-color: #334155;
  outline: none;
}

/* --------------------------------------------------------------------------
   DASHBOARD BODY (SIDEBAR + MAIN CONTENT)
   -------------------------------------------------------------------------- */
.dashboard-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  height: calc(1080px - var(--header-height));
  min-height: 0;
  transition: height 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#dashboard-scaler.has-ticker .dashboard-body {
  flex: 0 0 calc(1080px - var(--header-height) - var(--ticker-actual-height, var(--ticker-height)) - var(--ticker-safe-gap));
  height: calc(1080px - var(--header-height) - var(--ticker-actual-height, var(--ticker-height)) - var(--ticker-safe-gap));
  min-height: 0;
  margin-bottom: var(--ticker-safe-gap);
}

/* Left Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid #121c2b;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 0 16px 0;
  z-index: 50;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: none;
  border: none;
  color: #7b8ea6;
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  text-align: left;
  width: 100%;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
  flex-shrink: 0;
}

.nav-item:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
  color: var(--accent-color);
  background: var(--accent-glow-subtle);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent-color);
  box-shadow: 0 0 12px var(--accent-glow);
  border-radius: 0 4px 4px 0;
}

.sidebar-footer {
  padding: 12px 14px;
  position: relative;
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.4) 100%);
}

.sidebar-footer-brand {
  font-size: 15px;
  font-weight: 800;
  font-style: italic;
  color: #94a3b8;
  letter-spacing: -0.5px;
}

.sidebar-footer-sub {
  font-size: 9px;
  color: #475569;
  line-height: 1.3;
  margin-top: 4px;
}

.sidebar-glow-accent {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--accent-color);
  box-shadow: 0 0 15px var(--accent-glow);
}

/* --------------------------------------------------------------------------
   MAIN GRID CONTENT
   -------------------------------------------------------------------------- */
.main-content {
  flex: 1;
  min-height: 0;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 310px 1fr 540px;
  gap: 14px;
  overflow: hidden;
  background: radial-gradient(circle at 10% 20%, rgba(20, 30, 48, 0.3) 0%, transparent 60%);
}

/* Universal Card Styles */
.dash-card {
  background: var(--card-bg-gradient);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
}

.dash-card.glow-left::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent-color);
  box-shadow: 0 0 10px var(--accent-glow);
  border-radius: 4px 0 0 4px;
}

/* --------------------------------------------------------------------------
   COLUMN 1: POWER METRICS (LEFT)
   -------------------------------------------------------------------------- */
.col-power-metrics {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.site-badge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  margin-bottom: 2px;
}

.site-id-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.site-solar-icon {
  width: 28px;
  height: 28px;
  color: var(--accent-color);
  background: var(--accent-glow-subtle);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.site-title-text,
#badge-site-name {
  font-family: 'Prompt', 'Kanit', 'Outfit', 'Inter', sans-serif !important;
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: normal !important;
  word-spacing: normal !important;
  white-space: nowrap;
}

.site-title-text span,
#badge-site-name span {
  font-family: 'Prompt', 'Kanit', 'Outfit', sans-serif;
  color: #64748b;
  font-weight: 400;
  margin-left: 6px;
  font-size: 13.5px;
  letter-spacing: normal;
}

.live-pill-mini {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  color: var(--color-online);
  letter-spacing: 0.5px;
}

.live-pill-mini .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-online);
  animation: pulse-glow 2s infinite ease-in-out;
}

/* 4 Power Cards: Top 3 cards reduced by 30% (flex: 0.7), Card 4 takes remaining space (flex: 1.9) */
.power-card {
  flex: 0.7;
  display: flex;
  flex-direction: column;
  padding: 10px 16px;
  background: var(--card-bg-gradient);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

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

.power-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.power-card-label-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.power-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-color);
  background: var(--accent-glow-subtle);
  border: 1px solid rgba(var(--accent-rgb), 0.2);
}

.power-icon-box svg {
  width: 20px;
  height: 20px;
}

.power-label-title {
  font-size: 12px;
  font-weight: 700;
  color: #cbd5e1;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.power-label-sub {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.power-indicator {
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.power-indicator.up-green {
  color: #10b981;
}

.power-indicator.double-green {
  color: #10b981;
}

.power-indicator.down-red {
  color: #ef4444;
}

.power-indicator.up-yellow {
  color: #fbbf24;
}

.power-value-row {
  display: flex;
  align-items: baseline;
  justify-content: center; /* จัดค่าตัวเลขให้อยู่กลางการ์ด */
  width: 100%;
  padding-left: 0;
  margin-top: auto;
  margin-bottom: auto;
  transform: translateY(-4px); /* จัดกึ่งกลางแนวตั้ง */
}

.power-val-box,
.power-value {
  display: inline-flex;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 48px; /* 42px + 15% = 48.3px rounded to 48px */
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.5px;
  line-height: 1;
  transition: color 0.3s ease;
}

.power-val-int {
  display: inline-flex;
  justify-content: flex-end;
  align-items: baseline;
  width: 98px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: inherit;
}

.power-val-dot {
  display: inline-flex;
  justify-content: center;
  align-items: baseline;
  width: 16px;
  text-align: center;
  user-select: none;
  color: inherit;
}

.power-val-dec {
  display: inline-flex;
  justify-content: flex-start;
  align-items: baseline;
  width: 62px;
  text-align: left;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: inherit;
}

/* Card 2: Load Power is strictly yellow */
#metric-load-power,
#metric-load-power *,
.power-val-box.text-yellow,
.power-value.text-yellow {
  color: #fbbf24 !important;
}

/* Card 3: Grid Power real-time status blinking */
@keyframes blinkImportRed {
  0%, 100% {
    color: #ef4444;
    opacity: 1;
    text-shadow: 0 0 8px rgba(239, 68, 68, 0.7);
  }
  50% {
    color: #fca5a5;
    opacity: 0.25;
    text-shadow: none;
  }
}

@keyframes blinkExportGreen {
  0%, 100% {
    color: #10b981;
    opacity: 1;
    text-shadow: 0 0 8px rgba(16, 185, 129, 0.7);
  }
  50% {
    color: #6ee7b7;
    opacity: 0.25;
    text-shadow: none;
  }
}

#grid-power-sub {
  font-size: 22px; /* เพิ่มขนาด 100% จาก 11px เป็น 22px */
  font-weight: 700;
  line-height: 1.15;
  margin-top: 2px;
  letter-spacing: -0.2px;
}

.grid-sub-blink-import {
  display: inline-block;
  font-weight: 800;
  animation: blinkImportRed 1s ease-in-out infinite;
  color: #ef4444 !important;
}

.grid-sub-blink-export {
  display: inline-block;
  font-weight: 800;
  animation: blinkExportGreen 1s ease-in-out infinite;
  color: #10b981 !important;
}

.grid-sub-dimmed {
  opacity: 0.35;
  color: #64748b !important;
}

/* ==========================================================================
   Card 4: Sun Path & Solar Day Cycle Arc (วิถีการเดินทางของดวงอาทิตย์)
   ========================================================================== */
.power-card.sun-path-card {
  flex: 1.8;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px 14px 8px 14px;
  background: radial-gradient(circle at 50% 100%, rgba(245, 158, 11, 0.09) 0%, rgba(15, 23, 42, 0.75) 75%);
  border: 1px solid rgba(251, 191, 36, 0.22);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  margin-bottom: 12px; /* ยกกรอบล่างขึ้น เพื่อไม่ให้ตัวหนังสือวิ่งบนพื้นขาวทับกรอบ */
}

.power-card.sun-path-card:hover {
  border-color: rgba(251, 191, 36, 0.45);
  box-shadow: 0 6px 24px rgba(245, 158, 11, 0.15);
}

.sun-path-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.sun-path-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sun-path-icon-badge {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fbbf24;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sun-path-icon-badge svg {
  width: 15px;
  height: 15px;
}

.sun-path-title {
  font-size: 11px;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: 0.6px;
}

.sun-path-subtitle {
  font-size: 9px;
  color: #94a3b8;
}

.sun-phase-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2.5px 8px;
  border-radius: 12px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2px;
  background: rgba(251, 191, 36, 0.12);
  color: #fcd34d;
  border: 1px solid rgba(251, 191, 36, 0.3);
  transition: all 0.3s ease;
}

.sun-phase-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fbbf24;
  box-shadow: 0 0 6px #fbbf24;
  animation: pulse-glow 1.5s infinite;
}

.sun-phase-pill.phase-night {
  background: rgba(56, 189, 248, 0.12);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.3);
}

.sun-phase-pill.phase-night .sun-phase-dot {
  background: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
}

/* SVG Sky Dome Container */
.sun-arc-canvas-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  position: relative;
  padding: 0;
  margin: 0;
}

.sun-arc-svg {
  width: 100%;
  height: 98px;
  max-height: 105px;
  overflow: visible;
}

.sky-dome-fill {
  transition: fill 0.5s ease;
}

.sun-arc-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 2;
  stroke-dasharray: 4, 4;
}

.sun-arc-peak-zone {
  fill: none;
  stroke: rgba(251, 191, 36, 0.25);
  stroke-width: 6;
  stroke-linecap: round;
}

.sun-arc-progress {
  fill: none;
  stroke: url(#sunArcGrad);
  stroke-width: 3.5;
  stroke-linecap: round;
  filter: url(#sunGlow);
  transition: stroke-dashoffset 0.8s ease;
}

.sun-horizon-line {
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 1.5;
  stroke-dasharray: 2, 2;
}

.horizon-point {
  fill: #64748b;
}

.horizon-point.left {
  fill: #f97316;
}

.horizon-point.right {
  fill: #ea580c;
}

.celestial-outer-ring {
  animation: pulseSunRing 2.2s infinite ease-in-out;
}

@keyframes pulseSunRing {
  0%, 100% {
    r: 12px;
    opacity: 0.7;
  }
  50% {
    r: 15px;
    opacity: 1;
  }
}

.sun-rays-rot {
  animation: rotateSunRays 20s linear infinite;
  transform-origin: 0 0;
}

@keyframes rotateSunRays {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Sun Path Footer */
.sun-path-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  gap: 6px;
  margin-top: 2px;
}

.sun-time-node {
  display: flex;
  align-items: center;
  gap: 4px;
}

.node-icon {
  font-size: 13px;
}

.node-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.node-lbl {
  font-size: 8px;
  color: #64748b;
}

.node-time {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: #cbd5e1;
}

.sun-center-status {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  max-width: 120px;
}

.solar-noon-badge {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 8.5px;
  font-weight: 600;
  color: #fbbf24;
  white-space: nowrap;
}

.noon-icon {
  font-size: 10px;
}

.daylight-progress-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}

.daylight-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #f97316, #fbbf24);
  border-radius: 2px;
  transition: width 0.8s ease;
}

.power-unit {
  font-size: 16px;
  font-weight: 600;
  color: #94a3b8;
  margin-left: 8px;
  width: 24px;
  user-select: none;
  display: inline-block;
}

/* --------------------------------------------------------------------------
   COLUMN 2: MIDDLE SECTION (ENERGY, REVENUE, 24H GRAPH)
   -------------------------------------------------------------------------- */
.col-middle-center {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

/* Top 3 Energy Totals */
.energy-totals-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.energy-summary-card {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 124px;
}

.energy-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-color);
}

.energy-card-header svg {
  width: 18px;
  height: 18px;
}

.energy-card-title {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.energy-card-value {
  font-family: var(--font-mono);
  font-size: 36px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  margin: auto 0;
  line-height: 1;
}

.energy-card-revenue {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-color);
  font-family: var(--font-mono);
}

.energy-card-revenue svg {
  width: 14px;
  height: 14px;
}

.mini-bar-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.mini-bar-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 2px;
  box-shadow: 0 0 6px var(--accent-glow);
}

/* Middle Row 2: Revenue (2 cols) + Consumption (1 col) */
.revenue-consumption-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.revenue-consumption-row .revenue-bar-card {
  grid-column: span 2;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--card-bg-gradient);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  margin: 0;
  height: 100%;
}

.revenue-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.revenue-left-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.revenue-icon-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-glow-subtle);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  color: var(--accent-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.revenue-icon-circle svg {
  width: 17px;
  height: 17px;
}

.revenue-heading-box {
  display: flex;
  flex-direction: column;
}

.revenue-heading-text {
  font-size: 11.5px;
  font-weight: 700;
  color: #cbd5e1;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  white-space: nowrap;
}

.revenue-formula-tag {
  font-size: 10px;
  color: #64748b;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  white-space: nowrap;
}

/* 3-Column Full-Width Glassmorphism Grid */
.revenue-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  flex: 1;
}

.revenue-glass-card {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.revenue-glass-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.6), transparent);
  opacity: 0.7;
}

.revenue-glass-card:hover {
  background: rgba(255, 255, 255, 0.065);
  border-color: rgba(var(--accent-rgb), 0.35);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), 0 0 12px rgba(var(--accent-rgb), 0.2);
}

.rev-card-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.rev-card-icon {
  font-size: 13px;
  line-height: 1;
  display: inline-block;
  transform: translateY(-0.5px);
}

.rev-card-title {
  font-size: 11.5px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.rev-stat-amount {
  font-family: var(--font-mono);
  font-size: 21px; /* ขนาดใหญ่ ชัดเจน อ่านได้ง่ายจากระยะไกล */
  font-weight: 700;
  color: var(--accent-color);
  letter-spacing: -0.3px;
  white-space: nowrap;
  line-height: 1.15;
  text-shadow: 0 0 14px rgba(var(--accent-rgb), 0.3);
  text-align: center;
}

/* Consumption Donut Charts Card (Spans 1 Column, exactly matching This Year's Energy) */
.consumption-card {
  grid-column: span 1;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--card-bg-gradient);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  margin: 0;
  height: 100%;
}

.consumption-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
  padding-bottom: 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.consumption-card-title {
  font-size: 11px;
  font-weight: 800;
  color: #cbd5e1;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 5px;
}

.consumption-card-title svg {
  color: var(--accent-color);
}

.consumption-legend-pills {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.legend-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.legend-pill.pv {
  color: #10b981;
}

.legend-pill.pv .dot {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.legend-pill.grid {
  color: #f97316;
}

.legend-pill.grid .dot {
  background: #f97316;
  box-shadow: 0 0 6px rgba(249, 115, 22, 0.6);
}

/* 3-Column Donut Charts Grid */
.consumption-donuts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  align-items: center;
  padding: 2px 0;
}

.consumption-donut-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.consumption-donut-item:hover {
  transform: translateY(-2px);
}

.donut-period-title {
  font-size: 11px;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 3px;
  text-align: center;
  letter-spacing: 0.3px;
}

.donut-chart-wrapper {
  position: relative;
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.donut-ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.04);
  stroke-width: 13;
}

.donut-ring-grid {
  fill: none;
  stroke: #f97316; /* Grid Orange */
  stroke-width: 13;
  transition: stroke-dasharray 0.6s cubic-bezier(0.18, 0.88, 0.32, 1.06), transform 0.6s cubic-bezier(0.18, 0.88, 0.32, 1.06);
  transform-origin: 50% 50%;
}

.donut-ring-pv {
  fill: none;
  stroke: #10b981; /* PV Green */
  stroke-width: 13;
  transition: stroke-dasharray 0.6s cubic-bezier(0.18, 0.88, 0.32, 1.06), transform 0.6s cubic-bezier(0.18, 0.88, 0.32, 1.06);
  transform-origin: 50% 50%;
}

.donut-center-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.donut-pct-val {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1;
  letter-spacing: -0.5px;
}

.donut-sub-label {
  font-size: 7.5px;
  font-weight: 600;
  color: #94a3b8;
  margin-top: 2px;
  letter-spacing: 0.2px;
  line-height: 1;
}

/* Real-Time Power & Energy Chart Card (Lifted & Compacted) */
.chart-card {
  height: 275px;
  min-height: 265px;
  display: flex;
  flex-direction: column;
  padding: 10px 16px;
}

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

.chart-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-title-group svg {
  width: 18px;
  height: 18px;
  color: #94a3b8;
}

.chart-title-text {
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.chart-title-text span {
  color: #64748b;
  font-weight: 400;
  font-size: 11px;
}

.chart-legend-and-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* Peak Power Indicator Badge */
.chart-peak-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 245, 155, 0.08);
  border: 1px solid rgba(0, 245, 155, 0.28);
  padding: 3px 10px;
  border-radius: 20px;
  box-shadow: 0 0 12px rgba(0, 245, 155, 0.12);
  transition: all 0.3s ease;
  user-select: none;
}

.chart-peak-badge:hover {
  background: rgba(0, 245, 155, 0.14);
  border-color: rgba(0, 245, 155, 0.55);
  box-shadow: 0 0 16px rgba(0, 245, 155, 0.22);
}

.chart-peak-badge .peak-icon {
  font-size: 11px;
  color: #00f59b;
  display: flex;
  align-items: center;
  filter: drop-shadow(0 0 4px #00f59b);
}

.chart-peak-badge .peak-label {
  font-size: 10.5px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.2px;
}

.chart-peak-badge .peak-val {
  font-size: 11.5px;
  font-weight: 700;
  color: #00f59b;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  letter-spacing: 0.2px;
  text-shadow: 0 0 8px rgba(0, 245, 155, 0.45);
}

.chart-peak-badge .peak-time {
  font-size: 10px;
  color: #64748b;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #94a3b8;
}

.graph-series-legend {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.graph-series-legend[hidden] {
  display: none !important;
}

.graph-legend-button,
.graph-v2-expand-button {
  border: 0;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
}

.graph-v2-expand-button {
  display: none;
  width: 25px;
  height: 24px;
  border: 1px solid rgba(71, 85, 105, 0.7);
  border-radius: 5px;
  color: #94a3b8;
}

.graph-v2-expand-button:hover,
.graph-v2-expand-button:focus-visible {
  color: #22f28b;
  border-color: rgba(34, 242, 139, 0.55);
  outline: none;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.solar-dot {
  background: linear-gradient(135deg, #00f59b 0%, #10b981 50%, #047857 100%);
  box-shadow: 0 0 10px rgba(0, 245, 155, 0.8), 0 0 4px #10b981;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.legend-dot.load-dot {
  background: linear-gradient(135deg, #fb7185 0%, #ef4444 50%, #991b1b 100%);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.8), 0 0 4px #ef4444;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.legend-dot.grid-dot {
  background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 50%, #0284c7 100%);
  box-shadow: 0 0 10px rgba(14, 165, 233, 0.8), 0 0 4px #0ea5e9;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.chart-legend-item.dimmed {
  opacity: 0.35;
  text-decoration: line-through;
}

.time-range-toggle {
  display: flex;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid #1e293b;
  border-radius: 6px;
  padding: 2px;
}

.time-range-btn {
  background: none;
  border: none;
  color: #64748b;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.time-range-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.chart-container-box {
  flex: 1;
  position: relative;
  width: 100%;
  min-height: 205px;
}

.power-chart-zoom-controls {
  position: absolute;
  top: 3px;
  right: 7px;
  z-index: 4;
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid rgba(71, 85, 105, 0.65);
  border-radius: 7px;
  background: rgba(8, 15, 29, 0.82);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(5px);
}

.power-chart-zoom-controls button {
  width: 23px;
  height: 21px;
  padding: 0;
  border: 1px solid rgba(71, 85, 105, 0.55);
  border-radius: 4px;
  background: rgba(30, 41, 59, 0.72);
  color: #cbd5e1;
  font: 700 13px/19px var(--font-mono, 'JetBrains Mono', monospace);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.power-chart-zoom-controls button:hover,
.power-chart-zoom-controls button:focus-visible {
  color: #22f28b;
  border-color: rgba(34, 242, 139, 0.65);
  background: rgba(15, 68, 55, 0.78);
  outline: none;
}

.power-chart-zoom-controls button:disabled {
  color: #475569;
  border-color: rgba(51, 65, 85, 0.45);
  cursor: default;
  opacity: 0.65;
}

.graph-v2-inline-host {
  flex: 1;
  position: relative;
  min-height: 0;
}

#powerChartV2 {
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
  cursor: crosshair;
}

#powerChartV2.is-panning {
  cursor: grabbing;
}

.graph-v2-fullscreen-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 34px;
  background: rgba(2, 6, 15, 0.94);
  backdrop-filter: blur(12px);
}

.graph-v2-fullscreen-modal.open {
  display: flex;
}

.graph-v2-fullscreen-panel {
  width: min(1800px, 96vw);
  height: min(920px, 88vh);
  display: flex;
  flex-direction: column;
  padding: 18px;
  border: 1px solid rgba(34, 242, 139, 0.22);
  border-radius: 16px;
  background: radial-gradient(circle at 35% 0%, rgba(16, 185, 129, 0.08), transparent 38%), #070b13;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}

.graph-v2-fullscreen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 2px 14px;
}

.graph-v2-fullscreen-header strong,
.graph-v2-fullscreen-header span {
  display: block;
}

.graph-v2-fullscreen-header #graph-fullscreen-version-label {
  display: inline;
  margin: 0;
  color: inherit;
  font: inherit;
}

.graph-v2-fullscreen-header strong {
  color: #f8fafc;
  font: 700 18px/1.3 var(--font-display, 'Outfit', sans-serif);
}

.graph-v2-fullscreen-header span {
  margin-top: 4px;
  color: #64748b;
  font: 600 11px/1.2 var(--font-mono, 'JetBrains Mono', monospace);
}

.graph-v2-fullscreen-header button {
  width: 38px;
  height: 38px;
  border: 1px solid #334155;
  border-radius: 9px;
  background: rgba(30, 41, 59, 0.72);
  color: #cbd5e1;
  cursor: pointer;
}

.graph-v2-fullscreen-stage {
  flex: 1;
  min-height: 0;
}

.graph-v2-fullscreen-stage .chart-card {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
}

/* Flow 13: approved Golden Desktop allocation for the final realtime graph. */
html.graph-v2-final .main-content {
  grid-template-columns: 310px minmax(0, 1fr) 540px;
}

html.graph-v2-final .col-middle-center,
html.graph-v2-final .col-right-site {
  min-width: 0;
}

html.graph-v2-final .chart-card {
  flex: 0 0 310px;
  height: 310px;
  min-height: 310px;
  padding: 8px 12px;
}

html.graph-v2-final #dashboard-scaler.has-ticker .chart-card {
  flex-basis: 310px;
  height: 310px;
  min-height: 310px;
}

html.graph-v2-final .col-middle-center,
html.graph-v2-final #dashboard-scaler.has-ticker .col-middle-center {
  gap: 4px;
}

html.graph-v2-final .energy-summary-card {
  height: 95px;
  padding: 7px 12px;
}

html.graph-v2-final .revenue-consumption-row {
  flex: 0 0 120px;
  height: 120px;
  min-height: 120px;
}

html.graph-v2-final .revenue-consumption-row .revenue-bar-card,
html.graph-v2-final .consumption-card {
  min-height: 0;
  padding-block: 6px;
}

html.graph-v2-final .grid-meter-card {
  gap: 4px;
  padding-block: 6px;
}

html.graph-v2-final .grid-meter-content-grid {
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

html.graph-v2-final .grid-combined-exchange-box {
  gap: 4px;
  min-height: 0;
}

html.graph-v2-final .exchange-cards-top-group {
  gap: 5px;
}

html.graph-v2-final .exchange-sub-card {
  gap: 3px;
  padding: 3px 10px;
}

html.graph-v2-final .exchange-scada-meter-panel {
  gap: 4px;
  min-height: 0;
  padding: 4px 8px;
}

html.graph-v2-final .scada-gauges-grid {
  min-height: 0;
}

html.graph-v2-final .chart-header {
  flex: 0 0 36px;
  min-height: 36px;
  gap: 10px;
  margin-bottom: 4px;
}

html.graph-v2-final .chart-title-group {
  flex: 0 1 auto;
  gap: 6px;
  min-width: 0;
}

html.graph-v2-final .chart-title-group svg {
  width: 15px;
  height: 15px;
}

html.graph-v2-final .chart-title-text {
  font-size: 10.5px;
  letter-spacing: 0.3px;
}

html.graph-v2-final .chart-title-text span {
  font-size: 8.5px;
}

html.graph-v2-final .chart-legend-and-controls {
  flex: 0 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  min-width: 0;
}

html.graph-v2-final .chart-peak-badge {
  flex: 0 0 auto;
  gap: 3px;
  padding: 3px 7px;
}

html.graph-v2-final .chart-peak-badge .peak-label {
  display: none;
}

html.graph-v2-final .graph-series-legend {
  flex: 0 0 auto;
  gap: 8px;
}

html.graph-v2-final .chart-legend-item {
  gap: 4px;
  font-size: 9.5px;
}

html.graph-v2-final .legend-dot {
  width: 8px;
  height: 8px;
}

html.graph-v2-final .time-range-btn {
  padding-inline: 6px;
  font-size: 9px;
}

html.graph-v2-final .graph-v2-expand-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 24px;
  height: 23px;
  padding: 0;
}

html.graph-v2-final .chart-container-box,
html.graph-v2-final .graph-v2-inline-host,
html.graph-v2-final .graph-v2-view {
  min-height: 0;
  height: 100%;
}

html.graph-v2-final .graph-v2-fullscreen-stage .chart-card {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 12px 16px 14px;
}

html.graph-v2-final .graph-v2-fullscreen-stage .chart-header {
  flex-basis: 42px;
  min-height: 42px;
  margin-bottom: 6px;
}

/* --------------------------------------------------------------------------
   GRID ENERGY EXCHANGE & MONTHLY YIELD CARD
   -------------------------------------------------------------------------- */
.grid-meter-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 14px;
  gap: 6px;
  min-height: 180px;
}

.grid-meter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.grid-meter-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.grid-meter-title-group svg {
  width: 16px;
  height: 16px;
  color: #38bdf8;
}

.grid-meter-title-text {
  font-size: 11.5px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.grid-meter-title-text span {
  color: #64748b;
  font-weight: 400;
  font-size: 10.5px;
}

.grid-meter-status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(14, 165, 233, 0.08);
  border: 1px solid rgba(14, 165, 233, 0.28);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  color: #38bdf8;
  font-family: var(--font-mono);
}

.grid-meter-status-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

/* 2-Column Split: Card 1 (Left 385px) vs Merged Cards 2&3 (Right 1fr) */
.grid-meter-content-grid {
  display: grid;
  grid-template-columns: 385px 1fr;
  gap: 10px;
  flex: 1;
  min-height: 135px;
}

/* Card 1: Combined Grid Power Exchange (Import + Export + Meter) */
.grid-combined-exchange-box {
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
}

/* กระชับและจัดสัดส่วนกล่องซื้อไฟและขายไฟให้สูงขึ้น สวยงาม เด่นชัด */
.exchange-cards-top-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exchange-sub-card {
  background: rgba(10, 16, 28, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: all 0.2s ease;
}

.exchange-sub-card:hover {
  background: rgba(15, 23, 42, 0.85);
  border-color: rgba(255, 255, 255, 0.12);
}

.sub-import {
  border-left: 3.5px solid #ef4444;
}

.sub-export {
  border-left: 3.5px solid #10b981;
}

.exchange-sub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.meter-box-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2.5px 8px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.import-badge {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.export-badge {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.meter-box-sub {
  font-size: 9.5px;
  color: #64748b;
  font-family: var(--font-mono);
}

.exchange-mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  align-items: center;
}

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

.ex-lbl {
  font-size: 9px;
  color: #94a3b8;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.2px;
}

.ex-val-row {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.ex-num {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.3px;
  line-height: 1.1;
}

.sub-import .ex-num {
  color: #fca5a5;
}

.sub-export .ex-num {
  color: #6ee7b7;
}

.ex-unit {
  font-size: 9.5px;
  color: #64748b;
  font-weight: 600;
}

.ex-cost {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: #94a3b8;
}

/* ==========================================================================
   Industrial SCADA Real-Time Smart Meter Panel (DTSU666-H RS485 LIVE)
   ========================================================================== */
.exchange-scada-meter-panel {
  background: rgba(10, 16, 28, 0.94);
  border: 1px solid rgba(14, 165, 233, 0.28);
  border-left: 3.5px solid #0ea5e9;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1; /* ขยายเต็มพื้นที่ที่เหลือ เพื่อให้ความสูงเสมอกับกราฟ Monthly Yield ด้านขวา */
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35);
}

.scada-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.scada-header-left {
  display: flex;
  align-items: center;
  gap: 7px;
}

.scada-icon-pulse {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: rgba(14, 165, 233, 0.15);
  border: 1px solid rgba(14, 165, 233, 0.35);
  color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scada-icon-pulse svg {
  width: 13px;
  height: 13px;
}

.scada-title-wrap {
  display: flex;
  flex-direction: column;
}

.scada-main-title {
  font-size: 11px;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.3px;
}

.scada-sub-tag {
  font-size: 8.5px;
  color: #64748b;
  font-family: var(--font-mono);
}

.scada-online-pill {
  font-size: 8.5px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: #38bdf8;
  background: rgba(14, 165, 233, 0.12);
  border: 1px solid rgba(14, 165, 233, 0.35);
  padding: 2px 7px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.scada-dot-live {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
  animation: pulse-glow 1.5s infinite;
}

/* 4 SCADA Gauges Grid - ขยายให้เต็มพื้นที่การ์ด กำจัด Dead Space */
.scada-gauges-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  flex: 1;
}

.scada-gauge-box {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: border-color 0.2s ease, background 0.2s ease;
  height: 100%;
}

.scada-gauge-box:hover {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(15, 23, 42, 0.95);
}

.scada-gauge-box.gauge-net {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.06);
}

.scada-gauge-label {
  font-size: 9px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.scada-gauge-val-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
  margin: 4px 0;
}

.scada-gauge-val {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.3px;
  line-height: 1.1;
}

.scada-gauge-val.val-green {
  color: #34d399;
  text-shadow: 0 0 8px rgba(52, 211, 153, 0.4);
}

.scada-gauge-val.val-cyan {
  color: #38bdf8;
}

.scada-gauge-unit {
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
  margin-left: 1px;
}

.scada-gauge-sub {
  font-size: 8.5px;
  color: #64748b;
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* Net Energy Balance Bar */
.scada-balance-wrapper {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 6px 9px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.scada-balance-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.bal-label-left {
  display: flex;
  align-items: center;
  gap: 3px;
  color: #fca5a5;
  font-size: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.bal-label-center {
  font-size: 8.5px;
  font-weight: 600;
  color: #38bdf8;
  letter-spacing: 0.1px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 2px;
}

.bal-label-right {
  display: flex;
  align-items: center;
  gap: 3px;
  color: #6ee7b7;
  font-size: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.bal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  display: inline-block;
}

.bal-dot.red {
  background: #ef4444;
  box-shadow: 0 0 4px #ef4444;
}

.bal-dot.green {
  background: #10b981;
  box-shadow: 0 0 4px #10b981;
}

.scada-balance-track {
  position: relative;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.scada-balance-center-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: rgba(255, 255, 255, 0.35);
  transform: translateX(-50%);
  z-index: 2;
}

.scada-balance-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  height: 100%;
  border-radius: 3px;
  transition: all 0.4s ease;
  z-index: 1;
}

/* Merged Cards 2 & 3: Monthly Daily Yield Bar Chart Box */
.monthly-yield-box {
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.monthly-yield-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
  gap: 6px;
  flex-wrap: nowrap;
}

.yield-title-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 1;
  min-width: 0;
  white-space: nowrap;
}

.yield-title-group svg {
  color: #10b981;
  flex-shrink: 0;
}

.yield-title-text {
  font-size: 10.5px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
}

.yield-title-text span {
  font-size: 9px;
  color: #64748b;
  font-weight: 400;
}

.yield-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Month Navigation Pill (Back/Forward arrows) */
.yield-month-nav {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 1.5px 4px;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  white-space: nowrap;
}

.yield-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 4px;
  color: #94a3b8;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
  user-select: none;
}

.yield-nav-btn:hover:not(:disabled) {
  background: rgba(16, 185, 129, 0.25);
  border-color: #10b981;
  color: #34d399;
  transform: scale(1.08);
}

.yield-nav-btn:active:not(:disabled) {
  transform: scale(0.92);
}

.yield-nav-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  pointer-events: none;
}

.yield-nav-label {
  font-family: 'Prompt', 'Outfit', sans-serif;
  font-size: 10px;
  font-weight: 600;
  color: #e2e8f0;
  min-width: 54px;
  text-align: center;
  letter-spacing: 0.2px;
  user-select: none;
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 4px;
  transition: background 0.15s ease, color 0.15s ease;
}

.yield-nav-label:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #38bdf8;
}

.yield-badge-box {
  display: flex;
  align-items: baseline;
  gap: 4px;
  background: rgba(16, 185, 129, 0.10);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 1.5px 7px;
  border-radius: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

.yield-badge-lbl {
  font-size: 9.5px;
  color: #94a3b8;
  white-space: nowrap;
}

.yield-badge-num {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: #6ee7b7;
  white-space: nowrap;
}

.yield-badge-unit {
  font-size: 9px;
  color: #64748b;
  white-space: nowrap;
}

.monthly-yield-chart-wrapper {
  flex: 1;
  position: relative;
  width: 100%;
  min-height: 105px;
}

#monthlyYieldChart {
  width: 100% !important;
  height: 100% !important;
}

/* --------------------------------------------------------------------------
   COLUMN 3: RIGHT SECTION (PHOTO, ECO, FLOW & PV DETAILS)
   -------------------------------------------------------------------------- */
.col-right-site {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

/* Top Rooftop Image Card (16:9 Aspect Ratio) */
.rooftop-image-card {
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  min-height: 290px;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--card-border);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

.rooftop-img {
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform 0.4s ease;
}

.rooftop-image-card:hover .rooftop-img {
  transform: scale(1.03);
}

.rooftop-overlay-gradient {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, rgba(10, 16, 26, 0) 0%, rgba(10, 16, 26, 0) 68%, rgba(10, 16, 26, 0.28) 100%);
  pointer-events: none;
}

.wifi-status-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(10, 15, 24, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 4px 10px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #ffffff;
  cursor: pointer;
  z-index: 5;
}

.wifi-indicator-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-online);
  box-shadow: 0 0 6px var(--color-online);
}

.wifi-signal-icon {
  width: 14px;
  height: 14px;
  color: #ffffff;
}

.site-name-badge {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(10, 15, 24, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 6px 14px;
  border-radius: 6px;
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  color: #ffffff;
  letter-spacing: 0.3px;
  z-index: 5;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  user-select: none;
}

.site-name-badge:hover {
  background: rgba(15, 23, 42, 0.95);
  border-color: var(--accent-color);
  box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.4);
  transform: translateY(-1px);
}

.site-name-badge-edit-icon {
  width: 12px;
  height: 12px;
  color: var(--accent-color);
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.2s ease;
}

.site-name-badge:hover .site-name-badge-edit-icon {
  opacity: 1;
  transform: scale(1);
}

/* Rooftop Action Bar (Top Left Hover) */
.rooftop-action-bar {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.rooftop-image-card:hover .rooftop-action-bar,
.rooftop-image-card:hover .btn-change-image {
  opacity: 1;
}

.btn-rooftop-action,
.btn-change-image {
  background: rgba(10, 15, 24, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #cbd5e1;
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.btn-rooftop-action:hover,
.btn-change-image:hover {
  color: #ffffff;
  background: rgba(var(--accent-rgb), 0.85);
  border-color: var(--accent-color);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.4);
}

/* Customer Logo Overlay (รองรับไฟล์ PNG โปร่งใส) */
.rooftop-logo-overlay {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 6;
  transition: all 0.25s ease;
  user-select: none;
}

/* Glass Badge styling (หรูหรา มีมิติพื้นหลังโปร่งแสง) */
.rooftop-logo-overlay.with-badge-bg {
  background: rgba(10, 16, 26, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 5px 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

.rooftop-logo-overlay.with-badge-bg:hover {
  background: rgba(15, 23, 42, 0.92);
  border-color: var(--accent-color);
  box-shadow: 0 0 16px rgba(var(--accent-rgb), 0.35);
  transform: translateY(-1px);
}

/* Floating transparent mode (ลอยโปร่งใสสนิทตรงบนภาพ) */
.rooftop-logo-overlay.no-badge-bg {
  background: transparent !important;
  border: none !important;
  padding: 2px !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

.rooftop-logo-overlay.no-badge-bg:hover {
  transform: scale(1.05);
}

/* Position Variants */
.rooftop-logo-overlay.pos-bottom-right {
  bottom: 12px;
  right: 12px;
}

.rooftop-logo-overlay.pos-top-right {
  top: 44px;
  right: 12px;
}

.rooftop-logo-overlay.pos-bottom-left {
  bottom: 12px;
  left: 200px;
}

.rooftop-logo-overlay.pos-top-left {
  top: 44px;
  left: 12px;
}

/* Size Variants */
.rooftop-logo-overlay.size-small .rooftop-logo-img {
  max-height: 28px;
  max-width: 120px;
}

.rooftop-logo-overlay.size-medium .rooftop-logo-img {
  max-height: 40px;
  max-width: 160px;
}

.rooftop-logo-overlay.size-large .rooftop-logo-img {
  max-height: 52px;
  max-width: 200px;
}

.rooftop-logo-img {
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.65));
  transition: transform 0.2s ease;
}

/* Edit Badge Indicator on Hover */
.rooftop-logo-edit-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-color);
  color: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: scale(0.6);
  transition: all 0.2s ease;
}

.rooftop-logo-overlay:hover .rooftop-logo-edit-badge {
  opacity: 1;
  transform: scale(1);
}

/* Checkerboard pattern for transparent PNG preview in modal */
.png-checkerboard {
  background-color: #1e293b;
  background-image: 
    linear-gradient(45deg, #0f172a 25%, transparent 25%), 
    linear-gradient(-45deg, #0f172a 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #0f172a 75%), 
    linear-gradient(-45deg, transparent 75%, #0f172a 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  padding: 12px;
}

/* Environmental Benefits Card */
.environmental-card {
  padding: 14px 18px;
}

.env-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.env-header svg {
  width: 18px;
  height: 18px;
  color: #10b981;
}

.env-header-title {
  font-size: 12px;
  font-weight: 700;
  color: #cbd5e1;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.env-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.env-stat-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.env-icon-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.env-icon-circle.coal {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
  color: #f59e0b;
}

.env-icon-circle.tree {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.3);
  color: #22c55e;
}

.env-stat-data {
  display: flex;
  flex-direction: column;
}

.env-stat-val {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
}

.env-stat-sub {
  font-size: 10px;
  color: #64748b;
  margin-top: 1px;
}

/* Bottom Right: Energy Flow & RS485 PV Card */
.energy-flow-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
  justify-content: space-between;
}

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

.flow-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.flow-title-group svg {
  width: 16px;
  height: 16px;
  color: var(--accent-color);
}

.flow-title-text {
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.flow-breadcrumb {
  font-size: 11px;
  color: var(--accent-color);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* --------------------------------------------------------------------------
   PREMIUM ENERGY FLOW SYSTEM (EXPORT & IMPORT MODES)
   -------------------------------------------------------------------------- */
.energy-flow-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  gap: 8px;
}

.flow-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flow-title-group {
  display: flex;
  align-items: center;
  gap: 7px;
}

.flow-title-group svg {
  width: 15px;
  height: 15px;
  color: var(--accent-color);
}

.flow-title-text {
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.flow-controls-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.flow-mode-toggle {
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.flow-mode-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.flow-mode-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.flow-mode-btn.active {
  background: var(--accent-glow-subtle);
  color: var(--accent-color);
  font-weight: 700;
  box-shadow: 0 0 8px var(--accent-glow-subtle);
}

.flow-expand-btn {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 4px;
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.flow-expand-btn:hover {
  color: #ffffff;
  border-color: var(--accent-color);
  background: rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   ENERGY FLOW STAGE (Dot-Matrix Background Canvas)
   ========================================================================== */
.energy-flow-stage {
  position: relative;
  width: 100%;
  height: 250px;
  background-color: #121824;
  background-image: radial-gradient(rgba(255, 255, 255, 0.12) 1.2px, transparent 1.2px);
  background-size: 20px 20px;
  background-position: 10px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  user-select: none;
}

/* Top Status Badge Pill */
.flow-status-badge {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(18, 26, 38, 0.88);
  backdrop-filter: blur(8px);
  padding: 4px 14px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: all 0.3s ease;
}

.flow-status-badge.status-export {
  border-color: rgba(6, 182, 212, 0.35);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.15);
}

.flow-status-badge.status-export .status-badge-dot {
  background: #06b6d4;
  box-shadow: 0 0 8px #06b6d4;
}

.flow-status-badge.status-import {
  border-color: rgba(168, 85, 247, 0.35);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.15);
}

.flow-status-badge.status-import .status-badge-dot {
  background: #c084fc;
  box-shadow: 0 0 8px #c084fc;
}

.status-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  animation: pulse-glow 2s infinite ease-in-out;
}

.status-badge-text {
  font-size: 11px;
  font-weight: 600;
  color: #f1f5f9;
  letter-spacing: 0.2px;
}

/* SVG Overlay for Dynamic Conduits */
.flow-svg-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* Base Wide Translucent Ribbon Conduits */
.flow-conduit-ribbon {
  fill: none;
  stroke-width: 15px;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.42;
  transition: opacity 0.4s ease;
}

/* Core Dashed Energy Pulse Lines */
.flow-conduit-dash {
  fill: none;
  stroke-width: 2.8px;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 6 9;
  opacity: 1;
  transition: opacity 0.4s ease;
}

/* Smooth, Slow Dashed Flow Animations */
.dash-solar {
  stroke: #10b981;
  filter: drop-shadow(0 0 4px #059669);
  animation: flowDashNormal 1.8s linear infinite;
}

.dash-load {
  stroke: #fbbf24;
  filter: drop-shadow(0 0 4px #f59e0b);
  animation: flowDashNormal 1.8s linear infinite;
}

.dash-export {
  stroke: #38bdf8;
  filter: drop-shadow(0 0 5px #06b6d4);
  animation: flowDashNormal 1.8s linear infinite;
}

.dash-import {
  stroke: #d8b4fe;
  filter: drop-shadow(0 0 5px #a855f7);
  animation: flowDashNormal 1.8s linear infinite;
}

@keyframes flowDashNormal {
  from {
    stroke-dashoffset: 0;
  }
  to {
    stroke-dashoffset: -30;
  }
}

/* Floating Conduit Badges (Placed at curve midpoints) */
.flow-conduit-badge {
  position: absolute;
  z-index: 15;
  background: rgba(14, 21, 33, 0.94);
  backdrop-filter: blur(8px);
  border-radius: 9999px;
  padding: 1.5px 7px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
  transition: opacity 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.flow-conduit-badge.badge-solar {
  border: 1px solid rgba(16, 185, 129, 0.55);
  color: #34d399;
}

.flow-conduit-badge.badge-load {
  border: 1px solid rgba(251, 191, 36, 0.55);
  color: #fbbf24;
}

.flow-conduit-badge.badge-grid.mode-export {
  border: 1px solid rgba(6, 182, 212, 0.55);
  color: #22d3ee;
}

.flow-conduit-badge.badge-grid.mode-import {
  border: 1px solid rgba(168, 85, 247, 0.55);
  color: #c084fc;
}

/* ==========================================================================
   FLOW NODE CARDS (Solar, Inverter, Home Load, Grid) - Compact & Elegant
   ========================================================================== */
.flow-node-card {
  position: absolute;
  z-index: 10;
  background: #101622;
  border-radius: 9px;
  padding: 4px 6px 3px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
  transition: transform 0.25s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  width: 78px;
  min-width: 76px;
  max-width: 82px;
  box-sizing: border-box;
}

.flow-node-card:hover {
  transform: scale(1.05);
}

/* Node 1: โซล่าเซลล์ (เขียวเมื่อผลิตได้ > 0.00kW, เทาเมื่อ <= 0.00kW) */
.flow-node-card.node-solar {
  left: 12px;
  top: 48%;
  transform: translateY(-50%);
  border: 1.5px solid #10b981;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4), inset 0 0 10px rgba(16, 185, 129, 0.15);
  color: #10b981;
  transition: all 0.3s ease;
}
.flow-node-card.node-solar:hover {
  transform: translateY(-50%) scale(1.05);
}

.flow-node-card.node-solar.solar-active {
  border-color: #10b981;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4), inset 0 0 10px rgba(16, 185, 129, 0.18);
  color: #10b981;
}
.flow-node-card.node-solar.solar-active .node-power {
  color: #10b981 !important;
}
.flow-node-card.node-solar.solar-active .node-icon-box svg rect,
.flow-node-card.node-solar.solar-active .node-icon-box svg line {
  stroke: #10b981 !important;
}

.flow-node-card.node-solar.solar-inactive {
  border-color: #64748b;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4), inset 0 0 10px rgba(100, 116, 139, 0.12);
  color: #64748b;
}
.flow-node-card.node-solar.solar-inactive .node-title {
  color: #94a3b8;
}
.flow-node-card.node-solar.solar-inactive .node-power {
  color: #64748b !important;
}
.flow-node-card.node-solar.solar-inactive .node-icon-box svg rect,
.flow-node-card.node-solar.solar-inactive .node-icon-box svg line {
  stroke: #64748b !important;
}

/* Node 2: อินเวอร์เตอร์ */
.flow-node-card.node-inverter {
  left: 36%;
  top: 48%;
  transform: translate(-50%, -50%);
  border: 1.5px solid #2563eb;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4), inset 0 0 10px rgba(37, 99, 235, 0.12);
}
.flow-node-card.node-inverter:hover {
  transform: translate(-50%, -50%) scale(1.05);
}

/* Node 3: โหลดในบ้าน (เปลี่ยนเป็นสีเหลือง) */
.flow-node-card.node-load {
  right: 12px;
  top: 10%;
  border: 1.5px solid #fbbf24;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4), inset 0 0 10px rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

.flow-node-card.node-load .node-icon-box svg path {
  stroke: #fbbf24 !important;
}

.flow-node-card.node-grid {
  right: 12px;
  bottom: 8%;
  transition: border-color 0.35s ease, box-shadow 0.35s ease;
}

.flow-node-card.node-grid.mode-export {
  border: 1.5px solid #06b6d4;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4), inset 0 0 10px rgba(6, 182, 212, 0.12);
  color: #06b6d4;
}

.flow-node-card.node-grid.mode-import {
  border: 1.5px solid #a855f7;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4), inset 0 0 10px rgba(168, 85, 247, 0.12);
  color: #c084fc;
}

.node-icon-box {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1px;
}

.node-title {
  font-size: 9px;
  font-weight: 600;
  color: #ffffff;
  margin-top: 1px;
  letter-spacing: 0.1px;
  line-height: 1.2;
}

.node-power {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  margin-top: 1px;
  white-space: nowrap;
}

.node-power.solar-color { color: #10b981; }
.node-power.solar-color.solar-inactive { color: #64748b !important; }
.node-power.inverter-color { color: #60a5fa; }
.node-power.load-color { color: #fbbf24; }
.node-power.grid-color { color: #06b6d4; }
.node-power.grid-import-color { color: #c084fc; }

.node-current {
  font-family: var(--font-mono);
  font-size: 7px;
  font-weight: 600;
  line-height: 1.1;
  margin-top: 1px;
  opacity: 0.7;
  white-space: nowrap;
}

.node-current.inverter-color { color: #60a5fa; }
.node-current.load-color { color: #fbbf24; }
.node-current.grid-color { color: #06b6d4; }
.node-current.grid-import-color { color: #c084fc; }

/* ==========================================================================
   BOTTOM SUMMARY METRICS (3 COLUMNS MATCHING USER'S SCREENSHOTS)
   ========================================================================== */
.flow-summary-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 6px 4px 2px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.flow-sum-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.flow-sum-label {
  font-size: 10.5px;
  color: #94a3b8;
  font-weight: 500;
  letter-spacing: 0.2px;
  margin-bottom: 1px;
}

.flow-sum-val {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.flow-sum-val.solar-color {
  color: #10b981;
  transition: color 0.3s ease;
}
.flow-sum-val.solar-color.solar-inactive {
  color: #64748b !important;
}

.flow-sum-val.load-color {
  color: #fbbf24;
}

.flow-sum-val.grid-color {
  color: #06b6d4;
  transition: color 0.3s ease;
}

.flow-sum-val.grid-import-color {
  color: #c084fc;
}

/* Live Grid Import must be unmistakably red across the complete Energy Flow. */
.flow-node-card.node-grid.grid-import-red {
  border-color: #ef4444 !important;
  color: #ef4444 !important;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4), inset 0 0 12px rgba(239, 68, 68, 0.2) !important;
}
.grid-import-red-text,
.node-power.grid-import-red-text,
.flow-sum-val.grid-import-red-text,
.grid-import-arrow-red { color: #ef4444 !important; }
.flow-conduit-badge.badge-grid.grid-import-red-badge {
  color: #f87171 !important;
  border-color: rgba(239, 68, 68, 0.75) !important;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.25) !important;
}

/* ==========================================================================
   ENERGY FLOW EXPANDED MODAL (Cinematic 16:9 Presentation)
   ========================================================================== */
.modal-flow-dialog-box {
  max-width: 980px;
  width: 94vw;
}

.modal-flow-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-flow-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 12px;
}

.modal-flow-presets {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-flow-preset {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-flow-preset:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.btn-flow-preset.active {
  background: rgba(var(--accent-rgb), 0.2);
  border-color: var(--accent-color);
  color: #ffffff;
  box-shadow: 0 0 12px var(--accent-glow-subtle);
}

.dot-export {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #06b6d4;
  box-shadow: 0 0 6px #06b6d4;
}

.dot-import {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c084fc;
  box-shadow: 0 0 6px #c084fc;
}

.modal-flow-speed-tag {
  font-size: 11px;
  color: #64748b;
  font-family: var(--font-mono);
}

.energy-flow-stage.modal-stage {
  height: 380px;
}

.modal-stage .flow-node-card {
  min-width: 140px;
  padding: 14px 16px;
  border-radius: 16px;
}

.modal-stage .flow-node-card.node-solar {
  left: 30px;
}

.modal-stage .flow-node-card.node-inverter {
  left: 45%;
}

.modal-stage .flow-node-card.node-load {
  right: 30px;
  top: 14%;
}

.modal-stage .flow-node-card.node-grid {
  right: 30px;
  bottom: 12%;
}

.modal-stage .node-title {
  font-size: 14px;
  margin-top: 4px;
}

.modal-stage .node-power {
  font-size: 15px;
  margin-top: 2px;
}

.modal-stage .node-current {
  font-size: 11px;
}

.modal-stage .flow-conduit-badge {
  font-size: 12px;
  padding: 4px 14px;
}

.flow-summary-metrics.modal-summary {
  padding: 12px 10px 6px 10px;
}

.modal-summary .flow-sum-label {
  font-size: 13px;
  margin-bottom: 3px;
}

.modal-summary .flow-sum-val {
  font-size: 22px;
}

/* Bottom Split: PV DC Details & System Status */
.flow-details-split {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 12px;
  border-top: 1px solid #141f30;
  padding-top: 10px;
}

.pv-dc-box, .system-status-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.section-mini-heading {
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.pv-dc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  padding: 3px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

.pv-name {
  color: var(--accent-color, #f59e0b);
  font-weight: 700;
  width: 38px;
}

.pv-volt {
  font-family: var(--font-mono);
  color: #ffffff;
  font-weight: 600;
  min-width: 58px;
  text-align: right;
}

.pv-curr {
  font-family: var(--font-mono);
  color: #94a3b8;
  font-weight: 500;
  min-width: 52px;
  text-align: right;
}

.pv-power-badge {
  font-family: var(--font-mono);
  color: #10b981;
  font-weight: 700;
  min-width: 55px;
  text-align: right;
}

/* System Status Items */
.status-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  padding: 2px 0;
}

.status-label-group {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #94a3b8;
}

.status-dot-hollow {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--color-online);
  box-shadow: 0 0 5px var(--color-online);
}

.status-value-text {
  font-weight: 600;
  color: #94a3b8;
}

.status-value-text.online {
  color: #94a3b8;
}

/* --------------------------------------------------------------------------
   MODALS (SETTINGS, PHOTO CHANGER, HISTORY & EXPORT)
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(3, 7, 14, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal-backdrop.open {
  display: flex;
  opacity: 1;
}

.modal-window {
  width: 760px;
  max-width: 90%;
  max-height: 85%;
  background: #0d1522;
  border: 1px solid #1f2f45;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(var(--accent-rgb), 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-pop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-pop {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 16px 22px;
  background: #090f1a;
  border-bottom: 1px solid #1a273b;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title-group svg {
  width: 20px;
  height: 20px;
  color: var(--accent-color);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
}

.modal-close-btn {
  background: none;
  border: none;
  color: #64748b;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.modal-close-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  max-height: 600px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 3px;
}

.modal-footer {
  padding: 14px 22px;
  background: #090f1a;
  border-top: 1px solid #1a273b;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* Form Groups & Inputs */
.form-section {
  background: rgba(16, 26, 42, 0.5);
  border: 1px solid #162438;
  border-radius: 10px;
  padding: 16px;
}

.form-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-color);
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
}

.form-input, .form-select {
  background: #090f19;
  border: 1px solid #1f2e45;
  border-radius: 6px;
  padding: 8px 12px;
  color: #ffffff;
  font-family: var(--font-main);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus, .form-select:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px var(--accent-glow-subtle);
}

.form-hint {
  font-size: 10px;
  color: #64748b;
}

/* Action Buttons */
.btn-primary {
  background: var(--accent-gradient);
  color: #ffffff;
  border: none;
  padding: 8px 18px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 10px var(--accent-glow);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
  border: 1px solid #1f2f45;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

/* Photo Selector Presets Grid */
.photo-presets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.preset-card {
  border: 2px solid #1a273b;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  height: 140px;
  transition: all 0.2s ease;
}

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

.preset-card.active {
  border-color: var(--accent-color);
  box-shadow: 0 0 12px var(--accent-glow);
}

.preset-card-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(9, 15, 26, 0.85);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  color: #ffffff;
}

/* History Data Table */
.data-table-wrapper {
  overflow-x: auto;
  border: 1px solid #1a273b;
  border-radius: 8px;
  max-height: 380px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  text-align: left;
}

.history-table th {
  background: #090f19;
  color: #7b8ea6;
  font-weight: 700;
  padding: 8px 12px;
  border-bottom: 1px solid #1f2e45;
  position: sticky;
  top: 0;
  z-index: 10;
}

.history-table td {
  padding: 7px 12px;
  border-bottom: 1px solid #121c2b;
  color: #cbd5e1;
  font-family: var(--font-mono);
}

.history-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-msg {
  background: #0e1726;
  border: 1px solid var(--accent-color);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
  padding: 10px 16px;
  border-radius: 8px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-slide 0.3s ease;
  pointer-events: auto;
}

@keyframes toast-slide {
  from { transform: translateX(50px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* --------------------------------------------------------------------------
   MODAL TABS, TARIFF HISTORY & PERFORMANCE EXTENSIONS
   -------------------------------------------------------------------------- */
.modal-tab-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #080d17;
  padding: 6px 14px;
  border-bottom: 1px solid #162438;
}

.modal-tab-btn {
  background: none;
  border: none;
  color: #7b8ea6;
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-tab-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.modal-tab-btn.active {
  color: #ffffff;
  background: var(--accent-glow-subtle);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  box-shadow: 0 0 10px var(--accent-glow-subtle);
}

/* Tariff Period Pill Badges */
.tariff-active-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
}

.tariff-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(16, 26, 42, 0.6);
  border: 1px solid #1a273b;
  border-radius: 8px;
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

.tariff-history-item:hover {
  border-color: #2b3d58;
  background: rgba(16, 26, 42, 0.9);
}

.tariff-history-item.is-current {
  border-left: 3px solid var(--accent-color);
  background: rgba(var(--accent-rgb), 0.06);
}

/* 3-Phase AC Grid */
.phase-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.phase-card {
  background: rgba(10, 16, 26, 0.7);
  border: 1px solid #1a273b;
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.phase-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.phase-val-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
}

.phase-val-label {
  color: #7b8ea6;
}

.phase-val-num {
  font-family: var(--font-mono);
  font-weight: 700;
  color: #ffffff;
}

/* Performance String Grid (2 Strings) */
.string-perf-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.string-perf-card {
  background: rgba(10, 16, 26, 0.7);
  border: 1px solid #1a273b;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ==========================================================================
   HISTORICAL REPLAY MODE BANNER & SCRUBBER
   ========================================================================== */
.historical-banner {
  position: sticky;
  top: 0;
  z-index: 50;
  margin-bottom: 12px;
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.18) 0%, rgba(15, 23, 42, 0.95) 30%, rgba(15, 23, 42, 0.95) 70%, rgba(239, 68, 68, 0.18) 100%);
  border: 1px solid rgba(239, 68, 68, 0.5);
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  backdrop-filter: blur(8px);
  animation: bannerGlow 2.5s infinite alternate ease-in-out;
}

@keyframes bannerGlow {
  0% { border-color: rgba(239, 68, 68, 0.4); box-shadow: 0 4px 15px rgba(239, 68, 68, 0.15); }
  100% { border-color: rgba(239, 68, 68, 0.85); box-shadow: 0 4px 25px rgba(239, 68, 68, 0.35); }
}

.hist-banner-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  gap: 16px;
  flex-wrap: wrap;
}

.hist-banner-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hist-pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 12px #ef4444;
  animation: histPulse 1.2s infinite ease-in-out;
}

@keyframes histPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.6; }
}

.hist-banner-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(239, 68, 68, 0.25);
  border: 1px solid #ef4444;
  color: #fca5a5;
  text-transform: uppercase;
}

.hist-banner-text {
  font-size: 13px;
  font-weight: 600;
  color: #f1f5f9;
}

.hist-scrubber-box {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  max-width: 480px;
  background: rgba(0, 0, 0, 0.4);
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hist-scrubber-label {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  white-space: nowrap;
}

.hist-slider {
  flex: 1;
  accent-color: var(--accent-color);
  cursor: pointer;
  height: 6px;
}

.hist-time-display {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: #38bdf8;
  min-width: 48px;
  text-align: right;
}

.hist-exit-btn {
  padding: 6px 14px !important;
  font-size: 12px !important;
  background: rgba(239, 68, 68, 0.8) !important;
  border: 1px solid #ef4444 !important;
  color: #fff !important;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
  white-space: nowrap;
}

.hist-exit-btn:hover {
  background: #dc2626 !important;
}

/* Quick Preset Chips */
.quick-preset-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.preset-chip {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid #334155;
  border-radius: 4px;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-chip:hover, .preset-chip.active {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: #fff;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ==========================================================================
   REVENUE & SAVINGS / RAW VS CALCULATED ARCHITECTURE
   ========================================================================== */
.rev-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.rev-kpi-card {
  background: linear-gradient(145deg, rgba(16, 26, 42, 0.85) 0%, rgba(10, 16, 26, 0.95) 100%);
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

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

.rev-kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-gradient);
}

.rev-kpi-period {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--accent-color);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.rev-kpi-gen {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 6px;
}

.rev-kpi-gen-num {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: #10b981;
}

.rev-kpi-gen-unit {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
}

.rev-kpi-val-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.rev-kpi-baht-num {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 800;
  color: #f59e0b;
}

.rev-kpi-baht-unit {
  font-size: 13px;
  font-weight: 700;
  color: #f59e0b;
}

.rev-kpi-sub {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 4px;
}

/* Raw Data vs Calculated Architecture Comparison */
.raw-calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.raw-box {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid #1e3a5f;
  border-radius: 8px;
  padding: 14px;
}

.calc-box {
  background: rgba(20, 24, 38, 0.7);
  border: 1px solid #4a2e12;
  border-radius: 8px;
  padding: 14px;
}

.raw-calc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.raw-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  background: rgba(56, 189, 248, 0.2);
  border: 1px solid #38bdf8;
  color: #7dd3fc;
  padding: 2px 6px;
  border-radius: 4px;
}

.calc-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid #f59e0b;
  color: #fcd34d;
  padding: 2px 6px;
  border-radius: 4px;
}

.raw-calc-title {
  font-size: 12px;
  font-weight: 700;
  color: #f8fafc;
}

.metric-pill-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.metric-pill-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.25);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
}

.metric-pill-name {
  color: #94a3b8;
}

.metric-pill-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: #ffffff;
}

/* ==========================================================================
   REPORT & DOWNLOAD CENTER CARDS
   ========================================================================== */
.report-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.report-download-card {
  background: linear-gradient(180deg, rgba(16, 26, 42, 0.9) 0%, rgba(10, 16, 26, 0.95) 100%);
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.report-download-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-color);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), 0 0 15px var(--accent-glow-subtle);
}

.report-dl-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--accent-color);
}

.report-dl-title {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
}

.report-dl-desc {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.4;
  flex: 1;
}

.report-dl-btn {
  width: 100%;
  margin-top: 4px;
}

/* ==========================================================================
   ODOMETER (ROLLING UPWARD NUMBERS) EFFECT
   ========================================================================== */
.odometer-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: inherit;
  white-space: nowrap;
  vertical-align: baseline;
  line-height: 1;
}

.odometer-slot {
  display: inline-flex;
  flex-direction: column;
  overflow: hidden;
  height: 1em;
  line-height: 1em;
  position: relative;
  text-align: center;
  font-variant-numeric: tabular-nums;
  justify-content: flex-start;
  min-width: 0.56em;
  vertical-align: baseline;
}

.odometer-strip {
  display: inline-flex;
  flex-direction: column;
  line-height: 1em;
  will-change: transform;
}

.odometer-frame {
  display: block;
  height: 1em;
  line-height: 1em;
  text-align: center;
  font: inherit;
  color: inherit;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.odometer-static {
  display: inline-block;
  line-height: 1em;
  font: inherit;
  color: inherit;
  white-space: pre;
}

/* ==========================================================================
   BOTTOM TICKER ANNOUNCEMENT BANNER (ตัวหนังสือวิ่งประชาสัมพันธ์)
   ========================================================================== */
.bottom-ticker-banner {
  display: none;
  width: 100%;
  height: var(--ticker-height);
  min-height: var(--ticker-height);
  max-height: var(--ticker-height);
  background-color: #f1f5f9; /* White-light-grayish (ขาวอมเทาอ่อนๆ) */
  border-top: 1.5px solid #cbd5e1;
  overflow: hidden;
  align-items: center;
  position: relative;
  z-index: 80;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.25);
  user-select: none;
}

#dashboard-scaler.has-ticker .bottom-ticker-banner {
  display: flex;
}

#dashboard-scaler.has-ticker .main-content {
  height: 100%;
  min-height: 0;
  padding: 10px 18px 0 18px;
  gap: 12px;
}

#dashboard-scaler.has-ticker .col-power-metrics {
  gap: 6px;
  padding-bottom: 4px;
  min-height: 0;
  height: 100%;
}

#dashboard-scaler.has-ticker .col-middle-center {
  gap: 6px;
  min-height: 0;
  height: 100%;
}

#dashboard-scaler.has-ticker .col-right-site {
  gap: 8px;
  min-height: 0;
  height: 100%;
}

/*
 * Ticker ON allocation for the fixed 1920x1080 canvas.
 * Reclaim vertical room from upper presentation areas so the bottom data
 * regions remain wholly inside the reserved dashboard viewport. No scaling,
 * transforms or overlay positioning are used.
 */
#dashboard-scaler.has-ticker .col-power-metrics > .power-card:not(.sun-path-card) {
  flex: 0.62;
}

#dashboard-scaler.has-ticker .power-card.sun-path-card {
  flex: 2.05;
  margin-bottom: 0;
}

#dashboard-scaler.has-ticker .chart-card {
  height: 245px;
  min-height: 235px;
}

#dashboard-scaler.has-ticker .grid-meter-card {
  min-height: 205px;
}

#dashboard-scaler.has-ticker .rooftop-image-card {
  min-height: 260px;
}

#dashboard-scaler.has-ticker .environmental-card {
  padding-block: 10px;
}

#dashboard-scaler.has-ticker .environmental-card .env-header {
  margin-bottom: 8px;
}

#dashboard-scaler.has-ticker .energy-flow-card {
  min-height: 520px;
}

.ticker-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #e2e8f0;
  color: #000000;
  border-right: 1.5px solid #cbd5e1;
  padding: 0 10px;
  height: 100%;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.3px;
  z-index: 2;
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.08);
}

.ticker-badge-icon {
  font-size: 13px;
  display: flex;
  align-items: center;
}

.ticker-viewport {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  display: flex;
  align-items: center;
  position: relative;
  height: 100%;
  pointer-events: none;
}

.ticker-track {
  display: flex;
  align-items: center;
  width: max-content;
  position: absolute;
  left: 0;
  top: 50%;
  will-change: transform;
  transform: translate3d(0, -50%, 0);
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  animation: none;
}

.ticker-track.ticker-motion-ready {
  animation: tickerScroll var(--ticker-duration, 40s) linear infinite;
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  white-space: nowrap;
}

@keyframes tickerScroll {
  0% {
    transform: translate3d(0, -50%, 0);
  }
  100% {
    transform: translate3d(-50%, -50%, 0);
  }
}

.ticker-phrase {
  font-family: 'Prompt', 'Kanit', 'Outfit', sans-serif;
  font-size: var(--ticker-font-size); /* 19px: same size as today price */
  font-weight: 700;
  line-height: 1.2;
  color: #000000; /* Solid Black (ตัวหนังสือสีดำ) */
  letter-spacing: 0.2px;
  padding: 0 20px;
  display: inline-block;
  white-space: nowrap;
}

.ticker-separator {
  color: #f59e0b;
  font-size: 13px;
  padding: 0 6px;
  display: inline-block;
  vertical-align: middle;
}

/* Header Quick Toggle Button active glow */
#btn-toggle-ticker.active {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.6);
  background: rgba(16, 185, 129, 0.15);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}
