/* Additions to the prototype's styles: navigation, tables, the booking dialog, builds and planning. */

.linkbtn { background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; font-size: inherit; }
h2.sec { margin: 0; font-size: 18px; }
.view { display: grid; gap: 18px; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.spacer { flex: 1; }
.hidden { display: none !important; }
/* `hidden` must win over a class that sets display (a button, a flex row, the warning banner) */
[hidden] { display: none !important; }

/* stock list: one more action than the prototype */
.listhead, .row { grid-template-columns: minmax(0, 1fr) 90px 90px 120px 290px; }
.acts .btn { padding: 8px 11px; }
.pill.recount { background: var(--crit-soft); color: var(--crit); }
.pinfo .bin { font-family: var(--font-mono); font-size: 12px; background: var(--none-soft); border-radius: 4px; padding: 0 5px; margin-left: 6px; color: var(--ink); }
.tile.link { cursor: pointer; }

/* tables */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel.pad { padding: 16px; display: grid; gap: 12px; }
.tablewrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th { text-align: left; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 50%, var(--surface)); white-space: nowrap; }
table.grid td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid th.r, table.grid td.r { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.r { font-family: var(--font-mono); }
table.grid tr.short td { background: color-mix(in srgb, var(--crit-soft) 50%, var(--surface)); }
table.grid tr.unknown td { background: color-mix(in srgb, var(--none-soft) 60%, var(--surface)); }
table.grid tr.sechead td { background: color-mix(in srgb, var(--bg) 60%, var(--surface)); font-weight: 600; color: var(--muted); font-size: 13px; }
table.grid .t { font-weight: 600; }
table.grid .pn { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); }
td.neg { color: var(--crit); }
td.pos { color: var(--ok); }
.struck { text-decoration: line-through; color: var(--muted); }

