/* ---------------------------------------------------------------------------
   Sổ Cái — accounting-core

   Built for three kinds of use at once, which is why it looks the way it does:

   - a phone held in one hand at a back door, in daylight, by somebody holding
     a crate with the other hand. Hence the 48px targets and the very large
     numerals on the receiving and count screens.
   - a laptop in an office, all day, by somebody reading figures. Hence the
     tabular monospaced numerals and the restraint everywhere else.
   - a glance by the owner. Hence the dashboard being the only screen with
     any colour in quantity.

   The palette is from Vietnamese official documents: ink blue, seal red, the
   warm off-white of government paper. It is not decoration — a system that
   issues VAT invoices should not look like a toy.
   --------------------------------------------------------------------------- */

:root {
  --ink: #16263d;
  --ink-2: #334a68;
  --ink-3: #60748f;
  --ink-4: #9aa8bb;
  --line: #d9dfe8;
  --line-2: #e9edf3;
  --paper: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --seal: #a8221f;
  --seal-soft: #fdf1f0;
  --ok: #1d6b4f;
  --ok-soft: #eef7f2;
  --warn: #8a5a09;
  --warn-soft: #fdf5e7;
  --accent: #1c4f8f;
  --accent-soft: #eef3fa;
  --shadow: 0 1px 2px rgba(22, 38, 61, .06), 0 4px 12px rgba(22, 38, 61, .05);
  --radius: 10px;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --sans: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e8edf4;
    --ink-2: #c2cde0;
    --ink-3: #93a2b8;
    --ink-4: #6b7d96;
    --line: #2c3a4e;
    --line-2: #243041;
    --paper: #11161f;
    --surface: #182130;
    --surface-2: #1e2938;
    --seal: #e8706c;
    --seal-soft: #2e1c1d;
    --ok: #6cc69f;
    --ok-soft: #16281f;
    --warn: #e0ab5a;
    --warn-soft: #2a2316;
    --accent: #7fb0ea;
    --accent-soft: #19253a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  }
}

