:root {
  /* Marca Kobralia */
  --brand-violet: #5B3DF5;
  --brand-mint: #12C99B;
  --brand-night: #15123A;
  --bg: #f1f0f8;
  --panel: #ffffff;
  --ink: #1c1a33;
  --muted: #6e6a8c;
  --line: #e0dded;
  --primary: var(--brand-violet);
  --primary-ink: #ffffff;
  --primary-soft: #ebe7fe;
  --side: var(--brand-night);
  --side-ink: #cfcbe8;
  --ok: #0c9b76;
  --ok-soft: #dcf7ee;
  --warn: #b26a00;
  --warn-soft: #fff3dc;
  --bad: #c62f2f;
  --bad-soft: #fde7e7;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
kbd { font: 11px ui-monospace, Menlo, monospace; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); border-radius: 4px; padding: 1px 5px; }
.btn kbd { background: rgba(0,0,0,.08); border-color: rgba(0,0,0,.12); }
.btn.ok kbd { background: rgba(21,18,58,.1); border-color: rgba(21,18,58,.2); }
.btn.primary kbd { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.3); }

/* Layout */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; padding: 16px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-logo { width: 38px; height: 38px; border-radius: 10px; flex: none; }
.brand-name { color: #fff; font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.brand-sub { font-size: 12px; opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
nav { display: flex; flex-direction: column; padding: 10px 8px; gap: 2px; flex: 1; overflow: auto; }
nav a { color: var(--side-ink); text-decoration: none; padding: 9px 10px; border-radius: 8px; display: flex; align-items: center; gap: 10px; }
nav a span { width: 20px; text-align: center; }
nav a kbd { margin-left: auto; }
nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
nav a.active { background: var(--primary); color: #fff; }
.sidebar-foot { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.caja-status { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.caja-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.caja-status.open .dot { background: #34d17c; }
.clock { opacity: .7; }
main { padding: 18px 22px; min-width: 0; }

.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.small { font-size: 12px; }

/* Controls */
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.field input, label.field select, label.field textarea { font-size: 14px; color: var(--ink); }
label.check { display: flex; gap: 8px; align-items: center; }
.btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 8px 12px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; justify-content: center; white-space: nowrap; }
.btn:hover { border-color: #b9c4d4; background: #f7f9fc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ok { background: var(--brand-mint); border-color: var(--brand-mint); color: var(--brand-night); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.sm { padding: 4px 8px; font-size: 12px; }
.btn.lg { padding: 14px 16px; font-size: 16px; font-weight: 700; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--primary-soft); color: var(--primary); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }

/* Tables */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #f6f8fb; font-size: 12px; color: var(--muted); font-weight: 600; position: sticky; top: 0; z-index: 1; }
tbody tr:hover { background: #fafcff; }
tr.selected td { background: var(--primary-soft); }
tr.clickable { cursor: pointer; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

/* KPI */
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* POS */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; height: calc(100vh - 36px); }
.pos-left { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.pos-search { display: flex; gap: 8px; position: relative; }
.pos-search input { flex: 1; font-size: 18px; padding: 12px 14px; }
.suggest { position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(15,39,71,.15); z-index: 20; max-height: 320px; overflow: auto; }
.suggest div { padding: 9px 12px; display: flex; justify-content: space-between; gap: 10px; cursor: pointer; }
.suggest div.active, .suggest div:hover { background: var(--primary-soft); }
.pos-cart { flex: 1; min-height: 0; }
.pos-cart td input { width: 80px; padding: 5px 7px; text-align: right; }
.pos-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.pos-right { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.total-box { background: linear-gradient(135deg, var(--brand-night) 0%, #2a1f7a 100%); color: #fff; border-radius: var(--radius); padding: 16px; }
.total-box .lbl { font-size: 12px; opacity: .75; text-transform: uppercase; letter-spacing: .06em; }
.total-box .big { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; margin: 4px 0 10px; }
.total-box .line { display: flex; justify-content: space-between; font-size: 13px; opacity: .85; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .full { grid-column: 1 / -1; }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; overflow: auto; }
.quick button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 10px 8px; cursor: pointer; text-align: left; font: inherit; }
.quick button:hover { border-color: var(--primary); background: var(--primary-soft); }
.quick .q-name { font-size: 12px; font-weight: 600; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.quick .q-price { font-size: 12px; color: var(--primary); margin-top: 4px; }
.cats { display: flex; gap: 6px; flex-wrap: wrap; }
.cats button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.cats button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Cobro */
.pay-total { font-size: 34px; font-weight: 800; text-align: center; margin: 4px 0 12px; font-variant-numeric: tabular-nums; }
.pay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pay-grid input { font-size: 18px; text-align: right; }
.bills { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.change { margin-top: 14px; padding: 12px; border-radius: var(--radius); background: var(--ok-soft); color: var(--ok); display: flex; justify-content: space-between; font-size: 20px; font-weight: 700; }
.change.missing { background: var(--bad-soft); color: var(--bad); }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(15,39,71,.45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.modal.wide { width: min(900px, 100%); }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-head h2 { margin: 0; flex: 1; }
.modal-head .x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .full { grid-column: 1 / -1; }

/* Toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--side); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 8px 20px rgba(0,0,0,.2); animation: tin .2s ease; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }
@keyframes tin { from { transform: translateY(10px); opacity: 0; } }

/* Bars */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 10px; }
.bars .bar { flex: 1; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars .bar:hover { filter: brightness(1.15); }
.bars-labels { display: flex; gap: 4px; font-size: 10px; color: var(--muted); }
.bars-labels span { flex: 1; text-align: center; overflow: hidden; white-space: nowrap; }
.hbar { height: 8px; background: var(--primary-soft); border-radius: 4px; overflow: hidden; }
.hbar > div { height: 100%; background: var(--primary); }

/* Ticket print */
#print-area { display: none; }
.ticket { width: 72mm; font: 12px/1.35 ui-monospace, Menlo, Consolas, monospace; color: #000; }
.ticket .c { text-align: center; }
.ticket hr { border: 0; border-top: 1px dashed #000; margin: 6px 0; }
.ticket table td { padding: 1px 0; border: 0; }
.ticket .tot { font-size: 15px; font-weight: 700; }
@media print {
  @page { margin: 4mm; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
}

@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  nav { flex-direction: row; flex-wrap: wrap; }
  .pos { grid-template-columns: 1fr; height: auto; }
  .cols-4, .cols-3 { grid-template-columns: 1fr 1fr; }
}

/* Carga, acceso y sesión */
.loading { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; background: var(--bg); color: var(--muted); z-index: 300; }
.loading img { width: 56px; height: 56px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.9); opacity: .7; } }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 10% -10%, #2a1f7a 0%, var(--brand-night) 60%); }
.auth-card { background: #fff; border-radius: 16px; width: min(420px, 100%); padding: 28px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.auth-card .logo { height: 44px; margin-bottom: 18px; }
.auth-card h1 { margin-bottom: 4px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.auth-card .btn.primary { padding: 11px; font-weight: 700; }
.auth-tabs { display: flex; gap: 4px; background: #f1f0f8; border-radius: 10px; padding: 4px; margin-top: 16px; }
.auth-tabs button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 8px; font: inherit; cursor: pointer; color: var(--muted); }
.auth-tabs button.active { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.link { border: 0; background: none; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }
.sidebar .link { color: var(--brand-mint); }
.side-select { width: 100%; margin-bottom: 8px; background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.15); font-size: 12px; padding: 6px 8px; }
.side-select option { color: var(--ink); }
.side-user { display: flex; justify-content: space-between; gap: 8px; margin: 6px 0 2px; }
.side-user span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notice { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.notice.info { background: var(--primary-soft); color: var(--primary); }
.btn.busy { pointer-events: none; opacity: .6; }
