/*
 * XECO POS styles.
 *
 * Written for the environment this actually runs in: a glass tablet held by
 * someone moving fast, in a room that is either dim or glaring, often with wet
 * or gloved hands.
 *
 *  - Dark by default. A white screen at a dim table is a lighthouse.
 *  - 44px minimum touch target, everywhere, no exceptions.
 *  - High contrast type. Menu items are read at arm's length.
 *  - No hover-only affordances: there is no cursor on a tablet.
 *  - Colour is never the sole signal -- table states and kitchen alerts carry
 *    text as well, because roughly one in twelve men cannot separate the reds
 *    from the greens.
 */

:root {
  --bg: #12141a;
  --bg-raised: #1a1d26;
  --bg-sunken: #0d0f14;
  --line: #2a2f3d;
  --text: #eef1f7;
  --text-dim: #9aa3b8;

  --primary: #3d7ea6;
  --primary-ink: #ffffff;
  --accent: #e8b33a;
  --accent-ink: #1a1d26;
  --ok: #4f9d69;
  --warn: #d99a2b;
  --danger: #cf5a4e;

  --radius: 10px;
  --radius-lg: 16px;
  --touch: 44px;
  --gap: 12px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  /* Stop the pull-to-refresh gesture wiping a half-built ticket. */
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  /* Respect notches and home indicators on tablets used as tills. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

h1, h2, h3, h4 { margin: 0 0 0.5em; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0 0 0.75em; }
a { color: inherit; text-decoration: none; }

.muted { color: var(--text-dim); font-size: 0.875rem; }
.warn { color: var(--warn); }
.empty { color: var(--text-dim); padding: 2rem; text-align: center; }
.empty--big { font-size: 1.5rem; padding: 4rem 2rem; }
.tiny { font-size: 0.7rem; color: var(--text-dim); }

/* ---------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 8px 14px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.topbar__brand { display: flex; align-items: baseline; gap: 10px; }
.topbar__logo { font-weight: 800; letter-spacing: 0.08em; color: var(--accent); }
.topbar__outlet { font-size: 0.85rem; color: var(--text-dim); }

.topbar__nav { display: flex; gap: 4px; margin-left: auto; }

.navlink {
  padding: 10px 16px;
  border-radius: var(--radius);
  color: var(--text-dim);
  font-weight: 600;
  min-height: var(--touch);
  display: flex;
  align-items: center;
}
.navlink--active { background: var(--bg-sunken); color: var(--text); }

.topbar__right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topbar__user { font-size: 0.875rem; color: var(--text-dim); }

.main { flex: 1; min-height: 0; overflow: auto; }

/* --------------------------------------------------------- status pill */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
}
.pill__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill--ok { color: var(--ok); }
.pill--warn { color: var(--warn); }
.pill--bad { color: var(--danger); border-color: var(--danger); }

/* ------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch);
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--bg-sunken);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  /* Kills the 300ms tap delay and the grey flash on iOS. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--primary); color: var(--primary-ink); }
.btn--accent { background: var(--accent); color: var(--accent-ink); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--text-dim); }
.btn--sm { min-height: 36px; padding: 6px 12px; font-size: 0.85rem; }
.btn--lg { min-height: 56px; font-size: 1.05rem; }
.btn--wide { width: 100%; }

.iconbtn {
  min-width: var(--touch);
  min-height: var(--touch);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.iconbtn--danger { color: var(--danger); border-color: var(--danger); }

/* Chips wrap onto a new row rather than running off the right-hand edge.
   They used to scroll horizontally with the scrollbar hidden, which on a
   touch screen means a category exists but nothing on screen says so.
   Capped so a long category list cannot squeeze the tile grid to nothing --
   the grid below is `flex: 1`, so it yields whatever this takes. */
.chiprow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
  max-height: 33vh;
  overflow-y: auto;
}

