/* TPV Puerto Pesquero — touch screen, 1024×768 and up. */
:root {
    --bg: #e9e4da;
    --panel: #fffdf8;
    --ink: #1a1a1a;
    --muted: #6b6459;
    --libre: #20a845;
    --ocupada: #f08a24;
    --presentada: #2fa3d6;
    --danger: #e0352b;
    --ok: #17a34a;
    --dark: #1f2328;
    --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif; background: var(--bg); color: var(--ink); overflow: hidden; user-select: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .35; cursor: default; }
button:active:not(:disabled) { transform: scale(.97); }

.tpv { height: 100vh; }

/* ── Toast ── */
.toast { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 60; padding: 12px 22px; border-radius: var(--radius); font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 90vw; }
.toast-ok { background: var(--ok); color: #fff; }
.toast-warn { background: #ffd34d; }
.toast-error { background: var(--danger); color: #fff; }

/* ── Table map ── */
.map { height: 100vh; display: flex; flex-direction: column; }
.map-bar { display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: var(--dark); color: #fff; }
.map-bar strong { font-size: 20px; letter-spacing: .04em; }
.map-bar .clock { margin-right: auto; opacity: .8; text-transform: capitalize; }
.map-bar form { margin: 0; }
.bar-btn { background: #3a4048; color: #fff; padding: 10px 14px; border-radius: var(--radius); text-decoration: none; font-size: 15px; display: inline-block; }
.bar-alert { background: var(--danger); }
.tables { flex: 1; display: grid; grid-template-columns: repeat(10, 1fr); grid-auto-rows: 1fr; gap: 8px; padding: 14px; overflow: auto; }
.table-tile { position: relative; border-radius: 10px; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 72px; box-shadow: inset 0 -4px 0 rgba(0,0,0,.18); }
.table-number { font-size: 30px; font-weight: 700; line-height: 1; }
.table-total { font-size: 13px; font-weight: 600; margin-top: 4px; }
.table-time { font-size: 11px; opacity: .85; }
.table-flag { position: absolute; top: 4px; right: 6px; background: #fff; color: var(--danger); width: 20px; height: 20px; border-radius: 50%; font-weight: 800; font-size: 14px; display: grid; place-items: center; }
.is-libre { background: var(--libre); }
.is-ocupada { background: var(--ocupada); }
.is-presentada { background: var(--presentada); }
.legend { display: flex; gap: 22px; padding: 8px 16px 12px; color: var(--muted); font-size: 15px; }
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; }

/* ── Order screen ── */
.order-screen { height: 100vh; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 54vh 1fr; gap: 6px; padding: 6px; }
.ticket-panel { background: var(--panel); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; }
.ticket-head { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; background: var(--dark); color: #fff; padding: 8px 12px; }
.zone { font-size: 13px; opacity: .75; }
.mesa { font-size: 26px; font-weight: 700; }
.head-meta { font-size: 13px; opacity: .9; line-height: 1.35; }
.covers { background: #3a4048; color: #fff; padding: 2px 10px; border-radius: 6px; font-size: 14px; }
.head-total { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.head-total.is-billed { color: #7fd3f7; }
.lines { flex: 1; overflow-y: auto; }
.line { display: grid; grid-template-columns: 48px 1fr 70px 78px; width: 100%; text-align: left; padding: 9px 10px; border-bottom: 1px solid #ece6da; background: transparent; font-size: 16px; font-variant-numeric: tabular-nums; }
.line span:nth-child(3), .line span:nth-child(4) { text-align: right; }
.line-head { font-size: 12px; color: var(--muted); text-transform: uppercase; background: #f3eee4; position: sticky; top: 0; cursor: default; }
.line.is-selected { background: #bfe6f7; }
.line.is-pending { background: #fff7d6; }
.line.is-selected.is-pending { background: #bfe6f7; }
.line-name { font-weight: 600; }
.tag { font-style: normal; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; margin-left: 6px; vertical-align: 2px; }
.tag-sent { background: #dff3e4; color: #17733a; }
.tag-wait { background: #ffe39a; color: #7a5600; }
.tag-fix { background: #fde0de; color: #a3241c; }
.lines-empty { color: var(--muted); padding: 24px; text-align: center; }
.ticket-foot { display: flex; gap: 12px; justify-content: space-between; padding: 6px 12px; font-size: 13px; font-weight: 600; background: #f3eee4; min-height: 30px; align-items: center; }
.state-billed { color: #0f78a8; }
.state-wait { color: #9a6a00; }

.control-panel { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.actions { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.act { border-radius: var(--radius); padding: 10px 6px; font-weight: 700; font-size: 15px; line-height: 1.15; min-height: 56px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.15); }
.act-mesas { background: #efd98c; }
.act-cocina { background: #f4a259; }
.act-cuenta { background: #6fc9ee; }
.act-cobrar { background: #2dbb5c; color: #fff; }
.act-anula { background: var(--danger); color: #fff; }
.pad-row { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; min-height: 0; }
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 1fr; gap: 5px; }
.numpad-display { grid-column: 1 / -1; background: #fff; border-radius: 6px; font-size: 22px; font-weight: 700; text-align: right; padding: 4px 10px; min-height: 36px; }
.key { background: #dcdcdc; border-radius: 6px; font-size: 24px; font-weight: 600; box-shadow: inset 0 -3px 0 rgba(0,0,0,.12); }
.key-clear { background: #f2b8b4; }
.key-ok { background: var(--ok); color: #fff; }
.key-plus, .key-minus { font-size: 18px; background: #cfe3ef; }
.numpad .key-plus { grid-column: span 1; }
.categories { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; gap: 6px; }
.cat { background: var(--c); color: #fff; border-radius: var(--radius); font-size: 19px; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,.35); box-shadow: inset 0 -4px 0 rgba(0,0,0,.2); }
.cat.is-active { outline: 4px solid #fff; outline-offset: -4px; box-shadow: 0 0 0 3px var(--ink); }

.products { grid-column: 1 / -1; background: #f7f3ea; border-radius: var(--radius); padding: 6px; display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); grid-auto-rows: 64px; gap: 5px; overflow-y: auto; align-content: start; }
.product { background: var(--c); color: var(--t); border-radius: 6px; font-weight: 700; font-size: 13px; line-height: 1.1; padding: 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.15); }
.product small { font-weight: 500; font-size: 11px; opacity: .75; }
.product.no-price small { color: var(--danger); opacity: 1; font-weight: 700; }

/* ── Modals ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,22,26,.6); display: grid; place-items: center; z-index: 50; }
.modal { background: var(--panel); border-radius: 12px; padding: 20px; width: min(560px, 94vw); max-height: 94vh; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-small { width: min(400px, 94vw); }
.modal h2 { margin: 0; font-size: 20px; }
.big-display, .pay-total { font-size: 44px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.modal-pad { display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 58px; gap: 6px; }
.modal-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.link-btn { background: none; color: var(--muted); text-decoration: underline; padding: 6px; }
.pay-methods { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pay-method { padding: 18px; border-radius: 10px; font-size: 22px; font-weight: 700; background: #ece6da; border: 3px solid transparent; }
.pay-method.is-active { border-color: var(--ok); background: #dff3e4; }
.cash-row { display: flex; justify-content: space-between; font-size: 18px; }
.change { color: var(--ok); font-weight: 700; }
.price-hint { text-align: center; margin: 0; color: var(--muted); font-weight: 600; }
.warn { color: #a3241c; font-weight: 600; margin: 0; }
.paper { background: #fff; border: 1px solid #ddd; padding: 14px; font: 13px/1.35 "Courier New", monospace; white-space: pre; overflow-x: auto; margin: 0; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.job-status { font-size: 12px; padding: 2px 8px; border-radius: 4px; vertical-align: 3px; margin-left: 6px; }
.job-printed { background: #dff3e4; color: #17733a; }
.job-preview { background: #e5eef8; color: #24527a; }
.job-failed { background: #fde0de; color: #a3241c; }
.report { width: 100%; border-collapse: collapse; font-size: 17px; }
.report td { padding: 8px 4px; border-bottom: 1px solid #ece6da; }
.report td:last-child { text-align: right; font-weight: 600; }
.report-total td { font-size: 22px; font-weight: 700; }
.report-flag td { background: #fde0de; color: #a3241c; }

/* ── Cash count ── */
.modal-wide { width: min(720px, 96vw); }
.hint { margin: 0; color: var(--muted); }
.cash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.cash-cell { display: flex; flex-direction: column; gap: 4px; background: #f3eee4; border-radius: 8px; padding: 8px; font-weight: 700; }
.cash-cell input, .cash-line input, .reason-input { font-size: 20px; padding: 6px 8px; border: 1px solid #d6cfc2; border-radius: 6px; width: 100%; background: #fff; }
.cash-line { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.cash-total { font-size: 20px; text-align: right; }
.report-ok td { background: #dff3e4; color: #17733a; font-weight: 700; }
.employee-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 160px; overflow-y: auto; }
.chip small { font-weight: 500; opacity: .8; }
.reason-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #ece6da; border-radius: 99px; padding: 8px 12px; font-weight: 600; }
.chip.is-active { background: var(--presentada); color: #fff; }

/* ── PIN ── */
.pin-page { display: grid; place-items: center; background: var(--dark); overflow: auto; }
.pin-box { background: var(--panel); border-radius: 14px; padding: 24px; width: min(420px, 94vw); display: flex; flex-direction: column; gap: 12px; }
.pin-box h1 { margin: 0; font-size: 22px; text-align: center; }
.pin-hint { margin: 0; text-align: center; color: var(--muted); }
.pin-users { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.pin-user input { display: none; }
.pin-user span { display: block; padding: 12px; text-align: center; border-radius: 8px; background: #ece6da; font-weight: 600; cursor: pointer; }
.pin-user input:checked + span { background: var(--presentada); color: #fff; }
.pin-display { font-size: 32px; text-align: center; letter-spacing: .4em; padding: 8px; border: 2px solid #ddd; border-radius: 8px; }
.pin-error { color: var(--danger); margin: 0; text-align: center; font-weight: 600; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 62px; gap: 6px; }
.pin-pad button { background: #dcdcdc; border-radius: 8px; font-size: 26px; font-weight: 600; }
.pin-pad .key-ok { background: var(--ok); color: #fff; }
.pin-pad .key-clear { background: #f2b8b4; }

@media (max-width: 800px) {
    .tables { grid-template-columns: repeat(6, 1fr); }
    .order-screen { grid-template-columns: 1fr; grid-template-rows: auto auto auto; overflow-y: auto; height: auto; min-height: 100vh; }
    body { overflow: auto; }
    .actions { grid-template-columns: repeat(3, 1fr); }
}
