:root {
  --accent: #0a6e4f;
  --accent-light: #e6f4ef;
  --text: #1a1a1a;
  --muted: #666;
  --border: #d9d9d9;
  --bg: #fafafa;
  --card: #fff;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0 auto;
  max-width: 860px;
  padding: 1.5rem 1rem 3rem;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.6rem;
}

.tagline {
  margin: 0;
  color: var(--muted);
}

h2 {
  font-size: 1.15rem;
  margin: 2rem 0 0.25rem;
}

.hint {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

input {
  width: 100%;
  padding: 0.5rem 0.6rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}

input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.plan {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.plan-header {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}

.plan-header .field {
  flex: 1;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius);
}

.btn-secondary {
  background: var(--card);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 0.5rem 1rem;
  font-weight: 600;
}

.btn-secondary:hover { background: var(--accent-light); }

.btn-remove {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.45rem 0.75rem;
  white-space: nowrap;
}

.btn-remove:hover {
  border-color: #c0392b;
  color: #c0392b;
}

/* Advanced: tariff hours */
.toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  width: fit-content;
}

.toggle input { width: auto; accent-color: var(--accent); }

#bill-windows h3, .plan-windows h3 {
  font-size: 0.95rem;
  margin: 1rem 0 0.25rem;
}

.legend {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

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

.swatch {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 3px;
  display: inline-block;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.band-peak { background: #f6cdc9; }
.band-shoulder { background: #fbe9b8; }
.band-offpeak { background: #cfe8dd; }

.win-scroll { overflow-x: auto; }

.win-row {
  display: grid;
  grid-template-columns: 4.2rem repeat(24, 1fr);
  gap: 2px;
  margin-bottom: 2px;
  min-width: 540px;
}

.win-day {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  align-self: center;
}

.win-cell {
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 3px;
  padding: 0.3rem 0;
  font-size: 0.62rem;
  line-height: 1;
  text-align: center;
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.win-cell:hover { outline: 1px solid var(--accent); }

.plan-windows { margin-top: 0.9rem; border-top: 1px dashed var(--border); }

.plan-windows-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.8rem;
  text-decoration: underline;
  padding: 0;
}

.plan-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  margin-top: 0.75rem;
}

.plan-options .toggle { margin-top: 0; }

.plan.is-current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.badge-current { background: #55606c; }

.warning {
  background: #fff8e6;
  border: 1px solid #e8d49a;
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

/* Results */
.results-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}

.results-table th,
.results-table td {
  padding: 0.55rem 0.75rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.results-table th:first-child,
.results-table td:first-child {
  text-align: left;
}

.results-table thead th {
  background: var(--accent-light);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.results-table tbody tr:last-child td { border-bottom: none; }

.results-table .cheapest {
  background: var(--accent-light);
  font-weight: 600;
}

.badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border-radius: 99px;
  vertical-align: middle;
}

.placeholder {
  color: var(--muted);
  font-size: 0.9rem;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

footer {
  margin-top: 3rem;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

@media (max-width: 560px) {
  .results-table th, .results-table td { padding: 0.45rem 0.4rem; font-size: 0.8rem; }
  .col-optional { display: none; }
}