.chip {
  flex: 0 0 auto;
  min-height: var(--touch);
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--text-dim);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.chip--active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* --------------------------------------------------------------- login */

.screen-login { justify-content: center; align-items: center; }
.login { display: grid; place-items: center; width: 100%; padding: 24px; }
.login__card {
  width: min(420px, 100%);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
}
.login__brand { text-align: center; letter-spacing: 0.1em; color: var(--accent); }
.login__brand span { color: var(--text-dim); margin-left: 6px; }
.login__error {
  background: rgba(207, 90, 78, 0.15);
  border: 1px solid var(--danger);
  color: #ffc9c3;
  padding: 10px 14px;
  border-radius: var(--radius);
}

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 0.8rem; color: var(--text-dim); margin-bottom: 6px; }
.field input {
  width: 100%;
  min-height: var(--touch);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  color: var(--text);
  font: inherit;
  font-size: 1.25rem;
  letter-spacing: 0.15em;
}

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.key {
  min-height: 60px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.key--muted { color: var(--text-dim); }
.key--go { background: var(--primary); color: #fff; }

/* --------------------------------------------------------------- floor */

.floor { padding: 16px; }
.floor__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.floor__stat { color: var(--text-dim); }
.floor__stat strong { color: var(--text); font-size: 1.2rem; }
.floor__actions { display: flex; gap: 8px; }

.area { margin-bottom: 28px; }
.area__name { color: var(--text-dim); font-size: 0.85rem; text-transform: uppercase;
              letter-spacing: 0.08em; }

/* Tables are placed on a grid from their stored pos_x/pos_y, so the on-screen
   layout matches the room. Auto-flow keeps unplaced tables visible. */
.area__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  grid-auto-rows: 60px;
  gap: 8px;
}

.table {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-raised);
  padding: 6px;
  text-align: center;
  min-height: var(--touch);
}
.table__code { font-size: 1.15rem; font-weight: 700; }
.table__meta { font-size: 0.72rem; color: var(--text-dim); }
.table__server { font-size: 0.68rem; color: var(--text-dim); }

/* Status is carried by border colour *and* by the text inside, never colour
   alone. */
.table--free { border-color: var(--line); opacity: 0.75; }
.table--seated { border-color: var(--primary); background: rgba(61, 126, 166, 0.12); }
.table--occupied { border-color: var(--ok); background: rgba(79, 157, 105, 0.12); }
.table--bill_printed { border-color: var(--accent); background: rgba(232, 179, 58, 0.14); }
.table--part_paid { border-color: var(--warn); background: rgba(217, 154, 43, 0.14); }

.ticketlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.ticketcard {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-raised);
}
.ticketcard__number { font-weight: 700; }
.ticketcard__type { font-size: 0.75rem; color: var(--text-dim); }
.ticketcard__total { font-weight: 600; color: var(--accent); }

/* --------------------------------------------------------------- order */

.screen-order .main { overflow: hidden; }

.order {
  display: grid;
  grid-template-columns: 1fr 380px;
  height: 100%;
  min-height: 0;
}

.order__menu { display: flex; flex-direction: column; min-height: 0; padding: 12px; gap: 10px; }
.order__search input {
  width: 100%;
  min-height: var(--touch);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  color: var(--text);
  font: inherit;
}

.tilegrid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  grid-auto-rows: 92px;
  gap: 10px;
  padding-bottom: 24px;
  -webkit-overflow-scrolling: touch;
}

.tile {
  --tile-accent: var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--tile-accent);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
.tile__name { font-weight: 600; font-size: 0.95rem; }
.tile__price { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; }
.tile__flag { font-size: 0.68rem; color: var(--danger); }
.tile--unavailable { opacity: 0.45; }

.order__ticket {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--bg-raised);
}
.ticket__head { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
                border-bottom: 1px solid var(--line); }
.ticket__head h2 { margin: 0; font-size: 1rem; }

.ticket__lines { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; }

.cartline {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  grid-template-areas: "qty body total" "act act act";
  gap: 6px 8px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}
