/* Sunsite — Blueprint components (Plan_FrontendUpdate FE.1).
   Ported from docs/design/frontend/css/blueprint.css (prototype-only demo
   controls dropped). Tokens live in tokens.css, which must load first.
   Template-side counterparts: calculator/templatetags/ui.py + templates/ui/. */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); line-height: 1.45;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px; overflow-x: hidden;
}
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: .01em; line-height: 1.15; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.05rem; } h4 { font-size: .95rem; }
p { margin: .4rem 0; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
.app-header { background: var(--sheet); border-bottom: 1.5px solid var(--ink); position: sticky; top: 0; z-index: 20; }
.app-header .in { max-width: var(--maxw); margin: 0 auto; padding: .6rem 16px; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.logo { font-weight: 700; letter-spacing: .12em; text-transform: uppercase; display: flex; gap: .45rem; align-items: center; color: var(--ink); text-decoration: none; }
.logo svg { width: 22px; height: 22px; }
.app-header nav { margin-left: auto; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.app-main { max-width: var(--maxw); margin: 0 auto; padding: 1.25rem 16px 3rem; }
.sheet { background: var(--sheet); border: 1.5px solid var(--ink); padding: 1.25rem; position: relative; }
.sheet + .sheet { margin-top: 1rem; }
.app-footer { border-top: 1px solid var(--line); background: var(--sheet); }
.app-footer .in { max-width: var(--maxw); margin: 0 auto; padding: .6rem 16px; display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.app-footer a { color: inherit; }

/* ---------- page head ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head .sub { font-family: var(--mono); font-size: .8rem; color: var(--muted); margin-top: .25rem; }
.back { font-size: .85rem; color: var(--muted); text-decoration: none; display: inline-block; margin-bottom: .35rem; }
.back:hover { color: var(--accent); }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.stack > * + * { margin-top: .75rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid2.wide-r { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
.grid2.wide-l { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.section-h { display: flex; align-items: center; gap: .75rem; margin: 1.5rem 0 .6rem; flex-wrap: wrap; }
.section-h::after { content: ""; flex: 1; border-top: 1px solid var(--line); order: 1; }
.section-h > .right { order: 2; display: flex; gap: .4rem; flex-wrap: wrap; }
.section-h h2, .section-h h3 { order: 0; }

/* ---------- boxes ---------- */
.box { border: 1.5px solid var(--ink); background: var(--sheet); padding: .9rem 1rem; position: relative; }
.box.thin { border-width: 1px; border-color: var(--line); }
.box.dashed { border-style: dashed; border-color: var(--line); }
.box-label { position: absolute; top: -.62rem; left: .75rem; background: var(--sheet); padding: 0 .35rem; font-family: var(--mono);
  font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.box.link { text-decoration: none; color: inherit; display: block; }
.box.link:hover { background: var(--fill); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 500; font-size: 1rem;
  min-height: var(--ctl-h); padding: .55rem 1.2rem; border: 1.5px solid var(--ink); background: var(--sheet); color: var(--ink); text-decoration: none; cursor: pointer; border-radius: 0; line-height: 1.2; }
.btn:hover { background: var(--fill); }
.btn:focus-visible, a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.1); background: var(--accent); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: var(--ctl-h-sm); padding: .35rem .85rem; font-size: .9rem; }
.btn.lg { min-height: var(--ctl-h-lg); padding: .75rem 1.6rem; font-size: 1.1rem; }
.btn.block { display: flex; width: 100%; }
.btn[disabled], .btn.disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }

/* ---------- chips / flags ---------- */
.flag { display: inline-flex; align-items: center; gap: .3rem; font-family: var(--mono); font-size: .78rem; text-transform: uppercase;
  padding: .2rem .55rem; border: 1px solid currentColor; white-space: nowrap; color: var(--muted); vertical-align: middle; line-height: 1.4; }
.flag.mark { color: var(--mark); } .flag.ok { color: var(--ok); } .flag.acc { color: var(--accent); } .flag.bad { color: var(--bad); }
.flag.solid { background: var(--ink); color: var(--sheet); border-color: var(--ink); }
.flag.spin::before { content: ""; width: .6em; height: .6em; border: 1.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* tooltip ⓘ */
.tip { display: inline-grid; place-items: center; width: 18px; height: 18px; border: 1px solid var(--muted); color: var(--muted); border-radius: 50%;
  font-family: var(--mono); font-size: .72rem; font-style: normal; cursor: help; position: relative; vertical-align: middle; flex: none; }
.tip:hover::after, .tip:focus::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); width: max-content; max-width: 260px;
  background: var(--ink); color: var(--sheet); font-family: var(--font); font-size: .78rem; line-height: 1.35; padding: .4rem .55rem; z-index: 40; white-space: normal; text-align: left;
}

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(var(--n, 4), 1fr); border: 1.5px solid var(--ink); background: var(--sheet); }
.kpis > div { padding: .8rem 1rem; border-right: 1px solid var(--line); min-width: 0; }
.kpis > div:last-child { border-right: 0; }
.kpis .v { font-family: var(--mono); font-size: 1.55rem; font-weight: 600; white-space: nowrap; }
.kpis .u { font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.kpis .l { font-family: var(--mono); font-size: .74rem; text-transform: uppercase; color: var(--muted); }
.kpis .hl { background: var(--fill); } .kpis .hl .v { color: var(--accent); }
.kpis.sm .v { font-size: 1.2rem; }

/* ---------- stepper ---------- */
.steps { display: inline-flex; font-family: var(--mono); font-size: .82rem; flex-wrap: wrap; }
.steps > * { padding: .45rem .9rem; border: 1px solid var(--line); margin-left: -1px; background: var(--sheet); color: var(--muted); text-decoration: none; text-transform: uppercase; }
.steps .done { color: var(--ok); } .steps .cur { background: var(--ink); color: var(--sheet); border-color: var(--ink); }
.steps a:hover { background: var(--fill); }
.steps .lock { opacity: .55; }

/* ---------- forms ---------- */
label.f, span.f { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .2rem; }
.field { margin-bottom: .8rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=url], input[type=tel], select, textarea {
  font: inherit; font-size: .95rem; color: var(--ink); background: var(--sheet); border: 1.5px solid var(--ink); padding: .45rem .6rem; width: 100%; border-radius: 0; min-width: 0;
}
input[type=number] { font-family: var(--mono); }
input.inline, select.inline { width: auto; display: inline-block; }
textarea { min-height: 4.5rem; resize: vertical; }
input[type=file] { font: inherit; font-size: .9rem; max-width: 100%; }
input[type=file]::file-selector-button { font: inherit; font-weight: 500; min-height: var(--ctl-h-sm); padding: .35rem .85rem; margin-right: .6rem;
  border: 1.5px solid var(--ink); background: var(--sheet); color: var(--ink); cursor: pointer; border-radius: 0; }
input[type=file]::file-selector-button:hover { background: var(--fill); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 1rem; height: 1rem; vertical-align: -2px; }
.check { display: flex; gap: .45rem; align-items: center; margin: .35rem 0; cursor: pointer; }
.inp-group { display: flex; border: 1.5px solid var(--ink); background: var(--sheet); }
.inp-group input { border: 0; flex: 1; }
.inp-group .btn { border-width: 0 0 0 1.5px; }
.seg { display: inline-flex; flex-wrap: wrap; }
.seg > label, .seg > button, .seg > a { border: 1.5px solid var(--ink); margin-left: -1.5px; min-height: var(--ctl-h-sm); display: inline-flex; align-items: center; padding: .4rem .9rem; cursor: pointer; background: var(--sheet); font-size: .95rem; color: var(--ink); text-decoration: none; font-family: inherit; }
.seg > :first-child { margin-left: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg > label:has(input:checked), .seg > .on { background: var(--ink); color: var(--sheet); }
.formgrid { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: .25rem 1rem; }
fieldset { border: 1px solid var(--line); padding: .75rem 1rem .25rem; margin: 0 0 1rem; }
legend { font-family: var(--mono); font-size: .76rem; text-transform: uppercase; color: var(--muted); padding: 0 .35rem; }
.err { color: var(--bad); font-size: .82rem; }

/* range slider */
.slider { display: grid; grid-template-columns: 7rem 1fr 5.5rem; gap: .75rem; align-items: center; margin: .45rem 0; }
.slider output { font-family: var(--mono); text-align: right; }
input[type=range] { width: 100%; accent-color: var(--accent); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; background: var(--sheet); border: 1.5px solid var(--ink); font-size: .88rem; }
table.t th { font-family: var(--mono); font-size: .74rem; text-transform: uppercase; font-weight: 400; color: var(--muted); text-align: left; padding: .4rem .6rem; border-bottom: 1.5px solid var(--ink); white-space: nowrap; }
table.t tbody th { border-bottom: 1px solid var(--line); text-transform: none; font-family: var(--font); font-size: .88rem; color: var(--muted); }
table.t td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t .r { text-align: right; }
table.t tr.hl td { background: var(--fill); }
table.kv { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.kv th { text-align: left; font-weight: 400; color: var(--muted); padding: .3rem .75rem .3rem 0; white-space: nowrap; vertical-align: top; width: 1%; }
table.kv td { padding: .3rem 0; }
.neg { color: var(--bad); }
.better { color: var(--ok); font-family: var(--mono); font-size: .75rem; }

/* ---------- details / accordion ---------- */
details.acc { border-top: 1px solid var(--line); }
details.acc:last-of-type { border-bottom: 1px solid var(--line); }
details.acc > summary { list-style: none; cursor: pointer; padding: .6rem .25rem; display: flex; gap: .5rem; align-items: center; }
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::before { content: "▸"; font-family: var(--mono); color: var(--accent); width: 1em; }
details.acc[open] > summary::before { content: "▾"; }
details.acc > .body { padding: .25rem .25rem 1rem 1.5rem; }
details.acc > summary .right { margin-left: auto; }

/* tabs */
.tabs { display: flex; border-bottom: 1.5px solid var(--ink); flex-wrap: wrap; }
.tabs > a, .tabs > button { min-height: var(--ctl-h); display: inline-flex; align-items: center; padding: .55rem 1.1rem; color: var(--muted); text-decoration: none; font: inherit; font-size: 1rem; border: 0; border-right: 1px solid var(--line); background: var(--sheet); cursor: pointer; }
.tabs > .on { color: var(--sheet); background: var(--ink); }
.tabs .count { font-family: var(--mono); font-size: .8rem; margin-left: .3rem; }
[data-panel]:not(.on) { display: none; }

/* ---------- charts ---------- */
.chart { color: var(--c-ink); }
.chart svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.chart-row { display: flex; flex-wrap: wrap; justify-content: center; gap: .75rem; }
.chart.scroll { overflow-x: auto; } .chart.scroll svg { max-width: none; }
.chart.fit svg { width: 100%; max-width: 420px !important; }
.ph { border: 1px dashed var(--line); color: var(--muted); font-family: var(--mono); font-size: .78rem; display: grid; place-items: center; min-height: 80px; }


/* ---------- list rows ---------- */
.list { border: 1.5px solid var(--ink); background: var(--sheet); }
.list > .li { display: flex; align-items: center; gap: .75rem; padding: .65rem .85rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; color: inherit; text-decoration: none; }
.list > .li:last-child { border-bottom: 0; }
.list > a.li:hover { background: var(--fill); }
.li .grow { flex: 1; min-width: 10rem; }
.empty { padding: 1.25rem; text-align: center; color: var(--muted); border: 1px dashed var(--line); background: var(--sheet); }
.empty .btn { margin-top: .6rem; }

/* gauge (slots) */
.gauge { display: inline-grid; grid-template-columns: repeat(var(--n, 5), 16px); border: 1.5px solid var(--ink); vertical-align: middle; }
.gauge i { height: 12px; border-right: 1px solid var(--ink); } .gauge i:last-child { border-right: 0; } .gauge i.f { background: var(--accent); }

/* hero */
.hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 2rem; align-items: center; padding: 2.5rem 0 1.5rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.1rem); text-transform: uppercase; letter-spacing: .02em; line-height: 1.05; }
.hero h1 span { color: var(--accent); }
.dimline { display: flex; align-items: center; gap: .5rem; font-family: var(--mono); font-size: .76rem; color: var(--muted); margin-top: .4rem; }
.dimline::before, .dimline::after { content: ""; flex: 1; border-top: 1px solid var(--muted); }
.flowsteps { display: grid; gap: .6rem; }
.flowsteps .box { display: flex; gap: .75rem; align-items: center; }
.flowsteps .n { font-family: var(--mono); font-weight: 600; color: var(--accent); }

/* ---------- toast & dialog ---------- */
.toasts { position: fixed; top: 4.2rem; right: 16px; z-index: 60; display: grid; gap: .5rem; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--sheet); border: 1.5px solid var(--ink); border-left: 5px solid var(--ok); padding: .6rem .8rem; display: flex; gap: .6rem; align-items: start; box-shadow: 4px 4px 0 var(--line); animation: tin .2s ease-out; }
.toast.warn { border-left-color: var(--mark); } .toast.err { border-left-color: var(--bad); } .toast.info { border-left-color: var(--accent); }
.toast button { margin: -.4rem -.5rem -.4rem auto; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1.1rem;
  min-width: var(--ctl-h-sm); min-height: var(--ctl-h-sm); display: inline-flex; align-items: center; justify-content: center; }
