/* Reusable components: page layout, panels, tables, forms, buttons, sheet, lock, toasts */

/* ---------- page layouts (inside .view) ---------- */
.page { flex: 1; min-height: 0; display: grid; gap: 14px; grid-template-rows: auto minmax(0, 1fr); }
.page.rows-3 { grid-template-rows: auto auto minmax(0, 1fr); }
.page.solo { grid-template-rows: minmax(0, 1fr); }
.split { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); min-height: 0; }
.split.wide-left { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.col { min-height: 0; overflow: auto; display: grid; gap: 14px; align-content: start; padding-right: 2px; }

/* Dashboard (manager): chart on the left, the two lists stacked on the right. Each panel scrolls inside itself. */
.dash { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.dash-grid {
  flex: 1; min-height: 0; display: grid; gap: 14px;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  grid-template-rows: repeat(2, minmax(0, 1fr));
}
.dash-grid > .pane-chart { grid-row: 1 / span 2; }
.dash .dash-switch { display: none; } /* outranks .chips, which loads later */

/* side-by-side panels stack (each keeps its own inner scroll) once there is no room for two */
@media (max-width: 900px) {
  .split, .split.wide-left { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(2, minmax(0, 1fr)); }

  /* the Dashboard's three panels become tabs: one at a time, using the full height */
  .dash .dash-switch { display: flex; }
  .dash-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .dash-grid > .panel { grid-row: 1; grid-column: 1; }
  .dash-grid[data-pane="chart"] > :not(.pane-chart),
  .dash-grid[data-pane="attention"] > :not(.pane-attention),
  .dash-grid[data-pane="cost"] > :not(.pane-cost) { display: none; }
}

/* ---------- KPI tiles ---------- */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; min-width: 0; border-left: 3px solid var(--line-strong);
}
.kpi.ok { border-left-color: var(--ok); }
.kpi.warn { border-left-color: var(--warn); }
.kpi.bad { border-left-color: var(--bad); }
.kpi .k { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }
.kpi .v { font-family: var(--font-mono); font-weight: 500; font-size: 1.65rem; line-height: 1.2; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi.ok .v { color: var(--ok); }
.kpi.warn .v { color: var(--warn); }
.kpi.bad .v { color: var(--bad); }
.kpi .s { color: var(--muted); font-size: 0.78rem; margin-top: 1px; }

@media (max-width: 720px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 8px 12px; }
  .kpi .v { font-size: 1.25rem; }
  .kpi .s { display: none; }
  /* the manager Dashboard has five tiles: three across gives two rows, which leaves the chart room to breathe */
  .dash-page .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-page .kpi { padding: 8px 10px; }
  .dash-page .kpi .k { font-size: 0.66rem; letter-spacing: 0.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dash-page .kpi .v { font-size: 1.02rem; }
}
@media (max-width: 400px) { .dash-page .kpi .v { font-size: 0.92rem; } }

/* ---------- panel ---------- */
.panel {
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.panel-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 0.95rem; font-weight: 600; margin-right: auto; }
/* position: relative keeps absolutely-positioned .sr captions inside the panel's clipping */
.panel-body { position: relative; flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.panel-body.pad { padding: 16px; }
.panel.compact .panel-head { border-bottom: 0; }

.muted { color: var(--muted); }
.lead { color: var(--ink); }
.hint { color: var(--muted); font-size: 0.8rem; }
.mono { font-family: var(--font-mono); }

/* ---------- table ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tbl th {
  position: sticky; top: 0; z-index: 1; background: var(--surface);
  text-align: left; padding: 10px 16px; white-space: nowrap;
  color: var(--muted); font-weight: 600; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.07em;
  border-bottom: 1px solid var(--line-strong);
}
.tbl td { padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.tbl .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tbl th.num { font-family: var(--font-body); }
.tbl .act { text-align: right; white-space: nowrap; }
.tbl .strong { font-weight: 600; }
.tbl td.num.strong { font-weight: 500; color: var(--ink); } /* the mono face only has 400 and 500: a heavier weight would be faked and smeared */

/* tablet: tighter cells and drop secondary columns instead of scrolling sideways */
@media (max-width: 1024px) and (min-width: 721px) {
  .tbl th, .tbl td { padding-inline: 10px; }
  .tbl th.gone, .tbl td.gone { display: none; }
  .tbl th.tab-hide, .tbl td.tab-hide { display: none; } /* like .gone, but phones (stacked rows) still show it */
}

@media (max-width: 720px) {
  .tbl.stack thead { display: none; }
  .tbl.stack, .tbl.stack tbody { display: block; }
  .tbl.stack tr { display: block; padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .tbl.stack td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 3px 0; border: 0; text-align: right;
  }
  .tbl.stack td::before { content: attr(data-label); color: var(--muted); font-size: 0.78rem; text-align: left; flex: none; }
  .tbl.stack td[data-label=""]::before { content: none; }
  .tbl.stack td.act { justify-content: flex-end; padding-top: 8px; }
  .tbl.stack td.gone { display: none; }
  .tbl.stack td.strong { font-size: 1rem; }
}

/* ---------- charts (Dashboard trends) ---------- */
.viz-body { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px; }
.viz-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 6px; }
.viz-legend { display: flex; gap: 14px; margin-left: auto; color: var(--muted); font-size: 0.8rem; }
.viz-legend span { display: inline-flex; align-items: center; gap: 6px; }
.viz-legend .sw.bar { width: 10px; height: 10px; border-radius: 2px; background: var(--viz-1); }
.viz-legend .sw.line { width: 14px; height: 2px; border-radius: 2px; background: var(--viz-trend); }

.viz-sum { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.viz-stat { min-width: 0; }
.viz-stat .k { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }
.viz-stat .v { font-weight: 600; font-size: 1.2rem; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viz-stat .s { margin-left: 8px; color: var(--muted); font-size: 0.78rem; font-weight: 400; }

.viz-plot { position: relative; flex: 1; min-height: 130px; outline: none; touch-action: pan-y; }
.viz-plot:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 6px; }
.viz-plot > .empty { height: 100%; align-content: center; justify-items: center; }
.vz { display: block; }
.vz text { font-family: var(--font-mono); font-size: 11px; }
.vz-tick { fill: var(--muted); }
.vz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.vz-axis { stroke: var(--viz-axis); stroke-width: 1; }
.vz-bar { fill: var(--viz-1); }
.vz-bar.hot { fill: var(--viz-1-hot); }
.vz-line, .vz-trend { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.vz-line { stroke: var(--viz-1); }
.vz-trend { stroke: var(--viz-trend); }
.vz-ref { stroke: rgba(255, 255, 255, 0.42); stroke-width: 1; }
.vz-cross { stroke: var(--viz-axis); stroke-width: 1; }
.vz-dot { fill: var(--viz-1); stroke: var(--surface); stroke-width: 2; }
.vz-dot.trend { fill: var(--viz-trend); }
/* labels wear ink, never the series colour; the halo keeps them legible over marks */
.vz-label { fill: var(--ink); stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; paint-order: stroke; }
.vz-label.muted { fill: var(--muted); }

.vz-tip {
  position: absolute; z-index: 3; pointer-events: none; min-width: 150px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line-strong);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45); font-size: 0.82rem;
}
.vz-tip .h { color: var(--muted); font-size: 0.76rem; margin-bottom: 4px; }
.vz-tip .r { display: flex; align-items: center; gap: 8px; }
.vz-tip .key { flex: none; width: 12px; height: 0; border-top: 2px solid var(--viz-1); border-radius: 2px; }
.vz-tip .key.t { border-top-color: var(--viz-trend); }
.vz-tip .v { font-weight: 600; color: var(--ink); }
.vz-tip .n { color: var(--muted); }
.vz-tip .note { margin-top: 4px; color: var(--muted); font-size: 0.76rem; }

.tbl.dense th, .tbl.dense td { padding: 9px 12px; }
.tbl .nowrap { white-space: nowrap; }
.chip.sm { min-height: 30px; padding: 0 12px; font-size: 0.84rem; }

@media (max-width: 720px) {
  /* one-row panel header: the Table/Chart button keeps only its icon (its aria-label still names it) */
  .pane-chart .panel-head { padding: 10px 12px; gap: 8px; }
  .pane-chart .panel-head .btn .lbl { display: none; }
  .pane-chart .panel-head .btn { padding: 0 10px; }
  .pane-chart .panel-head h2 { white-space: nowrap; }
  .pane-chart .panel-head .chip.sm { padding: 0 9px; font-size: 0.8rem; }
  .tbl.dense th { font-size: 0.66rem; letter-spacing: 0.03em; }
  .viz-body { padding: 10px 12px; gap: 8px; }
  .viz-stat .v { font-size: 1.05rem; }
  .viz-stat .s { display: none; }
  .viz-sum { gap: 8px; }
  .tbl.dense th, .tbl.dense td { padding: 8px 6px; font-size: 0.8rem; }
  .tbl.dense th:first-child, .tbl.dense td:first-child { padding-left: 12px; }
}
/* short screens: the summary row goes first, so the chart keeps room and the panel never needs its own scrollbar */
@media (max-height: 640px) { .viz-sum { display: none; } .viz-plot { min-height: 110px; } }
@media (max-width: 720px) and (max-height: 760px) { .viz-sum { display: none; } }
@media (pointer: coarse) { .chip.sm { min-height: 38px; } }

/* ---------- badges, chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  padding: 2px 9px; border-radius: 999px; font-size: 0.74rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  min-height: 34px; padding: 0 14px; border-radius: 999px;
  background: transparent; border: 1px solid var(--line-strong); color: var(--muted); font-weight: 500;
}
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--amber-soft); color: var(--amber); border-color: rgba(242, 169, 59, 0.4); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink);
  font-weight: 600; white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: rgba(255, 255, 255, 0.3); }
.btn.primary { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #1b1d1f; }
.btn.ghost { background: transparent; }
.btn.ghost.danger-text { color: var(--bad); border-color: rgba(242, 120, 106, 0.35); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 0.82rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.danger:hover { color: var(--bad); }
.icon-btn.ok:hover { color: var(--ok); } /* a "done" tick: normal colour like the pencil and bin, and green when pointed at (the bin goes red) */

@media (pointer: coarse) {
  .btn { min-height: var(--tap); }
  .btn.sm { min-height: 38px; }
  .icon-btn { width: var(--tap); height: var(--tap); }
  .chip { min-height: 40px; }
}

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field label { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; }
.field .err { color: var(--bad); font-size: 0.8rem; }
.field.invalid input, .field.invalid select, input.bad, select.bad { border-color: var(--bad); }

input, select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px;
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
input::placeholder { color: #6d767e; }
input[type="checkbox"] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--amber); }
input[type="number"] { font-family: var(--font-mono); }
input[type="date"], input[type="month"] { color-scheme: dark; min-width: 0; max-width: 100%; }
.quickbar > *, .form-grid > * { min-width: 0; }

/* slim, on-brand scrollbars for the panels that scroll internally */
.panel-body, .col, .sheet-body { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.panel-body::-webkit-scrollbar, .col::-webkit-scrollbar, .sheet-body::-webkit-scrollbar { width: 8px; height: 8px; }
.panel-body::-webkit-scrollbar-thumb, .col::-webkit-scrollbar-thumb, .sheet-body::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
select option { background: var(--surface); }
input.inline { width: 96px; min-height: 34px; padding: 4px 8px; text-align: right; }

@media (max-width: 720px) {
  input, select, textarea { font-size: 16px; min-height: var(--tap); } /* 16px stops iOS zoom-on-focus */
  input.inline { min-height: 38px; }
}

.quickbar {
  display: grid; gap: 10px; align-items: end;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.quickbar.compact-form { border-bottom: 0; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: start; } /* start: an error under one field must not stretch its neighbour */
.form-grid .full { grid-column: 1 / -1; }
.form-stack { display: grid; gap: 14px; }
@media (max-width: 720px) {
  .quickbar { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 10px 12px; }
  .quickbar .field:first-child { grid-column: 1 / -1; }
  .quickbar .btn { width: 100%; }
}

/* line editor (recipe rows, order rows) */
.lines { display: grid; gap: 8px; }
.line { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr) 96px 96px auto; align-items: center; }
.line.two { grid-template-columns: minmax(0, 1fr) 110px auto; }
.line.receive { grid-template-columns: minmax(0, 1fr) 96px 96px; }
.line-head { display: grid; gap: 8px; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; grid-template-columns: minmax(0, 1fr) 96px 96px auto; }
.line-head.two { grid-template-columns: minmax(0, 1fr) 110px 36px; }
.line-head.receive { grid-template-columns: minmax(0, 1fr) 96px 96px; }
.preview { display: flex; gap: 16px; flex-wrap: wrap; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--bg); border: 1px dashed var(--line-strong); }
.preview b { font-family: var(--font-mono); font-weight: 500; }

/* ---------- list rows ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.rows .grow { flex: 1; min-width: 0; }
.rows .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .meta { color: var(--muted); font-size: 0.82rem; }
.updates-panel .rows .title { white-space: normal; } /* update titles may wrap instead of being cut off */
.updates { margin: 6px 0 0; padding-left: 18px; font-size: 0.88rem; display: grid; gap: 3px; }

/* inventory reports: a KPI strip inside each report card, and the explanatory note under its table */
.col.rep-col { grid-auto-rows: max-content; } /* each report card keeps its full height and the column scrolls, instead of every card squeezing into its own inner scroll */
/* The cards never scroll themselves, so their bodies must not be scroll areas: a scroll area with overscroll-behavior: contain swallows the mouse wheel and the column would only scroll over a card's title bar. clip keeps the rounded corners without making a scroll area. */
.rep-col .panel { overflow: clip; }
.rep-col .panel-body { overflow: visible; overscroll-behavior: auto; }
/* narrow tablets (e.g. 744px portrait): the seven-column consumable table needs a little less room per cell to stay inside its card */
@media (max-width: 1024px) and (min-width: 721px) {
  .rep-col .tbl { font-size: 0.84rem; }
  .rep-col .tbl th, .rep-col .tbl td { padding-inline: 4px; }
  .rep-col .tbl th:first-child, .rep-col .tbl td:first-child { padding-left: 12px; }
  .rep-col .tbl th:last-child, .rep-col .tbl td:last-child { padding-right: 12px; }
}
.rep-kpis { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.rep-kpis .kpi .v { font-size: 1.35rem; }
.rep-note { padding: 10px 16px 14px; }
.mv-pos { color: var(--ok); }
.mv-neg { color: var(--bad); }
/* tablets and phones: the extra header buttons shrink to their icon (the full name stays as the tooltip and screen-reader label) */
@media (max-width: 980px) {
  .head-actions .btn.compact .lbl { display: none; }
  .head-actions .btn.compact { padding-inline: 10px; }
}
@media (max-width: 480px) { .head-actions .btn .lbl-xs { display: none; } } /* phones: even the primary button keeps only its icon, so the search and lock buttons stay on screen */
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); } .dot.info { background: var(--info); }
a.row-link { text-decoration: none; color: inherit; }
a.row-link:hover .title { color: var(--amber); }