.cartline__qty { grid-area: qty; font-weight: 700; font-variant-numeric: tabular-nums; }
.cartline__body { grid-area: body; min-width: 0; }
.cartline__name { font-weight: 600; }
.cartline__mods, .cartline__note { font-size: 0.78rem; color: var(--text-dim); }
.cartline__note { font-style: italic; }
.cartline__total { grid-area: total; font-variant-numeric: tabular-nums; font-weight: 600; }
.cartline__actions { grid-area: act; display: flex; gap: 6px; justify-content: flex-end; }
/* A sent line is visually distinct: changing it is a kitchen event, not an edit. */
.cartline--sent { border-left: 3px solid var(--ok); padding-left: 5px; }

.ticket__totals { padding: 10px 14px; border-top: 1px solid var(--line); }
.totals__row { display: flex; justify-content: space-between; padding: 3px 0;
               font-variant-numeric: tabular-nums; color: var(--text-dim); }
.totals__row--grand { color: var(--text); font-size: 1.3rem; font-weight: 700;
                      border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; }
.totals__row--paid { color: var(--ok); }
.totals__row--due { color: var(--accent); font-weight: 700; }
.totals__row--change { color: var(--accent); font-weight: 700; font-size: 1.15rem;
                       border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 8px; }

/* ------------------------------------------------------------- settling */

.paysum { margin-bottom: 14px; }
.paysum__row { display: flex; justify-content: space-between; align-items: baseline;
               padding: 4px 0; color: var(--text-dim);
               font-variant-numeric: tabular-nums; }
.paysum__row--due { color: var(--text); font-size: 1.7rem; font-weight: 700;
                    border-top: 1px solid var(--line); padding-top: 10px; }

.payfield { display: block; margin: 12px 0; }
.payfield span { display: block; font-size: 0.75rem; color: var(--text-dim);
                 text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
/* Money is typed on a tablet in a hurry, so the box is big and the digits
   line up under each other. */
.payfield .input { width: 100%; font-size: 1.35rem; min-height: 52px;
                   font-variant-numeric: tabular-nums; }

.chiprow--quick { margin: -4px 0 4px; }
.chiprow--quick .chip { font-variant-numeric: tabular-nums; }

.paychange { margin: 10px 0 0; min-height: 1.4em; font-weight: 700;
             font-variant-numeric: tabular-nums; }
.paychange--change { color: var(--accent); font-size: 1.25rem; }
.paychange--part { color: var(--warn); font-weight: 600; }

@media (max-width: 520px) {
  .modal__panel--pay .modal__foot { flex-direction: column-reverse; }
  .modal__panel--pay .modal__foot .btn { width: 100%; }
}

.ticket__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; }
/* Secondary full-width row under the two primary buttons. */
.ticket__actions .btn--wide { grid-column: 1 / -1; }

/* --------------------------------------------------------------- modal */

.modal { position: fixed; inset: 0; display: none; place-items: center;
         background: rgba(0, 0, 0, 0.6); z-index: 50; padding: 16px; }