/* forms outside dialogs */
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.field input, .field select, input.in, select.in { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
input.qty { width: 84px; text-align: right; font-family: var(--font-mono); padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
input.qty.changed { border-color: var(--accent); background: var(--accent-soft); }
input.qty.zero { color: var(--muted); }

/* dialogs */
dialog.wide { width: min(1040px, calc(100vw - 24px)); }
dialog .scroll { max-height: min(56vh, 620px); overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
dialog .scroll table.grid th { position: sticky; top: 0; z-index: 1; }
dialog input[type="checkbox"] { width: auto; padding: 0; }
label.inline, dialog label.inline { display: inline-flex; gap: 8px; align-items: center; color: inherit; font-size: inherit; }
dialog textarea { min-height: 60px; resize: vertical; }
dialog .sum { font-size: 13px; color: var(--muted); }
dialog .sum b { color: var(--ink); }
dialog .sum .warn { color: var(--crit); font-weight: 600; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 10px; cursor: pointer; font-weight: 500; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.bigqty { display: grid; grid-template-columns: 56px 1fr 56px; gap: 8px; align-items: stretch; }
.bigqty input { font-family: var(--font-mono); font-size: 30px; font-weight: 600; text-align: center; padding: 10px; }
.bigqty button { font-size: 24px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 14px; cursor: pointer; }
.chips button.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.names button { padding: 18px 10px; font-size: 16px; }
.toast button { font: inherit; }

.bigcode { font-family: var(--font-mono); font-size: 20px; font-weight: 600; letter-spacing: .04em; padding: 14px; margin: 0; text-align: center; background: var(--none-soft); border-radius: 8px; user-select: all; overflow-wrap: anywhere; }

.reminder { padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); font-size: 14px; display: grid; gap: 2px; }
.reminder ul { margin: 0; padding-left: 18px; }
input.in.wide { width: 100%; min-width: 180px; }
input.in.mono { font-family: var(--font-mono); font-size: 13px; width: 100%; min-width: 132px; }
table.bomedit td { vertical-align: bottom; padding: 6px 8px; }
table.bomedit input.in { min-height: 34px; padding: 5px 8px; }
input.in.changed { border-color: var(--focus); background: var(--brand-pale); }

/* builds */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 8px; text-decoration: none; color: inherit; }
a.card:hover { border-color: var(--accent); }
.card .unit { font-size: 22px; font-weight: 600; font-family: var(--font-mono); }
.card .meta { font-size: 13px; color: var(--muted); }
.bar { height: 8px; border-radius: 999px; background: var(--none-soft); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); }
.buildhead { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.buildhead h2 { margin: 0; font-size: 24px; font-family: var(--font-mono); }
.pill.open { background: var(--accent-soft); color: var(--accent); }
.pill.finished { background: var(--ok-soft); color: var(--ok); }
.pill.cancelled { background: var(--none-soft); color: var(--muted); }
.stepper { display: inline-flex; gap: 4px; align-items: center; }
.stepper .btn { padding: 6px 12px; min-width: 44px; }
.stepper .btn.num { font-family: var(--font-mono); font-weight: 600; min-width: 64px; }

/* planning */
.planrow { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.planrow input.n { width: 96px; font-size: 22px; font-weight: 600; font-family: var(--font-mono); text-align: center; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.verdict { border-radius: var(--radius); padding: 14px 16px; font-size: 17px; font-weight: 600; }
.verdict.yes { background: var(--ok-soft); color: var(--ok); }
.verdict.no { background: var(--crit-soft); color: var(--crit); }
.verdict.maybe { background: var(--warn-soft); color: var(--warn); }
.verdict small { display: block; font-weight: 400; font-size: 13px; margin-top: 2px; color: var(--ink); }

/* sign-in */
.login { max-width: 460px; margin: 10vh auto; padding: 0 20px; display: grid; gap: 16px; }
.login h1 { margin: 0; }
.login .btn { padding: 12px 16px; text-align: left; }

@media (max-width: 760px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile .num { font-size: 24px; }
  .row { grid-template-columns: minmax(0, 1fr) auto; }
  .acts .btn { flex: 1; }
  .hide-narrow { display: none; }
}

/* camera reader */
.scanbox { position: relative; background: #000; border-radius: 8px; overflow: hidden; aspect-ratio: 4 / 3; }
.scanbox video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanframe { position: absolute; inset: 18% 24%; border: 3px solid var(--sd-neon); border-radius: 10px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .28); pointer-events: none; }
.scanrow { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.warnline { color: var(--danger); }
#scanBtn { gap: 6px; }

/* labels: drawn in millimetres, so the preview on screen is the size that is printed */
.labelsmain { grid-template-columns: minmax(0, 1fr) 360px; }
@media (max-width: 1000px) { .labelsmain { grid-template-columns: minmax(0, 1fr); } }
.labelsheet { display: grid; gap: 12px; justify-items: start; max-height: 46vh; overflow: auto; padding: 2px; }
.labelitem { display: grid; gap: 6px; }
.labelitem .scanrow { width: max(var(--label-length, 45mm), 56mm); align-items: center; }
.labelitem input.in { min-width: 0; min-height: 32px; padding: 4px 8px; font-size: 13px; }
.labelpick { max-height: 70vh; overflow: auto; }
aside.log .btn { white-space: normal; }
.label { box-sizing: border-box; width: var(--label-length, 45mm); height: var(--label-tape, 24mm); padding: calc((var(--label-tape, 24mm) - var(--label-print, 18mm)) / 2) 1.5mm; display: flex; align-items: center; gap: 1.5mm; background: #fff; color: #000; overflow: hidden; outline: 1px dashed var(--border-strong); font-family: var(--sd-font-body); }
.label-qr { flex: 0 0 auto; height: var(--label-print, 18mm); aspect-ratio: 1; }
.label-qr svg { width: 100%; height: 100%; display: block; }
.label-text { min-width: 0; flex: 1 1 auto; display: grid; gap: .6mm; align-content: center; }
/* The name is what people read first: large, and it wraps onto up to three lines so the label
   can be short. Text never runs off the tape: a long word breaks, and what will not fit is cut. */
.label-name { font-size: 3.6mm; line-height: 1.08; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.label.has-bin .label-name { -webkit-line-clamp: 2; }
.label-pn { font-family: var(--sd-mono); font-weight: 500; font-size: 2.5mm; line-height: 1.1; overflow-wrap: anywhere; }
.label-bin { font-size: 2.3mm; line-height: 1.1; overflow-wrap: anywhere; }
.scanlast { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--ok-soft); font-size: 14px; }
.scanlast .btn { min-height: 32px; padding: 4px 12px; }
#printArea { display: none; }

@media print {
  /* Only while labels are being printed. Any other page (plan, pick list, log) prints as it is. */
  html:has(#printArea), body:has(> #printArea) { background: #fff !important; margin: 0 !important; }
  body:has(> #printArea) > *:not(#printArea) { display: none !important; }
  #printArea { display: block; }
  #printArea .strip { display: flex; flex-wrap: nowrap; break-after: page; page-break-after: always; break-inside: avoid; }
  #printArea .strip:last-child { break-after: auto; page-break-after: auto; }
  #printArea .label { outline: 0; flex: 0 0 auto; }
  /* where to cut between two labels on a strip. With half cut the printer does the cutting. */
  #printArea.strip .label + .label { border-left: 0.25mm dashed #000; }
}
