/*
 * Maud POS screens, in the Maud house style: index bar in the brand green (Pantone 3435 C, #154734),
 * gold highlight, sand page,
 * boxed sheets with tinted title bands and square corners. Loaded after app.css, which supplies
 * the base rules; the colours and fonts it names are redefined here for the POS only.
 */
:root {
  color-scheme: light;
  --bg: #F6F2EB; --panel: #FFFDF9; --field: #FFFDF9; --tint: #EBE4D8; --hover: #F1ECE3;
  --ink: #1B1A16; --muted: #57524A; --line: #DDD4C5; --rule-strong: #154734;
  --accent: #154734; --accent-ink: #F6F2EB;
  --bar-bg: #154734; --bar-ink: #F6F2EB; --bar-muted: #C9BC9A; --gold: #E1CEA3; --taupe: #7B5F48;
  --hl: #E1CEA3; --hl-ink: #154734;
  --good: #2E6B44; --warn: #A3322A; --warn-bg: #F6E3DF; --note: #8F5A12; --note-bg: #F3E7CF;
  --font-body: "Schibsted Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-display: "Playfair Display", "Times New Roman", serif;
  --font-mono: "DM Mono", ui-monospace, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #04140E; --panel: #071F15; --field: #04140E; --tint: #0E2A1D; --hover: #0B2419;
    --ink: #F6F2EB; --muted: #C9BC9A; --line: #1F3B2D; --rule-strong: #E1CEA3;
    --accent: #E1CEA3; --accent-ink: #04140E;
    --bar-bg: #071F15; --bar-ink: #F6F2EB; --bar-muted: #A8916A; --gold: #E1CEA3; --taupe: #C9A88A;
    --hl: #3A3524; --hl-ink: #E1CEA3;
    --good: #7FCB98; --warn: #EE958C; --warn-bg: #3A1F1D; --note: #E3B46A; --note-bg: #3A3018;
  }
}

body { font-size: 14px; line-height: 1.5; }
.page { max-width: 1360px; padding: 26px 20px 64px; gap: 18px; }
@media (min-width: 900px) { .page { padding-left: 32px; padding-right: 32px; } }

