:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --border: #dfe6f0;
  --text: #0d1b2e;
  --muted: #5b6b80;
  --primary: #13315c;
  --primary-2: #0b2545;
  --primary-soft: #e8eef8;
  --accent: #8da9c4;
  --navy: #0b2545;
  --navy-3: #071a33;
  --danger: #c2372f;
  --danger-soft: #fdecea;
  --warn: #8a5a12;
  --warn-soft: #fff6e0;
  --ok: #166b3a;
  --ok-soft: #e7f6ed;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(11, 37, 69, .06), 0 6px 20px rgba(11, 37, 69, .07);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
#print-frame { position: absolute; width: 0; height: 0; border: 0; visibility: hidden; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; height: 100vh; }
.side { background: linear-gradient(180deg, var(--navy) 0%, var(--navy-3) 100%); color: #cfd8e3; display: flex; flex-direction: column; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 700; font-size: 18px; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; background: #fff; color: var(--navy) !important; display: grid; place-items: center; font-size: 12px; }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #cfd8e3; text-decoration: none; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: #fff; color: var(--navy); font-weight: 600; }
.nav .ico { width: 20px; display: inline-flex; justify-content: center; opacity: .95; }
.nav .sep { margin: 10px 12px 4px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: #a3b3c7; font-weight: 600; }
.side-foot { margin-top: auto; padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.side-foot .who { color: #fff; font-weight: 600; }
.side-foot .term { color: #8fa0b3; margin-top: 2px; }
.side-foot button { margin-top: 10px; width: 100%; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #9aa5b1; margin-right: 6px; }
.status-dot.on { background: #34d399; }
.status-dot.off { background: #f87171; }

.main { overflow-y: auto; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 16px 24px 0; }
.topbar h1 { font-size: 22px; margin: 0; flex: 1; }
.page { padding: 16px 24px 32px; }
.menu-toggle { display: none; }

/* ---------- componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card h2, .card h3 { margin: 0 0 12px; font-size: 16px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.hidden { display: none !important; }

.btn { border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; line-height: 1.2; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
a.btn, a.tile { text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.05); }
.side .btn.ghost { color: #cfd8e3; border-color: rgba(255,255,255,.15); }
.btn.big { padding: 13px 20px; font-size: 17px; font-weight: 600; }
.btn.sm { padding: 5px 9px; font-size: 13px; }
.btn kbd { font-size: 12px; opacity: .85; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; }

label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.f > span { font-weight: 600; }
input, select, textarea { border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 8px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(19,49,92,.25); border-color: var(--primary); }
textarea { resize: vertical; min-height: 64px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--primary-soft); }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef1f4; color: #435264; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--primary-soft); color: var(--primary); }

.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 13px; color: var(--muted); }

.alert { padding: 10px 14px; border-radius: 8px; background: var(--warn-soft); color: #7a5413; border: 1px solid #f3dfae; }
.alert.danger { background: var(--danger-soft); color: var(--danger); border-color: #f5c6c2; }
.alert.ok { background: var(--ok-soft); color: var(--ok); border-color: #bfe5cd; }
.alert.info { background: var(--primary-soft); color: var(--primary-2); border-color: #bfe0dc; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 9px 14px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; }
.tabs button.active { color: var(--primary); border-color: var(--primary); }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar { display: grid; grid-template-columns: 130px 1fr 110px; align-items: center; gap: 10px; font-size: 14px; }
.bar .track { height: 10px; background: #eef1f4; border-radius: 6px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--primary); border-radius: 6px; }
.hours { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: 8px; }
.hours .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.hours .colbar { width: 100%; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; }
.hours .lbl { font-size: 12px; color: var(--muted); }

/* ---------- modal / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 25, 38, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(900px, 100%); }
.modal.xwide { width: min(1150px, 100%); }
.modal header { padding: 16px 20px 0; display: flex; align-items: center; gap: 10px; }
.modal header h3 { margin: 0; font-size: 18px; flex: 1; }
.modal .body { padding: 14px 20px; overflow-y: auto; }
.modal footer { padding: 12px 20px 16px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--border); flex-wrap: wrap; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; animation: tin .2s ease; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 80% -10%, #1d4a85 0%, transparent 60%), linear-gradient(160deg, #0b2545 0%, #071a33 100%); padding: 16px; }
.login-card { width: min(380px, 100%); background: #fff; border-radius: 16px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-card:has(.lu-grid:not(.hidden):not(:empty)) { width: min(560px, 100%); }
.lu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 16px; max-height: 50vh; overflow: auto; padding: 2px; }
.lu-grid:empty { display: none; }
.lu { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px; border: 1.5px solid #dbe3ef; border-radius: 14px; background: #fff; cursor: pointer; font: inherit; color: var(--text); transition: transform .15s, border-color .15s, box-shadow .15s; }
.lu:hover, .lu:focus-visible { border-color: var(--primary); box-shadow: 0 6px 18px rgba(19,49,92,.15); transform: translateY(-2px); outline: none; }
.lu b { font-size: 14px; text-align: center; line-height: 1.2; overflow-wrap: anywhere; }
.lu small, .lu-sel small { color: var(--muted, #64748b); font-size: 12px; display: block; }
.lu-av { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #fff; font-weight: 700; font-size: 18px; flex: none; }
.lu-sel { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--primary-soft); }
.lu-sel .lu-av { width: 44px; height: 44px; font-size: 16px; }
.lu-sel > span:nth-child(2) { flex: 1; }
.login-brand { padding: 0 !important; margin-bottom: 4px; }
.brand .brand-logo { max-width: 100%; }
.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }

/* ---------- PDV (modo caixa, tela cheia) ---------- */
.shell.focus { grid-template-columns: 1fr; }
.shell.focus .side, .shell.focus .topbar { display: none; }
.shell.focus .page { padding: 0; }
.cx { display: flex; flex-direction: column; height: 100vh; background: var(--bg); }
.cx-head { background: linear-gradient(90deg, var(--navy) 0%, var(--primary) 100%); color: #fff; padding: 12px 20px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.cx-head .store { font-weight: 700; font-size: 17px; letter-spacing: .02em; }
.cx-head .meta { font-size: 13px; color: #c9d6e8; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.cx-head .btn { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.25); color: #fff; }
.cx-head .btn:hover { background: rgba(255,255,255,.2); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .03em; }
.pill.on { background: #e7f6ed; color: #1f7a45; }
.pill.off { background: #fdecea; color: #b4322a; }
.pill.none { background: #fff3d6; color: #8a5a00; }
.cx-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; padding: 14px 20px; }
.cx-entry { display: grid; grid-template-columns: 150px 1fr; gap: 12px; position: relative; }
.cx-entry .lbl { font-size: 12.5px; font-weight: 700; color: #475569; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 4px; display: block; }
.cx-entry input { width: 100%; font-size: 30px; padding: 12px 16px; border: 2px solid var(--primary); border-radius: 12px; background: #fff; color: var(--navy); font-weight: 600; }
.cx-entry input::placeholder { color: #6b7f99; font-weight: 500; }
.cx-entry #qty-in { text-align: center; }
.cx-entry .results { top: calc(100% + 4px); left: 162px; }
.results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 16px 40px rgba(11,37,69,.18); z-index: 20; max-height: 420px; overflow-y: auto; }
.results .it { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; padding: 11px 16px; cursor: pointer; border-bottom: 1px solid var(--border); align-items: center; }
.results .it:last-child { border-bottom: 0; }
.results .it.sel, .results .it:hover { background: var(--primary-soft); }
.results .it .nm { font-weight: 600; }
.results .it.zero { opacity: .55; }
.pdv-search { position: relative; }
.pdv-search input { width: 100%; font-size: 18px; padding: 12px 14px; border-width: 2px; }
.cx-list { flex: 1; min-height: 0; overflow-y: auto; background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.cx-list table.t th { position: sticky; top: 0; background: var(--navy); color: #fff; z-index: 1; font-size: 12px; padding: 11px 12px; }
.cx-list table.t td { padding: 10px 12px; font-size: 15px; }
.cx-list tr.last td { background: #f2f6fc; }
.cx-list .empty { padding: 70px 20px; }
.qty-ctl { display: inline-flex; align-items: center; gap: 4px; }
.qty-ctl input { width: 64px; text-align: center; padding: 5px; }
.cx-foot { background: #fff; border-top: 1px solid var(--border); padding: 12px 20px; display: grid; grid-template-columns: 205px 1fr 300px; gap: 18px; align-items: center; box-shadow: 0 -4px 20px rgba(11,37,69,.05); }
.cx-sum { display: grid; grid-template-columns: 1fr auto; gap: 3px 14px; font-size: 14px; }
.cx-sum b { font-variant-numeric: tabular-nums; text-align: right; }
.cx-sum .eco { color: #1f7a45; }
.cx-mid { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cx-cust { display: flex; align-items: center; gap: 10px; font-size: 14px; flex-wrap: wrap; }
.cx-cust .who { font-weight: 700; color: var(--navy); text-transform: uppercase; letter-spacing: .02em; }
.cx-cust select { padding: 5px 8px; }
.cx-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 66px; flex: 1 1 66px; max-width: 96px; padding: 7px 4px; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--navy); cursor: pointer; font-size: 12px; font-weight: 600; line-height: 1.1; }
.tool:hover { background: var(--primary-soft); border-color: #c4d3e8; }
.tool kbd { font-size: 12px; color: #475569; font-weight: 600; font-family: inherit; }
.tool.danger { color: var(--danger); }
.tool.danger:hover { background: var(--danger-soft); border-color: #f2c3be; }
.paybtn { height: 100%; min-height: 86px; border: 0; border-radius: 14px; background: linear-gradient(135deg, var(--primary) 0%, var(--navy) 100%); color: #fff; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; box-shadow: 0 8px 24px rgba(11,37,69,.3); }
.paybtn:hover { filter: brightness(1.12); }
.paybtn .l { font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: #c9d6e8; }
.paybtn .v { font-size: 36px; font-weight: 800; font-variant-numeric: tabular-nums; }
.paybtn .k { font-size: 13px; color: #dbe5f2; }
.pay-methods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pay-methods button { padding: 12px 6px; font-weight: 600; flex-direction: column; justify-content: center; }
.pay-list .pl { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.big-total { font-size: 40px; font-weight: 800; text-align: center; color: var(--navy); font-variant-numeric: tabular-nums; }
.change { font-size: 26px; font-weight: 800; text-align: center; color: var(--ok); }
.term-banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }

/* ---------- Início (blocos) ---------- */
.hero { background: linear-gradient(120deg, var(--navy) 0%, var(--primary) 70%, #1d4a85 100%); color: #fff; border-radius: 16px; padding: 22px 26px; display: flex; gap: 20px; align-items: center; flex-wrap: wrap; box-shadow: var(--shadow); }
.hero .mark { width: 58px; height: 58px; border-radius: 14px; background: #fff; color: var(--navy); display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.hero h2 { margin: 0; font-size: 24px; }
.hero .sub { color: #c9d6e8; font-size: 14px; margin-top: 4px; }
.hero .stats { margin-left: auto; display: flex; gap: 26px; flex-wrap: wrap; }
.hero .stat .k { font-size: 12px; color: #c9d6e8; text-transform: uppercase; letter-spacing: .06em; }
.hero .stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 14px; margin-top: 18px; }
.tile { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 20px 16px; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; cursor: pointer; text-decoration: none; color: var(--text); box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s, border-color .12s; min-height: 132px; }
.tile:hover { transform: translateY(-2px); border-color: #b9c9e0; box-shadow: 0 10px 28px rgba(11,37,69,.12); }
.tile .ti { width: 48px; height: 48px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.tile .tn { font-weight: 700; font-size: 16px; }
.tile .td { font-size: 12.5px; color: var(--muted); margin-top: -8px; }
.tile.main { background: linear-gradient(135deg, var(--primary) 0%, var(--navy) 100%); color: #fff; border-color: transparent; grid-column: span 2; }
.tile.main .ti { background: rgba(255,255,255,.14); color: #fff; }
.tile.main .td { color: #c9d6e8; }
.quick { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.quick .btn { padding: 12px 18px; font-weight: 600; }

.variant-grid { border-collapse: collapse; }
.variant-grid td, .variant-grid th { padding: 5px; }
.variant-grid input { width: 100%; }

@media (max-width: 1100px) {
  .cx-foot { grid-template-columns: 1fr; }
  .tile.main { grid-column: span 1; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .menu-toggle { display: inline-flex; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .page, .topbar { padding-left: 16px; padding-right: 16px; }
  .bar { grid-template-columns: 90px 1fr 90px; }
}
.alert.warn { background: var(--warn-soft); color: var(--warn); border-color: #f5d79e; }
/* Totais da venda (detalhe): rótulo à esquerda, valor à direita */
.totals .ln { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
