/* Flint design system
   App shell: fixed sidebar (grouped nav) + top bar with search; content in a centred column.
   Type: Geist for UI, Geist Mono for codes, numbers and references. */
:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --sunken: #f2f1ee;
  --ink: #17181c;
  --ink-2: #3d3f46;
  --muted: #6e7079;
  --faint: #a0a2a9;
  --line: #e7e6e2;
  --line-strong: #d6d4cf;
  --accent: #d4500f;
  --accent-hover: #b8430b;
  --accent-soft: #fdf0e8;
  --accent-ink: #ffffff;
  --ok: #12804a;  --ok-soft: #e4f5ec;
  --warn: #a35b00; --warn-soft: #fdf1df;
  --err: #c0291f;  --err-soft: #fdeceb;
  --info: #2f5bd3; --info-soft: #ebf0fd;
  --note: #fffaeb; --note-ink: #6b4d00; --note-line: #f3dea2;
  --shadow-sm: 0 1px 2px rgba(15, 23, 41, .05);
  --shadow: 0 1px 2px rgba(15, 23, 41, .04), 0 4px 16px rgba(15, 23, 41, .06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 41, .16);
  --radius: 10px;
  --radius-sm: 7px;
  --sidebar: 236px;
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101113; --surface: #17181b; --surface-2: #1b1c20; --sunken: #131417;
    --ink: #ececea; --ink-2: #c8c7c3; --muted: #918f8a; --faint: #64625e;
    --line: #26272b; --line-strong: #33343a;
    --accent: #ff8a4c; --accent-hover: #ffa16e; --accent-soft: #33200f; --accent-ink: #1a0d04;
    --ok: #4cc98a; --ok-soft: #10301f; --warn: #f0b45a; --warn-soft: #33250e; --err: #f2847b; --err-soft: #3a1714;
    --info: #8aa3ff; --info-soft: #1b2547; --note: #2b2410; --note-ink: #f1dea4; --note-line: #4a3d17;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25); --shadow-lg: 0 16px 48px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
a { color: var(--accent); text-decoration: none; } a:hover { color: var(--accent-hover); }
h1, h2, h3 { text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 600; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 13px; font-weight: 600; margin: 16px 0 8px; color: var(--ink-2); }
small { font-weight: 400; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .dim { opacity: .5; }
.mono, code, .code { font-family: var(--mono); font-size: .92em; letter-spacing: -.01em; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100%; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); padding: 14px 10px 20px; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 16px; color: var(--ink); font-weight: 650; font-size: 15px; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: radial-gradient(circle at 30% 25%, #44464d, #1c1d21 70%); display: grid; place-items: center; color: #ff8a3d; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 1px 2px rgba(0,0,0,.2); }
.brand .logo svg { filter: drop-shadow(0 0 4px rgba(255,138,61,.55)); }
.brand small { display: block; color: var(--muted); font-weight: 450; font-size: 12px; margin-top: -2px; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); font-weight: 600; padding: 14px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--sunken); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav a .badge { margin-left: auto; }
.nav svg, .ico { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.avatar { width: 28px; height: 28px; border-radius: 99px; background: var(--sunken); display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--ink-2); flex: none; }
.side .me div { min-width: 0; line-height: 1.25; } .side .me b { display: block; font-weight: 550; } .side .me a { font-size: 12px; color: var(--muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 28px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.search { flex: 1; max-width: 520px; position: relative; }
.search input { width: 100%; padding: 8px 12px 8px 34px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-sm); }
.search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }
kbd { font: 500 11px var(--mono); color: var(--muted); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; background: var(--surface); }
main.content { width: 100%; max-width: 1280px; margin: 0 auto; padding: 24px 28px 64px; }

/* page header: first .row.between in a page reads as the header */
main.content > .row.between:first-child, .page-head { margin-bottom: 20px; align-items: flex-end; }
main.content > .row.between:first-child p.muted { margin: 4px 0 0; }
main.content > h1:first-child { margin-bottom: 20px; }

/* ------------------------------------------------------------ layout bits */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid2 > *, .grid3 > * { min-width: 0; margin-bottom: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: 0 0 16px; box-shadow: var(--shadow-sm); min-width: 0; }
.card > h2:first-child { display: flex; align-items: center; gap: 8px; }
.card .card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: -4px 0 12px; }
.card .card-head h2 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; } .card.flush > h2:first-child, .card.flush > .card-head { padding: 16px 20px 0; margin-bottom: 12px; }
section.card > table, .card > .tbl { margin: 0 -20px -18px; width: calc(100% + 40px); }
.card.flush > .tbl, .card.flush > form > .tbl { margin: 0; width: auto; }
.card > form > table { margin: 0 -20px; width: calc(100% + 40px); }

