/* ERPSN design system – see docs/ui-guidelines.md.
   Dense back office by default; body.touch (till, goods receipt, count list)
   and small screens get large touch controls. */

:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --text: #1c2430;
  --muted: #667180;
  --border: #dde1e7;
  --primary: #3f7d20;
  --primary-hover: #33661a;
  --primary-text: #ffffff;
  --primary-soft: #eaf4e0;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --warning: #9a5b00;
  --warning-soft: #fdf1dc;
  --info: #1d5fa8;
  --info-soft: #e5eefa;
  --success: #3f7d20;
  --success-soft: #eaf4e0;
  --sale: #c2410c;
  --pea: #6fb03a;         /* brand pea: same in light and dark */
  --pea-light: #c4e596;
  --focus: #2563eb;
  --sidebar-bg: #17202b;
  --sidebar-text: #c9d1db;
  --sidebar-active: #ffffff;
  --sidebar-active-bg: #263243;
  --radius: 6px;
  --ctl-h: 30px;          /* control height, back office */
  --ctl-pad: .25rem .55rem;
  --cell-pad: .32rem .55rem;
  --sidebar-w: 212px;
  --sidebar-w-collapsed: 56px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10151b;
    --surface: #182029;
    --surface-2: #1d2631;
    --text: #e6e9ee;
    --muted: #98a2ae;
    --border: #2b3541;
    --primary: #86bf4f;
    --primary-hover: #98cd63;
    --primary-text: #12200a;
    --primary-soft: #24351a;
    --danger: #f2766d;
    --danger-soft: #3a1f1d;
    --warning: #f0b45a;
    --warning-soft: #3a2c15;
    --info: #79aef0;
    --info-soft: #1a2a40;
    --success: #9bd068;
    --success-soft: #24351a;
    --sale: #fb923c;
    --focus: #60a5fa;
    --sidebar-bg: #0b1016;
    --sidebar-active-bg: #1c2633;
  }
}

* { box-sizing: border-box; }
html { font: 13.5px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); display: flex; align-items: flex-start; min-height: 100vh; }
a { color: var(--primary); }
h1 { font-size: 1.35rem; margin: 0; line-height: 1.25; }
h2 { font-size: .8rem; margin: 0 0 .6rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }
h3 { font-size: 1rem; margin: 0 0 .4rem; }
p { margin: 0 0 .6rem; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.pre { white-space: pre-wrap; }
.num { text-align: right !important; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sale { color: var(--sale); }
.nowrap { white-space: nowrap; }

/* ---------- app shell: sidebar + content ---------- */
.sidebar {
  align-self: stretch; flex: none; width: var(--sidebar-w); z-index: 30;
  background: var(--sidebar-bg); color: var(--sidebar-text); transition: width .15s, transform .2s;
}
.sb-inner { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: .7rem .6rem .7rem 1rem; min-height: 48px; }
.brand-pea { display: inline-block; width: .5em; height: .5em; margin-left: .2em; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--pea-light), var(--pea) 65%); }
.tagline { margin: -.15rem 0 .5rem; color: var(--primary); font-weight: 600; }
.brand { font-weight: 750; font-size: 1.1rem; color: #fff; text-decoration: none; letter-spacing: .01em; }
.sidebar nav { flex: 1; overflow-y: auto; padding: .25rem .5rem; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li.sep { border-top: 1px solid rgba(255,255,255,.09); margin: .5rem .4rem; }
.sb-link {
  display: flex; align-items: center; gap: .7rem; width: 100%; padding: .5rem .65rem; margin: 1px 0;
  border: 0; border-radius: var(--radius); background: none; color: inherit; text-decoration: none; font: inherit; cursor: pointer; text-align: left;
  justify-content: flex-start; min-height: 0; font-weight: 400;
}
.sb-link:hover, button.sb-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sb-link[aria-current="page"] { background: var(--sidebar-active-bg); color: var(--sidebar-active); font-weight: 600; box-shadow: inset 3px 0 0 var(--primary); }
.sb-foot { border-top: 1px solid rgba(255,255,255,.09); padding: .5rem; }
.sb-foot form { margin: 0; }
.sb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .3rem; border: 0; border-radius: var(--radius); background: none; color: inherit; cursor: pointer; font: inherit; }
.icon-btn:hover { background: rgba(127,127,127,.15); }
.sb-collapse { color: var(--sidebar-text); }

.shell { flex: 1; min-width: 0; min-height: 100vh; }
.appbar { display: none; align-items: center; gap: .75rem; padding: .4rem .75rem; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.appbar-title { font-weight: 650; }
.sb-backdrop { display: none; }
main { max-width: 1440px; padding: 1rem 1.25rem 2rem; }

/* collapsed rail (desktop) */
body.nav-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.nav-collapsed .sb-label, body.nav-collapsed .brand { display: none; }
body.nav-collapsed .sb-head { justify-content: center; padding: .7rem 0; }
body.nav-collapsed .sb-link { justify-content: center; padding: .55rem 0; }
body.nav-collapsed .sb-collapse .icon { transform: rotate(180deg); }

/* off-canvas: small screens and the full-screen till */
@media (max-width: 1023px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); width: var(--sidebar-w) !important; }
  .appbar { display: flex; }
  .sb-collapse { display: none; }
  body.nav-collapsed .sb-label, body.nav-collapsed .brand { display: inline; }
  body.nav-collapsed .sb-link { justify-content: flex-start; padding: .5rem .65rem; }
}
body.fullscreen .sidebar { position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); width: var(--sidebar-w); }
body.fullscreen .appbar { display: flex; }
body.fullscreen .sb-collapse { display: none; }
body.fullscreen.nav-collapsed .sb-label, body.fullscreen.nav-collapsed .brand { display: inline; }
body.fullscreen.nav-collapsed .sb-link { justify-content: flex-start; padding: .5rem .65rem; }
body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
body.nav-open .sb-backdrop { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.35); }

