:root {
  color-scheme: dark;

  --page: #121b2b;
  --page-soft: #172235;
  --header: #111c2d;
  --panel: #1b2a40;
  --panel-soft: #263954;
  --panel-hover: #2b405f;
  --border: rgba(180, 197, 220, 0.26);
  --border-strong: rgba(180, 197, 220, 0.38);

  --text: #eef4fb;
  --text-soft: #d7e2f0;
  --muted: #aebbd0;
  --faint: #8493aa;

  --blue: #60a5fa;
  --green: #4ade80;
  --red: #fb7185;
  --gold: #fbbf24;
  --orange: #fb923c;
  --purple: #c084fc;

  --shadow: 0 18px 42px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(96, 165, 250, 0.12), transparent 34rem),
    radial-gradient(circle at top right, rgba(74, 222, 128, 0.07), transparent 30rem),
    linear-gradient(180deg, var(--page-soft) 0%, var(--page) 52%, #101827 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-loading {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--text);
}

.app-loading span {
  display: block;
  color: var(--muted);
  margin-top: 0.2rem;
}

.loading-mark,
.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #263954, #101827);
  border: 1px solid rgba(96, 165, 250, 0.45);
  color: var(--text);
  font-weight: 850;
  letter-spacing: -0.03em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 10px 26px rgba(0, 0, 0, 0.24);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 68px;
  padding: 0.8rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, rgba(21, 33, 52, 0.98), rgba(17, 28, 45, 0.98));
  border-bottom: 1px solid rgba(180, 197, 220, 0.2);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand h1 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.15;
  color: var(--text);
}

.brand p {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 800;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 14px var(--green);
}

.tabs {
  position: sticky;
  top: 68px;
  z-index: 19;
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  padding: 0 1.25rem;
  overflow-x: auto;
  background: rgba(18, 29, 47, 0.97);
  border-bottom: 1px solid rgba(180, 197, 220, 0.24);
}

.tab {
  appearance: none;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: #c7d3e5;
  padding: 0.72rem 1rem;
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 650;
}

.tab:hover {
  background: rgba(96, 165, 250, 0.1);
  color: var(--text);
  border-color: rgba(147, 197, 253, 0.2);
}

.tab.active {
  background: rgba(96, 165, 250, 0.16);
  color: var(--text);
  border-color: rgba(147, 197, 253, 0.36);
  border-bottom-color: var(--blue);
}

.app-main {
  width: min(1320px, calc(100vw - 2rem));
  margin: 1.15rem auto 3rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.zone-card,
.mini-card,
.panel,
.forecast-card {
  background: linear-gradient(180deg, rgba(38, 57, 84, 0.98), rgba(24, 38, 59, 0.98));
  border: 1px solid var(--border);
  border-radius: 15px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.055);
}

.zone-card {
  position: relative;
  min-height: 214px;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  overflow: hidden;
  border-top: 4px solid var(--zone-color, var(--blue));
}

.zone-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--zone-color, var(--blue));
}

.zone-card:hover,
.panel:hover,
.forecast-card:hover,
.mini-card:hover {
  border-color: rgba(147, 197, 253, 0.45);
}

.zone-card-title {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  color: #c7d3e5;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.zone-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--zone-color, var(--blue));
  box-shadow: 0 0 12px var(--zone-color, var(--blue));
}

.zone-temp {
  margin-top: 0.55rem;
  color: var(--text);
  font-size: 2rem;
  line-height: 1;
  font-weight: 850;
}

