/* savings.css — page-specific styles for /savings.
   Hero section is the centerpiece — the giant number is the entire
   point of the page. Everything below it supports the headline. */

/* Header layout — match History/Meters/Cloud: brand on the left,
   icon-button + connection pill on the right, single row. common.css
   stops short of opinionated page-chrome, so each page sets its own
   header flex rule. */
header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; gap: 24px; }
.wrap > .card { margin-bottom: 16px; }
.wrap > .card:last-of-type { margin-bottom: 0; }

/* ============= HERO CARD ============= */
.hero-card {
  position: relative;
  overflow: hidden;
  padding: 56px 40px 48px;
  text-align: center;
  background:
    radial-gradient(900px 400px at 50% -50%, rgba(245, 158, 11, 0.20), transparent 70%),
    radial-gradient(700px 380px at 50% 130%, rgba(16, 185, 129, 0.15), transparent 70%),
    var(--card);
  border-color: rgba(252, 211, 77, 0.18);
  margin-bottom: 18px;
}
.hero-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      45deg,
      transparent 0,
      transparent 70px,
      rgba(255, 255, 255, 0.012) 70px,
      rgba(255, 255, 255, 0.012) 71px
    );
  pointer-events: none;
}
.hero-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.32em;
  color: var(--solar-soft);
  margin-bottom: 18px;
  text-shadow: 0 0 24px rgba(245, 158, 11, 0.4);
}
.hero-number {
  font-size: clamp(56px, 11vw, 128px);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.04em;
  color: #fff;
  margin-bottom: 16px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 4px 32px rgba(245, 158, 11, 0.25);
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.hero-currency {
  font-size: 0.55em;
  font-weight: 600;
  color: var(--solar-soft);
  margin-right: 4px;
}
.hero-value {
  background: linear-gradient(180deg, #fff 0%, #fde68a 50%, #fcd34d 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-sub {
  font-size: 15px;
  color: var(--text-dim);
  margin-bottom: 12px;
  font-weight: 500;
}
.hero-sub strong, .hero-sub #hero-units, .hero-sub #hero-period {
  color: var(--text);
  font-weight: 700;
}
.hero-estimate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 12px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.28);
  background: rgba(56, 189, 248, 0.10);
  color: #7dd3fc;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.hero-estimate.hidden { display: none; }
.hero-foot {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 14px;
  border-radius: 100px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: var(--batt-soft);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
/* The .rate-edit wrapper carries data-auth-required so common.css's
   :not(.auth-ok) gate hides the entire input form for viewers without
   write tokens. The readonly label sits next to it and is hidden once
   the input becomes visible (mirror logic in savings.js). */
.rate-edit { display: inline-flex; align-items: center; gap: 4px; }
.rate-readonly { color: var(--batt-soft); }
.rate-prefix, .rate-suffix { color: var(--batt-soft); }
.rate-input {
  width: 56px;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(110, 231, 183, 0.32);
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color 160ms ease, background 160ms ease;
}
.rate-input::-webkit-outer-spin-button,
.rate-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.rate-input { -moz-appearance: textfield; }
.rate-input:focus {
  border-color: var(--batt-soft);
  background: rgba(16, 185, 129, 0.18);
}
.rate-status {
  margin-left: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  min-width: 0;
  color: var(--text-dim);
  transition: color 160ms ease;
}
.rate-status.saving  { color: var(--text-dim); }
.rate-status.saved   { color: var(--batt-soft); }
.rate-status.error   { color: var(--red-soft); }

/* ============= INSIGHT CARD ============= */
.insight-card {
  display: flex;
  gap: 24px;
  align-items: center;
  padding: 28px 32px;
  background:
    linear-gradient(135deg, rgba(239, 68, 68, 0.07), rgba(245, 158, 11, 0.05)),
    var(--card);
  border-color: rgba(252, 165, 165, 0.18);
  margin-bottom: 18px;
}
.insight-icon {
  flex-shrink: 0;
  width: 48px; height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.18), rgba(252, 211, 77, 0.10));
  border: 1px solid rgba(252, 211, 77, 0.28);
  display: grid; place-items: center;
  color: var(--solar-soft);
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.18);
}
.insight-icon svg { width: 22px; height: 22px; }
.insight-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.insight-text {
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.55;
}
.insight-text strong { color: var(--solar-soft); font-weight: 700; }