/* ---------- index bar ---------- */
.masthead { position: sticky; top: 0; z-index: 5; }
.topbar {
  background: var(--bar-bg);
  display: flex; align-items: stretch; gap: 2px; overflow-x: auto;
  padding: 0 20px;
}
@media (min-width: 900px) { .topbar { padding: 0 32px; } }
.brand { display: flex; align-items: baseline; gap: 10px; padding: 14px 22px 14px 0; margin-right: 8px; border-right: 1px solid rgba(225, 206, 163, 0.22); white-space: nowrap; }
.brand .mark, .login-mark { font-family: var(--font-brand); font-size: 19px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--gold); }
.brand .sub { font-size: 12.5px; color: var(--bar-muted); }
.tabs, .groups { display: flex; gap: 2px; }
/* The sections of the open group, in a lighter bar under the green one. */
.subbar { background: var(--panel); border-bottom: 1px solid var(--line); padding: 0 20px; overflow-x: auto; scrollbar-width: none; }
.subbar::-webkit-scrollbar { display: none; }
@media (min-width: 900px) { .subbar { padding: 0 32px; } }
.tabs button.other-group { display: none; }
.subbar .tabs button { padding: 9px 12px 8px; color: var(--muted); font-size: 13.5px; }
.subbar .tabs button:hover { color: var(--ink); }
.subbar .tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--rule-strong); }
.groups button[aria-pressed="true"] { color: var(--bar-ink); border-bottom-color: var(--gold); }
.groups button:hover { color: var(--bar-ink); }
.tabs button, .groups button {
  border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none;
  padding: 14px 12px 12px; color: var(--bar-muted); font-size: 14px; font-weight: 500; white-space: nowrap;
}
.tabs button:hover { color: var(--bar-ink); }
.tabs button[aria-selected="true"] { color: var(--bar-ink); border-bottom-color: var(--gold); }
.bar-foot { margin-left: auto; display: flex; align-items: center; gap: 16px; padding-left: 16px; font-size: 12px; color: var(--bar-muted); white-space: nowrap; }
.bar-foot a { color: var(--bar-ink); text-decoration-color: var(--bar-muted); text-underline-offset: 3px; }
.topbar :focus-visible { outline-color: var(--gold); }
@media (max-width: 820px) { .brand .sub, #storeKind { display: none; } }

/* ---------- page heading ---------- */
.ph { padding-bottom: 14px; margin-bottom: 18px; border-bottom: 1px solid var(--line); gap: 2px; }
.ph h1 { font-family: var(--font-display); font-size: 27px; font-weight: 500; line-height: 1.2; letter-spacing: 0; }
.ph .lede { color: var(--muted); max-width: 70ch; }
@media (max-width: 820px) { .ph h1 { font-size: 21px; } }

/* ---------- sheets, title bands, controls ---------- */
.work { gap: 18px; }
.work.sell { grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); }
@media (max-width: 860px) { .work.sell { grid-template-columns: minmax(0, 1fr); } }
.panel { border-radius: 0; padding: 16px; gap: 16px; }
.panel.flush { padding: 0; }
.group { border: 0; padding: 0; gap: 12px; }
.band, details.group > summary {
  margin: 0 -16px; padding: 8px 16px;
  background: var(--tint); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font-size: 13px; font-weight: 600; line-height: 1.5;
}
.group.first > .band { margin-top: -16px; border-top: 0; }
details.group > summary { cursor: pointer; }
details.group:not([open]) > summary { margin-bottom: -16px; border-bottom: 0; }
details.group > * + * { margin-top: 12px; }
details.group textarea { min-height: 130px; }
.field { gap: 4px; }
.field label { font-size: 12px; font-weight: 500; color: var(--muted); }
.hint { font-size: 12px; }
textarea, select, input[type="number"], input[type="text"], input[type="password"], input[type="email"], input[type="date"] {
  font: inherit; font-size: 13.5px; color: var(--ink); background: var(--field);
  border: 1px solid var(--line); border-radius: 2px; padding: 7px 9px; width: 100%; min-width: 0;
}
textarea { font-family: var(--font-mono); font-size: 12.5px; }
input[type="number"] { font-family: var(--font-mono); }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: none; }
input[type="text"].invalid, select.invalid { border-color: var(--warn); }
button { border-radius: 2px; font-size: 13.5px; }
button:hover { border-color: var(--ink); }
button.primary:hover { opacity: 0.88; border-color: var(--accent); }
button.big { font-size: 15px; padding: 10px 18px; }
.filter { width: 200px; }
#scan { font-family: var(--font-body); font-size: 17px; padding: 11px 12px; }
.err { border-radius: 0; }
.empty { border-radius: 0; background: none; }
.toast { border-radius: 0; }
.summary { font-size: 13px; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); background: var(--tint); padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--hover); }
table.data .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data th.num { font-family: var(--font-body); }
table.data code, .preview code, .results code { font-family: var(--font-mono); font-size: 12px; }
table.data td > code { white-space: nowrap; }
table.data td input[type="number"], table.data td input[type="text"] { width: 90px; padding: 4px 7px; text-align: right; font-family: var(--font-mono); }
table.data td input[type="checkbox"], table.data th input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
table.data .sub { display: block; font-size: 12px; color: var(--muted); }
table.data tr.void td { color: var(--muted); text-decoration: line-through; }
table.data tr.void td:last-child, table.data tr.void td.status { text-decoration: none; }
table.data td button { padding: 3px 9px; font-size: 12.5px; font-family: var(--font-body); white-space: nowrap; }
.panel:not(.flush) > .tablewrap { margin: 0 -16px; }
.panel:not(.flush) > .tablewrap table.data th:first-child, .panel:not(.flush) > .tablewrap table.data td:first-child { padding-left: 16px; }
.panel:not(.flush) > .tablewrap table.data th:last-child, .panel:not(.flush) > .tablewrap table.data td:last-child { padding-right: 16px; }
.low { color: var(--warn); font-weight: 600; }
.minus { color: var(--warn); }
.plus { font-weight: 600; }
.scan-msg { min-height: 18px; font-size: 13px; color: var(--ink); }
.scan-msg.bad { color: var(--warn); font-weight: 600; }
.count-big { display: flex; align-items: baseline; gap: 10px; }
.count-big > span:first-child { font-family: var(--font-mono); font-size: 40px; line-height: 1; }
.count-big .k { font-size: 13px; color: var(--muted); }
.out-line { overflow-wrap: anywhere; }

