/* ============================================================
   Mezura CCP theme. Mirrors the Mezura EPC Portal design system.
   Primary green #1EE600, accent green #20cb26, dark navy #2A3450,
   Rajdhani headings. Do not introduce new colours or fonts here.
   ============================================================ */

:root {
  --green: #1ee600;
  --green-accent: #20cb26;
  --green-tint: rgba(30, 230, 0, 0.12);
  --green-tint-strong: rgba(30, 230, 0, 0.18);

  --navy: #2a3450;
  --navy-deep: #222a40;
  --navy-soft: #38426180;

  --ink: #1b2230;
  --muted: #6b7689;
  --bg: #eef1f6;
  --card: #ffffff;
  --border: #e3e8f0;
  --border-strong: #cdd5e2;

  --danger: #d6324a;
  --danger-tint: #fdecef;
  --warn: #c77700;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.06), 0 8px 24px rgba(20, 30, 60, 0.06);
  --shadow-sm: 0 1px 2px rgba(20, 30, 60, 0.08);

  --sidebar-w: 248px;
  --font-head: 'Rajdhani', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-head);
  letter-spacing: 0.2px;
  color: var(--navy);
  margin: 0;
}

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

/* ---------- Brand ---------- */
.brand,
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--green);
  color: var(--navy-deep);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 22px;
  box-shadow: 0 4px 14px rgba(30, 230, 0, 0.35);
}

.brand-text {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 1.5px;
  color: #fff;
  line-height: 1;
}

.brand-text small {
  display: block;
  font-size: 11px;
  letter-spacing: 3px;
  font-weight: 600;
  color: var(--green);
  margin-top: 2px;
}

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  z-index: 40;
}

.sidebar .brand {
  padding: 4px 8px 22px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: #b9c2d6;
  font-weight: 500;
  font-size: 14.5px;
  position: relative;
  transition: background 0.15s, color 0.15s;
}

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

.nav-item:hover {
  background: var(--navy-soft);
  color: #fff;
}

.nav-item.active {
  background: var(--green-tint-strong);
  color: #fff;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--green);
}

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

.sidebar-foot {
  margin-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 16px;
}

.client-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
}

.client-name {
  color: #fff;
  font-weight: 600;
  font-size: 13.5px;
}

/* ---------- Main column ---------- */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 64px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  width: 38px;
  height: 38px;
  cursor: pointer;
  color: var(--navy);
  align-items: center;
  justify-content: center;
}

.menu-btn svg {
  width: 20px;
  height: 20px;
}

.scope {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.scope-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.scope-value {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 17px;
  color: var(--navy);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ---------- Global context selector ---------- */
.ctx-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ctx-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}

.ctx-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.ctx-select-wrap svg {
  position: absolute;
  right: 10px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}

.ctx-select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 34px 9px 14px;
  min-width: 190px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ctx-select-wrap select:hover {
  border-color: var(--green-accent);
}

.ctx-select-wrap select:focus {
  outline: none;
  border-color: var(--green-accent);
  box-shadow: 0 0 0 3px var(--green-tint);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.5px;
}

.user-email {
  font-size: 13px;
  color: var(--muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Content ---------- */
.content {
  padding: 28px;
  max-width: 1280px;
  width: 100%;
}

.page-head {
  margin-bottom: 22px;
}

.page-head h1 {
  font-size: 30px;
  font-weight: 700;
}

.page-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14.5px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--border-strong);
}

.stat-card.stat-accent::after {
  background: var(--green);
}

.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}

.stat-value {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 28px;
  color: var(--navy);
  line-height: 1.1;
}

.stat-sub {
  font-size: 12.5px;
  color: var(--muted);
}

.placeholder-card {
  border-style: dashed;
  border-color: var(--border-strong);
  background: linear-gradient(180deg, #fff, #fbfcfe);
}

.placeholder-inner h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.placeholder-inner p {
  color: var(--muted);
  max-width: 640px;
  margin: 0 0 14px;
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 56px 28px;
}

.empty-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 16px;
  background: var(--green-tint);
  color: var(--green-accent);
}

