/* Horas da luz. The font is kept with the site (SIL Open Font License, see the OFL file next to
   it); nothing is loaded from other domains. */
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("../fonts/hanken-grotesk-latin-wght-normal.woff2") format("woff2"); }

:root {
  --bg: #F4EFE3;
  --surface: #FFFCF5;
  --surface-2: #F9F4E8;
  --ink: #0B1220;
  --muted: #4B5468;
  --line: #D6CCB6;
  --accent: #85560A;
  --accent-mark: #C28A2B;
  --btn: #0B1220;
  --btn-ink: #F4EFE3;
  --focus: #9A6410;
  --vazio: #8FD0BC;
  --cheias: #F2D08A;
  --ponta: #EE9C90;
  --fora: #F2B48A;
  --low: #2E8B73;
  --mid: #B9A57A;
  --high: #C2493C;
  --band: rgba(46, 139, 115, .18);
  --now: #0B1220;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1220; --surface: #121B2E; --surface-2: #17213A; --ink: #EEE8DB; --muted: #AAB3C5; --line: #2F3D5C;
    --accent: #E8B04B; --accent-mark: #E8B04B; --btn: #E8B04B; --btn-ink: #0B1220; --focus: #E8B04B;
    --vazio: #1E6E5C; --cheias: #7A5D16; --ponta: #8E3A31; --fora: #8A4F22;
    --low: #4FC3A1; --mid: #8C8165; --high: #E8796B; --band: rgba(79, 195, 161, .22); --now: #EEE8DB;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B1220; --surface: #121B2E; --surface-2: #17213A; --ink: #EEE8DB; --muted: #AAB3C5; --line: #2F3D5C;
  --accent: #E8B04B; --accent-mark: #E8B04B; --btn: #E8B04B; --btn-ink: #0B1220; --focus: #E8B04B;
  --vazio: #1E6E5C; --cheias: #7A5D16; --ponta: #8E3A31; --fora: #8A4F22;
  --low: #4FC3A1; --mid: #8C8165; --high: #E8796B; --band: rgba(79, 195, 161, .22); --now: #EEE8DB;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 1rem/1.55 "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; overflow-wrap: break-word;
}
h1, h2, h3, h4 { line-height: 1.2; letter-spacing: 0; }
h1 { font-weight: 750; }
h2 { font-weight: 700; font-size: 1.45rem; margin: 0 0 10px; }
h3 { font-size: 1.05rem; margin: 0 0 8px; }
h4 { font-size: 1rem; margin: 0 0 8px; }
p { margin: 0 0 10px; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.skip { position: absolute; left: 12px; top: -60px; background: var(--btn); color: var(--btn-ink); padding: 10px 14px; border-radius: 8px; z-index: 10; text-decoration: none; font-weight: 600; }
.skip:focus { top: 12px; }

/* header */
.top { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; padding-bottom: 6px; flex-wrap: wrap; }
.brand { margin: 0; display: inline-flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: url("../img/icon.svg") center / cover no-repeat; flex: none; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar select { min-height: 40px; width: auto; }
.intro { padding-top: 14px; padding-bottom: 24px; }
.intro h1 { font-size: clamp(1.8rem, 4.6vw, 3rem); margin: 0 0 12px; max-width: 22ch; }
.lead { font-size: 1.06rem; max-width: 72ch; }
.notice { display: inline-block; margin: 6px 0 0; padding: 6px 12px; border: 1px dashed var(--accent-mark); border-radius: 12px; color: var(--muted); font-size: .92rem; max-width: 100%; }

/* controls */
button, select, input { font: inherit; color: inherit; }
select, input[type="text"] {
  background: var(--surface); border: 1px solid var(--muted); border-radius: 8px; padding: 8px 10px; min-height: 44px; width: 100%; max-width: 100%;
}
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 18px; border-radius: 999px; border: 1px solid var(--muted); background: var(--surface); cursor: pointer; font-weight: 600; text-align: center; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0; }

main { padding: 22px 0 56px; }
main:focus { outline: none; }
.block { margin-top: 34px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.callout { background: var(--surface); border: 1px solid var(--accent-mark); border-left-width: 5px; border-radius: var(--radius); padding: 16px 18px; }
.callout h2 { font-size: 1.3rem; }
.callout p { max-width: 75ch; }
.hint { color: var(--muted); font-size: .9rem; }
.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 14px 16px; }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.field label { font-weight: 600; font-size: .93rem; }
.field .hint { margin: 0; }
.wide { grid-column: 1 / -1; }
.tou-fields { grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); }
.with-suffix { display: flex; align-items: center; gap: 8px; }
.with-suffix input { max-width: 130px; }
.suffix { color: var(--muted); font-size: .9rem; }