/* KPI tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 16px; color: var(--ink); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
a.stat:hover { border-color: var(--line-strong); box-shadow: var(--shadow); color: var(--ink); }
.stat span { display: block; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat b { display: block; font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat em { display: block; font-style: normal; font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.warn b { color: var(--warn); } .stat.bad b { color: var(--err); } .stat.good b { color: var(--ok); }
.stat b { order: 2; } .stat { display: flex; flex-direction: column; } .stat span { order: 1; } .stat em { order: 3; }

/* ------------------------------------------------------------ tables */
.tbl { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
thead th, table > tr:first-child > th { background: var(--surface-2); font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
tbody tr { transition: background .1s; } tbody tr:hover { background: var(--surface-2); }
tr:last-child > td { border-bottom: 0; }
tfoot td { background: var(--surface-2); font-variant-numeric: tabular-nums; }
main.content > table, main.content > form > table, main.content > .tbl { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); margin-bottom: 16px; }
main.content > table thead th { top: 56px; }
table.compact td, table.compact th { padding: 7px 12px; }
td a { font-weight: 500; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------ forms & buttons */
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 7px 10px; min-height: 34px; transition: border-color .12s, box-shadow .12s; }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input[type=checkbox] { min-height: 0; width: 16px; height: 16px; accent-color: var(--accent); }
textarea { min-height: 70px; }
button, .btn { font: inherit; font-weight: 550; display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; padding: 7px 13px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s, transform .05s; white-space: nowrap; }
button:hover, .btn:hover { background: var(--sunken); color: var(--ink); }
button:active, .btn:active { transform: translateY(1px); }
.primary, button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px rgba(36,72,216,.3), inset 0 1px 0 rgba(255,255,255,.12); }
.primary:hover, .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.danger, button.danger { background: var(--err); border-color: var(--err); color: #fff; }
.danger:hover { background: color-mix(in srgb, var(--err) 85%, #000); color: #fff; }
.ghost { background: transparent; border-color: transparent; box-shadow: none; }
button.link { border: 0; background: none; box-shadow: none; padding: 0; min-height: 0; color: var(--accent); font-weight: 500; }
button.link:hover { background: none; text-decoration: underline; }
button[disabled] { opacity: .55; cursor: not-allowed; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0 0 16px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.filters input:not([type=checkbox]) { flex: 1 1 220px; }
.page-head .filters, .row .filters { margin: 0; padding: 0; background: none; border: 0; box-shadow: none; }
.inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin: 0 0 12px; }
.inline label { display: flex; flex-direction: column; font-size: 12.5px; font-weight: 500; color: var(--muted); gap: 5px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px 16px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); min-width: 0; }
.form-grid .wide { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding-top: 8px; border-top: 1px solid var(--line); margin-top: 4px; }
label.check { flex-direction: row !important; align-items: center; gap: 8px; font-weight: 500; color: var(--ink-2); }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }

/* ------------------------------------------------------------ feedback */
.flash { display: flex; gap: 10px; align-items: center; padding: 11px 14px; border-radius: var(--radius); margin-bottom: 16px; background: var(--ok-soft); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 25%, transparent); font-weight: 500; }
.flash.err { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 25%, transparent); }
.flash.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.note { background: var(--note); color: var(--note-ink); border: 1px solid var(--note-line); padding: 9px 12px; border-radius: var(--radius-sm); margin: 8px 0; }

.tag, .badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 550; line-height: 1; padding: 4px 8px; border-radius: 99px; background: var(--sunken); color: var(--muted); white-space: nowrap; vertical-align: 1px; }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; opacity: .8; }
.tag.open, .tag.planned, .tag.sent, .tag.draft { background: var(--info-soft); color: var(--info); }
.tag.on_handheld, .tag.out, .tag.part, .tag.due, .tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.delivered, .tag.closed, .tag.received, .tag.paid, .tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.cancelled, .tag.err, .tag.overdue { background: var(--err-soft); color: var(--err); }
.badge { background: var(--accent-soft); color: var(--accent); padding: 3px 7px; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; margin: 2px 4px 2px 0; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); font-weight: 500; font-size: 13px; box-shadow: var(--shadow-sm); }
a.chip:hover, button.chip:hover { border-color: var(--accent); color: var(--accent); }