.empty-mark svg {
  width: 30px;
  height: 30px;
}

.empty-state h2 {
  font-size: 22px;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--muted);
  max-width: 520px;
  margin: 0 auto 16px;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  padding: 4px 10px;
  border-radius: 999px;
}

.badge-green {
  background: var(--green-tint);
  color: #117a00;
}

.badge-muted {
  background: #eef1f6;
  color: var(--muted);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14.5px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--green);
  color: var(--navy-deep);
  cursor: pointer;
  transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
}

.btn:hover {
  background: var(--green-accent);
  color: #fff;
}

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

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--green-tint);
}

.btn-outline {
  background: #fff;
  color: var(--navy);
  border-color: var(--border-strong);
}

.btn-outline:hover {
  background: #fff;
  color: var(--green-accent);
  border-color: var(--green-accent);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13.5px;
}

.btn-block {
  width: 100%;
}

/* ---------- Tables ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table thead th {
  text-align: left;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  padding: 12px 14px;
  border-bottom: 2px solid var(--border);
}

.table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.table tbody tr:hover {
  background: #f8fafc;
}

/* ---------- Forms ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field span {
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
}

.field input {
  font-family: var(--font-body);
  font-size: 15px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  outline: none;
  border-color: var(--green-accent);
  box-shadow: 0 0 0 3px var(--green-tint);
}

/* ---------- Alerts ---------- */
.alert {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  margin-bottom: 18px;
}

.alert-error {
  background: var(--danger-tint);
  color: var(--danger);
  border: 1px solid #f3c6ce;
}

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(1200px 600px at 70% -10%, #34406180, transparent),
    linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  padding: 24px;
}

.login-wrap {
  width: 100%;
  max-width: 420px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(10, 16, 36, 0.45);
  padding: 34px 32px 30px;
}

.login-brand {
  justify-content: center;
  margin-bottom: 22px;
}

.login-brand .brand-text {
  color: var(--navy);
}

.login-title {
  text-align: center;
  font-size: 23px;
  font-weight: 700;
}

.login-sub {
  text-align: center;
  color: var(--muted);
  margin: 6px 0 22px;
  font-size: 14px;
}

.login-form {
  margin-top: 4px;
}

.login-foot {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin: 18px 0 0;
}

.login-copyright {
  text-align: center;
  color: #aeb8cf;
  font-size: 12px;
  margin-top: 18px;
}

/* ---------- Scrim (mobile nav) ---------- */
.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 38, 0.5);
  z-index: 35;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.25);
  }

  .app.nav-open .sidebar {
    transform: translateX(0);
  }

  .app.nav-open .scrim {
    display: block;
  }

  .main {
    margin-left: 0;
  }

  .menu-btn {
    display: inline-flex;
  }

  .ctx-label,
  .user-email {
    display: none;
  }

  .ctx-select-wrap select {
    min-width: 150px;
  }
}

/* ============================================================
   Portfolio Command Center (dashboard page 1)
   ============================================================ */

:root {
  --amber: #f5a623;
  --red: #d6324a;
  --green-text: #0f8a00;
}