/* ============= BADGE GRID ============= */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.badge-card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 16px;
  padding: 22px 20px;
  text-align: center;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: transform 200ms ease, border-color 200ms ease;
}
.badge-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.12);
}
.badge-icon {
  width: 40px; height: 40px;
  margin: 0 auto 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-edge);
  display: grid; place-items: center;
  color: var(--text-dim);
  transition: color 200ms ease, border-color 200ms ease;
}
.badge-icon svg { width: 20px; height: 20px; }
.badge-card:hover .badge-icon {
  color: var(--solar-soft);
  border-color: rgba(252, 211, 77, 0.22);
}
.badge-value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: #fff;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  margin-bottom: 4px;
}
.badge-unit {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ============= PAYBACK CARD ============= */
.payback-card { margin-bottom: 18px; }
#payback-readout.hidden, #payback-empty.hidden { display: none; }
.payback-empty {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.55;
  padding: 6px 0 14px;
}

/* Cost control in the card head — mirrors the rate-input pattern in
   the hero. .cost-readonly is hidden once .cost-edit gains .auth-ok
   (mirror logic in savings.js). */
.cost-readonly { font-variant-numeric: tabular-nums; }
.cost-edit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 100px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-edge);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.cost-prefix { color: var(--text-dim); }
.cost-input {
  width: 90px;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color 160ms ease, background 160ms ease;
}
.cost-input::-webkit-outer-spin-button,
.cost-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cost-input { -moz-appearance: textfield; }
.cost-input:focus {
  border-color: var(--solar-soft);
  background: rgba(245, 158, 11, 0.10);
}
.cost-status {
  margin-left: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  transition: color 160ms ease;
}
.cost-status.saving { color: var(--text-dim); }
.cost-status.saved  { color: var(--batt-soft); }
.cost-status.error  { color: var(--red-soft); }
.payback-progress {
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.payback-bar {
  height: 14px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
  border: 1px solid var(--card-edge);
  position: relative;
}
.payback-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--batt) 0%, var(--solar) 100%);
  border-radius: 100px;
  transition: width 1200ms cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.4);
}
.payback-numbers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 18px;
}
.payback-stat { text-align: center; }
.payback-stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.payback-stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* ============= CHART ============= */
.savings-chart {
  width: 100%;
  height: 320px;
}

/* ============= BREAKDOWN TABLE ============= */
.card-desc {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.55;
  margin: -6px 0 18px;
}
.card-desc strong { color: var(--text); font-weight: 600; }
.breakdown-wrap {
  overflow-x: auto;
  margin: 0 -8px;
}
#breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
#breakdown-table th {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--card-edge);
}
#breakdown-table th.num,
#breakdown-table td.num {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
}
#breakdown-table td {
  padding: 13px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.025);
  color: var(--text);
}
#breakdown-table td.period-cell {
  min-width: 210px;
  white-space: normal;
}
#breakdown-table tbody tr:hover { background: rgba(255, 255, 255, 0.018); }
#breakdown-table .meter-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(59, 130, 246, 0.15);
  color: var(--home-soft);
  border: 1px solid rgba(59, 130, 246, 0.25);
}
#breakdown-table .meter-pill.b {
  background: rgba(16, 185, 129, 0.15);
  color: var(--batt-soft);
  border-color: rgba(16, 185, 129, 0.25);
}
#breakdown-table .meter-pill.flipped {
  background: rgba(245, 158, 11, 0.16);
  color: var(--solar-soft);
  border-color: rgba(245, 158, 11, 0.32);
}
#breakdown-table .meters-cell { white-space: nowrap; }
#breakdown-table .meters-cell .meter-pill {
  margin-right: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
