/* Fonts are served by Worktally itself, so visitors' details never go to Google. Both are SIL Open Font Licence. */
@font-face { font-family: "Archivo"; src: url("/fonts/archivo-latin.woff2") format("woff2"); font-weight: 400 800; font-stretch: 62% 125%; font-display: swap; }
@font-face { font-family: "Caveat"; src: url("/fonts/caveat-latin.woff") format("woff"); font-weight: 600; font-display: swap; }

/* Worktally app: everything behind the login, plus the invoice and quote pages customers open.
   Direction: graphite. Neutral dark greys, near-white for the main action, colour only for status
   (paid, due, overdue). Every text colour is at least 5:1 against its background. Customers' pages keep a light version. */

:root {
  color-scheme: dark;
  --bg: #111316;
  --surface: #191c20;
  --subtle: #20242a;
  --line: #2a2f36;
  --line-strong: #3a4049;
  --ink: #e7e9ec;
  --ink-2: #b9bfc7;
  --ink-3: #9098a3;
  --accent: #e7e9ec;
  --accent-ink: #111316;
  --accent-weak: #262b32;
  --canary: #eef0f3;
  --ok: #7fcf98;    --ok-bg: #15281d;
  --warn: #e3b862;  --warn-bg: #2a2314;
  --bad: #f28b82;   --bad-bg: #33191a;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: none;
}
/* What customers see from their invoice and quote links: the same palette, in daylight. */
.public-invoice {
  color-scheme: light;
  --bg: #f4f5f7; --surface: #ffffff; --subtle: #eff1f4; --line: #e1e4e9; --line-strong: #cbd0d7;
  --ink: #16191d; --ink-2: #474e58; --ink-3: #636b76;
  --accent: #16191d; --accent-ink: #f4f5f7; --accent-weak: #e6e9ee;
  --ok: #1f7a3d; --ok-bg: #e6f4ea; --warn: #8a5a00; --warn-bg: #fff2cf; --bad: #b42318; --bad-bg: #fdecea;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 "Archivo", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { font-weight: 650; letter-spacing: -0.01em; line-height: 1.25; }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }
p { margin: 0 0 12px; }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--ink-3); }
.hint { font-size: 13px; color: var(--ink-3); margin: 4px 0 0; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: ui-serif, Georgia, "Times New Roman", serif; font-weight: 600; font-stretch: 100%; letter-spacing: -.01em; font-size: 17px; letter-spacing: -0.01em; }

/* ---------- Shell ---------- */
.app-main { padding: 16px 16px 96px; }
.panel { max-width: 760px; margin: 0 auto; }
.panel-wide { max-width: 1120px; }

.topbar { display: flex; align-items: center; height: 56px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.mobile-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; height: 52px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--line); }

.sidebar { display: none; }
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
}
.tabbar a { display: grid; justify-items: center; gap: 2px; padding: 6px 0; color: var(--ink-3); text-decoration: none; font-size: 11px; font-weight: 600; }
.tabbar .icon { width: 22px; height: 22px; }
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar .tab-new .icon { width: 36px; height: 36px; padding: 8px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); stroke-width: 2.2; margin-top: -4px; }