.section {
  margin-bottom: 28px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.section-head h2 {
  font-size: 20px;
  font-weight: 700;
}

.section-note {
  color: var(--muted);
  font-size: 12.5px;
}

.stat-grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

/* ---------- Card heads ---------- */
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.card-head h3 {
  font-size: 16px;
  font-weight: 600;
}

.card-sub {
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- Layout grids ---------- */
.grid-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

/* ---------- SVG charts ---------- */
.chart {
  width: 100%;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.ch-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.ch-ylabel,
.ch-xlabel {
  fill: var(--muted);
  font-size: 11px;
  font-family: var(--font-body);
}

.ch-unit {
  fill: var(--muted);
  font-size: 10px;
}

.ch-legend {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.ch-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink);
}

.ch-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

/* ---------- Radial gauge ---------- */
.gauge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.gauge-svg {
  width: 150px;
  height: 150px;
}

.gauge-track {
  fill: none;
  stroke: var(--border);
  stroke-width: 12;
}

.gauge-value {
  fill: none;
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dasharray 0.4s ease;
}

.gauge-center {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 30px;
  fill: var(--navy);
}

.gauge-caption {
  color: var(--muted);
  font-size: 12.5px;
}

.mini-stats {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  width: 100%;
}

.mini-stat {
  flex: 1;
  background: #f7f9fc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
}

.mini-value {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 18px;
  color: var(--navy);
}

.mini-label {
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ---------- Proportion bars ---------- */
.pbar {
  margin-top: 6px;
}

.pbar-track {
  display: flex;
  height: 16px;
  border-radius: 999px;
  overflow: hidden;
  background: #eef1f6;
}

.pbar-seg {
  height: 100%;
  display: block;
}

.pbar-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.pbar-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
}

.pbar-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

.pbar-legend-label {
  color: var(--ink);
}

.pbar-legend-value {
  margin-left: auto;
  font-weight: 600;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

/* ---------- Yield figure ---------- */
.yield-figure {
  margin-bottom: 12px;
}

.yield-value {
  display: block;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 32px;
  color: var(--green-text);
  line-height: 1.1;
}

.yield-caption {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 4px;
}

/* ---------- Map ---------- */
.map-card {
  padding: 0;
  overflow: hidden;
}

.map-head {
  padding: 18px 22px 14px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
}

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

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

.health-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
  box-shadow: 0 0 0 3px rgba(20, 30, 60, 0.05);
}

.map-layout {
  display: flex;
  min-height: 460px;
}

/* isolate Leaflet's internal z-index stack so it never paints over the topbar */
.site-map {
  flex: 1;
  min-height: 460px;
  position: relative;
  z-index: 0;
  isolation: isolate;
  background: #e9eef4;
}

.site-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  width: 300px;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  max-height: 520px;
}

.site-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border-radius: var(--radius-sm);
}

.site-row:hover {
  background: #f7f9fc;
}

.site-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.site-row-name {
  font-weight: 600;
  color: var(--navy);
  font-size: 14px;
}

.site-row-meta {
  color: var(--muted);
  font-size: 12px;
}

.site-row .health-dot {
  margin-top: 5px;
}

/* ---------- Map pins (Leaflet divIcon) ---------- */
.map-pin-wrap {
  background: none;
  border: none;
}

.map-pin {
  position: relative;
  display: block;
  width: 22px;
  height: 22px;
}

.map-pin-dot {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--pin);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.map-pin-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--pin);
  opacity: 0.3;
}

.map-pin-healthy .map-pin-ring {
  animation: pingpulse 1.8s ease-out infinite;
}

.map-pin-stale .map-pin-ring {
  opacity: 0.25;
}

.map-pin-offline .map-pin-ring {
  opacity: 0.18;
}

@keyframes pingpulse {
  0% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  70% {
    transform: scale(1.7);
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}

/* ---------- Leaflet popup theming ---------- */
.leaflet-popup-content-wrapper {
  border-radius: 10px;
}

.map-popup {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-family: var(--font-body);
}

.map-popup strong {
  font-family: var(--font-head);
  font-size: 15px;
  color: var(--navy);
}

.mp-status {
  font-weight: 600;
  font-size: 12.5px;
}

.map-popup span {
  font-size: 12.5px;
  color: var(--muted);
}

@media (max-width: 980px) {
  .grid-2-1,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .map-layout {
    flex-direction: column;
  }

  .site-list {
    width: auto;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 260px;
  }

  .site-map {
    min-height: 360px;
  }
}

/* ============================================================
   Live Sites & UMS Telemetry (dashboard page 2)
   ============================================================ */

.feed-head {
  align-items: center;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--green-text);
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(30, 230, 0, 0.5);
  animation: livepulse 1.4s ease-out infinite;
}

