:root {
  --bg: #eef3ef;
  --ink: #10261e;
  --muted: #52635c;
  --accent: #0f766e;
  --accent-soft: #d6efe8;
  --accent-blue: #1d4ed8;
  --accent-amber: #d97706;
  --accent-red: #b91c1c;
  --panel: #fffdf9;
  --border: #d8d1c5;
  --warn: #9a3412;
  --deep: #15372d;
  --shadow: 0 12px 30px rgba(16, 38, 30, 0.08);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.1), transparent 28%),
    linear-gradient(180deg, #f7f4ee 0%, var(--bg) 100%);
  color: var(--ink);
}

.app-shell {
  max-width: 1840px;
  margin: 0 auto;
  padding: 18px 24px 28px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 12px;
  padding: 18px 22px;
  background: linear-gradient(160deg, rgba(21, 55, 45, 0.98), rgba(15, 118, 110, 0.92));
  border-radius: calc(var(--radius) + 4px);
  color: #f8fbf8;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  color: rgba(248, 251, 248, 0.72);
}

.hero-logos {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 0 0 12px;
  min-height: 44px;
}

.hero-logo {
  display: block;
  object-fit: contain;
}

.hero-logo-lds {
  max-height: 36px;
  max-width: 190px;
}

.hero-logo-customer {
  max-height: 44px;
  max-width: 170px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(30px, 4.3vw, 48px);
  line-height: 1;
}

.subtitle {
  margin: 8px 0 0;
  color: rgba(248, 251, 248, 0.76);
  font-size: 14px;
}

.hero-status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.hero-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
  min-width: 330px;
}

.stamp,
.kpi,
.panel,
.site-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stamp {
  padding: 12px 16px;
  background: rgba(255, 253, 249, 0.98);
}

.stamp-label,
.kpi-label,
.metric-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.stamp-value,
.kpi-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
}

.stamp-value {
  color: var(--ink);
}

