:root {
  --bg: #F5F4F1; --surface: #FFFFFF; --sunk: #EEEBE6; --ink: #1C1917; --muted: #675E57; --line: #E1DCD5;
  --accent: #B23A26; --accent-ink: #FFFFFF; --accent-soft: #F6E3DE; --good: #2E7D4F; --good-soft: #DFF0E6; --warn: #A86400; --warn-soft: #FBEBD2; --bad: #B23A26;
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", sans-serif;
  --body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --top: 56px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #161412; --surface: #201D1A; --sunk: #2A2622; --ink: #F1ECE6; --muted: #A99F97; --line: #38322D;
  --accent: #E46D52; --accent-ink: #1A0F0B; --accent-soft: #3A2420; --good: #6CC08F; --good-soft: #1F3328; --warn: #E3A447; --warn-soft: #3A2E1A; --bad: #E46D52; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #161412; --surface: #201D1A; --sunk: #2A2622; --ink: #F1ECE6; --muted: #A99F97; --line: #38322D;
  --accent: #E46D52; --accent-ink: #1A0F0B; --accent-soft: #3A2420; --good: #6CC08F; --good-soft: #1F3328; --warn: #E3A447; --warn-soft: #3A2E1A; --bad: #E46D52; color-scheme: dark }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { touch-action: manipulation; overscroll-behavior-y: none; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, select, .tlines, .tnote, code { -webkit-user-select: text; user-select: text; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.45; min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
h1 { font-family: var(--display); font-size: 26px; line-height: 1.1; margin: 0; letter-spacing: -.01em; }
h2 { font-family: var(--display); font-size: 20px; margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.msg { margin: 0; color: var(--bad); font-size: 14px; }
.note { margin: 0; font-size: 14px; background: var(--sunk); border-radius: 10px; padding: 10px 12px; }
code { background: var(--sunk); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; font-size: 16px; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 12px; padding: 13px 16px; font-weight: 600; font-size: 16px; width: 100%; }
.btn.auto { width: auto; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.good { background: var(--good); color: #fff; }
.btn.sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .5; cursor: default; }
.iconbtn { background: transparent; border: 0; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--ink); flex: none; }
.iconbtn:hover { background: var(--sunk); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.narrow { max-width: 440px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrapgap { flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; }
.lbl { font-weight: 600; font-size: 14px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; letter-spacing: .12em; color: var(--accent); }

/* top bar */
.top { position: sticky; top: 0; z-index: 20; height: calc(var(--top) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0; display: flex; align-items: center; gap: 4px; background: var(--surface); border-bottom: 1px solid var(--line); }
.toptitle { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; padding-left: 6px; }
.toptitle span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toptitle strong { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 0 6px; }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.conn.off i { background: var(--bad); }
.conn.off { color: var(--bad); }

.view { min-height: calc(100dvh - var(--top)); }
.view.center { display: grid; place-items: center; padding: 24px 16px; min-height: 100dvh; }
.wrap { max-width: 560px; margin: 0 auto; padding: 18px 16px 40px; display: flex; flex-direction: column; gap: 16px; }
.wrap.wide { max-width: 980px; }
.roles { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 640px) { .roles { grid-template-columns: 1fr 1fr; } }
.role { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: grid; grid-template-columns: 36px 1fr; column-gap: 12px; align-items: center; }
.role svg { grid-row: span 2; color: var(--accent); }
.role strong { font-size: 17px; }
.role span { color: var(--muted); font-size: 14px; }
.role:hover { border-color: var(--accent); }

/* floor */
.zonebar, .tabs, .cats { display: flex; gap: 6px; overflow-x: auto; padding: 10px 12px; scrollbar-width: none; background: var(--surface); border-bottom: 1px solid var(--line); }
.zonebar::-webkit-scrollbar, .cats::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }
.zonebar button, .tabs button, .cats button, .chips button { flex: none; border: 1px solid var(--line); background: var(--bg); border-radius: 99px; padding: 7px 14px; font-size: 14.5px; font-weight: 500; }
.zonebar button.on, .tabs button.on, .cats button.on, .chips button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.floorwrap { padding: 12px; overflow: auto; min-width: 0; max-width: 100%; overscroll-behavior: contain; }
.floor { position: relative; width: 100%; margin: 0 auto; aspect-ratio: 10 / 7; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; touch-action: manipulation;
  background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 4% 5.714%; }
.tbl { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 2px solid var(--line); background: var(--bg); border-radius: 10px; font-weight: 600; user-select: none; -webkit-user-select: none; padding: 2px; text-align: center; line-height: 1.1; overflow: hidden; container-type: size; }
.tbl.round { border-radius: 50%; }
.tbl .lab { font-size: clamp(11px, 32cqmin, 26px); }
.tbl .meta { font-size: clamp(9px, 15cqmin, 13px); font-weight: 500; color: var(--muted); }
.tbl.busy { background: var(--accent-soft); border-color: var(--accent); }
.tbl.late { background: var(--warn-soft); border-color: var(--warn); }
.tbl.sel { outline: 3px solid var(--ink); outline-offset: 2px; }
button.tbl { cursor: pointer; }
.legend { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); padding: 0 12px 20px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; border: 2px solid var(--line); background: var(--bg); }
.dot.busy { border-color: var(--accent); background: var(--accent-soft); }
.dot.late { border-color: var(--warn); background: var(--warn-soft); }
.floor.edit .tbl { cursor: grab; touch-action: none; }

/* order */
.orderhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tablebig { font-family: var(--display); font-size: 24px; }
.guests { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); color: var(--ink); }
.stepper button { border: 0; background: transparent; width: 38px; height: 36px; font-size: 20px; }
.stepper b { min-width: 28px; text-align: center; font-variant-numeric: tabular-nums; }
.search { padding: 10px 12px 0; background: var(--surface); }
.cats { position: sticky; top: calc(var(--top) + env(safe-area-inset-top)); z-index: 5; }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; padding: 12px; }
.item { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-height: 76px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; position: relative; }
.item strong { font-size: 15px; line-height: 1.25; }
.item span { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.item .qty { position: absolute; top: 8px; right: 8px; background: var(--accent); color: var(--accent-ink); border-radius: 99px; min-width: 24px; height: 24px; font-size: 13px; font-weight: 700; display: grid; place-items: center; padding: 0 6px; }
.item.out { opacity: .45; }
.item.out span::after { content: ' · sold out'; }
.item:active { transform: scale(.98); }
.sent { padding: 0 12px 120px; display: flex; flex-direction: column; gap: 8px; }
.sent h3 { font-size: 15px; margin: 10px 0 0; }
.cartbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.cartbar .btn { width: auto; flex: 1.2; }
.cartsum { flex: 1; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 6px 12px; font-size: 14px; }
.cartsum span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }

/* tickets */
.tickets { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.ticket { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.ticket.new { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.ticket.void { opacity: .55; }
.ticket.void .tlines { text-decoration: line-through; }
.thead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.thead .tt { font-family: var(--display); font-size: 26px; line-height: 1; }
.tmeta { font-size: 13px; color: var(--muted); }
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; border-radius: 99px; padding: 2px 8px; background: var(--sunk); color: var(--muted); vertical-align: 2px; }
.badge.add { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--good-soft); color: var(--good); }
.badge.red { background: var(--accent-soft); color: var(--accent); }
.tlines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding-top: 8px; }
.tlines li { display: grid; grid-template-columns: 34px 1fr auto; gap: 6px; font-size: 15.5px; }
.tlines li b { font-variant-numeric: tabular-nums; }
.tlines li .opt { grid-column: 2 / 4; font-size: 13.5px; color: var(--muted); margin-top: -4px; }
.tlines li .pr { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; }
.tnote { font-size: 14px; background: var(--warn-soft); border-radius: 8px; padding: 6px 8px; }
.ttotal { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 8px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tact { display: flex; gap: 8px; flex-wrap: wrap; }
.tact .btn { flex: 1; width: auto; }
.tact .badge { align-self: center; }
.count { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-family: var(--body); font-size: 14px; padding: 0 7px; vertical-align: 3px; }
details.help { border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; background: var(--surface); }
details.help summary { cursor: pointer; padding: 12px 0; font-weight: 600; }
details.help[open] { padding-bottom: 14px; }
details.help ol { margin: 0 0 12px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; grid-column: 1 / -1; }

/* sheet */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
.sheet { position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-height: 88dvh; overflow: auto; background: var(--surface); border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; box-shadow: 0 -10px 30px rgba(0,0,0,.15); }
@media (min-width: 700px) { .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: min(560px, 94vw); border-radius: 18px; max-height: 86dvh; } }
.sheet h2 { font-size: 21px; }
.opts { display: flex; flex-direction: column; gap: 12px; }
.optgroup { display: flex; flex-direction: column; gap: 6px; }
.optgroup .chips button span { color: var(--muted); font-size: 13px; margin-left: 4px; }
.optgroup .chips button.on span { color: inherit; opacity: .8; }
.cartlines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.cartlines li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.cartlines li .nm { font-weight: 600; }
.cartlines li .op { font-size: 13px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14.5px; max-width: 92vw; box-shadow: 0 8px 20px rgba(0,0,0,.2); }
#printFrame { position: fixed; width: 0; height: 0; border: 0; left: -10px; top: -10px; }

/* manage */
.mpane { padding: 12px 12px 60px; max-width: 1600px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar .btn { width: auto; }
.lockbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-radius: 12px; background: var(--sunk); font-size: 14.5px; }
.lockbar.locked { background: var(--good-soft); }
.lockbar svg { vertical-align: -3px; margin-right: 6px; }
.panel { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; align-items: end; }
.seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; max-width: 100%; }
.seg button { border: 0; background: var(--bg); padding: 10px 14px; font-size: 15px; white-space: nowrap; min-width: 0; }
.seg button + button { border-left: 1px solid var(--line); }
.panel .wide { grid-column: 1 / -1; }
.panel .wide .seg { display: grid; width: 100%; max-width: 360px; }
.seg button.on { background: var(--ink); color: var(--bg); }
.list { display: flex; flex-direction: column; gap: 8px; }
.mrow { display: grid; grid-template-columns: 1fr 110px auto; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.mrow .nm { font-weight: 600; }
.mrow .sub { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.mrow .sub .btn { width: auto; }
.catblock { display: flex; flex-direction: column; gap: 8px; }
.cathead { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.cathead h3 { margin: 0; font-size: 17px; }
.maptable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.maptable td, .maptable th { border-top: 1px solid var(--line); padding: 5px 6px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.scrollx { overflow-x: auto; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pinpad button { height: 56px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 22px; font-weight: 600; }
.pindots { display: flex; justify-content: center; gap: 10px; height: 18px; }
.pindots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); }
.pindots i.on { background: var(--ink); border-color: var(--ink); }
@media (prefers-reduced-motion: no-preference) { .ticket.new { animation: pop .35s ease-out; } @keyframes pop { from { transform: scale(.97); opacity: .4; } } }

.qr { width: 180px; height: 180px; background: #fff; padding: 8px; border-radius: 10px; }
.qr svg { width: 100%; height: 100%; display: block; }
.linkbox { display: flex; gap: 8px; }
.linkbox input { font-size: 16px; text-overflow: ellipsis; }
.vgrid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 720px) { .vgrid { grid-template-columns: 196px 1fr; } }

.floor .guide { position: absolute; pointer-events: none; background: var(--accent); opacity: .7; z-index: 3; }
.floor .guide.v { top: 0; bottom: 0; width: 1px; }
.floor .guide.h { left: 0; right: 0; height: 1px; }

@media (max-width: 560px) {
  .mrow { grid-template-columns: 1fr 44px; }
  .mrow > div:first-child { grid-column: 1 / -1; }
  .cathead > input { max-width: none !important; flex: 1 1 100%; }
}
.strow { display: grid; grid-template-columns: 1fr auto 44px; gap: 8px; align-items: center; }

/* area resize handles (layout editor) */
.floor .edge { position: absolute; z-index: 4; touch-action: none; }
.floor .edge.e { top: 0; right: 0; bottom: 22px; width: 22px; cursor: ew-resize; }
.floor .edge.s { left: 0; right: 22px; bottom: 0; height: 22px; cursor: ns-resize; }
.floor .edge.se { right: 0; bottom: 0; width: 30px; height: 30px; cursor: nwse-resize; }
.floor .edge.e::after { content: ''; position: absolute; right: 6px; top: 50%; width: 5px; height: 44px; margin-top: -22px; border-radius: 3px; background: var(--muted); opacity: .6; }
.floor .edge.s::after { content: ''; position: absolute; bottom: 6px; left: 50%; height: 5px; width: 44px; margin-left: -22px; border-radius: 3px; background: var(--muted); opacity: .6; }
.floor .edge.se::after { content: ''; position: absolute; right: 6px; bottom: 6px; width: 14px; height: 14px; border-right: 4px solid var(--muted); border-bottom: 4px solid var(--muted); border-radius: 0 0 4px 0; opacity: .7; }
.floor .edge:hover::after, .floor.resizing .edge::after { background-color: var(--accent); border-color: var(--accent); opacity: 1; }
.floor.resizing { outline: 2px dashed var(--accent); outline-offset: -2px; }
.floor.resizing::after { content: attr(data-size); position: absolute; right: 36px; bottom: 36px; background: var(--ink); color: var(--bg); font-size: 13px; padding: 4px 8px; border-radius: 8px; z-index: 5; }
.floor .guide.gap { opacity: 1; background: repeating-linear-gradient(var(--accent) 0 6px, transparent 6px 10px); }
.floor .guide.h.gap { background: repeating-linear-gradient(90deg, var(--accent) 0 6px, transparent 6px 10px); }