.empty { display: grid; place-items: center; text-align: center; gap: 4px; padding: 36px 20px; color: var(--muted); }
.empty strong { color: var(--ink); font-weight: 600; }

.bar-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 0; font-size: 0.86rem; }
.bar { height: 8px; border-radius: 99px; background: var(--bg); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--amber); border-radius: 99px; }

.shift {
  display: inline-flex; align-items: center; gap: 4px; margin: 2px 4px 2px 0;
  padding: 2px 4px 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
  background: var(--info-soft); color: var(--info);
}
.shift button { border: 0; background: transparent; color: inherit; width: 22px; height: 22px; border-radius: 50%; padding: 0; display: inline-grid; place-items: center; }
.shift button:hover { background: rgba(255, 255, 255, 0.12); }

details.faq { border-bottom: 1px solid var(--line); }
details.faq summary { cursor: pointer; padding: 14px 16px; font-weight: 600; }
details.faq .answer { padding: 0 16px 16px; color: var(--muted); display: grid; gap: 8px; max-width: 70ch; }
details.faq .answer b { color: var(--ink); }

/* ---------- dish pictures ----------
   Every picture sits in a fixed frame, so a picture — or a missing one — never changes a row's height or a table's columns.
   A dish with no picture, or one that cannot be loaded, shows a plate symbol in the same frame. */