:root[data-theme="dark"] {
  --ink: #e8edf4; --ink-2: #c2cde0; --ink-3: #93a2b8; --ink-4: #6b7d96;
  --line: #2c3a4e; --line-2: #243041; --paper: #11161f; --surface: #182130;
  --surface-2: #1e2938; --seal: #e8706c; --seal-soft: #2e1c1d;
  --ok: #6cc69f; --ok-soft: #16281f; --warn: #e0ab5a; --warn-soft: #2a2316;
  --accent: #7fb0ea; --accent-soft: #19253a;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* Figures line up in columns or they cannot be read down a page. */
.num, td.num, th.num, .mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.num { text-align: right; white-space: nowrap; }

h1, h2, h3 { font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .9rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- shell ------------------------------------------------------------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.side {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}

.brand {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line-2);
}
.brand b { display: block; font-size: 1.1rem; letter-spacing: .02em; }
.brand span { display: block; font-size: .7rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .14em; margin-top: 2px; }

.nav { padding: 10px 8px; flex: 1; }
.nav-group { font-size: .66rem; text-transform: uppercase; letter-spacing: .14em; color: var(--ink-4); padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--ink-2); font-size: .875rem; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a .pill { margin-left: auto; }
.nav svg { width: 17px; height: 17px; flex: none; opacity: .8; }

.who { border-top: 1px solid var(--line-2); padding: 12px 14px; font-size: .8rem; }
.who b { display: block; }
.who small { color: var(--ink-3); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px; border-bottom: 1px solid var(--line);
  background: var(--surface); position: sticky; top: 0; z-index: 20;
}
.topbar .grow { flex: 1; min-width: 0; }
.sub { color: var(--ink-3); font-size: .8rem; }
.content { padding: 22px 24px 64px; max-width: 1180px; width: 100%; }

/* --- cards and tables -------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 16px; overflow: hidden;
}
.card > header {
  padding: 13px 16px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 10px;
}
.card > header .grow { flex: 1; min-width: 0; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th {
  text-align: left; font-size: .68rem; text-transform: uppercase;
  letter-spacing: .1em; color: var(--ink-3); font-weight: 600;
  padding: 9px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface-2); white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }

.empty { padding: 42px 20px; text-align: center; color: var(--ink-3); }
.empty b { display: block; color: var(--ink-2); margin-bottom: 4px; }

/* --- pills and chips --------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .68rem; font-weight: 600; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line);
}
.pill.critical { background: var(--seal-soft); color: var(--seal); border-color: color-mix(in srgb, var(--seal) 30%, transparent); }
.pill.warning  { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.pill.ok       { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.pill.info     { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

/* --- buttons ----------------------------------------------------------- */
button, .btn {
  font-family: inherit; font-size: .875rem; font-weight: 600;
  padding: 9px 15px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  display: inline-flex; align-items: center; gap: 7px; min-height: 38px;
}
button:hover:not(:disabled), .btn:hover { background: var(--surface-2); text-decoration: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
/* the generic hover rule outranks .primary on specificity, which turned a
   hovered primary button white-on-white — restate the background here */
button.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
button.danger { background: var(--seal); border-color: var(--seal); color: #fff; }
button.danger:hover:not(:disabled) { background: var(--seal); filter: brightness(1.08); }
button.ghost { border-color: transparent; background: transparent; }
button.sm { padding: 5px 10px; min-height: 30px; font-size: .8rem; }
button.big { min-height: 52px; font-size: 1rem; width: 100%; justify-content: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

/* --- forms ------------------------------------------------------------- */
label { display: block; font-size: .78rem; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
label .hint { font-weight: 400; color: var(--ink-3); }
input, select, textarea {
  font-family: inherit; font-size: .9rem; width: 100%;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); min-height: 40px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: -1px; border-color: var(--accent);
}
input[inputmode="decimal"], input.num { font-family: var(--mono); text-align: right; }
.field { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* --- notices ----------------------------------------------------------- */
.notice {
  border-radius: 8px; padding: 11px 14px; font-size: .85rem;
  border: 1px solid var(--line); background: var(--surface-2);
  margin-bottom: 14px; display: flex; gap: 9px; align-items: flex-start;
}
.notice b { display: block; }
.notice.bad { background: var(--seal-soft); border-color: color-mix(in srgb, var(--seal) 28%, transparent); color: var(--seal); }
.notice.good { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 28%, transparent); color: var(--ok); }
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 28%, transparent); color: var(--warn); }

/* --- the owner's tiles -------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 15px; box-shadow: var(--shadow); cursor: pointer;
}
.tile:hover { border-color: var(--accent); }
.tile .k { font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); }
.tile .v { font-family: var(--mono); font-size: 1.5rem; font-weight: 500; margin: 7px 0 3px; font-variant-numeric: tabular-nums; }
.tile .d { font-size: .76rem; color: var(--ink-3); display: flex; gap: 8px; align-items: center; }
.tile .d .up { color: var(--ok); } .tile .d .down { color: var(--seal); }

/* --- the queue --------------------------------------------------------- */
.queue-item {
  display: flex; gap: 13px; padding: 13px 16px; border-bottom: 1px solid var(--line-2);
  cursor: pointer; align-items: flex-start;
}
.queue-item:last-child { border-bottom: 0; }
.queue-item:hover { background: var(--surface-2); }
.queue-item .bar { width: 3px; border-radius: 2px; align-self: stretch; background: var(--ink-4); flex: none; }
.queue-item.critical .bar { background: var(--seal); }
.queue-item.warning .bar { background: var(--warn); }
.queue-item.info .bar { background: var(--accent); }
.queue-item .t { font-weight: 600; font-size: .9rem; }
.queue-item .m { color: var(--ink-3); font-size: .82rem; margin-top: 2px; }
.queue-item .meta { margin-left: auto; text-align: right; flex: none; font-size: .76rem; color: var(--ink-3); }

/* --- receiving and counting, on a phone -------------------------------- */
.big-line {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.big-line .name { font-weight: 600; font-size: 1rem; }
.big-line .code { font-family: var(--mono); font-size: .72rem; color: var(--ink-3); }
.big-line .qty {
  font-family: var(--mono); font-size: 1.9rem; font-weight: 500;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.big-line .unit { font-size: .9rem; color: var(--ink-3); font-family: var(--sans); }
.shot {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; border: 1.5px dashed var(--line); border-radius: 8px;
  background: var(--surface-2); color: var(--ink-2); font-weight: 600;
  font-size: .85rem; cursor: pointer; width: 100%;
}
.shot.done { border-style: solid; border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-soft); color: var(--ok); }
.shot input { display: none; }
.thumb { width: 54px; height: 54px; border-radius: 7px; object-fit: cover; border: 1px solid var(--line); }

/* --- sign in ------------------------------------------------------------ */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.signin .box { width: 100%; max-width: 384px; }
.signin .seal {
  width: 46px; height: 46px; border: 2px solid var(--seal); border-radius: 50%;
  display: grid; place-items: center; color: var(--seal); font-weight: 700;
  font-size: .95rem; margin: 0 auto 16px; letter-spacing: -.02em;
}
.signin h1 { text-align: center; margin-bottom: 4px; }
.signin .sub { text-align: center; margin-bottom: 22px; }
.code-input {
  font-family: var(--mono); font-size: 1.8rem; text-align: center;
  letter-spacing: .34em; padding: 12px; text-indent: .34em;
}
.secret-box {
  font-family: var(--mono); font-size: .95rem; letter-spacing: .06em;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 11px; text-align: center; word-break: break-all;
}
.qr { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: 8px; border: 1px solid var(--line); }
.qr svg { display: block; width: 200px; height: 200px; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; font-family: var(--mono); font-size: .9rem; }
.codes span { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 7px; text-align: center; }

/* --- drill-down drawer -------------------------------------------------- */
.drawer-bg { position: fixed; inset: 0; background: rgba(22,38,61,.4); z-index: 60; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100%);
  background: var(--paper); z-index: 61; overflow-y: auto;
  border-left: 1px solid var(--line); box-shadow: -8px 0 32px rgba(22,38,61,.14);
}
.drawer > header {
  padding: 15px 20px; border-bottom: 1px solid var(--line); background: var(--surface);
  display: flex; gap: 12px; align-items: center; position: sticky; top: 0; z-index: 2;
}
.drawer .content { padding: 18px 20px 60px; }

.spinner {
  width: 15px; height: 15px; border: 2px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 40px; text-align: center; color: var(--ink-3); }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 11px 17px;
  border-radius: 9px; font-size: .875rem; z-index: 90; max-width: 90vw;
  box-shadow: 0 6px 24px rgba(0,0,0,.26);
}
.toast.bad { background: var(--seal); color: #fff; }

kbd {
  font-family: var(--mono); font-size: .76rem; background: var(--surface-2);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px;
}

.lang { display: flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.lang button { border: 0; border-radius: 0; padding: 5px 9px; min-height: 28px; font-size: .74rem; background: var(--surface); }
.lang button.on { background: var(--accent); color: #fff; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  border: 0; border-radius: 0; background: transparent; color: var(--ink-3);
  padding: 9px 14px; border-bottom: 2px solid transparent; margin-bottom: -1px;
  font-size: .85rem; white-space: nowrap; min-height: 0;
}
.tab:hover { background: transparent; color: var(--ink); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

details.why { margin-top: 10px; font-size: .8rem; color: var(--ink-3); }
details.why summary { cursor: pointer; font-weight: 600; color: var(--ink-2); }
details.why p { margin: 7px 0 0; }

/* --- phones ------------------------------------------------------------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto;
    flex-direction: row; border-right: 0; border-top: 1px solid var(--line);
    z-index: 40; overflow-x: auto;
  }
  .brand, .who, .nav-group { display: none; }
  .nav { display: flex; padding: 4px; gap: 2px; width: 100%; }
  .nav a { flex-direction: column; gap: 3px; font-size: .62rem; padding: 7px 9px; flex: 1; text-align: center; min-width: 62px; }
  .nav a .pill { margin: 0; position: absolute; transform: translate(16px, -6px); }
  .nav a { position: relative; }
  .content { padding: 16px 16px 92px; }
  .topbar { padding: 12px 16px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; }
  table.stack thead { display: none; }
  table.stack tr { display: block; border-bottom: 1px solid var(--line); padding: 10px 0; }
  table.stack td { display: flex; justify-content: space-between; border: 0; padding: 4px 14px; gap: 14px; }
  table.stack td::before { content: attr(data-l); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; }
  .drawer { width: 100%; }
}

@media print {
  .side, .topbar, button { display: none !important; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; font-size: 11pt; }
}

/* Row actions (waste, and anywhere a row carries two or three small buttons) */
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
label.btn-like { display: inline-flex; align-items: center; justify-content: center; padding: 4px 9px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; font-size: .8rem; min-height: 30px; }
label.btn-like:hover { filter: brightness(1.05); }

/* People & seats: the seat picker and the permission editor */
.seat-h { margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .08em; font-size: .7rem; color: var(--ink-3); }
.seat-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.seat-row .seat-note { grid-column: 1 / -1; min-height: 0; }
.seat-row .seat-note:empty { display: none; }
@media (max-width: 640px) { .seat-row { grid-template-columns: 1fr auto; } .seat-row select[name=scope] { grid-column: 1 / 2; } }
.perm-preview summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.perm-group { padding: 4px 0; border-bottom: 1px solid var(--line-2); font-size: .85rem; }
.perm-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.perm-row.on { background: color-mix(in srgb, var(--ok) 6%, transparent); }
.perm-row input { width: 18px; height: 18px; flex: none; }

/* --- goods movements: the three-leg chain ----------------------------- */
.chain { display: inline-flex; gap: 4px; }
.chain-dot {
  width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: .7rem; font-weight: 700; border: 1px solid var(--line); color: var(--ink-4); background: var(--surface-2);
}
.chain-dot.done { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.leg {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); position: relative;
}
.leg .name { font-weight: 600; font-size: 1rem; }
.leg.done { border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.leg.done::before { content: '✓'; position: absolute; left: -1px; top: -1px; width: 22px; height: 22px;
  border-radius: var(--radius) 0 8px 0; background: var(--ok); color: #fff; font-size: .7rem; display: grid; place-items: center; }
.leg.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.leg .thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.leg .thumbs:empty { display: none; }
.leg .thumb { cursor: zoom-in; }
.leg .thumb.sig { width: 108px; background: #fff; object-fit: contain; }
.leg .thumb.ph { display: inline-grid; place-items: center; background: var(--surface-2); font-size: 1.3rem; cursor: default; }
.sigpad canvas {
  width: 100%; height: auto; aspect-ratio: 640 / 220; display: block;
  border: 1.5px dashed var(--line); border-radius: 8px; background: #fff; touch-action: none; cursor: crosshair;
}

/* --- uploading a sheet ------------------------------------------------- */
.drop {
  display: flex; align-items: center; gap: 16px; padding: 22px 18px; cursor: pointer;
  border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface-2);
  font-weight: 400; color: var(--ink); font-size: .95rem; margin: 0;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop.busy { opacity: .7; pointer-events: none; }
.drop input { display: none; }
.drop-icon { font-size: 1.9rem; line-height: 1; color: var(--accent); }
.kinds { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.kind { display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; font-weight: 400; color: var(--ink); margin: 0; }
.kind.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.kind.off { opacity: .55; cursor: not-allowed; }
.kind input { display: none; }
.kind b { display: block; margin-bottom: 4px; }
table.mapping td { padding: 7px 8px; vertical-align: middle; border-bottom: 1px solid var(--line-2, var(--line)); }
table.mapping td:first-child { width: 34%; }
table.mapping select { min-width: 160px; }
.req { color: var(--seal); }
table.raw { font-size: .78rem; white-space: nowrap; }
table.raw th, table.raw td { padding: 5px 8px; border-bottom: 1px solid var(--line-2, var(--line)); max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
table.raw th { background: var(--surface-2); position: sticky; top: 0; text-align: left; font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tiles .tile { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }

/* --- reports ----------------------------------------------------------- */
.rep-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 16px; align-items: start; }
.rep-side .nav-group { margin: 10px 0 2px; }
.rep-item { display: block; padding: 7px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: .88rem; }
.rep-item:hover { background: var(--surface-2); text-decoration: none; }
.rep-item.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.rep-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.rep-filters .span2 { grid-column: 1 / -1; }
.rep-filters .field { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: .8rem; font-weight: 500; color: var(--ink); cursor: pointer; margin: 0; }
.chip input { width: auto; min-height: 0; margin: 0; }
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.rep-cols { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; }
table.rep { font-size: .8rem; white-space: nowrap; width: 100%; }
table.rep th, table.rep td { padding: 6px 9px; border-bottom: 1px solid var(--line-2, var(--line)); text-align: left; }
table.rep th { background: var(--surface-2); position: sticky; top: 0; font-weight: 600; font-size: .72rem; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-2); }
table.rep th.sortable { cursor: pointer; }
table.rep th.num, table.rep td.num { text-align: right; }
table.rep tfoot td { border-top: 2px solid var(--line); background: var(--surface-2); }
@media (max-width: 900px) { .rep-layout { grid-template-columns: 1fr; } .rep-side .card-body { display: flex; flex-wrap: wrap; gap: 4px; } .rep-side .nav-group { width: 100%; } }

/* --- orders to the prep kitchen (032) ---------------------------------- */
/* The branch's phone after service: one thumb, bad light, a crate in the other hand. */
.ko-days { display: flex; gap: 6px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.ko-days::-webkit-scrollbar { display: none; }
.ko-day {
  flex: none; min-width: 66px; min-height: 64px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); display: flex; flex-direction: column; align-items: center; gap: 1px; line-height: 1.2; color: var(--ink-2);
}
.ko-day .w { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.ko-day .d { font-family: var(--mono); font-size: 1rem; font-weight: 600; color: var(--ink); }
.ko-day .s { font-size: .68rem; color: var(--ink-3); white-space: nowrap; }
.ko-day.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.ko-day.late .s { color: var(--warn); font-weight: 600; }
.ko-day.past { opacity: .55; }
.ko-cut { margin-top: 10px; padding: 9px 12px; border-radius: 8px; background: var(--ok-soft); color: var(--ok); font-size: .85rem; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ko-cut.late { background: var(--warn-soft); color: var(--warn); }
.ko-open { margin-top: 10px; padding: 10px 12px; border-radius: 8px; border: 1px dashed var(--line); background: var(--surface-2); }
.ko-tools { display: flex; gap: 8px; align-items: center; margin: 4px 0 10px; position: sticky; top: 0; z-index: 5; background: var(--paper); padding: 6px 0; }
.ko-tools input[type=search] { flex: 1; min-height: 48px; font-size: 1rem; border-radius: 12px; padding: 0 14px; }
.ko-sec { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-4); padding: 14px 4px 6px; }
.ko-secs { display: flex; gap: 6px; overflow-x: auto; padding: 0 0 8px; scrollbar-width: none; }
.ko-secs::-webkit-scrollbar { display: none; }
.ko-secbtn { flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: 0 12px; min-height: 36px; font-size: .8rem; }
.ko-secbtn.on { background: var(--ink); border-color: var(--ink); color: var(--paper); font-weight: 600; }
.ko-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 10px 10px 10px 14px; margin-bottom: 8px;
}
.ko-row.picked { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface)); }
.ko-row.done { align-items: flex-start; }
.ko-name { min-width: 0; flex: 1; }
.ko-name .name { font-weight: 600; font-size: .98rem; line-height: 1.25; }
.ko-hints { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.ko-hint { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-3); border-radius: 999px; padding: 2px 9px; font-size: .72rem; min-height: 26px; line-height: 1.2; }
.ko-hint b { color: var(--ink); font-family: var(--mono); font-weight: 600; }
.ko-step { display: grid; grid-template-columns: 48px 72px 48px; grid-template-rows: 48px auto; align-items: center; justify-items: center; gap: 0 4px; flex: none; }
.ko-btn { width: 48px; height: 48px; border-radius: 12px; font-size: 1.5rem; line-height: 1; padding: 0; font-weight: 500; }
.ko-btn.txt { font-size: .8rem; font-weight: 600; }
.ko-qty { width: 72px; height: 48px; text-align: center !important; font-size: 1.25rem; font-family: var(--mono); padding: 0 6px; border-radius: 10px; }
.ko-unit { grid-column: 1 / -1; font-size: .72rem; color: var(--ink-3); text-align: center; line-height: 1.2; padding-top: 3px; }
.ko-unit .sub { font-size: .7rem; }
.ko-fig { text-align: right; font-family: var(--mono); font-size: .9rem; line-height: 1.5; }
.ko-fig .k { font-family: var(--sans); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin-right: 4px; }
.ko-fig .unit { font-family: var(--sans); color: var(--ink-3); font-size: .78rem; }
.ko-fig .sub { font-family: var(--sans); font-size: .78rem; }
.ko-bar {
  position: sticky; bottom: 0; margin: 14px -16px 0; padding: 10px 16px 12px; background: var(--paper); border-top: 1px solid var(--line);
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; z-index: 6;
}
.ko-bar button.big { flex: 1; min-width: 180px; }
.ko-sum { font-size: .85rem; color: var(--ink-3); flex-basis: 100%; }
.short { color: var(--seal); }
.warnish { color: var(--warn); font-weight: 600; }
@media (max-width: 860px) { .ko-bar { bottom: 70px; } }

/* The kitchen's morning */
.tile.sm { cursor: default; padding: 8px 12px; min-width: 96px; }
.tile.sm .v { font-size: 1.2rem; margin: 2px 0 0; }
.tile.sm .v.warn { color: var(--warn); }
.ko-plan td, .ko-plan th { vertical-align: top; }
.ko-sec-row td { background: var(--surface-2); font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); padding: 6px 14px; }
.ko-order > header { align-items: flex-start; flex-wrap: wrap; }
.ko-order.open { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.ko-lines td { padding: 6px 4px; border-bottom: 1px solid var(--line-2); font-size: .9rem; vertical-align: top; }
.ko-lines tr:last-child td { border-bottom: 0; }
.ko-wd { display: flex; gap: 4px; flex-wrap: wrap; }
.ko-wd label { border: 1px solid var(--line); border-radius: 7px; padding: 3px 7px; font-size: .74rem; cursor: pointer; min-width: 34px; text-align: center; background: var(--surface); color: var(--ink-3); }
.ko-wd label.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.ko-wd input { display: none; }
tr.muted td { opacity: .5; }
@media print {
  .ko-days, .tabs, .tile, .ko-order .actions, .ko-order button { display: none !important; }
  .print-sheet table { font-size: 12pt; }
  .ko-plan .warnish { font-weight: 700; }
}