@media (min-width: 900px) {
  .mobile-top, .tabbar { display: none; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 232px; z-index: 20; display: flex; flex-direction: column; gap: 4px;
    padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto;
  }
  .app-main { margin-left: 232px; padding: 28px 40px 56px; }
}
.sidebar .brand { padding: 4px 8px 16px; }
.sidebar-new { margin: 0 4px 12px; }
.side-nav { display: grid; gap: 1px; }
.side-settings { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.side-nav a, .side-link {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: var(--radius);
  color: var(--ink-2); text-decoration: none; font: inherit; font-weight: 500; font-size: 14px;
  background: none; border: 0; cursor: pointer; width: 100%; text-align: left;
}
.side-nav a:hover, .side-link:hover { background: var(--subtle); color: var(--ink); }
.side-nav a[aria-current="page"] { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.side-logout { margin: 0; }

/* ---------- Page structure ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head > div:first-child { min-width: 0; }
.page-sub { color: var(--ink-3); margin: 4px 0 0; }
.crumb { margin: 0 0 8px; font-size: 13px; color: var(--ink-3); }
.crumb a { color: var(--ink-3); }
.section-head { display: flex; justify-content: space-between; align-items: center; margin: 28px 0 10px; }
.section-head h2, .group-title { font-size: 15px; margin: 0; }
.group-title { margin: 24px 0 8px; display: flex; gap: 8px; align-items: baseline; }

/* A bordered surface. Used for things that belong together, not around every block. */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-title { font-size: 15px; margin: 0 0 4px; }
.card-title-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.card-title-row a { font-size: 13px; font-weight: 600; }

.empty { border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); padding: 24px; text-align: center; color: var(--ink-2); background: var(--surface); }
.empty p { margin: 0 0 12px; }
.empty .btn { margin-top: 4px; }
.all-clear { color: var(--ink-3); margin: 8px 0 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--radius); border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-size: 14px; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn .icon { width: 16px; height: 16px; }
.btn-quiet { background: var(--surface); color: var(--ink); border-color: var(--line-strong); box-shadow: var(--shadow); }
.btn-quiet:hover { background: var(--subtle); filter: none; }
.btn-danger { background: var(--bad); color: var(--accent-ink); }
.btn-block { width: 100%; height: 42px; margin-top: 16px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.link-button { background: none; border: 0; padding: 0; font: inherit; font-size: 14px; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.account-actions, .contact-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }
.contact-actions { margin: 0 0 16px; }
.account-actions form, .contact-actions form { margin: 0; }

/* ---------- Messages ---------- */
.form-msg { border-radius: var(--radius); padding: 10px 14px; margin: 0 0 16px; font-size: 14px; border: 1px solid; }
.form-notice { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 30%, transparent); color: var(--ink); }
.form-error { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 30%, transparent); color: var(--ink); }
.form-msg p { margin: 0; }
.form-msg ul { margin: 6px 0 0; padding-left: 18px; }
.field-error { color: var(--bad); font-size: 13px; font-weight: 600; margin: 4px 0 0; }

/* ---------- Forms ---------- */
.form { display: grid; }
.form fieldset { border: 0; margin: 0 0 16px; padding: 0; min-width: 0; display: grid; }
.form fieldset.card { padding: 16px 20px 20px; }
.form legend { float: left; width: 100%; padding: 0; font-weight: 650; font-size: 15px; margin-bottom: 4px; }
.form label, .upload label, .invite-form label { font-weight: 600; font-size: 13px; color: var(--ink-2); margin: 14px 0 6px; display: block; }
.form label small { font-weight: 400; color: var(--ink-3); }
input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="date"], input[type="time"],
input[type="search"], input[type="password"], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; font: inherit; font-size: 15px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
}
textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
[aria-invalid="true"] { border-color: var(--bad) !important; }
.short { max-width: 220px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.pair > div { display: grid; min-width: 0; }
.form .choice { display: flex; align-items: center; gap: 10px; font-weight: 400; font-size: 15px; color: var(--ink); margin: 12px 0 0; }
.choice input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.field-link { font-size: 13px; text-align: right; margin: 8px 0 0; }

/* Choices shown as selectable options (business type, customer type) */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0 4px; }
.tiles-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form .tile {
  position: relative; display: grid; gap: 2px; margin: 0; padding: 12px 12px 12px 38px; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink);
}
.tile input { position: absolute; left: 12px; top: 14px; width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.tile-title { font-weight: 600; font-size: 14px; }
.tile-about { font-size: 13px; color: var(--ink-3); font-weight: 400; }
.tile:has(input:checked) { border-color: var(--accent); background: var(--accent-weak); }
.tile:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 640px) { .tiles { grid-template-columns: 1fr; } }

.pw { position: relative; }
.pw input { padding-right: 64px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: 0; padding: 6px 8px; font: inherit; font-size: 13px; font-weight: 600; color: var(--accent); cursor: pointer; }

