/* PDV — CSS touch-first para o Elgin M10 (1280x800, horizontal). Sem build: arquivo servido direto. */
:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #1d4ed8;
    --primary-dark: #1e3a8a;
    --success: #15803d;
    --success-bg: #dcfce7;
    --danger: #b91c1c;
    --danger-bg: #fee2e2;
    --warning: #a16207;
    --warning-bg: #fef9c3;
    --header: #0f172a;
    --radius: 12px;
    --touch: 56px;
    font-size: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
    background: var(--bg);
    color: var(--text);
    overscroll-behavior: none;
}
[x-cloak] { display: none !important; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.big { font-size: 1.6rem; font-weight: 700; }
.huge { font-size: 3rem; font-weight: 800; letter-spacing: -.02em; }
.right { text-align: right; } .center { text-align: center; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.nowrap { white-space: nowrap; }
.text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-warning { color: var(--warning); }

/* ---------- layout ---------- */
.app { display: flex; flex-direction: column; height: 100vh; }
.topbar {
    display: flex; align-items: center; gap: .5rem;
    background: var(--header); color: #fff; padding: 0 .75rem; min-height: 60px; flex-shrink: 0;
}
.topbar .brand { font-weight: 800; font-size: 1.1rem; margin-right: .5rem; white-space: nowrap; }
.topbar nav { display: flex; gap: .1rem; flex: 1; overflow-x: auto; scrollbar-width: none; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar a, .topbar button.navlink {
    color: #cbd5e1; text-decoration: none; padding: 0 .6rem; min-height: 48px; display: inline-flex; align-items: center;
    border-radius: 10px; font-weight: 600; background: transparent; border: 0; font-size: .95rem; cursor: pointer; white-space: nowrap;
}
.topbar a:hover, .topbar a.active, .topbar button.navlink:hover { background: #1e293b; color: #fff; }
.topbar .who { color: #94a3b8; font-size: .85rem; text-align: right; line-height: 1.2; white-space: nowrap; }
.content { flex: 1; overflow: auto; padding: 1rem; }
.content.no-pad { padding: 0; overflow: hidden; }
.page { max-width: 1200px; margin: 0 auto; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .75rem; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: .75rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.card.tight { padding: .75rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.4rem; font-weight: 800; margin-top: .15rem; }

/* ---------- botoes (minimo 48px, padrao 56px) ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: var(--touch); padding: 0 1.1rem; border-radius: 10px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font-size: 1.05rem; font-weight: 700; cursor: pointer;
    text-decoration: none; user-select: none; touch-action: manipulation; transition: transform .05s, filter .1s;
}
.btn:active:not(:disabled) { transform: scale(.97); filter: brightness(.95); }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-warning { background: #f59e0b; border-color: #f59e0b; color: #1f2937; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-lg { min-height: 72px; font-size: 1.35rem; padding: 0 1.5rem; }
.btn-sm { min-height: 48px; font-size: .95rem; padding: 0 .8rem; }
.btn-block { width: 100%; }
.btn-icon { min-width: var(--touch); padding: 0; font-size: 1.4rem; }

/* ---------- formularios ---------- */
label { display: block; font-weight: 600; margin-bottom: .3rem; }
.input, select.input, textarea.input {
    width: 100%; min-height: var(--touch); padding: 0 .9rem; border: 1px solid #cbd5e1; border-radius: 10px;
    font-size: 1.1rem; background: #fff; color: var(--text);
}
textarea.input { padding: .7rem .9rem; min-height: 96px; }
.input:focus { outline: 3px solid #93c5fd; border-color: var(--primary); }
.field { margin-bottom: .9rem; }
.field .hint { color: var(--muted); font-size: .85rem; margin-top: .25rem; }
.error-text { color: var(--danger); font-size: .9rem; margin-top: .25rem; }
.check { display: flex; align-items: center; gap: .6rem; min-height: 48px; font-weight: 600; cursor: pointer; }
.check input { width: 28px; height: 28px; accent-color: var(--primary); }
.color-input { width: 72px; height: 56px; padding: 4px; border-radius: 10px; border: 1px solid #cbd5e1; }

/* ---------- alertas ---------- */
.alert { padding: .8rem 1rem; border-radius: 10px; font-weight: 600; margin-bottom: 1rem; }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }

/* Faixa de conexao: aparece fixa quando o servidor cai */
.offline-banner {
    background: var(--danger); color: #fff; font-weight: 800; padding: .7rem 1rem; text-align: center; font-size: 1.1rem;
    flex-shrink: 0; animation: pulse 1.6s infinite;
}
@keyframes pulse { 50% { filter: brightness(1.2); } }

/* ---------- tabelas ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td { padding: .65rem .7rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { background: var(--surface-2); font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.table td.num, .table th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tr.canceled td { color: var(--muted); text-decoration: line-through; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.badge { display: inline-block; padding: .2rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 700; background: #e2e8f0; color: #334155; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }

/* ---------- PDV ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 440px; height: 100%; }
.pos-left { display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--border); }
.pos-toolbar { display: flex; gap: .5rem; padding: .6rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.categories { display: flex; gap: .5rem; padding: .6rem; overflow-x: auto; background: var(--surface-2); border-bottom: 1px solid var(--border); flex-shrink: 0; scrollbar-width: none; }
.categories::-webkit-scrollbar { display: none; }
.categories .btn { flex-shrink: 0; }
.categories .btn.active { background: var(--header); color: #fff; border-color: var(--header); }
.products { flex: 1; overflow-y: auto; padding: .6rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; align-content: start; }
.product-btn {
    position: relative; min-height: 110px; border-radius: 12px; border: 0; color: #fff; cursor: pointer; padding: .6rem;
    display: flex; flex-direction: column; justify-content: space-between; text-align: left; font-weight: 700; font-size: 1rem;
    box-shadow: 0 1px 2px rgba(0,0,0,.15); touch-action: manipulation; user-select: none;
}
.product-btn:active { transform: scale(.96); }
.product-btn .icon { font-size: 1.7rem; line-height: 1; }
.product-btn .price { font-size: 1.05rem; background: rgba(0,0,0,.22); border-radius: 8px; padding: .15rem .45rem; align-self: flex-start; }
.product-btn .qty-badge { position: absolute; top: 6px; right: 6px; background: #fff; color: var(--text); border-radius: 999px; min-width: 30px; height: 30px; display: grid; place-items: center; font-weight: 800; }

.cart { display: flex; flex-direction: column; background: var(--surface); min-height: 0; }
.cart-header { padding: .6rem; border-bottom: 1px solid var(--border); }
.cart-items { flex: 1; overflow-y: auto; }
.cart-item { padding: .55rem .6rem; border-bottom: 1px solid var(--border); }
.cart-item .name { font-weight: 700; }
.cart-item .note { color: var(--warning); font-size: .9rem; font-weight: 600; }
.cart-item .disc { color: var(--success); font-size: .85rem; font-weight: 600; }
.qty-ctrl { display: flex; align-items: center; gap: .3rem; }
.qty-ctrl .btn { min-height: 48px; min-width: 48px; padding: 0; font-size: 1.4rem; }
.qty-ctrl .qty { min-width: 36px; text-align: center; font-weight: 800; font-size: 1.15rem; }
.cart-empty { color: var(--muted); text-align: center; padding: 3rem 1rem; }
.totals { padding: .6rem .8rem; border-top: 2px solid var(--border); background: var(--surface-2); }
.totals .line { display: flex; justify-content: space-between; font-size: 1.05rem; padding: .1rem 0; }
.totals .total { font-size: 1.9rem; font-weight: 800; }
.cart-actions { display: grid; grid-template-columns: 1fr 1.3fr 1.7fr; gap: .5rem; padding: .6rem; border-top: 1px solid var(--border); }

/* Pagamento */
.pay { display: grid; grid-template-columns: minmax(0, 1fr) 420px; height: 100%; }
.pay-left { padding: 1rem; overflow: auto; }
.pay-right { background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; padding: 1rem; }
.pay-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-bottom: 1rem; }
.pay-summary .stat.remaining { border-color: var(--primary); background: #eff6ff; }
.pay-summary .stat.remaining .value { color: var(--primary); font-size: 1.8rem; }
.pay-summary .stat.change .value { color: var(--success); font-size: 1.8rem; }
.methods { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .6rem; }
.method-btn { min-height: 76px; font-size: 1.15rem; }
.method-btn.selected { outline: 4px solid var(--primary); outline-offset: 1px; }
.payments-list .item { display: flex; align-items: center; gap: .6rem; padding: .6rem; border: 1px solid var(--border); border-radius: 10px; margin-bottom: .5rem; }

/* Teclado numerico */
.keypad-display { font-size: 2.4rem; font-weight: 800; text-align: right; padding: .5rem .9rem; background: var(--surface-2); border: 2px solid var(--border); border-radius: 12px; margin-bottom: .6rem; font-variant-numeric: tabular-nums; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.keypad .btn { min-height: 68px; font-size: 1.6rem; }
.quick { display: grid; grid-template-columns: repeat(6, 1fr); gap: .4rem; margin-bottom: .6rem; }
.quick .btn { min-height: 48px; font-size: 1rem; padding: 0; }

/* Venda concluida */
.done { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; text-align: center; padding: 2rem; }
.change-box { background: var(--success-bg); color: var(--success); border-radius: 20px; padding: 1.5rem 3rem; }
.change-box .huge { font-size: 4.5rem; }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 560px; max-height: calc(100vh - 2rem); overflow: auto; padding: 1.25rem; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal.wide { max-width: 980px; }
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.chips .btn { min-height: 48px; font-size: .95rem; }
.segmented { display: grid; grid-auto-flow: column; gap: .4rem; }
.segmented .btn.active { background: var(--header); color: #fff; border-color: var(--header); }

/* ---------- toasts e painel de falhas de hardware ---------- */
.toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: .5rem; align-items: center; }
.toast { padding: .8rem 1.2rem; border-radius: 12px; font-weight: 700; color: #fff; background: var(--header); box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 90vw; }
.toast.success { background: var(--success); } .toast.error { background: var(--danger); } .toast.warning { background: #b45309; }
.hw-issues { position: fixed; top: 116px; right: 1rem; z-index: 55; width: 420px; display: flex; flex-direction: column; gap: .5rem; }
.hw-issue { background: #fff; border: 2px solid var(--danger); border-radius: 12px; padding: .8rem; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.hw-issue .title { font-weight: 800; color: var(--danger); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-side { background: var(--header); color: #fff; padding: 2rem; display: flex; flex-direction: column; }
.login-main { padding: 2rem; display: flex; align-items: center; justify-content: center; }
.user-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; margin-top: 1rem; }
.user-tile { min-height: 80px; background: #1e293b; color: #fff; border: 2px solid transparent; font-size: 1.05rem; }
.user-tile.selected { border-color: #60a5fa; background: #1e3a8a; }
.pin-dots { display: flex; gap: .7rem; justify-content: center; margin: .8rem 0; }
.pin-dots span { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #64748b; }
.pin-dots span.on { background: #fff; border-color: #fff; }

/* ---------- paginacao ---------- */
nav[role="navigation"] { margin-top: 1rem; }
nav[role="navigation"] svg { width: 20px; height: 20px; }

@media (max-width: 1100px) {
    .pos { grid-template-columns: minmax(0, 1fr) 380px; }
    .pay { grid-template-columns: minmax(0, 1fr) 360px; }
}
@media print {
    .topbar, .offline-banner, .toasts, .hw-issues, .no-print { display: none !important; }
    .content { overflow: visible; }
}
