:root {
  --bg: #0a0e17;
  --bg-elevated: #121826;
  --border: rgba(255, 255, 255, 0.08);
  --text: #eef2ff;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #fbbf24;
  --good: #34d399;
  --bad: #f87171;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  --font: 'DM Sans', system-ui, sans-serif;
  --display: 'Instrument Serif', Georgia, serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 40% at 10% -10%, rgba(56, 189, 248, 0.18), transparent 55%),
    radial-gradient(ellipse 50% 35% at 90% 0%, rgba(251, 191, 36, 0.12), transparent 50%),
    radial-gradient(ellipse 80% 50% at 50% 100%, rgba(52, 211, 153, 0.06), transparent 60%);
  z-index: -1;
}

.container {
  width: min(1120px, 92vw);
  margin-inline: auto;
}

.site-header {
  padding: 2.5rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.header-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.site-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
  padding: 0.3rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.22);
}

.site-nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.45rem 0.55rem;
  border-radius: 14px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.site-nav a[aria-current="page"] {
  color: var(--text);
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.28), rgba(251, 191, 36, 0.08));
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.55);
}

.brand {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.brand-icon {
  font-size: 2rem;
  filter: drop-shadow(0 0 12px rgba(251, 191, 36, 0.5));
}

.brand-kicker {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

h1 {
  margin: 0.15rem 0 0;
  font-family: var(--display);
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 400;
  letter-spacing: -0.02em;
}

.header-tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 22rem;
  text-align: right;
}

.panel {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

main {
  padding: 1.5rem 0 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.controls {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.day-switch {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
}

.day-switch-label {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.retailer-tabs,
.day-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.day-switch .day-tabs {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
}

.retailer-tab,
.day-tab,
.bono-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 1.15rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.bono-tab {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.retailer-tab:hover,
.day-tab:hover,
.bono-tab:hover {
  border-color: rgba(56, 189, 248, 0.4);
}

.retailer-tab.active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(56, 189, 248, 0.08));
  border-color: rgba(56, 189, 248, 0.55);
}

.day-tab.active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.28), rgba(56, 189, 248, 0.08));
  border-color: rgba(56, 189, 248, 0.55);
  color: var(--text);
}

.bono-tab.active {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.22), rgba(52, 211, 153, 0.06));
  border-color: rgba(52, 211, 153, 0.5);
}