/* ---------- area tabs ---------- */
/* A4 voucher preview: the A4 page scaled into the card */
.voucher-preview { margin-top: .75rem; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: #fff; aspect-ratio: 210 / 160; position: relative; }
.voucher-preview iframe { position: absolute; top: 0; left: 0; width: 794px; height: 605px; border: 0; transform-origin: 0 0; }
/* receipt: issued voucher in a box with its barcode */
.r-voucher { border: 2px solid currentColor; border-radius: 4px; padding: .4rem .5rem; margin: .5rem 0; text-align: center; }
.r-voucher .r-voucher-code { font-size: 1.15em; font-weight: 700; letter-spacing: .05em; }
.r-voucher .barcode { display: block; width: 100%; max-width: 260px; height: 44px; margin: .3rem auto 0; background: #fff; }

.card-foot { padding: .6rem 1rem; margin: 0; }

/* till pages: who is logged in, highlighted (pos.md, user decision) */
.till-user { display: inline-flex; align-items: center; gap: .45rem; margin: 0 0 .75rem; padding: .2rem .8rem; border-radius: 999px; background: var(--primary-soft); color: var(--text); border: 1px solid var(--primary); font-size: .95rem; }
.till-user svg { width: 1.1em; height: 1.1em; color: var(--primary); }
.till-user strong { color: var(--primary); }
.till-user form { margin: 0 -.5rem 0 .25rem; }
.till-user .till-switch { display: inline-flex; align-items: center; gap: .35rem; min-height: 2.75rem; padding: .3rem .9rem; border-radius: 999px; }
.till-user .till-switch svg { color: currentColor; }
.tabs { display: flex; gap: .15rem; margin: -.25rem 0 1rem; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: thin; }
.tabs a { padding: .5rem .75rem; color: var(--muted); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom-color: var(--primary); }

/* ---------- page header ---------- */
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: .75rem 1rem; margin-bottom: .9rem; flex-wrap: wrap; }
.pagehead-main { min-width: 0; }
.pagehead h1 { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.pagehead h1 .muted { font-weight: 500; }
.back { display: inline-block; font-size: .88rem; color: var(--muted); text-decoration: none; margin-bottom: .2rem; }
.back::before { content: "‹ "; }
.back:hover { color: var(--primary); }
.subtitle { color: var(--muted); margin-top: .25rem; font-size: .92rem; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; margin-bottom: .9rem; }
.card > :last-child { margin-bottom: 0; }
.card.flush { padding: 0; overflow-x: auto; }
.card.flush > .card-head { padding: .7rem 1rem .1rem; }
.card.flush > .card-intro { margin: 0; padding: 0 1rem .5rem; color: var(--muted); } /* explanation under the head of a table card */
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.card-head h2 { margin-bottom: .6rem; }
.card.warning { border-color: var(--warning); background: var(--warning-soft); }
.card.narrow { max-width: 460px; }
.grid { display: grid; gap: .9rem; align-items: start; }
.grid > .card { margin-bottom: 0; }
.grid > .span-all { grid-column: 1 / -1; } /* a card with long content takes the full row */
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.section { margin-bottom: .9rem; }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: .9rem; align-items: start; }
.split > .card, .split > div > .card:last-child { margin-bottom: 0; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.panel { position: sticky; top: 1rem; }

/* ---------- messages ---------- */
.flash, .alert { display: flex; gap: .6rem; align-items: flex-start; padding: .55rem .8rem; border-radius: var(--radius); margin-bottom: .9rem; border: 1px solid transparent; }
.alert { display: block; } /* running text with <code>/<strong>/<a>; flex would split it into columns */
.flash { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.flash.error, .alert { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.alert.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.alert.warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.flash.fade { opacity: 0; transition: opacity .4s; }
.flash .close { margin-left: auto; }
/* the brand pea marks successes; errors, warnings and hints stay plain */
.flash:not(.error)::before { content: ""; flex: none; width: .8em; height: .8em; margin-top: .22em; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--pea-light), var(--pea) 65%); animation: pea-pop .35s ease-out; }
@keyframes pea-pop { from { transform: scale(0); } 70% { transform: scale(1.25); } to { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .flash:not(.error)::before { animation: none; } }
.error { display: block; color: var(--danger); font-size: .86rem; margin-top: .15rem; }
.note { display: block; color: var(--muted); font-size: .86rem; margin-top: .15rem; font-weight: 400; } /* hint under a field: what is missing and where to fix it */

/* ---------- badges ---------- */
.badge { display: inline-block; font-size: .76rem; font-weight: 600; line-height: 1.5; padding: 0 .45rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; vertical-align: middle; text-decoration: none; }
.badge.info { background: var(--info-soft); border-color: transparent; color: var(--info); }
.badge.success { background: var(--success-soft); border-color: transparent; color: var(--success); }
.badge.warning { background: var(--warning-soft); border-color: transparent; color: var(--warning); }
.badge.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }

/* ---------- controls ---------- */
input, select, textarea, button, .button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; min-height: var(--ctl-h); padding: var(--ctl-pad); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
textarea { min-height: 4.5rem; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--primary); }
input:disabled, select:disabled, input[readonly] { background: var(--surface-2); color: var(--muted); }
button:disabled, .button[aria-disabled="true"] { opacity: .55; cursor: not-allowed; box-shadow: none; }
label:has(> .error) input, label:has(> .error) select, label:has(> .error) textarea { border-color: var(--danger); }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: var(--ctl-h);
  padding: var(--ctl-pad); padding-inline: .8rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; text-decoration: none; white-space: nowrap; font-weight: 500;
}
button:hover, .button:hover { background: var(--surface-2); }
button.primary, .button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
button.primary:hover, .button.primary:hover { background: var(--primary-hover); }
button.danger, .button.danger { color: var(--danger); }
button.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
button.link, button.link:hover { border: 0; background: none; padding: 0; min-height: 0; color: var(--primary); text-decoration: underline; font-weight: inherit; }
button.link.danger { color: var(--danger); }
button.icon-only { padding: .25rem; min-width: var(--ctl-h); }
button.big { min-height: 48px; font-size: 1.1rem; font-weight: 600; }