@keyframes tin { from { transform: translateY(-6px); opacity: 0; } }
dialog.confirm { border: 1.5px solid var(--ink); padding: 0; background: var(--sheet); color: var(--ink); max-width: min(420px, calc(100vw - 32px)); box-shadow: 6px 6px 0 var(--line); }
dialog.confirm::backdrop { background: rgb(11 42 74 / .35); }
dialog.confirm .hd { padding: .75rem 1rem; border-bottom: 1.5px solid var(--ink); font-weight: 700; }
dialog.confirm .bd { padding: .75rem 1rem; color: var(--muted); }
dialog.confirm .ft { padding: .75rem 1rem; display: flex; justify-content: flex-end; gap: .5rem; border-top: 1px solid var(--line); }

/* printable */
@media print {
  body { background: #fff; } .app-header, .app-footer, .skip-link, .no-print, .toasts { display: none !important; }
  .sheet { border: 0; padding: 0; }
}

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .hero, .grid2, .grid2.wide-r, .grid2.wide-l { grid-template-columns: 1fr; }
  .grid3, .grid4 { grid-template-columns: 1fr 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpis > div:nth-child(2n) { border-right: 0; }
  .kpis > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .kpis .v { font-size: 1.25rem; }
  .formgrid { grid-template-columns: 1fr; }
  .slider { grid-template-columns: 5.5rem 1fr 4.5rem; gap: .5rem; }
  .hide-sm { display: none !important; }
  .sheet { padding: 1rem .85rem; }
}
@media (max-width: 460px) { .grid3, .grid4 { grid-template-columns: 1fr; } }

/* ---------- production additions (not in the prototype) ---------- */
/* Skip link: first focusable element in the shell. */
.skip-link { position: absolute; left: 16px; top: -3rem; z-index: 80; background: var(--ink); color: var(--sheet); padding: .45rem .8rem; text-decoration: none; }
.skip-link:focus { top: .5rem; }
/* Header log-out is a POST form; keep it inline with the nav links. */
.app-header nav form { margin: 0; display: inline-flex; }
/* Stepper steps that are POST forms (Optimise / Request quotes) look like links. */
.steps > form { padding: 0; border: 0; margin-left: -1px; background: none; display: flex; }
.steps > form > button { font: inherit; text-transform: uppercase; padding: .45rem .9rem; border: 1px solid var(--line); background: var(--sheet); color: var(--muted); cursor: pointer; border-radius: 0; }
.steps > a, .steps > span, .steps > form > button { display: flex; align-items: center; min-height: var(--ctl-h); }
.steps > form > button:hover { background: var(--fill); }
.steps > :first-child { margin-left: 0; }
/* Phones: the four steps share one full-width row (labels wrap inside a cell)
   rather than spilling «Request quotes» onto a second line. */
@media (max-width: 640px) {
  .steps { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); width: 100%; font-size: .74rem; }
  .steps > * { padding: .35rem .3rem; justify-content: center; text-align: center; }
  .steps > form > button { width: 100%; padding: .35rem .3rem; justify-content: center; }
}
/* Toasts never block the page underneath — only the ✕ takes clicks. */
.toasts, .toast { pointer-events: none; }
.toast button { pointer-events: auto; }
.toast.out { opacity: 0; transition: opacity .3s; }
/* System pages (404/403/500, session expired): one small sheet, centred. */
.sys-page { max-width: 34rem; margin: 2.5rem auto; }
.sys-page .code { font-family: var(--mono); font-size: 2.4rem; font-weight: 600; color: var(--accent); line-height: 1; }
.sys-page.warn .code { color: var(--mark); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- FE.2 additions (homeowner estimate pages) ---------- */
/* Segmented controls hide the radio itself — show keyboard focus on the label. */
.seg > label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -4px; }
.seg > label:has(input:disabled) { cursor: not-allowed; }
fieldset[disabled] { opacity: .6; }
@media (max-width: 460px) { .seg > label { padding: .35rem .6rem; } }
fieldset.bare { border: 0; padding: 0; margin: 0; min-width: 0; }
/* Address bar on the landing page: the primary button drops below on phones. */
@media (max-width: 460px) {
  .inp-group.stack-sm { flex-wrap: wrap; }
  .inp-group.stack-sm input { flex: 1 1 60%; }
  .inp-group.stack-sm .btn.primary { flex: 1 1 100%; border-width: 1.5px 0 0; padding: .65rem; }
}
/* Inline title edit: an input that looks like the page heading. */
.title-edit { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: 0; }
.title-edit input[type=text] { font-size: 1.7rem; font-weight: 700; border-color: transparent; background: transparent; padding: .1rem .3rem; margin-left: -.3rem; width: auto; flex: 1 1 14rem; max-width: 100%; }
.title-edit input[type=text]:hover, .title-edit input[type=text]:focus { border-color: var(--line); background: var(--sheet); }
/* ⋯ menu: a <details> that drops a list. */
details.more { position: relative; display: inline-block; }
details.more > summary { list-style: none; }
details.more:not([open]) > .list { display: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > .list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 15; min-width: 220px; box-shadow: 4px 4px 0 var(--line); }
/* Phones: the ⋯ button can sit anywhere in a wrapping .btn-row, so the menu
   anchors to the row (full width) instead of the button and never overflows. */