.kpi-meta {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.kpi-status-green {
  color: #166534;
}

.kpi-status-amber {
  color: #b45309;
}

.kpi-status-red {
  color: #b91c1c;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.kpi {
  padding: 16px 16px 12px;
  min-height: 148px;
  display: grid;
  gap: 8px;
  align-content: start;
  background: linear-gradient(180deg, #fffdf9 0%, #f9f6ef 100%);
  border-radius: 14px;
  border: 1px solid #ece6dc;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}

.kpi-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kpi-icon {
  display: inline-flex;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  align-items: center;
  justify-content: center;
  background: #eef7f3;
  color: var(--accent);
  font-size: 14px;
}

.kpi-value {
  font-size: clamp(26px, 1.9vw, 36px);
  line-height: 1.02;
}

.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.kpi-sparkline {
  min-height: 36px;
}

.mini-sparkline {
  width: 100%;
  height: 36px;
}

.mini-sparkline-path {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mini-sparkline-teal .mini-sparkline-path {
  stroke: var(--accent);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.status-pill-good {
  color: #166534;
  background: #ecfdf3;
  border-color: #bbf7d0;
}

.status-pill-watch {
  color: #92400e;
  background: #fff7ed;
  border-color: #fed7aa;
}

.status-pill-alert {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

.status-pill-neutral {
  color: #334155;
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.panel {
  padding: 18px 20px;
}

.panel + .panel {
  margin-top: 14px;
}

.attention-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.attention-card {
  background: rgba(255, 253, 249, 0.98);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  min-height: 78px;
}

.attention-card p {
  margin: 8px 0 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.3;
}

.attention-card-watch {
  border-color: #f0c79a;
}

.attention-card-alert {
  border-color: #fecaca;
}

.wallboard-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 16px;
  align-items: stretch;
}

.wallboard-side-stack {
  display: grid;
  gap: 14px;
  align-content: start;
}

.panel-head-compact {
  margin-bottom: 10px;
}

.environment-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.calls-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.calls-section {
  display: grid;
  gap: 12px;
}

.calls-section-overview {
  grid-column: 1 / -1;
}

.calls-section-queue {
  grid-column: 1;
}

.calls-section-watch {
  grid-column: 2;
}

.calls-section-agents {
  grid-column: 1;
}

.calls-section-callers {
  grid-column: 2;
}

.calls-section-head h3 {
  margin: 0;
  font-size: 20px;
}

.calls-section-head p {
  margin: 4px 0 0 0;
  color: var(--muted);
  font-size: 12px;
}

.calls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.call-stat {
  padding: 16px;
  background: linear-gradient(180deg, #fffdf9 0%, #f9f6ef 100%);
  border-radius: 14px;
  border: 1px solid #ece6dc;
  min-height: 144px;
  display: grid;
  align-content: start;
}

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

.call-card-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  color: #6b7280;
}

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

.call-stat-value {
  display: block;
  font-size: clamp(28px, 1.8vw, 38px);
  font-weight: 700;
  line-height: 1.05;
}

.call-stat-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 28px;
  margin-top: 10px;
}

.call-stat-trend {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.call-stat-trend-up {
  color: #166534;
}

.call-stat-trend-down {
  color: #92400e;
}

.call-stat-note {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.call-stat-alert {
  background: linear-gradient(160deg, #f7f5ef, #fffaf1);
  border-color: #e7ddcd;
}

.call-gauge-card {
  text-align: center;
}

.call-gauge-target {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.call-queue-strip {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.call-queue-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: #f3efe8;
  border: 1px solid #e2d8c8;
  font-size: 12px;
  color: var(--muted);
}

.call-agents {
  padding: 14px;
  background: linear-gradient(180deg, #fffdf9 0%, #f9f6ef 100%);
  border-radius: 14px;
  border: 1px solid #ece6dc;
  min-height: 100%;
}

.call-agent-bars {
  display: grid;
  gap: 12px;
}

.call-agent-bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(180px, 1fr) 52px 72px;
  gap: 10px;
  align-items: center;
}

.call-agent-name {
  font-weight: 600;
}

.call-agent-bar-track {
  position: relative;
  height: 24px;
  border-radius: 999px;
  background: #ece6dc;
  overflow: hidden;
}

.call-agent-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0f766e, #2dd4bf);
}

.call-agent-bar-fill-volunteer {
  background: linear-gradient(90deg, #15803d, #4ade80);
}

.call-agent-bar-fill-other {
  background: linear-gradient(90deg, #1d4ed8, #60a5fa);
}

.call-agent-bar-fill-unassigned {
  background: linear-gradient(90deg, #6b7280, #cbd5e1);
}

.call-agent-value {
  font-size: 22px;
  font-weight: 700;
  text-align: right;
}

.call-agent-note {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

.call-agent-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 12px;
}

.call-agent-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.legend-dot-volunteer {
  background: #22c55e;
}

.legend-dot-other {
  background: #3b82f6;
}

.legend-dot-unassigned {
  background: #94a3b8;
}

.call-audit {
  padding: 10px 12px;
  border-radius: 12px;
  background: #f3efe8;
  border: 1px solid #e2d8c8;
  color: var(--muted);
  font-size: 12px;
}

.call-audit strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
}

.call-audit ul {
  margin: 0;
  padding-left: 18px;
}

.quality-note {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #e2d8c8;
  background: #f8f5ef;
  color: var(--muted);
  font-size: 12px;
  margin-top: 14px;
}

.quality-note strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
}

.quality-note ul {
  margin: 0;
  padding-left: 18px;
}

.quality-note-warning {
  background: #fff8f1;
  border-color: #f0c79a;
}

.environment-card {
  padding: 14px;
  background: linear-gradient(180deg, #fffdf9 0%, #f9f6ef 100%);
  border-radius: 14px;
  border: 1px solid #ece6dc;
}

.environment-outside .gauge-card {
  width: 100%;
  max-width: 260px;
  margin: 0 auto;
}

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

.environment-title {
  margin: 0;
  font-size: 18px;
}

.environment-date {
  color: var(--muted);
  font-size: 12px;
}

.environment-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.environment-source {
  color: var(--muted);
  font-size: 12px;
}

.environment-outside-value {
  font-size: clamp(32px, 2.2vw, 48px);
  font-weight: 700;
  line-height: 1;
}

.environment-icon {
  font-size: 22px;
  line-height: 1;
}

.environment-gauges {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.chart-shell {
  width: 100%;
  min-height: 286px;
}

.usage-chart {
  width: 100%;
  height: auto;
  min-height: 260px;
  display: block;
  background: #fbfaf7;
  border: 1px solid #ece6dc;
  border-radius: 14px;
}

.usage-chart-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.chart-grid {
  stroke: #ddd5c8;
  stroke-width: 1;
}

.chart-axis-label,
.chart-empty {
  fill: var(--muted);
  font-size: 16px;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

.chart-area {
  fill: rgba(15, 118, 110, 0.12);
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-point {
  fill: var(--accent);
}

.chart-point-peak {
  fill: #0f172a;
}

.chart-marker {
  stroke: #9a3412;
  stroke-width: 2;
  stroke-dasharray: 5 4;
}

.chart-marker-label {
  fill: #9a3412;
  font-size: 12px;
  font-weight: 700;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

.chart-peak-label {
  fill: #0f172a;
  font-size: 12px;
  font-weight: 700;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 24px;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.site-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.site-card {
  padding: 14px;
  min-height: 194px;
}

.site-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.site-name {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.site-meta-line {
  margin: 6px 0 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.site-meta-subtle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.site-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.aggregate {
  background: #fce7d6;
  color: var(--warn);
}

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

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  padding: 10px 12px;
  background: #fbfaf7;
  border-radius: 14px;
  border: 1px solid #ece6dc;
}

.metric-value {
  font-size: 22px;
  font-weight: 700;
}

.comfort-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.gauge-card {
  padding: 10px 12px;
  background: #fbfaf7;
  border-radius: 14px;
  border: 1px solid #ece6dc;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 164px;
}

.gauge {
  --gauge-pct: 0%;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, var(--panel) 0 53%, transparent 54%),
    conic-gradient(var(--gauge-fill) 0 var(--gauge-pct), #e8e1d5 var(--gauge-pct) 100%);
}

.gauge-temperature {
  --gauge-fill: #d97706;
}

.gauge-humidity {
  --gauge-fill: #0284c7;
}

.gauge-teal {
  --gauge-fill: #0f766e;
}

.gauge-amber {
  --gauge-fill: #d97706;
}

.gauge-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.gauge-value {
  font-size: 24px;
  font-weight: 700;
}

.gauge-unit {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

.gauge-detail {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 1680px) {
  .app-shell {
    padding: 18px 18px 26px;
  }

  .hero {
    gap: 18px;
    padding: 16px 18px;
  }

  .hero h1 {
    font-size: clamp(28px, 3.2vw, 42px);
  }

  .hero-meta {
    min-width: 280px;
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

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

  .wallboard-main-grid {
    grid-template-columns: 1fr;
  }

  .wallboard-side-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

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

  .calls-section-overview,
  .calls-section-queue,
  .calls-section-watch,
  .calls-section-agents,
  .calls-section-callers {
    grid-column: auto;
  }
}

@media (max-width: 1440px) {
  .site-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .call-agent-bar-row {
    grid-template-columns: minmax(110px, 150px) minmax(140px, 1fr) 48px 60px;
  }
}

@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .wallboard-main-grid {
    grid-template-columns: 1fr;
  }

  .wallboard-side-stack {
    grid-template-columns: 1fr;
  }

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

  .calls-section-overview,
  .calls-section-queue,
  .calls-section-watch,
  .calls-section-agents,
  .calls-section-callers {
    grid-column: auto;
  }

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

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

@media (max-width: 900px) {
  .app-shell {
    padding: 18px;
  }

  .hero {
    padding: 18px;
  }

  .hero-meta {
    min-width: 0;
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

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

  .attention-strip,
  .usage-chart-summary,
  .site-grid,
  .environment-grid {
    grid-template-columns: 1fr;
  }

  .call-agent-bar-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .call-agent-value {
    text-align: left;
  }

  .call-agent-note {
    text-align: left;
  }

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

.hidden {
  display: none;
}

.error-copy {
  color: var(--warn);
  margin: 0;
}

.portal-shell {
  max-width: 1320px;
}

.portal-hero {
  align-items: stretch;
}

.portal-auth {
  display: grid;
  gap: 12px;
  min-width: 320px;
}

.portal-user {
  font-size: 22px;
}

.portal-auth-links {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.portal-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--panel);
  text-decoration: none;
  font-weight: 700;
}

.portal-link-button-muted {
  background: transparent;
  color: var(--ink);
  border-color: var(--border);
}

.portal-link-button[disabled] {
  opacity: 0.6;
  cursor: wait;
}

.portal-empty-state {
  display: grid;
  gap: 14px;
  justify-items: start;
}

.portal-customer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.portal-customer-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel-soft);
  box-shadow: var(--shadow);
}

.portal-customer-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.portal-customer-card-head h3 {
  margin: 0;
  font-size: 24px;
}

.portal-customer-card-metrics,
.portal-customer-card-links {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

/* Onboarding / baseline status line on the landing customer cards. Empty until
   the non-blocking portfolio summary fills it, so it collapses cleanly. */
.portal-card-onboarding {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.portal-card-onboarding:empty {
  display: none;
}
.portal-card-onboarding-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* --- Four-tab adviser view (Option B) --- */
.adviser-household-header { display: grid; gap: var(--s-3); }
.adviser-header-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.adviser-action-status { color: var(--muted); font-size: 0.85rem; }
.adviser-header-lens { display: grid; gap: var(--s-3); }
.adviser-tabbar { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: var(--s-4) 0; }
.adviser-tab { cursor: pointer; border: none; }
/* Show only the active tab panel; no re-render on switch. */
.adviser-tabpanel { display: none; }
.adviser-tabs[data-active-tab="call"] .adviser-tabpanel[data-tabpanel="call"],
.adviser-tabs[data-active-tab="property"] .adviser-tabpanel[data-tabpanel="property"],
.adviser-tabs[data-active-tab="dynamics"] .adviser-tabpanel[data-tabpanel="dynamics"],
.adviser-tabs[data-active-tab="welfare"] .adviser-tabpanel[data-tabpanel="welfare"],
.adviser-tabs[data-active-tab="interactions"] .adviser-tabpanel[data-tabpanel="interactions"],
.adviser-tabs[data-active-tab="evidence"] .adviser-tabpanel[data-tabpanel="evidence"] { display: block; }
.adviser-rollup__grid { display: flex; flex-wrap: wrap; gap: var(--s-4); }
.adviser-rollup__item { display: grid; gap: 2px; min-width: 96px; }
.adviser-rollup__item strong { font-size: 1.6rem; line-height: 1; }
.adviser-rollup__item span { color: var(--muted); font-size: 0.8rem; }
.adviser-log-form { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.adviser-log-form input[type="text"] { flex: 1 1 240px; }
.adviser-log-countable { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.85rem; }
.adviser-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.adviser-table th, .adviser-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line, rgba(0,0,0,0.08)); vertical-align: top; }
.adviser-table th { color: var(--muted); font-weight: 600; }

.portal-kpi-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.portal-kpi-grid-compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.portal-kpi-link a {
  color: inherit;
}

.portal-detail-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.portal-table-panel {
  margin-top: 24px;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
}

.portal-site-list {
  display: grid;
  gap: 12px;
}

.portal-site-row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 18px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.portal-site-row h3 {
  margin: 0 0 6px;
  font-size: 20px;
}

.portal-site-row p {
  margin: 0;
  color: var(--muted);
}

.portal-site-copy {
  margin-top: 4px;
}

.portal-site-row-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-weight: 600;
}

@media (max-width: 1100px) {
  .hero {
    flex-direction: column;
  }

  .hero-meta,
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
    width: 100%;
  }

  .portal-detail-grid,
  .portal-kpi-grid-compact {
    grid-template-columns: 1fr;
  }

  .portal-auth {
    min-width: 100%;
  }

  .portal-auth-links {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 18px;
  }

  .hero-meta,
  .kpi-grid,
  .metric-grid,
  .comfort-grid {
    grid-template-columns: 1fr;
  }

  .portal-site-row {
    flex-direction: column;
    align-items: flex-start;
  }
}

body:has(.portal-shell) {
  font-family: "Manrope", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.18), transparent 30%),
    radial-gradient(circle at right 10%, rgba(29, 78, 216, 0.12), transparent 24%),
    linear-gradient(180deg, var(--panel-soft) 0%, var(--bg-deep) 100%);
}

.portal-shell {
  max-width: 1440px;
}

.portal-shell .hero h1,
.portal-shell .panel-head h2,
.portal-shell .portal-story-copy h2,
.portal-shell .portal-customer-card-head h3,
.portal-shell .portal-story-card h3,
.portal-shell .portal-site-spotlight h2 {
  font-family: "Fraunces", Georgia, serif;
}

.portal-shell .panel {
  background: rgba(255, 253, 249, 0.92);
  backdrop-filter: blur(10px);
}

.portal-story-hero {
  display: grid;
  grid-template-columns: 1.8fr 0.9fr;
  gap: 20px;
  align-items: start;
}

.portal-home-hero {
  margin-bottom: 18px;
}

.portal-story-copy h2 {
  margin: 0;
  font-size: clamp(34px, 4vw, 56px);
  line-height: 1;
}

.portal-story-summary {
  margin: 14px 0 0;
  max-width: 68ch;
  font-size: 18px;
  line-height: 1.6;
  color: var(--muted);
}

.portal-story-aside {
  display: grid;
  gap: 12px;
  justify-items: end;
}

.portal-story-stamp,
.portal-home-count {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--ink);
  font-weight: 700;
}

.portal-home-count {
  background: linear-gradient(135deg, var(--status-info-bg), var(--status-info-bg));
  color: var(--accent-strong);
}

.portal-section-tag,
.portal-card-tag {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  color: var(--muted);
}

.portal-story-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 18px 0 22px;
}

.portal-story-grid-compact {
  margin: 16px 0 0;
}

.portal-story-card {
  padding: 20px;
  border-radius: 20px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-soft) 100%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.portal-story-card h3 {
  margin: 0 0 10px;
  font-size: 24px;
}

.portal-story-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.portal-context-panel {
  margin-bottom: 22px;
}

.portal-context-panel summary {
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 14px;
  list-style: none;
}

.portal-context-panel summary::-webkit-details-marker {
  display: none;
}

.portal-context-summary-title {
  font-weight: 700;
  color: var(--ink);
}

.portal-context-summary-copy {
  color: var(--muted);
  font-size: 14px;
}

.portal-metric-ribbon {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.portal-impact-card {
  padding: 20px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: grid;
  gap: 8px;
}

.portal-impact-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #f8fffd;
}

.portal-impact-card-risk {
  border-width: 2px;
}

.portal-impact-card-risk-green {
  border-color: var(--status-ok-border);
  background: linear-gradient(180deg, var(--status-ok-bg) 0%, var(--panel) 100%);
}

.portal-impact-card-risk-amber {
  border-color: var(--status-watch-border);
  background: linear-gradient(180deg, var(--status-watch-bg) 0%, var(--panel) 100%);
}

.portal-impact-card-risk-red {
  border-color: var(--status-alert-border);
  background: linear-gradient(180deg, var(--status-alert-bg) 0%, var(--panel) 100%);
}

.portal-impact-card-risk-unknown {
  border-color: var(--border);
}
/* Tiered vocabulary (high/medium/low) — used by the cold-home watch card —
   aliased to the same status tints so those cards aren't left borderless. */
.portal-impact-card-risk-high {
  border-color: var(--status-alert-border);
  background: linear-gradient(180deg, var(--status-alert-bg) 0%, var(--panel) 100%);
}
.portal-impact-card-risk-medium {
  border-color: var(--status-watch-border);
  background: linear-gradient(180deg, var(--status-watch-bg) 0%, var(--panel) 100%);
}
.portal-impact-card-risk-low {
  border-color: var(--status-ok-border);
  background: linear-gradient(180deg, var(--status-ok-bg) 0%, var(--panel) 100%);
}

.portal-impact-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.78;
}

.portal-impact-card strong {
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1;
}

.portal-impact-card span:last-child {
  color: var(--muted);
}

.portal-impact-primary span:last-child {
  color: rgba(248, 255, 253, 0.82);
}

.portal-selector-panel {
  margin-bottom: 22px;
}

.portal-site-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.portal-site-chip {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  padding: 12px 16px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.portal-site-chip:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.portal-site-chip.is-selected {
  background: linear-gradient(135deg, var(--accent), var(--accent));
  color: var(--panel);
  border-color: transparent;
}

.portal-date-toolbar {
  margin-top: 18px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: end;
}

.portal-date-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.portal-date-preset {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.portal-date-preset:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: #f7fffc;
}

.portal-date-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  justify-content: flex-end;
}

.portal-date-inputs label {
  display: grid;
  gap: 6px;
  min-width: 160px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.portal-date-inputs input {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

.portal-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.95fr);
  gap: 18px;
  margin-bottom: 22px;
  align-items: start;
}

.portal-site-context-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.portal-decision-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.portal-visual-card {
  min-height: 320px;
}

.portal-chart-empty {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.portal-donut-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 18px;
  align-items: center;
}

.portal-donut {
  width: 220px;
  height: 220px;
  margin: 0 auto;
}

.portal-donut-total {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  fill: var(--muted);
}

.portal-donut-value {
  font-size: 28px;
  font-weight: 800;
  fill: var(--ink);
}

.portal-legend-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.portal-legend-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 14px;
}

.portal-legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
}

.portal-bar-stack {
  display: grid;
  gap: 16px;
  padding-top: 8px;
}

.portal-chart-note {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  margin-top: 4px;
}

.portal-chart-note strong {
  color: var(--ink);
}

.portal-chart-note p {
  margin: 0;
  line-height: 1.55;
}

.portal-bar-row {
  display: grid;
  gap: 8px;
}

.portal-bar-copy {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 14px;
  align-items: baseline;
}

.portal-bar-copy strong {
  font-size: 18px;
}

.portal-bar-track {
  height: 16px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.portal-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.portal-bar-teal {
  background: linear-gradient(90deg, var(--accent-strong), var(--c-moss));
}

.portal-bar-amber {
  background: linear-gradient(90deg, var(--status-watch-ink), var(--c-gold));
}

.portal-bar-blue {
  background: linear-gradient(90deg, var(--viz-carbon), var(--c-sage));
}

.portal-adviser-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.portal-analytics-panel {
  margin-bottom: 22px;
}

.portal-secondary-chart {
  margin-top: 18px;
}

.portal-subpanel-head {
  margin-top: 6px;
}

.portal-subpanel-head h3 {
  margin: 0;
  font-size: 1rem;
}

.portal-usage-chart-shell {
  width: 100%;
  overflow-x: auto;
}

.portal-usage-chart {
  width: 100%;
  min-width: 720px;
  height: auto;
  display: block;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-soft) 100%);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.portal-usage-grid {
  stroke: var(--viz-grid);
  stroke-width: 1;
}

.portal-usage-area {
  fill: rgba(15, 118, 110, 0.14);
}

.portal-usage-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.portal-usage-line-gas {
  stroke: var(--viz-gas);
}

.portal-usage-point {
  fill: var(--accent);
}

/* H.5.e — export overlay (solar / SEG) — distinct hue so import vs export
   stays readable at a glance. Amber matches the "out / generation" feel,
   teal stays the "in / grid consumption" series. */
.portal-usage-area-export {
  fill: rgba(217, 119, 6, 0.13);
}

.portal-usage-line-export {
  fill: none;
  stroke: var(--viz-gas);
  stroke-width: 3;
  stroke-dasharray: 6 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.portal-usage-point-export {
  fill: var(--viz-gas);
}

.portal-usage-legend {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  margin: 0 0 0.5rem 0;
  font-size: 0.85rem;
  color: var(--portal-muted, #475569);
}

.portal-usage-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.portal-usage-legend-item::before {
  content: "";
  display: inline-block;
  width: 0.85rem;
  height: 0.25rem;
  border-radius: 2px;
}

.portal-usage-legend-import::before {
  background: var(--accent);
}

.portal-usage-legend-export::before {
  background: var(--viz-gas);
  background-image: linear-gradient(to right, var(--viz-gas) 60%, transparent 60%);
  background-size: 5px 100%;
}

.portal-usage-axis {
  fill: var(--muted);
  font-size: 11px;
  font-family: "Manrope", "Segoe UI", sans-serif;
}

.portal-adviser-panel {
  min-height: 300px;
}

.portal-selector-actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.portal-selector-note {
  color: var(--muted);
  font-size: 13px;
}

.portal-pdf-controls {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.portal-pdf-mode {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--rule, #d7deea);
  background: var(--panel);
  font-size: 13px;
  color: var(--ink, #0f1e37);
}

.portal-pdf-status:empty {
  display: none;
}

.portal-section-head {
  margin-bottom: 16px;
}

.portal-section-head p {
  max-width: 72ch;
}

.portal-data-freshness {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--status-info-bg);
  border: 1px solid var(--status-info-border);
  color: var(--accent-strong);
}

.portal-data-freshness strong {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.portal-data-freshness span {
  font-size: 14px;
  line-height: 1.5;
}

.portal-data-freshness-warning {
  background: var(--status-watch-bg);
  border-color: var(--status-watch-border);
  color: var(--status-watch-ink);
}

.portal-site-spotlight {
  display: grid;
  gap: 18px;
}

.portal-estate-summary {
  display: grid;
  gap: 18px;
}

.portal-portfolio-summary {
  gap: 22px;
}

.portal-portfolio-hero {
  padding-bottom: 8px;
}

.portal-portfolio-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.portal-portfolio-kpi {
  padding: 18px;
  border-radius: 18px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  display: grid;
  gap: 8px;
}

.portal-portfolio-kpi span {
  color: var(--muted);
  font-size: 13px;
}

.portal-portfolio-kpi strong {
  font-size: 32px;
  line-height: 1.1;
}

.portal-portfolio-kpi p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.portal-kpi-change {
  font-weight: 700;
}

.portal-kpi-change-up {
  color: var(--status-watch-ink);
}

.portal-kpi-change-down {
  color: var(--status-ok-ink);
}

.portal-kpi-change-neutral {
  color: var(--muted);
}

.portal-portfolio-insights,
.portal-portfolio-sites {
  display: grid;
  gap: 16px;
}

.portal-portfolio-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(2, minmax(180px, 0.8fr)) auto;
  gap: 12px;
  align-items: center;
}

.portal-portfolio-controls input,
.portal-portfolio-controls select {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

.portal-view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.portal-view-button {
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.portal-view-button.is-selected {
  background: var(--status-info-bg);
  color: var(--accent-strong);
  font-weight: 700;
}

.portal-portfolio-site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.portal-portfolio-site-grid.is-list {
  grid-template-columns: 1fr;
}

.portal-portfolio-site-card {
  text-align: left;
  width: 100%;
  padding: 18px;
  border-radius: 18px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  box-shadow: none;
  min-height: 238px;
}

.portal-portfolio-site-card:hover {
  border-color: var(--border);
  background: var(--panel);
}

.portal-portfolio-site-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.portal-portfolio-site-head .badge {
  white-space: nowrap;
  flex-shrink: 0;
}

.portal-portfolio-site-head span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.portal-portfolio-site-head h3 {
  margin: 6px 0 0;
  font-size: 20px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.portal-portfolio-site-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.portal-portfolio-site-metrics div {
  display: grid;
  gap: 4px;
}

.portal-portfolio-site-metrics span {
  color: var(--muted);
  font-size: 12px;
}

.portal-portfolio-site-metrics strong {
  font-size: 18px;
}

.portal-portfolio-site-foot {
  display: grid;
  gap: 6px;
}

.portal-portfolio-site-foot small {
  color: var(--muted);
  line-height: 1.45;
}

.portal-site-trend {
  font-weight: 700;
}

.portal-site-trend.up {
  color: var(--status-watch-ink);
}

.portal-site-trend.down {
  color: var(--status-ok-ink);
}

.portal-site-trend.neutral {
  color: var(--muted);
}

.portal-badge-teal {
  background: var(--status-info-bg);
  color: var(--accent-strong);
}

.portal-badge-amber {
  background: var(--status-watch-bg);
  color: var(--status-watch-ink);
}

.portal-badge-blue {
  background: var(--status-info-bg);
  color: var(--viz-carbon);
}

.portal-usage-line-carbon {
  stroke: var(--viz-carbon);
  stroke-width: 3;
  fill: none;
}

.portal-estate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.portal-estate-card {
  padding: 16px;
  border-radius: 18px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  display: grid;
  gap: 6px;
}

.portal-estate-card span {
  color: var(--muted);
  font-size: 13px;
}

.portal-estate-card strong {
  font-size: 28px;
  line-height: 1.1;
}

.portal-estate-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.portal-priority-panel {
  border-style: dashed;
}

.portal-priority-list {
  display: grid;
  gap: 14px;
}

.portal-priority-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
}

.portal-priority-order {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--status-info-bg);
  color: var(--accent-strong);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
}

.portal-priority-copy {
  display: grid;
  gap: 8px;
}

.portal-priority-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.portal-priority-head h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}

.portal-priority-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.portal-workflow-section,
.portal-trend-section,
.portal-evidence-section,
.portal-quality-panel {
  margin-bottom: 22px;
}

.portal-workflow-grid,
.portal-quality-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

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

.portal-trend-card,
.portal-trend-panel {
  padding: 16px;
  border-radius: 18px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
}

.portal-trend-card {
  display: grid;
  gap: 8px;
  min-height: 148px;
}

.portal-trend-card span {
  color: var(--muted);
  font-size: 13px;
}

.portal-trend-card strong {
  font-size: 24px;
  line-height: 1.2;
}

.portal-trend-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.portal-trend-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.portal-trend-panel {
  min-height: 220px;
}

.portal-trend-panel > strong {
  display: block;
  margin-bottom: 12px;
  font-size: 16px;
}

.portal-trend-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.portal-trend-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
}

.portal-trend-list li strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

.portal-trend-list li p,
.portal-trend-list li small {
  display: block;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.portal-trend-list li small {
  margin-top: 6px;
}

.portal-risk-low {
  background: var(--status-info-bg);
  color: var(--accent-strong);
}

.portal-risk-medium {
  background: var(--status-watch-bg);
  color: var(--status-watch-ink);
}

.portal-risk-high {
  background: var(--status-alert-bg);
  color: var(--status-alert-ink);
}

.portal-workflow-card,
.portal-quality-card {
  min-height: 180px;
}

.portal-workflow-card h3 {
  margin: 0 0 10px;
  font-size: 22px;
  line-height: 1.35;
}

.portal-workflow-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.portal-spotlight-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.portal-spotlight-head h2 {
  margin: 0;
  font-size: 32px;
}

.portal-spotlight-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.portal-spotlight-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.portal-spotlight-note {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--muted);
  line-height: 1.55;
}

.portal-spotlight-note strong {
  color: var(--ink);
}

.portal-spotlight-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.portal-spotlight-metric {
  padding: 16px;
  border-radius: 18px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  display: grid;
  gap: 6px;
}

.portal-spotlight-metric span {
  color: var(--muted);
  font-size: 13px;
}

.portal-spotlight-metric strong {
  font-size: 26px;
}

.portal-tariff-card {
  display: grid;
  gap: 14px;
}

/* Devices in this home — gene discovery card */
.portal-gene-panel { margin-top: 18px; }
.portal-gene-list { display: grid; gap: 8px; margin-top: 6px; }
.portal-gene-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border, #e6e6e6);
  border-radius: 12px;
  background: var(--surface-subtle, #fafafa);
}
.portal-gene-main { display: grid; gap: 2px; min-width: 0; }
.portal-gene-main strong { font-weight: 650; }
.portal-gene-sub { font-size: 12px; color: var(--muted, #6b6b6b); }
.portal-gene-ev-miles { font-size: 12px; font-weight: 650; color: var(--accent, var(--status-ok-ink)); }
.portal-carbon-verdict { font-weight: 650; }
.portal-carbon-verdict-good { color: var(--status-ok-ink); }
.portal-carbon-verdict-neutral { color: var(--muted, #6b6b6b); }
.portal-carbon-verdict-bad { color: var(--status-watch-ink); }
.portal-carbon-verdict-ugly { color: var(--status-alert-ink); }
.portal-gene-meta { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.portal-gene-cost { font-weight: 700; font-size: 16px; white-space: nowrap; }
.portal-gene-cost-unit { font-weight: 500; font-size: 12px; color: var(--muted, #6b6b6b); }
.portal-gene-cost-managed { font-size: 12px; font-weight: 600; color: var(--accent, var(--status-ok-ink)); }
.portal-gene-cost-none { color: var(--muted, #9b9b9b); }
.portal-gene-foot { margin-top: 10px; font-size: 11px; color: var(--muted, #8b8b8b); }

.portal-tariff-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.portal-tariff-name {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 600;
}

.portal-tariff-gas {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.portal-tariff-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.portal-tariff-grid .portal-tariff-metric strong {
  font-size: 20px;
}

.portal-tariff-source {
  margin: 0;
}

/* Heating-cost sliding scale (17-22°C) — Property & usage tab */
.portal-heatcost-scale {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}
.portal-heatcost-cell {
  display: grid;
  gap: 2px;
  padding: 8px 4px;
  text-align: center;
  border: 1px solid rgba(127, 127, 127, 0.22);
  border-radius: 8px;
  background: rgba(127, 127, 127, 0.04);
}
.portal-heatcost-cell.is-current {
  border-color: rgba(127, 127, 127, 0.5);
  background: rgba(127, 127, 127, 0.12);
  font-weight: 600;
}
.portal-heatcost-cell.is-healthy { border-color: rgba(46, 139, 87, 0.55); }
.portal-heatcost-cell.is-oap {
  border-color: rgba(176, 137, 60, 0.7);
  background: rgba(176, 137, 60, 0.08);
}
.portal-heatcost-temp { font-size: 0.82rem; }
.portal-heatcost-temp small { font-size: 0.6rem; letter-spacing: 0.04em; opacity: 0.75; }
.portal-heatcost-cost { font-size: 0.95rem; font-weight: 600; }
.portal-heatcost-delta { font-size: 0.72rem; color: var(--muted); }
@media (max-width: 560px) {
  .portal-heatcost-scale { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.portal-action-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 14px;
  color: var(--muted);
  line-height: 1.7;
}

.portal-evidence-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.portal-evidence-list li {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  color: var(--ink);
  line-height: 1.6;
}

.portal-quality-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.portal-quality-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
}

.portal-quality-list p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.portal-quality-badge {
  align-self: start;
}

.portal-quality-ok {
  background: var(--status-ok-bg);
  color: var(--status-ok-ink);
}

.portal-quality-warning {
  background: var(--status-watch-bg);
  color: var(--status-watch-ink);
}

.portal-quality-missing-data,
.portal-quality-partial-window {
  background: var(--status-alert-bg);
  color: var(--status-alert-ink);
}

.portal-debug-panel {
  margin-top: 16px;
  border-top: 1px solid #ece3d6;
  padding-top: 16px;
}

.portal-debug-panel summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
}

.portal-debug-open {
  display: none;
}

.portal-debug-panel[open] .portal-debug-open {
  display: inline;
}

.portal-debug-panel[open] .portal-debug-closed {
  display: none;
}

.portal-debug-sections {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

.portal-debug-block {
  display: grid;
  gap: 8px;
}

.portal-debug-block strong {
  color: var(--ink);
  font-size: 14px;
}

.portal-debug-panel pre {
  margin: 0;
  padding: 14px;
  border-radius: 16px;
  background: rgba(15, 27, 23, 0.94);
  color: #dce8e3;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.portal-insight-grid {
  display: grid;
  gap: 14px;
}

.portal-funder-grid {
  display: grid;
  gap: 12px;
}

.portal-funder-row {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
}

.portal-funder-row span {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.portal-funder-row strong {
  font-size: 15px;
  line-height: 1.55;
}

.portal-funder-row small {
  color: var(--muted);
  line-height: 1.5;
}

.portal-funder-audit {
  margin-top: 6px;
}

.portal-funder-audit > summary {
  color: var(--muted);
  font-size: 0.78rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.portal-funder-audit > summary::-webkit-details-marker {
  display: none;
}

.portal-funder-audit > summary::before {
  content: "▸ ";
}

.portal-funder-audit[open] > summary::before {
  content: "▾ ";
}

.portal-narrative-tools {
  margin-bottom: 14px;
}

.portal-insight-card {
  padding: 16px 18px;
  border-radius: 16px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(16, 38, 30, 0.04);
}

.portal-insight-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.portal-insight-period {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.portal-narrative-headline {
  margin: 0 0 10px;
  font-size: 24px;
}

.portal-narrative-section {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.portal-insight-card p {
  margin: 0;
  color: var(--ink);
  line-height: 1.65;
}

.portal-customer-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.portal-customer-card-rich {
  background:
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.1), transparent 38%),
    linear-gradient(180deg, var(--panel) 0%, var(--panel-soft) 100%);
}

.portal-customer-card-metrics-rich {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  display: grid;
  gap: 12px;
}

.portal-customer-card-metrics-rich div {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
  display: grid;
  gap: 6px;
}

.portal-customer-card-metrics-rich span {
  color: var(--muted);
  font-size: 13px;
}

.portal-customer-card-metrics-rich strong {
  font-size: 20px;
}

.portal-card-ribbon {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-weight: 700;
}

.onboarding-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem 1.25rem;
}

.onboarding-form-grid label {
  display: grid;
  gap: 0.45rem;
  color: var(--text-strong);
  font-size: 0.92rem;
  font-weight: 700;
}

.onboarding-form-grid input,
.onboarding-form-grid select,
.onboarding-form-grid textarea {
  width: 100%;
  border: 1px solid rgba(18, 38, 32, 0.14);
  border-radius: 16px;
  padding: 0.85rem 0.95rem;
  font: inherit;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text-strong);
}

.onboarding-form-grid textarea {
  resize: vertical;
  min-height: 120px;
}

.checkbox-field {
  align-self: end;
  display: flex !important;
  align-items: center;
  gap: 0.7rem;
}

.checkbox-field input {
  width: 1rem;
  height: 1rem;
}

.onboarding-notes-field {
  grid-column: 1 / -1;
}

.onboarding-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-top: 0.35rem;
}

.onboarding-status-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 1rem;
}

.onboarding-status-form label {
  display: grid;
  gap: 0.45rem;
  min-width: min(100%, 24rem);
  color: var(--text-strong);
  font-size: 0.92rem;
  font-weight: 700;
  flex: 1 1 24rem;
}

.onboarding-status-form input {
  width: 100%;
  border: 1px solid rgba(18, 38, 32, 0.14);
  border-radius: 16px;
  padding: 0.85rem 0.95rem;
  font: inherit;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text-strong);
}

.portal-json-block {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(15, 27, 23, 0.94);
  color: #dce8e3;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

@media (max-width: 1100px) {
  .portal-story-grid,
  .portal-metric-ribbon,
  .portal-main-grid,
  .portal-site-context-grid,
  .portal-decision-grid,
  .portal-adviser-grid,
  .portal-trend-detail-grid,
  .portal-portfolio-kpis,
  .portal-estate-grid,
  .portal-story-hero,
  .portal-date-toolbar {
    grid-template-columns: 1fr;
  }

  .portal-portfolio-controls {
    grid-template-columns: 1fr;
  }

  .portal-donut-layout {
    grid-template-columns: 1fr;
  }

  .portal-story-aside {
    justify-items: start;
  }

  .portal-spotlight-head {
    flex-direction: column;
  }

  .portal-spotlight-badges {
    justify-content: flex-start;
  }

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

@media (max-width: 720px) {
  .portal-shell .hero {
    margin-bottom: 20px;
  }

  .portal-story-copy h2,
  .portal-spotlight-head h2 {
    font-size: 28px;
  }

  .portal-spotlight-grid,
  .portal-customer-card-metrics-rich,
  .portal-date-inputs {
    grid-template-columns: 1fr;
  }

  .portal-donut {
    width: 190px;
    height: 190px;
  }

  .portal-date-inputs {
    display: grid;
    justify-content: stretch;
  }

  .portal-date-inputs label {
    min-width: 0;
  }
}

/* Property Details section */
.portal-property-details-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.portal-property-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.portal-property-block {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 14px 16px;
}
.portal-property-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 6px;
  color: var(--muted, #98a4b6);
}
.portal-property-value {
  margin: 0 0 4px;
  font-size: 1.05rem;
  line-height: 1.4;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.portal-property-meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted, #98a4b6);
}
.portal-property-fabric-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.portal-property-fabric-list li {
  font-size: 0.85rem;
  color: var(--muted, #98a4b6);
}
.portal-source-tag {
  display: inline-block;
  font-size: 0.65rem;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted, #98a4b6);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 4px;
  vertical-align: middle;
}
.portal-property-epc-band {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.95rem;
  color: #0b1320;
  background: #c7d3e6;
}
.portal-property-epc-band-a { background: #0aa758; color: #fff; }
.portal-property-epc-band-b { background: #29c46f; color: #08240f; }
.portal-property-epc-band-c { background: #95d36a; color: #122b08; }
.portal-property-epc-band-d { background: #f4d35e; color: #2e2308; }
.portal-property-epc-band-e { background: #f5a04a; color: #2e1908; }
.portal-property-epc-band-f { background: #e6713d; color: #fff; }
.portal-property-epc-band-g { background: #d0463a; color: #fff; }

/* Property Details portfolio rollup */
.portal-property-rollup-shell {
  overflow-x: auto;
}
.portal-property-rollup {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.portal-property-rollup thead th {
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  color: var(--muted, #98a4b6);
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.portal-property-rollup tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}
.portal-property-rollup tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* Admin portal scaffold (v1) */
.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 0.75rem;
}
.admin-tab {
  border: 1px solid rgba(18, 38, 32, 0.18);
  background: rgba(255, 255, 255, 0.76);
  color: var(--text-strong);
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.admin-tab:hover { background: rgba(255, 255, 255, 0.92); }
.admin-tab.admin-tab-active {
  background: var(--text-strong, #122620);
  color: #fff;
  border-color: var(--text-strong, #122620);
}
.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.5rem 0 0.75rem;
}
.admin-workflow-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.25rem 0 1rem;
}
.admin-workflow-step {
  background: rgba(18, 38, 32, 0.06);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: 0.02em;
}
.admin-cases-table th, .admin-cases-table td { font-size: 0.86rem; }
.admin-case-detail { margin-top: 1.25rem; }
.admin-detail-json {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 14px;
  background: rgba(18, 38, 32, 0.05);
}
.admin-detail-json summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text-strong);
}
.admin-form-result { margin-top: 0.75rem; }
.admin-end-of-life {
  margin-top: 1.75rem;
  padding: 1rem 1.1rem;
  border-radius: 18px;
  border: 1px dashed rgba(208, 70, 58, 0.45);
  background: rgba(208, 70, 58, 0.04);
}
.admin-end-of-life .panel-head h2 { color: #b53b30; }
.admin-health-light {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 0.35rem;
  border: 1px solid rgba(18, 38, 32, 0.15);
}
.admin-health-light-green { background: #2f9b6a; }
.admin-health-light-amber { background: #e6a042; }
.admin-health-light-red   { background: #d0463a; }
.admin-health-light-grey  { background: #b6bcc4; }
.admin-consent-header { margin-bottom: 0.75rem; }

/* Tab pills — make active state more prominent */
.admin-tab {
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.admin-tab.admin-tab-active {
  box-shadow: 0 4px 12px rgba(18, 38, 32, 0.18);
}

/* Tighter, more readable admin tables */
.admin-table {
  font-size: 0.9rem;
  width: 100%;
}
.admin-table thead th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #6a7480);
  font-weight: 700;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid rgba(18, 38, 32, 0.12);
  background: rgba(18, 38, 32, 0.02);
}
.admin-table tbody td {
  padding: 0.55rem 0.7rem;
  vertical-align: middle;
  border-bottom: 1px solid rgba(18, 38, 32, 0.06);
}
.admin-table tbody tr:hover {
  background: rgba(18, 38, 32, 0.025);
}

/* Status pills (Onboarding Cases auth/submission/pull/apply) */
.admin-pill {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.admin-pill-good    { background: rgba(47, 155, 106, 0.15); color: #1f7a52; border-color: rgba(47, 155, 106, 0.4); }
.admin-pill-warn    { background: rgba(230, 160, 66, 0.18); color: #8a5a14; border-color: rgba(230, 160, 66, 0.45); }
.admin-pill-bad     { background: rgba(208, 70, 58, 0.16); color: #a13328; border-color: rgba(208, 70, 58, 0.45); }
.admin-pill-neutral { background: rgba(18, 38, 32, 0.06); color: #4a5159; border-color: rgba(18, 38, 32, 0.12); }

/* Data-source chips (Households) */
.admin-chip-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.admin-chip {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.admin-chip-sandbox    { background: rgba(230, 160, 66, 0.18); color: #8a5a14; border-color: rgba(230, 160, 66, 0.45); }
.admin-chip-production { background: rgba(47, 155, 106, 0.15); color: #1f7a52; border-color: rgba(47, 155, 106, 0.4); }
.admin-chip-octopus    { background: rgba(122, 60, 175, 0.14); color: #5b2a8f; border-color: rgba(122, 60, 175, 0.4); }
.admin-chip-influx     { background: rgba(40, 110, 200, 0.14); color: #1f5994; border-color: rgba(40, 110, 200, 0.4); }
.admin-chip-neutral    { background: rgba(18, 38, 32, 0.06); color: #4a5159; border-color: rgba(18, 38, 32, 0.12); }
.admin-evidence-placeholders:not(.hidden) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}
.admin-evidence-field {
  background: rgba(18, 38, 32, 0.04);
  border-radius: 14px;
  padding: 0.65rem 0.85rem;
  display: grid;
  gap: 0.2rem;
}
.portal-link-button-danger {
  background: #d0463a;
  color: var(--panel);
  border-color: #d0463a;
}
.portal-link-button-danger:hover { background: #b53b30; }
.portal-link-button-danger[disabled] { opacity: 0.55; cursor: not-allowed; }
.admin-modal-backdrop:not(.hidden) {
  position: fixed;
  inset: 0;
  background: rgba(15, 27, 23, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2.5rem 1rem;
  overflow-y: auto;
  z-index: 999;
}
.admin-modal {
  background: #fff;
  border-radius: 22px;
  padding: 1.6rem 1.6rem 1.2rem;
  width: min(100%, 880px);
  box-shadow: 0 24px 48px rgba(15, 27, 23, 0.18);
}

/* ===================================================================
 * 2026 REBOOT
 * --------------------------------------------------------------------
 * Editorial / high-contrast refresh. Overrides earlier tokens and
 * decorative chrome. Keep LDS green as the single accent.
 * Scoped via :where() where useful so revert is one commit away.
 * =================================================================== */

:root {
  /* Visual Refresh R3: legacy portal vars now resolve to brand tokens
     (tokens.css loads first). Forest-green is the single accent; greys map to
     the brand ink/sage family. This retargets every var(--accent/--muted/...)
     usage across the portal in one place. */
  --bg: var(--c-cream-soft);
  --bg-deep: var(--c-cream);
  --panel: var(--c-paper);
  --border: var(--c-sage);
  --border-strong: #AEBFB6;
  --ink: var(--c-ink);
  --ink-soft: var(--c-ink);
  --muted: var(--c-ink-soft);
  --accent: var(--c-forest);
  --accent-strong: var(--c-forest-d);
  --accent-soft: var(--c-moss-soft);
  --warn: var(--c-warn);
  --shadow: var(--shadow-2);
  --radius: var(--r-lg);
  --radius-small: var(--r-xs);
}

body {
  background: var(--bg);
  font-family: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

body:has(.portal-shell) {
  background: var(--bg);
}

.app-shell {
  padding: 22px 28px 36px;
}

/* --- Hero: solid near-black block, square edges, no shadow ----------- */
.hero {
  background: var(--ink);
  color: #fafafa;
  border-radius: var(--radius);
  box-shadow: none;
  padding: 28px 32px;
  margin-bottom: 22px;
  border: 1px solid var(--ink);
}
.hero h1 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.02;
  font-size: clamp(34px, 4.8vw, 56px);
}
.hero .subtitle {
  color: rgba(250, 250, 250, 0.6);
  font-size: 14px;
  max-width: 56ch;
  margin-top: 10px;
}
.hero .eyebrow {
  color: var(--accent);
  letter-spacing: 0.16em;
  font-weight: 700;
  font-size: 11px;
}
.hero-logos { margin-bottom: 16px; }
.hero-logo-lds { max-height: 28px; }

/* Auth stamp area on hero — neutralise the chrome */
.hero .stamp {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-small);
  box-shadow: none;
  backdrop-filter: none;
}
.hero .stamp-label {
  color: rgba(250, 250, 250, 0.55);
  font-size: 10px;
  letter-spacing: 0.14em;
}
.hero .stamp-value { color: #fafafa; }
.hero .kpi-meta { color: rgba(250, 250, 250, 0.6); font-size: 11px; }

/* --- Panels: white card, hairline only ------------------------------ */
.panel,
.stamp,
.kpi,
.site-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
}
.portal-shell .panel {
  background: var(--panel);
  backdrop-filter: none;
}
.panel { padding: 22px 24px; }
.panel + .panel { margin-top: 16px; }

.panel-head { padding: 0; margin: 0 0 14px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.panel-head h2 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: clamp(22px, 2.4vw, 28px);
  margin: 0;
  color: var(--ink);
}
.panel-head p { color: var(--muted); margin: 6px 0 0; font-size: 13px; max-width: 70ch; }

.eyebrow {
  color: var(--muted);
  letter-spacing: 0.14em;
  font-size: 11px;
  font-weight: 700;
}

/* --- Buttons: sharp rectangles, deliberate colour use --------------- */
.portal-link-button {
  background: var(--ink);
  color: #fafafa;
  border: 1px solid var(--ink);
  border-radius: var(--radius-small);
  padding: 0.6rem 0.95rem;
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  text-decoration: none;
  display: inline-block;
}
.portal-link-button:hover { background: var(--ink-soft); }

.portal-link-button-muted {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border-strong);
}
.portal-link-button-muted:hover {
  background: var(--bg-deep);
  border-color: var(--ink);
}

.portal-link-button-danger {
  background: var(--status-alert-ink);
  color: var(--panel);
  border-color: var(--status-alert-ink);
}
.portal-link-button-danger:hover { background: var(--status-alert-ink); border-color: var(--status-alert-ink); }

.portal-link-button[disabled],
.portal-link-button-danger[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Accent button — use sparingly for explicit "go" actions */
.portal-link-button-accent {
  background: var(--accent);
  color: var(--panel);
  border-color: var(--accent);
}
.portal-link-button-accent:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

/* --- Tabs (admin portal): underline tabs, not pills ----------------- */
.admin-tabs {
  border-bottom: 1px solid var(--border);
  margin: 18px 0 18px;
  gap: 0;
  padding-bottom: 0;
}
.admin-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 0;
  padding: 0.7rem 1rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.admin-tab:hover { background: transparent; color: var(--ink); }
.admin-tab.admin-tab-active {
  background: transparent;
  color: var(--ink);
  border-bottom-color: var(--ink);
  box-shadow: none;
}

/* --- Tables: editorial / hairline only ------------------------------ */
.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.portal-table thead th,
.admin-table thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
  padding: var(--density-row-pad);
  border-bottom: 1px solid var(--border-strong);
  background: transparent;
}
.portal-table tbody td,
.admin-table tbody td {
  padding: var(--density-row-pad);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.portal-table tbody tr:hover,
.admin-table tbody tr:hover { background: var(--bg-deep); }
.portal-table-wrap { border: 0; }

/* --- Forms: clean inputs, no shadows -------------------------------- */
.onboarding-form-grid input,
.onboarding-form-grid select,
.onboarding-form-grid textarea,
.onboarding-status-form input {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  background: var(--panel);
  color: var(--ink);
  padding: 0.7rem 0.85rem;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.onboarding-form-grid input:focus,
.onboarding-form-grid select:focus,
.onboarding-form-grid textarea:focus,
.onboarding-status-form input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(10, 10, 10, 0.08);
}
.onboarding-form-grid label > span {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

/* Confirmation checkboxes inside .onboarding-form-grid would otherwise
   inherit the full-width input styling (width:100%, padding 0.85rem) and
   the uppercase 11px span styling that's intended for field labels.
   Restore checkbox-shaped checkboxes and a readable confirmation message. */
.onboarding-form-grid input[type="checkbox"] {
  width: auto;
  height: auto;
  padding: 0;
  border-radius: 0;
  flex-shrink: 0;
  margin-top: 0.25rem;
}
.onboarding-form-grid label > input[type="checkbox"] + span {
  text-transform: none;
  font-size: 0.92rem;
  letter-spacing: normal;
  color: var(--ink);
  font-weight: 500;
}

/* --- Empty-state / warning / json blocks ---------------------------- */
.portal-empty-state {
  background: transparent;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--muted);
}
.portal-warning {
  background: var(--status-watch-bg);
  border: 1px solid var(--status-watch-border);
  color: var(--status-watch-ink);
  padding: 12px 14px;
  border-radius: var(--radius-small);
}
.portal-json-block {
  background: #0d0d0d;
  color: #e8eae6;
  border-radius: var(--radius-small);
  border: 0;
  font-size: 12px;
  padding: 14px 16px;
}

/* --- Cards (panel-card) used in dashboards -------------------------- */
.panel-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
  padding: 16px 18px;
}
.panel-card-label {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 700;
}
.panel-card-value {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.01em;
  color: var(--ink);
  display: block;
  margin-top: 4px;
  line-height: 1;
}
.kpi-meta { color: var(--muted); font-size: 12px; }

/* --- Admin modal: cleaner --- */
.admin-modal {
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  box-shadow: 0 12px 24px rgba(10, 10, 10, 0.12);
  padding: 24px 26px 20px;
}

/* --- Pills: tighter --- */
.admin-pill {
  font-size: 11px;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
}
.admin-chip { border-radius: var(--radius-small); }

/* --- Status pills inherit editorial weight on dark hero --- */
.hero .portal-link-button {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fafafa;
}
.hero .portal-link-button:hover { background: rgba(255, 255, 255, 0.14); }
.hero .portal-link-button-muted {
  background: transparent;
  color: rgba(250, 250, 250, 0.85);
  border-color: rgba(255, 255, 255, 0.2);
}
.hero .portal-link-button-muted:hover { background: rgba(255, 255, 255, 0.08); color: #fafafa; }

/* --- Code, monospace --- */
code {
  font-family: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, monospace;
  font-size: 0.9em;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.05em 0.35em;
  color: var(--ink-soft);
}
.hero code { background: rgba(255, 255, 255, 0.08); color: #fafafa; border-color: rgba(255, 255, 255, 0.12); }

/* --- Onboarding workflow steps: editorial --- */
.admin-workflow-step {
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.3rem 0.7rem;
}

/* --- Links --- */
a { color: var(--accent); }
a:hover { color: var(--accent-strong); }
.hero a { color: rgba(250, 250, 250, 0.85); }
.hero a:hover { color: #fff; }

/* --- Stamp on non-hero panels (login pill, status header etc.) --- */
.stamp:not(.hero .stamp) {
  background: var(--bg-deep);
  border: 1px solid var(--border);
}

/* --- Property EPC band colour chips stay loud — they communicate
       the band visually and editorial neutrality would lose that.
       Just tighten the radius. --- */
.portal-property-epc-band { border-radius: var(--radius-small); }

/* --- Data-source / health lights — minor tighten --- */
.admin-evidence-field {
  background: var(--bg-deep);
  border-radius: var(--radius-small);
}

/* --- Digital Twin lens --- */
.twin-body {
  background:
    radial-gradient(circle at top left, rgba(29, 78, 216, 0.10), transparent 30%),
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.08), transparent 30%),
    linear-gradient(180deg, #f3f6fb 0%, #eef2f7 100%);
}

.hero-twin {
  background: linear-gradient(160deg, rgba(15, 30, 55, 0.98), rgba(29, 78, 216, 0.92));
}

.twin-gate {
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 18px 0 12px;
}

.twin-gate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.twin-gate-detail {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.twin-kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin: 14px 0;
}

.twin-kpi {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.twin-zone-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  padding: 4px;
}

.twin-zone-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.twin-zone-card.is-parent {
  border-color: rgba(29, 78, 216, 0.35);
  background: linear-gradient(180deg, rgba(29, 78, 216, 0.04), var(--panel));
}

.twin-zone-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.twin-zone-card-head h3 {
  margin: 0;
  font-size: 18px;
  color: var(--ink);
}

.twin-zone-card-role {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  color: var(--muted);
}

.twin-zone-card-role.is-parent { color: var(--accent-blue); }

.twin-zone-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 14px;
}

.twin-zone-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.twin-zone-metric-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.twin-zone-metric-value {
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
}

.twin-zone-metric-value.is-warm { color: var(--accent-amber); }
.twin-zone-metric-value.is-cool { color: var(--accent-blue); }
.twin-zone-metric-value.is-good { color: var(--accent); }
.twin-zone-metric-value.is-muted { color: var(--muted); }

.twin-zone-occupancy-bar {
  position: relative;
  height: 8px;
  background: rgba(15, 30, 55, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.twin-zone-occupancy-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-blue));
  border-radius: inherit;
}

.twin-chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 14px;
}

@media (min-width: 1200px) {
  /* On wide desktops, pair the temp chart and forecast since they
   * fit well side-by-side, but keep power demand + occupancy heatmap
   * full-width because their x-axis labels need the room. */
  .twin-chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .twin-chart-grid > section:nth-child(1),
  .twin-chart-grid > section:nth-child(2) {
    grid-column: 1 / -1;
  }
}

.twin-forecast {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  padding: 6px 4px 0;
}

.twin-forecast-cell {
  background: rgba(15, 30, 55, 0.04);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.twin-forecast-cell-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.twin-forecast-cell-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
}

.twin-forecast-cell.is-best {
  background: linear-gradient(160deg, rgba(15, 118, 110, 0.08), rgba(29, 78, 216, 0.06));
  border-color: rgba(15, 118, 110, 0.3);
}

.twin-power-bar {
  fill: rgba(29, 78, 216, 0.55);
}

.twin-power-bar.is-empty-room {
  fill: rgba(185, 28, 28, 0.55);
}

.twin-occupancy-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.twin-temp-bar-indoor { fill: rgba(29, 78, 216, 0.7); }
.twin-temp-bar-outdoor { fill: rgba(217, 119, 6, 0.75); }
.twin-temp-bar-label { font-size: 18px; font-weight: 600; fill: var(--ink); }

/* Date selector */
.twin-date-stamp {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
}

.twin-date-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.twin-date-input {
  flex: 1;
  font: inherit;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  min-width: 140px;
}

.twin-date-step {
  font-size: 20px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  padding: 0;
}

.twin-date-step:hover:not([disabled]) {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.twin-date-step[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Occupancy heatmap */
.twin-heatmap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0 14px;
}

.twin-heatmap-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  align-items: center;
}

.twin-heatmap-row.is-axis {
  margin-top: 4px;
}

.twin-heatmap-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.twin-heatmap-axis {
  font-size: 12px;
  color: var(--muted);
}

.twin-heatmap-cells {
  display: grid;
  grid-template-columns: repeat(48, minmax(0, 1fr));
  gap: 2px;
}

.twin-heatmap-axis-cells {
  display: grid;
  grid-template-columns: repeat(48, minmax(0, 1fr));
  gap: 2px;
  font-size: 12px;
  color: var(--muted);
}

.twin-heatmap-axis-cells > span {
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
}

.twin-heatmap-cell {
  height: 26px;
  border-radius: 4px;
  background: rgba(15, 30, 55, 0.05);
  border: 1px solid rgba(15, 30, 55, 0.06);
}

.twin-heatmap-cell.is-occupied {
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.95), rgba(29, 78, 216, 0.85));
  border-color: rgba(29, 78, 216, 0.3);
}

.twin-heatmap-cell.is-missing {
  background: repeating-linear-gradient(
    45deg,
    rgba(15, 30, 55, 0.04),
    rgba(15, 30, 55, 0.04) 3px,
    rgba(15, 30, 55, 0.08) 3px,
    rgba(15, 30, 55, 0.08) 6px
  );
}

/* Hub Cliniko-session overlay: green = session+occupancy (good),
   red = session+no occupancy (no-shows / room empty during a scheduled class). */
.twin-heatmap-cell.is-booked-occupied {
  background: linear-gradient(135deg, rgba(22, 163, 74, 0.95), rgba(21, 128, 61, 0.9));
  border-color: rgba(21, 128, 61, 0.4);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.twin-heatmap-cell.is-booked-empty {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.92), rgba(185, 28, 28, 0.88));
  border-color: rgba(185, 28, 28, 0.4);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.twin-heatmap-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 10px;
}

.twin-legend-chip {
  display: inline-block;
  width: 16px;
  height: 12px;
  border-radius: 3px;
  background: rgba(15, 30, 55, 0.05);
  border: 1px solid rgba(15, 30, 55, 0.06);
  margin-right: 4px;
}

.twin-legend-chip.is-occupied {
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.95), rgba(29, 78, 216, 0.85));
  border-color: rgba(29, 78, 216, 0.3);
}

.twin-legend-chip.is-booked-occupied {
  background: linear-gradient(135deg, rgba(22, 163, 74, 0.95), rgba(21, 128, 61, 0.9));
  border-color: rgba(21, 128, 61, 0.4);
}

.twin-legend-chip.is-booked-empty {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.92), rgba(185, 28, 28, 0.88));
  border-color: rgba(185, 28, 28, 0.4);
}

.twin-legend-chip.is-missing {
  background: repeating-linear-gradient(
    45deg,
    rgba(15, 30, 55, 0.04),
    rgba(15, 30, 55, 0.04) 3px,
    rgba(15, 30, 55, 0.08) 3px,
    rgba(15, 30, 55, 0.08) 6px
  );
}

.twin-heatmap-cell.is-booked-missing {
  background: repeating-linear-gradient(
    45deg,
    rgba(220, 38, 38, 0.32),
    rgba(220, 38, 38, 0.32) 3px,
    rgba(185, 28, 28, 0.55) 3px,
    rgba(185, 28, 28, 0.55) 6px
  );
  border-color: rgba(185, 28, 28, 0.35);
}

/* Dishwasher on-overlay: distinctive striped outline on energy cells so the
   underlying kWh gradient is still visible. Sits above the colour fill. */
.twin-heatmap-cell.is-dishwasher-on {
  position: relative;
  box-shadow: inset 0 0 0 1.5px rgba(79, 70, 229, 0.9);
}
.twin-heatmap-cell.is-dishwasher-on::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 4px;
  pointer-events: none;
  background: repeating-linear-gradient(
    135deg,
    transparent,
    transparent 3px,
    rgba(79, 70, 229, 0.55) 3px,
    rgba(79, 70, 229, 0.55) 5px
  );
  mix-blend-mode: multiply;
}

.twin-legend-chip.is-dishwasher-on {
  background: repeating-linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.7),
    rgba(255, 255, 255, 0.7) 3px,
    rgba(79, 70, 229, 0.7) 3px,
    rgba(79, 70, 229, 0.7) 5px
  );
  border-color: rgba(79, 70, 229, 0.55);
}

/* Calls overlay: amber tier on top of the occupancy base. The amber band
   sits on the right edge so the underlying occupancy fill (or Hub-session
   overlay) is still readable on the left two-thirds of the cell. Three
   tiers — light (1-2), medium (3-5), heavy (6+) — set by the JS based on
   per-slot call count. Tooltip carries the actual number. */
.twin-heatmap-cell.is-calls-l1,
.twin-heatmap-cell.is-calls-l2,
.twin-heatmap-cell.is-calls-l3 {
  position: relative;
}
.twin-heatmap-cell.is-calls-l1::before,
.twin-heatmap-cell.is-calls-l2::before,
.twin-heatmap-cell.is-calls-l3::before {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  bottom: 2px;
  border-radius: 2px;
  pointer-events: none;
}
.twin-heatmap-cell.is-calls-l1::before {
  width: 4px;
  background: rgba(245, 158, 11, 0.55);
  box-shadow: 0 0 0 1px rgba(180, 83, 9, 0.4);
}
.twin-heatmap-cell.is-calls-l2::before {
  width: 5px;
  background: rgba(245, 158, 11, 0.78);
  box-shadow: 0 0 0 1px rgba(180, 83, 9, 0.55);
}
.twin-heatmap-cell.is-calls-l3::before {
  width: 7px;
  background: rgba(217, 119, 6, 0.95);
  box-shadow: 0 0 0 1px rgba(154, 52, 18, 0.7);
}

.twin-legend-chip.is-calls-l2 {
  background: rgba(245, 158, 11, 0.78);
  border-color: rgba(180, 83, 9, 0.55);
}
.twin-legend-chip.is-calls-l3 {
  background: rgba(217, 119, 6, 0.95);
  border-color: rgba(154, 52, 18, 0.7);
}

/* UniFi connected-devices overlay — a building-network occupancy proxy, painted
   on the HQ rollup row as a rose BOTTOM bar so it coexists with the amber calls
   bar (right edge) on the same cell. Three tiers by connected-device count. */
.twin-heatmap-cell.is-devices-l1,
.twin-heatmap-cell.is-devices-l2,
.twin-heatmap-cell.is-devices-l3 {
  position: relative;
}
.twin-heatmap-cell.is-devices-l1::after,
.twin-heatmap-cell.is-devices-l2::after,
.twin-heatmap-cell.is-devices-l3::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 2px;
  border-radius: 2px;
  pointer-events: none;
}
.twin-heatmap-cell.is-devices-l1::after { height: 3px; background: rgba(236, 72, 153, 0.5); }
.twin-heatmap-cell.is-devices-l2::after { height: 4px; background: rgba(236, 72, 153, 0.78); }
.twin-heatmap-cell.is-devices-l3::after { height: 6px; background: rgba(219, 39, 119, 0.95); }
.twin-legend-chip.is-devices-l2 {
  background: rgba(236, 72, 153, 0.78);
  border-color: rgba(190, 24, 93, 0.55);
}
.twin-legend-chip.is-devices-l3 {
  background: rgba(219, 39, 119, 0.95);
  border-color: rgba(157, 23, 77, 0.7);
}

/* Nourish appointments — violet intensity. Three tiers tuned to home-support
   volume (~1-2, 3-5, 6+ concurrent visits per 30-min slot). The base panel
   uses the same .twin-heatmap-cell grid as occupancy/energy. */
.twin-heatmap-cell.is-appts-l1 {
  background: rgba(167, 139, 250, 0.45);
  border-color: rgba(124, 58, 237, 0.35);
}
.twin-heatmap-cell.is-appts-l2 {
  background: rgba(139, 92, 246, 0.7);
  border-color: rgba(91, 33, 182, 0.5);
}
.twin-heatmap-cell.is-appts-l3 {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.95), rgba(91, 33, 182, 0.92));
  border-color: rgba(76, 29, 149, 0.55);
}

.twin-legend-chip.is-appts-l1 {
  background: rgba(167, 139, 250, 0.45);
  border-color: rgba(124, 58, 237, 0.35);
}
.twin-legend-chip.is-appts-l2 {
  background: rgba(139, 92, 246, 0.7);
  border-color: rgba(91, 33, 182, 0.5);
}
.twin-legend-chip.is-appts-l3 {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.95), rgba(91, 33, 182, 0.92));
  border-color: rgba(76, 29, 149, 0.55);
}

/* Staff sub-grid sits directly under the aggregate row — visually grouped
   with a slim gap and a left-border accent so it reads as a single panel. */
.twin-heatmap-staff {
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px dashed rgba(91, 33, 182, 0.2);
}

/* Rostered (scheduled, not yet checked in) cells get a diagonal stripe
   overlay so the user can tell at a glance which violet slots are "real"
   actuals vs which are just the rota. Sits above the base intensity fill. */
.twin-heatmap-cell.is-appts-rostered {
  position: relative;
}
.twin-heatmap-cell.is-appts-rostered::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 4px;
  pointer-events: none;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 3px,
    rgba(255, 255, 255, 0.45) 3px,
    rgba(255, 255, 255, 0.45) 5px
  );
}
.twin-legend-chip.is-appts-rostered {
  position: relative;
}
.twin-legend-chip.is-appts-rostered::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 2px,
    rgba(255, 255, 255, 0.5) 2px,
    rgba(255, 255, 255, 0.5) 4px
  );
}

.twin-narrative-caption {
  font-size: 12.5px;
  color: var(--muted);
  margin: 6px 0 10px;
  line-height: 1.55;
}
.twin-narrative-caption strong {
  color: rgba(91, 33, 182, 0.9);
}

/* TeamViewer fleet — per-group online/offline split bars */
.twin-tv-groups {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0 12px;
}
.twin-tv-group-row {
  display: grid;
  grid-template-columns: minmax(140px, 22%) 1fr auto;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
}
.twin-tv-group-name {
  color: var(--ink, #1f2937);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.twin-tv-group-bar {
  position: relative;
  display: inline-block;
  height: 12px;
  min-width: 40px;
  background: rgba(20, 150, 136, 0.16);
  border-radius: 6px;
  overflow: hidden;
}
.twin-tv-group-bar-on {
  position: absolute;
  inset: 0 auto 0 0;
  height: 100%;
  background: rgba(20, 150, 136, 0.85);
  border-radius: 6px;
}
.twin-tv-group-count {
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Cover Planner */
.twin-cover-controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin: 6px 0 12px; }
.twin-cover-controls label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
.twin-cover-controls select, .twin-cover-controls input { font: inherit; padding: 7px 9px; border: 1px solid #cfd6dd; border-radius: 8px; min-width: 120px; }
.twin-cover-controls select { min-width: 220px; }
.twin-cover-hint, .twin-cover-foot { font-size: 12.5px; color: var(--muted); }
.twin-cover-head { font-size: 14px; margin: 8px 0 4px; }
.twin-cover-money { font-size: 12.5px; color: #5b6a61; background: #fbf7ec; padding: 9px 11px; border-radius: 7px; line-height: 1.5; }
.twin-cover-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13px; }
.twin-cover-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid #e7e2d4; }
.twin-cover-table td { padding: 8px; border-bottom: 1px solid #efebe0; vertical-align: top; font-variant-numeric: tabular-nums; }
.twin-cover-table tr.is-rec { background: #f0f7f2; }
.twin-cover-desc { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.twin-cover-sub { display: block; font-size: 11px; color: var(--muted); }
.twin-cover-good { color: #1f7a4d; font-weight: 600; }
.twin-cover-bad { color: #b42318; }
.twin-cover-changes h3 { font-size: 14px; margin: 12px 0 6px; }
.twin-cover-ch-h { font-size: 12.5px; font-weight: 700; color: var(--deep, #123328); margin: 8px 0 2px; }
.twin-cover-changes ul { margin: 0 0 6px; padding-left: 18px; font-size: 12.5px; }
.twin-cover-changes li { margin: 2px 0; }
.twin-cover-cols { columns: 2; column-gap: 28px; }
.twin-cover-emailrow { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-top: 12px; padding-top: 12px; border-top: 1px solid #e7e2d4; }
.twin-cover-emailrow label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
.twin-cover-emailrow input { font: inherit; padding: 7px 9px; border: 1px solid #cfd6dd; border-radius: 8px; min-width: 280px; }
.twin-cover-emailstatus { font-size: 12.5px; color: var(--muted); }
@media (max-width: 720px) { .twin-cover-cols { columns: 1; } }

/* ---------- Nourish appointments BI strip ---------- */

.twin-appts-kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 14px 0 18px;
}
.twin-appts-kpi {
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.06), rgba(124, 58, 237, 0.02));
  border: 1px solid rgba(124, 58, 237, 0.18);
  border-radius: 12px;
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.twin-appts-kpi-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.twin-appts-kpi-value {
  font-family: "Fraunces", Georgia, serif;
  font-size: 28px;
  line-height: 1;
  font-weight: 600;
  color: var(--ink);
}
.twin-appts-kpi-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.twin-appts-kpi-primary {
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.16), rgba(124, 58, 237, 0.06));
  border-color: rgba(91, 33, 182, 0.35);
}
.twin-appts-kpi-primary .twin-appts-kpi-value {
  color: rgba(76, 29, 149, 0.95);
}
.twin-appts-kpi-good { border-color: rgba(22, 163, 74, 0.3); }
.twin-appts-kpi-good .twin-appts-kpi-value { color: rgba(21, 128, 61, 0.95); }
.twin-appts-kpi-watch { border-color: rgba(245, 158, 11, 0.4); }
.twin-appts-kpi-watch .twin-appts-kpi-value { color: rgba(180, 83, 9, 0.95); }
.twin-appts-kpi-alert { border-color: rgba(220, 38, 38, 0.4); }
.twin-appts-kpi-alert .twin-appts-kpi-value { color: rgba(185, 28, 28, 0.95); }

/* ---------- Carbon-aware heating plan card ---------- */

.twin-heating-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.18), rgba(6, 182, 212, 0.16));
  color: rgba(76, 29, 149, 0.95);
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.twin-heating-host {
  padding-top: 6px;
}
.twin-heating-loading,
.twin-heating-error {
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  border: 1px dashed rgba(15, 30, 55, 0.15);
  border-radius: 8px;
}
.twin-heating-error {
  color: rgba(185, 28, 28, 0.95);
  border-color: rgba(185, 28, 28, 0.3);
  background: rgba(220, 38, 38, 0.05);
}

.twin-heating-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.twin-heating-meta-tile {
  background: linear-gradient(180deg, rgba(6, 182, 212, 0.06), rgba(6, 182, 212, 0.02));
  border: 1px solid rgba(6, 182, 212, 0.22);
  border-radius: 12px;
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.twin-heating-meta-primary {
  background: linear-gradient(180deg, rgba(22, 163, 74, 0.18), rgba(22, 163, 74, 0.06));
  border-color: rgba(22, 163, 74, 0.42);
}
.twin-heating-meta-primary .twin-heating-meta-value {
  color: rgba(21, 128, 61, 0.96);
}
.twin-heating-meta-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.twin-heating-meta-value {
  font-family: "Fraunces", Georgia, serif;
  font-size: 26px;
  line-height: 1;
  font-weight: 600;
  color: var(--ink);
}
.twin-heating-meta-sub {
  font-size: 12px;
  color: var(--muted);
}

.twin-heating-summary {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  margin: 0 0 12px;
  padding: 12px 14px;
  background: rgba(15, 30, 55, 0.03);
  border-left: 3px solid rgba(124, 58, 237, 0.45);
  border-radius: 0 8px 8px 0;
}
.twin-heating-insights {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}
.twin-heating-insights li {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink);
  padding: 8px 12px;
  background: rgba(124, 58, 237, 0.06);
  border-radius: 8px;
  position: relative;
  padding-left: 26px;
}
.twin-heating-insights li::before {
  content: "✦";
  position: absolute;
  left: 10px;
  top: 8px;
  color: rgba(124, 58, 237, 0.8);
  font-size: 12px;
}

.twin-heating-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 12px;
  align-items: center;
}
.twin-heating-legend-chip {
  display: inline-block;
  width: 18px;
  height: 12px;
  border-radius: 3px;
  margin-right: 4px;
}

/* Timeline */
.twin-heating-timeline {
  margin: 8px 0 18px;
}
.twin-heating-row {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 6px;
}
.twin-heating-row-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  text-align: right;
}
.twin-heating-track {
  position: relative;
  height: 36px;
  background: repeating-linear-gradient(
    to right,
    rgba(15, 30, 55, 0.04) 0,
    rgba(15, 30, 55, 0.04) 1px,
    transparent 1px,
    transparent calc(100% / 24)
  ),
  rgba(15, 30, 55, 0.03);
  border-radius: 6px;
  overflow: hidden;
}
.twin-heating-row-axis .twin-heating-track {
  height: 18px;
  background: transparent;
}
.twin-heating-block {
  position: absolute;
  top: 4px;
  bottom: 4px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.96);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(0, 0, 0, 0.15);
  overflow: hidden;
  cursor: help;
  transition: filter 120ms ease;
}
.twin-heating-block:hover { filter: brightness(1.05); }
.twin-heating-block-label {
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  padding: 0 4px;
}
.twin-heating-block-preheat {
  background: linear-gradient(180deg, rgba(22, 163, 74, 0.95), rgba(21, 128, 61, 0.95));
}
.twin-heating-block-maintain {
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.95), rgba(29, 78, 216, 0.95));
}
.twin-heating-block-coast {
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.95), rgba(217, 119, 6, 0.95));
}
.twin-heating-block-frost {
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.95), rgba(100, 116, 139, 0.95));
}
.twin-heating-block-off {
  background: rgba(148, 163, 184, 0.6);
}
.twin-heating-block-neutral {
  background: rgba(15, 30, 55, 0.25);
}

.twin-heating-axis-tick {
  position: absolute;
  top: 0;
  font-size: 10.5px;
  color: var(--muted);
  transform: translateX(-50%);
}

/* Action buttons */
.twin-heating-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding-top: 6px;
  border-top: 1px dashed rgba(15, 30, 55, 0.1);
}
.twin-heating-button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, rgba(22, 163, 74, 1), rgba(21, 128, 61, 1));
  color: white;
  box-shadow: 0 2px 6px rgba(21, 128, 61, 0.3);
  transition: transform 80ms ease, box-shadow 120ms ease;
}
.twin-heating-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(21, 128, 61, 0.4);
}
.twin-heating-button:disabled {
  background: rgba(15, 30, 55, 0.18);
  color: rgba(15, 30, 55, 0.4);
  cursor: not-allowed;
  box-shadow: none;
}
.twin-heating-button-secondary {
  background: rgba(124, 58, 237, 0.1);
  color: rgba(76, 29, 149, 0.95);
  box-shadow: none;
  border: 1px solid rgba(124, 58, 237, 0.3);
}
.twin-heating-button-secondary:hover {
  background: rgba(124, 58, 237, 0.16);
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.15);
}
.twin-heating-button-done {
  background: rgba(21, 128, 61, 0.18);
  color: rgba(21, 128, 61, 0.95);
  box-shadow: none;
  border: 1px solid rgba(21, 128, 61, 0.4);
}
.twin-heating-receipt {
  font-size: 12.5px;
  color: var(--ink);
  flex: 1;
  min-width: 200px;
}
.twin-heating-receipt strong { color: rgba(21, 128, 61, 0.95); }
.twin-heating-receipt-meta {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}
.twin-heating-receipt-error { color: rgba(185, 28, 28, 0.95); }

.twin-pnl-note {
  font-size: 11.5px;
  color: var(--muted);
  margin: -8px 2px 16px;
  line-height: 1.55;
  background: rgba(245, 158, 11, 0.07);
  border-left: 3px solid rgba(217, 119, 6, 0.45);
  padding: 6px 10px;
  border-radius: 0 6px 6px 0;
}
.twin-pnl-note strong {
  color: rgba(154, 52, 18, 0.92);
}

.twin-appts-bi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.twin-appts-bi-card-wide {
  grid-column: span 1;
}
@media (max-width: 980px) {
  .twin-appts-bi-grid { grid-template-columns: 1fr; }
}
.twin-appts-bi-card {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(15, 30, 55, 0.08);
  border-radius: 14px;
  padding: 14px 16px 16px;
}
.twin-appts-bi-head h3 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--ink);
}
.twin-appts-bi-head p {
  font-size: 12px;
  color: var(--muted);
  margin: 2px 0 12px;
}

/* Donut */
.twin-appts-donut {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}
@media (max-width: 720px) {
  .twin-appts-donut { grid-template-columns: 1fr; }
}
.twin-donut-svg-wrap {
  position: relative;
  width: 160px;
  height: 160px;
}
.twin-donut-svg {
  width: 100%;
  height: 100%;
  display: block;
}
.twin-donut-arc {
  transition: opacity 120ms ease;
}
.twin-donut-arc:hover { opacity: 0.82; }
.twin-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
}
.twin-donut-center-value {
  font-family: "Fraunces", Georgia, serif;
  font-size: 30px;
  line-height: 1;
  font-weight: 700;
  color: rgba(76, 29, 149, 0.95);
}
.twin-donut-center-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-top: 4px;
}
.twin-donut-center-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}
.twin-donut-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 160px;
  width: 160px;
  font-size: 12px;
  color: var(--muted);
  border: 1px dashed rgba(15, 30, 55, 0.12);
  border-radius: 50%;
}
.twin-donut-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
}
.twin-donut-legend-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.twin-donut-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  flex-shrink: 0;
}
.twin-donut-legend-label {
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.twin-donut-legend-value {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.twin-donut-legend-pct {
  color: var(--muted);
}

/* Day-of-week bar */
.twin-appts-dow {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
  height: 160px;
}
.twin-appts-dow-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
}
.twin-appts-dow-bar-wrap {
  flex: 1;
  width: 70%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(15, 30, 55, 0.04);
  border-radius: 6px;
  overflow: hidden;
}
.twin-appts-dow-bar {
  width: 100%;
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.85), rgba(76, 29, 149, 0.95));
  border-radius: 6px 6px 0 0;
  transition: height 200ms ease;
}
.twin-appts-dow-value {
  font-size: 11px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.twin-appts-dow-label {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Punctuality */
.twin-appts-punct {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.twin-appts-punct-bar {
  display: flex;
  width: 100%;
  height: 28px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(15, 30, 55, 0.08);
}
.twin-appts-punct-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
  min-width: 0;
}
.twin-appts-punct-good { background: linear-gradient(180deg, rgba(22, 163, 74, 0.95), rgba(21, 128, 61, 0.95)); }
.twin-appts-punct-watch { background: linear-gradient(180deg, rgba(245, 158, 11, 0.95), rgba(180, 83, 9, 0.95)); }
.twin-appts-punct-alert { background: linear-gradient(180deg, rgba(239, 68, 68, 0.95), rgba(185, 28, 28, 0.95)); }
.twin-appts-punct-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12.5px;
}
.twin-appts-punct-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.twin-appts-punct-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}
.twin-appts-punct-legend-value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.twin-appts-punct-empty,
.twin-appts-punct-meta {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

/* Inline tone accents for the calls answer-rate strip meta text. */
.twin-appts-tone-good { color: #16a34a; }
.twin-appts-tone-watch { color: #d97706; }
.twin-appts-tone-alert { color: #dc2626; }

.twin-heatmap-empty {
  font-size: 13px;
  color: var(--muted);
  padding: 24px 0;
  text-align: center;
}

.twin-occupancy-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.twin-occupancy-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.twin-occupancy-mode {
  display: inline-flex;
  border: 1px solid #d6cebd;
  border-radius: 999px;
  overflow: hidden;
  background: #f6f1e7;
}

.twin-occupancy-mode-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  letter-spacing: 0.02em;
}

.twin-occupancy-mode-btn:hover {
  color: var(--ink);
}

.twin-occupancy-mode-btn.is-active {
  background: var(--ink);
  color: #f6f1e7;
}

.twin-occupancy-zone-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.twin-occupancy-zone-select {
  font: inherit;
  font-size: 13px;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid #d6cebd;
  background: #fbfaf7;
  color: var(--ink);
  min-width: 180px;
}

.twin-heatmap-row-day {
  align-items: stretch;
}

.twin-heatmap-label-stacked {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.1;
  white-space: normal;
}

.twin-heatmap-label-day {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.twin-heatmap-label-date {
  font-size: 11px;
  color: var(--muted);
}

/* ============================================================================
   Occupancy Heatmap — Stirling forest/brass operational restyle.
   Everything is scoped to .twin-occupancy-panel so the SHARED classes it reuses
   (.metric, .usage-chart-summary, .twin-heatmap-cell, .twin-legend-chip) keep
   their existing look in every other panel/heatmap. Forest + brass tokens are
   read straight from stirling-brand.css so the panel reads dark regardless of
   the cool-grey modern.css layer.
   ========================================================================== */
.panel.twin-occupancy-panel {
  background: linear-gradient(165deg, var(--st-forest) 0%, var(--st-forest-d) 100%);
  border: 1px solid rgba(196, 153, 58, 0.45);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(18, 51, 40, 0.22);
}
.twin-occupancy-panel .panel-head h2 {
  font-family: "Fraunces", Georgia, serif;
  color: var(--st-cream);
}
.twin-occupancy-panel #twin-occupancy-subtitle {
  color: rgba(247, 244, 236, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
}
.twin-occupancy-panel .chart-shell {
  /* the day view is two rows — drop the tall fixed plot area */
  min-height: 0;
}

/* --- KPI stat tiles (dark, not the global white .metric) ------------------- */
.twin-occupancy-panel #twin-occupancy-summary {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.twin-occupancy-panel #twin-occupancy-summary .metric {
  background: rgba(8, 24, 18, 0.55);
  border: 1px solid rgba(196, 153, 58, 0.3);
  border-radius: 8px;
  padding: 9px 12px;
}
.twin-occupancy-panel #twin-occupancy-summary .metric-label {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
  color: rgba(151, 188, 98, 0.85);
  margin-bottom: 3px;
}
.twin-occupancy-panel #twin-occupancy-summary .metric-value {
  font-family: "Fraunces", Georgia, serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--st-cream);
}

/* --- segmented Day/Week/Month control ------------------------------------- */
.twin-occupancy-panel .twin-occupancy-mode {
  border: 1px solid rgba(196, 153, 58, 0.4);
  border-radius: 8px;
  background: rgba(8, 24, 18, 0.5);
}
.twin-occupancy-panel .twin-occupancy-mode-btn {
  color: rgba(247, 244, 236, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
  font-weight: 700;
}
.twin-occupancy-panel .twin-occupancy-mode-btn:hover {
  color: var(--st-cream);
}
.twin-occupancy-panel .twin-occupancy-mode-btn.is-active {
  background: var(--st-brass);
  color: #16261e;
}

/* --- zone select (no browser-default look) -------------------------------- */
.twin-occupancy-panel .twin-occupancy-zone-label {
  color: rgba(247, 244, 236, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
}
.twin-occupancy-panel .twin-occupancy-zone-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: rgba(8, 24, 18, 0.6);
  color: var(--st-cream);
  border: 1px solid rgba(196, 153, 58, 0.4);
  border-radius: 8px;
  padding: 6px 28px 6px 10px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%23c4993a' stroke-width='1.6' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 9px center;
}
.twin-occupancy-panel .twin-occupancy-zone-select option {
  color: #16261e;
}

/* --- compact legend chips ------------------------------------------------- */
.twin-occupancy-panel .twin-heatmap-legend {
  gap: 6px;
  margin: 8px 0 12px;
}
.twin-occupancy-panel .twin-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(8, 24, 18, 0.5);
  border: 1px solid rgba(196, 153, 58, 0.25);
  color: rgba(247, 244, 236, 0.8);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.twin-occupancy-panel .twin-legend-item .twin-legend-chip {
  margin-right: 0;
}

/* --- heatmap grid: compact, readable, gold gridlines every 2h ------------- */
.twin-occupancy-panel .twin-heatmap {
  gap: 6px;
  padding: 2px 0 6px;
}
.twin-occupancy-panel .twin-heatmap-row {
  grid-template-columns: 92px 1fr;
  gap: 10px;
}
.twin-occupancy-panel .twin-heatmap-label {
  color: rgba(247, 244, 236, 0.92);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 11px;
  font-weight: 700;
}
.twin-occupancy-panel .twin-heatmap-label-day {
  color: rgba(247, 244, 236, 0.92);
}
.twin-occupancy-panel .twin-heatmap-label-date {
  color: rgba(247, 244, 236, 0.55);
}
/* subtle vertical grid lines every 2 hours (24h / 2 = 12 segments) */
.twin-occupancy-panel .twin-heatmap-cells,
.twin-occupancy-panel .twin-heatmap-axis-cells {
  background-image: repeating-linear-gradient(
    to right,
    rgba(196, 153, 58, 0.18) 0 1px,
    transparent 1px calc(100% / 12)
  );
}
.twin-occupancy-panel .twin-heatmap-cell {
  height: 24px;
  border-radius: 3px;
  background: rgba(247, 244, 236, 0.05);
  border: 1px solid rgba(247, 244, 236, 0.07);
}
.twin-occupancy-panel .twin-heatmap-cell.is-missing {
  background: repeating-linear-gradient(
    45deg,
    rgba(0, 0, 0, 0.22) 0 3px,
    rgba(0, 0, 0, 0.1) 3px 6px
  );
  border-color: rgba(247, 244, 236, 0.05);
}
/* axis labels — bright enough to read, not clipped */
.twin-occupancy-panel .twin-heatmap-axis {
  color: rgba(247, 244, 236, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
}
.twin-occupancy-panel .twin-heatmap-axis-cells {
  color: rgba(247, 244, 236, 0.7);
  font-size: 11px;
  margin-top: 4px;
}
.twin-occupancy-panel .twin-heatmap-axis-cells > span {
  overflow: visible;
}

/* --- sparse / empty designed note ----------------------------------------- */
.twin-occupancy-panel .twin-occupancy-note {
  display: inline-block;
  margin: 0 0 10px;
  padding: 6px 11px;
  border-radius: 8px;
  background: rgba(196, 153, 58, 0.1);
  border: 1px solid rgba(196, 153, 58, 0.28);
  color: var(--st-brass-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.twin-occupancy-panel .twin-heatmap-empty {
  color: rgba(247, 244, 236, 0.6);
}

.twin-heatmap-cell-energy {
  background: rgba(15, 30, 55, 0.04);
  border: 1px solid rgba(15, 30, 55, 0.07);
  transition: filter 120ms ease;
}

.twin-heatmap-cell-energy:hover {
  filter: brightness(1.08);
}

.twin-heatmap-energy .twin-heatmap-label-stacked .twin-heatmap-label-day {
  text-transform: none;
  letter-spacing: 0.01em;
}

.twin-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
  padding: 8px 12px 0;
}

.twin-legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
}

/* ===========================================================
 * Twin v0.3 polish — Building Status, Insights, pills, badges
 * =========================================================== */

.twin-status-panel {
  background: linear-gradient(160deg, #ffffff 0%, #f6f8fc 100%);
  border: 1px solid rgba(15, 30, 55, 0.08);
  border-radius: 18px;
  padding: 22px 26px;
  box-shadow: 0 12px 32px -28px rgba(15, 30, 55, 0.35);
  margin-bottom: 18px;
}

.twin-status-head {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr);
  gap: 24px;
  align-items: flex-start;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(15, 30, 55, 0.07);
}

.twin-status-mode {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.twin-status-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.twin-status-mode-value {
  font-family: "Fraunces", "Manrope", "Segoe UI", serif;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--ink);
}

.twin-status-mode-detail {
  font-size: 13px;
  color: var(--muted);
}

.twin-status-mode-good { color: #047857; }
.twin-status-mode-watch { color: #b45309; }
.twin-status-mode-alert { color: #991b1b; }
.twin-status-mode-neutral { color: var(--ink); }

.twin-status-action {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-left: 3px solid rgba(15, 30, 55, 0.12);
  padding-left: 14px;
}

.twin-status-action-good { border-left-color: #10b981; }
.twin-status-action-watch { border-left-color: #f59e0b; }
.twin-status-action-alert { border-left-color: #ef4444; }
.twin-status-action-neutral { border-left-color: rgba(15, 30, 55, 0.2); }

.twin-status-action-body {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  margin: 0;
  max-width: 70ch;
}

.twin-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding-top: 18px;
}

.twin-status-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(15, 30, 55, 0.08);
  background: #ffffff;
  min-height: 96px;
}

.twin-status-cell-good { border-left: 4px solid #10b981; }
.twin-status-cell-watch { border-left: 4px solid #f59e0b; background: #fffaf0; }
.twin-status-cell-alert { border-left: 4px solid #ef4444; background: #fff5f5; }
.twin-status-cell-neutral { border-left: 4px solid rgba(15, 30, 55, 0.25); }

.twin-status-cell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.twin-status-cell-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.twin-status-cell-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}

.twin-status-cell-detail {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

/* Insights & Actions ---------------------------------------- */

.twin-insights-panel {
  background: #ffffff;
  border: 1px solid rgba(15, 30, 55, 0.08);
  border-radius: 16px;
  padding: 18px 22px;
  margin-bottom: 18px;
}

.twin-insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.twin-insight {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(15, 30, 55, 0.08);
  background: #fbfaf7;
}

.twin-insight-good { border-left: 4px solid #10b981; }
.twin-insight-watch { border-left: 4px solid #f59e0b; background: #fffaf0; }
.twin-insight-alert { border-left: 4px solid #ef4444; background: #fff5f5; }
.twin-insight-neutral { border-left: 4px solid rgba(15, 30, 55, 0.25); }

.twin-insight-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.twin-insight-head h3 {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  margin: 0;
}

.twin-insight-detail {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-soft, #334155);
  margin: 0;
}

.twin-insights-empty {
  font-size: 13px;
  color: var(--muted);
  padding: 14px 4px;
}

/* Severity badges (used inline in KPI trend + insight head) -- */

.twin-severity-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid transparent;
  margin-left: 4px;
}

.twin-severity-good { color: #047857; background: #ecfdf5; border-color: #a7f3d0; }
.twin-severity-watch { color: #92400e; background: #fffbeb; border-color: #fde68a; }
.twin-severity-alert { color: #991b1b; background: #fef2f2; border-color: #fecaca; }
.twin-severity-neutral { color: #334155; background: #f1f5f9; border-color: #cbd5e1; }

/* Data-type pills (Measured / Inferred / Forecast / Missing)  */

.twin-source-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.twin-source-measured { color: #166534; background: #f0fdf4; border-color: #bbf7d0; }
.twin-source-inferred { color: #1e3a8a; background: #eff6ff; border-color: #bfdbfe; }
.twin-source-forecast { color: #6b21a8; background: #faf5ff; border-color: #e9d5ff; }
.twin-source-missing { color: #64748b; background: #f8fafc; border-color: #cbd5e1; }

.twin-kpi {
  position: relative;
}

.twin-kpi-pill {
  margin-left: auto;
}

.twin-kpi .kpi-head {
  align-items: center;
  gap: 8px;
}

/* Tighter responsive layout for tablet (and below) ---------- */

@media (max-width: 960px) {
  .twin-status-head {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .twin-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .twin-status-mode-value {
    font-size: 24px;
  }
  .twin-occupancy-head {
    flex-direction: column;
    align-items: stretch;
  }
  .twin-occupancy-controls {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .twin-status-grid {
    grid-template-columns: 1fr;
  }
  .twin-status-panel,
  .twin-insights-panel {
    padding: 16px 18px;
  }
  .twin-status-mode-value {
    font-size: 22px;
  }
}

.twin-forecast-unavailable {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  border-radius: 12px;
  border: 1px dashed rgba(15, 30, 55, 0.2);
  background: #fbfaf7;
}

.twin-forecast-unavailable h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.twin-forecast-unavailable p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  max-width: 56ch;
}

/* Chart tooltips ------------------------------------------- */

.twin-tooltip {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(0, 4px, 0);
  transition: opacity 100ms ease, transform 100ms ease;
  background: rgba(15, 30, 55, 0.95);
  color: #f8fafc;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.45;
  max-width: 280px;
  box-shadow: 0 18px 40px -16px rgba(15, 30, 55, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.twin-tooltip.is-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.twin-tooltip-title {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}

.twin-tooltip-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: rgba(248, 250, 252, 0.78);
}

.twin-tooltip-meta strong {
  color: #f8fafc;
  font-weight: 600;
}

[data-tooltip] {
  cursor: default;
}

/* Step-up email-OTP modal --------------------------------- */

.auth-stepup-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.auth-stepup-modal.hidden {
  display: none;
}

.auth-stepup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 30, 55, 0.72);
  backdrop-filter: blur(2px);
}

.auth-stepup-card {
  position: relative;
  max-width: 460px;
  width: 100%;
  background: #ffffff;
  border-radius: 18px;
  padding: 28px 30px;
  box-shadow: 0 30px 60px -20px rgba(15, 30, 55, 0.45);
  border: 1px solid rgba(15, 30, 55, 0.06);
}

.auth-stepup-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #b45309;
  margin-bottom: 10px;
}

.auth-stepup-card h2 {
  font-family: "Fraunces", "Manrope", "Segoe UI", serif;
  font-size: 24px;
  margin: 0 0 8px;
  color: #0f1e37;
}

.auth-stepup-card p {
  font-size: 13px;
  color: #475569;
  line-height: 1.55;
  margin: 0 0 18px;
}

.auth-stepup-step {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-stepup-step.hidden {
  display: none;
}

.auth-stepup-primary,
.auth-stepup-secondary {
  appearance: none;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 11px 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
}

.auth-stepup-primary {
  background: #0f1e37;
  color: #f8fafc;
}

.auth-stepup-primary:hover:not(:disabled) {
  background: #1e2c4d;
}

.auth-stepup-primary:disabled {
  background: #94a3b8;
  cursor: progress;
}

.auth-stepup-secondary {
  background: transparent;
  color: #0f1e37;
  border-color: rgba(15, 30, 55, 0.18);
}

.auth-stepup-secondary:hover:not(:disabled) {
  background: rgba(15, 30, 55, 0.04);
}

.auth-stepup-secondary:disabled {
  color: #94a3b8;
  border-color: rgba(15, 30, 55, 0.08);
  cursor: not-allowed;
}

.auth-stepup-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-stepup-label span {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.auth-stepup-input {
  font: inherit;
  font-size: 22px;
  letter-spacing: 0.4em;
  text-align: center;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(15, 30, 55, 0.15);
  background: #fbfaf7;
  color: #0f1e37;
  width: 100%;
  box-sizing: border-box;
}

.auth-stepup-input:focus {
  outline: 3px solid rgba(15, 30, 55, 0.12);
  outline-offset: 1px;
  border-color: rgba(15, 30, 55, 0.4);
}

.auth-stepup-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-stepup-hint {
  font-size: 12px;
  color: #64748b;
  margin: 0;
}

.auth-stepup-error {
  font-size: 13px;
  color: #b91c1c;
  margin: 0;
  min-height: 1.2em;
}

.auth-stepup-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(15, 30, 55, 0.08);
  text-align: right;
}

.auth-stepup-logout {
  font-size: 12px;
  color: #64748b;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.auth-stepup-logout:hover {
  color: #0f1e37;
}

body.auth-stepup-locked {
  overflow: hidden;
}


/* App-layer login form (replaces SWA EasyAuth front door). Used on
   /portal-login and on the Digital Twin gate panel. */
.portal-login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 360px;
  margin: 16px 0 0;
}
.portal-login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.portal-login-label {
  font-size: 13px;
  color: var(--muted, #4a5b78);
  letter-spacing: 0.02em;
}
.portal-login-form input {
  font: inherit;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.portal-login-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.portal-login-form button[type="submit"] {
  align-self: flex-start;
}
.portal-login-error {
  min-height: 1.2em;
  margin: 0;
  font-size: 13px;
  color: var(--status-alert-ink);
}

/* Vertical sign-in stack: primary AAD button on top, divider, then the
   secondary portal-password form. Used on /portal-login and the DT gate. */
.portal-login-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 360px;
  margin: 16px 0 0;
}
.portal-login-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 8px;
  text-decoration: none;
  transition: background 120ms ease, transform 120ms ease;
}
.portal-login-primary:hover {
  background: var(--accent-strong);
}
.portal-login-aad-icon {
  display: inline-block;
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
}
.portal-login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 0;
  color: var(--muted, #4a5b78);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.portal-login-divider::before,
.portal-login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.portal-login-divider span {
  white-space: nowrap;
}
.portal-login-form {
  margin: 0;
}

/* Sellable capacity panel (Phase A of rota optimisation brief). Green
   intensity tiers signal "money on the table" — distinct from violet
   (home-support actuals) and amber (calls). */
.twin-heatmap-sellable .twin-heatmap-cells-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.twin-heatmap-row .twin-heatmap-axis-cells.twin-heatmap-cells-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  font-size: 11px;
  color: var(--muted, #4a5b78);
  text-align: center;
}
.twin-sellable-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 6px;
  background: rgba(15, 30, 55, 0.04);
}
.twin-sellable-cell-label {
  font-size: 11px;
  color: rgba(15, 30, 55, 0.85);
  font-variant-numeric: tabular-nums;
  position: relative;
  z-index: 2;
}
.twin-heatmap-cell.is-sellable-l1 { background: rgba(34, 197, 94, 0.22); }
.twin-heatmap-cell.is-sellable-l2 { background: rgba(22, 163, 74, 0.42); }
.twin-heatmap-cell.is-sellable-l3 { background: rgba(21, 128, 61, 0.65); }
.twin-heatmap-cell.is-sellable-l3 .twin-sellable-cell-label { color: #fff; }

.twin-sellable-slots {
  overflow-x: auto;
}
.twin-sellable-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.twin-sellable-table thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #4a5b78);
  padding: 8px 8px 6px;
  border-bottom: 1px solid rgba(15, 30, 55, 0.1);
  white-space: nowrap;
}
.twin-sellable-table tbody td {
  padding: 8px;
  border-bottom: 1px solid rgba(15, 30, 55, 0.06);
  vertical-align: top;
}
.twin-sellable-table tbody tr:hover {
  background: rgba(34, 197, 94, 0.04);
}
.twin-sellable-rank {
  font-weight: 700;
  color: #16a34a;
  width: 28px;
}
.twin-sellable-area {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.14);
  color: #166534;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.02em;
}
.twin-sellable-duration {
  color: var(--muted, #4a5b78);
  font-size: 11px;
  margin-left: 4px;
}

/* AI-generated weekly sales briefing — sits between the KPI strip and
   the heatmap on the sellable-slots panel. Soft green border signals
   "money commentary" without screaming AI. */
.twin-sellable-briefing {
  margin: 12px 0 0;
  padding: 16px 18px;
  background: rgba(34, 197, 94, 0.05);
  border: 1px solid rgba(34, 197, 94, 0.22);
  border-left: 3px solid #16a34a;
  border-radius: 8px;
}
.twin-sellable-briefing-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.twin-sellable-briefing-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #166534;
  letter-spacing: 0.01em;
}
.twin-sellable-briefing-meta {
  font-size: 11px;
  color: var(--muted, #4a5b78);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.twin-sellable-briefing-body {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: #0f1e37;
  white-space: pre-wrap;
}

/* Glossary tooltips (infoTip) ------------------------------ */
.portal-infotip { position: relative; display: inline-flex; vertical-align: middle; margin-left: 4px; cursor: help; outline: none; }
.portal-infotip-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%;
  border: 1px solid var(--muted, #8a8f98); color: var(--muted, #8a8f98);
  font-size: 10px; font-style: italic; font-weight: 700; font-family: Georgia, "Times New Roman", serif; line-height: 1;
  transition: border-color .12s ease, color .12s ease;
}
.portal-infotip:hover .portal-infotip-dot,
.portal-infotip:focus-visible .portal-infotip-dot { border-color: var(--accent, var(--status-ok-ink)); color: var(--accent, var(--status-ok-ink)); }
.portal-infotip:focus-visible { outline: 2px solid var(--accent, var(--status-ok-ink)); outline-offset: 2px; border-radius: 50%; }
.portal-infotip-bubble {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 250px;
  background: #1e2329; color: #f3f5f7; padding: 8px 11px; border-radius: 8px;
  font-size: 12.5px; line-height: 1.45; font-weight: 400; text-align: left; letter-spacing: 0;
  box-shadow: 0 8px 28px rgba(0,0,0,.28);
  opacity: 0; visibility: hidden; transition: opacity .12s ease; z-index: 60; pointer-events: none; white-space: normal;
}
.portal-infotip-bubble strong { display: block; margin: 0 0 3px; font-weight: 700; }
.portal-infotip-bubble::after {
  content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: #1e2329;
}
.portal-infotip:hover .portal-infotip-bubble,
.portal-infotip:focus .portal-infotip-bubble,
.portal-infotip:focus-within .portal-infotip-bubble { opacity: 1; visibility: visible; }
/* keep the bubble on-screen near the right edge */
@media (max-width: 560px) { .portal-infotip-bubble { left: auto; right: 0; transform: none; } .portal-infotip-bubble::after { left: auto; right: 4px; transform: none; } }

/* Property Dynamics capture form */
.pd-form { display: grid; gap: var(--s-4, 16px); }
.pd-section { border: 1px solid var(--border, #e2e2e2); border-radius: 10px; padding: 12px 14px; }
.pd-section legend { font-weight: 650; padding: 0 6px; font-size: 13px; }
.pd-section-sensitive { border-color: #d8b24a; background: #fffaf0; }
.pd-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 14px; }
.pd-field { display: grid; gap: 3px; min-width: 0; }
.pd-field > span { font-size: 12px; color: var(--muted, #6b6b6b); }
.pd-field select, .pd-field input, .pd-field textarea { padding: 6px 8px; border: 1px solid var(--border, #d6d6d6); border-radius: 7px; font: inherit; width: 100%; box-sizing: border-box; }
.pd-field-wide { grid-column: 1 / -1; }
.pd-consent { display: flex; gap: 8px; align-items: center; margin: 6px 0 10px; font-size: 13px; }
.pd-actions { display: flex; gap: 12px; align-items: center; }

/* ============================================================================
   Visual Refresh R3 (2026-06-20) — accessibility pass for portal controls.
   Keyboard focus was invisible on chips/presets/cards; tap targets on the
   date presets and site chips fell short of the 44px minimum. Scoped to the
   portal so other products are untouched.
   ========================================================================== */
.portal-site-chip:focus-visible,
.portal-date-preset:focus-visible,
.portal-view-button:focus-visible,
.portal-link-button:focus-visible,
.portal-customer-card:focus-visible,
.portal-portfolio-site-card:focus-visible,
.portal-card-onboarding a:focus-visible,
.site-grid__card:focus-visible,
.insight-row:focus-visible,
.adviser-tab:focus-visible,
.portal-tab:focus-visible {
  outline: 2px solid var(--c-gold);
  outline-offset: 2px;
}
/* Meet the 44px minimum tap target (these sat at ~36–38px). */
.portal-date-preset { min-height: 44px; }
.portal-site-chip { min-height: 44px; }
