/* Staff ordering app (/take-order) — phones and tablets in the restaurant */
:root {
  --brand: #00654b; --brand-dark: #004d39; --brand-soft: #e3f5ee;
  --text: #141c25; --muted: #5b6a63; --line: #e3e9e6; --bg: #f5f7f6; --card: #fff;
  --warn: #b45309; --bad: #b91c1c;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: 'Inter', system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
body { display: flex; flex-direction: column; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
input[type="text"], input[type="tel"], input[type="search"], select, textarea {
  width: 100%; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; font-size: 16px; /* 16px stops iOS zooming */
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,101,75,.12); }
textarea { resize: vertical; }
.to-muted { color: var(--muted); }
.to-pad { padding: 0 16px 12px; }
.to-warn { color: var(--bad); font-weight: 600; font-size: .9rem; margin: 6px 0 0; }

/* ── Top bar ───────────────────────────── */
.to-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--brand); color: #fff; flex-shrink: 0; }
.to-brand { display: flex; flex-direction: column; min-width: 0; }
.to-brand strong { font: 800 1.05rem 'Manrope', sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.to-brand span { font-size: .78rem; opacity: .85; }
.to-bar-actions { display: flex; gap: 6px; flex-shrink: 0; }
.to-bar .to-btn-ghost { color: #fff; border-color: rgba(255,255,255,.4); }
.to-btn-ghost { display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 14px; min-height: 42px; font-weight: 700; font-size: .9rem; text-decoration: none; color: var(--text); }

/* ── Layout ────────────────────────────── */
.to-layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 400px; min-height: 0; }
.to-menu { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.to-menu-tools { padding: 12px 16px 6px; display: grid; gap: 10px; flex-shrink: 0; }
.to-cats { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.to-cats::-webkit-scrollbar { display: none; }
.to-cats button { flex-shrink: 0; border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 16px; font-weight: 700; font-size: .9rem; min-height: 40px; }
.to-cats button.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.to-items { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 16px 120px; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); align-content: start; gap: 10px; }
.to-cat-title { grid-column: 1 / -1; font: 800 1rem 'Manrope', sans-serif; margin: 12px 0 0; }
.to-item { text-align: left; background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 12px; min-height: 92px; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; position: relative; }
.to-item:active { border-color: var(--brand); background: var(--brand-soft); }
.to-item-name { font-weight: 700; line-height: 1.25; }
.to-item-meta { display: flex; justify-content: space-between; align-items: center; font-size: .9rem; color: var(--muted); }
.to-item-price { font-weight: 700; color: var(--text); }
.to-item.out { opacity: .45; }
.to-item .to-in-cart { position: absolute; top: -8px; right: -6px; background: var(--brand); color: #fff; border-radius: 999px; min-width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .85rem; padding: 0 7px; }

/* ── Ticket ────────────────────────────── */
.to-ticket { background: var(--card); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.to-ticket-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 6px; }
.to-ticket-head h2 { font: 800 1.15rem 'Manrope', sans-serif; margin: 0; }
.to-ticket .to-close { display: none; }
.to-ticket-body { flex: 1; overflow-y: auto; padding: 6px 16px 12px; display: flex; flex-direction: column; gap: 12px; }
.to-ticket-foot { border-top: 1px solid var(--line); padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); display: grid; gap: 10px; }

.to-seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 12px; padding: 4px; }
.to-seg button { border: 0; background: transparent; border-radius: 9px; padding: 10px; font-weight: 700; min-height: 44px; }
.to-seg button.active { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12); color: var(--brand); }
.to-fields { display: grid; gap: 8px; }
.to-table-btn { border: 1.5px dashed var(--brand); background: var(--brand-soft); color: var(--brand); border-radius: 10px; padding: 12px; font-weight: 800; min-height: 48px; }
.to-table-btn.set { border-style: solid; }
.to-display-pick { display: flex; align-items: center; gap: 10px; font-size: .85rem; font-weight: 700; color: var(--muted); }
.to-display-pick select { flex: 1; padding: 8px 10px; }

.to-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.to-line { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.to-line-main { cursor: pointer; min-width: 0; }
.to-line-title { font-weight: 700; }
.to-line-mods { font-size: .82rem; color: var(--muted); }
.to-line-note { font-size: .82rem; color: var(--warn); font-weight: 600; }
.to-line-price { font-weight: 700; font-variant-numeric: tabular-nums; }
.to-line .to-stepper { transform: scale(.9); transform-origin: left center; }
.to-empty { text-align: center; padding: 18px 0; margin: 0; }

.to-totals { display: grid; gap: 4px; font-size: .95rem; color: var(--muted); }
.to-totals div { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.to-totals .to-grand { color: var(--text); font: 800 1.35rem 'Manrope', sans-serif; padding-top: 6px; border-top: 1px solid var(--line); margin-top: 4px; }

.to-paid { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: .92rem; }
.to-paid input { width: 22px; height: 22px; accent-color: var(--brand); }
.to-foot-row { display: flex; gap: 10px; }
.to-foot-row .to-send { flex: 1; }
/* With a card reader, Charge card is the main action and Send (unpaid) the secondary one */
.to-send.to-secondary { background: #fff; color: var(--brand); border: 2px solid var(--brand); }
.to-danger { color: var(--bad) !important; }

/* Card reader payment */
.to-charge-box { padding: 28px 22px; text-align: center; align-items: center; gap: 10px; }
.to-charge-box h3 { font: 800 2rem 'Manrope', sans-serif; margin: 0; }
.to-charge-state { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 1.05rem; padding: 10px 0; text-align: left; }
.to-spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--brand-soft); border-top-color: var(--brand); animation: toSpin .9s linear infinite; flex-shrink: 0; }
@keyframes toSpin { to { transform: rotate(360deg); } }
.to-charge-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; width: 100%; margin-top: 6px; }
.to-charge-actions .to-send { flex: 1 1 100%; }
.to-send { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 800; font-size: 1.05rem; min-height: 54px; padding: 0 20px; text-decoration: none; }
.to-send:active { background: var(--brand-dark); }
.to-send[disabled] { opacity: .45; }