@keyframes livepulse {
  0% {
    box-shadow: 0 0 0 0 rgba(30, 230, 0, 0.5);
  }
  70% {
    box-shadow: 0 0 0 9px rgba(30, 230, 0, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(30, 230, 0, 0);
  }
}

.live-readouts {
  display: flex;
  gap: 26px;
}

.readout {
  display: flex;
  flex-direction: column;
  text-align: right;
}

.readout-value {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.readout-value.load {
  color: var(--navy);
}

.readout-value.solar {
  color: var(--green-text);
}

.readout-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.live-chart {
  width: 100%;
  min-height: 200px;
}

.live-chart .chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

/* ---------- Per-facility split tiles ---------- */
.facility-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.facility-tile {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: #fbfcfe;
}

.facility-tile h4 {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 14.5px;
  color: var(--navy);
  margin: 0 0 10px;
}

.ft-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 0;
}

.ft-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
}

.ft-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.ft-dot.load {
  background: var(--navy);
}

.ft-dot.solar {
  background: var(--green);
}

.ft-value {
  font-weight: 600;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
}

/* ---------- Prepaid balance vault ---------- */
.vault-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: linear-gradient(155deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff;
  border: none;
}

.vault-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.vault-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--green-tint-strong);
  color: var(--green);
}

.vault-icon svg {
  width: 18px;
  height: 18px;
}

.vault-card .card-sub {
  color: #b9c2d6;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-size: 11.5px;
}

.vault-balance {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 42px;
  line-height: 1.05;
  color: #fff;
}

.vault-kwh {
  font-size: 14px;
  color: var(--green);
  font-weight: 600;
}

/* ---------- Depletion ---------- */
.depletion-grid {
  display: flex;
  gap: 14px;
}

.depletion-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: #f7f9fc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.depletion-value {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 26px;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.depletion-unit {
  font-size: 12px;
  color: var(--muted);
}

.depletion-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.runway {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
  padding: 11px 14px;
  background: var(--green-tint);
  border-radius: var(--radius-sm);
}

.runway-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green-accent);
  flex: none;
}

.runway-text {
  font-weight: 600;
  color: var(--green-text);
  font-size: 13.5px;
}

/* ---------- Ledger table ---------- */
.ledger-card {
  margin-bottom: 16px;
}

.table td.num,
.table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ledger-table tfoot td {
  font-weight: 700;
  color: var(--navy);
  border-top: 2px solid var(--border);
  border-bottom: none;
}

.muted-note {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 16px;
}

@media (max-width: 620px) {
  .live-readouts {
    gap: 16px;
  }
  .depletion-grid {
    flex-direction: column;
  }
}

/* ============================================================
   The Power Purchase Engine (dashboard page 3)
   ============================================================ */

.alert-success {
  background: var(--green-tint);
  color: var(--green-text);
  border: 1px solid #a8e89a;
}

/* ---------- Balance bar ---------- */
.balance-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 16px 22px;
}

.bb-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 14px;
}

.bb-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
}

.bb-value {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 22px;
  color: var(--navy);
}

.bb-divider {
  width: 1px;
  align-self: stretch;
  background: var(--border);
}

/* ---------- Purchase forms ---------- */
.purchase-form {
  display: flex;
  flex-direction: column;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  margin: 4px 0 8px;
}

.input-prefix,
.input-suffix {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  overflow: hidden;
}

.input-prefix:focus-within,
.input-suffix:focus-within {
  border-color: var(--green-accent);
  box-shadow: 0 0 0 3px var(--green-tint);
}

.input-prefix .prefix,
.input-suffix .suffix {
  display: flex;
  align-items: center;
  align-self: stretch;
  padding: 0 13px;
  color: var(--muted);
  font-weight: 600;
  background: #f4f6fa;
}

.input-prefix input,
.input-suffix input {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  padding: 12px 14px;
  font-size: 15px;
  font-family: var(--font-body);
  color: var(--ink);
}

/* ---------- Chips ---------- */
.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 18px;
}

.chip {
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--navy);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: border-color 0.15s, color 0.15s;
}

.chip:hover {
  border-color: var(--green-accent);
  color: var(--green-accent);
}