.modal--open { display: grid; }
.modal__panel {
  width: min(560px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.modal__head { display: flex; align-items: center; justify-content: space-between;
               padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal__head h3 { margin: 0; }
.modal__body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.modal__foot { display: flex; gap: 10px; justify-content: flex-end;
               padding: 12px 16px; border-top: 1px solid var(--line); }

.modgroup { margin-bottom: 18px; }
.modgroup h4 { font-size: 0.85rem; color: var(--text-dim); text-transform: uppercase;
               letter-spacing: 0.06em; }
.req { color: var(--danger); font-size: 0.72rem; }
.modgroup__opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }

.opt {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: var(--touch);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.opt em { font-style: normal; color: var(--accent); font-size: 0.8rem; }
.opt--on { border-color: var(--primary); background: rgba(61, 126, 166, 0.2); }

/* ----------------------------------------------------------------- kds */

.kds { padding: 12px; }
.kds__bar { display: flex; align-items: center; justify-content: space-between;
            gap: var(--gap); margin-bottom: 12px; }
.kds__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }

.kticket {
  border: 1px solid var(--line);
  border-top: 4px solid var(--primary);
  border-radius: var(--radius);
  background: var(--bg-raised);
  overflow: hidden;
}
/* Late tickets pulse: a kitchen screen is watched from across the room and
   peripheral vision detects motion long before it detects colour. */
.kticket--late { border-top-color: var(--danger); animation: nudge 2s ease-in-out infinite; }
@keyframes nudge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(207, 90, 78, 0); }
  50% { box-shadow: 0 0 0 4px rgba(207, 90, 78, 0.35); }
}
@media (prefers-reduced-motion: reduce) {
  .kticket--late { animation: none; border-top-width: 8px; }
}

.kticket__head { display: flex; align-items: center; gap: 8px; padding: 10px 12px;
                 border-bottom: 1px solid var(--line); }
.kticket__number { font-weight: 800; font-size: 1.1rem; }
.kticket__where { color: var(--text-dim); font-size: 0.85rem; }
.kticket__age { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700; }

.kticket__lines { list-style: none; margin: 0; padding: 0; }
.kline { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px;
         border-bottom: 1px solid var(--line); }
.kline:last-child { border-bottom: 0; }
.kline__qty { font-weight: 800; font-size: 1.15rem; min-width: 28px; }
.kline__name { flex: 1; font-size: 1.05rem; }
.kline__mod, .kline__note { display: block; font-style: normal; font-size: 0.82rem;
                            color: var(--accent); }
.kline__note { color: var(--warn); }
.kline--ready { opacity: 0.6; }

/* ------------------------------------------------------------- panels */

.panel { max-width: 720px; margin: 24px auto; padding: 24px; background: var(--bg-raised);
         border: 1px solid var(--line); border-radius: var(--radius-lg); }
.panel--wide { max-width: 1100px; }
.panel--center { text-align: center; }
.panel__head { display: flex; justify-content: space-between; align-items: flex-start;
               gap: var(--gap); flex-wrap: wrap; margin-bottom: 18px; }
.panel__nav { display: flex; gap: 6px; flex-wrap: wrap; }
.stack { display: grid; gap: 10px; }

.statrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
           gap: 10px; margin-bottom: 22px; }
.stat { background: var(--bg-sunken); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 12px; }
.stat span { display: block; font-size: 0.75rem; color: var(--text-dim); }
.stat strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 22px; }
.table { width: 100%; border-collapse: collapse; }
table.table td { padding: 7px 4px; border-bottom: 1px solid var(--line);
                 font-variant-numeric: tabular-nums; }
table.table td:last-child { text-align: right; }
table.table tr.grand td { font-weight: 700; font-size: 1.1rem; border-bottom: 0; }

/* ------------------------------------------------------------- receipt */

.receipt-page { padding: 20px; display: grid; justify-items: center; gap: 16px; }
.receipt-page__actions { display: flex; gap: 10px; }

.receipt {
  /* 80mm thermal roll, minus printer margins. */
  width: 72mm;
  background: #fff;
  color: #000;
  padding: 6mm 4mm;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.35;
}
.receipt h1 { font-size: 14px; text-align: center; margin: 6px 0; letter-spacing: 0.1em; }
.receipt pre { font-family: inherit; white-space: pre-wrap; margin: 0; text-align: center; }
.receipt__meta { margin: 8px 0; border-top: 1px dashed #000; border-bottom: 1px dashed #000;
                 padding: 6px 0; }
