:root {
  --ink: #1b1733;
  --ink-2: #4a4666;
  --muted: #817d99;
  --line: #e6e3ef;
  --bg: #f5f4f9;
  --card: #fff;
  --hover: #faf9fd;
  --field-line: #d9d5e6;
  --btn-hover-line: #cfc9e0;
  --brand: #7c3aed;
  --brand-solid: #7c3aed;
  --brand-solid-hover: #6d28d9;
  --brand-soft: #f1ebff;
  --focus: #c4b5fd;
  --brand-2: #db2777;
  --brand-3: #06b6d4;
  --grad: linear-gradient(90deg, #06b6d4, #7c3aed 55%, #db2777);
  --ok: #059669;
  --warn: #d97706;
  --bad: #dc2626;
  --bad-line: #fecaca;
  --shadow: 0 8px 24px rgba(20,10,60,.12);
  --scrim: rgba(0,0,0,.25);
  --st-neutral-bg: #eef0f3; --st-neutral-fg: #5b6472;
  --st-warn-bg: #fff4e0;    --st-warn-fg: #9a5b00;
  --st-info-bg: #e6f1ff;    --st-info-fg: #1d5fbf;
  --st-ok-bg: #e3f7ee;      --st-ok-fg: #0b7a4e;
  --st-bad-bg: #fde8e8;     --st-bad-fg: #b42318;
  --tint-warn: #fff4e0;     --tint-bad: #fde8e8;      /* soft background for highlighted rows/boxes */
  --st-it-bg: #e0f7fb;      --st-it-fg: #0e7490;
  --hero-bg: #1b1733;
  --hero-sub: #c9c4e6;
  --timeline: #ddd6fe;
  --top-bg: #fff;
  --nav-bg: #fff; --nav-fg: #4a4666; --nav-hover: #f5f4f9; --nav-active-bg: #f1ebff; --nav-active-fg: #7c3aed; --nav-line: #e6e3ef;
  --r: 0;          /* corner radius: sharp everywhere */
  --radius: var(--r);
  --nav-w: 220px;
  --top-h: 56px;
  font-size: 15px;
  color-scheme: light;
}
/* Themes: each person picks Light, Dark or Ninja on their own settings page (data-theme on <html>). */
:root[data-theme="dark"] {
  --ink: #ece9f7;
  --ink-2: #c3bedb;
  --muted: #938eae;
  --line: #2e2a45;
  --bg: #121020;
  --card: #1b1830;
  --hover: #221f3a;
  --field-line: #3a3556;
  --btn-hover-line: #4b4570;
  --brand: #b79cff;
  --brand-solid: #7c3aed;
  --brand-solid-hover: #8b5cf6;
  --brand-soft: #2c2350;
  --focus: #6d4fc9;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --bad-line: #7f1d1d;
  --shadow: 0 8px 24px rgba(0,0,0,.5);
  --scrim: rgba(0,0,0,.55);
  --st-neutral-bg: #2a2838; --st-neutral-fg: #b8b5c8;
  --st-warn-bg: #3a2a0c;    --st-warn-fg: #fcd34d;
  --st-info-bg: #132a4a;    --st-info-fg: #93c5fd;
  --st-ok-bg: #0d3325;      --st-ok-fg: #6ee7b7;
  --st-bad-bg: #3d1515;     --st-bad-fg: #fca5a5;
  --tint-warn: #2e2410;     --tint-bad: #321717;
  --st-it-bg: #0c2f38;      --st-it-fg: #67e8f9;
  --hero-bg: #0b0916;
  --hero-sub: #b3add3;
  --timeline: #3b2f6b;
  --top-bg: #1b1830;
  --nav-bg: #1b1830; --nav-fg: #c3bedb; --nav-hover: #221f3a; --nav-active-bg: #2c2350; --nav-active-fg: #b79cff; --nav-line: #2e2a45;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.45;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 0 0 .5rem; color: var(--ink-2); }
small, .muted { color: var(--muted); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }


/* Ninja: matches Invoice Ninja in dark mode — black page, dark grey panels, charcoal sidebar,
   blue marker on the active menu item, green main buttons, solid coloured status tags */
:root[data-theme="ninja"] {
  --ink: #ffffff; --ink-2: #d4d4d4; --muted: #9e9e9e; --line: #333336; --bg: #000000; --card: #1f1f21; --hover: #29292c;
  --field-bg: #2d2d30; --field-line: #3d3d41; --btn-hover-line: #5a5a5f;
  --brand: #5b9bd5; --brand-solid: #3e7d3a; --brand-solid-hover: #4a8f45; --brand-soft: #1b2430; --focus: #2f6fb0;
  --grad: linear-gradient(90deg, #333336, #333336);
  --ok: #6cc070; --warn: #e0a030; --bad: #ef5350; --bad-line: #6b2020;
  --shadow: 0 8px 24px rgba(0,0,0,.6); --scrim: rgba(0,0,0,.6);
  --st-neutral-bg: #5a5a5e; --st-neutral-fg: #fff;
  --st-warn-bg: #a6720f;    --st-warn-fg: #fff;
  --st-info-bg: #2c47a8;    --st-info-fg: #fff;
  --st-ok-bg: #437a3b;      --st-ok-fg: #fff;
  --st-bad-bg: #a33a3a;     --st-bad-fg: #fff;
  --tint-warn: #2a2213;     --tint-bad: #2c1818;      /* Ninja tags are solid; rows get only a faint tint */
  --st-it-bg: #1f5f73;      --st-it-fg: #fff;
  --hero-bg: #1f1f21; --hero-sub: #b0b0b0; --timeline: #2f4a66;
  --top-bg: #000000;
  --nav-bg: #202124; --nav-fg: #c8c8c8; --nav-hover: #2a2b2f; --nav-active-bg: #1b2330; --nav-active-fg: #ffffff; --nav-line: #2a2a2d;
  color-scheme: dark;
}
:root[data-theme="ninja"] .sidenav a.active { box-shadow: inset 4px 0 0 #4a8fd8; }
:root[data-theme="ninja"] .sidenav a svg { color: #9e9e9e; }
:root[data-theme="ninja"] .sidenav a.active svg { color: #fff; }
:root[data-theme="ninja"] .topbar::after { height: 1px; background: var(--line); }
:root[data-theme="ninja"] .badge { min-width: 84px; text-align: center; padding: 3px 8px; font-weight: 500; }
:root[data-theme="ninja"] table.list th { color: #fff; text-transform: none; letter-spacing: 0; font-size: .85rem; }
:root[data-theme="ninja"] .stat, :root[data-theme="ninja"] .card { border-color: #2a2a2d; }
:root[data-theme="ninja"] .btn { background: #2d2d30; border-color: #3d3d41; color: #fff; }
:root[data-theme="ninja"] .btn.primary { background: var(--brand-solid); border-color: var(--brand-solid); }
:root[data-theme="ninja"] .btn.danger { color: #ef5350; }
:root[data-theme="ninja"] .tag { background: #1b2430; color: #8fbfe8; }
:root[data-theme="ninja"] .brand { color: #fff; }

/* ---------- app shell ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--top-h); z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--top-bg); border-bottom: 1px solid var(--line);
}
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--grad); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.brand img { height: 32px; }
.brand:hover { text-decoration: none; }
.search { flex: 1; max-width: 420px; margin-left: 12px; margin-right: auto; }
.search input { width: 100%; }
.who { margin-left: 8px; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.menu-btn { display: none; background: none; border: 0; padding: 6px; cursor: pointer; color: var(--ink); }
.sidenav {
  position: fixed; top: var(--top-h); left: 0; bottom: 0; width: var(--nav-w); z-index: 20;
  background: var(--nav-bg); border-right: 1px solid var(--nav-line); padding: 12px 8px; overflow-y: auto;
}
.sidenav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--r);
  color: var(--nav-fg); font-weight: 500;
}
.sidenav a:hover { background: var(--nav-hover); text-decoration: none; }
.sidenav a.active { background: var(--nav-active-bg); color: var(--nav-active-fg); }
.main { margin: var(--top-h) 0 0 var(--nav-w); padding: 24px; max-width: 1280px; }
.nav-scrim { display: none; }

@media (max-width: 900px) {
  .menu-btn { display: block; }
  .who { display: none; }
  .brand span { display: none; }
  .search { margin-left: 0; }
  .sidenav { transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidenav { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: 0; z-index: 15; background: var(--scrim); }
  .main { margin-left: 0; padding: 16px; }
}

/* ---------- building blocks ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card.narrow { max-width: 440px; margin: 40px auto; }
.card > h2:first-child { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.4rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .value.bad { color: var(--bad); }
.stat .value.ok { color: var(--ok); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--btn-hover-line); }
.btn.primary { background: var(--brand-solid); border-color: var(--brand-solid); color: #fff; }
.btn.primary:hover { background: var(--brand-solid-hover); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.btn svg { width: 16px; height: 16px; }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
table.list tr:hover td { background: var(--hover); }
table.list .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.list tfoot td { font-weight: 700; border-bottom: 0; }
.table-wrap { overflow-x: auto; }
@media (max-width: 700px) {
  table.list.stack thead { display: none; }
  table.list.stack tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.list.stack td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 3px 4px; }
  table.list.stack td::before { content: attr(data-l); color: var(--muted); font-size: .8rem; }
  table.list.stack td.num { text-align: right; }
}

.badge { display: inline-block; padding: 2px 8px; border-radius: var(--r); font-size: .75rem; font-weight: 600; background: var(--st-neutral-bg); color: var(--st-neutral-fg); white-space: nowrap; }
.st-draft { background: var(--st-neutral-bg); color: var(--st-neutral-fg); }
.st-sent, .st-waiting, .st-waiting_parts { background: var(--st-warn-bg); color: var(--st-warn-fg); }
.st-partial, .st-in_progress { background: var(--st-info-bg); color: var(--st-info-fg); }
.st-paid, .st-approved, .st-done, .st-collected { background: var(--st-ok-bg); color: var(--st-ok-fg); }
.st-cancelled { background: var(--st-bad-bg); color: var(--st-bad-fg); }
.st-converted { background: var(--brand-soft); color: var(--brand); }
.tag { display: inline-block; padding: 1px 7px; border-radius: var(--r); font-size: .72rem; font-weight: 600; background: var(--brand-soft); color: var(--brand); }
.tag.it { background: var(--st-it-bg); color: var(--st-it-fg); }
.tag.warn { background: var(--st-warn-bg); color: var(--st-warn-fg); }

/* ---------- forms ---------- */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--field-bg, var(--card)); border: 1px solid var(--field-line); border-radius: var(--r);
  padding: 8px 10px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); border-color: var(--brand); }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { min-height: 70px; resize: vertical; }
.form-grid { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.field { margin-bottom: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 3px; }
.inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline > * { flex: 1; min-width: 140px; }
.inline > .btn { flex: none; }

.flash { padding: 10px 14px; border-radius: var(--r); margin-bottom: 14px; font-weight: 500; }
.flash-ok { background: var(--st-ok-bg); color: var(--st-ok-fg); }
.flash-err { background: var(--st-bad-bg); color: var(--st-bad-fg); }
.flash-warn { background: var(--st-warn-bg); color: var(--st-warn-fg); }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: .85rem; }
.kv dd { margin: 0; font-weight: 500; }
.row-flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--ink-2); border-bottom: 2px solid transparent; font-weight: 600; }
.tabs a.active { color: var(--brand); border-color: var(--brand); }
.tabs a:hover { text-decoration: none; }

/* ---------- line editor ---------- */
.lines { width: 100%; border-collapse: collapse; }
.lines th { font-size: .75rem; text-transform: uppercase; color: var(--muted); text-align: left; padding: 6px 4px; }
.lines td { padding: 4px; vertical-align: top; }
.lines tr.line td { border-top: 1px solid var(--line); padding-top: 8px; }
.lines input, .lines select, .lines textarea { padding: 6px 8px; }
.lines textarea { min-height: 34px; margin-top: 4px; font-size: .9rem; }
.lines .w-qty { width: 70px; }
.lines .w-price { width: 100px; }
.lines .w-type { width: 110px; }
.lines .w-worker { width: 130px; }
.lines .total { padding-top: 14px; font-weight: 600; text-align: right; white-space: nowrap; }
.lines .base-note { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.lines .base-note.up { color: var(--ok); }
.lines .base-note.down { color: var(--bad); }
.lines .c-drag { width: 22px; padding-left: 0; padding-right: 0; }
.lines .drag { display: block; padding: 8px 4px; cursor: grab; color: var(--muted); font-size: 1.1rem; line-height: 1; touch-action: none; user-select: none; }
.lines .drag:hover { color: var(--brand); }
.lines tr.dragging td { background: var(--brand-soft); }
.lines tr.dragging .drag { cursor: grabbing; }
.lines .del { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1.2rem; padding: 6px; }
.ac-wrap { position: relative; }
.ac-list {
  position: absolute; z-index: 40; left: 0; right: 0; top: 100%; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); max-height: 280px; overflow-y: auto;
}
.ac-list div { padding: 8px 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.ac-list div:hover, .ac-list div.hl { background: var(--brand-soft); }
.ac-list small { white-space: nowrap; }
.totals { margin-left: auto; max-width: 320px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .grand { font-size: 1.15rem; font-weight: 700; border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 8px; }
@media (max-width: 800px) {
  .lines thead { display: none; }
  .lines tr.line { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; border-top: 1px solid var(--line); padding: 10px 0; }
  .lines tr.line td { border: 0; padding: 0; width: auto !important; }
  .lines tr.line td.c-name { grid-column: 1 / -1; padding-right: 34px; }
  .lines tr.line { position: relative; }
  .lines tr.line td.c-drag { position: absolute; top: 8px; right: 0; width: auto; }
  .lines tr.line td.c-drag::before { display: none; }
  .lines tr.line td::before { content: attr(data-l); display: block; font-size: .7rem; color: var(--muted); }
  .lines .total { padding-top: 0; text-align: left; }
}

/* ---------- specs ---------- */
.spec-compare { width: 100%; border-collapse: collapse; }
.spec-compare th, .spec-compare td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.spec-compare th { color: var(--muted); font-weight: 500; font-size: .85rem; width: 38%; }
.spec-compare td.now { font-weight: 700; }
.spec-compare td.changed { color: var(--brand); }
.spec-compare thead th { color: var(--ink); font-weight: 700; font-size: .8rem; text-transform: uppercase; }
.cr-box { background: var(--brand-soft); border-radius: var(--r); padding: 10px 14px; font-weight: 600; }

/* ---------- portal (vehicle page) ---------- */
.hero { background: var(--hero-bg); color: #fff; border-radius: var(--r); padding: 18px; margin-bottom: 16px; position: relative; overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: auto 0 0 0; height: 4px; background: var(--grad); }
.hero .plate { display: inline-block; background: #111; border: 2px solid #fff; border-radius: var(--r); padding: 2px 10px; font-weight: 800; letter-spacing: .08em; font-size: 1.3rem; }
.hero h1 { color: #fff; margin: 10px 0 2px; }
.hero .sub { color: var(--hero-sub); font-size: .9rem; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 3px solid var(--timeline); padding: 0 0 16px 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 11px; height: 11px; border-radius: 50%; background: var(--brand); }
.timeline .when { font-size: .8rem; color: var(--muted); }

/* ---------- print (invoice) ---------- */
.doc-paper {
  --ink: #1b1733; --ink-2: #4a4666; --muted: #817d99; --line: #e6e3ef; --card: #fff; --brand: #7c3aed; --brand-soft: #f1ebff;
  --ok: #059669; --bad: #dc2626; --st-ok-bg: #e3f7ee; --st-ok-fg: #0b7a4e; --st-bad-bg: #fde8e8; --st-bad-fg: #b42318;
  --st-neutral-bg: #eef0f3; --st-neutral-fg: #5b6472; color: var(--ink); color-scheme: light;
}
.doc-paper { background: #fff; max-width: 820px; margin: 0 auto; padding: 36px 40px; border: 1px solid var(--line); border-radius: var(--r); }
.doc-paper .doc-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.doc-paper .doc-head img { height: 72px; }
.doc-paper .co { font-size: .82rem; color: var(--ink-2); }
.doc-paper .co strong { font-size: 1rem; color: var(--ink); }
.doc-paper .doc-title { text-align: right; }
.doc-paper .doc-title h1 { font-size: 1.8rem; letter-spacing: .06em; text-transform: uppercase; margin: 0; }
.doc-paper .bar { height: 4px; background: var(--grad); margin: 18px 0; border-radius: var(--r); }
.doc-paper .parties { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 18px; font-size: .9rem; }
.doc-paper table.items { width: 100%; border-collapse: collapse; font-size: .9rem; }
.doc-paper table.items th { background: var(--ink); color: #fff; padding: 7px 8px; text-align: left; font-weight: 600; }
.doc-paper table.items td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc-paper .terms { white-space: pre-line; font-size: .8rem; color: var(--ink-2); margin-top: 20px; }
.doc-paper .qr { text-align: center; font-size: .7rem; color: var(--muted); }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  :root { color-scheme: light; }
  .no-print, .topbar, .sidenav { display: none !important; }
  .main { margin: 0; padding: 0; }
  .doc-paper { border: 0; padding: 0; max-width: none; }
  .doc-paper table.items th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc-paper .bar { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}


/* The logo has dark lettering — sit it on a white chip so it reads on the dark theme too. */
.brand img, .pt-brand img { background: #fff; padding: 2px 3px; }

/* ---------- customer portal ---------- */
body.portal { background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
.pt-top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.pt-top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--grad); }
.pt-top-inner { max-width: 960px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.pt-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); min-width: 0; }
.pt-brand:hover { text-decoration: none; }
.pt-brand img { height: 40px; flex: none; }
.pt-brand strong { display: block; font-size: 1.05rem; line-height: 1.2; }
.pt-brand small { display: block; font-size: .75rem; color: var(--muted); }
.pt-top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.pt-who { font-weight: 600; font-size: .9rem; color: var(--ink-2); white-space: nowrap; }
.pt-tabs { max-width: 960px; margin: 0 auto; padding: 0 12px; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.pt-tabs::-webkit-scrollbar { display: none; }
.pt-tabs a { padding: 10px 14px 12px; color: var(--muted); font-weight: 600; font-size: .92rem; white-space: nowrap; border-bottom: 3px solid transparent; }
.pt-tabs a:hover { color: var(--ink); text-decoration: none; }
.pt-tabs a.active { color: var(--ink); border-bottom-color: var(--brand); }
.pt-main { max-width: 960px; width: 100%; margin: 0 auto; padding: 20px 16px 32px; flex: 1; }
.pt-foot { border-top: 1px solid var(--line); background: var(--card); font-size: .8rem; }
.pt-foot-inner { max-width: 960px; margin: 0 auto; padding: 18px 16px 28px; display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; }
.pt-foot-contact { display: flex; flex-direction: column; gap: 2px; text-align: right; }
@media (max-width: 600px) { .pt-who { display: none; } .pt-foot-contact { text-align: left; } }

.pt-h1 { font-size: 1.35rem; margin: 0 0 4px; }
.pt-sub { color: var(--muted); margin: 0 0 18px; font-size: .92rem; }
.pt-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 760px) { .pt-grid { grid-template-columns: 1fr; } }
.pt-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 14px; }
.pt-card h2 { font-size: 1rem; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.pt-card h2 .more { margin-left: auto; font-size: .85rem; font-weight: 600; }

/* balance */
.pt-balance { position: relative; overflow: hidden; background: var(--hero-bg); color: #fff; border: 0; }
.pt-balance::after { content: ""; position: absolute; inset: auto 0 0 0; height: 4px; background: var(--grad); }
.pt-balance .label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--hero-sub); }
.pt-balance .amount { font-size: 2.2rem; font-weight: 800; letter-spacing: -.01em; margin: 2px 0 6px; font-variant-numeric: tabular-nums; }
.pt-balance .note { color: var(--hero-sub); font-size: .88rem; }
.pt-balance.clear .amount { color: #6ee7b7; }
.pt-pay { margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.14); font-size: .88rem; display: grid; gap: 6px; }
.pt-pay .row { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.pt-pay .row span:first-child { color: var(--hero-sub); }
.pt-copy { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: var(--r); padding: 3px 8px; font: inherit; font-size: .78rem; cursor: pointer; }
.pt-copy:hover { background: rgba(255,255,255,.22); }

.pt-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.pt-stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.pt-stat .k { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.pt-stat .v { font-weight: 700; font-size: 1.1rem; margin-top: 2px; font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .pt-stats { grid-template-columns: 1fr 1fr; } .pt-stats .pt-stat:nth-child(3):last-child { grid-column: 1 / -1; } }

/* vehicles */
.pt-vehicles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.pt-vehicle { display: block; border: 1px solid var(--line); border-radius: var(--r); padding: 14px; color: var(--ink); background: var(--card); transition: border-color .15s, transform .15s; }
.pt-vehicle:hover { border-color: var(--brand); text-decoration: none; transform: translateY(-1px); }
.plate-badge { display: inline-block; background: #111; color: #fff; border: 2px solid #111; outline: 1px solid var(--line); border-radius: var(--r); padding: 1px 8px; font-weight: 800; letter-spacing: .08em; font-size: .95rem; }
.pt-vehicle .model { font-weight: 600; margin-top: 8px; }
.pt-vehicle .meta { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.pt-vehicle .status { display: inline-block; margin-top: 8px; }
.pt-vehicle .device-ic { width: 26px; height: 26px; color: var(--brand); }

/* document rows */
.pt-list { display: flex; flex-direction: column; }
.pt-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-top: 1px solid var(--line); color: var(--ink); }
.pt-row:first-child { border-top: 0; }
a.pt-row:hover { background: var(--hover); text-decoration: none; }
.pt-row .ic { width: 38px; height: 38px; border-radius: var(--r); display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.pt-row .ic.pay { background: var(--st-ok-bg); color: var(--st-ok-fg); }
.pt-row .ic.quote { background: var(--st-info-bg); color: var(--st-info-fg); }
.pt-row .ic svg { width: 18px; height: 18px; }
.pt-row .pt-body { flex: 1; min-width: 0; }
.pt-row .title { font-weight: 600; }
.pt-row .desc { font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-row .amt { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pt-row .amt small { display: block; font-weight: 500; margin-top: 2px; }
.pt-filter { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.pt-filter a { padding: 5px 12px; border-radius: var(--r); border: 1px solid var(--line); color: var(--ink-2); font-size: .85rem; font-weight: 600; }
.pt-filter a.active { background: var(--brand-solid); border-color: var(--brand-solid); color: #fff; }
.pt-filter a:hover { text-decoration: none; }
.pt-empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* statement */
.pt-range { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.pt-range > div { min-width: 140px; }
.pt-aging { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.pt-aging div { border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; }
.pt-aging .k { font-size: .72rem; color: var(--muted); }
.pt-aging .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.pt-aging .late .v { color: var(--bad); }
@media (max-width: 640px) { .pt-aging { grid-template-columns: repeat(2, 1fr); } }
table.stmt { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.stmt th, table.stmt td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.stmt th { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
table.stmt td.n, table.stmt th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.stmt tr.sum td { font-weight: 700; border-bottom: 0; }
table.stmt tr.open td { color: var(--muted); font-style: italic; }
@media (max-width: 600px) { table.stmt .hide-sm { display: none; } }
table.stmt .sm-amt { display: none; font-size: .82rem; font-weight: 600; }
table.stmt .sm-amt.in { color: var(--ok); }
@media (max-width: 600px) { table.stmt .sm-amt { display: block; } }
@media print { .pt-top, .pt-foot { display: none !important; } .pt-main { padding: 0; max-width: none; } body.portal { background: #fff; } }
.pt-row .pt-body, .pt-row .title, .pt-row .desc, .pt-row .amt { display: block; }
/* portal on phones: never let long text widen the page; balance card first */
@media (max-width: 760px) {
  .pt-grid { grid-template-columns: minmax(0, 1fr); }
  .pt-grid > div:last-child { order: -1; }
  .pt-main { padding: 14px 12px 24px; }
  .pt-card { padding: 14px; }
  .pt-h1 { font-size: 1.2rem; }
  .pt-balance .amount { font-size: 1.9rem; }
  .pt-vehicles { grid-template-columns: minmax(0, 1fr); }
  .pt-row { gap: 10px; }
  .pt-row .ic { width: 34px; height: 34px; }
  .pt-range > div { min-width: 0; flex: 1 1 130px; }
  .pt-range .btn { flex: 1 1 auto; }
  .pt-stats .v { font-size: 1rem; }
  .pt-top-inner { padding: 8px 12px; }
  .pt-brand img { height: 34px; }
  .pt-tabs a { padding: 10px 11px 11px; }
}
.pt-card, .pt-row, .pt-body { min-width: 0; }
/* invoice / quote / statement paper on a phone screen (printing still uses A4) */
@media screen and (max-width: 640px) {
  .doc-paper { padding: 16px 12px; }
  .doc-paper .doc-head { flex-direction: column; gap: 10px; }
  .doc-paper .doc-head img { height: 48px; }
  .doc-paper .doc-title { text-align: left; }
  .doc-paper .doc-title h1 { font-size: 1.35rem; }
  .doc-paper .parties { flex-direction: column; gap: 10px; }
  .doc-paper .parties > div { text-align: left !important; }
  .doc-paper table.items { font-size: .8rem; }
  .doc-paper table.items th, .doc-paper table.items td { padding: 6px 4px; }
  .doc-paper table.items th:first-child, .doc-paper table.items td:first-child { display: none; }
  .doc-paper .totals { min-width: 0 !important; width: 100%; }
  .doc-paper .qr { display: none; }
}
@media (max-width: 700px) { table.list.stack td:empty { display: none; } }
/* sortable table headings */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--ink); }
th.sortable::after { content: "↕"; opacity: .35; margin-left: 4px; font-size: .85em; }
th.sortable[data-sorted="asc"]::after { content: "↑"; opacity: 1; color: var(--brand); }
th.sortable[data-sorted="desc"]::after { content: "↓"; opacity: 1; color: var(--brand); }
.sort-pick { display: none; align-items: center; gap: 8px; margin-bottom: 10px; }
.sort-pick label { margin: 0; white-space: nowrap; }
@media (max-width: 700px) { .sort-pick { display: flex; } }

/* payment QR */
.pt-qr { margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.14); text-align: center; }
.pt-qr-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--hero-sub); margin-bottom: 8px; }
.pt-qr img { width: 100%; max-width: 230px; background: #fff; padding: 8px; display: block; margin: 0 auto 8px; }
.pt-qr .pt-copy { display: inline-block; }
.pt-qr-hint { font-size: .78rem; color: var(--hero-sub); margin-top: 6px; }
.pt-warn { margin-top: 14px; background: #fff4e0; color: #7a4800; padding: 9px 11px; font-size: .86rem; }
.pt-receipt { display: block; margin-top: 10px; text-align: center; background: #25d366; color: #fff; font-weight: 700; padding: 10px; }
.pt-receipt:hover { text-decoration: none; background: #1ebe5b; }
.how-to-pay { display: flex; gap: 18px; align-items: flex-start; margin-top: 18px; padding: 14px 16px; border: 1px solid var(--line); background: #faf9fd; font-size: .82rem; color: var(--ink-2); -webkit-print-color-adjust: exact; print-color-adjust: exact; break-inside: avoid; }
.how-to-pay .htp-text { flex: 1; }
.how-to-pay strong { display: block; font-size: .95rem; color: var(--ink); margin-bottom: 6px; }
.how-to-pay .htp-bank { margin-bottom: 6px; }
.how-to-pay .htp-warn { background: #fff4e0; color: #7a4800; padding: 6px 8px; margin: 8px 0 6px; }
.how-to-pay .htp-qr { width: 1.45in; flex: none; }
@media screen and (max-width: 640px) { .how-to-pay { flex-direction: column; } .how-to-pay .htp-qr { width: 60%; align-self: center; } }
.enter-saves { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }


/* ---------------------------------------------------------------- job cards */
.narrow-only { display: none; }
@media (max-width: 700px) {
  .wide-only { display: none; }
  .narrow-only { display: block; }
  /* status tabs: one row you swipe sideways, fading at the edge so it's clear there's more */
  .tabs.swipe { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 8px; padding: 0 16px;
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .tabs.swipe::-webkit-scrollbar { display: none; }
  .tabs.swipe a { flex: none; white-space: nowrap; padding: 10px 12px; }
}
h2.job-group { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); margin: 18px 0 8px; }
.job-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.job-card { display: flex; flex-direction: column; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; color: var(--ink); }
.job-card:hover { text-decoration: none; border-color: var(--brand); }
.jc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.jc-plate { font-size: 1.1rem; letter-spacing: .02em; }
.jc-sub { color: var(--ink-2); font-size: .88rem; }
.jc-what { font-size: .9rem; }
.jc-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: 2px; }


/* ---------------------------------------------------------------- waiting for customer */
.st-waiting_customer { background: var(--st-bad-bg); color: var(--st-bad-fg); }
:root .tag.wait-none { background: var(--st-neutral-bg); color: var(--st-neutral-fg); }
:root .tag.wait-remind { background: var(--st-warn-bg); color: var(--st-warn-fg); }
:root .tag.wait-final { background: var(--st-bad-bg); color: var(--st-bad-fg); font-weight: 600; }
.job-card.wait-remind, table.list tr.wait-remind td { background: var(--tint-warn); }
.job-card.wait-final, table.list tr.wait-final td { background: var(--tint-bad); }
table.list tr.wait-remind td:first-child { box-shadow: inset 3px 0 var(--warn); }
table.list tr.wait-final td:first-child { box-shadow: inset 3px 0 var(--bad); }
.job-card.wait-remind { border-color: var(--warn); }
.job-card.wait-final { border-color: var(--bad); }
.notice-box.wait-box-remind { border-color: var(--warn); background: var(--tint-warn); }
.notice-box.wait-box-final { border-color: var(--bad); background: var(--tint-bad); }
.notice-head { margin-bottom: 8px; }
.notice-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.notice-row form { margin: 0; }
.notice-label { min-width: 190px; font-weight: 600; font-size: .9rem; }
.notice-row .btn[disabled] { opacity: .45; cursor: not-allowed; }
@media (max-width: 600px) { .notice-label { min-width: 0; flex-basis: 100%; } }