@media (max-width: 460px) {
  .btn-row:has(> details.more) { position: relative; }
  .btn-row > details.more { position: static; }
  details.more > .list { left: 0; right: 0; min-width: 0; }
}
.list > button.li { width: 100%; font: inherit; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; cursor: pointer; color: inherit; }
.list > button.li:hover { background: var(--fill); }
.btn-row > form { margin: 0; display: inline-flex; }
/* Chips that are buttons (owner-only «stale ↻» re-run). */
button.flag { background: none; cursor: pointer; font-family: var(--mono); }
button.flag:hover { background: var(--fill); }
/* Clickable chips (buttons / links) are small-button tall so they're easy to hit. */
button.flag, a.flag { min-height: var(--ctl-h-sm); padding: .3rem .65rem; }
/* Small disclosure toggles (⚙ settings, «▸ 7 postcodes», «▸ Notes») likewise. */
summary.small, summary.row { min-height: var(--ctl-h-sm); padding-block: .4rem; cursor: pointer; }
form.inline { display: inline; margin: 0; }
/* Map thumbnail (OSM embed behind a click-to-interact overlay). */
.map-thumb { position: relative; width: 100%; max-width: 320px; }
.map-thumb iframe { display: block; width: 100%; height: 160px; border: 1px solid var(--line); }
.map-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; color: transparent; font-size: .82rem; }
.map-overlay:hover, .map-overlay:focus { background: rgb(11 42 74 / .45); color: #fff; }
.map-overlay.on { display: none; }
/* Monthly bars on the result page (plain HTML, no SVG). */
.mbars { display: grid; grid-template-columns: 2.5rem 1fr 6rem; gap: .2rem .5rem; align-items: center; font-family: var(--mono); font-size: .75rem; }
.mbars i { display: block; height: .9rem; background: var(--c-solar, #fbbf24); }
.mbars .r { text-align: right; }
/* Appliance composer rows. */
.appliance-row { display: grid; grid-template-columns: minmax(0, 2fr) 6.5rem auto auto auto; gap: .5rem; align-items: center; margin: .35rem 0; }
.appliance-row > * { min-width: 0; }
.appliance-row .err { grid-column: 1 / -1; margin: 0; }
.appliance-row input[type=number] { width: 5.5rem; }
.household-form .row input[type=number] { width: 7rem; flex: none; }
@media (max-width: 640px) { .appliance-row { grid-template-columns: minmax(0, 1fr) 6.5rem; } .appliance-row .appliance-remove { justify-self: end; } }
.months-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .25rem .5rem; }
@media (max-width: 640px) { .months-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* Optimise: ★ best-fit bar and slider label row. */
.bestfit { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; background: var(--fill); }
.bestfit form { margin-left: auto; }
.slider label { font-size: .85rem; }
/* Charts whose intrinsic size follows the data (surface grids) fill their box;
   the refine load shape is capped so its axis text stays readable. */
.chart.full svg { width: 100%; }
.chart.mid svg { width: 100%; max-width: 640px !important; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.print-only { display: none; }
@media print { .print-only { display: block !important; } }
/* On screen a heading only for screen readers (the owner edits the title in an input);
   printed as a normal heading. */
.sr-print { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media print { .sr-print { position: static; width: auto; height: auto; overflow: visible; clip: auto; } }
/* Printable summary (also the WeasyPrint PDF source). */
.qr svg { width: 86px; height: 86px; display: block; }
@media print {
  @page { size: A4; margin: 10mm; }
  .kpis { break-inside: avoid; }
  .box { break-inside: avoid; }
  .print-grid .chart svg { max-height: 161px; }
  .summary-numbers .box, .print-grid .box { padding: .35rem .55rem; }
}

/* ---------- FE.3 additions (account and auth pages) ---------- */
/* Narrow centred auth sheets (log in, reset password). */
.narrow { max-width: 380px; margin: 1.5rem auto; }
/* Favourite star on dashboard cards. */
.star { text-decoration: none; font-size: 1.35rem; color: var(--muted); line-height: 1;
  min-width: var(--ctl-h-sm); min-height: var(--ctl-h-sm); display: inline-flex; align-items: center; justify-content: center; }
.star.on { color: var(--c-solar, #f59e0b); }
/* ⚙ settings: the summary is the panel heading. */
details.account-settings > summary { display: flex; width: 100%; }
details.account-settings > summary::-webkit-details-marker { display: none; }
details.account-settings[open] > summary span[aria-hidden] { transform: rotate(180deg); }
a.flag { text-decoration: none; }
a.flag:hover { background: var(--fill); }
details.li > summary { list-style: none; }
details.li > summary::-webkit-details-marker { display: none; }
details.li > summary::before { content: "▸ "; color: var(--accent); font-family: var(--mono); }
details.li[open] > summary::before { content: "▾ "; }
/* Phone touch targets: text inputs/selects 44px (FE.7); buttons are sized by --ctl-h*. */
@media (max-width: 640px) {
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=url], input[type=tel], select { min-height: 2.75rem; font-size: 1rem; }
  h1 { font-size: 1.4rem; } h2 { font-size: 1.2rem; }
}

/* ---------- FE.4 additions ---------- */
/* Grid/flex children may shrink below their content (long kv labels, chip rows). */
.grid2 > *, .grid3 > *, .grid4 > *, .page-head > * { min-width: 0; max-width: 100%; }
@media (max-width: 460px) { table.kv th { white-space: normal; width: 40%; } }

/* ---------- FE.5 additions (installer portal) ---------- */
.installer-bar .tabs > a { display: inline-flex; align-items: center; }
/* Quote builder / importer line rows. */
.list > .quote-line, .quote-line { display: grid; grid-template-columns: 8rem minmax(0, 1fr) 4.5rem 6.5rem 4.5rem 6rem 3rem; gap: .4rem; align-items: center; }
.quote-line .slug-order { grid-column: 2 / -1; }
.quote-line .slug-order input { width: auto; flex: 1 1 8rem; }
.quote-line .err { grid-column: 1 / -1; margin: 0; }
.quote-head { display: grid; grid-template-columns: 8rem minmax(0, 1fr) 4.5rem 6.5rem 4.5rem 6rem 3rem; gap: .4rem; padding: 0 .85rem; }
@media (max-width: 760px) {
  .list > .quote-line, .quote-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .quote-line > [name$="-description"] { grid-column: 1 / -1; }
  .quote-line .slug-order { grid-column: 1 / -1; }
  .quote-head { display: none; }
}
.file-chip { text-transform: none; font-size: .78rem; }
.contact-line > span + span::before { content: " · "; color: var(--muted); }

/* ---------- FE.6 additions (flag-off extras, directory, utility) ---------- */
/* Heading tabs: each tab label is a heading (screen-reader heading navigation lands on
   it) wrapping a link that switches the [data-panel]. */
.tabs > h2, .tabs > h3 { margin: 0; font-size: .9rem; font-weight: 500; }
.tabs > h2 > a, .tabs > h3 > a { display: block; padding: .5rem 1rem; color: var(--muted); text-decoration: none; background: var(--sheet); border-right: 1px solid var(--line); }
.tabs > * > a.on { color: var(--sheet); background: var(--ink); }
.tabs + [data-panel] > .table-wrap > table.t, .tabs ~ [data-panel] > .table-wrap > table.t { border-top: 0; }
/* Jump links + anchored section rules (More detail). */
.jump { font-size: .82rem; margin-bottom: .5rem; }
.jump a + a::before { content: "·"; color: var(--muted); display: inline-block; margin-right: .35rem; text-decoration: none; }
.section-h[id] { scroll-margin-top: 4.5rem; }
/* What-if: figures dim while a recompute is pending. */
.whatif-figs { transition: opacity .15s ease; }
.whatif-figs.busy { opacity: .55; }
table.kv td.r, table.kv th + td.r { text-align: right; }
/* Directory cards: the name is the link (the e2e page object reads it). */
.cards > article.box h2 { font-size: 1rem; margin: 0; }
.cards > article.box h2 a { color: var(--ink); text-decoration: none; }
.cards > article.box h2 a:hover { color: var(--accent); text-decoration: underline; }
.filters .lbl { width: 3.75rem; }
.postcodes { columns: 3; column-gap: 1rem; max-width: 36rem; }
@media (max-width: 460px) { .postcodes { columns: 2; } }
/* Utility results: tech section rules carry their headline numbers on the right. */
.tech-sec .right { font-family: var(--mono); font-size: .75rem; color: var(--muted); }
h2.box-label, h3.box-label, h4.box-label { font-weight: 400; margin: 0; }
details.acc > summary > h2, details.acc > summary > h3 { font-size: 1rem; margin: 0; }
