/* PowerBill — light "utility paper" theme.
   Warm off-white ledger surfaces, utility blue primary (#1d4ed8) and amber
   accent (#d97706) — a paper-bill look set apart from the dark developer-tool
   palette and the magenta/red light themes of the other nxtolerance sites. */

:root {
  --bg: #f6f5ef;
  --surface: #ffffff;
  --surface-2: #efeee4;
  --text: #20242f;
  --text-dim: #5c6372;
  --border: #e0ddcd;
  --pb-good: #0e7a4f;
  --pb-warn: #a15c00;
  --pb-tick: rgba(29, 78, 216, 0.07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #f6f5ef;
    --surface: #ffffff;
    --surface-2: #efeee4;
    --text: #20242f;
    --text-dim: #5c6372;
    --border: #e0ddcd;
  }
}
html {
  color-scheme: light;
}

/* ---------- estimator shell ---------- */
.pb {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin: 1.4rem 0 1.8rem;
  box-shadow: 0 10px 34px -26px rgba(32, 36, 47, 0.4);
  overflow: hidden;
}
@media (min-width: 54rem) {
  .prose .pb {
    width: min(62rem, calc(100vw - 2.5rem));
  }
}

/* ---------- rate bar ---------- */
.pb-ratebar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.7rem 1rem;
  padding: 0.9rem 1rem 0.6rem;
  border-bottom: 1px solid var(--border);
  background:
    repeating-linear-gradient(0deg, transparent 0 1.1rem, var(--pb-tick) 1.1rem calc(1.1rem + 1px)),
    var(--surface-2);
}
.pb-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.pb-field > span,
.pb-cell > span {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.pb input[type="text"] {
  font-family: var(--mono);
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.38rem 0.5rem;
  box-sizing: border-box;
  min-height: 2.75rem; /* 44px tap target */
}
.pb input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}
.pb-ratebar input {
  width: 5.6rem;
}
.pb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding-bottom: 0.1rem;
}
.pb-chip {
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.24rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary);
  cursor: pointer;
  min-height: 2.75rem; /* 44px tap target */
}
.pb-chip:hover {
  border-color: var(--primary);
}
.pb-ratenote {
  width: 100%;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin: 0 0 0.2rem;
}
.pb-ratenote strong {
  color: var(--pb-warn);
}

/* ---------- device table ---------- */
.pb-head,
.pb-row {
  display: grid;
  grid-template-columns: minmax(9.5rem, 1.5fr) 4.6rem 3.6rem 4.6rem 4.6rem 4.6rem 5rem;
  gap: 0.3rem 0.5rem;
  align-items: end;
  padding: 0.55rem 1rem;
}
.pb-head {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
  padding-top: 0.7rem;
}
.pb-head span {
  display: block;
}
.pb-head .pb-head-kwh,
.pb-head .pb-head-cost {
  text-align: end;
}
.pb-row {
  border-bottom: 1px dashed var(--border);
}
.pb-row:last-of-type {
  border-bottom: none;
}
.pb-row.pb-off {
  opacity: 0.62;
}
.pb-dev {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}
.pb-name {
  font-size: 0.9rem;
  font-weight: 650;
  color: var(--text);
}
.pb-range {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.3;
}
.pb-cell {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
/* On desktop the header row labels the columns; the per-cell labels only
   appear when the grid collapses to cards on small screens. */
.pb-cell > span {
  display: none;
}
.pb-cell input {
  width: 100%;
}
.pb-kwh,
.pb-cost {
  font-family: var(--mono);
  font-size: 0.88rem;
  text-align: end;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  padding-bottom: 0.35rem;
  white-space: nowrap;
}
.pb-kwh {
  font-weight: 700;
}
.pb-cost {
  color: var(--text-dim);
}

/* ---------- summary ---------- */
.pb-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 0.55rem;
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.pb-tot {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0.55rem 0.7rem;
}
.pb-tot b {
  display: block;
  font-size: 1.2rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.pb-tot span {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.pb-totnote {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin: 0;
  padding: 0.55rem 1rem 0.85rem;
  background: var(--surface-2);
}

/* ---------- share chart ---------- */
.pb-share {
  padding: 0.9rem 1rem 1rem;
  border-top: 1px solid var(--border);
}
.pb-sec-title {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 0.65rem;
}
.pb-bar {
  display: grid;
  grid-template-columns: minmax(7rem, 9.5rem) 1fr minmax(8.5rem, auto);
  gap: 0.55rem;
  align-items: center;
  margin: 0.3rem 0;
}
.pb-bar-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pb-bar-track {
  height: 0.65rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.pb-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--accent) 70%, var(--primary)));
  min-width: 2px;
}
.pb-bar-val {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  text-align: end;
  white-space: nowrap;
}
.pb-empty {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin: 0.3rem 0 0;
}

/* ---------- what-if cards ---------- */
.pb-whatif {
  padding: 0 1rem 1rem;
}
.pb-wi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: 0.6rem;
}
.pb-wi-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 0.7rem 0.8rem;
}
.pb-wi-name {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.3rem;
}
.pb-wi-desc {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin: 0 0 0.45rem;
}
.pb-wi-out {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.pb-wi-out.pb-idle {
  font-weight: 500;
  color: var(--text-dim);
}

/* ---------- article polish ---------- */
.prose table {
  font-variant-numeric: tabular-nums;
}
.prose table code {
  white-space: nowrap;
}

/* ---------- mobile: rows become mini-cards ---------- */
@media (max-width: 52rem) {
  .pb-head {
    display: none;
  }
  .pb-row {
    grid-template-columns: repeat(4, 1fr) 5rem 5.2rem;
    padding: 0.7rem 0.85rem;
    align-items: end;
  }
  .pb-dev {
    grid-column: 1 / -1;
    margin-bottom: 0.15rem;
  }
  .pb-cell > span {
    display: block;
  }
  .pb-kwh,
  .pb-cost {
    font-size: 0.8rem;
  }
  /* outputs lose their column header on small screens — label them inline */
  .pb-kwh::before,
  .pb-cost::before {
    display: block;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-dim);
    font-family: var(--font);
  }
  .pb-kwh::before {
    content: "kWh/mo";
  }
  .pb-cost::before {
    content: "cost/mo";
  }
}
@media (max-width: 400px) {
  .pb-row {
    grid-template-columns: 1fr 1fr;
  }
  .pb-kwh,
  .pb-cost {
    text-align: start;
  }
  .pb-bar {
    grid-template-columns: 6.5rem 1fr;
  }
  .pb-bar-val {
    grid-column: 1 / -1;
    text-align: start;
  }
}
