/* iFrameWorx look (iframeworx.be, dns-admin.iframeworx.be): charcoal bar with logo, Montserrat uppercase
   headings with wide letter-spacing, Source Sans body, warm off-white canvas, teal actions, brand orange.
   Mobile-first. Breakpoint 720px: tabs move from a bottom bar into the top bar. */
@font-face { font-family: "Montserrat"; src: url("fonts/montserrat-latin.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Source Sans 3"; src: url("fonts/source-sans-3-latin.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
:root {
  --bg: #f4f2ef; --card: #ffffff; --fg: #2b2b2b; --muted: #6e6a65; --border: #e3dfd9; --subtle: #f3f0ec;
  --ink: #2b2b2b; --ink-fg: #e9e9e9; --ink-muted: #a6a6a6;                 /* charcoal bar, as on iframeworx.be */
  --brand: #b8702a; --sage: #587058;                                         /* logo colours */
  --a: #00838f; --a-soft: #e2f1f2; --b: #b8702a; --b-soft: #f7ece0;          /* Mode A teal (dns-admin), Mode B brand orange */
  --ok: #2e7d4f; --warn: #9a6200; --warn-soft: #fdf5e3; --danger: #c0392b;
  --radius: 8px; --shadow: 0 1px 2px rgb(43 43 43 / .06);
  --tabbar: 64px;
  --heading: "Montserrat", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color-scheme: light dark;
  font-family: "Source Sans 3", "Source Sans Pro", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px; line-height: 1.45; color: var(--fg); background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1c; --card: #262626; --fg: #ececec; --muted: #a3a09b; --border: #383634; --subtle: #2f2e2c;
    --ink: #141414; --brand: #d48a42;
    --a: #3fb6c1; --a-soft: #183638; --b: #d48a42; --b-soft: #3a2a1a;
    --ok: #63c58c; --warn: #e9be55; --warn-soft: #33290f; --danger: #ff8a7a; --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
[hidden] { display: none !important; }
/* Page shells stay hidden until the data is rendered (or loading failed): only the status line shows. */
body.loading .page, body.loading .footer { display: none !important; }
/* Signed-out visits: nothing is shown before the redirect to the login page (see auth-gate.js). */
html.auth-pending body { visibility: hidden; }
h2 { font-family: var(--heading); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .14em; margin: 0; }
p { margin: 0; }
a { color: var(--a); }
:focus-visible { outline: 2px solid var(--a); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num, .temp, time { font-variant-numeric: tabular-nums; }

/* ---------- Top bar + tabs ---------- */
/* No backdrop-filter here: it would become the containing block of the fixed bottom tab bar. */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--ink); color: var(--ink-fg); padding-top: env(safe-area-inset-top); }
.topbar-inner { max-width: 960px; margin: 0 auto; height: 56px; padding: 0 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand img { height: 24px; width: auto; display: block; }
.brand-name { font-family: var(--heading); font-size: .82rem; font-weight: 500; letter-spacing: .3em; text-transform: uppercase;
              padding-left: 12px; border-left: 1px solid #4a4a4a; white-space: nowrap; }
.updated { margin-left: auto; color: var(--ink-muted); font-size: .8rem; white-space: nowrap; }
.icon-button { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 6px;
               background: transparent; color: var(--ink-muted); cursor: pointer; }
.icon-button:hover { background: #3a3a3a; color: #fff; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button svg { width: 22px; height: 22px; }
@media (max-width: 419px) { .brand img { height: 20px; } .brand-name { letter-spacing: .2em; padding-left: 10px; } .brand { gap: 10px; } }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(3, 1fr);
        height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
        background: var(--ink); }
.tabs a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
          color: var(--ink-muted); text-decoration: none; font-family: var(--heading); font-size: .62rem; font-weight: 600;
          text-transform: uppercase; letter-spacing: .12em; }
.tabs svg { width: 22px; height: 22px; }
.tabs a[aria-current="page"] { color: #fff; }
.tabs a[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; background: var(--brand); }

@media (min-width: 720px) {
  body { padding-bottom: 0; }
  .tabs { position: static; display: flex; gap: 2px; height: 56px; padding: 0; background: none; margin-left: 20px; }
  .tabs a { flex-direction: row; gap: 8px; font-size: .7rem; padding: 0 14px; }
  .tabs svg { width: 17px; height: 17px; }
  .tabs a:hover { color: #fff; }
  .tabs a[aria-current="page"]::before { top: auto; bottom: 0; left: 14px; right: 14px; }
}

/* ---------- Footer ---------- */
.footer { max-width: 960px; margin: 8px auto 0; padding: 8px 16px 24px; color: var(--muted); font-size: .78rem;
          display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer a { color: inherit; }
.footer .made-by { font-family: var(--heading); text-transform: uppercase; letter-spacing: .14em; font-size: .66rem; }

/* ---------- Layout ---------- */
main { max-width: 960px; margin: 0 auto; padding: 16px; display: grid; gap: 14px; }
.page { display: grid; gap: 14px; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-meta, .fold-meta { color: var(--muted); font-size: .82rem; }
.note { color: var(--muted); font-size: .85rem; margin-top: 10px; }
.status { color: var(--muted); }
.status.error { color: var(--danger); background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.banner { background: var(--warn-soft); color: var(--fg); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
          border-radius: var(--radius); padding: 12px 16px; font-size: .9rem; }
.banner strong { color: var(--warn); }
.banner ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Mode badges ---------- */
.mode-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 22px; padding: 0 7px;
             border-radius: 4px; font-family: var(--heading); font-weight: 700; font-size: .72rem; color: #fff; background: var(--a); }
.mode-pill.b { background: var(--b); }
@media (prefers-color-scheme: dark) { .mode-pill { color: #141414; } }

/* ---------- Decision (hero) ---------- */
.decision { --tone: var(--a); --tone-soft: var(--a-soft); border-top: 3px solid var(--tone); }
.decision.b { --tone: var(--b); --tone-soft: var(--b-soft); }
.eyebrow { color: var(--muted); font-family: var(--heading); font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .16em; }
.decision-main { display: flex; align-items: center; gap: 14px; margin: 12px 0 0; }
.mode-mark { flex: none; width: 52px; height: 52px; border-radius: 6px; display: grid; place-items: center;
             background: var(--tone); color: #fff; font-family: var(--heading); font-size: 1.7rem; font-weight: 600; }
@media (prefers-color-scheme: dark) { .mode-mark { color: #141414; } }
.decision-title { font-family: var(--heading); font-size: 1.15rem; font-weight: 500; line-height: 1.25; text-transform: uppercase; letter-spacing: .14em; }
/* The short divider under headings is an iframeworx.be signature. */
.decision-summary { color: var(--muted); font-size: .95rem; }
.decision-summary::before { content: ""; display: block; width: 32px; height: 1px; background: var(--fg); opacity: .55; margin: 14px 0 12px; }
.decision-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 16px 0 0; }
.decision-facts > div { padding-left: 10px; border-left: 2px solid color-mix(in srgb, var(--tone) 45%, var(--border)); }
.decision-facts dt { color: var(--muted); font-family: var(--heading); font-size: .62rem; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; }
.decision-facts dd { margin: 3px 0 0; font-size: 1.1rem; font-weight: 700; white-space: nowrap; }
@media (min-width: 720px) { .decision-title { font-size: 1.45rem; } .mode-mark { width: 60px; height: 60px; font-size: 2rem; } }
.callout { margin-top: 16px; padding: 11px 12px; border-radius: 4px; font-family: var(--heading); font-weight: 600; font-size: .74rem;
           text-transform: uppercase; letter-spacing: .12em; display: flex; align-items: center; gap: 10px; }
.callout.switch { background: var(--tone); color: #fff; }
@media (prefers-color-scheme: dark) { .callout.switch { color: #141414; } }
.callout.stay { background: var(--subtle); color: var(--muted); }
.callout svg { width: 18px; height: 18px; flex: none; }

/* ---------- Settings / checklist ---------- */
.settings { list-style: none; margin: 0; padding: 0; display: grid; }
.setting { display: grid; grid-template-columns: auto 1fr; gap: 0 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.setting:first-child { border-top: 0; padding-top: 4px; }
.setting:not(.checkable) { grid-template-columns: 1fr; }
.setting input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--a); grid-row: span 2; }
.setting-name { font-weight: 600; }
.setting.done .setting-name { color: var(--muted); text-decoration: line-through; }
.setting-value { margin-top: 2px; }
.setting-note { color: var(--muted); font-size: .85rem; margin-top: 6px; }
.progress { color: var(--muted); font-size: .85rem; font-weight: 600; }
.progress.complete { color: var(--ok); }
.schedule { display: grid; gap: 6px; margin-top: 6px; }
.sched-row { display: grid; grid-template-columns: 64px 1fr; gap: 8px; align-items: start; }
.sched-days { color: var(--muted); font-size: .82rem; font-weight: 600; padding-top: 4px; }
.events { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.event { display: inline-flex; align-items: baseline; gap: 5px; padding: 3px 8px; border-radius: 4px;
         background: var(--subtle); font-size: .88rem; white-space: nowrap; }
.event time { font-weight: 700; }
.event .set { color: var(--muted); }
.event.off .set { color: var(--danger); font-weight: 600; }

/* ---------- Week strip ---------- */
.week { list-style: none; margin: 0 -16px; padding: 2px 16px 4px; display: grid; grid-auto-flow: column;
        grid-auto-columns: minmax(84px, 1fr); gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.week::-webkit-scrollbar { display: none; }
.day { scroll-snap-align: start; border: 1px solid var(--border); border-radius: 6px; padding: 10px 6px;
       display: grid; gap: 4px; justify-items: center; text-align: center; background: var(--card); }
.day.tomorrow { border: 2px solid var(--a); padding: 9px 5px; }
.day.tomorrow.b { border-color: var(--b); }
.day-name { font-family: var(--heading); font-size: .66rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .14em; }
.day-date { font-size: .78rem; color: var(--muted); }
.day .temp { font-size: 1.2rem; font-weight: 700; }
.day-range { font-size: .75rem; color: var(--muted); }

/* ---------- Folding sections ---------- */
.fold { padding: 0; }
.fold summary { list-style: none; cursor: pointer; padding: 14px 16px; display: flex; align-items: center; gap: 10px;
                font-family: var(--heading); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .14em; }
.mode-heading { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; margin: 0; font-family: var(--heading);
                font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .14em; line-height: 1.4; }
.fold summary .fold-meta { font-family: "Source Sans 3", sans-serif; text-transform: none; letter-spacing: 0; font-weight: 400; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::after { content: ""; flex: none; margin: -4px 2px 0 4px; width: 8px; height: 8px; border-right: 2px solid var(--muted);
                       border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s; }
.fold[open] summary::after { transform: rotate(-135deg); margin-top: 4px; }
.card-meta, .fold-meta, .progress { white-space: nowrap; }
.fold-title { flex: 1; min-width: 0; }
.fold > :not(summary) { margin: 0 16px; }
.fold > .note { margin-top: 0; }
.fold > .settings { margin-top: 6px; }
.fold > :last-child { margin-bottom: 14px; }

.section-caption { font-family: var(--heading); font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin: 6px 2px 10px; }

/* ---------- Prices ---------- */
.switch-row { display: flex; align-items: center; gap: 16px; }
.switch-temp { font-family: var(--heading); font-size: 2.4rem; font-weight: 500; letter-spacing: -.01em; line-height: 1; }
.switch-text { font-weight: 600; }
.switch-detail { color: var(--muted); font-size: .88rem; margin-top: 10px; }
.chip { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 4px; margin-left: 6px; vertical-align: middle; }
.chip.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.chip.changed { background: var(--warn-soft); color: var(--warn); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.tile-label { color: var(--muted); font-size: .8rem; font-weight: 600; }
.tile-value { font-size: 1.7rem; font-weight: 700; margin-top: 2px; }
.tile-value small { font-size: .8rem; font-weight: 600; color: var(--muted); margin-left: 2px; }
.tile-delta { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.tile-delta .up { color: var(--danger); } .tile-delta .down { color: var(--ok); }

.chart { position: relative; touch-action: pan-y; }
.chart svg { display: block; width: 100%; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); stroke: none; font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { stroke-width: 2.2; fill: none; }
.chart .elec { stroke: var(--a); } .chart .gas { stroke: var(--b); }
.chart .cursor { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart .dot { stroke: var(--card); stroke-width: 2; }
.chart .dot.elec { fill: var(--a); } .chart .dot.gas { fill: var(--b); }
.tooltip { position: absolute; top: 0; pointer-events: none; background: var(--fg); color: var(--card); border-radius: 4px;
           padding: 6px 9px; font-size: .8rem; line-height: 1.35; white-space: nowrap; transform: translateX(-50%); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: .82rem; margin-top: 8px; }
.swatch { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.swatch.elec { background: var(--a); } .swatch.gas { background: var(--b); }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: right; font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-family: var(--heading); font-weight: 600; font-size: .64rem; text-transform: uppercase; letter-spacing: .12em; }
.compare td:first-child { white-space: normal; }
.compare td { vertical-align: top; }
.compare .group td { font-weight: 700; padding-top: 14px; border-bottom-color: transparent; }
.basis { display: block; color: var(--muted); font-size: .72rem; }

/* History: a table on desktop, stacked cards on phones. */
.runs .changed td { background: var(--warn-soft); }
@media (max-width: 719px) {
  .runs thead { display: none; }
  .runs, .runs tbody, .runs tr, .runs td { display: block; }
  .runs tr { border-top: 1px solid var(--border); padding: 10px 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 8px; }
  .runs tr:first-child { border-top: 0; padding-top: 0; }
  .runs td { border: 0; padding: 0; text-align: left; }
  .runs td.when { grid-column: 1 / -1; font-weight: 700; }
  .runs td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: .72rem; font-weight: 600; }
  .runs .changed td { background: none; }
  .runs tr.changed { background: var(--warn-soft); margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
}
