/* Shift & Shine — workshop app. System fonts only (strict CSP). */
:root {
  --navy: #0f172a;
  --navy-2: #1e293b;
  --orange: #f26522;
  --orange-ink: #c2410c;
  --orange-soft: #fff1e8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, "Noto Sans Arabic", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  /* surfaces and lines that change with the theme */
  --surface: #ffffff;        /* inputs, light buttons */
  --sunk: #f8fafc;           /* row hover, calculation boxes */
  --neutral: #e2e8f0;        /* grey pills, board columns */
  --slate: #94a3b8;
  --amber: #f59e0b;
  --amber-line: #fcd34d;
  --bad-line: #fca5a5;
  --orange-line: #fed7aa;
  --unsure-bg: #fffbeb;
  --btn-dark: #0f172a;
  --shadow: rgba(15,23,42,.14);
  --focus: rgba(242,101,34,.18);
  color-scheme: light;
  accent-color: var(--orange);
}
/* Dark theme (Admin -> Company details sets the garage default; each person can switch in the top bar).
   data-theme="dark" always; data-theme="auto" follows the computer or phone setting. PDFs never use this file. */
:root[data-theme="dark"] {
  --bg: #0b1220; --card: #111a2c; --surface: #0b1424; --sunk: #0e1626; --neutral: #1e293b; --slate: #64748b;
  --line: #1f2a40; --line-2: #33415a; --ink: #e5e9f0; --ink-2: #c4cbd8; --muted: #8b97ab;
  --orange-ink: #fb8a4c; --orange-soft: #3a2014; --orange-line: #7c2d12;
  --ok: #4ade80; --ok-soft: #10301e; --warn: #fbbf24; --warn-soft: #3a2a0c; --bad: #f87171; --bad-soft: #3b1515;
  --info: #93c5fd; --info-soft: #10224a; --amber-line: #78350f; --bad-line: #7f1d1d; --unsure-bg: #2a210a;
  --navy: #070c18; --navy-2: #1e293b; --btn-dark: #334155; --shadow: rgba(0,0,0,.45); --focus: rgba(242,101,34,.35);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0b1220; --card: #111a2c; --surface: #0b1424; --sunk: #0e1626; --neutral: #1e293b; --slate: #64748b;
    --line: #1f2a40; --line-2: #33415a; --ink: #e5e9f0; --ink-2: #c4cbd8; --muted: #8b97ab;
    --orange-ink: #fb8a4c; --orange-soft: #3a2014; --orange-line: #7c2d12;
    --ok: #4ade80; --ok-soft: #10301e; --warn: #fbbf24; --warn-soft: #3a2a0c; --bad: #f87171; --bad-soft: #3b1515;
    --info: #93c5fd; --info-soft: #10224a; --amber-line: #78350f; --bad-line: #7f1d1d; --unsure-bg: #2a210a;
    --navy: #070c18; --navy-2: #1e293b; --btn-dark: #334155; --shadow: rgba(0,0,0,.45); --focus: rgba(242,101,34,.35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { font-size: 14px; }
/* workshop tablet keeps finger-sized text */
html:has(body.tablet-ui), html:has(.box.tablet) { font-size: 16px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.5; }
a { color: var(--orange-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; color: var(--ink-2); }
.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* top bar */
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 1rem; padding: 0 1rem; min-height: 48px; flex-wrap: wrap; border-bottom: 3px solid var(--orange); }
.brand { font-weight: 700; letter-spacing: .02em; color: #fff; display: flex; align-items: baseline; gap: .5rem; }
.brand span { color: var(--orange); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: .1rem; flex-wrap: wrap; flex: 1; }
.nav a { color: #cbd5e1; padding: .4rem .6rem; border-radius: 6px; font-weight: 500; white-space: nowrap; }
.nav a:hover, .nav a.active { background: var(--navy-2); color: #fff; text-decoration: none; }
.nav a.admin { color: #fdba74; }
.userbox { display: flex; align-items: center; gap: .6rem; color: #cbd5e1; font-size: .85rem; white-space: nowrap; }
.userbox button { background: transparent; border: 1px solid #475569; color: #e2e8f0; border-radius: 8px; padding: .25rem .6rem; cursor: pointer; font: inherit; }

main.page { max-width: 1200px; margin: 0 auto; padding: 1.25rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head .sub { color: var(--muted); margin-top: .15rem; }

/* cards & grid */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.1rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.tiles-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }          /* Dashboard: always 4 + 4 */
@media (max-width: 760px) { .tiles-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--orange); border-radius: var(--radius); padding: .65rem .9rem; display: block; color: var(--ink); }
.tile:hover { text-decoration: none; border-color: var(--line-2); }
.tile .n { font-size: 1.6rem; line-height: 1.2; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--muted); font-size: .9rem; }

/* definition list for record pages */
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; font-weight: 500; }

/* tables */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.list th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; padding: .5rem .6rem; border-bottom: 2px solid var(--line); }
table.list td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tbody tr:hover { background: var(--sunk); }
table.list tr.total td { font-weight: 700; border-top: 2px solid var(--line-2); }

/* forms */
.input, select.input, textarea.input { width: 100%; font: inherit; padding: .55rem .7rem; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--ink); }
textarea.input { min-height: 4rem; }
.input:focus { border-color: var(--orange); outline: none; box-shadow: 0 0 0 3px var(--focus); }
.field { margin-bottom: .9rem; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; color: var(--ink-2); }
.field .help { color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.field .error, .errorlist { color: var(--bad); font-size: .85rem; list-style: none; padding: 0; margin: .25rem 0 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1rem; }
.searchbar { display: flex; gap: .5rem; margin-bottom: 1rem; }
.searchbar .input { font-size: 1.05rem; padding: .7rem .9rem; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: .4rem; font: inherit; font-weight: 600; border-radius: 8px; padding: .45rem .85rem; border: 1px solid transparent; cursor: pointer; background: var(--btn-dark); color: #fff; white-space: nowrap; }
.btn:hover { text-decoration: none; filter: brightness(1.12); }
.btn.primary { background: var(--orange); }
.btn.light { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn.danger { background: var(--surface); color: var(--bad); border-color: var(--bad-line); }
.btn.small { padding: .3rem .65rem; font-size: .85rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

/* pills & messages */
.pill { display: inline-block; font-size: .78rem; font-weight: 600; padding: .1rem .55rem; border-radius: 999px; background: var(--neutral); color: var(--ink-2); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.warn-text { color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.orange { background: var(--orange-soft); color: var(--orange-ink); }
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .7rem 1rem; border-radius: 8px; margin-bottom: .5rem; background: var(--info-soft); color: var(--info); }
.messages li.success { background: var(--ok-soft); color: var(--ok); }
.messages li.error { background: var(--bad-soft); color: var(--bad); }
.messages li.warning { background: var(--warn-soft); color: var(--warn); }
.notice { padding: .8rem 1rem; border-radius: 8px; background: var(--warn-soft); color: var(--warn); margin-bottom: 1rem; }
.notice.bad { background: var(--bad-soft); color: var(--bad); }

/* admin panel side menu */
.panel { display: grid; grid-template-columns: 220px 1fr; gap: 1.25rem; align-items: start; }
.panel-nav { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem; position: sticky; top: 1rem; }
.panel-nav a { display: block; padding: .5rem .7rem; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.panel-nav a.active, .panel-nav a:hover { background: var(--orange-soft); color: var(--orange-ink); text-decoration: none; }
@media (max-width: 800px) { .panel { grid-template-columns: 1fr; } .panel-nav { position: static; } }

/* auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: var(--navy); }
.auth .box { background: var(--card); border-radius: 14px; padding: 2rem; width: 100%; max-width: 420px; border-top: 5px solid var(--orange); }
.auth .box h1 { font-size: 1.35rem; }
.auth .box .btn { width: 100%; justify-content: center; padding: .75rem; font-size: 1.05rem; }
.qr { max-width: 220px; margin: .5rem auto 1rem; }
.qr svg { width: 100%; height: auto; }

/* tablet PIN screen: large targets */
.tablet .names { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.tablet .names label { display: block; padding: 1rem; border: 2px solid var(--line-2); border-radius: 12px; text-align: center; font-size: 1.15rem; font-weight: 600; cursor: pointer; }
.tablet .names input { position: absolute; opacity: 0; }
.tablet .names input:checked + span { color: var(--orange-ink); }
.tablet .names label:has(input:checked) { border-color: var(--orange); background: var(--orange-soft); }
.tablet .input { font-size: 1.6rem; letter-spacing: .5em; text-align: center; }

/* review list */
.review-item { border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: .6rem; background: var(--card); }
.review-item.done { border-left: 4px solid var(--ok); }
.review-item.open { border-left: 4px solid var(--warn); }
.review-item .opts { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.review-item .opts button { font: inherit; border: 1px solid var(--line-2); background: var(--surface); padding: .35rem .8rem; border-radius: 8px; cursor: pointer; }
.review-item .opts button.chosen { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.review-item .opts button.suggested::after { content: " (suggested)"; color: var(--muted); font-weight: 400; }

.pagination { display: flex; gap: .5rem; align-items: center; margin-top: .75rem; }
.htmx-request .spinner { display: inline; }
.spinner { display: none; color: var(--muted); font-size: .85rem; }
.eyebrow { color: var(--muted); font-size: .8rem; letter-spacing: .08em; margin: 0 0 .25rem; }
.mt-1 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 1rem; }

/* ---------- phase 2 ---------- */
.topsearch input { background: var(--navy-2); border: 1px solid #334155; color: #fff; border-radius: 8px; padding: .35rem .6rem; font: inherit; width: 11rem; }
.topsearch input::placeholder { color: #94a3b8; }
.board { display: grid; grid-template-columns: repeat(6, minmax(155px, 1fr)); gap: .75rem; overflow-x: auto; align-items: start; }
.board .col { background: var(--neutral); border-radius: var(--radius); padding: .6rem; min-height: 8rem; }
.board .col h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); display: flex; justify-content: space-between; }
.jobcard { display: block; background: var(--card); border-radius: 8px; padding: .6rem .7rem; margin-top: .5rem; border-left: 4px solid var(--line-2); color: var(--ink); }
.jobcard:hover { text-decoration: none; box-shadow: 0 2px 8px var(--shadow); }
.jobcard .plate { font-family: var(--mono); font-weight: 700; font-size: 1.05rem; }
.jobcard .meta { color: var(--muted); font-size: .82rem; }
.jobcard.late { border-left-color: var(--bad); }
.jobcard.soon { border-left-color: var(--amber); }
.promise-late-text { color: var(--bad); font-weight: 600; font-size: .82rem; }
.promise-soon-text { color: var(--warn); font-weight: 600; font-size: .82rem; }
.bad-text { color: var(--bad); }
.promise-strip { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .5rem; padding: .55rem .8rem; margin-bottom: .8rem;
  border: 1px solid var(--line); border-left: 4px solid var(--bad); border-radius: var(--radius); background: var(--card); }
.promise-strip .soon-group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .4rem .5rem; }
.pchip { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .82rem; white-space: nowrap; }
.pchip.bad { background: var(--bad-soft); color: var(--bad); }
.pchip.warn { background: var(--warn-soft); color: var(--warn); }
tr.promise-late td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
tr.promise-soon td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
.field-note { font-size: .82rem; font-weight: 600; margin-top: .2rem; }
.field-note.late { color: var(--bad); }
.field-note.soon { color: var(--warn); }
.col-received .jobcard { border-left-color: var(--slate); }
.col-awaiting_approval .jobcard { border-left-color: var(--warn); }
.col-in_progress .jobcard { border-left-color: var(--info); }
.col-waiting_parts .jobcard { border-left-color: var(--orange); }
.col-ready .jobcard { border-left-color: var(--ok); }
/* past / near the promised time wins over the column colour */
.col .jobcard.late { border-left-color: var(--bad); box-shadow: 0 0 0 1px var(--bad-soft), 0 0 0 2px var(--bad-line); }
.col .jobcard.soon { border-left-color: var(--amber); box-shadow: 0 0 0 1px var(--warn-soft), 0 0 0 2px var(--amber-line); }
.state { font-size: .75rem; font-weight: 600; padding: .05rem .5rem; border-radius: 999px; white-space: nowrap; }
.state-approved, .state-flagged { background: var(--ok-soft); color: var(--ok); }
.state-waiting { background: var(--warn-soft); color: var(--warn); }
.state-not_quoted, .state-changed { background: var(--orange-soft); color: var(--orange-ink); }
.state-declined, .state-cancelled { background: var(--neutral); color: var(--muted); }
tr.cancelled td { color: var(--muted); text-decoration: line-through; }
.status-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.status-big { font-size: 1rem; padding: .3rem .8rem; }
details.inline-form summary { cursor: pointer; font-weight: 600; color: var(--orange-ink); }
.kind-row { display: flex; gap: .4rem; flex-wrap: wrap; }
.decision { display: flex; gap: .75rem; }
.decision label { font-weight: 500; }
.totals td { padding: .25rem .6rem; }
.totals .grand td { font-weight: 700; font-size: 1.1rem; border-top: 2px solid var(--line-2); }
.bigbtn { font-size: 1.1rem; padding: .9rem 1.2rem; }
.tabletlist a { display: block; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; margin-bottom: .6rem; background: var(--card); color: var(--ink); font-size: 1.1rem; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.photos a { display: block; color: var(--ink); }
.photos img { width: 100%; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }

/* ---------- shared table kit (core/tables.py, templates/_table/) ---------- */
.grid-cards { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
.tile .s { color: var(--muted); font-size: .8rem; margin-top: .1rem; }
.tile.ok { border-left-color: var(--ok); }
.tile.warn { border-left-color: var(--amber); }
.tile.bad { border-left-color: var(--bad); }
a.tile.on { background: var(--orange-soft); border-color: var(--orange); }
.tbl-tools { display: flex; gap: .5rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: .75rem; position: relative; }
.tbl-tools > .input { flex: 1; min-width: 220px; max-width: 480px; }
/* filter builder: field -> condition -> value, one row per filter; the footer never scrolls away */
.fb { position: relative; }
.fb-panel { position: absolute; z-index: 30; top: calc(100% + .35rem); left: 0; width: min(460px, calc(100vw - 32px)); max-height: min(72vh, 600px); display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: 0 10px 28px var(--shadow); }
.fb-panel[hidden] { display: none; }
.fb-body { overflow-y: auto; padding: .75rem; display: grid; gap: .5rem; }
.fb-rows { display: grid; gap: .5rem; }
.fb-row { display: grid; grid-template-columns: 1fr auto; gap: .4rem; align-items: start; }
.fb-row + .fb-row::before { content: "AND"; grid-column: 1 / -1; font-size: .72rem; font-weight: 700; letter-spacing: .08em; color: var(--muted); }
.fb-controls { display: grid; gap: .4rem; }
.fb-controls label.fb-l { display: grid; gap: .15rem; font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.fb-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.fb-remove { background: none; border: 0; color: var(--muted); font-size: 1.2rem; line-height: 1; padding: .35rem .3rem; cursor: pointer; border-radius: 6px; }
.fb-remove:hover { color: var(--bad); background: var(--bad-soft); }
.fb-add { justify-self: start; background: none; border: 0; color: var(--orange-ink); font: inherit; font-weight: 600; cursor: pointer; padding: .2rem 0; }
.fb-picks { display: flex; flex-wrap: wrap; gap: .3rem; max-height: 9.5rem; overflow-y: auto; }
.fb-picks label { display: inline-flex; align-items: center; gap: .3rem; border: 1px solid var(--line-2); border-radius: 999px; padding: .15rem .6rem; font-size: .85rem; cursor: pointer; background: var(--surface); }
.fb-picks label:has(input:checked) { border-color: var(--orange); background: var(--orange-soft); color: var(--orange-ink); }
.fb-picks input { margin: 0; }
.fb-yesno { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; justify-self: start; }
.fb-yesno label { padding: .35rem .9rem; cursor: pointer; font-weight: 600; }
.fb-yesno input { position: absolute; opacity: 0; pointer-events: none; }
.fb-yesno label:has(input:checked) { background: var(--btn-dark); color: #fff; }
.fb-yesno label:has(input:focus-visible) { outline: 3px solid var(--orange); outline-offset: -3px; }
.fb-tokens { display: flex; flex-wrap: wrap; gap: .3rem; }
.fb-tokens:empty { display: none; }
.fb-token { display: inline-flex; gap: .3rem; align-items: center; background: var(--orange-soft); color: var(--orange-ink); border-radius: 999px; padding: .1rem .5rem; font-size: .85rem; font-weight: 600; }
.fb-token button { background: none; border: 0; color: inherit; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0; }
.fb-sugg { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; max-height: 11rem; overflow-y: auto; }
.fb-sugg:empty { display: none; }
.fb-sugg button { display: block; width: 100%; text-align: left; background: var(--surface); border: 0; border-bottom: 1px solid var(--line); padding: .35rem .6rem; font: inherit; cursor: pointer; }
.fb-sugg button:hover, .fb-sugg button:focus { background: var(--orange-soft); outline: none; }
.fb-sugg li.muted { padding: .35rem .6rem; font-size: .85rem; }
.fb-hint { color: var(--bad); font-size: .8rem; }
.fb-hint:empty { display: none; }
.fb-row.show-errors .input.need { border-color: var(--bad-line); }
@media (max-width: 640px) {
  .fb-panel { position: fixed; left: 8px; right: 8px; bottom: 8px; top: auto; width: auto; max-height: 82vh; }
}
.fb-foot { display: flex; align-items: center; gap: .4rem; padding: .6rem .75rem; border-top: 1px solid var(--line); background: var(--card); border-radius: 0 0 var(--radius) var(--radius); flex-wrap: wrap; }
.fb-msg { flex: 1; min-width: 8rem; font-size: .8rem; color: var(--muted); }
.fb-msg.bad { color: var(--bad); }
.btn[disabled] { opacity: .45; cursor: not-allowed; filter: none; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: 0 0 .75rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; background: var(--orange-soft); color: var(--orange-ink); border: 1px solid var(--orange-line); border-radius: 999px; padding: .15rem .6rem; font-size: .85rem; font-weight: 600; }
.chip:hover { text-decoration: none; border-color: var(--orange); }
.chip span { font-size: 1rem; line-height: 1; }
table.list th a.sort { color: inherit; display: inline-flex; gap: .25rem; align-items: center; white-space: nowrap; }
table.list th a.sort:hover { color: var(--ink); text-decoration: none; }
table.list th .arrow { opacity: .35; font-size: .9em; }
table.list th.sorted { color: var(--orange-ink); }
table.list th.sorted .arrow { opacity: 1; }
table.list td.empty { color: var(--muted); padding: 1.2rem .6rem; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-top: .75rem; }
.pagesize select.input { width: auto; padding: .2rem .4rem; margin-left: .3rem; }
.tbl { transition: opacity .15s; }
.tbl.htmx-request { opacity: .5; pointer-events: none; }
.tbl-error { margin-bottom: .75rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.card-head h2 { margin: 0; }
.bad-text { color: var(--bad); font-weight: 600; }
.tbl-tools .spinner { align-self: center; }

/* job line form: live calculation (workshop/pricing.py) */
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 640px) { .form-grid .span-2 { grid-column: auto; } }
.calc { margin-top: .75rem; max-width: 460px; border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .8rem; background: var(--sunk); display: grid; gap: .4rem; }
.calc-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.calc-table td { padding: .15rem 0; }
.calc-table tr.strong td { font-weight: 700; border-top: 1px solid var(--line-2); padding-top: .3rem; }
.calc-table tr.muted td { color: var(--muted); font-size: .85rem; }
.calc .notice { margin: 0; }
.calc-hint { margin-top: .6rem; }
.part-picker { max-width: 560px; margin-bottom: .6rem; display: grid; gap: .3rem; }
.panel-group { display: block; padding: .6rem .7rem .2rem; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.fieldgrid td { vertical-align: top; }
.fg-opts { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: flex-end; }
.fg-check { display: inline-flex; gap: .35rem; align-items: center; font-weight: 500; }
.fg-l { display: grid; gap: .15rem; font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.fg-l.fg-num .input { width: 6.5rem; }
.field-check label { display: flex; gap: .4rem; align-items: center; font-weight: 600; margin-top: 1.4rem; }
th.center, td.center { text-align: center; }

/* shared "type -> pick" box */
.sg-wrap { position: relative; }
.sg-list { position: absolute; z-index: 40; left: 0; right: 0; top: 100%; margin: .2rem 0 0; padding: .25rem 0; list-style: none; background: var(--card); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 8px 22px var(--shadow); max-height: 18rem; overflow-y: auto; }
.sg-list[hidden] { display: none; }
.sg-list button, .sg-list a { display: grid; gap: .05rem; width: 100%; text-align: left; background: none; border: 0; padding: .4rem .7rem; font: inherit; cursor: pointer; color: var(--ink); }
.sg-list button small { color: var(--muted); font-size: .78rem; }
.sg-list button:hover, .sg-list button.on { background: var(--orange-soft); }
.sg-list .sg-manual { color: var(--orange-ink); font-weight: 600; border-top: 1px solid var(--line); }
.sg-list .sg-none { padding: .4rem .7rem; font-size: .85rem; }
.sg-note[hidden] { display: none; }
table.split tr.unsure td { background: var(--unsure-bg); }
table.split .input { min-width: 9rem; }

/* data entry rules (core/fieldrules.py): required sign, warnings, summary */
.req { color: var(--orange); font-weight: 700; margin-left: .15rem; }
.req-note { font-size: .82rem; color: var(--muted); margin: 0 0 .6rem; }
.field .warning { color: var(--warn); font-size: .85rem; margin-top: .25rem; }
.field.has-error .input { border-color: var(--bad); }
.field.has-warning .input { border-color: var(--amber); }
.form-summary ul { margin: .3rem 0 0 1.1rem; padding: 0; }
.form-summary a { color: inherit; text-decoration: underline; }
.input.upper { text-transform: uppercase; }
.field .count { float: right; font-size: .75rem; color: var(--muted); font-weight: 400; }
.tabs { display: flex; flex-wrap: wrap; gap: .3rem; margin: .5rem 0 1rem; }
.tabs a { padding: .35rem .75rem; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--ink-2); font-weight: 500; font-size: .9rem; }
.tabs a.active { background: var(--orange-soft); border-color: var(--orange); color: var(--orange-ink); }
.input.tiny { width: 5.5rem; display: inline-block; }
table.rules td { vertical-align: top; }
table.rules select.input { min-width: 9rem; }

/* theme switch in the top bar */
.themepick { position: relative; }
.themepick summary { list-style: none; cursor: pointer; border: 1px solid #475569; color: #e2e8f0; border-radius: 8px; padding: .2rem .55rem; font-size: .95rem; line-height: 1.3; }
.themepick summary::-webkit-details-marker { display: none; }
.themepick[open] summary { background: var(--navy-2); }
.themepick .menu { position: absolute; right: 0; top: calc(100% + .4rem); z-index: 50; background: var(--card); color: var(--ink); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: 0 10px 28px var(--shadow); padding: .35rem; min-width: 13rem; display: grid; gap: .15rem; white-space: normal; }
.themepick .menu .t { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: .3rem .55rem .15rem; }
.themepick .menu button { display: flex; justify-content: space-between; align-items: center; gap: .6rem; width: 100%; text-align: left; font: inherit; color: var(--ink); background: transparent; border: 0; border-radius: 7px; padding: .45rem .55rem; cursor: pointer; }
.themepick .menu button:hover { background: var(--sunk); }
.themepick .menu button.on { background: var(--orange-soft); color: var(--orange-ink); font-weight: 600; }
.themepick .menu small { color: var(--muted); font-size: .78rem; }

/* ---------- sectioned forms (form.layout): titles on the left, a 12-column grid on the right ---------- */
.form-sections { padding: 0; max-width: 900px; container-type: inline-size; }
.form-sections > .notice, .form-sections > .form-summary { margin: 1rem 1.25rem 0; }
.fsec { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 1.5rem; padding: 1.15rem 1.35rem; border-top: 1px solid var(--line); }
.fsec:first-of-type { border-top: 0; }
.fsec.plain { grid-template-columns: minmax(0, 1fr); }
.fsec .about h3 { font-size: 1rem; color: var(--ink); margin: 0 0 .25rem; }
.fsec .about p { color: var(--muted); font-size: .86rem; margin: 0; }
.g12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: .9rem 1rem; align-content: start; }
.g12 > .c2 { grid-column: span 2; } .g12 > .c3 { grid-column: span 3; } .g12 > .c4 { grid-column: span 4; }
.g12 > .c5 { grid-column: span 5; } .g12 > .c6 { grid-column: span 6; } .g12 > .c7 { grid-column: span 7; }
.g12 > .c8 { grid-column: span 8; } .g12 > .c9 { grid-column: span 9; } .g12 > .c10 { grid-column: span 10; }
.g12 > .c12 { grid-column: span 12; }
.fsec .field { margin: 0; min-width: 0; }
.fsec .input, .fsec select.input { height: 2.7rem; }
.fsec textarea.input { height: auto; min-height: 5.2rem; }
.fsec input[type=file].input { height: auto; padding: .45rem .6rem; }
/* yes/no fields as a switch, on the same line as the boxes next to them */
.fsec .field-check label { display: flex; align-items: center; gap: .6rem; min-height: 2.7rem; margin-top: 1.6rem; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.fsec .c12.field-check label, .subpanel .c12.field-check label { margin-top: 0; }
.fsec .field-check input[type=checkbox] { appearance: none; -webkit-appearance: none; flex: none; width: 2.5rem; height: 1.4rem; border-radius: 999px; background: var(--line-2); position: relative; cursor: pointer; margin: 0; transition: background .15s; }
.fsec .field-check input[type=checkbox]::after { content: ""; position: absolute; top: .2rem; left: .2rem; width: 1rem; height: 1rem; border-radius: 50%; background: var(--card); box-shadow: 0 1px 2px var(--shadow); transition: left .15s; }
.fsec .field-check input[type=checkbox]:checked { background: var(--orange); }
.fsec .field-check input[type=checkbox]:checked::after { left: 1.3rem; }
.fsec .field-check input[type=checkbox]:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.fsec .field-check .help { margin-left: 3.1rem; }
.subpanel { border-left: 3px solid var(--orange); background: var(--orange-soft); border-radius: 0 8px 8px 0; padding: .8rem 1rem; }
/* the footer bar: "* Required" left, the page's buttons right */
.form-foot { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; padding: .85rem 1.35rem; border-top: 1px solid var(--line); background: var(--sunk); border-radius: 0 0 var(--radius) var(--radius); }
.form-foot .note { color: var(--muted); font-size: .84rem; }
.form-foot .btn-row { margin-left: auto; }
@container (max-width: 640px) {
  .fsec { grid-template-columns: minmax(0, 1fr); gap: .6rem; padding: 1rem; }
  .g12 > [class*=c] { grid-column: span 12; }
  .g12 > .c2.keep, .g12 > .c3.keep, .g12 > .c4.keep { grid-column: span 4; }
  .g12 > .c8.keep, .g12 > .c9.keep, .g12 > .c10.keep { grid-column: span 8; }
  .g12 > .c6.keep { grid-column: span 6; }
  .fsec .field-check label { margin-top: 0; }
  .form-foot { padding: .75rem 1rem; }
}
@media (max-width: 640px) {
  form.form-sections .form-foot { position: sticky; bottom: 0; z-index: 5; box-shadow: 0 -6px 14px var(--shadow); }
  form.form-sections .form-foot .btn-row { width: 100%; }
  form.form-sections .form-foot .btn { flex: 1; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { .fsec .field-check input[type=checkbox], .fsec .field-check input[type=checkbox]::after { transition: none; } }
.form-grid .input:not(textarea), .form-grid select.input { height: 2.7rem; }
.form-grid .field-check label { min-height: 2.7rem; }
.card.form-width, .notice.form-width { max-width: 900px; }
.logo-pick { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.logo-thumb { height: 3.2rem; max-width: 12rem; object-fit: contain; border: 1px dashed var(--line-2); border-radius: 8px; padding: .25rem; background: #fff; }
.logo-thumb.empty { display: inline-grid; place-items: center; width: 8rem; color: #64748b; font-size: .82rem; }
.logo-pick .btn { position: relative; overflow: hidden; }
.logo-pick .logo-file { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.logo-remove { display: inline-flex; gap: .4rem; align-items: center; color: var(--muted); font-size: .88rem; }

/* ---------- table editors (Data entry rules, Labour rates, Who can change prices, Car makes, line-type fields) ---------- */
form.tedit { padding: 0; }
form.tedit > .table-wrap, form.tedit > .notice { margin: 0; padding: .4rem 1.1rem 0; }
.tedit table.list th, .tedit table.list td { vertical-align: middle; }
.tedit table.list th[scope=row] { text-transform: none; letter-spacing: 0; font-size: .92rem; color: var(--ink); font-weight: 600; white-space: nowrap; }
.tedit .input { height: 2.4rem; }
.tedit textarea.input { height: auto; }
.tedit .input.num-in, .tedit .input.tiny { width: 4.6rem; padding-inline: .45rem; }
.tedit select.input { min-width: 8.5rem; width: auto; padding-inline: .45rem; }
table.rules td:first-child { min-width: 8.5rem; }
table.rules td:first-child .small { max-width: 26ch; white-space: normal; }
table.rules input[name$="__hint"] { min-width: 7.5rem; }
.tedit input[type=checkbox] { appearance: none; -webkit-appearance: none; width: 2.5rem; height: 1.4rem; border-radius: 999px; background: var(--line-2); position: relative; cursor: pointer; margin: 0; vertical-align: middle; transition: background .15s; }
.tedit input[type=checkbox]::after { content: ""; position: absolute; top: .2rem; left: .2rem; width: 1rem; height: 1rem; border-radius: 50%; background: var(--card); box-shadow: 0 1px 2px var(--shadow); transition: left .15s; }
.tedit input[type=checkbox]:checked { background: var(--orange); }
.tedit input[type=checkbox]:checked::after { left: 1.3rem; }
.tedit input[type=checkbox]:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.fg-stack { display: grid; gap: .4rem; }
.fg-checks { display: flex; gap: .9rem; flex-wrap: wrap; }
.fg-checks label, .fg-inline { display: inline-flex; gap: .45rem; align-items: center; white-space: nowrap; }
.center { text-align: center; }
.m0 { margin: 0; }
.inline-action { display: flex; align-items: end; padding-bottom: .05rem; }
.fsec form.g12 { margin: 0; }
@media (prefers-reduced-motion: reduce) { .tedit input[type=checkbox], .tedit input[type=checkbox]::after { transition: none; } }
.fsec.stack { grid-template-columns: minmax(0, 1fr); gap: .6rem; }
.fsec.stack .about p { max-width: 70ch; }
.panel > * { min-width: 0; }
form.tedit { max-width: 100%; }
.tedit table.list th, .tedit table.list td { padding-inline: .45rem; }
.tedit table.list thead th { white-space: normal; vertical-align: bottom; }
table.fieldgrid select.input { min-width: 0; width: 100%; }
table.fieldgrid td:nth-child(4) { min-width: 9.5rem; max-width: 13rem; }
table.fieldgrid .fg-checks label, table.fieldgrid .fg-inline { white-space: normal; }
.form-sections.wide { max-width: none; }
/* job page: "Add a line" is a button that opens the form */
details.add-line > summary.btn { list-style: none; display: inline-flex; color: #fff; }
details.add-line > summary.btn::-webkit-details-marker { display: none; }
details.add-line > summary .btn-sub { font-weight: 400; opacity: .85; font-size: .88em; }
details.add-line[open] > summary.btn { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.tbl-download { display: flex; justify-content: flex-end; margin: -.35rem 0 .35rem; }
.tbl-download a { color: var(--muted); }
.tbl-download a:hover { color: var(--orange-ink); }
ol.steps { margin: 0; padding-left: 1.2rem; display: grid; gap: .35rem; }
