/* The till. A tablet on the counter, landscape, touched with a thumb in a hurry.
   Everything tappable is at least 56px. Basket on the right on a tablet,
   a bar at the bottom on a phone. */
:root {
  --ink: #1c1a17;
  --paper: #f4efe7;
  --card: #fff;
  --accent: #b3541e;
  --accent-ink: #fff;
  --muted: #8a8378;
  --line: #e2dbcf;
  --band: #e4ded3;        /* the grey category band */
  --band-line: #d3ccbf;
  --good: #2f7a3d;
  --bad: #b3261e;
  --basket-w: 380px;
  --r: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
input { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:active { transform: scale(.97); }
h2 { margin: 0; font-size: 1.1rem; }

/* ── login ── */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--card); border-radius: 20px; padding: 28px; display: grid; gap: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.08); }
.login-brand { font-weight: 800; letter-spacing: .12em; font-size: 1.4rem; text-align: center; }
.login-card label { min-width: 0; display: grid; gap: 6px; color: var(--muted); font-size: .9rem; }
.login-card input { width: 100%; min-width: 0; font-size: 1.15rem; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); }
.big { height: 56px; border-radius: 14px; background: var(--ink); color: var(--paper); font-weight: 700; font-size: 1.05rem; }
.err { color: var(--bad); margin: 0; }

