:root {
  /* MJM defaults. brand.js overrides the themed set (--header-bg … --progress) per tradie. */
  --navy: #1A2744;
  --gold: #C8A96A;
  --off-white: #F8F8F5;
  --header-bg: var(--navy);
  --header-fg: #fff;
  --header-muted: #cfd3dd;
  --brand-fg: var(--gold);
  --accent: var(--navy);
  --accent-fg: #fff;
  --step-bg: var(--navy);
  --step-fg: var(--gold);
  --progress: var(--gold);
  --ink: #1A2744;
  --muted: #5a6378;
  --line: #e2e1da;
  --ok: #1f7a4d;
  --ok-bg: #e3f4eb;
  --warn: #9a6b00;
  --warn-bg: #fff4d6;
  --bad: #a33a3a;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--off-white); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.45; font-size: 17px; }
body { min-height: 100vh; display: flex; flex-direction: column; }

/* ---- header ---- */
header { background: var(--header-bg); color: var(--header-fg); padding: .7rem 1rem; display: flex; align-items: center; gap: .8rem; }
header img.logo { height: 2.4rem; width: 2.4rem; object-fit: contain; border-radius: 50%; }
header .titles { display: grid; line-height: 1.2; }
header .brand { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--brand-fg); }
header h1 { font-size: 1.05rem; font-weight: 600; margin: 0; }
header .icon { margin-left: auto; }
button.icon { background: transparent; border: 0; color: inherit; font-size: 1.4rem; padding: .3rem .5rem; cursor: pointer; line-height: 1; min-width: 48px; min-height: 48px; }