/* ---------- Status labels ---------- */
.badge, .tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 4px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--subtle); color: var(--ink-2); }
.badge-paid, .badge-q-accepted, .badge-j-done, .tag-ok { background: var(--ok-bg); color: var(--ok); }
.badge-overdue, .tag-bad { background: var(--bad-bg); color: var(--bad); }
.badge-part_paid, .badge-j-to_book, .badge-j-in_progress, .tag-warn { background: var(--warn-bg); color: var(--warn); }
.badge-unpaid, .badge-q-sent, .badge-q-viewed, .badge-j-booked { background: var(--accent-weak); color: var(--accent); }
.badge-void { text-decoration: line-through; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
.list > li + li { border-top: 1px solid var(--line); }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 10px 16px; color: var(--ink); text-decoration: none; }
a.list-row:hover { background: var(--subtle); }
.list-main { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.list-sub { display: block; font-weight: 400; font-size: 13px; color: var(--ink-3); }
.list-meta { color: var(--ink-3); font-size: 13px; text-align: right; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.list-meta.stacked { display: grid; justify-items: end; gap: 4px; }
.list-meta strong { color: var(--ink); font-size: 14px; }
.list-flat { border: 0; box-shadow: none; border-radius: 0; background: none; }
.list-flat .list-row { padding: 10px 0; }
.list-flat a.list-row:hover { background: none; }
.list-flat a.list-row:hover .list-main { color: var(--accent); }
.row-title { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.row-num { color: var(--ink-3); font-weight: 500; }
.avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--subtle); color: var(--ink-2); font-weight: 600; font-size: 12px; }
.list-row:has(.avatar) { justify-content: flex-start; }
.grow { flex: 1; }
.with-icon { display: inline-flex; align-items: center; gap: 10px; }
.with-icon .icon { color: var(--ink-3); }
.time { font-weight: 600; margin-right: 6px; color: var(--ink); }

.search { display: flex; gap: 8px; margin: 0 0 12px; }
.search input { flex: 1; }

/* Segmented filter above a list */
.filter-tabs { display: inline-flex; max-width: 100%; overflow-x: auto; gap: 2px; padding: 3px; margin: 0 0 12px; background: var(--subtle); border-radius: 8px; scrollbar-width: none; }
.filter-tabs a { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 6px; color: var(--ink-2); text-decoration: none; font-size: 13px; font-weight: 600; }
.filter-tabs a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.1); }
.filter-tabs .count { color: var(--ink-3); font-weight: 500; }

/* ---------- Tables (invoice and quote lists) ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--subtle); white-space: nowrap; }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; white-space: nowrap; }
.data-table tbody tr { position: relative; }
.data-table tbody tr:hover { background: var(--subtle); }
.data-table .row-link { color: var(--ink); font-weight: 600; text-decoration: none; }
.data-table .row-link::after { content: ""; position: absolute; inset: 0; } /* whole row is clickable */
.data-table .ref { color: var(--ink-3); white-space: nowrap; }
@media (max-width: 700px) {
  .data-table thead { display: none; }
  .data-table tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .data-table tbody tr:last-child { border-bottom: 0; }
  .data-table td { padding: 0; border: 0; }
  .data-table td.col-ref { grid-column: 1; font-size: 13px; }
  .data-table td.col-who { grid-column: 1; grid-row: 1; }
  .data-table td.col-when { grid-column: 1; font-size: 13px; color: var(--ink-3); }
  .data-table td.col-amount { grid-column: 2; grid-row: 1; }
  .data-table td.col-status { grid-column: 2; grid-row: 2 / span 2; justify-self: end; }
}

/* Definition list of details (customer page) */
.details { display: grid; grid-template-columns: 120px 1fr; gap: 10px 16px; margin: 0 0 16px; padding: 16px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.details dt { color: var(--ink-3); font-size: 13px; font-weight: 600; padding-top: 1px; }
.details dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 520px) { .details { grid-template-columns: 1fr; gap: 2px; } .details dd { margin-bottom: 10px; } }

/* ---------- Overview (home) ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
@media (min-width: 1000px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { display: grid; gap: 2px; align-content: start; padding: 16px 20px; color: var(--ink); text-decoration: none; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
a.kpi:hover { background: var(--subtle); }
.kpi-label { font-size: 13px; color: var(--ink-3); font-weight: 500; }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
.kpi-sub { font-size: 13px; color: var(--ink-3); }
.kpi-late .kpi-value { color: var(--bad); }
.home-grid { display: grid; gap: 16px; margin-bottom: 16px; }
.home-grid .card { margin: 0; }
@media (min-width: 1000px) { .home-grid { grid-template-columns: 1.25fr 1fr; } }
.start { border-style: dashed; border-color: var(--line-strong); }
.start h2 { font-size: 15px; margin: 0 0 8px; }
.start-steps { margin: 0; padding-left: 20px; display: grid; gap: 4px; color: var(--ink-2); }

/* Income chart: one series in the accent; quiet grid; the unfinished month lighter */
.chart { width: 100%; height: auto; display: block; overflow: visible; margin-top: 8px; }
.chart .grid { stroke: var(--line); }
.chart .grid.baseline { stroke: var(--line-strong); }
.chart .axis { fill: var(--ink-3); font-size: 12px; }
.chart .value { fill: var(--ink-2); font-size: 12px; font-weight: 600; }
.chart .bar path { fill: var(--accent); }
.chart .bar.is-current path { opacity: 0.4; }
.chart .hit { fill: transparent; }
.chart .tip { display: none; pointer-events: none; }
.chart .tip rect { fill: var(--ink); }
.chart .tip text { fill: var(--surface); font-size: 12px; font-weight: 600; }
.chart .bar:hover .tip, .chart .bar:focus .tip { display: inline; }
.chart .bar:hover path, .chart .bar:focus path { opacity: 1; }
.chart .bar:focus { outline: none; }
.chart .bar:focus-visible .hit { stroke: var(--accent); stroke-width: 2; }
.chart-empty { margin: 12px 0 4px; }
.chart-table { margin-top: 8px; font-size: 13px; }
.chart-table summary { cursor: pointer; color: var(--ink-3); }