/* ---------- forms ---------- */
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: .6rem .9rem; }
.form .card { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: .6rem .9rem; margin: 0; }
.form .card > h2 { grid-column: 1 / -1; margin: 0; }
.form .group { grid-column: 1 / -1; display: grid; grid-template-columns: inherit; gap: inherit; }
.form .group[hidden], .form [data-show-for][hidden] { display: none; }
.form label { display: block; font-size: .9rem; font-weight: 500; }
.form label > input, .form label > select, .form label > textarea { margin-top: .2rem; font-weight: 400; }
.form .wide, .form .actions, .form .hint { grid-column: 1 / -1; }
.form .hint { margin: 0; }
label.check, label.inline { display: flex !important; align-items: center; gap: .45rem; font-weight: 400 !important; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .4rem .75rem .6rem; margin: 0; }
legend { font-size: .9rem; font-weight: 500; padding: 0 .3rem; }
fieldset.segmented { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }
.form-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .9rem; }
.form .form-actions { grid-column: 1 / -1; margin-top: .2rem; }
.req-note { margin-left: auto; color: var(--muted); font-size: .86rem; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: 0; }
.inline-form > input:not([type=checkbox]):not([type=hidden]), .inline-form > select { width: auto; flex: 1 1 10rem; }
.print-form > select { flex: 0 0 auto; width: 4.5rem; } /* copies 1–3 next to the print button */
/* split button: primary action + ▾ that opens the choice (print dialog) */
.split-button { gap: 0; }
.split-button > select { margin-right: .5rem; }
.split-button > .primary + .split-toggle { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 1px solid rgba(255,255,255,.35); }
.split-button > .primary:has(+ .split-toggle) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split-button > .primary + .split-toggle { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.split-button > .primary + .split-toggle:hover { background: var(--primary-hover); }
/* printer choice in the print dialog: one big button per printer */
.printer-choice { list-style: none; margin: .75rem 0 0; padding: 0; display: grid; gap: .5rem; }
.printer-option { width: 100%; white-space: normal; overflow-wrap: anywhere; height: auto; display: flex; flex-direction: column; align-items: flex-start; gap: .15rem; text-align: left; min-height: 3rem; }
.printer-option[disabled] { opacity: .75; cursor: not-allowed; }
.inline-form > input.qty:not([type=hidden]) { flex: 0 0 6rem; text-align: right; }
.inline-form > label:not(.check):not(.inline) { display: flex; align-items: center; gap: .4rem; }
.inline-form > label > input { width: auto; }

/* ---------- toolbars & lists ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .6rem; }
.toolbar > input[type=search], .toolbar > input.grow { flex: 2 1 18rem; width: auto; }
.toolbar > select { flex: 1 1 11rem; width: auto; }
.toolbar > input[type=date] { width: auto; }
.result-count { color: var(--muted); font-size: .88rem; margin: 0 0 .4rem; }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: var(--cell-pad); border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
table.list thead th { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 650; background: var(--surface-2); white-space: nowrap; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list tfoot td { border-top: 1px solid var(--border); border-bottom: 0; background: var(--surface-2); font-weight: 600; }
table.list tr.inactive td { color: var(--muted); }
table.list tr[data-href] { cursor: pointer; }
table.list tbody tr:hover td { background: color-mix(in srgb, var(--primary) 5%, transparent); }
table.list tr.selected td { background: var(--primary-soft); }
table.list td.empty { color: var(--muted); text-align: center; padding: 1.5rem .6rem; }
table.list td.actions-cell { width: 1%; white-space: nowrap; text-align: right; }
table.list input, table.list select { min-height: 28px; }
.card > table.list:first-child thead th:first-child { border-top-left-radius: var(--radius); }
.row-actions { display: flex; gap: .75rem; justify-content: flex-end; white-space: nowrap; }
.row-actions form { margin: 0; }
.pager { display: flex; gap: .5rem; justify-content: center; align-items: center; margin-top: .6rem; }
.empty-state { text-align: center; padding: 2rem 1rem; color: var(--muted); }
/* a small pea touch in empty lists; .no-pea on states that report a problem */
.empty-state:not(.no-pea)::before { content: ""; display: block; width: 72px; height: 28px; margin: 0 auto .6rem; background: url(peas.svg) center / contain no-repeat; }
table.list td.empty::before, p.empty::before { content: ""; display: inline-block; width: .6em; height: .6em; margin-right: .45em; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--pea-light), var(--pea) 65%); }
.empty-state .actions { justify-content: center; margin-top: .6rem; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.flags { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; }
.flags li { color: var(--muted); }
.flags li::before { content: "○ "; }
.flags li.on { color: var(--text); }
.flags li.on::before { content: "● "; color: var(--primary); }
.meta { color: var(--muted); font-size: .86rem; margin: .2rem 0 .9rem; }

/* inline line editing (cart, goods receipt): one row, saved on change */
.line-edit { display: flex; gap: .35rem; margin: 0; align-items: center; }
.line-edit input, .line-edit select { width: auto; flex: 1 1 5rem; min-width: 0; }
.line-edit input { text-align: right; }

/* ---------- change history ---------- */
.history .hist-entry { padding: .45rem 0; border-bottom: 1px solid var(--border); }
.history .hist-entry:last-child { border-bottom: 0; }
table.changes { margin-top: .25rem; border-collapse: collapse; font-size: .9rem; }
table.changes td { padding: .1rem .75rem .1rem 0; vertical-align: top; }

/* ---------- dialogs ---------- */
dialog { border: 1px solid var(--border); border-radius: calc(var(--radius) + 2px); padding: 0; background: var(--surface); color: var(--text); width: min(460px, calc(100vw - 2rem)); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10,15,20,.45); }
.dialog-body { padding: 1rem 1.1rem; }
.dialog-body > label:not(.check) { display: grid; gap: .25rem; margin-top: .6rem; }
.dialog-body > label.check { margin-top: .6rem; }
.dialog-body h2 { color: var(--text); text-transform: none; letter-spacing: 0; font-size: 1.1rem; margin-bottom: .5rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; padding: .75rem 1.1rem; background: var(--surface-2); border-top: 1px solid var(--border); }
dialog .form { margin-top: .4rem; }
/* full-screen overlay (till: customer selection, new customer) */
dialog.dialog-full { position: fixed; inset: 0 auto auto 0; width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; display: none; flex-direction: column; }
dialog.dialog-full[open] { display: flex; }
body:has(dialog.dialog-full[open]) { overflow: hidden; } /* the page behind the overlay doesn't scroll */
.dialog-full-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.dialog-full-head h2 { margin: 0; font-size: 1.25rem; color: var(--text); text-transform: none; letter-spacing: 0; }
.dialog-full-search { display: flex; gap: .6rem; padding: 1rem; border-bottom: 1px solid var(--border); }
.dialog-full-search input { flex: 1; min-height: 52px; font-size: 1.2rem; }
.dialog-full-search button { min-height: 52px; white-space: nowrap; }
.dialog-full-body { flex: 1; overflow-y: auto; padding: 1rem; }
.dialog-full .sticky-actions { position: sticky; bottom: -1rem; background: var(--surface); padding: .75rem 0; border-top: 1px solid var(--border); z-index: 1; }
.empty-hint { padding: 2rem 1rem; text-align: center; display: grid; gap: 1rem; justify-items: center; }
.customer-hits { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.customer-hit { width: 100%; display: grid; grid-template-columns: 1fr auto; grid-template-areas: "main action" "addr action" "contact action"; gap: .15rem 1rem; text-align: left; padding: .75rem 1rem; min-height: 64px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-weight: 400; }
.customer-hit:hover, .customer-hit:focus-visible { border-color: var(--primary); background: var(--primary-soft); }
.customer-hit .hit-main { grid-area: main; font-size: 1.05rem; }
.customer-hit .hit-addr { grid-area: addr; }
.customer-hit .hit-contact { grid-area: contact; font-size: .9rem; }
.customer-hit .hit-action { grid-area: action; align-self: center; font-weight: 600; color: var(--primary); }
.till-customer-chosen { display: grid; gap: .1rem; margin-bottom: .5rem; }
.wide-button { width: 100%; justify-content: center; }
@media (max-width: 640px) { .dialog-full-search { flex-direction: column; } }

/* ---------- dashboard ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: .9rem; align-items: start; }
.tiles > .card { margin: 0; }
.stat-row { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat span { color: var(--muted); font-size: .86rem; }
.quick-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.search-results { list-style: none; margin: .5rem 0 0; padding: 0; }
.search-results li { padding: .3rem 0; border-bottom: 1px solid var(--border); display: flex; gap: .5rem; align-items: baseline; }
.search-results li:last-child { border-bottom: 0; }
.search-results .kind { min-width: 5.5rem; }
.task-list { list-style: none; margin: 0; padding: 0; }
.task-list li { display: flex; justify-content: space-between; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--border); }
.task-list li:last-child { border-bottom: 0; }

/* ---------- till & scanning ---------- */
.scan { display: flex; gap: .5rem; margin-bottom: .5rem; }
.scan input { flex: 1; }
.results { list-style: none; padding: 0; margin: 0 0 .75rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.results li { border-bottom: 1px solid var(--border); }
.results li:last-child { border-bottom: 0; }
.results form { margin: 0; }
.results button.result { display: flex; width: 100%; justify-content: space-between; gap: 1rem; border: 0; border-radius: 0; background: none; text-align: left; font-weight: 400; }
.results button.result:hover { background: var(--primary-soft); }
.till-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr); gap: .9rem; align-items: start; }
@media (max-width: 900px) { .till-grid { grid-template-columns: 1fr; } }
/* receipt offer without automatic printing: big touch targets, the till stays usable */
.receipt-offer { border-left: 4px solid var(--accent); margin-bottom: .9rem; }
.receipt-offer-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .3rem 1rem; }
.receipt-offer-head h2 { margin: 0; font-size: 1.15rem; text-transform: none; letter-spacing: normal; color: var(--text); }
.receipt-offer-change { margin: 0; font-size: 1.15rem; }
.receipt-offer-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: .8rem 0 .4rem; }
.receipt-offer-actions form { margin: 0; }
@media (max-width: 600px) { .receipt-offer-actions > *, .receipt-offer-actions button, .receipt-offer-actions .button { flex: 1 1 100%; width: 100%; } }
.till-extras { display: grid; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); gap: .5rem; }
.r-sum { width: 100%; border-collapse: collapse; margin-bottom: .75rem; }
.r-sum td { padding: .15rem 0; }
.r-total td { font-size: 1.6rem; font-weight: 750; }
.pay-quick { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.pay-more { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .5rem; }
.pay-more:only-child, .pay-more > :only-child { grid-column: 1 / -1; }
.pay-line td { color: var(--muted); }
.nowrap { white-space: nowrap; }
.pay-line td.num { color: var(--text); white-space: nowrap; }
.pay-line .actions-cell { width: 1%; padding-left: .4rem; }
.r-sum td:last-child:empty { width: 0; padding: 0; }
.r-open td { font-size: 1.15rem; font-weight: 700; border-top: 1px solid var(--border); padding-top: .35rem; }
.r-open.payout td { color: var(--warning); border-top: 0; }
.wide-button { width: 100%; min-height: 56px; font-size: 1.15rem; font-weight: 650; }
.pay-open { font-size: 1.1rem; margin: 0 0 .75rem; }
.cash-quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: .5rem; margin: .6rem 0 .9rem; }
.cash-quick button { min-height: 48px; font-weight: 600; }
.change-info { min-height: 3.6rem; margin-bottom: .5rem; }
.change-amount { font-size: 1.35rem; margin: 0 0 .35rem; }
.change-amount strong { font-size: 1.6rem; }
.change-missing { font-size: 1.2rem; margin: 0; color: var(--danger); }
.pieces { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0; }
.piece { border: 1px solid var(--border); border-radius: 999px; padding: .15rem .6rem; background: var(--surface-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cash-back { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; border-left: 4px solid var(--success); }
.cash-back .change-amount { margin: 0; }
.pay-quick button { min-height: 56px; font-size: 1.15rem; font-weight: 650; }
.stock-short { color: var(--danger); font-weight: 600; }
.register-choice { margin: .5rem 0; }
.register-choice button { width: 100%; justify-content: flex-start; min-height: 52px; font-size: 1.05rem; }
.receipt-card { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9rem; }
.receipt-card table { width: 100%; border-collapse: collapse; }
.receipt-card .r-head, .receipt-card .r-kind, .receipt-card .r-foot, .receipt-card .r-qr { text-align: center; }
.receipt-card .r-tse { word-break: break-all; margin-top: .5rem; }
.receipt-card .r-voucher { border: 2px solid var(--text); }
.receipt-card .r-slip { border-top: 1px dashed var(--text); margin-top: .75rem; padding-top: .4rem; }
.receipt-card .r-slip-cut { text-align: center; margin: 0 0 .3rem; font-size: .85em; color: var(--muted); }
.receipt-card .r-slip pre { font: inherit; white-space: pre-wrap; margin: 0; }
.receipt-card .r-copy { text-align: center; border: 2px solid var(--text); padding: .3rem; margin-bottom: .5rem; }
.denominations { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .4rem .9rem; }
.denominations label { display: grid; grid-template-columns: 5rem 1fr; align-items: center; gap: .4rem; font-weight: 400; }
.denominations label span { text-align: right; font-variant-numeric: tabular-nums; }
.denominations input { text-align: right; }

/* ---------- touch mode & small screens ---------- */
body.touch { --ctl-h: 44px; --ctl-pad: .5rem .7rem; --cell-pad: .55rem .6rem; }
body.touch { font-size: 15px; }
body.touch table.list input, body.touch table.list select { min-height: 40px; }
body.touch button.link { min-height: 0; }
body.touch .sb-link { padding: .7rem .75rem; }
@media (max-width: 640px) {
  :root { --ctl-h: 40px; --ctl-pad: .45rem .6rem; }
  html { font-size: 14px; }
  input, select, textarea { font-size: 16px; } /* no zoom on iOS */
  main { padding: .75rem .75rem 2rem; }
  .pagehead { align-items: flex-start; }
  .pagehead .actions { width: 100%; }
  .card { padding: .75rem; }
  .till-extras { grid-template-columns: 1fr; }
  dl.facts { grid-template-columns: 1fr; gap: 0; }
  dl.facts dd { margin-bottom: .4rem; }
}
@media print {
  .sidebar, .appbar, .tabs, .pagehead .actions, .toolbar { display: none !important; }
  .shell { margin: 0 !important; }
}

/* ---------- login & misc ---------- */
.login { max-width: 380px; margin: 14vh auto 0; padding: 1.5rem; }
.login h1 { font-size: 1.6rem; margin-bottom: .25rem; }
.login .big { width: 100%; }
.login.has-tiles { max-width: 560px; margin-top: 8vh; }
/* quick-switch tiles: the last users of this browser (touch-sized) */
.tiles-title { font-size: 1rem; margin: .8rem 0 .4rem; }
.user-tiles { list-style: none; margin: 0 0 .8rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .5rem; }
.user-tile { position: relative; }
.user-tile > a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; min-height: 84px;
  padding: .6rem .9rem .5rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2);
  color: var(--text); text-decoration: none; font-weight: 600; text-align: center; overflow-wrap: break-word; hyphens: auto; min-width: 0; }