/* ---------- signing in and users ---------- */
.no-access { display: none !important; }
#whoAmI { color: var(--bar-ink); }
.link-button { border: 0; background: none; padding: 0; color: var(--bar-muted); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; min-height: 0; }
.link-button:hover { color: var(--bar-ink); }
.login-sent { font-size: 13px; padding: 9px 11px; background: var(--tint); border-left: 2px solid var(--rule-strong); }
.login-sent[hidden] { display: none; }
.login-owner { font-size: 13px; }
.login-owner > summary { cursor: pointer; color: var(--muted); }
.login-owner[open] > summary { margin-bottom: 10px; }
.login-owner .field { margin-bottom: 10px; }
.dialog-note { font-size: 12.5px; color: var(--muted); margin-left: auto; }
#tab-users .work { grid-template-columns: minmax(0, 1fr); }
#tab-users .work > .panel { max-width: 560px; }
#usList td:last-child { white-space: normal; }
.steps { margin: 0; padding-left: 20px; font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.steps code { font-family: var(--font-mono); font-size: 12px; overflow-wrap: anywhere; }
#usList td button { margin: 2px 0 2px 6px; }
#usList td button:first-child { margin-left: 0; }
@media (max-width: 820px) { #whoAmI { display: none; } }

/* ---------- labels ---------- */
/*
 * The label maker's own rules are in app.css. Nothing here may change what is inside a label (.lbl).
 * app.css gives a label --font-body and the page's 15px, both of which this file changes for the
 * screens, so they are pinned back to what a label has always used.
 */
.lbl { font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif; font-size: 15px; }
#tab-labels .card, #tab-labels .stage { border-radius: 0; }
#tab-labels .meta code { font-family: var(--font-mono); font-size: 12px; }
#tab-labels .chip { border-radius: 2px; }
#tab-labels .printhint { margin: 0; }
#rows { min-height: 200px; }
#lpManual[hidden] { display: none; }
#lpTable th:nth-child(2), #lpTable th:nth-child(3) { width: 18%; }

/* ---------- costing ---------- */
.seg { display: flex; flex-wrap: wrap; gap: 0; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.seg button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 14px; color: var(--muted); font-weight: 500; }
.seg button:hover { color: var(--ink); }
.seg button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--rule-strong); }
.cview[hidden] { display: none; }
/*
 * Lists run across the whole page so their columns have room. Under the style list, the costing
 * sheet takes the larger share beside its totals, and the whole width on a smaller screen.
 */
