:root {
  --bg: #0a0a0c; --panel: #131317; --panel2: #1a1a20; --line: #26262e; --txt: #f4f4f6; --mut: #8a8a96;
  --pri: #ffffff; --pri-txt: #0a0a0c; --ok: #22c55e; --bad: #ef4444; --warn: #f5a524; --acc: #a78bfa;
  --r: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--txt); }
body { font: 15px/1.35 'Inter', system-ui, 'Segoe UI', Roboto, sans-serif; user-select: none; overscroll-behavior: none; }
input, select, textarea { user-select: text; }
.hidden { display: none !important; }
.mut { color: var(--mut); } .small { font-size: 12px; } .center { text-align: center; } .err { color: var(--bad); min-height: 18px; text-align: center; }
h2 { margin: 0 0 6px; font-size: 20px; } h3 { margin: 0 0 10px; font-size: 16px; letter-spacing: .02em; }

/* Login */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(circle at 50% 30%, #1b1b22 0, var(--bg) 60%); }
.login-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.login-logo { width: 78%; margin: 0 auto 6px; display: block; }

/* Header */
.top { display: flex; align-items: center; gap: 14px; padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top));
  background: rgba(10,10,12,.92); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; backdrop-filter: blur(8px); }
.brand { height: 30px; }
.tabs { display: flex; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 3px; overflow-x: auto; }
.tabs button { background: none; border: 0; color: var(--mut); padding: 8px 13px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.tabs button.on { background: var(--pri); color: var(--pri-txt); }
.status { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pill { font-size: 12px; padding: 5px 10px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); color: var(--mut); white-space: nowrap; }
.pill.ok { color: var(--ok); border-color: #1d4d2f; } .pill.warn { color: var(--warn); border-color: #5a4314; } .pill.bad { color: #fff; background: var(--bad); border-color: var(--bad); }
.icon-btn { background: var(--panel); border: 1px solid var(--line); color: var(--txt); border-radius: 10px; width: 34px; height: 30px; cursor: pointer; }

main { padding: 14px; max-width: 1500px; margin: 0 auto; }
.view { display: none; } .view.on { display: block; }

/* POS */
.pos { display: grid; grid-template-columns: 1fr 390px; gap: 14px; height: calc(100vh - 86px); }
@media (max-width: 960px) { .pos { grid-template-columns: 1fr; height: auto; } .cart { position: sticky; bottom: 0; } }
.catalog { display: flex; flex-direction: column; min-height: 0; }
.catalog-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.chips { display: flex; gap: 6px; overflow-x: auto; flex: 1; padding-bottom: 2px; }
.chip { padding: 9px 15px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); color: var(--txt); cursor: pointer; font: inherit; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--pri); color: var(--pri-txt); border-color: var(--pri); }
.search { width: 170px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; overflow-y: auto; align-content: start; padding-bottom: 20px; }
.prod { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 12px 12px; min-height: 104px;
  cursor: pointer; text-align: left; color: var(--txt); display: flex; flex-direction: column; justify-content: space-between; font: inherit; overflow: hidden;
  transition: transform .06s, border-color .1s; }
.prod::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--acc)); }
.prod:active { transform: scale(.96); border-color: var(--pri); }
.prod b { font-size: 16px; line-height: 1.2; } .prod span { color: var(--mut); font-weight: 600; font-size: 15px; }
.prod .badge { position: absolute; top: 8px; right: 8px; background: var(--pri); color: var(--pri-txt); border-radius: 99px; min-width: 24px; height: 24px; font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0 6px; }

.cart { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; min-height: 0; }
.cart-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 14px 4px; }
.cart-head h3 { margin: 0; }
.link { background: none; border: 0; color: var(--mut); cursor: pointer; font: inherit; text-decoration: underline; }
.cart-rows { flex: 1; overflow-y: auto; padding: 0 14px; min-height: 120px; }
.crow { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.crow .n { flex: 1; font-weight: 600; } .crow .n div { font-weight: 400; }
.q { display: flex; align-items: center; gap: 6px; }
.q button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--txt); font-size: 20px; cursor: pointer; }
.q b { min-width: 22px; text-align: center; }
.cart-foot { padding: 12px 14px 14px; border-top: 1px solid var(--line); }
.total { display: flex; justify-content: space-between; font-size: 30px; font-weight: 800; margin-bottom: 12px; letter-spacing: -.01em; }
.pay3 { display: grid; grid-template-columns: 1fr 1.3fr .8fr; gap: 8px; }
.empty { color: var(--mut); text-align: center; padding: 40px 10px; }