/* contract */
.types { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
.types legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
.type-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.type { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; min-width: 0; }
.type:has(input:checked) { border-color: var(--accent-mark); box-shadow: inset 0 -3px 0 var(--accent-mark); }
.type input { margin: 4px 0 0; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.type-text { display: grid; gap: 2px; }
.type-title { font-weight: 700; }
.type-hint { font-size: .88rem; color: var(--muted); }

/* now */
.status-big { font-size: 1.12rem; font-weight: 600; margin: 0 0 6px; }
.status p:last-child { margin-bottom: 0; }
.chip { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .9rem; font-weight: 700; border: 1px solid var(--line); vertical-align: 1px; }

/* period colours (decoration only: every period is also written out) */
.p-vazio { background: var(--vazio); }
.p-cheias { background: var(--cheias); }
.p-ponta { background: var(--ponta); }
.p-fora { background: var(--fora); }

/* appliances */
.appl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 14px; align-items: start; }
.appl-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.appl-head input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; margin: 0; }
.appl-name { font-weight: 700; font-size: 1.05rem; }
.appl-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 8px; }
.appl .hint { margin-bottom: 6px; }
.appl-res { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.res-day { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin: 8px 0 2px; }
.res-main { font-weight: 650; margin-bottom: 2px; }
.res-cost { margin-top: 10px; font-weight: 600; }
.estimate-note { font-size: .82rem; color: var(--muted); margin: 6px 0 0; }
.is-simple .appl-res { display: none; }

/* day and week */
.legend { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .92rem; }
.legend li { display: inline-flex; gap: 6px; align-items: center; }
.dot { width: 14px; height: 14px; border-radius: 4px; display: inline-block; flex: none; border: 1px solid var(--line); }
.dot.low { background: var(--low); } .dot.high { background: var(--high); } .dot.best { background: var(--band); border-color: var(--low); }
.day { margin-bottom: 12px; }
.day-label { margin-bottom: 8px; }
.bar { position: relative; height: 40px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.seg { position: absolute; top: 0; bottom: 0; border-right: 1px solid var(--surface); }
.seg-label { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.now-mark { position: absolute; top: -2px; bottom: -2px; width: 3px; margin-left: -1px; background: var(--now); }
.ticks { position: relative; height: 20px; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ticks span { position: absolute; top: 2px; transform: translateX(-50%); }
.ticks span:first-child { transform: none; }
.segs { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .9rem; }
.segs li { display: inline-flex; gap: 6px; align-items: center; }
.seg-time { font-variant-numeric: tabular-nums; }
.week-h { margin-top: 24px; }
.week { list-style: none; margin: 0 0 8px; display: grid; gap: 8px; }
.week-row { display: grid; grid-template-columns: 7.5em minmax(0, 1fr); gap: 10px; align-items: center; }
.week-day { font-size: .9rem; font-weight: 600; }
.week-bar .bar { height: 22px; border-radius: 6px; }

/* market prices */
.chart-area { position: relative; height: 190px; padding: 20px 0 0 0; }
.chart-svg { display: block; width: 100%; height: 100%; }
.chart-max, .chart-min { position: absolute; left: 0; font-size: .78rem; color: var(--muted); }
.chart-max { top: 0; }
.chart-min { bottom: 0; }
.price.low { fill: var(--low); } .price.mid { fill: var(--mid); } .price.high { fill: var(--high); }
.best-band { fill: var(--band); }
.now-line { fill: var(--now); }
.chart .legend { margin-top: 8px; }
.best-list { margin: 0 0 8px; padding-left: 1.2em; font-size: .92rem; }
.price-table summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.table-scroll { max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.price-table table { border-collapse: collapse; width: 100%; font-size: .88rem; font-variant-numeric: tabular-nums; }
.price-table th, .price-table td { padding: 5px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.price-table th { position: sticky; top: 0; background: var(--surface-2); }
.price-table .num { text-align: right; }

/* reminders */
.remind-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.remind-status { font-weight: 600; min-height: 1.5em; margin: 0; }
.remind-list { margin: 6px 0 0; padding-left: 1.2em; }

/* when it pays off */
.explain-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.explain-grid h3 { margin-top: 6px; }
.explain-grid p { max-width: 70ch; }
.calc { margin: 12px 0; }
.calc-out { font-weight: 700; font-size: 1.05rem; margin: 12px 0 8px; color: var(--accent); }

/* footer */
.foot { border-top: 1px solid var(--line); padding: 20px 0 60px; color: var(--muted); font-size: .9rem; }
.foot p { margin: 0 0 6px; max-width: 85ch; }

@media (max-width: 860px) {
  .type-grid, .remind-grid, .explain-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .wrap { padding: 0 14px; }
  .appl-fields { grid-template-columns: minmax(0, 1fr); }
  .week-row { grid-template-columns: 7.4em minmax(0, 1fr); gap: 6px; }
  .week-day { font-size: .84rem; }
  .seg-label { font-size: .7rem; left: 2px; }
}
@media print {
  .toolbar, .skip, #remind, #setup form { display: none; }
}