#cview-styles, #cview-production { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
#cview-production { grid-template-columns: minmax(0, 1fr); }
.cview > .span { grid-column: 1 / -1; }
#cview-production > .panel { max-width: 760px; }
@media (max-width: 1250px) { #cview-styles, #cview-materials { grid-template-columns: minmax(0, 1fr); } #cview-styles > .out:not(.span) { position: static; } }
#csPanel[hidden], #csTotalsPanel[hidden] { display: none; }
#csSheet { display: flex; flex-direction: column; gap: 14px; }
#csSheet > .sub-h { margin: 8px 0 -4px; }
#csSheet > .row-actions, .cview .group > .row-actions { margin-top: 6px; }
#cview-styles > .out:not(.span) { position: sticky; top: 64px; }   /* Costing has no second bar above it */
table.data tr.is-open td { background: var(--tint); }
table.data td.standing { white-space: nowrap; }
/* Lines of a costing fit the width they are given: the name takes what is left, the figures share the rest. */
table.data.lines { border: 1px solid var(--line); table-layout: fixed; }
table.data.lines th, table.data.lines td { padding-left: 8px; padding-right: 8px; white-space: normal; }
table.data.lines th:first-child { width: auto; }
table.data.lines th.num { width: 13%; }
table.data.lines th:last-child { width: 92px; }
#csFabTable th:nth-child(2) { width: 16%; }
table.data.lines td select, table.data.lines td input[type="text"] { width: 100%; min-width: 0; }
table.data.lines td input.role { text-align: left; font-family: var(--font-body); }
table.data.lines td.line-cost { overflow-wrap: anywhere; white-space: normal; }
#csTotalsPanel .totals { margin-top: 0; }
#csFlags, #cbNeed { margin-top: 10px; }
.standing-bad { color: var(--warn); font-weight: 600; }
@media (max-width: 640px) {
  table.data.lines { border: 0; }
  #cview-styles > .out:not(.span) { position: static; }
  table.data.lines td select, table.data.lines td input[type="text"], table.data.lines td input.role { width: 100%; max-width: none; min-width: 0; text-align: left; }
}

/* ---------- reports ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0; background: var(--panel, #fff); border: 1px solid var(--line); overflow: hidden; }
.tiles:empty { display: none; }
.tiles > div { box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tiles .k { font-size: 12px; color: var(--muted); }
.tiles .v { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
th.sortable { cursor: pointer; user-select: none; }
#rpTable th { white-space: normal; vertical-align: bottom; }
th.sortable:hover { text-decoration: underline; }
#rpTable td .bar { display: block; height: 3px; margin: 3px 0 0 auto; background: var(--rule-strong); }
#rpTable td.wrap { min-width: 170px; }
#tab-reports .work { grid-template-columns: minmax(0, 1fr); }
#tab-reports .group { flex-direction: row; flex-wrap: wrap; align-items: flex-start; gap: 12px 16px; }
#tab-reports .group > .band { flex: 0 0 calc(100% + 32px); }
#tab-reports .group > .field { flex: 1 1 240px; }
#tab-reports #rpRange { flex: 2 1 420px; grid-template-columns: 1.3fr 1fr 1fr; }
#tab-reports #rpRange .wide { grid-column: auto; }
#tab-reports .group > .hint { flex: 1 1 240px; align-self: center; }
#tab-reports .group > .row-actions { flex: 0 0 auto; margin-top: 21px; }
.topbar { scrollbar-width: none; }   /* the bar still slides sideways when the sections do not fit */
.topbar::-webkit-scrollbar { display: none; }
@media (max-width: 640px) {
  #rpTable td.wrap { min-width: 0; }
  #tab-reports #rpRange { grid-template-columns: 1fr 1fr; flex-basis: 100%; }
  #tab-reports #rpRange .wide { grid-column: 1 / -1; }
  #tab-reports .group > .row-actions { margin-top: 0; flex: 1 1 100%; }
}
#rpTable tr.total td { font-weight: 600; border-top: 2px solid var(--rule-strong); }
.report-print { display: none; }

/* ---------- product lookup, previews ---------- */
.results { display: flex; flex-direction: column; gap: 0; }
.results:empty { display: none; }
.results button { text-align: left; display: flex; justify-content: space-between; gap: 12px; align-items: baseline; border-radius: 0; margin-top: -1px; padding: 8px 10px; }
.results button:hover { background: var(--hover); position: relative; }
.results .sub { font-size: 12px; color: var(--muted); white-space: nowrap; font-family: var(--font-mono); }
.results .none { padding: 8px 10px; font-size: 13px; color: var(--muted); border: 1px solid var(--line); }
.notice { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; font-size: 13px; background: var(--tint); border-left: 2px solid var(--rule-strong); }
.notice[hidden] { display: none; }
.preview { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.preview:empty { display: none; }
.preview .ok, .preview .bad { padding: 8px 10px; background: var(--tint); overflow-wrap: anywhere; border-left: 2px solid var(--rule-strong); }
.preview .bad { background: var(--warn-bg); color: var(--warn); border-left-color: var(--warn); }
.preview .sub { display: block; color: var(--muted); font-size: 12.5px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.checks label { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 400; color: var(--ink); }
.checks input { width: 16px; height: 16px; accent-color: var(--accent); }
.vocab { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.vocab textarea { min-height: 130px; white-space: pre; }
@media (max-width: 520px) { .vocab { grid-template-columns: 1fr; } }
textarea.prose { font-family: var(--font-body); font-size: 13px; white-space: pre-wrap; min-height: 150px; }

/* ---------- the till: totals at the head of the sheet, the total on a gold band ---------- */
.totals { margin: -16px -16px 0; display: grid; grid-template-columns: 1fr auto; font-variant-numeric: tabular-nums; padding-top: 10px; }
.totals dt, .totals dd { margin: 0; padding: 3px 16px; font-size: 13px; }
.totals dt { color: var(--muted); }
.totals dd { text-align: right; font-family: var(--font-mono); }
.totals .grand { background: var(--hl); color: var(--hl-ink); padding-top: 10px; padding-bottom: 10px; margin: 8px 0 6px; font-weight: 600; font-size: 14px; display: flex; align-items: baseline; }
.totals dd.grand { font-size: 21px; font-weight: 500; justify-content: flex-end; }
.till > .group:first-of-type > .band { margin-top: -8px; }
.readout { padding: 7px 9px; border: 1px dashed var(--line); border-radius: 2px; font-family: var(--font-mono); font-size: 13.5px; min-height: 36px; }

.first-band { margin-top: -16px; border-top: 0; }
.sub-h { margin: 14px 0 0; font-size: 15px; font-weight: 600; }
.plain-h { margin: 0; font-size: 13px; font-weight: 600; }
.wide-filter { width: 300px; max-width: 100%; }
.stack { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.preview .ok button { float: right; margin-left: 8px; padding: 2px 8px; font-size: 12px; }
.history-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); }
.history-grid > div { padding: 10px 14px; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.history-grid > div:first-child { border-left: 0; }
.history-grid .k { font-size: 12px; color: var(--muted); }
.history-grid .v { font-family: var(--font-mono); font-size: 17px; }
.totals.plain { margin: 0; padding: 0; border: 1px solid var(--line); }
.totals.plain dt, .totals.plain dd { padding: 6px 12px; }
.totals.plain .grand { margin: 0; font-size: 14px; }
.totals.plain dd.grand { font-size: 17px; }

/* ---------- dialogs ---------- */
#returnDialog { width: 940px; max-width: 96vw; }
.return-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.return-body > .tablewrap { border: 1px solid var(--line); }
.return-cols { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 720px) { .return-cols { grid-template-columns: minmax(0, 1fr); } }
table.data td select { width: 100%; min-width: 120px; padding: 4px 7px; font-size: 13px; }
table.data td input.qty { width: 64px; }
dialog { border: 1px solid var(--line); border-radius: 0; padding: 0; background: var(--panel); color: var(--ink); max-width: min(96vw, 170mm); max-height: 94vh; }
dialog::backdrop { background: rgba(21, 71, 52, 0.55); }
/* The POS's own "are you sure" and typed-answer dialog. */
#askDialog { width: min(92vw, 440px); }
.ask { display: flex; flex-direction: column; gap: 14px; padding: 20px 22px 18px; }
.ask h2 { margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 500; line-height: 1.25; }
.ask-text p { margin: 0 0 8px; line-height: 1.45; overflow-wrap: anywhere; }
.ask-text p:last-child { margin-bottom: 0; }
.ask-text:empty, .ask [hidden] { display: none; }
.ask-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.ask-actions button { min-width: 96px; padding: 9px 16px; }
button.danger, button.primary.danger { background: var(--warn); border-color: var(--warn); color: #fff; }
@media (max-width: 720px) { .ask-actions button { flex: 1 1 0; } }
.dialog-bar { position: sticky; top: 0; display: flex; gap: 8px; padding: 10px 12px; background: var(--tint); border-bottom: 1px solid var(--line); }
.invoice-view { padding: 12px; overflow: auto; background: var(--bg); }
.invoice-view .invoice { box-shadow: 0 0 0 1px var(--line); margin: 0 auto; }
.login { display: flex; flex-direction: column; gap: 14px; padding: 0 22px 22px; width: min(86vw, 340px); }
.login-mark { margin: 0 -22px; padding: 18px 22px 16px; background: var(--bar-bg); font-size: 22px; text-align: center; }
.login h2 { margin: 0; font-family: var(--font-display); font-size: 21px; font-weight: 500; }

/*
 * ---------- the invoice: drawn at A5 to follow the Maud invoice sheet, in mm, black on white ----------
 * On A4 paper the whole sheet is enlarged at print time (see printInvoice), so nothing here changes.
 * Every row is 3.43 mm tall and the columns sit where they do on the sheet. Positions are from
 * the left edge of the text area, which starts 18.1 mm in from the paper edge.
 */
.invoice {
  box-sizing: border-box;
  width: 148mm;
  min-height: 209.5mm;
  padding: 19.4mm 18.4mm 8mm 18.1mm;
  background: #fff;
  color: #000;
  font-family: "Aptos Narrow", "Arial Narrow", "Barlow Semi Condensed", Arial, sans-serif;
  font-size: 6.6pt;
  line-height: 3.43mm;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.iv-r { display: grid; min-height: 3.43mm; }
.iv-r > span { min-width: 0; padding-left: 0.3mm; }
.iv-r .c { text-align: center; padding-left: 0; }
.iv-r .n { text-align: right; padding-left: 0; white-space: nowrap; }
.iv-small, .iv-size { font-size: 5.76pt; }
.iv-logo { display: block; width: 14.15mm; height: 15.08mm; margin: -0.1mm auto 0; }
.iv-brand { font-family: var(--font-brand); font-size: 19.92pt; line-height: 7mm; text-align: center; white-space: pre; margin-top: 1.3mm; padding-bottom: 7.55mm; }
.iv-who { grid-template-columns: 20.6mm 1fr auto; }
.iv-who .iv-date { padding-right: 0.5mm; }
.iv-who + .iv-item { margin-top: 3.43mm; }
.iv-item { grid-template-columns: 16.2mm 4.8mm 21.8mm 35.9mm 10.6mm 10.5mm 10.6mm 1.1mm; }
.iv-item > span:nth-child(6) { grid-column: 7; }
.iv-item.iv-head { border-bottom: 0.3mm solid #000; min-height: 3.46mm; margin-bottom: -0.03mm; }
.iv-item.iv-head > span { white-space: nowrap; justify-self: center; }
.iv-item.iv-head > span:nth-child(4) { padding-right: 5.3mm; }
/* Room for six one-line items, as on the sheet. More items, or long descriptions, push the totals down. */
.iv-items { min-height: 20.58mm; }
.iv-item > span:nth-child(4) { padding: 0 3mm 0 0.5mm; }
.iv-sum { grid-template-columns: 43.0mm 42.8mm auto 1fr 1.1mm; }
.iv-sum > span:nth-child(1) { grid-column: 2; }
.iv-sum > span:nth-child(2) { grid-column: 3; }
.iv-sum > span:nth-child(3) { grid-column: 4; }
.iv-grand { position: relative; }
.iv-grand::after { content: ""; position: absolute; left: 42.9mm; height: 0; right: 0; bottom: 0; border-bottom: 0.3mm solid #000; }
.iv-mode { grid-template-columns: 17.3mm 1fr; }
.iv-modehead { margin-top: -3.43mm; }
.iv-note { text-align: center; margin-top: 10.8mm; text-transform: none; }
.iv-policy { font-family: Arial, Helvetica, sans-serif; font-size: 5.76pt; line-height: 2.67mm; text-align: center; text-transform: none; white-space: pre-line; margin: 5.1mm -2mm 0; }
.iv-contact-head, .iv-contact { font-size: 5.4pt; text-align: center; }
.iv-contact-head { margin-top: 5.2mm; }
.iv-contact { white-space: pre-wrap; }
.invoice > * { break-inside: avoid; }

/*
 * ---------- touch screens and phones ----------
 * Screen layout only: the invoice keeps its mm sizes, and its preview is fitted to the screen by fitDoc in pos-app.js.
 */
@media (pointer: coarse), (max-width: 640px) {
  /* 16px stops a phone zooming the page when a field is tapped */
  textarea, select, input[type="number"], input[type="text"], input[type="password"] { font-size: 16px; min-height: 44px; }
  #scan { font-size: 17px; }
  button { min-height: 44px; padding-left: 14px; padding-right: 14px; }
  .tabs button, .groups button { min-height: 0; }
  table.data td button { min-height: 38px; padding: 6px 12px; font-size: 13.5px; }
  .preview .ok button { min-height: 32px; }
  .results button { padding-top: 11px; padding-bottom: 11px; }
  .check input, .checks input, table.data td input[type="checkbox"], table.data th input[type="checkbox"] { width: 20px; height: 20px; }
  .checks { gap: 12px 18px; }
  details.group > summary { padding-top: 12px; padding-bottom: 12px; }
}

@media (max-width: 640px) {
  .page { padding: 16px 12px 48px; gap: 14px; }
  .ph { padding-bottom: 10px; margin-bottom: 12px; }
  .ph .lede { font-size: 13px; }

  /* index bar: name and link on one line, the sections on a second line that slides sideways if it must */
  .topbar { flex-wrap: wrap; overflow: visible; padding: 0 12px; }
  .brand { border-right: 0; margin-right: 0; padding: 10px 0 2px; }
  .brand .mark { font-size: 17px; }
  .bar-foot { padding: 10px 0 2px; }
  .groups { order: 3; flex: 0 0 auto; width: calc(100% + 24px); margin: 0 -12px; padding: 0 4px; overflow-x: auto; scrollbar-width: none; }
  .groups::-webkit-scrollbar { display: none; }
  .groups button { flex: 1 0 auto; padding: 10px 7px 9px; font-size: 13.5px; }
  .subbar { padding: 0 4px; }
  .subbar .tabs button { flex: 1 0 auto; padding: 10px 8px 9px; }

  .bar-actions { width: 100%; }
  .filter, .wide-filter { width: auto; flex: 1 1 160px; }
  .bar-actions button { flex: 1 1 auto; }
  .row-actions button.big { flex: 1 1 auto; }
  .history-grid { grid-template-columns: minmax(0, 1fr); }
  .history-grid > div { border-left: 0; border-top: 1px solid var(--line); flex-direction: row; justify-content: space-between; align-items: baseline; }
  .history-grid > div:first-child { border-top: 0; }

  /* tables: one card per row, the column heading above each value */
  .tablewrap { overflow-x: visible; }
  table.data, table.data tbody { display: block; }
  table.data thead { display: none; }
  table.data tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.data tbody tr:last-child { border-bottom: 0; }
  table.data tbody tr:hover td { background: none; }
  table.data tbody td,
  .panel:not(.flush) > .tablewrap table.data td:first-child,
  .panel:not(.flush) > .tablewrap table.data td:last-child { display: block; min-width: 0; padding: 0; border: 0; overflow-wrap: anywhere; }
  table.data tbody td.num { text-align: left; white-space: normal; }
  table.data td button { font-family: var(--font-body); }
  table.data td > code { white-space: normal; }
  #moveBody td:nth-child(2) { grid-column: 1 / -1; }
  table.data tr.void td { text-decoration: none; }
  table.data tr.void td:first-child { text-decoration: line-through; }
  table.data tbody td:empty { display: none; }
  table.data tbody td[data-label]::before { content: attr(data-label); display: block; font-family: var(--font-body); font-size: 11.5px; font-weight: 400; color: var(--muted); text-decoration: none; }
  table.data tbody td:first-child { grid-column: 1 / -1; font-size: 14px; font-weight: 500; }
  table.data tbody td:first-child::before { display: none; }
  table.data tbody td:last-child:not([data-label]) { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
  table.data tbody td:last-child:not([data-label]):empty { display: none; }
  table.data td input[type="number"], table.data td input[type="text"], table.data td input.qty { width: 100%; max-width: 150px; text-align: left; }
  table.data td select { min-width: 0; }

  /* products keep their tick box down the left of each card, and the tick-all box above the list */
  #productTable thead { display: block; }
  #productTable thead tr { display: block; }
  #productTable thead th { display: none; }
  #productTable thead th:first-child { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
  #productTable thead th:first-child::after { content: "Tick all"; }
  #productTable tbody tr { grid-template-columns: 30px repeat(3, minmax(0, 1fr)); }
  #productTable tbody td:first-child { grid-column: 1; grid-row: 1 / span 4; }
  #productTable tbody td:nth-child(2), #productTable tbody td:nth-child(3), #productTable tbody td:nth-child(4) { grid-column: 2 / -1; }
  #productTable tbody td:nth-child(2)::before { display: none; }

  /* dialogs take the whole screen */
  #returnDialog, #invoiceDialog { width: 100vw; max-width: 100vw; height: 100vh; height: 100dvh; max-height: 100vh; max-height: 100dvh; margin: 0; border: 0; }
  .return-body { padding: 12px; }
  .return-body > .tablewrap { border: 1px solid var(--line); }
  .dialog-bar { z-index: 1; }
  .dialog-bar button { flex: 1 1 auto; }
}

@media print {
  dialog, .topbar, .masthead { display: none !important; }
  /* 12 mm of margin on every side, built into the report: see printReport in pos-app.js. */
  .report-print { display: block; color: #000; font-family: var(--font-body, sans-serif); font-size: 8.5pt; line-height: 1.3; padding: 12mm 12mm 0; }
  .report-print thead { display: table-header-group; }
  .report-print tfoot { display: table-footer-group; }
  .report-print table { margin-top: -12mm; }   /* the first page already has its top margin, above the heading */
  .report-print .rp-gap td { height: 12mm; padding: 0; border: 0; }
  .report-print .rp-brand { font-size: 8pt; letter-spacing: 0.2em; text-transform: uppercase; }
  .report-print h1 { font-size: 15pt; font-weight: 600; margin: 1mm 0 0.5mm; }
  .report-print .rp-meta { margin: 0 0 3mm; color: #333; }
  .report-print .rp-facts { display: flex; flex-wrap: wrap; gap: 1.5mm 7mm; margin: 0 0 4mm; padding: 2mm 0; border-top: 0.3mm solid #000; border-bottom: 0.3mm solid #000; }
  .report-print .rp-facts > div { display: flex; flex-direction: column; }
  .report-print .rp-facts .k { font-size: 7pt; color: #333; }
  .report-print .rp-facts .v { font-size: 10pt; font-weight: 600; }
  .report-print table { width: 100%; border-collapse: collapse; }
  .report-print thead { display: table-header-group; }
  .report-print th { text-align: left; font-weight: 600; border-bottom: 0.3mm solid #000; padding: 1mm 1.5mm; vertical-align: bottom; }
  .report-print td { border-bottom: 0.15mm solid #999; padding: 0.8mm 1.5mm; vertical-align: top; overflow-wrap: anywhere; }
  .report-print th.num, .report-print td.num { text-align: right; }
  .report-print tr { break-inside: avoid; page-break-inside: avoid; }
  .report-print tr.total td { font-weight: 600; border-top: 0.3mm solid #000; border-bottom: 0; }
  .report-print code { font-family: var(--font-mono, monospace); font-size: 7.5pt; white-space: nowrap; }
  .report-print .bar { display: none; }
  #printRoot .invoice { min-height: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