/* Buttons */
.btn { padding: 13px 14px; border-radius: 12px; border: 1px solid transparent; font: inherit; font-size: 16px; font-weight: 700; cursor: pointer;
  color: var(--txt); background: var(--panel2); display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.btn small { font-size: 10px; opacity: .55; font-weight: 600; }
.btn.primary { background: var(--pri); color: var(--pri-txt); }
.btn.cash { background: var(--ok); color: #04130a; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.ghost { background: var(--panel2); border-color: var(--line); }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; display: inline-flex; flex-direction: row; }
.btn.big { padding: 16px; font-size: 17px; }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }

/* Cards / forms */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; flex-wrap: wrap; }
.card-head h3 { margin: 0; }
.kv { display: flex; justify-content: space-between; padding: 5px 0; gap: 10px; }
.kv.big { font-size: 20px; font-weight: 800; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.kpi div { color: var(--mut); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; } .kpi b { font-size: 24px; display: block; margin-top: 4px; }
label { display: block; font-size: 12px; color: var(--mut); margin: 10px 0 5px; text-transform: uppercase; letter-spacing: .05em; }
input, select { background: #0d0d11; border: 1px solid var(--line); color: var(--txt); border-radius: 10px; padding: 11px 12px; font: inherit; font-size: 16px; width: 100%; outline: none; }
input:focus, select:focus { border-color: #55556a; }
.big-input { font-size: 26px; font-weight: 700; text-align: center; padding: 14px; }
.check { display: flex; gap: 8px; align-items: center; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--txt); margin: 12px 0 0; }
.check input { width: 20px; height: 20px; }
.inline { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; } .inline > * { flex: 1; min-width: 110px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
th { color: var(--mut); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
td.r, th.r { text-align: right; } td input { padding: 7px 9px; font-size: 14px; }
.tag { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--panel2); font-weight: 700; white-space: nowrap; }
.tag.paid { color: var(--ok); } .tag.void, .tag.failed, .tag.canceled { color: var(--bad); } .tag.pending { color: var(--warn); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 18px; }
.bar i { display: block; width: 100%; background: var(--pri); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bar span { font-size: 10px; color: var(--mut); }
.denoms { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.denom { display: flex; align-items: center; gap: 6px; background: #0d0d11; border: 1px solid var(--line); border-radius: 10px; padding: 4px 4px 4px 10px; }
.denom span { flex: 1; font-weight: 600; font-size: 14px; } .denom input { width: 70px; text-align: center; padding: 7px; }
pre { background: #0d0d11; border: 1px solid var(--line); padding: 10px; border-radius: 10px; overflow: auto; max-height: 260px; font-size: 12px; white-space: pre-wrap; }
.ticket-preview { background: #fff; color: #000; font-family: Consolas, 'Courier New', monospace; font-size: 11px; line-height: 1.25; padding: 12px; border-radius: 6px; white-space: pre; overflow: auto; max-height: 420px; }

/* Modals */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 20; backdrop-filter: blur(3px); }
.modal.on { display: flex; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 22px; width: 100%; max-width: 440px; max-height: 92vh; overflow: auto; }
.amount { font-size: 46px; font-weight: 900; letter-spacing: -.02em; margin: 4px 0 6px; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.spin { width: 54px; height: 54px; border: 5px solid var(--line); border-top-color: var(--pri); border-radius: 50%; animation: s 1s linear infinite; margin: 18px auto; }
@keyframes s { to { transform: rotate(360deg); } }
.result { font-size: 64px; line-height: 1; margin: 14px 0 6px; font-weight: 900; }
.result.ok { color: var(--ok); } .result.bad { color: var(--bad); }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #23232b; border: 1px solid #3a3a46; padding: 12px 18px; border-radius: 12px;
  display: none; z-index: 30; max-width: 92vw; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
#toast.bad { border-color: var(--bad); } #toast.ok { border-color: var(--ok); }

@media (max-width: 700px) { .brand { height: 24px; } .status .pill#modePill { display: none; } main { padding: 10px; } .total { font-size: 26px; } }

/* Ajustes finos */
.pos { grid-template-columns: minmax(0, 1fr) 390px; }
.catalog-bar > *, .chips, .catalog { min-width: 0; }
#cardCancel, #cardClose { grid-column: 1 / -1; }
.bars { justify-content: center; } .bar { max-width: 56px; }
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }
@media (max-width: 960px) {
  .pos { display: block; height: auto; }
  .grid { overflow: visible; padding-bottom: 12px; }
  .cart { position: sticky; bottom: 8px; margin-top: 12px; box-shadow: 0 -10px 30px rgba(0,0,0,.6); }
  .cart-rows { max-height: 28vh; min-height: 0; }
  .cart .empty { padding: 10px; }
  .search { width: 120px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .cols { grid-template-columns: minmax(0, 1fr); }
}

.role-btn { background: var(--panel); border: 1px solid var(--line); color: var(--txt); border-radius: 10px; height: 30px; padding: 0 12px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.role-btn.admin { background: var(--warn); color: #1a1100; border-color: var(--warn); }