#breakdown-table .meter-pill svg { width: 11px; height: 11px; flex-shrink: 0; }
#breakdown-table .pv-cell { color: var(--solar-soft); font-weight: 600; }
#breakdown-table .hyp-cell { color: var(--text); font-weight: 600; }
#breakdown-table .op { color: var(--text-muted); font-weight: 700; }
#breakdown-table .saved {
  color: var(--batt-soft);
  font-weight: 700;
}
#breakdown-table .saved-estimate {
  color: #7dd3fc;
  font-weight: 700;
  cursor: help;
}
#breakdown-table .saved-zero { color: var(--text-muted); }
#breakdown-table .flip-yes {
  font-size: 11px;
  font-weight: 700;
  color: var(--solar-soft);
  background: rgba(245, 158, 11, 0.10);
  padding: 2px 8px;
  border-radius: 100px;
  border: 1px solid rgba(245, 158, 11, 0.22);
}
#breakdown-table .flip-no { color: var(--text-muted); font-size: 11px; }
#breakdown-table .partial-marker {
  font-size: 10px;
  color: var(--solar-soft);
  margin-left: 4px;
  cursor: help;
}
#breakdown-table .inferred-tag {
  /* Match the sky-blue used by /history's audit-info column for
     "X inferred" suffixes — same vocabulary, same color across pages. */
  color: #38bdf8;
  font-size: 11px;
  font-weight: 500;
  cursor: help;
  white-space: nowrap;
}
#breakdown-table td, #breakdown-table th { white-space: nowrap; }
#breakdown-table { min-width: 720px; }
#breakdown-table .op-th { color: var(--text-muted); }
#breakdown-table tr.in-progress {
  background: linear-gradient(90deg,
    rgba(252, 211, 77, 0.06) 0%,
    rgba(252, 211, 77, 0.02) 100%);
}
#breakdown-table tr.in-progress td:first-child {
  position: relative;
}
#breakdown-table tr.in-progress td:first-child::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--solar) 0%, var(--solar-soft) 100%);
}
#breakdown-table .in-progress-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 100px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(252, 211, 77, 0.12);
  color: var(--solar-soft);
  border: 1px solid rgba(252, 211, 77, 0.28);
  vertical-align: middle;
}
#breakdown-table .drift-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 100px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: help;
  vertical-align: middle;
}
#breakdown-table .drift-tag.good {
  background: rgba(56, 189, 248, 0.12);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.28);
}
#breakdown-table .drift-tag.weak {
  background: rgba(245, 158, 11, 0.12);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.28);
}
#breakdown-table .read-window-note {
  margin-top: 5px;
  color: var(--text-dim);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: normal;
  cursor: help;
}

/* ============= METHODOLOGY ============= */
.method-card { margin-top: 18px; }
.method-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
}
.method-list li {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.method-list li:last-child { border: 0; }
.method-list strong { color: var(--text); font-weight: 600; }
.method-list code {
  background: rgba(255, 255, 255, 0.04);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

/* ============= MOBILE ============= */
@media (max-width: 700px) {
  .hero-card { padding: 40px 22px 36px; }
  .hero-number { font-size: clamp(52px, 14vw, 80px); }
  .hero-sub { font-size: 13px; }
  #breakdown-table { font-size: 12px; }
  #breakdown-table th, #breakdown-table td { padding: 8px 6px; }
  /* Hide the decorative + / = operator columns on phones — they
     eat horizontal real estate the data columns need more. The
     equation still reads naturally without them. */
  #breakdown-table .op, #breakdown-table .op-th { display: none; }
  /* Inferred-day suffix on its own line under the value to keep the
     primary number readable when columns are tight. */
  #breakdown-table .inferred-tag { display: block; margin-top: 2px; }
}