.user-tile > a .icon { width: 26px; height: 26px; color: var(--primary); }
.user-tile > a:hover { border-color: var(--primary); }
.user-tile.chosen > a { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 1px var(--primary); }
.user-tile form { position: absolute; top: 2px; right: 2px; margin: 0; }
.tile-forget { min-height: 0; height: 26px; width: 26px; padding: 0; font-size: 1.1rem; line-height: 1; color: var(--muted); border: 0; background: transparent; }
.tile-forget:hover { color: var(--danger); }
.chosen-user { display: flex; align-items: center; gap: .4rem; margin: 0; flex-wrap: wrap; }
.chosen-user .icon { color: var(--primary); }
.pin-input { font-size: 1.4rem; letter-spacing: .4em; text-align: center; }
.line-author { font-style: italic; }
details.approval { margin: .2rem 0; }
details summary { cursor: pointer; color: var(--primary); font-weight: 500; }
details[open] summary { margin-bottom: .4rem; }
a.stat { text-decoration: none; color: inherit; }
a.stat:hover strong { color: var(--primary); }
.scanbar { margin-bottom: .6rem; }
.scanbar > input[type=search] { margin-bottom: .4rem; }
.cart .line-edit input { max-width: 7rem; }
.card-head .actions a { display: inline-flex; align-items: center; gap: .2rem; }
.card-head .actions .icon { width: 14px; height: 14px; }
body.nav-collapsed .sb-foot form, body.nav-collapsed .sb-foot { text-align: center; }