.tax-box {
  padding: 1.25rem 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.tax-official {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.bono-custom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.bono-custom label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.bono-custom[hidden] {
  display: none;
}

.bono-custom input {
  width: 5.5rem;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font: inherit;
}

.pending-day h2,
.columns-guide h2,
.negative-note h2 {
  margin: 0 0 0.6rem;
  font-family: var(--display);
  font-size: 1.8rem;
  font-weight: 400;
}

.pending-kicker {
  margin: 0 0 0.35rem;
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pending-day p:last-child,
.negative-note p,
.negative-note li {
  margin: 0 0 0.75rem;
  color: var(--muted);
}

.negative-note p:last-child {
  margin-bottom: 0;
}

.negative-note ul {
  margin: 0 0 0.75rem;
  padding-left: 1.2rem;
}

.negative-note strong {
  color: var(--text);
}

.partial-day {
  margin: 0;
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  border: 1px solid rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.1);
}

.negative-note {
  margin-bottom: 1.25rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--border);
}

.negative-note summary {
  display: inline;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  list-style: none;
}

.negative-note summary::-webkit-details-marker {
  display: none;
}

.negative-note summary:hover {
  color: var(--text);
}

.negative-body {
  margin-top: 0.9rem;
}

.columns-guide dl {
  margin: 0;
  display: grid;
  gap: 0.85rem;
}

.columns-guide dt {
  font-weight: 700;
}

.columns-guide dd {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.retailer-note {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.stat-card {
  padding: 1.1rem 1.25rem;
}

.stat-card.highlight {
  border-color: rgba(52, 211, 153, 0.35);
}

.stat-card.warn {
  border-color: rgba(248, 113, 113, 0.35);
}

.stat-label {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-value {
  margin: 0.35rem 0 0;
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-value.stat-hours {
  font-size: 1.02rem;
  line-height: 1.45;
  white-space: pre-line;
}

.stat-hint {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: pre-line;
}

.stat-note,
.tax-note,
.fixed-bill {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.fixed-bill {
  margin-top: 0.85rem;
  display: grid;
  gap: 0.35rem;
}

.fixed-bill p {
  margin: 0;
}

.fixed-bill strong {
  color: var(--text);
}

.notify-tomorrow,
.power-field {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  font-size: 0.95rem;
}

.power-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.4rem;
  margin-top: 0.85rem;
}

.power-field {
  margin-top: 0.85rem;
  color: var(--muted);
}

.power-fields .power-field {
  margin-top: 0;
}

#show-fixed-hour {
  margin-right: 0.15rem;
}

label.notify-tomorrow {
  margin-top: 0.35rem;
}

.power-field input {
  width: 5.5rem;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font: inherit;
}

.notify-tomorrow input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: #fbbf24;
}

.fixed-short {
  display: none;
}

.section-head {
  margin-bottom: 1rem;
}

.section-head h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.section-sub {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.chart-section,
.table-section,
.appliances,
.info {
  padding: 1.25rem 1.35rem;
}

.appliance-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.appliance-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem 0.9rem;
  background: rgba(255, 255, 255, 0.03);
}

.appliance-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.appliance-name {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0.15rem 0;
}

.appliance-remove {
  flex: 0 0 auto;
  min-height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.25rem 0.7rem;
  cursor: pointer;
}

.appliance-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem 0.7rem;
  margin-top: 0.65rem;
}

.appliance-fields label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.appliance-fields input,
.appliance-fields select {
  width: 100%;
  min-width: 0;
  padding: 0.45rem 0.55rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

.appliance-prices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.appliance-price {
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.appliance-price span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.appliance-price strong {
  display: block;
  margin-top: 0.15rem;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.appliance-breakdown {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}

.appliance-example {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.appliance-use-example {
  min-height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
}

.appliance-price-full {
  border-color: rgba(251, 191, 36, 0.45);
}

.appliance-price.is-credit strong {
  color: var(--good);
}

.appliance-kwh {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.appliance-result {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.75rem;
  margin: 0.75rem 0 0;
  font-variant-numeric: tabular-nums;
}

.appliance-result strong {
  font-size: 1.25rem;
}

.appliance-result span,
.appliance-split {
  color: var(--muted);
  font-size: 0.88rem;
}

.appliance-result.is-credit strong {
  color: var(--good);
}

.appliance-split {
  margin: 0.35rem 0 0;
}

.appliance-split p {
  margin: 0.12rem 0;
}

.appliance-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.appliance-actions button {
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 1rem;
  cursor: pointer;
}

#appliance-add {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.28), rgba(251, 191, 36, 0.08));
  border-color: rgba(251, 191, 36, 0.55);
}

.chart-wrap {
  position: relative;
  height: min(340px, 55vw);
}

.legend {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.35rem;
}

.legend .dot.market,
.legend .dot.pvpc {
  background: var(--accent);
}

.fold {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.fold summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.fold p,
.fold dd {
  margin: 0.45rem 0;
}

.bono-status {
  margin: 1rem 0 0.75rem;
  padding: 0.7rem 0.95rem;
  border-radius: 12px;
  font-weight: 700;
}

.bono-status.is-off {
  background: rgba(148, 163, 184, 0.14);
  color: var(--text);
}

.bono-status.is-on {
  background: rgba(52, 211, 153, 0.16);
  color: #86efac;
}

.price-example {
  margin-top: 0.85rem;
  padding: 0.35rem 1rem 0.7rem;
}

.price-example .fold {
  margin: 0;
}

.price-example p {
  margin: 0.35rem 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.price-example strong {
  color: var(--text);
}

.history-intro {
  margin: 0.4rem 0 0.8rem;
  color: var(--muted);
}

.history-chart {
  margin-bottom: 0.9rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.history-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem 1rem;
}

.history-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.history-range {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.history-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.2rem;
}

.history-metrics p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.history-metrics strong {
  display: block;
  margin-top: 0.1rem;
  color: var(--text);
  font-size: 1.05rem;
}

.history-toggle {
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
}

.history-toggle:disabled {
  opacity: 0.4;
  cursor: default;
}

.history-hours {
  margin-top: 0.8rem;
}

.legend .dot.final {
  background: var(--accent-2);
}

.legend .dot.cheap {
  background: var(--good);
}

.legend .dot.dear {
  background: var(--bad);
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 0.55rem;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

thead th {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0 0.85rem 0.15rem;
}

.th-sub {
  font-weight: 500;
  color: var(--muted);
}

.hour-end:empty {
  display: none;
}

.hour-period {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  margin-left: 0.4rem;
  padding: 0.08rem 0.42rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
  vertical-align: middle;
}

.hour-period.punta {
  color: #fdba74;
  background: rgba(251, 146, 60, 0.16);
}

.hour-period.llano {
  color: #7dd3fc;
  background: rgba(56, 189, 248, 0.14);
}

.hour-period.valle {
  color: #5eead4;
  background: rgba(45, 212, 191, 0.14);
}

tbody tr.period-start td {
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.14);
}

.hour-short,
.band-mini {
  display: none;
}

.hour-end::before {
  content: ' – ';
}

th,
td {
  padding: 0.8rem 0.85rem;
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
}

th:first-child,
td:first-child {
  text-align: left;
}

tbody td {
  background: rgba(255, 255, 255, 0.035);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

tbody td:first-child {
  border-left: 3px solid rgba(56, 189, 248, 0.55);
  border-radius: 14px 0 0 14px;
}

tbody td:last-child {
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0 14px 14px 0;
}

tbody tr:hover td {
  background: rgba(56, 189, 248, 0.08);
}

.price-cell {
  font-weight: 600;
}

.price-extra {
  display: block;
  margin-top: 0.18rem;
  color: var(--accent-2);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.15;
}

.price-extra-label {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
}

.delta-short {
  display: none;
}

.delta-cell {
  text-align: center;
}

.delta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.delta svg {
  width: calc(0.95rem + var(--weight) * 0.14rem);
  height: calc(0.95rem + var(--weight) * 0.14rem);
  flex: 0 0 auto;
  display: block;
}

.delta svg path {
  fill: none;
  stroke: currentColor;
  stroke-width: calc(2.1 + var(--weight) * 1.15);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.delta-up {
  color: #fb7185;
}

.delta-down {
  color: #34d399;
}

.delta-flat {
  color: #94a3b8;
  font-weight: 700;
}

.legend .dot.trend {
  width: 16px;
  height: 0;
  border-radius: 0;
  background: transparent;
  border-top: 2.5px dashed #d8b4fe;
  vertical-align: middle;
}

.price-cell.cheap {
  color: var(--good);
}

.price-cell.dear {
  color: var(--bad);
}

tbody tr.band-cheap td {
  background: rgba(52, 211, 153, 0.1);
}

tbody tr.band-dear td {
  background: rgba(248, 113, 113, 0.1);
}

tbody tr.band-cheap td:first-child {
  border-left-color: var(--good);
}

tbody tr.band-dear td:first-child {
  border-left-color: var(--bad);
}

tbody tr.band-cheap:hover td {
  background: rgba(52, 211, 153, 0.16);
}

tbody tr.band-dear:hover td {
  background: rgba(248, 113, 113, 0.16);
}

tbody tr.is-now td {
  background: rgba(251, 191, 36, 0.22);
  border-top-color: rgba(251, 191, 36, 0.75);
  border-bottom-color: rgba(251, 191, 36, 0.75);
}

tbody tr.is-now td:first-child {
  border-left-color: #fbbf24;
  border-left-width: 4px;
}

tfoot th,
tfoot td {
  background: rgba(251, 191, 36, 0.1);
  border-top: 1px solid rgba(251, 191, 36, 0.4);
  border-bottom: 1px solid rgba(251, 191, 36, 0.4);
}

tfoot th {
  border-left: 3px solid #fbbf24;
  border-radius: 14px 0 0 14px;
  font-weight: 700;
}

tfoot td:last-child {
  border-right: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: 0 14px 14px 0;
}

tfoot .price-cell {
  font-weight: 700;
}

.hour-layout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
}

.alarm-btn {
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
  color: var(--muted);
  cursor: pointer;
}

.alarm-btn svg {
  width: 1.15rem;
  height: 1.15rem;
  display: block;
}

.alarm-btn:hover {
  color: var(--text);
  border-color: rgba(251, 191, 36, 0.55);
}

.alarm-btn[aria-pressed='true'] {
  color: #1c1403;
  background: var(--accent-2);
  border-color: var(--accent-2);
}

.alarm-btn[aria-pressed='true'] svg path:first-child {
  fill: currentColor;
}

.alarm-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.alarm-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.band-tag {
  display: inline-block;
  margin-right: 0.45rem;
  padding: 0.08rem 0.4rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: 0.05em;
}

.band-cheap .band-tag {
  color: #04281c;
  background: var(--good);
}

.band-dear .band-tag {
  color: #2a0a0a;
  background: var(--bad);
}

.footnote {
  margin: 1rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.info h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.info p {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.updated {
  font-size: 0.8rem !important;
  color: var(--accent) !important;
}

.site-footer {
  padding: 1.5rem 0 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.site-footer p {
  margin: 0;
}

.site-footer .creator {
  margin-top: 0.45rem;
}

.site-footer a {
  color: inherit;
}

body.needs-access .site-header,
body.needs-access main,
body.needs-access .site-footer,
body.needs-access .page-jump,
body.needs-access .install-prompt {
  visibility: hidden;
}

.access-lock {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(10, 14, 23, 0.92);
}

.access-card,
.admin-card {
  width: min(100%, 28rem);
  margin-inline: auto;
}

.access-card h2,
.admin-card h2 {
  margin: 0.2rem 0 0.6rem;
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 400;
}

.access-card label,
.admin-card label {
  display: block;
  margin-top: 0.9rem;
  font-size: 0.92rem;
}

.access-card input,
.admin-card input,
.admin-card textarea {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.75rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

.admin-card textarea {
  display: block;
  resize: none;
  overflow: hidden;
  line-height: 1.35;
  min-height: 3rem;
}

.access-card button,
.admin-card button,
.admin-row button {
  min-height: 44px;
  margin-top: 0.9rem;
  padding: 0.65rem 1rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.9), rgba(251, 191, 36, 0.55));
  color: #1c1404;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.access-error {
  margin: 0.75rem 0 0;
  color: var(--bad);
}

.admin-wrap {
  padding-top: 1.5rem;
  padding-bottom: 2rem;
}

.admin-card h3 {
  margin: 1.3rem 0 0;
}

.admin-card details {
  margin-top: 1.4rem;
}

.admin-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.admin-top button,
.admin-row button,
.admin-link {
  margin-top: 0;
}

.admin-link {
  color: var(--accent-2);
}

.admin-board {
  display: grid;
  gap: 1.25rem;
}

.admin-columns {
  display: grid;
  gap: 1.25rem;
}

.admin-columns h3 {
  margin-top: 0;
}

.admin-list {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.8rem;
}

.admin-row {
  display: grid;
  gap: 0.35rem;
  padding: 0.8rem 0.9rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.admin-row code,
.admin-row input[readonly] {
  font-family: ui-monospace, monospace;
  letter-spacing: 0.04em;
}

.admin-row .muted,
.admin-card .muted {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.admin-actions button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.page-jump {
  position: fixed;
  z-index: 85;
  right: max(0.7rem, env(safe-area-inset-right));
  bottom: calc(1rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.page-jump button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(251, 191, 36, 0.55);
  background: rgba(15, 23, 42, 0.92);
  color: #fbbf24;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.page-jump button:hover,
.page-jump button:focus-visible {
  background: rgba(251, 191, 36, 0.16);
  outline: none;
}

.page-jump svg {
  width: 1.15rem;
  height: 1.15rem;
}

.toast {
  position: fixed;
  bottom: calc(1.25rem + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 1.5rem);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 0.875rem;
  z-index: 100;
  pointer-events: none;
}

.install-prompt {
  position: fixed;
  z-index: 90;
  left: max(0.75rem, env(safe-area-inset-left));
  right: max(0.75rem, env(safe-area-inset-right));
  bottom: calc(0.75rem + env(safe-area-inset-bottom));
  margin-inline: auto;
  width: min(32rem, 100%);
  padding: 1rem 1.1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.install-prompt p {
  margin: 0 0 0.75rem;
}

.install-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.install-actions button {
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 1rem;
  cursor: pointer;
}

#install-yes {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.28), rgba(251, 191, 36, 0.08));
  border-color: rgba(251, 191, 36, 0.55);
}

.loading tbody tr {
  opacity: 0.5;
}

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .container {
    width: min(1120px, calc(100% - 1.25rem));
  }

  .site-header {
    padding: 1.15rem 0 0.9rem;
  }

  .header-top,
  .brand {
    align-items: flex-start;
  }

  .site-nav {
    border-radius: 16px;
  }

  .site-nav a {
    font-size: 0.8rem;
    padding: 0.4rem 0.35rem;
  }

  .day-switch,
  .day-switch .day-tabs {
    width: 100%;
  }

  .day-tab {
    flex: 1;
  }

  .header-tagline {
    text-align: left;
    max-width: none;
  }

  .controls,
  .chart-section,
  .table-section,
  .appliances,
  .tax-box,
  .info,
  .columns-guide,
  .pending-day {
    padding: 1rem 0.7rem;
  }

  .appliance-fields {
    grid-template-columns: 1fr 1fr;
  }

  .day-tab,
  .bono-tab,
  .retailer-tab,
  .site-nav a {
    min-height: 44px;
  }

  .appliance-prices {
    grid-template-columns: 1fr;
  }

  .bono-custom input,
  .power-field input {
    font-size: 16px;
  }

  .fixed-full {
    display: none;
  }

  .fixed-short {
    display: inline;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .chart-wrap {
    height: 240px;
  }

  .legend {
    gap: 0.55rem 0.85rem;
    font-size: 0.78rem;
  }

  .delta-full {
    display: none;
  }

  .delta-short {
    display: inline;
  }

  .delta {
    flex-direction: column;
    gap: 0.12rem;
    font-size: 0.72rem;
  }

  .delta svg {
    width: calc(0.95rem + var(--weight) * 0.12rem);
    height: calc(0.95rem + var(--weight) * 0.12rem);
  }

  .table-scroll {
    overflow-x: clip;
  }

  table {
    table-layout: fixed;
    border-spacing: 0 0.28rem;
  }

  .table-section .footnote {
    font-size: 0.92rem;
  }

  th:nth-child(1),
  td:nth-child(1) {
    width: 5.25rem;
  }

  th:nth-child(4),
  td:nth-child(4) {
    width: 2.65rem;
  }

  th,
  td {
    padding: 0.32rem 0.12rem;
    font-size: 1rem;
    white-space: normal;
    vertical-align: middle;
  }

  th {
    text-align: center;
    line-height: 1.2;
    font-size: 0.84rem;
  }

  thead th {
    font-size: 0.78rem;
    padding: 0 0.15rem 0.05rem;
  }

  .th-sub {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.75rem;
    font-weight: 500;
  }

  th:first-child,
  td:first-child {
    min-width: 0;
    text-align: center;
  }

  .hour-layout {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.08rem;
  }

  .hour-copy {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.12rem 0.2rem;
    line-height: 1.1;
  }

  .hour-full {
    display: none;
  }

  .hour-short {
    display: inline;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  .hour-copy {
    flex-direction: column;
    align-items: center;
  }

  .hour-period {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    margin: 0.08rem 0 0;
    padding: 0.04rem 0.08rem;
    font-size: 0.62rem;
  }

  .band-full {
    display: none;
  }

  .band-mini {
    display: inline;
  }

  .band-tag {
    display: inline-block;
    width: auto;
    margin: 0;
    padding: 0.02rem 0.28rem;
    font-size: 0.65rem;
  }

  .alarm-btn {
    width: 1.75rem;
    height: 1.75rem;
  }

  .alarm-btn svg {
    width: 1rem;
    height: 1rem;
  }

  .hour-range {
    display: inline;
    line-height: 1.1;
  }

  td:nth-child(2),
  td:nth-child(3) {
    white-space: nowrap;
    overflow-wrap: normal;
  }

  .toast {
    left: max(0.75rem, env(safe-area-inset-left));
    right: max(0.75rem, env(safe-area-inset-right));
    transform: none;
    border-radius: 16px;
    text-align: center;
  }
}

@media (min-width: 960px) {
  .header-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
  }

  .header-top {
    flex: 1;
    min-width: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
  }

  .header-tagline {
    text-align: left;
    max-width: 36rem;
  }

  .site-nav {
    width: max-content;
    flex: none;
    grid-template-columns: repeat(3, max-content);
  }

  .site-nav a {
    padding-inline: 1.15rem;
    white-space: nowrap;
  }

  .controls {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .columns-guide dl {
    grid-template-columns: 1fr 1fr;
    column-gap: 2rem;
  }

  .appliance-list {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .history-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  #admin-panel.admin-card {
    width: 100%;
  }

  .admin-board {
    grid-template-columns: minmax(18rem, 22rem) minmax(0, 1fr);
    align-items: start;
    gap: 1.75rem;
  }

  .admin-row:has(.admin-name) {
    grid-template-columns: 13rem minmax(0, 1fr);
    grid-template-areas:
      "name name"
      "code meta"
      "actions actions";
    align-items: center;
    column-gap: 0.9rem;
    row-gap: 0.55rem;
  }

  .admin-row:has(.admin-name):not(:has(.admin-code)) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "name"
      "meta"
      "actions";
  }

  .admin-row .admin-name,
  .admin-row .admin-code,
  .admin-row .muted,
  .admin-row .admin-actions {
    margin-top: 0;
  }

  .admin-row .admin-name {
    grid-area: name;
    width: 100%;
    min-width: 0;
  }

  .admin-row .admin-code {
    grid-area: code;
    width: 13rem;
    min-width: 13rem;
    justify-self: start;
  }

  .admin-row .muted {
    grid-area: meta;
    min-width: 0;
  }

  .admin-row .admin-actions {
    grid-area: actions;
    justify-content: flex-start;
    align-content: center;
    align-self: center;
  }

  .admin-actions button {
    white-space: nowrap;
  }
}