/* ---------- Payment methods ---------- */
.methods {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.method {
  position: relative;
  cursor: pointer;
}

.method input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.method-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: border-color 0.15s, background 0.15s;
}

.method-name {
  font-weight: 600;
  color: var(--navy);
  font-size: 14px;
}

.method-note {
  font-size: 12px;
  color: var(--muted);
}

.method input:checked + .method-body {
  border-color: var(--green);
  background: var(--green-tint);
}

.method input:focus-visible + .method-body {
  box-shadow: 0 0 0 3px var(--green-tint);
}

/* ---------- Conversion / notes ---------- */
.conversion {
  background: #f7f9fc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--muted);
  margin-bottom: 16px;
}

.conversion strong {
  color: var(--navy);
}

.form-note {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin: 12px 0 0;
}

/* ---------- Dynamic tariff ---------- */
.tariff-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 18px;
  background: linear-gradient(120deg, #f4fdf0, #f4f6fa);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
}

.tariff-now {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tariff-value {
  font-family: var(--font-head);
  font-size: 15px;
  color: var(--muted);
}

.tariff-value strong {
  font-size: 30px;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.tariff-spark {
  width: 240px;
  max-width: 45%;
}

.spark {
  width: 100%;
  height: 46px;
  display: block;
}

/* ---------- Ledger amounts ---------- */
.amount-pos {
  color: var(--green-text);
  font-weight: 600;
}

.amount-neg {
  color: var(--danger);
  font-weight: 600;
}

@media (max-width: 520px) {
  .methods {
    grid-template-columns: 1fr;
  }
  .tariff-spark {
    max-width: 100%;
    width: 100%;
  }
}

/* ============================================================
   New Projects & Onboarding (dashboard page 4)
   ============================================================ */

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

.badge-amber {
  background: #fdf0d9;
  color: var(--warn);
}

/* ---------- Site canvas wizard ---------- */
.add-site-btn {
  font-size: 15px;
}

.wizard {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

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

.canvas-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 10px;
}

.canvas-hint {
  font-size: 13px;
  color: var(--muted);
}

.canvas-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.roof-count {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy);
}

.site-canvas {
  height: 420px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  z-index: 0;
  isolation: isolate;
  border: 1px solid var(--border);
  background: #e9eef4;
}

.wizard-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* ---------- Onboarding pipeline ---------- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.project-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  transition: box-shadow 0.15s, transform 0.05s, border-color 0.15s;
}

.project-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--green-accent);
}

.project-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.project-card-head h3 {
  font-size: 16px;
  font-weight: 600;
}

.project-card-addr {
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 14px;
}

.doc-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.doc-progress-track {
  height: 8px;
  border-radius: 999px;
  background: #eef1f6;
  overflow: hidden;
}

.doc-progress-track span {
  display: block;
  height: 100%;
  background: var(--green);
}

.doc-progress-label {
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Detail header ---------- */
.detail-top {
  margin-bottom: 6px;
}

.back-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.back-link:hover {
  color: var(--green-accent);
}

.detail-stage {
  margin: -8px 0 16px;
}

/* ---------- Document locker ---------- */
.dropbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.dropbox {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}

.dropbox[data-state='uploaded'] {
  border-left-color: var(--green);
}

.dropbox[data-state='locked'] {
  border-left-color: var(--navy);
  background: #f7f9fc;
}

.dropbox-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.dropbox-num {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 14px;
  flex: none;
}

.dropbox[data-state='uploaded'] .dropbox-num,
.dropbox[data-state='locked'] .dropbox-num {
  background: var(--green);
  color: var(--navy-deep);
}

.dropbox-title {
  flex: 1;
}

.dropbox-title h4 {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 14.5px;
  color: var(--navy);
  margin: 0;
}

.dropbox-title p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.dropbox-status {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  flex: none;
}

.dropbox[data-state='uploaded'] .dropbox-status {
  color: var(--green-text);
}

.dropbox[data-state='locked'] .dropbox-status {
  color: var(--navy);
}

.dropbox-files {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.doc-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #f4f6fa;
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 12.5px;
}

.doc-file-name {
  color: var(--navy);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-file-tag {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  flex: none;
}

.dropbox-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  padding: 20px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.dropbox-drop svg {
  width: 22px;
  height: 22px;
}

.dropbox-drop:hover,
.dropbox-drop.drag {
  border-color: var(--green-accent);
  color: var(--green-accent);
  background: var(--green-tint);
}

/* ---------- EPC trigger ---------- */
.trigger-card {
  text-align: center;
}

.btn-request {
  width: 100%;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1.2px;
  padding: 16px;
}

.trigger-form .form-note {
  margin-top: 12px;
}

.trigger-done {
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
}

.trigger-done-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--green-tint);
  color: var(--green-text);
  flex: none;
}

