/* ============================================================================
   Challenger Quotation Platform — "precision paperwork"
   Swiss-accounting form aesthetic: paper stock, ink text, one stamp-red accent,
   hairline geometry, tabular numerals, mono for machine data. Arial only
   (mandatory: the on-screen preview must match the printed A4 sheet).
   ========================================================================= */

:root {
  --paper: #f4f2ee;
  --paper-deep: #ece8e1;
  --sheet: #ffffff;
  --ink: #111111;
  --ink-soft: #3a3833;
  --muted: #6e6a62;
  --line: #dbd6cc;
  --line-soft: #e8e4dc;
  --red: #c51e25;
  --red-deep: #9d1319;
  --red-wash: #fbeeea;
  --ok: #1f6a3d;
  --ok-wash: #e9f3ec;
  --radius: 3px;
  --shadow: 0 1px 0 #ffffff inset, 0 1px 2px #1111;
  --rail: 360px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: Arial, "Helvetica Neue", Helvetica, "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.55 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

/* paper grain — pure CSS, no image requests */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
  background-image:
    radial-gradient(circle at 18% 12%, #ffffff88, transparent 42%),
    radial-gradient(circle at 82% 0%, #ffffff66, transparent 38%),
    repeating-linear-gradient(0deg, #00000005 0 1px, transparent 1px 3px);
}

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--red); }

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

/* -------------------------------------------------------------- top bar --- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 58px;
  padding: 0 22px;
  background: #fbfaf7ee;
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}

.topbar[hidden] { display: none; }

.brand {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand b { color: var(--red); font-weight: 800; }

.brand small {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .12em;
  color: var(--muted);
  text-transform: uppercase;
}

.topbar-rule {
  width: 1px;
  height: 26px;
  background: var(--line);
}

/* The record's name in the sticky bar. It only appears once the page header has
   scrolled away, so the sheet keeps a name without saying it twice. */
.topbar-record {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdfa;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .04em;
  color: var(--ink);
  white-space: nowrap;
}

.topbar-record[hidden] { display: none; }

.spacer { flex: 1; }

.switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

select,
input,
textarea {
  font: inherit;
  color: var(--ink);
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 10px;
  width: 100%;
  transition: border-color .12s ease, box-shadow .12s ease;
}

select {
  width: auto;
  min-width: 190px;
  padding-right: 26px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 49%, var(--muted) 50%),
    linear-gradient(-45deg, transparent 49%, var(--muted) 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

input:hover, select:hover, textarea:hover { border-color: #c8c2b6; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px #c51e2514;
}

input::placeholder, textarea::placeholder { color: #a8a49b; }

textarea {
  min-height: 240px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  resize: vertical;
}

/* A comment is a short note, not template source: keep it in the desk font and one row tall. */
.field textarea {
  min-height: 0;
  height: 58px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
}

/* -------------------------------------------------------------- buttons --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform .1s ease, background .12s ease, color .12s ease, border-color .12s ease;
}

.btn:hover { background: #000; }
.btn:active { transform: translateY(1px); }

.btn.primary { background: var(--red); }
.btn.primary:hover { background: var(--red-deep); }

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn.ghost:hover {
  border-color: var(--ink);
  background: #fff;
  color: var(--ink);
}

.btn.danger {
  background: transparent;
  border-color: #e0b6b2;
  color: var(--red-deep);
}

.btn.danger:hover { background: var(--red-wash); border-color: var(--red); }

.btn.small { min-height: 30px; padding: 0 10px; font-size: 11px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* A glyph inside a button rides the label: it keeps its size and never
   shrinks when the label wraps on a narrow screen. */
.btn .icon { width: 15px; height: 15px; flex: none; }

/* ------------------------------------------------------------ auth gate --- */

.gate {
  position: relative;
  z-index: 1;
  min-height: calc(100vh - 58px);
  display: grid;
  place-items: center;
  padding: 40px 22px;
}

.gate[hidden] { display: none; }

.gate-card {
  width: 100%;
  max-width: 430px;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px -32px #1113, 0 2px 0 #fff inset;
  animation: rise .45s cubic-bezier(.2, .8, .2, 1) both;
}

.gate-rule {
  height: 5px;
  background: repeating-linear-gradient(90deg, var(--red) 0 22px, #111 22px 44px);
}

.gate-body { padding: 30px 30px 26px; }

.eyebrow {
  margin: 0 0 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
}

.gate h1 {
  margin: 0 0 4px;
  font-size: 25px;
  line-height: 1.15;
  letter-spacing: -.02em;
}

.gate p.lede { margin: 0 0 22px; color: var(--muted); font-size: 13px; }

.turnstile-widget { display: flex; justify-content: center; min-height: 65px; margin-top: 18px; }

.gate-actions { margin-top: 18px; }

.gate-foot {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.error {
  margin: 0 0 14px;
  padding: 9px 11px;
  border-left: 3px solid var(--red);
  background: var(--red-wash);
  color: var(--red-deep);
  font-size: 12.5px;
  font-weight: 700;
}

.error[hidden] { display: none; }

/* ------------------------------------------------------------ workspace --- */

.view { position: relative; z-index: 1; }
.view[hidden] { display: none; }

.workspace {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  max-width: 1500px;
  margin: 0 auto;
  padding: 22px 22px 56px;
}

.panel {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* form rail — a carbon-copy pad: red margin rule, mono hints */
.rail {
  position: sticky;
  top: 80px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 20px 22px;
  background-image:
    linear-gradient(90deg, #c51e250a 0 1px, transparent 1px),
    linear-gradient(180deg, #fffefb, #fbf9f5);
}

.rail-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.rail h2 { margin: 0; font-size: 15px; letter-spacing: -.01em; }

.rail-step {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .08em;
  color: var(--muted);
}

.field { display: block; margin-bottom: 13px; }

.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field-label em {
  font-style: normal;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--muted);
  letter-spacing: .04em;
  text-transform: none;
}

.prefix {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--sheet);
}

.prefix:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 3px #c51e2514;
}

.prefix-tag {
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: var(--paper-deep);
  border-right: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--red-deep);
}

.prefix input {
  border: 0;
  border-radius: 0;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: .02em;
  min-width: 0;
}

.prefix input:focus { box-shadow: none; }

.prefix.read-only-number {
  border-color: var(--line);
  background: #f1f3f6;
  cursor: not-allowed;
}

.prefix.read-only-number .prefix-tag {
  background: #e2e7ee;
  color: var(--ink-soft);
  letter-spacing: .08em;
  font-size: 10px;
}

.prefix input[readonly] {
  background: #f1f3f6;
  color: var(--ink);
  font-weight: 700;
  cursor: not-allowed;
  caret-color: transparent;
}

.prefix input[readonly]:focus {
  outline: none;
  box-shadow: none;
}

.rail-note {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

/* a note that opens a pane instead of closing it */
.rail-note.lead {
  margin: 0 0 16px;
  padding-top: 0;
  border-top: 0;
}

.rail-note code {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .02em;
  padding: 1px 4px;
  border-radius: 2px;
  background: var(--paper-deep);
}

/* --------------------------------------------------------------- ledger --- */

.ledger { min-width: 0; }

.ledger-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 2px solid var(--ink);
}

.ledger-head h1 { margin: 0; font-size: 21px; letter-spacing: -.02em; }

.muted { color: var(--muted); font-size: 12.5px; margin: 3px 0 0; }

.ledger-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.search { display: flex; gap: 6px; align-items: center; }

.search input { width: 250px; padding: 8px 10px; font-size: 13px; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--sheet);
  box-shadow: var(--shadow);
  max-height: calc(100vh - 230px);
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #faf8f4;
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
  text-align: left;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  white-space: nowrap;
}

tbody tr { transition: background .1s ease; }
tbody tr:hover { background: #fbf9f5; }
tbody tr:last-child td { border-bottom: 0; }

.num {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.num a { border-bottom: 1px solid transparent; }
.num a:hover { color: var(--red); border-bottom-color: var(--red); }

.vehicle { white-space: normal; }
.vehicle b { font-weight: 700; }
.vehicle span { display: block; font-family: var(--mono); font-size: 11px; color: var(--muted); }

.money {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

th.money-head, td.money { text-align: right; }

/* The line is the door: the cursor says a click opens the record, and the
   number inside stays a real link so the keyboard keeps its own route. */
tbody tr.row-open { cursor: pointer; }
tbody tr.row-open:hover td.num a { color: var(--red); border-bottom-color: var(--red); }

.empty {
  margin: 0;
  padding: 46px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

/* chips & misc */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  background: #fff;
}

.chip.ok { border-color: #bfd8c7; background: var(--ok-wash); color: var(--ok); }
.chip.off { border-color: #e0b6b2; background: var(--red-wash); color: var(--red-deep); }

/* --------------------------------------------------------------- toast --- */

.toast {
  position: fixed;
  left: 22px;
  bottom: 22px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 420px;
  padding: 11px 14px;
  background: #111;
  color: #fff;
  border-radius: var(--radius);
  border-left: 3px solid var(--red);
  font-family: var(--mono);
  font-size: 12px;
  box-shadow: 0 18px 40px -20px #000a;
  transform: translateY(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.toast.show { opacity: 1; transform: none; }
.toast.error { border-left-color: #ff8a80; background: #2a0f0f; }

/* ------------------------------------------------------- confirm dialog --- */

dialog.modal {
  width: min(430px, calc(100vw - 24px));
  max-width: none;
  max-height: calc(100vh - 24px);
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  overflow: visible;
}

dialog.modal::backdrop { background: #14120e99; }

.modal-card {
  overflow: hidden;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 30px 60px -28px #000000b3, 0 1px 0 #fff inset;
  animation: modalIn .16s ease-out;
}

/* the stamp-red rule that heads every card in the desk */
.modal-card::before {
  content: "";
  display: block;
  height: 3px;
  background: var(--red);
}

.modal-body { padding: 18px 20px 14px; }

.modal-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
  letter-spacing: -.01em;
}

.modal-message { margin: 8px 0 0; color: var(--ink-soft); font-size: 13px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 20px 18px;
}

.modal-actions .btn { flex: 0 1 auto; }

/* holding the page still is what makes the prompt feel like part of the app */
body:has(dialog.modal[open]) { overflow: hidden; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(6px) scale(.995); }
}

/* ------------------------------------------------------------- settings --- */

.settings-wrap {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  max-width: 1340px;
  margin: 0 auto;
  padding: 26px 22px 64px;
}

/* side panel — a section index laid out like a carbon-copy margin */
.settings-nav {
  position: sticky;
  top: 78px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 16px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background-image:
    linear-gradient(90deg, #c51e250a 0 1px, transparent 1px),
    linear-gradient(180deg, #fffefb, #fbf9f5);
}

.settings-nav-head { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.settings-nav-head .eyebrow { margin: 0 0 4px; }
.settings-nav-head h1 { margin: 0; font-size: 17px; letter-spacing: -.01em; }

.settings-menu { display: flex; flex-direction: column; }

.settings-tab {
  display: flex;
  flex-direction: column;
  gap: 1px;
  align-items: flex-start;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: transparent;
  font: inherit;
  text-align: left;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}

.settings-tab b { font-size: 12.5px; font-weight: 700; }
.settings-tab small {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}

.settings-tab:hover { background: #ffffff9c; }
.settings-tab[aria-current="true"] { border-left-color: var(--red); background: #fff; }
.settings-tab[aria-current="true"] b { color: var(--ink); }
.settings-tab[aria-current="true"] small { color: var(--red-deep); }

.settings-nav-foot { margin-top: auto; padding-top: 12px; border-top: 1px dashed var(--line); }

.settings-panes { display: grid; gap: 18px; min-width: 0; }
.settings-pane[hidden] { display: none; }

/* template studio — versions + editor on the left, proof sheet on the right */
.studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 470px);
  gap: 20px;
  align-items: start;
}

.studio-col { min-width: 0; }

.studio-block-head,
.studio-preview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.studio-block-head h3,
.studio-preview-head h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.studio-block-head span {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  color: var(--muted);
}

.versions { margin: 0 0 6px; padding: 0; list-style: none; display: grid; gap: 6px; }

.version-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fffdfa;
}

.version-row.on { border-color: #dca9a5; box-shadow: inset 3px 0 0 var(--red); background: #fff; }

.version-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.version-main b { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px; }
.version-main small {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.version-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.version-actions .btn { min-height: 26px; padding: 0 8px; font-size: 10.5px; }
.version-empty { padding: 12px 0; font-size: 12.5px; color: var(--muted); }

.studio-col textarea { min-height: 300px; }

.studio-preview {
  position: sticky;
  top: 78px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--sheet);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.studio-preview-head {
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfaf7;
}

.studio-preview .preview-note { border-top: 1px solid var(--line); }

.checkline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-soft);
  cursor: pointer;
}

.checkline input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 2px;
  accent-color: var(--red);
  cursor: pointer;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfaf7;
}

.card-head h2 { margin: 0; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; }

/* the head keeps its tools together on the right: chip, then the action */
.card-head-tools { display: flex; align-items: center; gap: 8px; }
.card-head-tools .btn { white-space: nowrap; }

.card-body { padding: 18px; }

/* ------------------------------------------------------------ brand logo --- */

.logo-field {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 16px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-deep);
}

.logo-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 76px;
  padding: 7px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--sheet);
  overflow: hidden;
}

.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

.logo-empty {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.logo-copy { min-width: 0; }

.logo-hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.logo-hint code {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 1px 4px;
  border-radius: 2px;
  background: var(--sheet);
  color: var(--ink-soft);
}

.logo-buttons { display: flex; flex-wrap: wrap; gap: 8px; }

.logo-status {
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .04em;
  color: var(--ink-soft);
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-2 .span-2 { grid-column: 1 / -1; }

.list { margin: 0; padding: 0; list-style: none; }

.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}

.list li:last-child { border-bottom: 0; }

.list .mono { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

hr.rule { border: 0; border-top: 1px dashed var(--line); margin: 16px 0; }

/* --------------------------------------------------------------- record --- */

.record-wrap {
  position: relative;
  z-index: 1;
  max-width: 1460px;
  margin: 0 auto;
  padding: 24px 22px 60px;
}

.record-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 14px;
  border-bottom: 3px solid var(--red);
  margin-bottom: 20px;
}

.record-number {
  margin: 0;
  font-family: var(--mono);
  font-size: 46px;
  line-height: .95;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}

.record-meta { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 10px; }

.record-meta div { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.record-meta b { display: block; margin-top: 3px; font-size: 13px; letter-spacing: 0; text-transform: none; color: var(--ink); }

.record-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.record-grid {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

/* The A4 frame carries an inline pixel width that is only refreshed on resize; letting
   that width feed back into the track sizing would widen the whole grid after a
   viewport change. min-width: 0 keeps the tracks at the space actually available. */
.record-grid > * { min-width: 0; }

.preview-card { position: sticky; top: 78px; }

.preview-stage {
  padding: 16px;
  background:
    repeating-linear-gradient(45deg, #eae7e1 0 8px, #eeebe5 8px 16px);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.preview-frame {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 10px 34px -18px #1119, 0 0 0 1px #d9d4ca;
  overflow: hidden;
}

.preview-frame iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 210mm;
  height: 297mm;
  border: 0;
  transform-origin: top left;
  background: #fff;
}

.preview-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ------------------------------------------------------------ responsive --- */

@media (max-width: 1240px) {
  .studio { grid-template-columns: minmax(0, 1fr) minmax(300px, 370px); }
}

@media (max-width: 1080px) {
  /* minmax(0, 1fr), not 1fr: the nowrap tab strip would otherwise push the
     whole page wider than the phone (a 1fr track never shrinks below content) */
  .settings-wrap { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { position: static; gap: 10px; min-width: 0; }
  .settings-panes { min-width: 0; }
  .settings-nav-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding-bottom: 8px; }
  .settings-nav-head h1 { font-size: 16px; }
  .settings-menu { flex-direction: row; gap: 2px; overflow-x: auto; min-width: 0; }
  .settings-tab {
    align-items: center;
    border-left: 0;
    border-bottom: 2px solid transparent;
    border-radius: var(--radius) var(--radius) 0 0;
    white-space: nowrap;
  }
  .settings-tab[aria-current="true"] { border-left-color: transparent; border-bottom-color: var(--red); }
  .settings-tab small { display: none; }
  .settings-nav-foot { display: none; }
  .studio { grid-template-columns: 1fr; }
  .studio-preview { position: static; }
}

@media (max-width: 1180px) {
  .record-grid { grid-template-columns: 1fr; }
  .preview-card { position: static; }
  .record-number { font-size: 38px; }
}

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .rail { position: static; }
  .table-wrap { max-height: none; }
  .ledger-head { flex-direction: column; align-items: flex-start; }
}

/* the five-column ledger cannot breathe on a phone: rows become stacked cards */
@media (max-width: 760px) {
  .table-wrap {
    max-height: none;
    overflow: visible;
    border: 0;
    background: none;
    box-shadow: none;
  }

  .table-wrap table { display: block; }

  /* the header row is redundant once every value carries its own caption */
  .table-wrap thead { display: none; }

  .table-wrap tbody { display: grid; gap: 10px; }

  .table-wrap tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "num num"
      "vehicle vehicle"
      "date money";
    gap: 2px 12px;
    padding: 12px 14px;
    background: var(--sheet);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }

  .table-wrap tbody tr:hover { background: var(--sheet); }

  .table-wrap tbody td {
    padding: 0;
    border: 0;
    white-space: normal;
    text-align: left;
  }

  .table-wrap tbody td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 1px;
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
  }

  /* the number is the card title, so it needs no caption */
  .table-wrap td.num::before,
  .table-wrap td.vehicle::before { display: none; }

  .table-wrap td.num {
    grid-area: num;
    margin-bottom: 6px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--line-soft);
    font-size: 14px;
  }

  .table-wrap td.num a { display: inline-block; padding: 2px 0; }

  .table-wrap td.vehicle { grid-area: vehicle; }
  .table-wrap td.vehicle b { font-size: 14px; }
  .table-wrap td.vehicle span { font-size: 11.5px; }

  .table-wrap td.date { grid-area: date; align-self: end; }

  .table-wrap td.money {
    grid-area: money;
    align-self: end;
    text-align: right;
    font-size: 14px;
  }

  /* the empty state loses the table's frame, so it needs its own */
  .table-wrap .empty {
    background: var(--sheet);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
}

@media (max-width: 640px) {
  .topbar { padding: 0 14px; gap: 10px; height: auto; min-height: 58px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  .brand small, .topbar-rule { display: none; }
  .workspace, .record-wrap, .settings-wrap { padding-left: 14px; padding-right: 14px; }
  .grid-2 { grid-template-columns: 1fr; }
  .record-number { font-size: 30px; }
  .record-head { flex-direction: column; align-items: flex-start; }
  .search input { width: 100%; }
  .ledger-actions { width: 100%; }
  .logo-field { grid-template-columns: 1fr; }

  /* the sheet head keeps its action on one line: "· A4" already names the paper */
  .preview-card .card-head .chip { display: none; }
  .preview-card .card-head h2 { white-space: nowrap; }

  /* iOS zooms into any focused control below 16px, which then hides the field label */
  .field input, .field textarea, .prefix input, .search input, select { font-size: 16px; }
  .field textarea { height: 68px; }
  .prefix-tag { font-size: 13px; padding: 0 8px; }

  /* touch targets: 44px for primary actions, 36px for the small ones */
  .btn { min-height: 44px; }
  .btn.small { min-height: 36px; font-size: 11.5px; }

  .rail { padding: 16px 14px 18px; }
  .rail-step { font-size: 10px; }

  .search { flex: 1 1 100%; }
  .search input { min-width: 0; }
  .search input, .search .btn { min-height: 44px; }
  .search .btn { flex: 0 0 auto; }

  /* the record page: two meta columns, no sticky sheet, tighter cards */
  .record-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
  .record-actions { justify-content: flex-start; width: 100%; }
  .card-head { padding: 12px 14px; }
  .card-body { padding: 14px; }
  .card-actions .btn { flex: 1 1 140px; }
  .preview-stage { padding: 10px; }
  .preview-note { flex-direction: column; align-items: flex-start; gap: 2px; }

  /* --- settings on a phone: the sidebar index becomes a 2×2 sheet of tabs --- */
  .settings-nav {
    padding: 12px 12px 10px;
    border-left: 1px solid var(--line);
    border-top: 3px solid var(--red);
    gap: 10px;
  }
  .settings-nav-head { padding-bottom: 10px; }
  .settings-nav-head .eyebrow { font-size: 9.5px; }
  .settings-nav-head h1 { font-size: 15px; }

  /* the counters ("4 versions", "3 companies") are the point of the index — keep them */
  .settings-menu { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; overflow: visible; }
  .settings-tab {
    align-items: flex-start;
    justify-content: center;
    min-height: 52px;
    padding: 8px 10px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    background: #fffdfa;
    white-space: normal;
  }
  .settings-tab small { display: block; }
  .settings-tab[aria-current="true"] {
    border-color: #dca9a5;
    box-shadow: inset 3px 0 0 var(--red);
    background: #fff;
  }

  /* the sidebar's way out is hidden with the sidebar — phones still need one */
  .settings-nav-foot { display: block; margin-top: 0; padding-top: 10px; }
  .settings-nav-foot .btn { width: 100%; }

  /* one version per card: name on top, actions in a 2×2 grid underneath */
  .version-row { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 10px 12px; }
  .version-main b { font-size: 13px; }
  .version-main small { white-space: normal; }
  .version-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--line-soft);
  }

  /* company rows: a long name pushes the chip and "Use" onto the next line */
  .list li { flex-wrap: wrap; gap: 6px 10px; padding: 12px 0; }
  .list li > span:first-child { flex: 1 1 140px; min-width: 0; }

  .logo-preview { height: 96px; }
  .logo-buttons .btn { flex: 1 1 0; }

  /* "Publish version" would break across two lines when sharing a row at 360px */
  .studio-col .card-actions .btn { flex: 1 1 100%; }

  /* the checkbox is 16px; the whole line is the target, so make it a thumb's worth */
  .checkline { min-height: 44px; }

  /* deactivate sits on its own line, away from Save */
  .card-actions .btn.danger { flex: 1 1 100%; }

  /* a fixed toast would otherwise run off the right edge */
  .toast { left: 12px; right: 12px; bottom: 12px; max-width: none; }

  /* thumb reach: the action sits on top, "keep" lands under the thumb */
  .modal-body { padding: 16px 16px 12px; }
  .modal-actions { flex-direction: column-reverse; padding: 0 16px 16px; }
  .modal-actions .btn { width: 100%; }
}

@media (max-width: 480px) {
  .topbar .chip { display: none; }
  .brand { font-size: 12px; letter-spacing: .12em; }
  .record-number { font-size: 26px; }
  .gate { padding: 24px 14px; }
  .gate-body { padding: 22px 18px; }
  .settings-menu { gap: 0; }
}

/* ------------------------------------------------------------ animations --- */

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes rowIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

tbody tr { animation: rowIn .28s ease both; }
tbody tr:nth-child(1) { animation-delay: .01s; }
tbody tr:nth-child(2) { animation-delay: .03s; }
tbody tr:nth-child(3) { animation-delay: .05s; }
tbody tr:nth-child(4) { animation-delay: .07s; }
tbody tr:nth-child(5) { animation-delay: .09s; }
tbody tr:nth-child(6) { animation-delay: .11s; }
tbody tr:nth-child(n+7) { animation-delay: .13s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

[hidden] { display: none !important; }


/* ============================ segmented switch ============================ */
/* Two mutually exclusive options in one hairline frame: the ledger order and the
   hand-off choice both read as a stamped toggle rather than a dropdown. */

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--sheet);
}

.segmented button {
  min-height: 30px;
  padding: 0 11px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}

.segmented button + button { border-left: 1px solid var(--line); }
.segmented button:hover { color: var(--ink); background: #fbf9f5; }
.segmented button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.segmented button[aria-pressed="true"]:hover { background: #000; color: #fff; }

/* the ledger's number cell now carries a state chip under the number */
.num-stack { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ============================== signed copy ============================== */
/* The record page leads with the paper the customer signed: proof stock on the
   left, the send controls and measurements on the right, a rubber stamp once the
   record is closed. */

.signed {
  margin-bottom: 22px;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: rise .3s cubic-bezier(.2, .8, .2, 1) both;
}

.signed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfaf7;
}

.signed-title {
  margin: 0;
  font-size: 13px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.signed-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(258px, 318px);
  align-items: stretch;
}

.signed-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 280px;
  margin: 0;
  padding: 24px;
  background: repeating-linear-gradient(45deg, #eae7e1 0 8px, #eeebe5 8px 16px);
  border-right: 1px solid var(--line);
}

/* two hairline crop marks, the way a print shop frames a proof */
.signed-frame::before,
.signed-frame::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 1px solid #b9b3a8;
  pointer-events: none;
}

.signed-frame::before { top: 13px; left: 13px; border-right: 0; border-bottom: 0; }
.signed-frame::after { bottom: 13px; right: 13px; border-left: 0; border-top: 0; }

.signed-frame img {
  display: block;
  max-width: 100%;
  max-height: min(58vh, 470px);
  background: #fff;
  box-shadow: 0 14px 38px -22px #1119, 0 0 0 1px #d9d4ca;
}

.signed-empty {
  display: grid;
  gap: 6px;
  max-width: 340px;
  padding: 10px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}

.signed-empty b {
  color: var(--ink);
  font-size: 15px;
  letter-spacing: -.01em;
}

.signed-stamp {
  position: absolute;
  right: 20px;
  bottom: 18px;
  padding: 5px 12px;
  border: 2px solid var(--ok);
  border-radius: 4px;
  background: #ffffffdd;
  color: var(--ok);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  transform: rotate(-7deg);
  box-shadow: 0 1px 0 #fff inset;
  pointer-events: none;
}

.signed-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 16px 18px;
}

.signed-meta { display: grid; gap: 6px; margin: 0; }

.signed-meta div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--line-soft);
}

.signed-meta dt {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.signed-meta dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-soft);
  text-align: right;
  overflow-wrap: anywhere;
}

.signed-buttons, .send-block { display: grid; gap: 8px; }

/* three ways in: the shutter, a photo already on the phone, or the scanner's PDF */
.signed-uploads {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.signed-uploads .btn { padding: 0 8px; font-size: 10.5px; letter-spacing: .03em; }

/* a PDF signed copy: the frame stops being a picture and becomes the document */
.signed-doc {
  display: grid;
  justify-items: center;
  gap: 9px;
  padding: 30px 24px;
  border: 1px solid #d9d4ca;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 14px 38px -22px #1119;
}

.signed-doc-kind {
  padding: 10px 14px;
  background: var(--red);
  color: #fff;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .16em;
}

.signed-doc-name { font-family: var(--mono); font-size: 12px; }

.signed-doc-meta {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.send-block {
  margin-top: 2px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.send-block .field-label { margin-bottom: 2px; }

.segmented.side { width: 100%; }
.send-block .segmented { width: 100%; }
.send-block .segmented button { flex: 1 1 0; min-height: 34px; }

.signed-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.signed-links .btn {
  min-width: 0;
  padding: 0 9px;
  font-size: 10.5px;
  letter-spacing: .03em;
  white-space: nowrap;
}

/* Keep the WhatsApp brand mark recognizable on the red primary action. */
.send-block .icon-whatsapp {
  width: 19px;
  height: 19px;
  padding: 2px;
  border-radius: 50%;
  background: #ffffff;
  color: #25d366;
}

.signed-hint {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

/* ========================= hand-off preference ========================= */

.choice-list { display: grid; gap: 8px; }

.choice {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fffdfa;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}

.choice:hover { border-color: #d8d2c6; }
.choice:has(input:checked) { border-color: #dca9a5; background: #fff; box-shadow: inset 3px 0 0 var(--red); }

.choice input[type="radio"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 2px 0 0;
  padding: 0;
  accent-color: var(--red);
  cursor: pointer;
}

.choice b { display: block; font-size: 13px; }
.choice em { display: block; margin-top: 3px; color: var(--muted); font-size: 11.5px; font-style: normal; line-height: 1.5; }

.choice code {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 1px 4px;
  border-radius: 2px;
  background: var(--paper-deep);
  color: var(--ink-soft);
}


/* ================================ scanner ================================ */
/* Full-screen capture surface: the camera frame, the detected page outline and
   the four corner handles all sit in one positioned stage so their coordinates
   share a single origin. */

dialog.scanner {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  /* on a phone 100vh is taller than the visible area: dvh keeps the control bar
     above the browser's own chrome instead of under it */
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  background: #14120e;
  color: #fff;
  overflow: hidden;
}

dialog.scanner::backdrop { background: #14120ee6; }

.scanner-card {
  display: grid;
  /* head · controls · picture: the shutter sits above the frame, where the thumb
     reaches it and the browser cannot cover it */
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100%;
}

.scanner-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid #ffffff1f;
  background: #1b1913;
}

.scanner-head .eyebrow { color: #b8b1a3; margin: 0 0 3px; }
.scanner-title { margin: 0; font-size: 15px; letter-spacing: -.01em; }

.scanner-stage {
  position: relative;
  overflow: hidden;
  background: #0c0b09;
  /* the camera frame is letterboxed inside this box; the JS fits it explicitly */
}

.scanner-media {
  position: absolute;
  display: block;
  background: #000;
}

.scanner-outline {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}

.scanner-handles { position: absolute; inset: 0; }
.scanner-handles[hidden] { display: none; }

.scanner-handle {
  position: absolute;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #c51e2566;
  box-shadow: 0 1px 6px #0009;
  cursor: grab;
  touch-action: none;
}

.scanner-handle:active { cursor: grabbing; background: #c51e25aa; }

.scanner-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-bottom: 1px solid #ffffff1f;
  background: #1b1913;
}

.scanner-status {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .04em;
  color: #cfc8b9;
}

.scanner-status[data-state="ok"] { color: #8bd8a6; }
.scanner-status[data-state="error"] { color: #ff8a80; }

.scanner-actions { display: flex; gap: 8px; margin-left: auto; align-items: center; }

/* the finish picker: colour keeps pen and stamp, grey turns the page into a copy */
.scanner-modes {
  display: flex;
  margin-right: 2px;
  border: 1px solid #ffffff33;
  border-radius: 3px;
  overflow: hidden;
}

.scanner-mode {
  min-height: 30px;
  padding: 0 9px;
  border: 0;
  background: transparent;
  color: #cfc8b9;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
}

.scanner-mode + .scanner-mode { border-left: 1px solid #ffffff26; }
.scanner-mode:hover { background: #ffffff14; color: #fff; }
.scanner-mode[aria-pressed="true"] { background: #f3efe6; color: #1b1913; }

.scanner-actions .btn.ghost { border-color: #ffffff33; color: #eae5da; }
.scanner-actions .btn.ghost:hover { background: #ffffff14; border-color: #ffffff66; color: #fff; }
.scanner-actions .btn.primary { background: var(--red); }
.scanner-actions .btn[disabled] { opacity: .5; }

/* ============================ responsive pass ============================ */

@media (max-width: 1180px) {
  .signed-body { grid-template-columns: minmax(0, 1fr) minmax(240px, 290px); }
  .signed-frame img { max-height: min(50vh, 420px); }
}

@media (max-width: 980px) {
  .signed-body { grid-template-columns: minmax(0, 1fr); }
  .signed-frame { border-right: 0; border-bottom: 1px solid var(--line); }
  .signed-frame img { max-height: 52vh; }
  .signed-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; }
}

@media (max-width: 760px) {
  .signed-frame { min-height: 210px; padding: 18px; }
  .signed-side { padding: 14px; }
  .signed-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .signed-links .btn:last-child { grid-column: 1 / -1; }
  .table-wrap td.num .chip { font-size: 9px; }
}

@media (max-width: 640px) {
  .segmented button { min-height: 34px; padding: 0 10px; font-size: 10px; }
  .signed-head { padding: 12px 14px; }
  .signed-frame { min-height: 190px; padding: 14px; }
  .signed-frame img { max-height: 44vh; }
  .signed-meta { grid-template-columns: minmax(0, 1fr); }
  .signed-stamp { right: 12px; bottom: 12px; font-size: 10px; letter-spacing: .16em; }
  .signed-hint { font-size: 11px; }

  /* the stage gets the full height between the two bars */
  .scanner-head { padding: 10px 12px; }
  .scanner-foot { padding: 10px 12px; gap: 8px; }
  .scanner-status { flex: 1 1 100%; }
  .scanner-actions { flex: 1 1 100%; flex-wrap: wrap; }
  .scanner-actions .btn { flex: 1 1 0; min-height: 44px; }
  .scanner-modes { flex: 1 1 100%; margin-right: 0; }
  .scanner-mode { flex: 1 1 0; min-height: 38px; }
  .scanner-handle { width: 40px; height: 40px; margin: -20px 0 0 -20px; }
}

@media (max-width: 480px) {
  .signed-title { font-size: 12px; }
  .signed-links { grid-template-columns: minmax(0, 1fr); }
  .choice { padding: 10px 12px; }
}

@media print {
  .signed, .scanner { display: none !important; }
}




/* ========================================================================
   Public landing page — Business Desk
   Extends the existing precision-paperwork design system.
   ======================================================================== */

.gate {
  display: block;
  min-height: 100vh;
  padding: 0;
}

.gate[hidden] { display: none; }

.landing-shell {
  position: relative;
  z-index: 1;
  width: min(1160px, calc(100% - 48px));
  margin: 0 auto;
}

.landing-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  border-bottom: 1px solid var(--line);
  background: #f4f2eef2;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Keep anchored sections visible below the sticky navigation. */
#overview,
#modules,
#login {
  scroll-margin-top: 92px;
}

.landing-brand {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  color: var(--ink);
}

.landing-brand:hover { color: var(--ink); }

.landing-brand-name {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .16em;
  line-height: 1.2;
}

.landing-brand-name b {
  color: var(--red);
  font-weight: 800;
}

.landing-brand-subtitle {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .14em;
  line-height: 1.4;
}

.landing-nav {
  display: flex;
  align-items: center;
  gap: 26px;
}

.landing-nav > a:not(.btn) {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.landing-nav > a:not(.btn):hover { color: var(--red); }

.landing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(340px, .88fr);
  gap: clamp(36px, 6vw, 76px);
  align-items: center;
  padding: 76px 0 82px;
}

.landing-intro { min-width: 0; }

.landing-intro .eyebrow { margin-bottom: 13px; }

.landing-intro h2 {
  max-width: 700px;
  margin: 0 0 18px;
  color: var(--ink);
  font-size: clamp(38px, 5vw, 60px);
  font-weight: 750;
  line-height: 1.035;
  letter-spacing: -.055em;
}

.landing-description {
  max-width: 590px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}

.landing-statuses {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 23px;
}

.landing-status {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.landing-status.available {
  border-color: #bfd8c7;
  background: var(--ok-wash);
  color: var(--ok);
}

.landing-status.planned {
  background: #fffdfa;
  color: var(--muted);
}

.landing-benefits {
  display: grid;
  gap: 10px;
  max-width: 430px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.landing-benefits p {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 700;
}

.landing-benefits span {
  color: var(--red);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .05em;
}

.gate-card.landing-login {
  max-width: none;
  width: 100%;
  box-shadow: 0 24px 60px -32px #1113, 0 2px 0 #fff inset;
}

.landing-login .gate-body { padding: 32px 30px 27px; }

.landing-login h1 {
  margin: 0 0 5px;
  color: var(--ink);
  font-size: 25px;
  line-height: 1.15;
  letter-spacing: -.02em;
}

.landing-login p.lede {
  margin: 0 0 23px;
  color: var(--muted);
  font-size: 13px;
}

.landing-login .field { margin-bottom: 13px; }

.landing-login .gate-actions { margin-top: 18px; }

.landing-login .gate-foot { margin-top: 18px; }

.landing-modules {
  padding: 33px 0 48px;
  border-top: 2px solid var(--ink);
}

.landing-section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 20px;
}

.landing-section-heading .eyebrow { margin-bottom: 5px; }

.landing-section-heading h2,
.workflow-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -.035em;
}

.landing-section-heading > p {
  max-width: 360px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.module-card {
  position: relative;
  min-height: 220px;
  padding: 19px 19px 21px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--sheet);
  box-shadow: var(--shadow);
}

.module-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: transparent;
}

.module-card.module-live::before { background: var(--red); }

.module-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.module-index {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
}

.module-state {
  padding: 3px 7px;
  border: 1px solid #bfd8c7;
  border-radius: 2px;
  background: var(--ok-wash);
  color: var(--ok);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.module-state.future {
  border-color: var(--line);
  background: #faf8f4;
  color: var(--muted);
}

.module-symbol {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 21px 0 13px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--red);
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
}

.module-card h3 {
  margin: 0 0 7px;
  color: var(--ink);
  font-size: 15px;
  letter-spacing: -.015em;
}

.module-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.landing-workflow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  margin: 0 0 34px;
  padding: 25px 28px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
}

.workflow-heading { min-width: 210px; }

.workflow-heading .eyebrow { color: #c6c1b8; }

.workflow-heading h2 {
  color: #fff;
  font-size: 19px;
}

.workflow-steps {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(13px, 2.4vw, 30px);
}

.workflow-step {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 8px;
  align-items: baseline;
  min-width: 94px;
}

.workflow-step > span {
  color: #e36b6f;
  font-family: var(--mono);
  font-size: 9px;
}

.workflow-step b {
  color: #fff;
  font-size: 11px;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.workflow-step small {
  grid-column: 2;
  color: #c6c1b8;
  font-size: 10px;
}

.workflow-arrow {
  color: var(--red);
  font-size: 18px;
}

.landing-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 65px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
}

.landing-footer-brand {
  color: var(--ink);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .13em;
}

.landing-footer a:last-child {
  color: var(--red);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

@media (max-width: 900px) {
  .landing-hero {
    grid-template-columns: minmax(0, 1fr) minmax(300px, .9fr);
    gap: 30px;
    padding: 58px 0 64px;
  }

  .landing-intro h2 { font-size: clamp(36px, 5vw, 48px); }

  .landing-workflow {
    align-items: flex-start;
    flex-direction: column;
    gap: 19px;
  }

  .workflow-steps { width: 100%; justify-content: space-between; }
}

@media (max-width: 760px) {
  .landing-hero {
    grid-template-columns: 1fr;
    gap: 30px;
    padding: 44px 0 48px;
  }

  .landing-intro h2 { max-width: 620px; }

  .landing-login { max-width: 500px; }

  .landing-section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .module-grid { grid-template-columns: 1fr; }

  .module-card { min-height: 0; }

  .module-symbol { margin-top: 15px; }
}

@media (max-width: 520px) {
  .landing-shell { width: calc(100% - 32px); }

  .landing-header { min-height: 66px; }

  .landing-brand-name { font-size: 12px; }

  .landing-brand-subtitle {
    font-size: 8px;
    letter-spacing: .1em;
  }

  .landing-nav { gap: 10px; }

  .landing-nav > a:not(.btn) { display: none; }

  .landing-intro h2 {
    font-size: clamp(35px, 10vw, 43px);
  }

  .landing-description { font-size: 13.5px; }

  .landing-login .gate-body { padding: 25px 20px 22px; }

  .landing-section-heading h2 { font-size: 21px; }

  .landing-workflow { padding: 21px 18px; }

  .workflow-steps {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .workflow-step { min-width: 0; }

  .workflow-arrow {
    margin-left: 2px;
    transform: rotate(90deg);
  }

  .landing-footer {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 7px;
    padding: 17px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gate-card { animation: none; }
}


/* ======================= authenticated module selector ======================= */

.module-hub,
.module-preview { min-height: calc(100vh - 58px); }

.module-shell {
  position: relative;
  width: min(1080px, calc(100% - 44px));
  margin: 0 auto;
  padding: clamp(42px, 7vw, 78px) 0 34px;
}

.module-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--ink);
}

.module-page-head .eyebrow { margin-bottom: 9px; }

.module-page-head h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 48px);
  line-height: 1.05;
  letter-spacing: -.045em;
}

.module-page-lede {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.module-count {
  flex: none;
  padding-bottom: 5px;
  color: var(--muted);
  font: 700 10px/1 var(--mono);
  letter-spacing: .1em;
}

.module-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 24px 0 0;
}

.module-choice {
  position: relative;
  display: flex;
  min-height: 340px;
  flex-direction: column;
  align-items: flex-start;
  padding: 22px 23px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--sheet);
  box-shadow: var(--shadow);
}

.module-choice-available::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--red);
  content: "";
}

.module-choice-top,
.module-preview-kicker {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.module-choice-mark,
.module-preview-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 36px 0 20px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--red);
  font: 700 22px/1 var(--mono);
}

.module-choice h2 {
  margin: 0 0 8px;
  font-size: 21px;
  letter-spacing: -.03em;
}

.module-choice > p {
  max-width: 440px;
  margin: 0 0 25px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.module-choice-action {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding: 0 13px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font: 700 11px/1 var(--sans);
  letter-spacing: .08em;
  text-align: left;
  text-transform: uppercase;
  transition: background .16s ease, border-color .16s ease;
}

.module-choice-action:hover {
  border-color: var(--red-deep);
  background: var(--red-deep);
}

.module-choice-action span:last-child {
  font-size: 17px;
  font-weight: 400;
}

.module-choice-coming .module-choice-action {
  border-color: var(--line);
  background: #fffdfa;
  color: var(--ink-soft);
}

.module-choice-coming .module-choice-action:hover {
  border-color: var(--ink-soft);
  background: var(--paper);
}

.module-hub-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 42px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
}

.module-hub-footer span:first-child {
  color: var(--ink);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .13em;
}

.module-preview-shell {
  width: min(780px, calc(100% - 44px));
  margin: 0 auto;
  padding: 26px 0 60px;
}

.module-back { margin-bottom: 20px; }

.module-preview-panel {
  padding: clamp(25px, 5vw, 48px);
  border: 1px solid var(--line);
  border-top: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--sheet);
  box-shadow: var(--shadow);
}

.module-preview-panel .module-preview-mark {
  margin: 30px 0 22px;
}

.module-preview-panel .eyebrow { margin-bottom: 7px; }

.module-preview-panel h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 46px);
  line-height: 1.1;
  letter-spacing: -.045em;
}

.module-preview-lede {
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 17px;
  line-height: 1.5;
}

.module-preview-copy {
  max-width: 650px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.module-preview-note {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 25px 0;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.module-preview-note-mark {
  display: grid;
  flex: none;
  place-items: center;
  width: 21px;
  height: 21px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font: 700 12px/1 var(--mono);
}

.module-preview-note p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
}

@media (max-width: 760px) {
  .module-shell { width: min(100% - 30px, 580px); padding-top: 40px; }
  .module-page-head { align-items: flex-start; flex-direction: column; gap: 12px; }
  .module-picker-grid { grid-template-columns: 1fr; gap: 12px; }
  .module-choice { min-height: 310px; padding: 19px; }
  .module-choice-mark { margin-top: 27px; }
  .module-hub-footer { align-items: flex-start; flex-direction: column; gap: 7px; }
  .module-preview-shell { width: calc(100% - 30px); padding-top: 18px; }
}

@media (max-width: 480px) {
  .module-count { font-size: 9px; }
  .module-choice h2 { font-size: 19px; }
  .module-preview-panel { padding: 23px 19px; }
}


/* ===================== deleted records and retained audit ===================== */

.quote-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 190px;
  white-space: nowrap;
}

.row-deleted { background: #fffdfa; }
.row-deleted td { color: var(--muted); }
.row-deleted td.num span:first-child {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-weight: 700;
}

.audit-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--sheet);
}

.audit-table {
  width: 100%;
  min-width: 850px;
  border-collapse: collapse;
  font-size: 11.5px;
}

.audit-table th {
  padding: 10px 11px;
  background: var(--paper);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .1em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.audit-table td {
  padding: 10px 11px;
  border-top: 1px solid var(--line-soft);
  color: var(--ink-soft);
  vertical-align: top;
}

.audit-table td.audit-time {
  min-width: 155px;
  color: var(--muted);
  white-space: nowrap;
}

.audit-table td.audit-details {
  max-width: 360px;
  color: var(--muted);
  font: 10px/1.5 var(--mono);
  overflow-wrap: anywhere;
}

.modal-confirm-field { margin: 17px 0 2px; }
.modal-confirm-field input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: 13px/1.3 var(--mono);
}
.modal-confirm-field input:focus {
  outline: 2px solid var(--red);
  outline-offset: 1px;
}
.modal-actions .btn:disabled {
  opacity: .38;
  cursor: not-allowed;
}

@media (max-width: 760px) {
  .table-wrap tbody tr {
    grid-template-areas:
      "num num"
      "vehicle vehicle"
      "date money"
      "actions actions";
  }

  .table-wrap td.quote-row-actions {
    grid-area: actions;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 7px;
    min-width: 0;
    margin-top: 8px;
    padding-top: 9px;
    border-top: 1px solid var(--line-soft);
  }

  .quote-row-actions .btn { flex: 1 1 auto; }
  .audit-table-wrap { margin: 0 -2px; }
}

@media (max-width: 480px) {
  .quote-row-actions .btn { min-height: 36px; }
}


.audit-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
}
.audit-pagination .rail-note { margin: 0; }

@media (max-width: 520px) {
  .audit-pagination { align-items: stretch; flex-direction: column; }
  .audit-pagination .btn { width: 100%; }
}

/* copy helper beside the exact-value confirmation field */
.modal-confirm-row {
  display: flex;
  align-items: stretch;
  gap: 7px;
}
.modal-confirm-row input {
  flex: 1 1 180px;
  min-width: 0;
}
.modal-copy-button {
  flex: 0 0 auto;
  white-space: nowrap;
}
.modal-copy-status {
  display: block;
  min-height: 14px;
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}
@media (max-width: 480px) {
  .modal-confirm-row { flex-wrap: wrap; }
  .modal-copy-button { flex: 1 1 100%; }
}


/* ======================== audit trail, readable history ======================== */

.audit-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 23px 24px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #fff 0%, #fbfaf7 100%);
}

.audit-heading .eyebrow {
  margin: 0 0 5px;
  color: var(--red-deep);
}

.audit-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  letter-spacing: -.035em;
}

.audit-heading p:last-child {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.audit-total {
  display: grid;
  flex: none;
  min-width: 108px;
  gap: 2px;
  justify-items: end;
}

.audit-total-value {
  color: var(--ink);
  font: 700 26px/1 var(--mono);
  letter-spacing: -.06em;
  font-variant-numeric: tabular-nums;
}

.audit-total-label {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.audit-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: #fbfaf8;
}

.audit-toolbar-copy {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.audit-live-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-wash);
}

.audit-toolbar-divider { color: #b3ada3; }

.audit-range {
  flex: none;
  color: var(--ink-soft);
  font: 10px/1.4 var(--mono);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.audit-table-wrap {
  overflow-x: auto;
  max-width: 100%;
  border: 0;
  border-radius: 0;
  background: var(--sheet);
}

.audit-table {
  width: 100%;
  min-width: 780px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

.audit-table th {
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  background: #f5f3ef;
  color: #777168;
  font: 700 9px/1.2 var(--sans);
  letter-spacing: .1em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.audit-table th:first-child,
.audit-table td:first-child { padding-left: 22px; }

.audit-table th:last-child,
.audit-table td:last-child { padding-right: 22px; }

.audit-table td {
  padding: 13px;
  border-bottom: 1px solid #eeeae3;
  color: var(--ink-soft);
  vertical-align: middle;
}

.audit-table tbody tr {
  background: #fff;
  transition: background .12s ease;
}

.audit-table tbody tr:nth-child(even) { background: #fdfcf9; }
.audit-table tbody tr:hover { background: #f8f5ef; }
.audit-table tbody tr:last-child td { border-bottom: 0; }

.audit-time-cell { min-width: 112px; }

.audit-date {
  display: block;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.audit-clock {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font: 10px/1.2 var(--mono);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.audit-actor {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #f8f7f4;
  color: var(--ink-soft);
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}

.audit-activity-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid #e4dfd6;
  border-radius: 3px;
  background: #f5f3ef;
  color: #514d46;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.25;
}

.audit-tone-success {
  border-color: #d6e7da;
  background: #edf5ef;
  color: #245d37;
}

.audit-tone-warning {
  border-color: #eadfc9;
  background: #f8f2e6;
  color: #795b24;
}

.audit-tone-danger {
  border-color: #efcfcc;
  background: #fbefed;
  color: #9d2523;
}

.audit-summary {
  display: block;
  max-width: 310px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.audit-record {
  display: inline-block;
  max-width: 210px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.audit-more-cell { min-width: 100px; }

.audit-more summary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--red-deep);
  cursor: pointer;
  font-size: 10.5px;
  font-weight: 700;
  list-style: none;
  white-space: nowrap;
}

.audit-more summary::-webkit-details-marker { display: none; }
.audit-more summary::after {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border: 1px solid #e3c4c1;
  border-radius: 50%;
  font: 12px/1 var(--mono);
}
.audit-more[open] summary::after { content: "−"; }
.audit-more summary:hover { color: var(--red); }

.audit-detail-list {
  display: grid;
  grid-template-columns: minmax(120px, .7fr) minmax(160px, 1.3fr);
  gap: 0 12px;
  min-width: 300px;
  max-width: 510px;
  margin: 10px 0 3px;
  padding: 9px 11px;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  background: #fbfaf7;
}

.audit-detail-list dt,
.audit-detail-list dd {
  min-width: 0;
  margin: 0;
  padding: 5px 0;
  border-bottom: 1px solid #eeeae3;
  font-size: 10px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.audit-detail-list dt {
  color: var(--muted);
  font-weight: 600;
  text-transform: capitalize;
}

.audit-detail-list dd { color: var(--ink-soft); }

.audit-detail-list dt:last-of-type,
.audit-detail-list dd:last-of-type { border-bottom: 0; }

.audit-detail-empty {
  margin: 8px 0 2px;
  color: var(--muted);
  font-size: 11px;
}

.audit-empty-state {
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 44px 18px;
  text-align: center;
  background: #fff;
}

.audit-empty-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid #d6e7da;
  border-radius: 50%;
  background: #edf5ef;
  color: #245d37;
  font-size: 18px;
}

.audit-empty-state h3 {
  margin: 3px 0 0;
  color: var(--ink);
  font-size: 15px;
}

.audit-empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.audit-pagination {
  min-height: 62px;
  padding: 13px 22px;
  border-top: 1px solid var(--line);
  background: #fbfaf8;
}

.audit-pagination-note {
  color: var(--muted);
  font-size: 10.5px;
}

.audit-pagination .btn { min-height: 34px; }
.audit-pagination .btn span { margin-left: 4px; }

.audit-empty-state[hidden] { display: none; }

@media (max-width: 760px) {
  .audit-heading { align-items: flex-start; padding: 19px 16px 16px; }
  .audit-heading h2 { font-size: 21px; }
  .audit-heading p:last-child { max-width: 420px; font-size: 11.5px; }
  .audit-total { min-width: 82px; padding-top: 3px; }
  .audit-total-value { font-size: 22px; }
  .audit-toolbar { align-items: flex-start; flex-direction: column; gap: 8px; padding: 11px 16px; }
  .audit-range { align-self: flex-end; }
  .audit-table-wrap { overflow: visible; }
  .audit-table { display: block; min-width: 0; }
  .audit-table thead { display: none; }
  .audit-table tbody { display: grid; gap: 10px; padding: 12px; background: var(--paper); }
  .audit-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #fff;
    box-shadow: var(--shadow);
  }
  .audit-table tbody tr:nth-child(even),
  .audit-table tbody tr:hover { background: #fff; }
  .audit-table td,
  .audit-table th:first-child,
  .audit-table td:first-child,
  .audit-table th:last-child,
  .audit-table td:last-child {
    min-width: 0;
    padding: 0;
    border: 0;
  }
  .audit-table td::before {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    content: attr(data-label);
    font: 700 8.5px/1.2 var(--sans);
    letter-spacing: .1em;
    text-transform: uppercase;
  }
  .audit-time-cell,
  .audit-table td:nth-child(3),
  .audit-table td:nth-child(4),
  .audit-more-cell { grid-column: 1 / -1; }
  .audit-time-cell {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding-bottom: 8px !important;
    border-bottom: 1px solid var(--line-soft) !important;
  }
  .audit-time-cell::before { margin: 0 4px 0 0; }
  .audit-date,
  .audit-clock { display: inline; margin: 0; }
  .audit-summary { max-width: none; }
  .audit-record { max-width: none; }
  .audit-detail-list { grid-template-columns: minmax(100px, .8fr) minmax(0, 1.2fr); min-width: 0; }
  .audit-pagination { padding: 12px 16px; }
}

@media (max-width: 420px) {
  .audit-heading { gap: 10px; }
  .audit-total { min-width: 68px; }
  .audit-total-label { font-size: 8px; }
  .audit-table tbody tr { grid-template-columns: 1fr; gap: 9px; }
  .audit-time-cell,
  .audit-table td:nth-child(3),
  .audit-table td:nth-child(4),
  .audit-more-cell { grid-column: 1; }
  .audit-time-cell { flex-wrap: wrap; }
}

.audit-record-context {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 400;
  line-height: 1.35;
}


/* Distinct document symbols for each Business Desk module */
.module-choice-icon {
  border-radius: 5px;
  font-size: 0;
}
.module-choice-icon svg {
  display: block;
  width: 36px;
  height: 36px;
  overflow: visible;
}
.module-icon-quotation {
  border-color: #efcfcc;
  background: var(--red-wash);
  color: var(--red-deep);
}
.module-icon-invoice {
  border-color: #d6e7da;
  background: var(--ok-wash);
  color: #245d37;
}
.module-preview-panel .module-icon-invoice {
  width: 62px;
  height: 62px;
}
.module-preview-panel .module-icon-invoice svg {
  width: 42px;
  height: 42px;
}


/* Whole-card interaction for module selection */
.module-choice {
  cursor: pointer;
  outline: none;
  transition:
    transform .18s ease,
    border-color .18s ease,
    box-shadow .18s ease,
    background-color .18s ease;
}

.module-choice-available:hover {
  transform: translateY(-4px);
  border-color: var(--red);
  box-shadow: 0 12px 28px #11111112, 0 3px 8px #1111110a;
}

.module-choice-coming:hover {
  transform: translateY(-4px);
  border-color: #8aa994;
  box-shadow: 0 12px 28px #11111112, 0 3px 8px #1111110a;
}

.module-choice:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 4px;
  border-color: var(--red);
}

.module-choice:active {
  transform: translateY(-1px) scale(.997);
  box-shadow: 0 3px 10px #11111112;
}

.module-choice-hint {
  display: flex;
  width: 100%;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 13px;
  border-top: 1px solid var(--line-soft);
  color: var(--ink-soft);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .065em;
  text-transform: uppercase;
}

.module-choice-arrow {
  display: grid;
  flex: none;
  place-items: center;
  width: 27px;
  height: 27px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
  transition:
    transform .18s ease,
    background-color .18s ease,
    border-color .18s ease,
    color .18s ease;
}

.module-choice-available:hover .module-choice-arrow,
.module-choice-available:focus-visible .module-choice-arrow {
  transform: translate(2px, -2px);
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

.module-choice-coming:hover .module-choice-arrow,
.module-choice-coming:focus-visible .module-choice-arrow {
  transform: translate(2px, -2px);
  border-color: #245d37;
  background: #245d37;
  color: #fff;
}

.module-choice:hover .module-choice-icon,
.module-choice:focus-visible .module-choice-icon {
  transform: translateY(-2px) scale(1.04);
}

.module-choice-icon {
  transition: transform .18s ease;
}

@media (prefers-reduced-motion: reduce) {
  .module-choice,
  .module-choice-arrow,
  .module-choice-icon {
    transition: none;
  }
  .module-choice-available:hover,
  .module-choice-coming:hover,
  .module-choice:active {
    transform: none;
  }
}


/* ========================== public module refresh ========================== */

.module-card {
  min-height: 252px;
}

.module-symbol.module-symbol-icon {
  width: 52px;
  height: 52px;
  margin: 20px 0 14px;
  border-radius: 5px;
  background: var(--paper);
  font-size: 0;
}

.module-symbol.module-symbol-icon svg {
  display: block;
  width: 37px;
  height: 37px;
}

.module-symbol-quotation {
  border-color: #efcfcc;
  background: var(--red-wash) !important;
  color: var(--red-deep);
}

.module-symbol-invoice {
  border-color: #d6e7da;
  background: var(--ok-wash) !important;
  color: #245d37;
}

.module-symbol-notifications {
  border-color: #e7dcc2;
  background: #f8f3e8 !important;
  color: #80622c;
}

.workflow-heading {
  flex: 0 0 245px;
}

.workflow-intro {
  max-width: 260px;
  margin: 9px 0 0;
  color: #c6c1b8;
  font-size: 11px;
  line-height: 1.55;
}

.workflow-steps {
  flex: 1;
  justify-content: space-between;
  gap: 18px;
}

.workflow-step {
  flex: 1 1 0;
  min-width: 0;
}

.workflow-step-icon {
  display: inline-grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 1px solid #5b5650;
  border-radius: 50%;
  color: #e36b6f;
  font: 700 9px/1 var(--mono);
  font-variant-numeric: tabular-nums;
}

.workflow-step b {
  align-self: center;
  font-size: 10px;
}

.workflow-step small {
  max-width: 170px;
  line-height: 1.5;
}

@media (max-width: 900px) {
  .workflow-heading { flex-basis: auto; }
  .workflow-steps { width: 100%; }
  .workflow-step { min-width: 0; }
}

@media (max-width: 760px) {
  .module-card { min-height: 0; }
  .module-symbol.module-symbol-icon { margin-top: 17px; }
  .workflow-step small { max-width: 240px; }
}

@media (max-width: 520px) {
  .workflow-heading { min-width: 0; }
  .workflow-steps { align-items: flex-start; }
  .workflow-step {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    column-gap: 9px;
  }
  .workflow-step-icon { grid-row: 1 / span 2; }
  .workflow-step b { grid-column: 2; }
  .workflow-step small { grid-column: 2; }
}
