/* TradieLite
   Layout: sidebar nav on desktop, bottom tab bar on phones; one working column per page.
   Palette: workshop slate with a builder's-tape yellow accent, used sparingly. */
:root {
    --bg: #eef1f4;
    --panel: #ffffff;
    --ink: #1c2733;
    --muted: #5d6b78;
    --line: #d3d9df;
    --soft: #f4f6f8;
    --nav: #1f2d3a;
    --nav-ink: #c9d4de;
    --accent: #f2b705;
    --accent-ink: #1c2733;
    --good: #2f7d4f;
    --warn: #a96400;
    --bad: #b3372e;
    --display: Bahnschrift, "DIN Alternate", "Arial Narrow", system-ui, sans-serif;
    --body: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
    --radius: 8px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12181e;
        --panel: #1b232b;
        --ink: #e4e9ee;
        --muted: #93a1ae;
        --line: #2e3943;
        --soft: #222b34;
        --nav: #0e1419;
        --nav-ink: #a9b6c2;
        --good: #5cb880;
        --warn: #e0a03a;
        --bad: #e2675c;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: .01em; margin: 0; text-wrap: balance; }
h1 { font-size: 1.7rem; }
h1:focus { outline: none; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
.hint { color: var(--muted); font-size: .9rem; margin: 0; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* Boot screen (before Blazor loads) */
.boot { min-height: 100vh; display: grid; place-content: center; gap: 10px; text-align: center; background: var(--nav); color: #fff; }
.boot-mark { font-family: var(--display); font-size: 2.2rem; letter-spacing: .06em; }
.boot-mark span, .brand span { color: var(--accent); }
.boot-text { color: var(--nav-ink); }

/* Shell */
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.side { background: var(--nav); color: var(--nav-ink); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { font-family: var(--display); color: #fff; font-size: 1.35rem; letter-spacing: .05em; padding: 2px 12px 16px; text-decoration: none; }
.side a.nav { display: flex; justify-content: space-between; align-items: center; color: var(--nav-ink); text-decoration: none; padding: 10px 12px; border-radius: 6px; font-weight: 500; }
.side a.nav:hover { background: rgba(255,255,255,.07); }
.side a.nav.active { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.side .spacer { flex: 1; }
.side .biz { font-size: .8rem; padding: 8px 12px; opacity: .8; overflow-wrap: anywhere; }
.badge { font-family: var(--mono); font-size: .75rem; background: var(--bad); color: #fff; border-radius: 999px; padding: 0 7px; }
.main { min-width: 0; padding: 22px max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left)); }
.page { max-width: 1060px; margin: 0 auto; display: grid; gap: 16px; }
.tabbar { display: none; }

@media (max-width: 820px) {
    .shell { grid-template-columns: 1fr; }
    .side { display: none; }
    .main { padding-top: 14px; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
    .tabbar { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--nav); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
    .tabbar a { color: var(--nav-ink); text-decoration: none; text-align: center; font-size: .78rem; padding: 8px 2px; border-radius: 6px; font-weight: 600; }
    .tabbar a.active { background: var(--accent); color: var(--accent-ink); }
    h1 { font-size: 1.45rem; }
}

/* Page header row */
.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }

/* Buttons */
.btn { appearance: none; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; border-radius: 6px; font: inherit; font-size: .93rem; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.btn.small { padding: 4px 10px; min-height: 32px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; font-size: .85rem; }

/* Cards and stats */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card > h2, .card > h3 { margin-bottom: 10px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.stat .k { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.stat .v { font-family: var(--mono); font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.stat .v.bad { color: var(--bad); }
.stat .v.warn { color: var(--warn); }
@media (max-width: 560px) { .stats { grid-template-columns: 1fr 1fr; } .stats .stat:last-child { grid-column: span 2; } }

/* Filters */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: .85rem; cursor: pointer; }
.chip.on { background: var(--ink); color: var(--panel); border-color: var(--ink); }

/* Lists: a table on desktop, stacked rows on phones */
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: grid; grid-template-columns: 96px 1.2fr 1.6fr 110px 120px; gap: 10px; align-items: center; padding: 11px 14px; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.row:first-child { border-top: 0; }
a.row:hover { background: var(--soft); }
.row.head { background: var(--soft); font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; padding: 8px 14px; }
.row .main-text { font-weight: 600; overflow-wrap: anywhere; }
.row .sub { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.row .mono { font-family: var(--mono); font-size: .88rem; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: 4px; }
.exp-row { grid-template-columns: 92px 1.4fr 1.1fr 90px 100px 90px; }
.gear-row { grid-template-columns: 1.4fr 1fr 1fr 1fr auto; }
.search { width: 240px; max-width: 100%; min-height: 36px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: var(--panel); color: var(--ink); }
@media (max-width: 820px) {
    .row, .exp-row, .gear-row { grid-template-columns: 1fr auto; gap: 2px 12px; }
    .row.head { display: none; }
    .row > .hide-sm { display: none; }
    .row > .full-sm { grid-column: 1 / -1; }
    /* Phone rows: who and how much on top, the reference and status underneath */
    .row:has(.a-main) { grid-template-areas: "main total" "sub status" "num status"; }
    .row .a-main { grid-area: main; }
    .row .a-total { grid-area: total; }
    .row .a-sub { grid-area: sub; }
    .row .a-num { grid-area: num; font-size: .8rem; color: var(--muted); }
    .row .a-status { grid-area: status; align-self: center; justify-self: end; }
    .search { width: 100%; }
}

/* Status pills */
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.pill.draft { color: var(--muted); }
.pill.sent { color: var(--warn); }
.pill.good { color: var(--good); }
.pill.paid { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.pill.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }

/* Forms */
.form { display: grid; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: .8rem; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea, .lines input {
    font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%; min-height: 40px;
}
.field textarea { min-height: 70px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: flex-start; }
.check input { width: 18px; height: 18px; margin-top: 2px; }
.err { color: var(--bad); font-size: .88rem; }
.ok { color: var(--good); font-size: .88rem; }
.notice { border: 1px solid color-mix(in srgb, var(--warn) 50%, var(--line)); background: color-mix(in srgb, var(--warn) 10%, var(--panel)); border-radius: var(--radius); padding: 10px 14px; }
.notice.bad { border-color: color-mix(in srgb, var(--bad) 50%, var(--line)); background: color-mix(in srgb, var(--bad) 10%, var(--panel)); }
.notice ul { margin: 4px 0 0; padding-left: 1.1em; }

/* Line items editor */
.lines { display: grid; gap: 6px; }
.line { display: grid; grid-template-columns: 1fr 150px 110px 100px 36px; gap: 6px; align-items: center; }
.line.head { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.line .num { padding-right: 4px; }
.x { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 6px; height: 40px; cursor: pointer; font-size: 1.1rem; }
@media (max-width: 640px) {
    .line { grid-template-columns: 1fr 1fr 1fr 36px; }
    .line .desc { grid-column: 1 / -1; }
    .line.head { display: none; }
    .line { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
}
.totals { display: grid; grid-template-columns: auto auto; justify-content: end; gap: 2px 22px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.totals .grand { font-weight: 700; border-top: 2px solid var(--ink); padding-top: 4px; }

/* Confirm strip (no browser dialogs) */
.confirm { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; border: 1px solid color-mix(in srgb, var(--bad) 45%, var(--line)); border-radius: var(--radius); padding: 10px 12px; background: color-mix(in srgb, var(--bad) 8%, var(--panel)); }

/* Printed document (quote/invoice). On screen it's a paper-like card. */
.paper { background: #fff; color: #1c2733; border: 1px solid var(--line); border-radius: 4px; padding: 40px 44px; max-width: 800px; width: 100%; margin: 0 auto; box-shadow: 0 6px 24px rgba(0,0,0,.08); font-size: 13px; }
.paper .phead { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.paper .ptitle { font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: .04em; margin: 0; }
.paper .pmeta { color: #5d6b78; line-height: 1.6; }
.paper .pbiz { text-align: right; line-height: 1.55; color: #5d6b78; }
.paper .pbiz strong { color: #1c2733; font-size: 15px; display: block; }
.paper .plogo { max-height: 70px; max-width: 220px; display: block; margin: 0 0 6px auto; }
.paper .pfor { margin-top: 24px; }
.paper .pfor small { color: #5d6b78; display: block; }
.paper .pjob { font-size: 16px; font-weight: 600; margin-top: 14px; }
.paper table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.paper th { text-align: left; font-size: 11px; color: #5d6b78; background: #f0f2f4; padding: 7px 8px; font-weight: 600; }
.paper td { padding: 7px 8px; border-bottom: 1px solid #d3d9df; vertical-align: top; }
.paper th.r, .paper td.r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.paper .ptot { display: grid; grid-template-columns: auto 130px; justify-content: end; gap: 3px 0; margin-top: 10px; font-variant-numeric: tabular-nums; }
.paper .ptot span { padding: 2px 8px; }
.paper .ptot span:nth-child(even) { text-align: right; }
.paper .ptot .g { font-weight: 700; font-size: 15px; border-top: 2px solid #1c2733; padding-top: 5px; }
.paper .psec { margin-top: 22px; white-space: pre-line; }
.paper .psec b { display: block; margin-bottom: 2px; }
.paper .pfoot { margin-top: 22px; color: #5d6b78; }
@media (max-width: 640px) { .paper { padding: 22px 16px; font-size: 12px; } .paper .pbiz { text-align: left; } .paper .plogo { margin-left: 0; } }

.doc-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

/* Print: only the paper, on A4 */
@page { size: A4; margin: 14mm; }
@media print {
    body { background: #fff; }
    .side, .tabbar, .no-print, #blazor-error-ui { display: none !important; }
    .shell { display: block; }
    .main { padding: 0; }
    .page { max-width: none; display: block; }
    .paper { border: 0; box-shadow: none; padding: 0; max-width: none; border-radius: 0; }
    .paper tr { break-inside: avoid; }
}

#blazor-error-ui { color-scheme: light only; background: #fff4cc; color: #1c2733; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); box-sizing: border-box; display: none; left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "Something went wrong on this screen."; }

/* First-run GST question */
.gst-q { display: grid; gap: 10px; margin: 0; min-width: 0; }
.gst-q legend { float: left; width: 100%; padding: 0; margin-bottom: 4px; }
.gst-q legend + * { clear: both; }
.gst-q legend h3 { margin: 0; }
.gst-q .check input { accent-color: var(--accent); }

/* Quantity with its unit ("4 hours") on the edit screen */
.qty { display: flex; align-items: center; gap: 4px; min-width: 0; }
.qty input { min-width: 0; flex: 1; }
.qty small { color: var(--muted); white-space: nowrap; }