dl { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; margin: 0; }
dt { color: var(--muted); font-size: 13px; } dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.results { position: relative; }
.results ul { position: absolute; z-index: 30; left: 0; right: 0; margin: 6px 0 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); max-height: 360px; overflow: auto; box-shadow: var(--shadow-lg); }
.results li { padding: 8px 10px; cursor: pointer; border-radius: 6px; }
.results li:hover, .results li.on { background: var(--accent-soft); }
.picked { padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink); }
table.lines input { width: 104px; text-align: right; } #prodSearch { width: 100%; }

details > summary { cursor: pointer; color: var(--accent); font-weight: 500; margin: 10px 0 6px; list-style: none; }
details > summary::before { content: "›"; display: inline-block; margin-right: 6px; transition: transform .15s; }
details[open] > summary::before { transform: rotate(90deg); }
details.card > summary { margin: 0; }

.bar-track { height: 6px; border-radius: 99px; background: var(--sunken); overflow: hidden; min-width: 60px; }
.bar-track i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent), var(--bg); }
.login { width: 100%; max-width: 380px; padding: 28px; box-shadow: var(--shadow-lg); }
.login .brand { padding: 0 0 18px; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.login label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 13px; }
.login button { width: 100%; min-height: 40px; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 50; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  body.nav-open .side { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(10,15,25,.4); z-index: 40; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; }
  main.content { padding: 18px 16px 48px; }
  thead th { top: 56px; }
  .search kbd { display: none; }
}
@media (max-width: 560px) { th, td { padding: 8px 10px; } .card { padding: 14px; } section.card > table, .card > .tbl { margin: 0 -14px -14px; width: calc(100% + 28px); } dl { grid-template-columns: 96px 1fr; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .side, .topbar { display: none; } .shell { display: block; } main.content { padding: 0; } .card { box-shadow: none; } }

/* ------------------------------------------------------------ dashboard */
.grid-dash { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
@media (max-width: 960px) { .grid-dash { grid-template-columns: minmax(0, 1fr); } }
.grid-dash > .card { margin-bottom: 0; }
.delta { font-family: var(--mono); font-weight: 600; } .delta.up { color: var(--ok); } .delta.down { color: var(--err); }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 6px; }
.spark-col { flex: 1; height: 100%; display: flex; align-items: flex-end; border-radius: 3px; }
.spark-col:hover { background: var(--sunken); }
.spark-col i { display: block; width: 100%; background: var(--accent); opacity: .78; border-radius: 3px 3px 1px 1px; min-height: 2px; }
.spark-col.wk i { opacity: .35; }
.spark-col.now i { opacity: 1; }
.spark-axis { display: flex; justify-content: space-between; color: var(--faint); font-size: 12px; margin-top: 6px; }
.todo { list-style: none; margin: 0; padding: 0; }
.todo li + li { border-top: 1px solid var(--line); }
.todo a { display: flex; align-items: center; gap: 12px; padding: 10px 0; color: var(--ink); }
.todo a:hover { color: var(--accent); }
.todo-n { min-width: 34px; text-align: center; font-family: var(--mono); font-weight: 600; padding: 3px 8px; border-radius: 99px; background: var(--sunken); color: var(--muted); }
.todo-n.warn { background: var(--warn-soft); color: var(--warn); } .todo-n.err { background: var(--err-soft); color: var(--err); }
.who { display: inline-flex; align-items: center; gap: 8px; }
.avatar.sm { width: 22px; height: 22px; font-size: 10px; background: var(--accent-soft); color: var(--accent); }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 10px 4px; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink); background: var(--surface-2); }
.day:hover { border-color: var(--accent); color: var(--ink); }
.day small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.day b { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.day span, .day em { font-size: 11px; font-style: normal; color: var(--accent); white-space: nowrap; }
.day em { color: var(--muted); }
@media (max-width: 560px) { .day span, .day em { display: none; } }
.rank { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 8px 0; color: var(--ink); }
.rank + .rank { border-top: 1px solid var(--line); }
.rank > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .bar-track { grid-column: 1 / -1; height: 4px; }
.rank:hover { color: var(--accent); }
input.invalid { border-color: var(--err); }

/* ------------------------------------------------------------ tabs & toolbars */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 16px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 9px 12px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .count { font-family: var(--mono); font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--sunken); color: var(--ink-2); }
.tabs a.on .count { background: var(--accent-soft); color: var(--accent); }
.card.flush > .toolbar { margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.toolbar-note { padding: 8px 16px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--line); }
.search-field { position: relative; flex: 1 1 280px; max-width: 440px; }
.search-field .ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search-field input { width: 100%; padding-left: 32px; }
.inline-label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
a.rowlink { color: var(--ink); font-weight: 500; } a.rowlink:hover { color: var(--accent); }
.card-foot { padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.seg { gap: 0 !important; flex-wrap: nowrap !important; } .seg input { flex: 0 0 auto !important; } .seg > * { border-radius: 0 !important; margin-left: -1px; } .seg > :first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm) !important; } .seg > :last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important; }
.affix { display: inline-flex; align-items: stretch; } .affix > span { display: grid; place-items: center; padding: 0 9px; border: 1px solid var(--line-strong); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: var(--sunken); color: var(--muted); }
.affix input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.empty-state { text-align: center; padding: 48px 24px; max-width: 520px; margin: 40px auto; }
.empty-ico { width: 48px; height: 48px; margin: 0 auto 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
tfoot tr.grand td { font-size: 16px; border-top: 1px solid var(--line-strong); }
@media (max-width: 760px) { .grid2[style] { grid-template-columns: minmax(0,1fr) !important; } .grid2 [style*="sticky"] { position: static !important; } }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .stat b { font-size: 20px; } }
.codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.codes code { padding: 10px 12px; background: var(--sunken); border-radius: var(--radius-sm); text-align: center; font-size: 15px; }
.steps { padding-left: 20px; display: grid; gap: 16px; } .steps li { padding-left: 4px; }
.qr { width: 200px; height: 200px; margin: 12px 0; background: #fff; border-radius: 12px; padding: 6px; border: 1px solid var(--line); }
.qr svg { width: 100%; height: 100%; display: block; }
code.secret { font-size: 14px; padding: 3px 8px; background: var(--sunken); border-radius: 6px; user-select: all; }
.dd-box { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

/* ------------------------------------------------------------ customer portal */
body.portal { background: var(--bg); }
.portal-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 14px max(20px, env(safe-area-inset-left, 0px)); background: var(--surface); border-bottom: 1px solid var(--line); }
.portal-brand { font-weight: 700; font-size: 17px; color: var(--ink); letter-spacing: -.01em; }
.portal-top nav { display: flex; gap: 18px; } .portal-top nav a { color: var(--ink-2); font-weight: 500; }
.portal-main { max-width: 860px; margin: 0 auto; padding: 28px 20px 40px; }
.portal-foot { text-align: center; color: var(--muted); font-size: 13px; padding: 20px; }
.portal-signin { max-width: 440px; margin: 40px auto; } .portal-signin label { display: flex; flex-direction: column; gap: 6px; margin: 16px 0; }
.portal-signin button { width: 100%; }

/* Order lines on a phone: each line becomes a small card (product on top, then qty / empties / price / VAT in a grid)
   instead of a seven-column table that runs off the side of the screen. Rows added by app.js get the same layout. */
@media (max-width: 640px) {
  table.lines, table.lines tbody, table.lines tfoot, table.lines tr, table.lines td { display: block; width: 100%; }
  table.lines thead { display: none; }
  table.lines tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  table.lines tbody td { padding: 0; border: 0; text-align: left; min-width: 0; }
  table.lines tbody td:nth-child(1) { grid-column: 1 / -1; }
  table.lines tbody td:nth-child(2)::before { content: 'Qty'; }
  table.lines tbody td:nth-child(3)::before { content: 'Empties back'; }
  table.lines tbody td:nth-child(4)::before { content: 'Price (net)'; }
  table.lines tbody td:nth-child(5)::before { content: 'VAT'; }
  table.lines tbody td:nth-child(6)::before { content: 'Line (net)'; }
  table.lines tbody td:nth-child(n+2):nth-child(-n+6)::before { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
  table.lines tbody td:nth-child(6) { align-self: end; font-weight: 600; }
  table.lines tbody td:nth-child(7) { align-self: end; text-align: right; }
  table.lines input, table.lines select { width: 100%; max-width: none; }
  table.lines tfoot tr { display: flex; justify-content: flex-end; gap: 16px; padding: 4px 0; }
  table.lines tfoot td { width: auto; padding: 4px 0; border: 0; }
  table.lines tfoot td:empty { display: none; }
  table.lines tfoot tr:first-child, table.lines tfoot tr:first-child td { display: block; width: 100%; }
}

/* link-style buttons side by side (e.g. Users: Sign out everywhere · Remove access) */
button.link + button.link, a + button.link, button.link + a { margin-left: 14px; }

/* ------------------------------------------------------------------ guided tours (tour.js) */
.tour-shade { position: fixed; inset: 0; z-index: 900; }
.tour-shade.solid { background: rgba(15, 17, 22, .45); }
.tour-spot { position: fixed; z-index: 901; border-radius: 10px; pointer-events: none; box-shadow: 0 0 0 3px var(--accent), 0 0 0 100vmax rgba(15, 17, 22, .45); transition: top .25s, left .25s, width .25s, height .25s; }
.tour-card { position: fixed; z-index: 902; width: min(340px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 16px 18px 14px; }
.tour-card.sheet { left: 12px !important; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); top: auto !important; width: auto; }
.tour-card h3 { margin: 6px 0 6px; font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.tour-card p { margin: 0 0 12px; color: var(--ink-2, var(--ink)); line-height: 1.5; font-size: 13.5px; }
.tour-card kbd { font: 12px var(--mono, monospace); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; }
.tour-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tour-count { font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.tour-x { border: 0; background: none; box-shadow: none; font-size: 20px; line-height: 1; padding: 2px 6px; color: var(--muted); min-height: 0; }
.tour-dots { display: flex; gap: 5px; margin-bottom: 12px; }
.tour-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.tour-dots i.done { background: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.tour-dots i.on { background: var(--accent); width: 16px; border-radius: 3px; }
.tour-btns { display: flex; justify-content: space-between; gap: 8px; }
.tour-btns .tour-skip { background: none; box-shadow: none; border-color: transparent; color: var(--muted); padding-left: 0; }
.tour-toast { position: fixed; z-index: 905; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px; font-weight: 550; box-shadow: var(--shadow-lg); transition: opacity .5s; }
.tour-toast.go { opacity: 0; }
.tour-list { margin-bottom: 16px; }
.tour-list .card-head { display: flex; align-items: baseline; gap: 10px; }
.tour-list .card-head h2 { margin-right: auto; }
.tour-list .bar-track { height: 4px; border-radius: 2px; background: var(--line); margin: 8px 0 6px; overflow: hidden; }
.tour-list .bar-track i { display: block; height: 100%; background: var(--accent); transition: width .4s; }
.tour-list ul, .tour-list-ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 18px; }
.tour-list li, .tour-list-ul li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.tour-list .tick, .tour-list-ul .tick { flex: 0 0 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; }
.tour-list li.done .tick, .tour-list-ul li.done .tick { background: var(--ok); border-color: var(--ok); }
.tour-list .lbl, .tour-list-ul .lbl { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tour-list .lbl em, .tour-list-ul .lbl em { font-style: normal; font-size: 12px; color: var(--muted); }
.tour-list li.done b, .tour-list-ul li.done b { color: var(--muted); font-weight: 500; }
.tour-list li button, .tour-list-ul li button { min-height: 0; padding: 4px 12px; font-size: 12.5px; }
.tour-menu { position: fixed; inset: 0; z-index: 890; background: rgba(15, 17, 22, .45); display: grid; place-items: center; padding: 16px; }
.tour-menu-card { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow-lg); }
.tour-menu-card .card-head { display: flex; justify-content: space-between; align-items: center; }
.tour-menu-card .tour-list-ul { grid-template-columns: 1fr; margin: 8px 0 12px; }
.tour-menu-foot { font-size: 13px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .tour-spot, .tour-list .bar-track i { transition: none; } }
.tour-install { display: flex; align-items: center; gap: 14px; justify-content: space-between; padding: 12px 14px; margin: 10px 0 4px; border: 1px solid var(--line); border-radius: var(--radius-sm, 8px); background: var(--surface-2); }
.tour-install div { display: flex; flex-direction: column; min-width: 0; }
.tour-install .muted { font-size: 13px; }
/* installed app: keep content clear of the phone's notch and home bar */
@media (display-mode: standalone) { main.content { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); } }
