:root {
  --ink: #1a1d21;
  --ink-soft: #5c6570;
  --paper: #e7eaee;
  --paper-2: #d8dde3;
  --card: #f7f8fa;
  --line: #c9d0d8;
  --wine: #2a2f36;
  --wine-2: #3a414b;
  --wine-deep: #1c2128;
  --gold: #6b7280;
  --gold-2: #e5e7eb;
  --sage: #2f6f4e;
  --sage-soft: #dcefe4;
  --danger: #9b2c2c;
  --warn: #9a6b12;
  --ok: #2f6f4e;
  --shadow: 0 16px 36px rgba(20, 24, 28, 0.12);
  --radius: 18px;
  --sidebar: 88px;
  font-synthesis: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: Outfit, system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  letter-spacing: 0.01em;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
img { max-width: 100%; display: block; }

#app { min-height: 100%; }
#splash{position:fixed;inset:0;z-index:80;background:#1c2128;display:grid;place-items:center;color:#e8eaed}
.splash-box{text-align:center;animation:rise .8s ease both}
.splash-mark{width:76px;height:76px;margin:0 auto 16px;border-radius:22px;background:#2a2f36;border:1px solid #4b5563;color:#e8eaed;display:grid;place-items:center;font-size:34px;font-weight:700;letter-spacing:.02em;box-shadow:0 0 0 0 rgba(232,234,237,.35);animation:pop .7s ease both, pulse 1.6s ease 0.7s 2}
.splash-kicker{letter-spacing:.28em;font-size:11px;color:#9aa3ad;text-transform:uppercase}
.splash-title{font-size:clamp(22px,4vw,36px);font-weight:700;margin:10px 0 14px;letter-spacing:.02em}
.splash-bar{width:160px;height:3px;margin:0 auto;border-radius:99px;background:#2f3540;overflow:hidden}
.splash-bar i{display:block;height:100%;width:0;background:#d1d5db;animation:load 1.8s ease .3s forwards}
.splash-sub{color:#8b949e;margin-top:14px;font-size:13px}
@keyframes rise{from{transform:translateY(14px);opacity:0}to{opacity:1}}
@keyframes pop{from{transform:scale(.7);opacity:0}to{transform:scale(1);opacity:1}}
@keyframes pulse{50%{box-shadow:0 0 0 16px rgba(232,234,237,0)}}
@keyframes load{to{width:100%}}
.splash-out{animation:out .45s ease forwards;pointer-events:none}
@keyframes out{to{opacity:0;visibility:hidden}}

.screen-login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(148,163,184,.22), transparent 50%),
    radial-gradient(900px 400px at 100% 100%, rgba(42,47,54,.10), transparent 45%),
    var(--paper);
}

.login-card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 36px 32px 28px;
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(160deg, var(--wine-2), var(--wine-deep));
  color: var(--gold-2);
  display: grid; place-items: center;
  font-family: Fraunces, serif; font-size: 28px; font-weight: 700;
  margin-bottom: 18px;
}
.login-card h1 { font-family: Fraunces, serif; font-size: 30px; line-height: 1.1; }
.login-card p.lead { color: var(--ink-soft); margin: 8px 0 24px; }

.pin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.pin-display {
  height: 58px; border-radius: 16px; background: var(--paper-2);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  letter-spacing: 10px; font-size: 28px; font-weight: 700;
}
.pin-key {
  height: 64px; border-radius: 16px; background: #fff; border: 1px solid var(--line);
  font-size: 22px; font-weight: 600;
}
.pin-key:hover { background: var(--paper-2); }
.pin-key.ok { background: var(--wine); color: #fff; border-color: var(--wine); }
.pin-key.muted { color: var(--ink-soft); }
.users-hint { margin-top: 18px; color: var(--ink-soft); font-size: 13px; }

.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.nav {
  background: var(--wine-deep);
  color: #d7dbe0;
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 10px; gap: 8px;
}
.nav .logo {
  width: 52px; height: 52px; border-radius: 16px;
  background: linear-gradient(160deg, var(--wine-2), var(--wine-deep));
  display: grid; place-items: center;
  font-family: Fraunces, serif; font-weight: 700; font-size: 24px; color: var(--gold-2);
  margin-bottom: 10px;
}
.nav-btn {
  width: 100%; border-radius: 14px; padding: 10px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: #c5cbd3; font-size: 11px; font-weight: 560;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.active, .nav-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-spacer { flex: 1; }

.workspace { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 68px; display: flex; align-items: center; gap: 14px;
  padding: 0 20px; border-bottom: 1px solid var(--line); background: #eef1f4;
  backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 5;
}
.topbar h2 { font-family: Fraunces, serif; font-size: 22px; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 0 16px; height: 42px;
}
.search input { flex: 1; border: 0; outline: none; background: transparent; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 560;
  background: #fff; border: 1px solid var(--line);
}
.chip.ok { background: var(--sage-soft); color: var(--sage); border-color: #b7d0c2; }
.chip.warn { background: #f8e3c4; color: #8a4e0c; border-color: #efd0a0; }
.chip.bad { background: #f6d7dc; color: var(--danger); border-color: #e8b4bc; }

.page { padding: 18px 20px 28px; }

.pos-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 16px;
  align-items: start;
}
.cats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.cat {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; font-weight: 560; font-size: 13px;
}
.cat.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
}
.product {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  overflow: hidden; text-align: left; display: flex; flex-direction: column;
  min-height: 198px; transition: transform .12s ease, box-shadow .12s ease;
}
.product:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.product .thumb {
  height: 96px; background:
    linear-gradient(135deg, #c5ccd4, #8b949e);
  display: grid; place-items: center; color: #fff; font-family: Fraunces, serif; font-size: 28px;
  position: relative;
}
.product .thumb img { width: 100%; height: 100%; object-fit: cover; }
.product .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.product .name { font-weight: 600; font-size: 14px; line-height: 1.25; }
.product .meta { color: var(--ink-soft); font-size: 12px; }
.product .price { margin-top: auto; font-weight: 700; }
.stock-dot {
  position: absolute; right: 8px; top: 8px;
  background: rgba(255,255,255,.92); color: var(--sage);
  border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 700;
}
.stock-dot.low { color: var(--warn); }
.stock-dot.out { color: var(--danger); }

.cart {
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  padding: 16px; position: sticky; top: 84px;
  display: flex; flex-direction: column; min-height: calc(100vh - 110px);
}
.cart h3 { font-family: Fraunces, serif; margin-bottom: 10px; }
.cart-lines { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 8px; max-height: 42vh; }
.line {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 10px;
  padding: 10px; border-radius: 14px; background: var(--paper);
}
.line .qty {
  display: flex; align-items: center; gap: 8px;
}
.qbtn {
  width: 28px; height: 28px; border-radius: 8px; background: #fff; border: 1px solid var(--line);
  font-weight: 700;
}
.totals { border-top: 1px dashed var(--line); padding-top: 12px; margin-top: 12px; display: grid; gap: 6px; }
.totals .row { display: flex; justify-content: space-between; color: var(--ink-soft); }
.totals .row.grand { color: var(--ink); font-size: 22px; font-weight: 700; font-family: Fraunces, serif; }
.pay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.pay {
  height: 46px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-weight: 600;
}
.pay.active { background: var(--wine); color: #fff; border-color: var(--wine); }
.btn {
  height: 48px; border-radius: 14px; padding: 0 16px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.primary { background: var(--wine); color: #fff; width: 100%; }
.btn.primary:disabled { opacity: .45; }
.btn.ghost { background: #fff; border: 1px solid var(--line); }
.btn.sage { background: var(--sage); color: #fff; }
.btn.warn { background: #9b2332; color: #fff; }
.btn.sm { height: 36px; border-radius: 10px; font-size: 13px; padding: 0 12px; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 16px 18px;
}
.stat .label { color: var(--ink-soft); font-size: 13px; }
.stat .value { font-family: Fraunces, serif; font-size: 30px; margin-top: 4px; }
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 16px 18px; margin-top: 14px;
}
.panel h3 { font-family: Fraunces, serif; margin-bottom: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--ink-soft); font-weight: 560; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }

.form { display: grid; gap: 10px; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 560; color: var(--ink-soft); }
input[type="text"], input[type="number"], input[type="url"], input[type="password"], input[type="email"], select, textarea {
  height: 44px; border-radius: 12px; border: 1px solid var(--line); background: #fff; padding: 0 12px; outline: none;
}
textarea { height: 88px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #6b7280; box-shadow: 0 0 0 3px rgba(107,114,128,.25); }

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 50;
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 14px;
  box-shadow: var(--shadow); max-width: 360px;
  pointer-events: none;
}
.toast[hidden], .modal[hidden] {
  display: none !important;
  pointer-events: none !important;
}
.modal {
  position: fixed; inset: 0; background: rgba(28,20,16,.45);
  display: none;
  place-items: center; z-index: 40; padding: 20px;
}
.modal:not([hidden]) {
  display: grid;
}
.modal-card {
  width: min(520px, 100%); background: var(--card); border-radius: 24px; padding: 22px;
  box-shadow: var(--shadow);
}
.modal-card h3 { font-family: Fraunces, serif; margin-bottom: 8px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.bars { display: flex; align-items: flex-end; gap: 8px; height: 140px; }
.bar { flex: 1; background: linear-gradient(180deg, var(--wine-2), var(--wine-deep)); border-radius: 8px 8px 4px 4px; min-height: 6px; position: relative; }
.bar span { position: absolute; top: -22px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.bar em { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 10px; font-style: normal; color: var(--ink-soft); }

.empty { color: var(--ink-soft); padding: 28px 8px; text-align: center; }

.ticket {
  width: 280px; margin: 0 auto; background: #fff; color: #111; padding: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
}
.ticket h1 { text-align: center; font-family: Fraunces, serif; font-size: 18px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

@media (max-width: 1100px) {
  .pos-layout { grid-template-columns: 1fr; }
  .cart { position: static; min-height: auto; }
  .cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .nav {
    position: sticky; bottom: 0; top: auto; flex-direction: row; width: 100%;
    order: 2; z-index: 6; overflow: auto; padding: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
  .nav .logo, .nav-spacer, .nav-btn span { display: none; }
  .nav-btn { width: auto; padding: 10px 12px; }
  .workspace { order: 1; padding: 10px 10px 88px; }
  .cards { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 8px; }
  .topbar h2 { font-size: 18px; }
  .pos-layout { grid-template-columns: 1fr; }
  .cart { position: static; width: 100%; }
  .pay-grid { grid-template-columns: 1fr 1fr; }
  .cust-grid, .cust-row, .split { grid-template-columns: 1fr; }
  .modal { padding: 8px; align-items: end; }
  .modal-card { width: 100%; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0; }
  input, select, textarea, button.pay { font-size: 16px; }
  table { font-size: 13px; }
  .panel { overflow: auto; }
}
.cust-box{margin:10px 0;padding:10px 12px;border:1px solid var(--line);border-radius:14px;background:#fff}
.cust-now{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px;font-weight:600}
.cust-row{display:grid;grid-template-columns:1fr 1fr auto;gap:6px;margin-bottom:6px}
.cust-box input{height:36px;border:1px solid var(--line);border-radius:10px;padding:0 10px;width:100%;background:#f7f8fa}
.cust-grid{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-top:8px}
.cust-grid input{height:36px;border:1px solid var(--line);border-radius:10px;padding:0 10px;width:100%;background:#f7f8fa}
#ticket-cust-hits .btn{margin:3px 0}
.pay-ok,.pay-miss{display:flex;justify-content:space-between;align-items:center;margin-top:8px;padding:8px 10px;border-radius:10px;font-weight:700}
.pay-ok{background:#dcefe4;color:#1e5a3a}
.pay-miss{background:#f3e4e4;color:#7a1f1f}

.doc-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:8px 0}
.staff-pick{display:grid;gap:8px;margin-top:12px}
.staff-pick .btn{display:flex;flex-direction:column;align-items:flex-start;height:auto;padding:12px 14px;text-align:left}
.staff-pick small{color:var(--ink-soft);font-weight:500}
.paper-pos { width: 72mm; font-size: 12px; }
.paper-carta, .paper-oficio { width: 100%; max-width: 190mm; font-size: 13px; }
@media print {
  body * { visibility: hidden; }
  #print-ticket, #print-ticket * { visibility: visible; }
  #print-ticket { position: absolute; left: 0; top: 0; background: #fff; color: #111; }
  body[data-print="carta"] #print-ticket,
  body[data-print="oficio"] #print-ticket { width: 190mm; max-width: 190mm; }
}
@page { size: 80mm auto; margin: 4mm; }
@media print {
  body[data-print="carta"] { }
}
@page carta-page { size: letter portrait; margin: 12mm; }
@page oficio-page { size: 216mm 330mm; margin: 12mm; }
@page pos-page { size: 80mm auto; margin: 4mm; }
@media print {
  body[data-print="carta"] { page: carta-page; }
  body[data-print="oficio"] { page: oficio-page; }
  body[data-print="pos"] { page: pos-page; }
}
.calc-wrap{display:grid;grid-template-columns:minmax(280px,380px) 1fr;gap:22px;align-items:start}
.calc-toy{background:linear-gradient(160deg,#2a2f36,#1c2128);border-radius:28px;padding:22px;box-shadow:0 22px 50px rgba(20,24,28,.28);color:#e8eaed}
.calc-vibe{min-height:24px;font-size:13px;letter-spacing:.04em;color:#9aa3ad;margin-bottom:8px}
.calc-edit{display:block;font-size:12px;color:#9aa3ad;margin-bottom:8px}
.calc-input{width:100%;margin-top:6px;background:#111318;border:1px solid #3a414b;border-radius:14px;color:#fff;font-size:22px;font-weight:600;padding:14px 12px;text-align:right}
.calc-result{background:#0d0f12;border-radius:14px;padding:14px 12px;font-size:28px;font-weight:700;text-align:right;margin:10px 0 14px;min-height:56px;color:#b6f3c8}
.calc-keys{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}
.calc-key{height:56px;border-radius:16px;background:#3a414b;color:#fff;font-weight:700;font-size:18px;transition:transform .08s ease,background .15s}
.calc-key:active{transform:scale(.94)}
.calc-key.gold{background:#5b6570}
.calc-key.ok{background:#2f6f4e}
.calc-key.muted{background:#252a31;color:#9aa3ad}
.calc-extra{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}
.calc-chip{background:#111318;color:#e8eaed;border-radius:999px;padding:8px 12px;font-size:12px;font-weight:600}
.calc-line{display:block;width:100%;text-align:left;background:transparent;padding:10px 0;border-bottom:1px solid var(--line);color:inherit;cursor:pointer;font-variant-numeric:tabular-nums}
@media (max-width:900px){.calc-wrap{grid-template-columns:1fr}}