.zone-sub {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.zone-summary {
  margin-top: auto;
  padding-top: 0.78rem;
  border-top: 1px solid rgba(180, 197, 220, 0.2);
}

.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.summary-header > span {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.summary-grid div {
  background: rgba(11, 18, 32, 0.32);
  border: 1px solid rgba(180, 197, 220, 0.16);
  border-radius: 10px;
  padding: 0.43rem 0.38rem;
  text-align: center;
}

.summary-grid span {
  display: block;
  color: #9fb0c7;
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.18rem;
}

.summary-grid strong {
  color: var(--text);
  font-size: 0.9rem;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  width: fit-content;
  margin-top: 0.42rem;
  padding: 0.24rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 850;
  border: 1px solid currentColor;
  background: rgba(255, 255, 255, 0.04);
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 12px currentColor;
}

.status-comfortable,
.status-normal {
  color: var(--green);
  background: rgba(74, 222, 128, 0.12);
}

.status-hot {
  color: var(--red);
  background: rgba(251, 113, 133, 0.13);
}

.status-warm,
.status-unknown {
  color: var(--gold);
  background: rgba(251, 191, 36, 0.13);
}

.status-cool {
  color: var(--blue);
  background: rgba(96, 165, 250, 0.13);
}

.panel {
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.panel h2 {
  margin: 0 0 0.2rem;
  color: var(--text);
  font-size: 1rem;
}

.panel p {
  margin: 0;
  color: var(--muted);
  font-size: 0.83rem;
}

.panel-foot {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

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

.chart-wrap {
  height: 320px;
  width: 100%;
}

.chart-wrap svg {
  width: 100%;
  height: 100%;
}

.chart-grid {
  stroke: rgba(180, 197, 220, 0.16);
  stroke-width: 1;
}

.chart-label {
  fill: var(--muted);
  font-size: 12px;
}

.empty-chart {
  height: 280px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed rgba(180, 197, 220, 0.25);
  border-radius: 12px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin-top: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text-soft);
  font-size: 0.84rem;
}

th,
td {
  border-bottom: 1px solid rgba(180, 197, 220, 0.16);
  padding: 0.7rem 0.75rem;
  text-align: left;
}

th {
  color: var(--muted);
  background: rgba(11, 18, 32, 0.2);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

tr:hover td {
  background: rgba(96, 165, 250, 0.06);
}

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

.mini-card {
  padding: 1rem;
}

.mini-card span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mini-card strong {
  display: block;
  margin-top: 0.35rem;
  color: var(--text);
  font-size: 1.35rem;
}

.forecast-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.75rem;
}

.forecast-card {
  padding: 0.85rem;
}

.forecast-card.show-day {
  border-color: rgba(251, 191, 36, 0.44);
}

.forecast-card span,
.forecast-card small {
  color: var(--muted);
  font-size: 0.72rem;
}

.forecast-card strong {
  display: block;
  color: var(--text);
  margin: 0.35rem 0;
  font-size: 1.1rem;
}

.forecast-card p {
  color: var(--text-soft);
  margin: 0 0 0.45rem;
}

.status-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: rgba(27, 41, 61, 0.98);
  border: 1px solid rgba(180, 197, 220, 0.22);
  border-left: 4px solid var(--green);
  border-radius: 12px;
  padding: 0.85rem 1rem;
}

.status-row strong {
  color: var(--text);
}

.status-row span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  margin-top: 0.15rem;
}

.status-row-grid {
  display: grid;
  grid-template-columns: repeat(4, max-content);
  gap: 0.75rem;
  align-items: center;
}

.status-row-grid span {
  margin: 0;
}

.status-row-grid b {
  color: var(--text);
}

.recommendations {
  color: var(--text-soft);
  line-height: 1.65;
}

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

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

  .panel-header,
  .status-row {
    flex-direction: column;
    align-items: stretch;
  }

  .legend {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .app-main {
    width: min(100vw - 1rem, 1320px);
  }

  .app-header {
    position: static;
  }

  .tabs {
    top: 0;
  }

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

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

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

/* ============================================================
   Restored Function Sections
   ============================================================ */

.report-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.forecast-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.forecast-top b {
  color: var(--gold);
  font-size: 0.68rem;
  border: 1px solid rgba(251, 191, 36, 0.36);
  background: rgba(251, 191, 36, 0.12);
  border-radius: 999px;
  padding: 0.18rem 0.48rem;
}

.forecast-card[data-risk="hot"] {
  border-color: rgba(251, 113, 133, 0.45);
}

.forecast-card[data-risk="warm"] {
  border-color: rgba(251, 191, 36, 0.42);
}

.show-day-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.show-day-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: rgba(27, 41, 61, 0.98);
  border: 1px solid rgba(180, 197, 220, 0.22);
  border-left: 4px solid var(--blue);
  border-radius: 12px;
  padding: 0.85rem 1rem;
}

.show-day-row[data-risk="hot"] {
  border-left-color: var(--red);
}

.show-day-row[data-risk="warm"] {
  border-left-color: var(--gold);
}

.show-day-row strong {
  color: var(--text);
}

.show-day-row span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}