.dish-img {
  position: relative; display: inline-grid; place-items: center; flex: none; overflow: hidden; vertical-align: middle;
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
}
.dish-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dish-img .dish-fallback { display: none; width: 56%; height: 56%; stroke-width: 1.6; opacity: 0.8; }
.dish-img.none .dish-fallback { display: block; }
.dish-img.sm { width: 32px; height: 32px; border-radius: 8px; }
.dish-img.lg { width: 56px; height: 56px; border-radius: 12px; }
.dish-img.hero { width: min(100%, 400px); height: auto; aspect-ratio: 4 / 3; margin-inline: auto; border-radius: var(--radius); }
.dish-img.hero .dish-fallback { width: 64px; height: 64px; }
/* a dish's name with its picture, in tables and lists */
.dish-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dish-cell .dish-name { min-width: 0; overflow-wrap: anywhere; }
.link-btn { padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.link-btn:hover { color: var(--amber); }
/* a whole list row that opens something (Dashboard dishes) */
.rows > li.pick { padding: 0; }
button.row-link { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 16px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
button.row-link:hover { background: rgba(255, 255, 255, 0.03); }
button.row-link:hover .title { color: var(--amber); }
@media (max-width: 720px) { .tbl.stack td .dish-cell { justify-content: flex-end; text-align: right; } }

/* dish details */
.dish-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.dish-facts > div { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; min-width: 0; }
.dish-facts .k { color: var(--muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; }
.dish-facts .v { font-family: var(--font-mono); font-weight: 500; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 480px) { .dish-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mini-tbl { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.mini-tbl th { text-align: left; color: var(--muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; padding: 6px 0; border-bottom: 1px solid var(--line-strong); }
.mini-tbl td { padding: 7px 0; border-bottom: 1px solid var(--line); }
.mini-tbl .num { text-align: right; font-family: var(--font-mono); padding-left: 10px; }

/* the dish form's picture: a preview with Choose / Upload / Remove */
.photo-field { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 14px; align-items: center; }
.photo-field .dish-img.hero { width: 132px; margin: 0; }
.photo-field .chips { gap: 8px; }
.field .photo-field label.btn { color: var(--ink); font-size: 0.82rem; font-weight: 600; text-transform: none; letter-spacing: normal; } /* a button, not a field label */
@media (max-width: 420px) { .photo-field { grid-template-columns: minmax(0, 1fr); } .photo-field .dish-img.hero { width: 100%; max-height: 140px; } }

/* Sales: the dishes as picture tiles. They are real radio buttons, so arrow keys, Tab and screen readers work as usual. */
.sale-form { display: grid; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
fieldset.dish-pick { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.dish-pick legend { padding: 0; margin-bottom: 6px; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; }
.dish-tiles { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); max-height: 216px; overflow-y: auto; padding: 3px; margin: -3px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
/* (a tile is a <label> inside a .field, so it undoes the small upper-case field-label style) */
fieldset.dish-pick .dish-tile { position: relative; display: block; min-width: 0; cursor: pointer; color: var(--ink); font-size: 0.92rem; font-weight: 400; text-transform: none; letter-spacing: normal; }
.dish-tile .t-sold { color: var(--info); font-family: var(--font-body); font-weight: 600; }
.dish-tile input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.dish-tile .tile-body {
  display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 7px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--bg);
}
.dish-tile:hover .tile-body { border-color: rgba(255, 255, 255, 0.3); }
.dish-tile input:checked + .tile-body { border-color: var(--amber); background: var(--amber-soft); box-shadow: inset 0 0 0 1px var(--amber); }
.dish-tile input:focus-visible + .tile-body { outline: 2px solid var(--amber); outline-offset: 2px; }
.dish-tile .t-text { display: grid; min-width: 0; flex: 1; }
.dish-tile .t-name { font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dish-tile .t-meta { color: var(--muted); font-size: 0.8rem; font-family: var(--font-mono); }
.dish-tile .badge { flex: none; }
.sale-row { display: grid; gap: 10px; align-items: end; grid-template-columns: minmax(0, 220px) auto; justify-content: start; }
.dish-pick.invalid .tile-body { border-color: var(--bad); }
@media (max-width: 720px) {
  .sale-form { padding: 10px 12px; }
  .dish-tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); max-height: 204px; }
  .dish-tile .tile-body { min-height: 56px; padding: 6px 8px; gap: 8px; }
  .sale-row { grid-template-columns: minmax(0, 1fr) auto; }
}

/* ---------- sheet (side drawer on desktop, bottom sheet on phone) ---------- */
dialog.sheet {
  padding: 0; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  width: min(520px, 100vw); max-width: 100vw; max-height: 100dvh;
  margin: 0 0 0 auto; height: 100dvh; border-radius: 18px 0 0 18px;
}
dialog.sheet[open] { display: flex; flex-direction: column; }
dialog.sheet::backdrop { background: rgba(0, 0, 0, 0.6); }
.sheet-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-family: var(--font-head); font-weight: 400; font-size: 1.7rem; letter-spacing: 0.03em; line-height: 1; }
.sheet-body { flex: 1; min-height: 0; overflow: auto; padding: 20px; display: grid; gap: 16px; align-content: start; }
.sheet-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
/* "You have unsaved changes": shown above the buttons when a tap outside or Esc would have thrown typed work away */
.sheet-note { flex: 1 1 100%; order: -1; color: var(--warn); font-size: 0.86rem; }
.sheet-note:empty { display: none; }
dialog.sheet.nudge { animation: nudge 0.3s; }
@keyframes nudge { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@media (max-width: 720px) {
  dialog.sheet { width: 100%; margin: auto 0 0; height: auto; max-height: 92dvh; border-radius: 18px 18px 0 0; }
  .sheet-body { padding: 16px; }
  .line { grid-template-columns: minmax(0, 1fr) 84px 84px auto; }
  .line.two { grid-template-columns: minmax(0, 1fr) 96px auto; }
}

/* ---------- lock screen ---------- */
.lock {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px;
  overflow-y: auto; /* the setup form can be taller than a phone held sideways: the overlay scrolls, never the page */
  background: radial-gradient(circle at 50% 0%, #2a2d31 0%, var(--bg) 60%);
}
.lock-card { width: min(380px, 100%); display: grid; gap: 14px; text-align: center; }
.lock-card .brand-mark { width: 64px; height: 64px; font-size: 2.6rem; margin: 0 auto; border-radius: 18px; }
.lock-card h1 { font-family: var(--font-head); font-weight: 400; font-size: 2.6rem; letter-spacing: 0.05em; line-height: 1; }
.lock-card .field { text-align: left; }
.lock-card .field input { min-height: 48px; }
.lock-card .lock-hint { text-align: left; margin-top: -8px; }
.lock-card .err { color: var(--bad); min-height: 1.4em; font-size: 0.9rem; }
.lock-card .err:empty { min-height: 0; }
.lock-card.shake { animation: shake 0.3s; }
/* a password box with its show/hide (eye) button */
.pw-wrap { position: relative; display: block; min-width: 0; }
.pw-wrap input { width: 100%; padding-right: 50px; }
.pw-eye {
  position: absolute; top: 0; bottom: 0; right: 0; width: 46px; display: grid; place-items: center;
  border: 0; border-radius: 0 10px 10px 0; background: transparent; color: var(--muted); cursor: pointer;
}
.pw-eye:hover { color: var(--ink); }
.pw-eye[aria-pressed="true"] { color: var(--amber); }
.pw-eye:focus-visible { outline: 2px solid var(--amber); outline-offset: -3px; }
/* a plain checkbox with its label beside it (Remember me) */
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; text-align: left; }
.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--amber); flex: none; }
/* a one-time setup or reset code, shown once to the manager */
.code-big { font-family: var(--font-mono); font-size: 1.8rem; letter-spacing: 0.08em; text-align: center; padding: 14px; border: 1px dashed var(--line-strong); border-radius: 12px; user-select: all; }
.warn-text { color: var(--warn); font-size: 0.9rem; }
/* an on/off switch (a real checkbox, so keyboard and screen readers work): Settings → Notifications */
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; min-height: 44px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 44px; height: 24px; flex: none; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line-strong); transition: background 0.15s; }
.switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform 0.15s, background 0.15s; }
.switch input:checked + .switch-track { background: var(--amber-soft); border-color: rgba(242, 169, 59, 0.5); }
.switch input:checked + .switch-track::after { transform: translateX(20px); background: var(--amber); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--amber); outline-offset: 2px; }
.switch-label { font-weight: 600; }
ul.bullets { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; width: min(420px, calc(100vw - 24px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line-strong); border-left: 4px solid var(--ok);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.toast.error { border-left-color: var(--bad); }
.toast.info { border-left-color: var(--info); }
/* after 7 seconds a message fades out (held while the pointer is on it: ui.toast) */
.toast { transition: opacity 0.4s ease, transform 0.4s ease; }
.toast.leaving { opacity: 0; transform: translateY(6px); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
@media (max-width: 720px) { .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); } }
