:root {
  --primary: #161682;
  --primary-dark: #0e0e5c;
  --accent: #f59e0b;
  --accent-text: #b45309;
  --bg: #f4f4fb;
  --card: #ffffff;
  --text: #1c1c2e;
  --muted: #6b6b85;
  --radius: 16px;
  --warn-bg: #fff4d6;
  --line: #e4e4ee;
  --on-primary: #fff;
  --danger: #b91c1c;
  --danger-dark: #800018;
  --border: #c9c9dd;
  --track: #e4e4f7;
  --shadow-hover: rgba(22, 22, 130, 0.16);
  --shadow: rgba(22, 22, 130, 0.08);
  /* Text-role tokens: the same as the fill colours in light, lighter on the dark till. */
  --primary-text: var(--primary);
  --danger-text: var(--danger);
  --on-accent: var(--text);
  /* The nav keeps its light colours on the planning views; the dark till gives it a dark bar. */
  --nav-bg: var(--primary);
  --nav-active: var(--primary-dark);
}

/* Dark till: the room is dark and the tablet is glossy; planning views stay light. */
body[data-view="till"]:not([data-till-theme="light"]) {
  color-scheme: dark;
  --bg: #11111f;
  --card: #1d1d35;
  --text: #f5f5ff;
  --muted: #b4b4d0;
  --primary: #5b5bf0;
  --primary-dark: #4646d2;
  --primary-text: #c4c4ff;
  --on-primary: #ffffff;
  --accent: #fbbf24;
  --accent-text: #fcd34d;
  --on-accent: #1c1c2e;
  --danger: #dc2626;
  --danger-text: #ff8a8a;
  --border: #3b3b68;
  --track: #2b2b52;
  --line: #2e2e54;
  --warn-bg: #3a2f10;
  --shadow: rgba(0, 0, 0, 0.45);
  --shadow-hover: rgba(0, 0, 0, 0.6);
  --nav-bg: #1d1d35;
  --nav-active: #2b2b52;
}
/* The viewport scrollbar follows the root element's color-scheme, not the body's. */
html:has(body[data-view="till"]:not([data-till-theme="light"])) { color-scheme: dark; }
body[data-view="till"]:not([data-till-theme="light"]) nav { border-bottom: 1px solid var(--line); }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4;
}

main { max-width: 960px; margin: 0 auto; padding: 16px; }

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px;
  background: var(--nav-bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
nav button {
  flex: 1 1 auto;
  background: transparent;
  color: var(--on-primary);
  border: 0;
  border-radius: var(--radius);
  padding: 10px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
nav .nav-spacer { flex: 0 0 8px; }
nav button.secondary { flex: 0 0 auto; color: var(--on-primary); background: rgba(255, 255, 255, 0.15); font-weight: 500; }
nav button.secondary:hover { background: rgba(255, 255, 255, 0.28); }
nav button.active { background: var(--nav-active); box-shadow: inset 0 -3px 0 var(--accent); }
nav .user { display: flex; align-items: center; gap: 8px; color: var(--on-primary); }
nav .user form { margin: 0; }

/* sign-in */
.signin { max-width: 420px; margin: 48px auto; padding: 24px; text-align: center; background: var(--card); border-radius: var(--radius); box-shadow: 0 2px 8px var(--shadow); }
.signin h1 { margin-top: 0; }
a.button { display: inline-block; padding: 10px 20px; border-radius: var(--radius); background: var(--primary); color: var(--on-primary); font-weight: 600; text-decoration: none; }
a.button:hover { background: var(--primary-dark); }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 2px 8px var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}

button {
  background: var(--primary);
  color: var(--on-primary);
  border: 0;
  border-radius: var(--radius);
  padding: 8px 16px;
  font: inherit;
  cursor: pointer;
}
button:hover { background: var(--primary-dark); }
button.accent { background: var(--accent); color: var(--on-accent); }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.hidden { display: none !important; }

/* notice */
.notice {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--warn-bg); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 16px;
}
.notice button { background: transparent; color: var(--text); padding: 2px 10px; font-size: 1.2rem; }
.notice button:hover { background: rgba(0, 0, 0, 0.06); }