/* ---------- Menus (New, More) ---------- */
.tile-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; }
.tile-link { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-lg); border: 1px solid var(--line); background: var(--surface); color: var(--ink-3); text-decoration: none; box-shadow: var(--shadow); font-size: 14px; }
.tile-link:hover { border-color: var(--line-strong); background: var(--subtle); }
.tile-link .icon { width: 20px; height: 20px; color: var(--accent); margin-top: 2px; }
.tile-link strong { display: block; color: var(--ink); font-size: 15px; font-weight: 600; }
.more-logout { margin-top: 24px; }

/* ---------- Danger zone ---------- */
.danger { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 14px; }
.danger summary, .inline-danger summary { cursor: pointer; color: var(--bad); font-weight: 600; font-size: 14px; }
.danger p { margin: 8px 0; color: var(--ink-2); }
.inline-danger form { margin-top: 6px; }

/* ---------- Invoice and quote pages ---------- */
.inv-actions { margin-bottom: 20px; }
.inv-actions > p:first-child { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inv-actions label { display: block; font-weight: 600; font-size: 13px; color: var(--ink-2); margin: 14px 0 6px; }
.inv-label { font-size: 13px; font-weight: 600; color: var(--ink-3); margin: 16px 0 6px; }
.share { display: flex; gap: 8px; }
.share input { flex: 1; min-width: 0; font-size: 13px; color: var(--ink-2); background: var(--subtle); }
.pay-form { margin-top: 12px; }
.pay-form > summary { list-style: none; display: inline-flex; cursor: pointer; }
.pay-form > summary::-webkit-details-marker { display: none; }
.pay-form form { margin-top: 12px; max-width: 420px; }
.reminders { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.reminders summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.timeline { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.timeline li { display: flex; justify-content: space-between; gap: 12px; color: var(--ink-3); }
.timeline li.done { color: var(--ok); font-weight: 600; }
.next-steps { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.next-steps p { margin: 0; }
.quote-answer h2 { margin-bottom: 4px; }

/* Line items editor */
.lines { display: grid; gap: 8px; margin: 12px 0; }
.line-row { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--subtle); }
.line-row label { margin: 0 0 4px !important; font-size: 12px; }
.line-desc { display: grid; }
.line-desc textarea { min-height: 52px; }
.line-nums { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }
.line-nums > div { display: grid; }
.line-remove { justify-self: end; color: var(--ink-3); font-size: 13px; }

/* The document itself: always black on white, like paper, so it prints and reads the same everywhere */
.invoice-doc {
  position: relative; background: #fff; color: #1a1a1a; border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 40px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; box-shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}
.invoice-doc p { margin: 0 0 10px; }
.invoice-doc.is-draft::before, .invoice-doc.is-void::before {
  position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg);
  font-weight: 800; font-size: clamp(48px, 12vw, 110px); opacity: 0.06; pointer-events: none;
}
.invoice-doc.is-draft::before { content: 'DRAFT'; }
.invoice-doc.is-void::before { content: 'VOID'; }
.inv-head { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid #1a1a1a; }
.inv-seller-name { font-weight: 700; font-size: 20px; line-height: 1.2; margin-bottom: 4px !important; }
.inv-small { font-size: 12px; color: #555; }
.inv-title h2 { margin: 0 0 8px; font-size: 24px; font-weight: 650; text-align: right; color: #1a1a1a; }
.inv-meta { display: grid; grid-template-columns: auto auto; gap: 2px 16px; margin: 0; }
.inv-meta dt { color: #666; }
.inv-meta dd { margin: 0; text-align: right; font-weight: 600; }
.invoice-doc .inv-label { color: #666; margin: 0 0 4px; }
.inv-table-wrap { overflow-x: auto; margin: 20px 0; }
.inv-lines { width: 100%; border-collapse: collapse; }
.inv-lines th, .inv-lines td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #e5e5e5; vertical-align: top; }
.inv-lines th { font-size: 12px; color: #666; font-weight: 600; border-bottom: 1px solid #1a1a1a; }
.inv-lines .num { text-align: right; white-space: nowrap; }
.inv-totals { display: flex; justify-content: flex-end; }
.inv-totals dl { display: grid; grid-template-columns: auto auto; gap: 4px 32px; margin: 0; min-width: min(320px, 100%); }
.inv-totals dt { color: #555; }
.inv-totals dd { margin: 0; text-align: right; }
.inv-totals .grand { color: #1a1a1a; font-weight: 700; border-top: 1px solid #1a1a1a; padding-top: 6px; }
.inv-note { margin-top: 16px !important; padding: 10px 12px; border: 1px solid #1a1a1a; }
.inv-pay { margin-top: 24px; padding: 14px 16px; background: #f5f5f5; border-radius: 4px; }
.inv-pay dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 16px; margin: 0; }
.inv-pay dt { color: #555; }
.inv-pay dd { margin: 0; font-weight: 600; }
.inv-notes { margin-top: 16px; }
.inv-legal { margin-top: 28px; padding-top: 10px; border-top: 1px solid #e5e5e5; font-size: 11px; color: #666; }
@media (max-width: 520px) { .invoice-doc { padding: 20px 16px; } .inv-title h2 { text-align: left; } }
.chart-table .inv-lines th, .chart-table .inv-lines td { border-color: var(--line); color: var(--ink-2); }

/* Pages customers open from a link */
.public-invoice .wrap { max-width: 860px; margin: 0 auto; padding: 24px 16px 40px; }
.public-actions { display: flex; justify-content: flex-end; margin: 0 0 12px; }
.card-pay { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 0 0 16px; }
.card-pay .hint { margin: 0; }
.public-footer { text-align: center; color: var(--ink-3); font-size: 12px; margin-top: 16px; }

/* ---------- Business details: preview of the invoice header ---------- */
.form-with-preview { gap: 0; }
.preview-label { color: var(--ink-3); font-size: 13px; font-weight: 600; margin: 0 0 8px; }
.preview-sheet { background: var(--canary); color: #1f2a44; border-radius: 4px; padding: 20px; box-shadow: 0 12px 28px -18px rgba(31, 42, 68, 0.5); font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.preview-sheet p { margin: 0; white-space: pre-line; }
.preview-name { font-weight: 700; font-size: 18px; line-height: 1.2; margin-bottom: 4px !important; }
.preview-small { font-size: 12px; opacity: 0.8; margin-top: 6px !important; }
.preview-lines { margin-top: 8px !important; }
.preview-empty { opacity: 0.5; font-style: italic; }
.preview-pay { border-top: 1px solid currentColor; margin-top: 14px; padding-top: 10px; }
.preview-pay-title { font-weight: 700; }
@media (min-width: 1000px) {
  .form-with-preview { grid-template-columns: minmax(0, 1fr) 320px; column-gap: 32px; }
  .form-with-preview > * { grid-column: 1; }
  .form-with-preview > .preview { grid-column: 2; grid-row: 1 / span 5; align-self: start; position: sticky; top: 24px; }
}

/* ---------- Jobs ---------- */
.job-summary p { margin: 0 0 8px; }
.job-summary .contact-actions { margin: 12px 0; }
.job-desc { background: var(--subtle); padding: 10px 12px; border-radius: var(--radius); color: var(--ink-2); }
.job-summary form { margin-top: 12px; }
.assign-label { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 16px 0 0; }
.upload { display: grid; gap: 8px; }
.upload input[type="file"] { font: inherit; font-size: 14px; }
.files { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.files li { display: grid; gap: 4px; font-size: 13px; }
.files img, .file-icon { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); background: var(--subtle); }
.file-icon { display: grid; place-items: center; font-weight: 700; color: var(--ink-3); }
.file-name { color: var(--ink-3); overflow-wrap: anywhere; }
.note-form { display: grid; gap: 8px; }
.note-form .btn { justify-self: start; }
.notes-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.notes-list li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.notes-list p { margin: 0 0 4px; }
.notes-list span { font-size: 12px; }

/* ---------- Diary ---------- */
.diary { display: grid; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; box-shadow: var(--shadow); }
.day { display: flex; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.day:last-child { border-bottom: 0; }
.day h2 { flex: 0 0 100px; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0; padding-top: 8px; }
.day.is-today h2 { color: var(--accent); }
.day.is-today { background: color-mix(in srgb, var(--accent-weak) 45%, var(--surface)); }
.day-jobs { flex: 1; display: grid; gap: 6px; min-width: 0; }
.day-jobs > p { padding-top: 8px; margin: 0; font-size: 13px; }
.diary-job { display: grid; grid-template-columns: 52px 1fr; column-gap: 12px; padding: 8px 10px; border-radius: var(--radius); border: 1px solid var(--line); border-left: 3px solid var(--accent); background: var(--surface); color: var(--ink); text-decoration: none; }
.diary-job:hover { background: var(--subtle); }
.diary-job.badge-border-done { border-left-color: var(--ok); color: var(--ink-3); }
.diary-job.badge-border-in_progress { border-left-color: var(--warn); }
.diary-time { grid-row: span 2; font-weight: 600; font-size: 13px; padding-top: 1px; }
.diary-title { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.diary-sub { font-size: 12px; color: var(--ink-3); overflow-wrap: anywhere; }
@media (max-width: 560px) { .day { flex-direction: column; gap: 6px; } .day h2 { flex: none; padding-top: 0; } }

/* ---------- Team, import and export ---------- */
.invite-form { display: grid; gap: 4px; margin-top: 16px; }
.invite-form .btn { justify-self: start; margin-top: 8px; }
.data-section h2 { margin: 0 0 6px; }
.data-section p { color: var(--ink-2); }
.downloads { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.map-grid { display: grid; grid-template-columns: minmax(120px, 180px) 1fr; gap: 8px 16px; align-items: center; }
.map-grid label { margin: 0 !important; }
@media (max-width: 520px) { .map-grid { grid-template-columns: 1fr; } }

@media print {
  body { background: #fff !important; }
  .sidebar, .tabbar, .mobile-top, .topbar, .crumb, .inv-actions, .public-actions, .card-pay, .public-footer, .form-msg { display: none !important; }
  .app-main { margin: 0 !important; padding: 0 !important; }
  .panel, .wrap { max-width: none !important; padding: 0 !important; }
  .invoice-doc { border: 0; padding: 0; box-shadow: none; }
}

/* Fixes after review */
/* A fieldset laid out as a grid draws its legend in the border, so fieldsets stay block-level. */
.form fieldset { display: block; }
.form legend { float: none; display: block; margin-bottom: 4px; }
.tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tiles-2 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.upload .btn, .invite-form .btn { justify-self: start; width: auto; }
.inv-totals dl { column-gap: 0; }
.inv-totals dd { padding-left: 32px; }
/* Floating the legend is what takes it out of the fieldset's border in every browser. */
.form legend { float: left; width: 100%; }
.form legend + * { clear: both; }
.auth-lede { color: var(--ink-3); margin: 4px 0 20px; }
.auth-switch { color: var(--ink-3); font-size: 14px; margin: 16px 0 0; }

/* Customer-facing pages: who it's from, at the top */
.public-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.public-due { background: var(--surface); border-color: var(--line); }

/* Line items: one row per item on wide screens (description beside qty, price, VAT), stacked on phones */
@media (min-width: 760px) {
  .line-row { grid-template-columns: minmax(0, 1fr) minmax(260px, 340px) auto; align-items: end; column-gap: 12px; }
  .line-desc textarea { min-height: 40px; height: 40px; }
  .line-remove { align-self: center; padding-top: 18px; }
}

/* Safari draws filled-in date and time fields taller and lower than text fields; this lines them up. */
input[type="date"], input[type="time"] { -webkit-appearance: none; appearance: none; display: block; line-height: 38px; }
.pair { align-items: start; }

/* Headings that sit straight above a card need a little room */
.panel > h1 { margin-bottom: 16px; }

/* Privacy notice and terms: comfortable reading width */
.legal { max-width: 68ch; }
.legal h2 { font-size: 17px; margin: 28px 0 8px; }
.legal p, .legal li { color: var(--ink-2); line-height: 1.6; }
.legal ul, .legal ol { padding-left: 20px; margin: 0 0 12px; display: grid; gap: 6px; }
.legal-table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0 16px; }
.legal-table th, .legal-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.legal-table th { color: var(--ink-3); font-weight: 600; font-size: 13px; }
.todo { background: var(--warn-bg); color: var(--warn); padding: 0 4px; border-radius: 3px; }
.legal-links { font-size: 13px; color: var(--ink-3); margin-top: 24px; }
.legal-links a, .public-footer a { color: var(--ink-3); }

/* Card payments: one tile per provider */
.providers { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 16px; }
.providers .provider { margin: 0; display: flex; flex-direction: column; }
.provider form, .provider .provider-status { margin-top: auto; }
.provider-on { border-color: var(--ok); }
.provider-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.provider-head h2 { margin: 0; }
.provider-logo { width: 36px; height: 36px; flex: none; }
.provider-logo-square { color: var(--ink); }
.provider .provider-status { margin-bottom: 8px; }
.how-steps { padding-left: 20px; margin: 8px 0; }
.how-steps li { margin: 4px 0; }

/* "Welcome to Pro": full-screen, quiet and warm. The name types itself out, each letter arriving as a trade icon. */
.welcome-overlay {
  --w-bg: var(--bg); --w-ink: var(--ink); --w-muted: var(--ink-3); --w-line: var(--line-strong); --w-btn: var(--accent); --w-btn-ink: var(--accent-ink);
  position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 24px 16px;
  background: var(--w-bg); color: var(--w-ink); text-align: center; animation: welcome-in .6s ease-out both;
}
html.welcome-open { overflow: hidden; }
.welcome-overlay.welcome-leaving { animation: welcome-out .4s ease-in forwards; }
.welcome-inner { display: grid; justify-items: center; gap: 0; }
.welcome-name { font-family: ui-serif, Georgia, "Times New Roman", serif; font-weight: 400; font-size: clamp(48px, 11vw, 112px); line-height: 1; letter-spacing: -.02em; margin: 0 0 20px; white-space: nowrap; }
.tw-glyph { position: relative; display: inline-block; }
/* Typing: each slot shows a trade icon for a beat, then cuts to the letter.
   Hard cuts only, like keystrokes. No fill mode on the icon, so it always ends hidden. */
.tw-glyph svg { animation-delay: var(--d) !important; }
.tw-ch { animation-delay: calc(var(--d) + .12s) !important; }
.tw-glyph svg { position: absolute; left: 50%; top: 52%; width: .5em; height: .5em; transform: translate(-50%, -50%); fill: none; stroke: var(--w-muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0; animation: tw-icon .12s linear; }
.tw-ch { opacity: 0; animation: tw-letter .01s linear forwards; }
.tw-glyph:nth-child(1) { --d: 0.50s; }
.tw-glyph:nth-child(2) { --d: 0.63s; }
.tw-glyph:nth-child(3) { --d: 0.76s; }
.tw-glyph:nth-child(4) { --d: 0.89s; }
.tw-glyph:nth-child(5) { --d: 1.02s; }
.tw-glyph:nth-child(6) { --d: 1.15s; }
.tw-glyph:nth-child(7) { --d: 1.28s; }
.tw-glyph:nth-child(8) { --d: 1.41s; }
.tw-glyph:nth-child(9) { --d: 1.54s; }
.tw-glyph:nth-child(10) { --d: 1.67s; }
.tw-glyph:nth-child(11) { --d: 1.80s; }
.tw-glyph:nth-child(12) { --d: 1.93s; }
.tw-glyph:nth-child(13) { --d: 2.06s; }
.tw-glyph:nth-child(14) { --d: 2.19s; }
.tw-glyph:nth-child(15) { --d: 2.32s; }
.tw-glyph:nth-child(16) { --d: 2.45s; }
.welcome-title { font-family: inherit; font-size: clamp(15px, 2vw, 18px); font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--w-muted); margin: 0 0 40px; padding-top: 20px; border-top: 1px solid var(--w-line); min-width: 220px; animation: welcome-rise .8s ease-out 1.7s both; }
.welcome-go { display: inline-block; padding: 12px 28px; border-radius: 999px; background: var(--w-btn); color: var(--w-btn-ink); text-decoration: none; font-weight: 600; font-size: 16px; animation: welcome-rise .8s ease-out 2.1s both; }
.welcome-go:hover { opacity: .9; }
.welcome-go:focus-visible { outline: 2px solid var(--w-ink); outline-offset: 4px; }
@keyframes tw-icon { 0%, 99% { opacity: 1; } 100% { opacity: 0; } }
@keyframes tw-letter { from { opacity: 0; } to { opacity: 1; } }
@keyframes welcome-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes welcome-out { to { opacity: 0; } }
@keyframes welcome-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .welcome-overlay, .welcome-overlay *, .tw-ch { animation: none !important; opacity: 1; }
  .tw-glyph svg { display: none; }
}

/* Unsaved draft found on this device (autosave.js) */
.draft-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px; margin-bottom: 16px; border: 1px solid var(--warn); background: var(--warn-bg); color: var(--ink); border-radius: var(--radius); }
.draft-bar span { flex: 1 1 220px; }
.btn-small { padding: 5px 10px; font-size: 13px; min-height: 0; }

/* Price list and template menus above the lines (src/price-list.js) */
.catalog { display: flex; flex-wrap: wrap; gap: 12px 16px; margin: 0 0 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.catalog > div { flex: 1 1 220px; }
.catalog select { width: 100%; }
.catalog-hint { margin: 0 0 12px; }
.public-tools, .doc-tools { display: flex; flex-wrap: wrap; gap: 8px; }
@media print { .public-tools, .doc-tools { display: none !important; } }

/* Quoted vs spent on a job */
.money-strip { display: flex; flex-wrap: wrap; gap: 8px 32px; margin: 0 0 8px; }
.money-strip dt { font-size: 12px; color: var(--ink-3); }
.money-strip dd { margin: 0; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.money-strip dd.over { color: var(--bad); }
.choice-row { border: 0; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 4px 20px; }
.choice-row legend { padding: 0; margin-bottom: 6px; font-weight: 600; }
.form input[type="file"] { margin-bottom: 12px; }

/* Team: what each person can do */
.team-row { flex-wrap: wrap; }
.team-perms { flex-basis: 100%; }
.team-perms fieldset { border: 0; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.team-remove { margin-top: 12px; }

/* Plan and billing: status at a glance */
.plan-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.plan-head h2 { margin: 0; }
.plan-head .tag { height: 26px; font-size: 13px; padding: 0 10px; }
.plan-facts { display: flex; flex-wrap: wrap; gap: 8px 32px; margin: 12px 0 16px; }
.plan-facts dt { font-size: 12px; color: var(--ink-3); }
.plan-facts dd { margin: 0; font-weight: 600; }

/* A form that's on its way: the button looks pressed so nobody taps it again (forms.js) */
form[aria-busy="true"] button[type="submit"] { opacity: .6; cursor: progress; }
/* "Already invoiced?" warning before issuing */
.dupe-warning { border: 1px solid var(--warn); background: var(--warn-bg); color: var(--ink); margin-bottom: 12px; }
.dupe-warning ul { margin: 6px 0 10px; padding-left: 20px; }
.another-invoice { margin: -4px 0 16px; }

/* Notification centre: unread count next to Notifications, and the bell on phones */
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; margin-left: auto; padding: 0 5px; border-radius: 9px; background: var(--bad-bg); color: var(--bad); font-size: 11px; font-weight: 700; }
.mobile-bell { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 4px; color: var(--ink-2); }
.mobile-bell .nav-badge { margin-left: 0; }

/* ---------- Admin console ---------- */
.admin-chip { font-family: "Archivo", system-ui, sans-serif; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; background: var(--accent-weak); color: var(--ink-2); }
.side-who { margin: 0 10px 4px; font-size: 12px; color: var(--ink-3); overflow-wrap: anywhere; }
.mobile-logout { margin: 0 0 0 auto; }
.mobile-logout .side-link { width: auto; height: 44px; }
.admin .home-grid .card { min-width: 0; }
/* Horizontal bar list: one series in the accent, number beside each bar, exact text on hover (title). */
.hbars { list-style: none; margin: 4px 0 12px; padding: 0; display: grid; gap: 12px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 4px 12px; font-size: 14px; border-radius: var(--radius); }
.hbar:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.hbar-label { color: var(--ink-2); }
.hbar-track { grid-column: 1 / -1; -webkit-appearance: none; appearance: none; width: 100%; height: 12px; display: block; border: 0; background: transparent; }
.hbar-track::-webkit-progress-bar { background: transparent; }
.hbar-track::-webkit-progress-value { background: var(--accent); border-radius: 0 4px 4px 0; }
.hbar-track::-moz-progress-bar { background: var(--accent); border-radius: 0 4px 4px 0; }
.hbar-value { font-weight: 600; text-align: right; }
.hbar-value .muted { font-weight: 400; font-size: 12px; }

/* Help and support */
.human-note { border-color: var(--line-strong); }
.human-note h2 { margin-bottom: 6px; }
.support-msg { margin-bottom: 12px; }
.support-msg.from-staff { border-left: 3px solid var(--ok); }
.new-message { color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* Services due: details on the left, actions on the right (stacked on phones) */
.service-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px; padding: 12px 16px; }
.service-row .row-title { color: var(--ink); font-weight: 600; }
.service-row .list-main { display: grid; gap: 2px; min-width: 0; }
.service-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.service-actions form { margin: 0; }

/* Gas records */
.radio-row { display: flex; flex-wrap: wrap; gap: 0 18px; margin-bottom: 8px; }
.radio-row .choice { margin-top: 6px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.form-actions .btn { flex: 1 1 160px; }
