/* ==========================================================
   Doce Tentação — ecrã do balcão
   Escuro, letras grandes e um passo de cada vez
   ========================================================== */
:root {
  color-scheme: dark;
  --bg: #120C0C;
  --panel: #1C1515;
  --card: #271D1D;
  --card-2: #332626;
  --text: #F6EFE6;
  --soft: #C9BCB0;
  --faint: #8C7F78;
  --line: #3A2C2A;
  --red: #E3263B;
  --new: #F5B851;
  --prep: #F08A4B;
  --ready: #6CC08C;
  --serve: #6FA8FF;
  --danger: #FF6B6B;
  --f: "Archivo", system-ui, sans-serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 18px/1.45 var(--f); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button[disabled] { opacity: .5; pointer-events: none; }
:focus-visible { outline: 3px solid var(--new); outline-offset: 2px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Entrada e início de turno ---------- */
.gate { min-height: 100%; display: grid; place-items: center; padding: 24px; background: radial-gradient(80% 60% at 50% 0%, #5A1018, var(--bg)); }
.gate__box { width: min(420px, 100%); display: grid; gap: 14px; text-align: center; }
.gate__brand { font: 700 60px/1 "Dancing Script", cursive; color: #F0384C; }
.gate h1 { margin: 0 0 6px; font: 800 40px/1 var(--f); }
.gate p { margin: 0; color: var(--soft); }
.input { width: 100%; height: 56px; padding: 0 16px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--panel); font-size: 18px; outline: none; }
.input:focus { border-color: var(--new); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 56px; padding: 0 22px; border: 0; border-radius: 14px; background: var(--red); color: #fff; font-weight: 700; font-size: 18px; transition: transform .1s; }
.btn:active { transform: scale(.97); }
.error { margin: 0; padding: 12px 14px; border-radius: 12px; background: rgba(255, 107, 107, .14); color: var(--danger); font-weight: 600; }
.start { width: 230px; height: 230px; margin: 18px auto 0; border-radius: 50%; font: 800 28px/1.1 var(--f); box-shadow: 0 0 0 14px rgba(227, 38, 59, .18), 0 0 90px rgba(227, 38, 59, .45); animation: breathe 2.6s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 0 0 24px rgba(227, 38, 59, .06), 0 0 120px rgba(227, 38, 59, .55); } }

/* ---------- Barra de topo e separadores ---------- */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 18px; background: rgba(18, 12, 12, .95); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top__brand { font: 700 30px/1 "Dancing Script", cursive; color: #F0384C; margin-right: 6px; }
.tabs { display: flex; gap: 4px; margin-right: auto; padding: 4px; border-radius: 16px; background: var(--panel); }
.tabs button { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px; border: 0; border-radius: 12px; background: transparent; font-weight: 700; font-size: 17px; color: var(--soft); }
.tabs button[aria-current="page"] { background: var(--text); color: var(--bg); }
.tabs b:not(:empty) { display: grid; place-items: center; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 999px; background: var(--red); color: #fff; font-size: 14px; }
.clock { font: 800 26px/1 var(--f); font-variant-numeric: tabular-nums; color: var(--soft); }
.live { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 999px; background: var(--card); font-size: 15px; font-weight: 700; }
.live i { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.live.on i { background: var(--ready); box-shadow: 0 0 0 4px rgba(108, 192, 140, .25); }
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px 0 8px; border: 0; border-radius: 999px; background: var(--card); font-size: 15px; font-weight: 700; }
.switch b { width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; }
.switch b::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .25s var(--ease); }
.switch[aria-pressed="true"] b { background: var(--ready); }
.switch[aria-pressed="true"] b::after { transform: translateX(18px); }
.switch[aria-pressed="false"] { box-shadow: inset 0 0 0 2px var(--danger); }
.tb { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; min-width: 48px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--card); font-weight: 700; font-size: 15px; }
.tb:hover { background: var(--card-2); }

/* ---------- Resumo do dia ---------- */
.summary { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px 0; }
.summary > div { display: grid; padding: 10px 16px; border-radius: 14px; background: var(--panel); min-width: 130px; }
.summary small { color: var(--faint); font-size: 13px; font-weight: 600; }
.summary b { font: 800 26px/1.15 var(--f); font-variant-numeric: tabular-nums; }
.summary b.warn { color: var(--new); }
.summary em { font-style: normal; font-size: 12px; color: var(--faint); }
.summary__pay { display: flex !important; flex-wrap: wrap; align-items: center; gap: 6px 18px; flex: 1; }
.summary__pay span { color: var(--soft); font-size: 15px; }
.summary__pay b { font-size: 20px; color: var(--text); margin-left: 4px; }

/* ---------- Chamadas das mesas ---------- */
.calls { display: flex; gap: 10px; flex-wrap: wrap; padding: 12px 18px 0; }
.calls:empty { display: none; }
.call { display: flex; align-items: center; gap: 14px; padding: 12px 12px 12px 18px; border-radius: 16px; background: var(--red); font-size: 17px; font-weight: 600; animation: call-in .5s var(--ease), ring 1.2s ease-in-out 3; }
.call--bill { background: #2E5BBA; }
.call b { font: 800 24px/1 var(--f); }
.call small { color: rgba(255, 255, 255, .8); font-weight: 500; }
.call button { min-height: 48px; padding: 0 18px; border: 0; border-radius: 12px; background: #fff; color: #1C1212; font-weight: 800; }
@keyframes call-in { from { transform: translateY(-12px); opacity: 0; } }
@keyframes ring { 25% { transform: rotate(-1.5deg); } 75% { transform: rotate(1.5deg); } }

/* ---------- Colunas dos pedidos ---------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(290px, 1fr)); gap: 12px; padding: 14px 18px 40px; align-items: start; }
.col { min-height: 60vh; padding: 12px; border-radius: 20px; background: var(--panel); border-top: 5px solid var(--line); }
.col--novo { border-top-color: var(--new); }
.col--preparar { border-top-color: var(--prep); }
.col--pronto { border-top-color: var(--ready); }
.col--caminho { border-top-color: var(--serve); }
.col__head { display: flex; align-items: center; gap: 10px; padding: 4px 6px 0; }
.col__step { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--card-2); font-weight: 800; }
.col__head h2 { margin: 0; font: 800 24px/1 var(--f); }
.col__n { margin-left: auto; display: grid; place-items: center; min-width: 38px; height: 38px; border-radius: 999px; background: var(--card); font-weight: 800; font-size: 18px; }
.col__hint { margin: 6px 6px 12px; color: var(--faint); font-size: 14px; }
.col__empty { padding: 30px 12px; text-align: center; color: var(--faint); }

.ticket { margin-bottom: 12px; padding: 16px; border-radius: 16px; background: var(--card); animation: drop .45s var(--ease); }
.ticket.is-fresh { animation: drop .45s var(--ease), flash 1.1s ease-in-out 3; }
@keyframes drop { from { transform: translateY(-14px) scale(.98); opacity: 0; } }
@keyframes flash { 50% { background: #4A3216; box-shadow: 0 0 0 3px var(--new); } }
.ticket__head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ticket__table { font: 800 32px/1 var(--f); }
.ticket__no { color: var(--soft); font-weight: 700; font-size: 18px; }
.ticket__age { margin-left: auto; padding: 4px 10px; border-radius: 999px; background: var(--card-2); font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; }
.ticket__age.is-soon { background: rgba(245, 184, 81, .2); color: var(--new); }
.ticket__age.is-late { background: rgba(255, 107, 107, .2); color: var(--danger); }
.ticket__eta { margin: 8px 0 0; color: var(--soft); font-size: 15px; }
.ticket__eta b { color: var(--text); }
.ticket__items { margin: 12px 0; padding: 0; list-style: none; }
.ticket__items li { padding: 8px 0; border-top: 1px dashed var(--line); font-size: 21px; font-weight: 600; line-height: 1.25; }
.ticket__items li:first-child { border-top: 0; }
.ticket__items b { display: inline-block; min-width: 42px; color: var(--new); }
.ticket__items em { display: block; margin: 2px 0 0 42px; color: var(--new); font-size: 17px; font-weight: 500; font-style: normal; }
.ticket__note { margin: 0 0 12px; padding: 10px 12px; border-radius: 12px; background: rgba(245, 184, 81, .14); color: var(--new); font-size: 17px; font-weight: 600; }
.ticket__note span { color: var(--soft); font-weight: 500; }
.ticket__meta { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--soft); font-size: 15px; font-weight: 600; }
.ticket__meta .paid { color: var(--ready); }
.ticket__meta .lang { color: var(--serve); }
.ticket__times { margin: 6px 0 12px; color: var(--faint); font-size: 14px; }
.ticket__ask { margin: 4px 0 8px; font-weight: 700; font-size: 15px; color: var(--soft); }
.eta-chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ticket__foot { display: flex; gap: 8px; margin-top: 8px; }
.ticket__foot .btn { flex: 1; }
.btn--accept { background: var(--new); color: #1C1212; min-height: 58px; padding: 0 6px; }
.btn--ready { background: var(--ready); color: #0E2A1A; }
.btn--serve { background: var(--serve); color: #0C1D3A; }
.btn--done { background: var(--text); color: var(--bg); }
.btn--soft { background: var(--card-2); color: var(--text); }
.link { margin: 4px auto 0; padding: 8px; border: 0; background: none; color: var(--faint); font-size: 15px; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--danger); }

/* ---------- Páginas: contas e registo ---------- */
.page { padding: 18px 18px 40px; }
.page__head h2 { margin: 0; font: 800 30px/1.1 var(--f); }
.page__head p { margin: 6px 0 18px; color: var(--soft); }
.page__head--row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.bills { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.bill { padding: 18px; border-radius: 18px; background: var(--panel); border: 2px solid transparent; }
.bill.is-requested { border-color: #6FA8FF; }
.bill__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.badge { padding: 6px 12px; border-radius: 999px; background: #2E5BBA; font-weight: 700; font-size: 14px; }
.bill__orders { margin: 12px 0; padding: 0; list-style: none; }
.bill__orders li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); color: var(--soft); }
.bill__total { display: flex; justify-content: space-between; align-items: baseline; }
.bill__total b { font: 800 34px/1 var(--f); }
.bill__ask { margin: 14px 0 8px; font-weight: 700; color: var(--soft); font-size: 15px; }
.bill__pay { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.bill__pay .btn { min-height: 54px; font-size: 16px; padding: 0 6px; }

.table-wrap { overflow-x: auto; border-radius: 16px; background: var(--panel); }
.hist { width: 100%; border-collapse: collapse; font-size: 16px; }
.hist th { position: sticky; top: 0; padding: 12px 14px; background: var(--panel); color: var(--faint); font-size: 13px; text-align: left; white-space: nowrap; }
.hist td { padding: 12px 14px; border-top: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
.hist tr[data-row] { cursor: pointer; }
.hist tr[data-row]:hover td, .hist tr.is-open td { background: var(--card); }
.hist .num { text-align: right; }
.hist small { color: var(--faint); }
.hist .late { color: var(--danger); font-weight: 700; }
.hist .warn { color: var(--new); font-weight: 700; }
.hist tr.is-cancelled td { color: var(--faint); }
.st { padding: 4px 10px; border-radius: 999px; background: var(--card-2); font-weight: 700; font-size: 13px; }
.st--entregue { background: rgba(108, 192, 140, .18); color: var(--ready); }
.st--cancelado { background: rgba(255, 107, 107, .14); color: var(--danger); }
.st--preparar { color: var(--prep); }
.st--novo { color: var(--new); }
.st--pronto { color: var(--ready); }
.st--caminho { color: var(--serve); }
.detail td { background: var(--card); white-space: normal !important; }
.detail__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.detail__grid ul, .detail__grid ol { margin: 0; padding-left: 20px; color: var(--soft); }
.detail__grid li { padding: 3px 0; }
.detail__grid em { color: var(--new); font-style: normal; }

/* ---------- Esgotados ---------- */
.drawer { position: fixed; inset: 0 0 0 auto; z-index: 20; width: min(460px, 100%); display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); transform: translateX(100%); transition: transform .35s var(--ease); }
.drawer.open { transform: none; box-shadow: -40px 0 80px rgba(0, 0, 0, .5); }
.drawer__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer__head h2 { margin: 0; font: 800 28px/1 var(--f); }
.drawer__hint { margin: 12px 18px; color: var(--soft); font-size: 15px; }
.drawer__body { flex: 1; overflow-y: auto; padding: 8px 18px 20px; }
.drawer__body h3 { margin: 18px 0 6px; font-size: 14px; color: var(--faint); font-weight: 700; }
.avail { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 56px; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; font-size: 18px; }
.avail span:last-child { padding: 5px 12px; border-radius: 999px; background: rgba(108, 192, 140, .16); color: var(--ready); font-size: 14px; font-weight: 800; white-space: nowrap; }
.avail.is-out span:first-child { color: var(--faint); text-decoration: line-through; }
.avail.is-out span:last-child { background: rgba(255, 107, 107, .16); color: var(--danger); }

/* ---------- Janelas ---------- */
.modal { width: min(560px, calc(100% - 24px)); padding: 26px; border: 0; border-radius: 22px; background: var(--panel); color: var(--text); }
.modal::backdrop { background: rgba(0, 0, 0, .7); }
.modal h2 { margin: 0 0 10px; font: 800 26px/1.15 var(--f); }
.modal p { color: var(--soft); }
.modal .btn { width: 100%; margin-top: 10px; }
.reasons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.reasons .btn { margin: 0; font-size: 16px; }
.help { margin: 14px 0; padding-left: 26px; display: grid; gap: 12px; font-size: 17px; }
.help b { color: var(--new); }
.help__more { font-size: 15px; }

.toast { position: fixed; left: 50%; bottom: 22px; z-index: 30; padding: 14px 20px; border-radius: 999px; background: var(--text); color: var(--bg); font-weight: 700; font-size: 17px; transform: translate(-50%, 160%); transition: transform .4s var(--ease); max-width: calc(100% - 24px); }
.toast.show { transform: translate(-50%, 0); }
.toast[data-kind="error"] { background: var(--danger); color: #fff; }

@media (max-width: 1200px) {
  .board { grid-template-columns: repeat(4, 82vw); overflow-x: auto; scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
}
@media (max-width: 760px) {
  .clock, .top__brand { display: none; }
  .tabs { order: 10; width: 100%; margin-right: 0; }
  .tabs button { flex: 1; justify-content: center; padding: 0 8px; font-size: 15px; }
  .switch span { display: none; }
  .detail__grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
.btn--accept { flex-direction: column; gap: 0; line-height: 1; }
.btn--accept b { font-size: 24px; font-weight: 800; }
.btn--accept small { font-size: 12px; font-weight: 700; opacity: .75; }
.bill__pay .btn--accept, .eta-chips + .ticket__foot .btn--accept { flex-direction: row; }

/* ---------- Por confirmar, retirar artigos ---------- */
.ticket.is-confirm { box-shadow: inset 0 0 0 2px var(--new); }
.confirm { display: grid; gap: 6px; margin: 0 0 12px; padding: 12px 14px; border-radius: 14px; background: rgba(245, 184, 81, .14); }
.confirm b { color: var(--new); font-size: 18px; }
.confirm span { color: var(--soft); font-size: 15px; }
.confirm--money { background: rgba(111, 168, 255, .14); }
.confirm--money b { color: var(--serve); }
.btn--empty { min-height: 48px; margin-top: 4px; background: transparent; color: var(--danger); box-shadow: inset 0 0 0 2px var(--danger); font-size: 16px; }
.ticket__items li { position: relative; padding-right: 44px; }
.ticket__items .x { position: absolute; right: 0; top: 4px; display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 10px; background: var(--card-2); color: var(--faint); }
.ticket__items .x:hover { color: var(--danger); }
.ticket__items .x svg { width: 18px; height: 18px; }
.ticket__items li.is-removed { color: var(--faint); text-decoration: line-through; font-size: 17px; }
.ticket__items li.is-removed b, .ticket__items li.is-removed em { color: var(--faint); text-decoration: none; }
.detail__grid li.is-removed { color: var(--faint); }
.qty-pick { display: flex; gap: 10px; margin: 12px 0 0; }
.qty-pick label { flex: 1; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 14px; border-radius: 12px; background: var(--card); font-weight: 700; cursor: pointer; }
.qty-pick input { width: 20px; height: 20px; accent-color: var(--new); }
.summary b.bad, .hist .bad, .closed-row .bad { color: var(--danger); }
.tabs b.soft:not(:empty) { background: var(--card-2); }

/* ---------- Mesas ---------- */
.tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tcard { display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: 18px; background: var(--panel); border-top: 5px solid var(--line); }
.tcard__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tcard__badge { padding: 6px 12px; border-radius: 999px; background: var(--card-2); font-weight: 800; font-size: 14px; white-space: nowrap; }
.tcard__sub { margin: 0; color: var(--soft); font-size: 15px; }
.tcard__sub.warn { color: var(--new); font-weight: 700; }
.tcard__facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 0; }
.tcard__facts dt { color: var(--faint); font-size: 13px; font-weight: 600; }
.tcard__facts dd { margin: 0; font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
.tcard__facts small { color: var(--faint); font-size: 13px; font-weight: 600; }
.tcard__facts .warn { color: var(--new); }
.tcard__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.tcard__actions .btn { flex: 1 1 auto; min-height: 48px; padding: 0 12px; font-size: 15px; }
.tcard--free { opacity: .7; }
.tcard--free .tcard__badge { color: var(--ready); }
.tcard--look { border-top-color: var(--faint); }
.tcard--busy { border-top-color: var(--prep); }
.tcard--busy .tcard__badge { color: var(--prep); }
.tcard--confirm { border-top-color: var(--new); }
.tcard--confirm .tcard__badge { background: var(--new); color: #1C1212; }
.tcard--bill { border-top-color: var(--serve); }
.tcard--bill .tcard__badge { background: #2E5BBA; }
.tcard--paid { border-top-color: var(--ready); }
.tcard--paid .tcard__badge { color: var(--ready); }
.tcard--stale { border-top-color: var(--danger); }
.tcard--stale .tcard__badge { background: rgba(255, 107, 107, .18); color: var(--danger); }

/* ---------- Desfazer e mesas fechadas ---------- */
.toast { display: flex; align-items: center; gap: 14px; }
.toast button { flex: none; padding: 8px 16px; border: 0; border-radius: 999px; background: var(--new); color: #1C1212; font: inherit; font-size: 16px; cursor: pointer; }
.toast[data-kind="error"] button { background: #fff; }
.undo-list { list-style: none; margin: 14px 0; padding: 0; max-height: 56vh; overflow: auto; display: grid; gap: 8px; }
.undo-list li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--bg); }
.undo-list li.is-done { opacity: .55; }
.undo-list__at { font-weight: 800; font-variant-numeric: tabular-nums; }
.undo-list__what { display: grid; gap: 2px; font-weight: 600; }
.undo-list__what small, .closed-row__what small { color: var(--soft); font-weight: 500; }
.modal .undo-list .btn, .closed-row .btn { width: auto; margin: 0; padding: 10px 16px; }
.closed-list { display: grid; gap: 8px; }
.closed-row { display: grid; grid-template-columns: minmax(90px, auto) 1fr auto; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 16px; background: var(--panel); }
.closed-row__what { display: grid; gap: 2px; }
.badge--soft { background: var(--line); color: var(--text); }
@media (max-width: 560px) {
  .undo-list li, .closed-row { grid-template-columns: 1fr auto; }
  .undo-list__at { grid-column: 1 / -1; }
}