/* ── shell ── */
.app { height: 100%; display: flex; flex-direction: column; }
.bar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 16px 8px;
  background: var(--ink); color: var(--paper);
}
.tabs { display: flex; gap: 4px; background: rgba(255,255,255,.08); padding: 4px; border-radius: 12px; }
.tab { height: 44px; padding: 0 20px; border-radius: 9px; font-weight: 600; color: rgba(255,255,255,.7); }
.tab.on { background: var(--paper); color: var(--ink); }
.pill { display: inline-block; min-width: 22px; padding: 1px 7px; border-radius: 11px; background: var(--accent); color: #fff; font-size: .8rem; }
.banner { flex: 1; text-align: center; font-weight: 700; color: #ffd27a; }
#day-btn { margin-left: auto; }
#day-btn + .who { margin-left: 0; }
.who { height: 44px; padding: 0 14px; border-radius: 10px; background: rgba(255,255,255,.08); color: var(--paper); font-weight: 600; white-space: nowrap; }

/* ── order view ── */
.order { flex: 1; min-height: 0; display: flex; }
.menu { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.search { position: relative; margin: 12px 16px 0; }
.search svg { position: absolute; left: 16px; top: 50%; width: 22px; height: 22px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; }
.search input {
  width: 100%; height: 56px; padding: 0 52px; font-size: 1.15rem;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--card); color: var(--ink);
  -webkit-appearance: none; appearance: none;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search input::-webkit-search-cancel-button { display: none; }
.q-clear { position: absolute; right: 6px; top: 6px; width: 44px; height: 44px; font-size: 1.6rem; color: var(--muted); }

.cats { display: flex; gap: 8px; padding: 12px 16px; overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
.cats::-webkit-scrollbar { display: none; }
.cat { height: 44px; padding: 0 18px; border-radius: 22px; background: var(--card); border: 1px solid var(--line); font-weight: 600; white-space: nowrap; }
.cat.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.grid {
  flex: 1; overflow-y: auto; padding: 0 16px 24px;
  display: grid; gap: 10px; align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  /* min-content, not auto: in a scrolling grid shorter than its content, auto
     rows shrink to each tile's min-height and long names spill out. */
  grid-auto-rows: min-content;
}
.group { grid-column: 1 / -1; margin: 10px 0 0; color: var(--muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.dish {
  position: relative; min-height: 92px; padding: 12px 14px; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  display: flex; flex-direction: column; justify-content: space-between; gap: 8px;
}
.dish .n { font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; hyphens: auto; }
.dish .p { color: var(--muted); font-variant-numeric: tabular-nums; }
.dish .c {
  position: absolute; top: -8px; right: -6px; min-width: 30px; height: 30px; padding: 0 8px;
  border-radius: 15px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 800; font-size: .95rem;
}
.dish.alt { background: var(--band); border-color: var(--band-line); }
.group.alt { color: #6f685d; }
.dish .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 0; }
.dish .minus {
  flex-shrink: 0; width: 48px; height: 44px; margin: -6px -6px -6px 0; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.7rem; font-weight: 700; line-height: 1;
  background: var(--ink); color: var(--paper);
}
.dish .minus:active { transform: scale(.92); }
.dish.in { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.dish.out { opacity: .45; background: transparent; }
.dish.out .p::after { content: " · " attr(data-out); color: var(--bad); font-weight: 600; }
.dish.pop { animation: pop .18s ease-out; }
@keyframes pop { 50% { transform: scale(.95); } }
.nothing { grid-column: 1 / -1; color: var(--muted); padding: 40px 0; text-align: center; }

/* ── basket ── */
.basket {
  width: var(--basket-w); flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--card); border-left: 1px solid var(--line);
}
.basket-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 16px 8px; }
.link { margin-left: auto; color: var(--bad); font-weight: 600; height: 40px; padding: 0 8px; }
.lines { list-style: none; margin: 0; padding: 0 8px; flex: 1; overflow-y: auto; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.line .n { font-weight: 600; overflow-wrap: anywhere; }
.line .lp { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.qty { display: flex; align-items: center; gap: 2px; grid-row: span 2; }
.qty button { width: 48px; height: 48px; border-radius: 12px; background: var(--paper); font-size: 1.5rem; font-weight: 600; }
.qty b { min-width: 30px; text-align: center; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); text-align: center; padding: 32px 16px; margin: 0; }
.basket-foot { padding: 12px 16px calc(env(safe-area-inset-bottom, 0px) + 16px); display: grid; gap: 10px; border-top: 1px solid var(--line); }
.row2 { display: flex; gap: 8px; }
.table-btn { height: 56px; padding: 0 16px; border-radius: 12px; background: var(--paper); font-weight: 600; white-space: nowrap; }
.table-btn b { font-size: 1.2rem; margin-left: 4px; }
.table-btn.set { background: var(--ink); color: var(--paper); }
.note { flex: 1; min-width: 0; height: 56px; padding: 0 14px; font-size: 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); }
.send {
  height: 68px; border-radius: 16px; background: var(--accent); color: var(--accent-ink);
  font-size: 1.25rem; font-weight: 800; letter-spacing: .04em;
  display: flex; justify-content: space-between; align-items: center; padding: 0 22px;
}
.sends { display: flex; gap: 8px; }
.sends .send { flex: 1; font-size: 1.1rem; padding: 0 16px; gap: 10px; white-space: nowrap; }
.tab-send { flex: 0 0 38%; height: 68px; border-radius: 16px; background: var(--ink); color: var(--paper); font-weight: 700; font-size: .95rem; line-height: 1.15; padding: 0 10px; }
.tab-send:disabled { background: var(--line); color: var(--muted); }
.send:disabled { background: var(--line); color: var(--muted); }
.total { font-variant-numeric: tabular-nums; }

.basket-bar {
  position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  height: 64px; border-radius: 16px; background: var(--accent); color: #fff;
  display: flex; justify-content: space-between; align-items: center; padding: 0 20px;
  font-weight: 800; font-size: 1.1rem; box-shadow: 0 8px 24px rgba(0,0,0,.2);
}

/* ── queue ── */
.queue { flex: 1; overflow-y: auto; padding: 16px; }
.orders { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); align-items: start; }
.ticket { background: var(--card); border-radius: var(--r); border: 1px solid var(--line); padding: 14px; display: grid; gap: 10px; }
.ticket.new { border: 2px solid var(--accent); }
.t-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.t-code { font-size: 1.4rem; font-weight: 800; letter-spacing: .06em; }
.t-table { font-weight: 800; background: var(--ink); color: var(--paper); border-radius: 8px; padding: 2px 10px; }
.t-meta { color: var(--muted); font-size: .9rem; }
.t-items { margin: 0; padding: 0; list-style: none; }
.t-items li { padding: 3px 0; }
.t-items b { display: inline-block; min-width: 28px; }
.t-note { background: #fff4d6; border-radius: 8px; padding: 6px 10px; }
.status { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 3px 8px; border-radius: 6px; background: var(--paper); }
.status.new { background: var(--accent); color: #fff; }
.status.ready { background: var(--good); color: #fff; }
.t-actions { display: flex; gap: 8px; }
.t-actions button { flex: 1; height: 52px; border-radius: 12px; font-weight: 700; background: var(--paper); }
.t-actions .go { background: var(--good); color: #fff; }
.t-actions .stop { flex: 0 0 auto; padding: 0 14px; color: var(--bad); }

/* ── open tables ── */
.tablesv { flex: 1; overflow-y: auto; padding: 16px; }
.hint { color: var(--muted); margin: 0 0 12px; }
.floor { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.ftable { min-height: 120px; border-radius: 18px; background: var(--card); border: 2px dashed var(--line); padding: 14px; display: flex; flex-direction: column; justify-content: space-between; text-align: left; }
.ftable .no { font-size: 2rem; font-weight: 800; line-height: 1; }
.ftable .st { color: var(--muted); font-size: .9rem; }
.ftable.open { background: var(--ink); color: var(--paper); border: 2px solid var(--ink); }
.ftable.open .st { color: rgba(255,255,255,.7); }
.ftable.open .sum { font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.ftable.busy { border-style: solid; }
.bill { list-style: none; margin: 0; padding: 0; max-height: 45vh; overflow-y: auto; }
.bill li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bill li b { min-width: 30px; }
.bill li span { flex: 1; }
.bill li i { font-style: normal; font-variant-numeric: tabular-nums; }
.bill-total { display: flex; justify-content: space-between; font-size: 1.3rem; font-weight: 800; }
.wide.pay { background: var(--accent); color: #fff; }
.tno.tab { background: var(--ink); color: var(--paper); }
.tno small { display: block; font-size: .7rem; font-weight: 600; opacity: .8; }

/* ── sheets ── */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(28,26,23,.45); display: grid; place-items: center; padding: 16px; }
.sheet-card { width: min(560px, 100%); background: var(--card); border-radius: 20px; padding: 20px; display: grid; gap: 14px; }
.sheet-card.small { width: min(400px, 100%); }
.sheet-card.small p { margin: 0; font-size: 1.1rem; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.x { width: 44px; height: 44px; font-size: 1.8rem; color: var(--muted); }
.table-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.tno { position: relative; aspect-ratio: 1; min-height: 56px; border-radius: 14px; background: var(--paper); font-size: 1.4rem; font-weight: 800; }
.tno.busy::after { content: ""; position: absolute; top: 8px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.tno.on { background: var(--ink); color: var(--paper); }
.wide { height: 56px; border-radius: 14px; background: var(--paper); font-weight: 700; flex: 1; }
.ghost { background: var(--paper); }
.danger { background: var(--bad); color: #fff; }

.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 72px); transform: translateX(-50%);
  z-index: 60; background: var(--ink); color: var(--paper); padding: 14px 22px; border-radius: 14px;
  font-weight: 700; font-size: 1.05rem; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: calc(100% - 32px); text-align: center;
}
.toast.good { background: var(--good); }
.toast.bad { background: var(--bad); }

/* ── phone ── */
@media (max-width: 760px) {
  .bar { gap: 5px; padding-left: 8px; padding-right: 8px; }
  .tab { padding: 0 10px; font-size: .95rem; }
  .tab, #day-btn { white-space: nowrap; flex-shrink: 0; }
  .tabs { padding: 3px; gap: 2px; }
  .tab { padding: 0 8px; }
  .pill { min-width: 18px; padding: 0 5px; font-size: .7rem; }
  #day-btn { padding: 0 8px; }
  /* the name shrinks to its first letter in a circle — the tabs need the room */
  #who { width: 44px; padding: 0; flex-shrink: 0; font-size: 0; border-radius: 22px; }
  #who::before { content: attr(data-initial); font-size: 1.05rem; }
  .banner { display: none; }
  .grid { grid-template-columns: repeat(2, 1fr); padding-bottom: 100px; }
  .basket {
    position: fixed; inset: 0; z-index: 40; width: auto; border: 0;
    padding-top: env(safe-area-inset-top, 0px);
    transform: translateY(100%); transition: transform .25s ease;
  }
  .basket.open { transform: none; }
  .table-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 760px) {
  .train-bar { flex-wrap: nowrap; justify-content: space-between; font-size: .85rem; letter-spacing: .02em; }
  .train-bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .train-bar button { flex-shrink: 0; height: 30px; padding: 0 10px; }
}
@media (min-width: 761px) { .basket-bar { display: none !important; } .basket-close { display: none; } }

.help { color: var(--muted); font-size: .8rem; }
.dl { display: grid; place-items: center; text-decoration: none; color: var(--ink); }
#login-key { letter-spacing: .3em; font-size: 1.4rem; text-align: center; }

/* ── closed tables history ── */
.hist-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 28px 0 10px; flex-wrap: wrap; }
.daynav { display: flex; align-items: center; gap: 6px; }
.daynav button { width: 44px; height: 44px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); font-size: 1.4rem; font-weight: 700; }
.daynav button:disabled { opacity: .35; }
.daynav span { min-width: 110px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.hist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.hist li { display: grid; grid-template-columns: 64px 96px 1fr auto; gap: 10px; align-items: center; min-height: 56px; padding: 0 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.hist li:nth-child(even) { background: var(--band); border-color: var(--band-line); }
.hist .h-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.hist .h-t { font-weight: 800; }
.hist .h-meta { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist .h-sum { font-weight: 800; font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .hist li { grid-template-columns: 52px 80px 1fr auto; } .hist .h-meta { display: none; } }

/* ── training mode: impossible to mistake for the real till ── */
.train-btn { height: 48px; border-radius: 12px; background: transparent; border: 2px dashed var(--accent); color: var(--accent); font-weight: 700; }
.train-bar {
  display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
  padding: calc(env(safe-area-inset-top, 0px) + 6px) 12px 6px; font-weight: 800; letter-spacing: .04em; color: #fff;
  background: repeating-linear-gradient(-45deg, #b3541e 0 14px, #9a4515 14px 28px);
}
.train-bar button { height: 32px; padding: 0 14px; border-radius: 9px; background: #fff; color: #9a4515; font-weight: 800; }
body.training .bar { padding-top: 8px; }