.trigger-done-icon svg {
  width: 26px;
  height: 26px;
}

.trigger-done h3 {
  font-size: 17px;
  margin: 0 0 2px;
}

.trigger-done p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

@media (max-width: 760px) {
  .wizard-grid,
  .dropbox-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Financial Summary & Audit Ledger (dashboard page 5)
   ============================================================ */

.btn svg {
  width: 16px;
  height: 16px;
}

.export-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 16px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.export-title {
  display: block;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 18px;
  color: var(--navy);
}

.export-sub {
  font-size: 12.5px;
  color: var(--muted);
}

.export-actions {
  display: flex;
  gap: 10px;
}

.csv-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 3px 11px;
  transition: border-color 0.15s, color 0.15s;
}

.csv-link:hover {
  border-color: var(--green-accent);
  color: var(--green-accent);
}

.card-note {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 0 12px;
}

.table-scroll {
  overflow-x: auto;
}

.matrix-table th,
.matrix-table td {
  white-space: nowrap;
}

.source-tag {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.source-recon {
  background: var(--green-tint);
  color: var(--green-text);
}

.source-transaction {
  background: #eef1f6;
  color: var(--muted);
}

/* ============================================================
   Settings (dashboard page 6)
   ============================================================ */

.badge-red {
  background: var(--danger-tint);
  color: var(--danger);
}

.muted {
  color: var(--muted);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 10px 16px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}

.tab:hover {
  color: var(--navy);
}

.tab.active {
  color: var(--navy);
  border-bottom-color: var(--green);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ---------- User management ---------- */
.user-cell {
  display: flex;
  flex-direction: column;
}

.user-cell-name {
  font-weight: 600;
  color: var(--navy);
}

.user-cell-email {
  font-size: 12.5px;
  color: var(--muted);
}

.inline-form {
  display: inline;
  margin: 0;
}

.mini-select {
  font-family: var(--font-body);
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--navy);
  cursor: pointer;
}

.add-user-card {
  margin-bottom: 16px;
}

.add-user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.add-user-grid .field {
  margin-bottom: 0;
}

.readonly-banner {
  background: #eef1f6;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--muted);
  font-size: 13.5px;
  margin-bottom: 16px;
}

/* ---------- Profile ---------- */
.profile-grid,
.legal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.readonly-row {
  display: flex;
  gap: 28px;
  margin: 4px 0 18px;
}

.ro-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 5px;
}

.ro-value {
  font-weight: 600;
  color: var(--navy);
}

/* ---------- Legal panels ---------- */
.legal-panel {
  max-height: 440px;
  overflow-y: auto;
  padding-right: 10px;
}

.legal-panel h3 {
  font-size: 16px;
  margin: 0 0 4px;
}

.legal-panel h4 {
  font-size: 13.5px;
  color: var(--navy);
  margin: 16px 0 4px;
}

.legal-panel p {
  font-size: 13px;
  color: var(--ink);
  margin: 0 0 8px;
  line-height: 1.55;
}

.legal-panel .legal-meta {
  color: var(--muted);
  font-style: italic;
  font-size: 12px;
}

@media (max-width: 760px) {
  .profile-grid,
  .legal-grid {
    grid-template-columns: 1fr;
  }
}