/* ---- step nav ---- */
nav.steps { display: grid; grid-template-columns: repeat(4, 1fr); background: #fff; border-bottom: 1px solid var(--line); }
nav.steps .step { background: transparent; border: 0; border-bottom: 3px solid transparent; padding: .55rem .25rem; display: flex; flex-direction: column; align-items: center; gap: .15rem; color: var(--muted); font: inherit; font-size: .78rem; cursor: pointer; min-height: 56px; }
nav.steps .step .n { display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: #e9e9e4; color: var(--muted); font-size: .8rem; font-weight: 600; }
nav.steps .step.done .n { background: var(--ok); color: #fff; }
nav.steps .step.current { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
nav.steps .step.current .n { background: var(--step-bg); color: var(--step-fg); }
nav.steps .step:disabled { cursor: default; opacity: .6; }

/* ---- screens ---- */
main { flex: 1; width: 100%; max-width: 44rem; margin: 0 auto; padding: 1rem 1rem 6rem; }
.screen[hidden] { display: none; }
h2 { font-size: 1.35rem; font-weight: 700; margin: .5rem 0 .4rem; }
.lede { color: var(--muted); margin: 0 0 1rem; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: .9rem; }
.field-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-bottom: .5rem; }
.hint { color: var(--muted); font-size: .92rem; margin: .4rem 0 0; }
.hint.small { font-size: .82rem; }
.hint.center { text-align: center; }
.meta { color: var(--muted); font-size: .85rem; font-weight: 400; }
.status { font-size: .92rem; color: var(--muted); margin: .5rem 0 0; min-height: 1.2em; }
.status.bad { color: var(--bad); }
.status.ok { color: var(--ok); }
.summary { font-size: 1rem; margin: 0 0 .5rem; }
.warn-text { color: var(--warn); font-weight: 600; }
.ok-text { color: var(--ok); font-weight: 600; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: end; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .75rem; }
a { color: var(--accent); }

/* ---- inputs ---- */
.field { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--muted); flex: 1; min-width: 8rem; }
.field input, .field select, textarea { font: inherit; font-size: 1rem; color: var(--ink); padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px; width: 100%; background: #fff; min-height: 48px; }
.field input[type="color"] { padding: .2rem; width: 4rem; }
.field input[type="file"] { padding: .5rem; min-height: auto; }
textarea { min-height: 6rem; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }
.big-field { display: block; font-size: 1.05rem; font-weight: 600; }
.money-input { display: flex; align-items: center; gap: .4rem; margin-top: .4rem; font-size: 1.4rem; font-weight: 500; }
.money-input input { font-size: 1.6rem; font-weight: 600; width: 7rem; text-align: center; padding: .4rem; min-height: 56px; }
.check { display: flex; align-items: center; gap: .6rem; margin: .6rem 0; font-size: .95rem; min-height: 44px; }
.check input, input.pick { width: 1.4rem; height: 1.4rem; accent-color: var(--accent); }
.choices label { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; min-height: 44px; border-bottom: 1px solid var(--line); }
.choices label:last-child { border-bottom: 0; }
.choices .pill { margin-left: auto; }

/* ---- buttons ---- */
button { font: inherit; }
button.primary, button.secondary { padding: .7rem 1.1rem; border-radius: 10px; border: 1px solid var(--accent); cursor: pointer; min-height: 48px; font-weight: 600; }
button.primary { background: var(--accent); color: var(--accent-fg); }
button.secondary { background: #fff; color: var(--accent); }
button.big { width: 100%; font-size: 1.1rem; min-height: 56px; }
button:disabled { opacity: .45; cursor: default; }
button.mini { font-size: .8rem; padding: .25rem .6rem; min-height: 36px; border-radius: 8px; background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.actions { position: sticky; bottom: 0; padding: .75rem 0 .5rem; background: linear-gradient(to top, var(--off-white) 70%, transparent); }

/* ---- pills ---- */
.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: #eef0f5; color: var(--navy); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn); color: #fff; }
.pill.soft { background: var(--warn-bg); color: var(--warn); }
.pill.done { background: #dff1e4; color: var(--ok); }

/* ---- jobs list (step 2) ---- */
.joblist { display: grid; gap: .5rem; margin-top: .5rem; }
.jobrow { display: grid; grid-template-columns: auto 1fr auto; gap: .7rem; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; }
.jobrow .when { font-size: .85rem; color: var(--muted); }
.jobrow .title { font-weight: 600; }
.jobrow .sub { font-size: .85rem; color: var(--muted); white-space: pre-line; max-height: 2.6em; overflow: hidden; }
.jobrow .hours { font-weight: 600; white-space: nowrap; text-align: right; }
.jobrow.excluded { opacity: .5; }
.jobrow.excluded .title { text-decoration: line-through; }
.jobrow.done .title::after { content: " done"; font-size: .75rem; color: var(--ok); font-weight: 600; }
progress { width: 100%; height: .6rem; accent-color: var(--progress); margin-top: .5rem; }

/* ---- check screen (step 3) ---- */
details.job { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .6rem; }
details.job.flagged { border-color: var(--warn); }
details.job > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: .3rem .8rem; padding: .8rem 1rem; align-items: center; min-height: 56px; }
details.job > summary::-webkit-details-marker { display: none; }
details.job > summary .who { font-weight: 700; font-size: 1.02rem; }
details.job > summary .when { font-size: .85rem; color: var(--muted); grid-column: 1; }
details.job > summary .total { font-weight: 700; text-align: right; }
details.job > summary .state { grid-column: 2; text-align: right; }
details.job .body { border-top: 1px solid var(--line); padding: .8rem 1rem 1rem; }
.lines { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.line { display: grid; grid-template-columns: 1fr auto; gap: .2rem .8rem; align-items: center; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 10px; }
.line.flag { border-color: var(--warn); background: var(--warn-bg); }
.line .name { font-weight: 600; }
.line .detail { font-size: .85rem; color: var(--muted); }
.line .amt { font-weight: 700; text-align: right; white-space: nowrap; }
.line .amt.zero { color: var(--warn); }
.fixer { grid-column: 1 / -1; display: grid; gap: .5rem; margin-top: .3rem; }
.fixer .field select, .fixer .field input { min-height: 48px; }
.fixer .custom { display: grid; grid-template-columns: 1fr 7rem; gap: .5rem; }
.fixer .custom .field, .edit-form .field { min-width: 0; }
.line-tools { grid-column: 2; grid-row: 2; display: flex; gap: .35rem; align-items: center; justify-content: flex-end; }
.edit-form { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .4rem; padding-top: .5rem; border-top: 1px dashed var(--line); }
.edit-form[hidden] { display: none; }
.edit-form .wide { grid-column: 1 / -1; }
.edit-form .btns { display: flex; gap: .5rem; flex-wrap: wrap; }
.add-row { margin: .5rem 0 0; }
.add-row + .edit-form { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; }
.note-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: .15rem; font-size: .95rem; color: var(--ink); }
.note-lines li.missing { background: var(--warn-bg); border-radius: 6px; padding: .2rem .4rem; margin: 0 -.4rem; }
.miss-tag { margin-left: .5rem; font-size: .72rem; font-weight: 700; color: var(--warn); text-transform: uppercase; letter-spacing: .04em; }
.miss-btns { display: flex; gap: .4rem; margin-top: .25rem; }
.fixer .custom[hidden] { display: none; }
.fixer .btns { display: flex; gap: .5rem; flex-wrap: wrap; }
.hours-field { display: inline-flex; align-items: center; gap: .4rem; }
.hours-field input { width: 5rem; min-height: 44px; text-align: center; font-size: 1rem; padding: .3rem; border: 1px solid var(--line); border-radius: 8px; }
.inv-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .3rem .8rem; font-size: .85rem; margin: .8rem 0 .4rem; }
.inv-meta span { display: block; color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: .15rem .8rem; font-size: .95rem; margin-top: .6rem; padding-top: .5rem; border-top: 1px solid var(--line); }
.totals .grand { font-weight: 700; font-size: 1.05rem; }
.totals .r { text-align: right; }
.note { background: #f6f6f2; border-left: 3px solid var(--accent); border-radius: 8px; padding: .55rem .8rem; margin: 0 0 .7rem; }
.note pre { white-space: pre-wrap; font-family: inherit; font-size: .95rem; line-height: 1.45; margin: 0; color: var(--ink); }
.note-label, .lines-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 .3rem; font-weight: 600; }
details.raw { margin-top: .6rem; font-size: .85rem; color: var(--muted); }
details.raw pre { white-space: pre-wrap; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; background: #f6f6f2; padding: .5rem .7rem; border-radius: 8px; margin: .4rem 0 0; }
.notice { margin: .5rem 0 0; padding: .6rem .8rem; border-radius: 10px; font-size: .9rem; background: #eef0f5; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }

/* ---- download (step 4) ---- */
.howto ol { padding-left: 1.2rem; margin: .2rem 0 0; line-height: 1.6; }
.markdone .status { margin-top: .5rem; }

/* ---- settings dialog ---- */
dialog.settings { border: 0; border-radius: var(--radius); padding: 0; width: min(44rem, calc(100% - 1.5rem)); max-height: calc(100vh - 2rem); }
dialog.settings::backdrop { background: rgba(26, 39, 68, .55); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: .6rem .6rem .6rem 1.2rem; border-bottom: 1px solid var(--line); margin: 0; font-size: 1.05rem; }
.dialog-head .icon { color: var(--ink); }
.dialog-body { padding: 1rem 1.2rem 1.4rem; display: grid; gap: .8rem; }
details.adv { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .9rem; }
details.adv summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; gap: .5rem; }
details.adv > *:not(summary) { margin-top: .6rem; }
.brand-preview { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--muted); }
.brand-preview img { height: 1.8rem; width: 1.8rem; border-radius: 50%; object-fit: contain; }

/* ---- misc ---- */
.toast { position: fixed; left: 50%; bottom: 5.5rem; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: 10px; font-size: .95rem; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: calc(100% - 2rem); z-index: 10; }
.toast[hidden] { display: none; }
footer { text-align: center; color: var(--muted); font-size: .78rem; padding: 1rem; }
footer a { color: inherit; }

@media (min-width: 700px) {
  html, body { font-size: 16px; }
  main { padding-top: 1.5rem; }
  nav.steps .step { flex-direction: row; gap: .5rem; font-size: .9rem; }
}

.second-look ul { margin: .4rem 0 .6rem; padding-left: 1.1rem; }
.second-look li { margin: .2rem 0; }