.receipt__meta div { display: flex; justify-content: space-between; }
.receipt__lines { width: 100%; border-collapse: collapse; margin: 6px 0; }
.receipt__lines td { vertical-align: top; padding: 2px 0; }
.receipt__lines .qty { width: 22px; }
.receipt__lines .amt { text-align: right; white-space: nowrap; }
.receipt__lines .mod { padding-left: 8px; font-size: 10px; }
.receipt__totals { width: 100%; border-top: 1px dashed #000; margin-top: 6px; padding-top: 4px; }
.receipt__totals td { padding: 2px 0; }
.receipt__totals td:last-child { text-align: right; }
.receipt__totals tr.grand td { font-weight: 700; font-size: 13px; border-top: 1px solid #000; }
.receipt__footer { margin-top: 10px; text-align: center; border-top: 1px dashed #000; padding-top: 6px; }
.receipt__footer .tiny { color: #555; }

@media print {
  /* Print the receipt alone: no chrome, no buttons, no page background. */
  body { background: #fff; padding: 0; }
  .topbar, .no-print, .toast-host, .panel__nav { display: none !important; }
  .receipt-page { padding: 0; }
  .receipt { width: auto; padding: 0; }
  .panel { border: 0; margin: 0; background: #fff; color: #000; }
  table.table td { border-color: #ccc; }
}

/* -------------------------------------------------------------- toasts */

.toast-host { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
              display: grid; gap: 8px; z-index: 100; pointer-events: none; }
.toast {
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: rise 0.2s ease-out;
}
.toast--ok { border-color: var(--ok); }
.toast--warn { border-color: var(--warn); }
.toast--error { border-color: var(--danger); }
.toast--leaving { opacity: 0; transition: opacity 0.3s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* --------------------------------------------------------------- stock */

.stock { padding: 20px; max-width: 1200px; margin: 0 auto; }
.stock__head h1 { margin: 0 0 2px; font-size: 1.4rem; }
.stock h2 { font-size: 1rem; margin: 26px 0 10px; color: var(--text-dim);
            text-transform: uppercase; letter-spacing: 0.06em; }

.stock__alerts { margin-top: 16px; }
.stock__chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.chip--warn { border-color: var(--warn); color: var(--warn); }
.chip--bad { border-color: var(--danger); color: var(--danger); }

.banner { border-radius: var(--radius); padding: 10px 14px; margin: 14px 0; }
.banner--ok { border: 1px solid var(--ok); color: var(--ok); }
.banner--bad { border: 1px solid var(--danger); color: var(--danger); }

/* The data-table rules above right-align only the last cell, which is wrong
   once a row ends in a form. Quantities opt in with .num instead. */
table.table th { text-align: left; padding: 7px 4px; font-size: 0.75rem;
                 color: var(--text-dim); text-transform: uppercase;
                 letter-spacing: 0.05em; border-bottom: 1px solid var(--line); }
table.table td.num, table.table th.num { text-align: right; }
/* Scoped to this screen only: the cash-up report still wants its last column
   right-aligned, because there the last column is always money. */
.stock table.table td:last-child { text-align: left; }
table.table--compact td { padding: 4px; font-size: 0.85rem; }
table.table .pos { color: var(--ok); }
table.table .neg { color: var(--danger); }
table.table tr.row--warn td { background: rgba(217, 154, 43, 0.10); }
table.table tr.row--bad td { background: rgba(207, 90, 78, 0.12); }

.stock__form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.input {
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  padding: 8px 10px;
  min-height: 40px;
}
.input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.input--sm { min-height: 34px; padding: 5px 8px; font-size: 0.85rem; max-width: 130px; }

/* ---------------------------------------------------------- responsive */

/* Below 900px the ticket panel stops being a sidebar and becomes a sheet at
   the bottom, which is the only shape that works one-handed on a phone. */
@media (max-width: 900px) {
  .order { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .order__ticket { border-left: 0; border-top: 1px solid var(--line); max-height: 52vh; }
  .topbar__nav { order: 3; width: 100%; margin-left: 0; }
  .topbar { flex-wrap: wrap; }
}

@media (max-width: 520px) {
  .tilegrid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
  .area__grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
}