.to-stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; }
.to-stepper button { border: 0; background: #fff; width: 44px; height: 44px; font-size: 1.3rem; font-weight: 700; }
.to-stepper span { min-width: 34px; text-align: center; font-weight: 800; }

/* Phone bar */
.to-cartbar { position: fixed; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); display: none; justify-content: space-between; align-items: center; gap: 10px; background: var(--brand); color: #fff; border: 0; border-radius: 16px; padding: 0 18px; min-height: 58px; font-weight: 700; box-shadow: 0 10px 30px rgba(0,60,40,.35); z-index: 20; }

/* ── Sheets ────────────────────────────── */
.to-sheet { position: fixed; inset: 0; background: rgba(20,28,37,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.to-sheet-box { background: #fff; border-radius: 18px; width: 100%; max-width: 520px; max-height: 88vh; max-height: 88dvh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 48px rgba(20,28,37,.25); }
.to-sheet-tall { max-width: 640px; }
.to-sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 18px 8px; }
.to-sheet-head h3 { font: 800 1.25rem 'Manrope', sans-serif; margin: 0; }
.to-sheet-head p { margin: 4px 0 0; font-size: .9rem; }
.to-sheet-body { padding: 8px 18px; overflow-y: auto; }
.to-sheet-foot { display: flex; gap: 12px; padding: 12px 18px 18px; }
.to-sheet-foot .to-send { flex: 1; }
.to-close { border: 0; background: var(--bg); border-radius: 999px; width: 40px; height: 40px; font-size: 1rem; flex-shrink: 0; }

.to-group { border: 0; padding: 0; margin: 0 0 14px; }
.to-group legend { font-weight: 800; margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.to-req { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--warn); background: #fef3c7; border-radius: 999px; padding: 2px 8px; }
.to-req.ok { color: var(--brand); background: var(--brand-soft); }
.to-opt { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1.5px solid var(--line); border-radius: 12px; margin-bottom: 6px; cursor: pointer; }
.to-opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.to-opt input { width: 20px; height: 20px; accent-color: var(--brand); margin: 0; }
.to-opt span { flex: 1; font-weight: 600; }
.to-opt small { color: var(--muted); font-weight: 600; }

.to-table-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; padding-bottom: 18px; }
.to-table-grid button { border: 1.5px solid var(--line); background: #fff; border-radius: 12px; min-height: 64px; font-weight: 800; }
.to-table-grid button.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }

.to-recent { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: center; }
.to-recent-title { font-weight: 800; }
.to-recent-meta { font-size: .82rem; color: var(--muted); }
.to-chip { display: inline-block; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; border-radius: 999px; padding: 2px 8px; background: var(--bg); color: var(--muted); }
.to-chip.due { background: #fef3c7; color: var(--warn); }
.to-chip.paid { background: var(--brand-soft); color: var(--brand); }
.to-recent .to-btn-ghost { min-height: 38px; padding: 6px 12px; }

.to-sent .to-sheet-box { padding: 28px 22px; text-align: center; gap: 10px; align-items: center; }
.to-sent-number { font: 800 clamp(2.4rem, 12vw, 3.6rem)/1 ui-monospace, 'SF Mono', Menlo, monospace; letter-spacing: .05em; color: var(--brand); }
.to-sent .to-send { width: 100%; margin-top: 8px; }

.to-toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: #fff; border-radius: 12px; padding: 10px 18px; font-weight: 700; z-index: 60; max-width: calc(100% - 32px); }
.to-toast.error { background: var(--bad); }
.to-blocker { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; z-index: 70; }
.to-blocker h2 { font: 800 1.5rem 'Manrope', sans-serif; }
.to-blocker p { color: var(--muted); margin-bottom: 20px; }

/* ── Phones: menu full width, order in a sheet ── */
@media (max-width: 860px) {
  .to-layout { grid-template-columns: 1fr; }
  .to-ticket { position: fixed; inset: 0; z-index: 40; border-left: 0; transform: translateY(100%); transition: transform .22s ease; padding-top: env(safe-area-inset-top); }
  body.ticket-open .to-ticket { transform: none; }
  .to-ticket .to-close { display: block; }
  .to-cartbar:not([hidden]) { display: flex; }
  .to-items { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .to-sheet { align-items: flex-end; padding: 0; }
  .to-sheet-box { border-radius: 18px 18px 0 0; max-width: none; padding-bottom: env(safe-area-inset-bottom); }
  .to-sent .to-sheet-box { border-radius: 18px 18px 0 0; }
}