.card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px var(--shadow-hover); }
.add-card:hover, .group-card:hover, .count-card:hover, .targets:hover { transform: none; }
.pop { animation: pop 0.3s ease-out; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
.count { display: inline-block; }
.table-wrap { overflow-x: auto; }

/* inventory */
h2 { margin: 0 0 12px; color: var(--primary-text); }
h3 { color: var(--primary-text); }
p.empty { padding: 16px 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; align-items: start; }
.bev { cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.bev.open { cursor: default; grid-column: span 2; }
.bev h3, .add-card h3 { margin: 0; font-size: 1rem; }
.bev p { margin: 0; }
.bev .stock { font-weight: 700; color: var(--primary-text); }
.muted { color: var(--muted); font-size: 0.875rem; }
.pic {
  width: 100%; aspect-ratio: 4 / 3; border-radius: 12px; background: var(--bg);
  display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--primary-text);
}
.pic img { width: 100%; height: 100%; object-fit: cover; }
.pic svg { width: 50%; height: 50%; }
.pic.broken { flex-direction: column; gap: 4px; }
.pic-error { font-size: 0.75rem; color: var(--danger-text); }
.pill {
  align-self: flex-start; font-size: 0.75rem; font-weight: 600; text-transform: capitalize;
  padding: 2px 10px; border-radius: 999px; background: var(--track); color: var(--primary-text);
}
.pill.spirit, .pill.liqueur { background: #fde8c2; color: #7a4a00; }
.pill.mixer, .pill.juice { background: #d6f0e3; color: #145a36; }
.edit-panel { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; border-top: 1px solid var(--line); padding-top: 12px; cursor: auto; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.875rem; color: var(--muted); }
.field input[type="text"], .field select { width: 100%; }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.stock-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.step-bottle { min-width: 48px; min-height: 48px; padding: 0 12px; font-weight: 700; }
.stock-row input { flex: 1; min-width: 0; }
.unit-label { color: var(--text); }
.toggle { display: flex; }
.toggle button { background: var(--track); color: var(--primary-text); border-radius: 0; padding: 8px 14px; min-height: 48px; }
.toggle button:first-child { border-radius: 10px 0 0 10px; }
.toggle button:last-child { border-radius: 0 10px 10px 0; }
.toggle button.on { background: var(--primary); color: var(--on-primary); }
.error { color: var(--danger-text); margin: 0; min-height: 0; font-size: 0.875rem; }
.error:empty { display: none; }
.actions { display: flex; gap: 8px; justify-content: space-between; }
button.danger { background: var(--danger); }
button.danger:hover { background: var(--danger-dark); }
button.secondary { background: var(--track); color: var(--primary-text); }
.add-card { display: flex; flex-direction: column; gap: 10px; border: 2px dashed var(--border); box-shadow: none; background: transparent; }
@media (max-width: 480px) { .bev.open { grid-column: 1 / -1; } }

/* recipes */
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.recipe { cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.recipe.open { cursor: default; grid-column: span 2; }
.recipe h3 { margin: 0; font-size: 1rem; }
.recipe p { margin: 0; }
.ingredients { margin: 0; padding-left: 18px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 0.875rem; cursor: pointer; align-self: flex-start; position: relative; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .slider { width: 40px; height: 22px; border-radius: 999px; background: var(--border); position: relative; transition: background 0.15s; }
.switch .slider::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--card); transition: transform 0.15s; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::after { transform: translateX(18px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }
.ing-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.field .ing-row select { flex: 1; width: auto; min-width: 0; }
.field .ing-row input[type="text"] { flex: 0 0 5.5em; width: 5.5em; }
textarea { width: 100%; resize: vertical; }
@media (max-width: 480px) { .recipe.open { grid-column: 1 / -1; } }
/* An open card spans two columns, so the 4:3 picture would fill the screen: cap it, cover-cropped. */
.bev.open .pic, .recipe.open .pic { max-height: 180px; }
/* recipes Menu view: offered, prices and till order of every drink at a glance */
table.menu-table { width: 100%; border-collapse: collapse; }
table.menu-table th, table.menu-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.menu-table th { color: var(--muted); font-size: 0.875rem; }
.menu-table input { width: 6em; text-align: right; min-height: 48px; }
.menu-table .ing-line { color: var(--muted); font-size: 0.8125rem; }
.menu-table td.order { white-space: nowrap; }
.menu-table button.move { min-width: 48px; min-height: 48px; padding: 0; }
.menu-table button.move + button.move { margin-left: 8px; }
button.offer { min-width: 88px; min-height: 48px; background: var(--track); color: var(--primary-text); font-weight: 700; }
button.offer.on { background: var(--primary); color: var(--on-primary); }

/* calculator */
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tabs .tab { flex: 1; min-height: 48px; background: var(--track); color: var(--primary-text); font-weight: 600; }
.tabs .tab.active { background: var(--primary); color: var(--on-primary); box-shadow: inset 0 -3px 0 var(--accent); }
.offered-strip { margin-bottom: 16px; }
.offered-strip h3 { margin: 0 0 8px; font-size: 0.875rem; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--card); color: var(--primary-text); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; }
.chip:hover { background: var(--track); }
.chip.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.chip.on:hover { background: var(--primary-dark); }
.calc-body { display: flex; flex-direction: column; gap: 16px; }
.targets h3 { margin: 0 0 8px; font-size: 1rem; }
.target-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.target-row .pic { width: 56px; flex: none; }
.target-name { flex: 1; font-weight: 600; }
.target-row input { width: 5em; text-align: right; }
table.shopping { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
table.shopping th, table.shopping td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.shopping th { color: var(--muted); font-size: 0.875rem; }
table.shopping tr.muted td { color: var(--muted); font-size: inherit; }
table.shopping td.buy { color: var(--accent-text); font-weight: 700; }
.copy-area { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.copy-area p { margin: 0; }
.empty { color: var(--muted); text-align: center; }
.count-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.count-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; }
.count-card .pic { width: 72px; }
.count-name { font-weight: 600; }
.count-card .count { font-size: 2rem; font-weight: 700; line-height: 1.1; color: var(--primary-text); }
.count-card input.count { width: 4em; text-align: center; }
.caption { color: var(--muted); font-size: 0.8125rem; }
.group-card h3 { margin: 0 0 8px; font-size: 1rem; }
.split-labels { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; font-size: 0.9375rem; }
.split-row { margin-bottom: 8px; }
.group-card input[type=range] { width: 100%; accent-color: var(--accent); margin: 8px 0; }
.group-card input[type=range]::-webkit-slider-runnable-track { height: 6px; background: linear-gradient(to right, var(--accent) var(--fill, 100%), var(--track) var(--fill, 100%)); border-radius: 3px; }
.group-card input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; background: var(--accent); border: 2px solid var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.group-card input[type=range]::-moz-range-track { height: 6px; background: linear-gradient(to right, var(--accent) var(--fill, 100%), var(--track) var(--fill, 100%)); border-radius: 3px; }
.group-card input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 2px solid var(--card); }
button.link { background: none; color: var(--primary-text); text-decoration: underline; padding: 4px 0; }
button.link:hover { background: none; color: var(--primary-dark); }
table.needs { width: 100%; border-collapse: collapse; margin-top: 12px; }
table.needs th, table.needs td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.needs th { color: var(--muted); font-size: 0.875rem; }
table.needs tr.short { background: var(--warn-bg); }
table.needs td.shortage { color: var(--accent-text); font-weight: 700; }
/* inventory Count view: one row per beverage, typed in on the morning-after shelf walk */
table.count-table { width: 100%; border-collapse: collapse; }
table.count-table th, table.count-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.count-table th { color: var(--muted); font-size: 0.875rem; }
.count-table input { width: 6em; text-align: right; min-height: 48px; }
.count-table td.now { font-weight: 700; color: var(--primary-text); white-space: nowrap; }
.count-table td.now.negative { color: var(--danger-text); }
.count-table td.steps { white-space: nowrap; }
.count-table .steps button { margin-left: 8px; }
@media (max-width: 480px) {
  .count-table th:nth-child(2), .count-table td:nth-child(2) { display: none; }
}

/* toast */
.toasts {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: max-content; max-width: min(90vw, 480px); pointer-events: none;
}
.toast {
  padding: 10px 16px; border-radius: var(--radius);
  background: var(--primary-dark); color: var(--on-primary); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.toast.error { background: var(--danger); }

/* phone width */
@media (max-width: 480px) {
  main { padding: 12px; }
  .grid { grid-template-columns: 1fr; }
  .count-grid { grid-template-columns: repeat(2, 1fr); }
  nav { padding: 8px 12px; }
  .section-head { flex-wrap: wrap; }
  .chips { gap: 6px; }
  .copy-area textarea { max-width: 100%; }
}

.negative, .bev .stock.negative { color: var(--danger-text); }
.limit-radio { display: inline-flex; align-items: center; gap: 4px; font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.price-fields { display: flex; gap: 12px; flex-wrap: wrap; }
.price-fields .field { flex: 1 1 10em; }
.prices { font-size: 0.875rem; font-weight: 600; color: var(--accent-text); margin: 0; }

/* till: wider than the planning views, for big tablets (app.js sets body[data-view]) */
body[data-view="till"] main { max-width: 1280px; }
.till { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 400px); gap: 16px; align-items: start; }
.till:not(.has-basket) { grid-template-columns: minmax(0, 1fr); }
.till-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.till-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
/* Wide screens: the whole side column (basket, then recent sales) stays in view while the tiles scroll;
   it scrolls inside itself when the recent list is longer than the screen. */
@media (min-width: 769px) {
  .till-side { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
}
.till-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.till-party { display: flex; align-items: baseline; gap: 12px; flex: 1 1 auto; }
.till-party h2 { margin: 0; }
.till-party .revenue { font-size: 1.25rem; font-weight: 700; color: var(--primary-text); }
.till-party .waiting { color: var(--accent-text); font-weight: 700; }
.till-head input { width: 14em; max-width: 100%; }
.badges { display: flex; gap: 6px; }
.badge { padding: 3px 12px; border-radius: 999px; font-size: 0.9375rem; font-weight: 700; color: var(--on-primary); white-space: nowrap; }
.badge.pending { background: var(--accent); color: var(--on-accent); }
.badge.offline, .badge.failed { background: var(--danger); }
.badge.ok { background: var(--track); color: var(--primary-text); }
.no-party { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.no-party p { margin: 0; font-weight: 600; }
.happy-band {
  width: 100%; min-height: 56px; background: var(--accent); color: var(--on-accent);
  font-size: 1.25rem; font-weight: 800; letter-spacing: 0.08em;
}
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tile {
  min-height: 96px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px;
  background: var(--card); color: var(--text); border-radius: var(--radius); box-shadow: 0 2px 8px var(--shadow);
  touch-action: manipulation; text-align: center;
}
.tile:hover { background: var(--card); box-shadow: 0 6px 16px var(--shadow-hover); }
.tile .pic { width: 64px; }
.tile-name { font-weight: 700; }
.tile .price { color: var(--primary-text); font-weight: 600; }
.tile .price.none { color: var(--accent-text); }
.tile .left { font-size: 1rem; font-weight: 700; color: var(--text); }
.tile.low .left { color: var(--danger-text); font-weight: 700; }
/* OUT: dim the tile's contents, but not the red OUT label itself. */
.tile.out > :not(.out-label) { opacity: 0.55; }
.tile .out-label { font-size: 1.5rem; font-weight: 800; color: var(--danger-text); letter-spacing: 0.05em; }
/* Big mode chips for wet fingers; Free sits apart on the right so it is not hit by mistake. */
.till .chips.modes { gap: 16px; }
.till .chip { min-height: 64px; flex: 1 1 auto; font-size: 1.125rem; font-weight: 600; }
.till .chips.modes .chip:last-child { flex: 0 0 auto; margin-left: auto; }
.basket { display: flex; flex-direction: column; gap: 12px; }
.basket p { margin: 0; }
.basket-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.basket-title { font-weight: 700; color: var(--primary-text); }
/* Wide enough for the armed label ("Clear all? tap again 6"), so arming does not move the second tap. */
.till button.clear { min-height: 48px; min-width: 12em; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Fixed height (five 64 px rows + four 12 px gaps + 4 px), then it scrolls: the chips and Sell below
   never move as lines are added, and a line stepped to 0 stays, so no row slides under a finger. */
.basket-lines {
  list-style: none; margin: 0; padding: 0 4px 0 0; display: flex; flex-direction: column; gap: 12px;
  /* Five rows; less on a short wide window, so Sell stays in view without scrolling the side column. */
  height: min(388px, 40vh); min-height: min(388px, 40vh); overflow-y: auto;
}
.basket-lines li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name stepper" "total stepper";
  align-items: center; column-gap: 12px; min-height: 64px; flex: 0 0 auto;
}
.basket-lines .line-name { grid-area: name; font-weight: 600; }
.basket-lines .line-total { grid-area: total; color: var(--muted); }
.basket-lines .stepper { grid-area: stepper; display: flex; align-items: center; gap: 12px; }
.till button.step { width: 56px; height: 56px; min-height: 56px; padding: 0; font-size: 1.75rem; line-height: 1; border-radius: 12px; }
.till button.step.minus { background: var(--track); color: var(--primary-text); }
.till button.step.plus { background: var(--primary); }
.basket-lines .qty { display: inline-block; min-width: 2ch; text-align: center; font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.basket-lines li.zero .line-name, .basket-lines li.zero .line-total, .basket-lines li.zero .qty { color: var(--muted); }
.basket-lines li.zero .step.minus { opacity: 0.4; }
.basket-lines li.empty { color: var(--muted); align-items: start; display: block; }
.basket-foot { display: flex; flex-direction: column; gap: 12px; }
button.sell { min-height: 72px; font-size: 1.5rem; font-weight: 700; width: 100%; }
button.sell.happy { background: var(--accent); color: var(--on-accent); }
.happy-band:hover, button.sell.happy:hover { background: var(--accent); }
button.sell:disabled { opacity: 0.45; cursor: default; }
.recent-wrap h3, .attention-wrap h3 { margin: 0 0 8px; font-size: 1rem; }
.attention-wrap h3 { color: var(--danger-text); }
ul.recent, ul.attention { list-style: none; margin: 0; padding: 0; }
ul.recent li, ul.attention li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
/* Recent row: time, lines, total on the first line; pills and Void (right-aligned) on the second. */
ul.recent li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; }
ul.recent .recent-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
ul.recent .recent-actions button.void, ul.recent .recent-actions .voided-text { margin-left: auto; }
ul.recent .lines, ul.attention .lines { flex: 1 1 10em; }
ul.recent .total, ul.attention .total { font-weight: 700; }
ul.recent li.voided .lines, ul.recent li.voided .total { text-decoration: line-through; color: var(--muted); }
ul.recent .time { color: var(--muted); font-variant-numeric: tabular-nums; }
button.void { padding: 6px 12px; }
.pill.waiting { background: var(--accent); color: var(--on-accent); }
.pill.failed { background: var(--danger); color: var(--on-primary); }
.error-text { color: var(--danger-text); font-size: 0.875rem; flex-basis: 100%; }

@media (max-width: 768px) {
  .till, .till:not(.has-basket) { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  /* The side column dissolves: the basket is fixed at the bottom, the recent list follows the tiles. */
  .till-side { display: contents; }
  /* Room for the fixed basket under the last tiles: 48 px header + 20vh lines + 64 px chips + 72 px Sell
     + gaps and padding ≈ 20vh + 206 px measured; 260 leaves a margin. */
  .till.has-basket { padding-bottom: calc(20vh + 260px); }
  /* "Sold X €" above the fixed basket, not over its Sell button. */
  body[data-view="till"] .toasts { bottom: calc(20vh + 280px); }
  .basket {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 10; gap: 8px;
    border-radius: var(--radius) var(--radius) 0 0; box-shadow: 0 -4px 16px var(--shadow-hover);
  }
  .basket-lines { height: 20vh; min-height: 20vh; }
}

@media (max-width: 480px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .till-head input { width: 100%; }
}
.basket:hover, .no-party:hover { transform: none; }
.tile.pop { animation: tile-pop 0.25s ease-out; }
@keyframes tile-pop { 0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1); } }

/* parties */
.parties-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.parties-list, .parties-detail { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.party-list { display: flex; flex-direction: column; gap: 8px; }
.party-row { display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left; background: var(--card); color: inherit; border-left: 4px solid transparent; }
.party-row.selected { border-left-color: var(--primary-text); }
.party-row:hover, .party-row.selected { background: var(--track); color: var(--text); }
/* The All-parties entry stands apart from the party rows (after .selected, so it keeps its accent). */
.party-row.all { border-left-color: var(--accent); font-weight: 700; }
.party-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.party-nums { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.8125rem; }
.new-party h3 { margin: 0 0 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row input { flex: 1 1 8em; min-width: 0; }
.detail-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-head h2 { margin: 0; flex: 1 1 auto; }
.figures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.figure { display: flex; flex-direction: column; gap: 4px; }
.figure strong { font-size: 1.5rem; }
.expense-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.expense { display: flex; align-items: center; gap: 12px; }
.expense .grow { flex: 1; }
/* Tablet touch targets: at least 48 px. */
.parties-layout button, .parties-layout input { min-height: 48px; }
.expense button { min-width: 48px; }
.parties-detail table { width: 100%; border-collapse: collapse; }
.parties-detail th, .parties-detail td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
tr.voided td { text-decoration: line-through; color: var(--muted); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head h3 { margin: 0; }
/* Analysis: chart ink stays recessive (hairline grid, muted ticks) so the bars carry the data. */
.analysis .chart { width: 100%; height: auto; display: block; }
.analysis .chart-grid { stroke: var(--line); stroke-width: 1; }
.analysis .chart-axis { stroke: var(--border); stroke-width: 1; }
.analysis .chart-tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.analysis .chart-band:hover rect:first-child { fill: var(--track); fill-opacity: 0.5; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; list-style: none; padding: 0; margin: 8px 0 0; font-size: 0.875rem; }
.legend .swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.halves { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.analysis h4 { margin: 16px 0 8px; font-size: 0.9375rem; color: var(--primary-text); }
.top-list { margin: 0; padding-left: 1.5em; max-width: 260px; }
.top-list li { padding: 2px 0; }
.top-list li span.qty { float: right; font-variant-numeric: tabular-nums; }
.analysis td { font-variant-numeric: tabular-nums; }
.figures.two { grid-template-columns: repeat(2, 1fr); margin-top: 16px; }
.analysis .figure { box-shadow: none; border: 1px solid var(--line); }
@media (max-width: 480px) { .halves { grid-template-columns: 1fr; } }
@media (max-width: 768px) {
  .parties-layout { grid-template-columns: 1fr; }
  .figure strong { font-size: 1.125rem; }
}

/* Two-tap confirm (ui.confirmTap): the armed state */
/* Tabular digits on one line: the per-second countdown does not change the button's width. */
button.armed, button.armed:hover { background: var(--accent); color: var(--on-accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
button.link.armed { padding: 4px 10px; text-decoration: none; }
/* The happy-hour band is full width either way: its longer armed label may wrap on a phone. */
.happy-band.armed { white-space: normal; }

.badge.closed { background: var(--muted); color: #fff; }
.hint { color: var(--muted); font-size: 0.8125rem; }

/* Offline: planning views are read-only (body.offline is set by app.js); the till stays usable. */
.offline-banner {
  display: none; margin: 0 0 16px; padding: 10px 14px; border-radius: var(--radius);
  background: var(--warn-bg); border: 1px solid var(--accent); font-weight: 600;
}
body.offline .offline-banner { display: block; }
body.offline .planning > :not(.offline-banner) { pointer-events: none; opacity: 0.6; }

/* Touch targets on the till: at least 48 px tall */
.till button, .till input, .till .chip { min-height: 48px; }
.till button.link, .till button.void { display: inline-flex; align-items: center; justify-content: center; }
.till button.link { padding: 4px 8px; }
/* Wide enough for the armed label with its countdown ("Void 12,50 €? 6", "Really discard? 6"), so
   neither arming nor the per-second tick moves the target of the second tap; tabular digits keep
   the countdown itself one width. */
.till button.void, .till ul.attention button.link { min-width: 11em; white-space: nowrap; font-variant-numeric: tabular-nums; }