/* phones: secondary columns hidden; editable tables stacked */
@media (max-width: 640px) {
  .hide-sm { display: none; }
  table.list.stack thead { display: none; }
  table.list.stack, table.list.stack tbody, table.list.stack tfoot, table.list.stack tr { display: block; width: 100%; }
  table.list.stack tr { border-bottom: 1px solid var(--border); padding: .35rem 0; position: relative; }
  table.list.stack td { display: block; border: 0; padding: .2rem .75rem; text-align: left !important; }
  table.list.stack td[data-label]:empty { display: none; }
  table.list.stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .86rem; }
  table.list.stack td.actions-cell { position: absolute; top: .35rem; right: .25rem; width: auto; }
  table.list.stack.static-actions td.actions-cell { position: static; } /* several actions: below the row */
  table.list.stack .line-edit input, table.list.stack .line-edit select { max-width: none; }
  table.list.stack tfoot td { display: flex; justify-content: space-between; }
}

/* --- sales document editor (docs/ui-guidelines.md: document with lines) ---
   single page: main column + sticky summary column on the right; stacked
   below 1100 px */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
.doc-main { min-width: 0; display: grid; gap: 1rem; }
.doc-main > .section, .doc-main > .grid { margin-top: 0; }
.doc-summary { position: sticky; top: 1rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; display: grid; gap: .75rem; }
.doc-summary h2 { margin: 0; }
.doc-summary .sums { width: 100%; border-collapse: collapse; }
.doc-summary .sums td { padding: .2rem 0; }
.doc-summary .sums tr.grand td { border-top: 2px solid var(--text); font-weight: 700; font-size: 1.15rem; padding-top: .45rem; }
.doc-summary .compact-form { grid-template-columns: 1fr; }
.doc-summary .wide-button { width: 100%; }
.doc-buyer { margin-bottom: .75rem; line-height: 1.45; }
.row-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }
/* blocking problems: what/why, "So beheben" and the button to the place of the fix */
.alert.fixes { display: block; }
.fix-list { margin: .5rem 0 0; padding-left: 1.3rem; }
.fix-list li { margin: 0 0 .7rem; }
.fix-list li:last-child { margin-bottom: 0; }
.fix-list p { margin: 0 0 .3rem; }
.fix-how { color: var(--muted); }
.fix-how strong { color: var(--text); }
.logo-preview { max-height: 80px; max-width: 260px; background: #fff; padding: .4rem; border: 1px solid var(--border); border-radius: var(--radius); }

/* one form per line in one cell: text on top, numbers in a row */
.line-grid { display: grid; grid-template-columns: 5.5rem 7.5rem 7rem 6.5rem max-content max-content 1fr; gap: .35rem .4rem; align-items: center; margin: 0; }
.line-grid .line-text { grid-column: 1 / -1; }
.line-grid.text { grid-template-columns: 1fr; }
.line-grid input.line-qty, .line-grid input.line-price, .line-grid input.line-disc { text-align: right; }
.line-grid .line-flag { display: flex; align-items: center; gap: .3rem; white-space: nowrap; font-size: .85rem; }
.line-grid .line-flag input:not([type=checkbox]) { width: 6.5rem; }
.line-grid select.line-vat { width: auto; min-width: 5.5rem; }
.send-log { margin-top: 1.25rem; }
table.doc-lines td:first-child { width: 100%; }
@media (max-width: 1100px) {
  .doc-layout { grid-template-columns: 1fr; }
  .doc-summary { position: static; }
}
@media (max-width: 640px) {
  .line-grid { grid-template-columns: 1fr 1fr; }
  .line-grid .line-flag { grid-column: 1 / -1; }
}

table.list input.qty { max-width: 7rem; text-align: right; }

/* --- hardware bridge (PCs & devices, login PC check) --- */
kbd { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82em; background: var(--surface-2); border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 4px; padding: 0 .3em; white-space: nowrap; }
code, .codeblock { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .86em; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 .25em; overflow-wrap: anywhere; }
.codeblock { display: block; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .55rem .7rem; margin: .4rem 0; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }
code.secret { user-select: all; font-weight: 600; }
.bigcode { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.7rem; font-weight: 700; letter-spacing: .08em;
  margin: .2rem 0 .6rem; user-select: all; overflow-wrap: anywhere; }
.refresh-code { border-color: var(--primary); }
ol.steps { margin: 0; padding-left: 1.2rem; }
ol.steps li { margin-bottom: .45rem; }
.alert.success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.pc-check p { margin: 0 0 .3rem; }
.pc-check p:last-child { margin-bottom: 0; }
.pc-check button.link { padding: 0; }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: .6rem; }
fieldset.plain[disabled] { opacity: .55; }
.inline-actions { display: flex; flex-wrap: wrap; gap: .3rem; }
button.small { min-height: 0; padding: .1rem .45rem; font-size: .82rem; }
table.log td { vertical-align: top; }