.threshold-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.threshold-grid article,
.estimator-card {
  background: rgba(11, 18, 32, 0.28);
  border: 1px solid rgba(180, 197, 220, 0.18);
  border-radius: 12px;
  padding: 0.85rem;
}

.threshold-grid span,
.estimator-card span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.threshold-grid strong,
.estimator-card strong {
  display: block;
  margin-top: 0.28rem;
  color: var(--text);
  font-size: 1.18rem;
}

.threshold-grid p,
.estimator-card p {
  color: var(--text-soft);
  margin: 0.45rem 0 0;
  font-size: 0.8rem;
  line-height: 1.45;
}

.estimator-card {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.estimator-card p {
  grid-column: 1 / -1;
  border-top: 1px solid rgba(180, 197, 220, 0.16);
  padding-top: 0.75rem;
}

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

  .estimator-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .report-grid,
  .threshold-grid {
    grid-template-columns: 1fr;
  }

  .show-day-row {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ============================================================
   Restored dashboard function sections — patch layer
   ============================================================ */

.summary-strip,
.report-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.mini-card.compact em,
.mini-card em {
  display: inline-flex;
  width: fit-content;
  margin-top: 0.45rem;
  font-style: normal;
  color: var(--muted);
  font-size: 0.75rem;
}

.note-grid,
.threshold-grid,
.checklist-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

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

.note-grid article,
.threshold-grid article,
.checklist-grid article,
.estimator-card {
  background: rgba(11, 18, 32, 0.28);
  border: 1px solid rgba(180, 197, 220, 0.18);
  border-radius: 12px;
  padding: 0.85rem;
}

.note-grid strong,
.threshold-grid strong,
.checklist-grid strong,
.estimator-card strong {
  display: block;
  color: var(--text);
  font-size: 1.08rem;
  margin-bottom: 0.25rem;
}

.note-grid span,
.threshold-grid span,
.checklist-grid span,
.estimator-card span {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.threshold-grid span,
.estimator-card span {
  display: block;
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.threshold-grid p,
.estimator-card p {
  color: var(--text-soft);
  margin: 0.45rem 0 0;
  font-size: 0.8rem;
  line-height: 1.45;
}

.forecast-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.forecast-top b {
  color: var(--gold);
  font-size: 0.68rem;
  border: 1px solid rgba(251, 191, 36, 0.36);
  background: rgba(251, 191, 36, 0.12);
  border-radius: 999px;
  padding: 0.18rem 0.48rem;
}

.forecast-card[data-risk="hot"],
.show-day-row[data-risk="hot"] {
  border-color: rgba(251, 113, 133, 0.45);
}

.forecast-card[data-risk="warm"],
.show-day-row[data-risk="warm"] {
  border-color: rgba(251, 191, 36, 0.42);
}

.show-day-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.show-day-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: rgba(27, 41, 61, 0.98);
  border: 1px solid rgba(180, 197, 220, 0.22);
  border-left: 4px solid var(--blue);
  border-radius: 12px;
  padding: 0.85rem 1rem;
}

.show-day-row[data-risk="hot"] {
  border-left-color: var(--red);
}

.show-day-row[data-risk="warm"] {
  border-left-color: var(--gold);
}

.show-day-row strong {
  color: var(--text);
}

.show-day-row span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}

.estimator-card {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.estimator-card p {
  grid-column: 1 / -1;
  border-top: 1px solid rgba(180, 197, 220, 0.16);
  padding-top: 0.75rem;
}

.status-row-grid {
  grid-template-columns: repeat(5, max-content);
}

.danger-panel {
  border-color: rgba(251, 113, 133, 0.45);
}

@media (max-width: 1100px) {
  .summary-strip,
  .report-grid,
  .note-grid,
  .threshold-grid,
  .checklist-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .estimator-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .summary-strip,
  .report-grid,
  .note-grid,
  .threshold-grid,
  .checklist-grid {
    grid-template-columns: 1fr;
  }

  .show-day-row {
    flex-direction: column;
    align-items: stretch;
  }

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

/* ============================================================
   Restored Energy / Cost / Report Function Sections
   ============================================================ */
.rate-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border: 1px solid rgba(96, 165, 250, 0.34);
  background: rgba(96, 165, 250, 0.12);
  color: #bfdbfe;
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

.cost-grid,
.report-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.cost-grid article,
.threshold-grid article,
.estimator-card,
.recommendation-list article {
  background: rgba(11, 18, 32, 0.28);
  border: 1px solid rgba(180, 197, 220, 0.18);
  border-radius: 12px;
  padding: 0.85rem;
}

.cost-grid span,
.estimator-card span,
.threshold-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.cost-grid strong,
.estimator-card strong,
.threshold-grid strong {
  display: block;
  margin-top: 0.28rem;
  color: var(--text);
  font-size: 1.18rem;
}

.cost-grid small,
.estimator-card small {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.forecast-top,
.show-day-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.forecast-top b {
  color: var(--gold);
  font-size: 0.68rem;
  border: 1px solid rgba(251, 191, 36, 0.36);
  background: rgba(251, 191, 36, 0.12);
  border-radius: 999px;
  padding: 0.18rem 0.48rem;
}

.show-day-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.show-day-row {
  background: rgba(27, 41, 61, 0.98);
  border: 1px solid rgba(180, 197, 220, 0.22);
  border-left: 4px solid var(--blue);
  border-radius: 12px;
  padding: 0.85rem 1rem;
}

.show-day-row[data-risk="hot"] { border-left-color: var(--red); }
.show-day-row[data-risk="warm"] { border-left-color: var(--gold); }

.show-day-row strong { color: var(--text); }
.show-day-row span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}

.show-day-metrics {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.show-day-metrics span {
  border: 1px solid rgba(180, 197, 220, 0.16);
  background: rgba(11, 18, 32, 0.24);
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
}

.estimator-card {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.estimator-card p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--text-soft);
  border-top: 1px solid rgba(180, 197, 220, 0.16);
  padding-top: 0.75rem;
  line-height: 1.45;
}

.zone-name-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.zone-name-cell i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}

.recommendation-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.recommendation-list article {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.recommendation-list span {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(96, 165, 250, 0.12);
  color: var(--blue);
}

.recommendation-list p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.45;
}

@media (max-width: 1100px) {
  .cost-grid,
  .report-grid,
  .estimator-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .show-day-row {
    flex-direction: column;
    align-items: stretch;
  }

  .show-day-metrics {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .cost-grid,
  .report-grid,
  .estimator-card {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Live Data Pipeline / Collector Status
   ============================================================ */

.live-health-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
  margin: 0 0 1rem;
}

.health-card {
  min-height: 118px;
}

.health-card p {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.health-card .status {
  display: inline-flex;
  margin-top: 0.35rem;
}

.zone-card[data-status="normal"]::before,
.zone-card[data-status="comfortable"]::before {
  background: var(--green);
}

.zone-card[data-status="warm"]::before {
  background: var(--gold);
}

.zone-card[data-status="hot"]::before {
  background: var(--red);
}

.zone-card[data-status="unknown"]::before {
  background: var(--gold);
}

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

@media (max-width: 680px) {
  .live-health-grid {
    grid-template-columns: 1fr;
  }
}

/* Offline / communication-lost climate zones */
.zone-card[data-status="offline"] {
  border-color: rgba(251, 113, 133, 0.55);
  border-top-color: var(--red) !important;
  background:
    radial-gradient(circle at top right, rgba(251, 113, 133, 0.13), transparent 13rem),
    linear-gradient(180deg, rgba(61, 39, 52, 0.98), rgba(31, 38, 55, 0.98));
}

.zone-card[data-status="offline"]::before {
  background: var(--red);
}

.status-offline {
  color: var(--red);
  background: rgba(251, 113, 133, 0.13);
}

.zone-offline-detail {
  color: #fecdd3 !important;
  font-weight: 800;
}

.status-row[data-status="offline"] {
  border-left-color: var(--red);
}

/* Offline-aware live climate UI */
.zone-card[data-status="offline"] {
  border-color: rgba(251, 113, 133, 0.58);
  border-top-color: var(--red);
}

.zone-card[data-status="offline"]::before {
  background: var(--red);
}

.status-offline {
  color: var(--red);
  background: rgba(251, 113, 133, 0.13);
}

.danger-text {
  color: var(--red) !important;
  font-weight: 800;
}

.status-row[data-status="offline"] {
  border-left-color: var(--red);
  border-color: rgba(251, 113, 133, 0.34);
}

.live-health-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

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

@media (max-width: 680px) {
  .live-health-grid {
    grid-template-columns: 1fr;
  }
}

/* Offline-aware zone display correction */
.zone-card[data-status="offline"] {
  border-color: rgba(251, 113, 133, 0.48);
  border-top-color: var(--red) !important;
}

.zone-card[data-status="offline"]::before {
  background: var(--red);
}

.status-offline {
  color: var(--red);
  background: rgba(251, 113, 133, 0.13);
}

/* Offline / communication lost zone support */
.zone-card[data-status="offline"] { border-color: rgba(251, 113, 133, 0.52); }
.zone-card[data-status="offline"]::before { background: var(--red); }
.status-offline { color: var(--red); background: rgba(251, 113, 133, 0.13); }

/* Offline-aware frontend repair */
.zone-card[data-status="offline"],
.status-row[data-status="offline"] {
  border-color: rgba(251, 113, 133, 0.44) !important;
  border-left-color: #fb7185 !important;
}
.status-offline {
  color: #fb7185;
  background: rgba(251, 113, 133, 0.13);
}
.header-actions {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 0.18rem;
}
.header-actions small {
  color: var(--muted);
  font-size: 0.72rem;
}
.summary-strip,
.live-health-grid,
.report-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}
.live-health-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.mini-card.compact em,
.health-card p {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 0.25rem;
  font-style: normal;
}
@media (max-width: 1100px) {
  .summary-strip,
  .live-health-grid,
  .report-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .summary-strip,
  .live-health-grid,
  .report-grid { grid-template-columns: 1fr; }
}

/* SMECO billing aggregation additions */
.energy-grid .mini-card strong,
.report-grid .mini-card strong {
  overflow-wrap: anywhere;
}

.table-wrap td:nth-child(5),
.table-wrap th:nth-child(5) {
  text-transform: capitalize;
}


/* SMECO data tab */
.data-panel-header {
  align-items: flex-end;
  gap: 1rem;
}

.data-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.data-controls label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-controls select {
  min-width: 170px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.78);
  color: var(--text);
  padding: 0.7rem 0.85rem;
  outline: none;
}

.data-view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.pill-button {
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.74);
  color: var(--muted);
  padding: 0.6rem 0.9rem;
  font-weight: 800;
  cursor: pointer;
}

.pill-button.active,
.pill-button:hover {
  color: var(--text);
  border-color: rgba(96, 165, 250, 0.48);
  background: rgba(37, 99, 235, 0.18);
}

.data-summary-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.data-table-wrap {
  max-height: 68vh;
  overflow: auto;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(15, 23, 42, 0.96);
}

.data-table td,
.data-table th {
  white-space: nowrap;
  vertical-align: top;
}

.interval-table td:last-child {
  min-width: 380px;
  max-width: 720px;
  white-space: normal;
  word-break: break-word;
  color: var(--muted);
  font-size: 0.74rem;
}

.interval-table code {
  color: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.data-note {
  border: 1px solid rgba(250, 204, 21, 0.22);
  background: rgba(250, 204, 21, 0.08);
  color: #fde68a;
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
}

@media (max-width: 900px) {
  .data-summary-strip { grid-template-columns: 1fr; }
  .data-panel-header { align-items: flex-start; }
}


/* SMECO expandable data table */
.expandable-data-table th:first-child,
.expandable-data-table td:first-child {
  width: 44px;
  text-align: center;
}

.row-expander {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(96, 165, 250, 0.45);
  background: rgba(37, 99, 235, 0.16);
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
  line-height: 1;
}

.row-expander.small {
  width: 24px;
  height: 24px;
  font-size: 0.8rem;
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.78);
}

.data-day-row.is-expanded td {
  background: rgba(37, 99, 235, 0.10);
  border-top: 1px solid rgba(96, 165, 250, 0.22);
}

.data-hour-row td {
  background: rgba(15, 23, 42, 0.45);
  color: var(--muted);
}

.data-hour-row.is-expanded td {
  background: rgba(14, 165, 233, 0.10);
  color: var(--text);
}

.data-interval-detail-row td {
  background: rgba(2, 6, 23, 0.38);
  border-bottom: 1px solid rgba(148, 163, 184, 0.10);
}

.interval-detail-card {
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.54);
  border-radius: 14px;
  padding: 0.75rem;
  margin: 0.25rem 0;
}

.interval-detail-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 0.65rem;
}

.interval-detail-grid span {
  display: grid;
  gap: 0.18rem;
  color: var(--text);
}

.interval-detail-grid strong {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.interval-detail-card details {
  margin-top: 0.6rem;
  color: var(--muted);
}

.interval-detail-card code {
  display: block;
  margin-top: 0.45rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.72rem;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .interval-detail-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

/* SMECO Data tab cleanup: hide source and interval-count summary columns if semantic markers exist. */
[data-smeco-column="source"],
[data-smeco-column="intervals"],
[data-column="source"],
[data-column="intervals"],
.cm-smeco-source-column,
.cm-smeco-interval-count-column {
  display: none !important;
}

/* SMECO Data tab clean drill-down */
.clean-data-table-panel {
  overflow: hidden;
}

.clean-data-table-wrap {
  max-height: calc(100vh - 320px);
  overflow: auto;
}

.clean-data-table th,
.clean-data-table td {
  vertical-align: middle;
}

.clean-data-table .data-day-row.is-expanded td {
  background: rgba(84, 123, 184, 0.16);
}

.clean-data-table .data-hour-row td {
  background: rgba(56, 96, 132, 0.18);
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.clean-data-table .data-hour-row td:nth-child(2) {
  padding-left: 1.4rem;
}

.data-interval-detail-row > td {
  background: rgba(7, 15, 30, 0.38) !important;
  padding-top: 0.55rem;
  padding-bottom: 0.75rem;
}

.interval-clean-panel {
  margin: 0.2rem 0 0.35rem 2.7rem;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.52);
}

.interval-clean-table {
  width: 100%;
  border-collapse: collapse;
}

.interval-clean-table th {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(203, 213, 225, 0.78);
  background: rgba(15, 23, 42, 0.72);
  padding: 0.65rem 0.85rem;
  text-align: left;
}

.interval-clean-table td {
  padding: 0.6rem 0.85rem;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  background: transparent !important;
}

.interval-detail-card,
.interval-detail-grid,
.interval-detail-card details {
  display: none !important;
}


/* Enriched AC unit details on Live cards */
.cm-live-ac-card-enriched {
  position: relative;
}

.cm-live-ac-details {
  margin-top: 0.85rem;
  padding: 0.85rem;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 1rem;
  background: rgba(15, 23, 42, 0.35);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.cm-live-ac-details__header,
.cm-live-ac-status-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.cm-live-ac-details__header {
  margin-bottom: 0.65rem;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(226, 232, 240, 0.72);
}

.cm-live-ac-details__header strong,
.cm-live-ac-status-list strong {
  color: #e5edf7;
  font-weight: 750;
}

.cm-live-ac-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.cm-live-ac-detail-grid > div {
  padding: 0.55rem 0.6rem;
  border-radius: 0.8rem;
  background: rgba(30, 41, 59, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.14);
}

.cm-live-ac-detail-grid span,
.cm-live-ac-status-list span {
  display: block;
  font-size: 0.72rem;
  line-height: 1.1;
  color: rgba(203, 213, 225, 0.72);
}

.cm-live-ac-detail-grid strong {
  display: block;
  margin-top: 0.22rem;
  font-size: 0.95rem;
  color: #f8fafc;
}

.cm-live-ac-status-list {
  display: grid;
  gap: 0.4rem;
  font-size: 0.82rem;
}

.cm-live-ac-status-list > div {
  padding-top: 0.38rem;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.cm-live-ac-details .is-good { color: #86efac !important; }
.cm-live-ac-details .is-bad { color: #fb7185 !important; }
.cm-live-ac-details .is-cool { color: #93c5fd !important; }
.cm-live-ac-details .is-heat { color: #fdba74 !important; }
.cm-live-ac-details .is-muted { color: #cbd5e1 !important; }

/* Live AC direct enriched display */
.cm-live-direct-card { position: relative; }
.cm-live-direct-details {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 0.95rem;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.38);
}
.cm-live-direct-row,
.cm-live-direct-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}
.cm-live-direct-head {
  margin-bottom: 0.55rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(226, 232, 240, 0.72);
}
.cm-live-direct-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}
.cm-live-direct-metrics > div {
  padding: 0.5rem 0.55rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(30, 41, 59, 0.62);
}
.cm-live-direct-metrics span,
.cm-live-direct-list span {
  display: block;
  font-size: 0.68rem;
  line-height: 1.1;
  color: rgba(203, 213, 225, 0.72);
}
.cm-live-direct-metrics strong {
  display: block;
  margin-top: 0.2rem;
  color: #f8fafc;
  font-size: 0.92rem;
}
.cm-live-direct-list {
  display: grid;
  gap: 0.34rem;
  font-size: 0.78rem;
}
.cm-live-direct-list > div {
  padding-top: 0.34rem;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}
.cm-live-direct-details strong { color: #e5edf7; font-weight: 750; }
.cm-status-good { color: #86efac !important; }
.cm-status-bad { color: #fb7185 !important; }
.cm-status-cool { color: #93c5fd !important; }
.cm-status-heat { color: #fdba74 !important; }
.cm-status-muted { color: #cbd5e1 !important; }

/* Climate Data tab AC unit drilldown */
.ac-snapshot-row > td { padding: 0.75rem 0.5rem 1rem !important; }
.ac-snapshot-panel {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 18px;
  padding: 14px;
  background: rgba(15, 23, 42, 0.62);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
.ac-snapshot-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #e5edf8;
}
.ac-snapshot-title small {
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  text-transform: none;
  color: #94a3b8;
  font-weight: 650;
}
.ac-snapshot-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.ac-snapshot-card {
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 14px;
  padding: 10px;
  background: rgba(30, 41, 59, 0.74);
}
.ac-snapshot-card.is-offline { border-color: rgba(248, 113, 113, 0.45); }
.ac-snapshot-card-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  color: #f8fafc;
}
.ac-snapshot-card-head span {
  color: #93c5fd;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}
.ac-snapshot-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 10px;
  margin-top: 9px;
  align-items: baseline;
}
.ac-snapshot-grid span {
  color: #94a3b8;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ac-snapshot-grid strong {
  color: #e2e8f0;
  font-size: 0.82rem;
  text-align: right;
  text-transform: capitalize;
}
@media (max-width: 1100px) {
  .ac-snapshot-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .ac-snapshot-cards { grid-template-columns: 1fr; }
  .ac-snapshot-title { flex-direction: column; align-items: flex-start; }
}

/* Data tab AC-unit drilldown */
.data-ac-units-row td {
  background: rgba(15, 23, 42, 0.42);
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}
.data-ac-units-wrap {
  padding: 0.7rem 0.4rem 0.9rem;
}
.data-ac-units-heading,
.data-ac-units-empty {
  color: rgba(226, 232, 240, 0.8);
  font-size: 0.8rem;
  margin-bottom: 0.55rem;
}
.data-ac-units-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 0.65rem;
}
.data-ac-unit-card {
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.55);
  border-radius: 14px;
  padding: 0.7rem;
}
.data-ac-unit-title {
  color: rgba(226, 232, 240, 0.88);
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.data-ac-unit-main {
  font-size: 1.45rem;
  font-weight: 900;
  margin: 0.3rem 0 0.45rem;
}
.data-ac-unit-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 0.45rem;
  font-size: 0.76rem;
}
.data-ac-unit-grid span { color: rgba(148, 163, 184, 0.9); }
.data-ac-unit-grid strong { color: rgba(248, 250, 252, 0.95); text-align: right; }
@media (max-width: 900px) {
  .data-ac-units-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
}
@media (max-width: 560px) {
  .data-ac-units-grid { grid-template-columns: 1fr; }
}


/* Data tab AC-unit values under each 15-minute interval */
.data-ac-interval-row td {
  background: rgba(6, 12, 26, 0.52);
  border-top: 1px solid rgba(148, 163, 184, 0.13);
}
.data-ac-units-wrap.interval {
  padding: 0.55rem 0.3rem 0.75rem;
}
.data-ac-units-grid.interval {
  display: grid;
  grid-template-columns: repeat(4, minmax(145px, 1fr));
  gap: 0.55rem;
}
.data-ac-unit-card.compact {
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.62);
  border-radius: 12px;
  padding: 0.58rem;
}
.data-ac-unit-card.compact .data-ac-unit-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0.28rem 0 0.38rem;
}
.data-ac-unit-card.compact .data-ac-unit-line strong {
  font-size: 1.28rem;
  color: rgba(248, 250, 252, 0.96);
}
.data-ac-unit-card.compact .data-ac-unit-line span {
  color: rgba(203, 213, 225, 0.86);
  font-weight: 800;
}
@media (max-width: 1000px) {
  .data-ac-units-grid.interval { grid-template-columns: repeat(2, minmax(145px, 1fr)); }
}
@media (max-width: 560px) {
  .data-ac-units-grid.interval { grid-template-columns: 1fr; }
}

/* ── AC Alert Banner (patch: ac_alert_detection) ───────────────────────────── */
.cm-live-alert-banner {
  background: #7f1d1d;
  border: 1px solid #ef4444;
  border-radius: 6px;
  color: #fca5a5;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 6px 10px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  animation: cm-alert-pulse 2s ease-in-out infinite;
}
@keyframes cm-alert-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.75; }
}