/* card dialog of the till: waiting for the customer at the terminal */
.card-op-wait { font-size: 1.15rem; font-weight: 600; margin: .4rem 0; }
.spinner { display: inline-block; width: .8em; height: .8em; margin: 0 .55em; border-radius: 50%; vertical-align: -.05em;
  background: radial-gradient(circle at 35% 30%, var(--pea-light), var(--pea) 65%); animation: pea-roll .9s ease-in-out infinite alternate; }
@keyframes pea-roll { from { transform: translateX(-.45em) rotate(-120deg); } to { transform: translateX(.45em) rotate(120deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.card-op .dialog-actions { flex-wrap: wrap; } /* several alternatives (cash, manual, retry) wrap on narrow dialogs */
.card-op .dialog-actions form { display: inline; }

/* related documents in the summary column (sales 0.8) */
ul.related { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
ul.related li { display: grid; gap: .1rem; }

/* register selector on Kassentag, Tagesabschlüsse and Bon-Journal from another PC */
.register-select { display: flex; align-items: center; gap: .6rem; margin: 0 0 .9rem; }
.register-select label { font-weight: 600; }
.register-select select { width: auto; min-width: min(280px, 100%); max-width: 100%; flex: 0 1 auto; }
.inline-form + .hint, .inline-form + .alert + .hint { margin-top: .5rem; }

/* payments (0.9) */
.alloc-actions { justify-content: flex-start; align-items: center; white-space: normal; }
.alloc-actions .muted { flex: 1 1 16rem; }
.alloc-input { width: 9rem; max-width: 100%; min-width: 0; text-align: right; }
.credit-hit { display: grid; gap: .5rem; padding: .75rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.credit-payout { display: grid; grid-template-columns: minmax(7rem, 12rem) 1fr; gap: .5rem .75rem; align-items: end; }
.credit-payout .actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-start; }
.customer-hits { grid-template-columns: minmax(0, 1fr); }
.customer-hit { grid-template-columns: minmax(0, 1fr) auto; white-space: normal; }
.credit-hit, .credit-payout label, .credit-payout input { min-width: 0; max-width: 100%; }
@media (max-width: 640px) { .credit-payout { grid-template-columns: minmax(0, 1fr); } }

/* incoming invoice: the original next to the form */
.invoice-frame iframe { display: block; width: 100%; height: 72vh; border: 0; background: #fff; }
.tax-rate { align-self: center; min-width: 4rem; font-weight: 600; }

/* demo mode (ADR-0040) */
.demo-banner { display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: center; padding: .3rem 1rem; background: var(--warning-soft); color: var(--text); border-bottom: 2px solid var(--warning); font-size: .875rem; }
.demo-banner strong { color: var(--warning); letter-spacing: .08em; }
.demo-banner a { margin-left: auto; white-space: nowrap; }
.demo-tiles { list-style: none; margin: 0 0 .8rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: .5rem; }
.demo-tile { display: flex; flex-direction: column; align-items: center; gap: .25rem; width: 100%; min-height: 96px; padding: .6rem; white-space: normal; }
.demo-tile .icon { width: 26px; height: 26px; color: var(--primary); }
.demo-tile:hover { border-color: var(--primary); }
.demo-figures { margin: 0 0 .8rem; padding-left: 1.1rem; color: var(--muted); }
.demo-progress { width: 100%; height: 1rem; margin: .5rem 0; }
.demo-mail { white-space: pre-wrap; overflow-wrap: anywhere; margin: .5rem 0 0; font: inherit; }
.demo-mark { text-align: center; font-weight: 700; border: 1px dashed currentColor; padding: 1mm; margin: 0 0 2mm; }
.demo-end { margin-top: .9rem; }
