/* Caja Clara 2.0 — estilos. Paleta y estructura tomadas del diseño de
   referencia (fondo petróleo, acento verde, menú lateral, tablas con cabecera
   gris azulada). Sin imágenes de producto: todo se identifica por texto. */
:root {
  --bg: #0f1c22;
  --bg-2: #13242c;
  --panel: #1c2f38;
  --panel-2: #22394389;
  --surface: #172a33;
  --surface-2: #203742;
  --head: #2a4350;
  --border: #2c4652;
  --border-soft: #233b46;
  --text: #e9f1f4;
  --muted: #94abb6;
  --faint: #6c8590;
  --accent: #22e27a;
  --accent-2: #19c468;
  --accent-ink: #052414;
  --accent-soft: rgba(34, 226, 122, .12);
  --danger: #ff7272;
  --danger-soft: rgba(255, 114, 114, .12);
  --warn: #f6bd4f;
  --warn-soft: rgba(246, 189, 79, .13);
  --info: #6cc4ff;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .35);
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.green { color: var(--accent); }
.red { color: var(--danger); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- marca ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .14em; font-size: 17px; white-space: nowrap; }
.brand svg { flex: none; }
.brand b { color: var(--accent); font-weight: 800; }

.demo-banner {
  background: var(--warn); color: #2b1d00; text-align: center; font-weight: 700; font-size: 12px; padding: 5px 12px;
}

/* ---------- login ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(900px 500px at 85% -10%, rgba(34, 226, 122, .18), transparent 60%), var(--bg);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 28px 24px; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 15px; font-weight: 600; color: var(--muted); margin: 18px 0 2px; }
.login-card .local { font-size: 20px; font-weight: 700; margin: 0 0 18px; }
.pin-input {
  width: 100%; text-align: center; font-size: 28px; letter-spacing: .45em; padding: 12px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--mono);
}
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.keypad button {
  height: 54px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); font-size: 20px; font-weight: 600; cursor: pointer;
}
.keypad button:hover { background: var(--head); }
.keypad button:active { transform: scale(.97); }
.login-hint { margin-top: 14px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; grid-template-rows: 60px 1fr; min-height: 100vh; background: linear-gradient(90deg, var(--panel) 232px, var(--border-soft) 232px 233px, transparent 233px); }
.shell.collapsed { grid-template-columns: 72px 1fr; background: linear-gradient(90deg, var(--panel) 72px, var(--border-soft) 72px 73px, transparent 73px); }
.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 0 18px; background: var(--panel);
  border-bottom: 1px solid var(--border-soft); position: sticky; top: 0; z-index: 20;
}
.topbar .brand { width: 196px; }
.shell.collapsed .topbar .brand-text { display: none; }
.shell.collapsed .topbar .brand { width: 36px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border);
  background: transparent; cursor: pointer; color: var(--muted); position: relative; flex: none;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn .dot {
  position: absolute; top: -3px; right: -3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--accent);
  color: var(--accent-ink); font-size: 10px; font-weight: 800; display: grid; place-items: center;
}
.search {
  flex: 1; max-width: 420px; display: flex; align-items: center; gap: 8px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0 12px; height: 38px; color: var(--muted);
}
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); }
.topbar .spacer { flex: 1; }
.caja-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--text);
}
.caja-chip .led { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.caja-chip.on .led { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.user-chip { display: flex; align-items: center; gap: 9px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px;
  background: linear-gradient(135deg, var(--accent), #0ea5a0); color: var(--accent-ink); flex: none;
}
.user-chip .who { line-height: 1.15; }
.user-chip .who small { color: var(--muted); font-size: 11px; }

.sidebar {
  background: var(--panel); border-right: 1px solid var(--border-soft); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto;
}
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--muted);
  text-decoration: none; font-weight: 500; border: 0; background: none; width: 100%; text-align: left; cursor: pointer; position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--head); color: var(--text); font-weight: 700; }
.nav-item.active::before { content: ''; position: absolute; left: -12px; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-item.active svg { color: var(--accent); }
.nav-item.disabled { opacity: .55; cursor: default; }
.nav-item.disabled:hover { background: none; color: var(--muted); }
.nav-item .tag { font-style: normal; white-space: nowrap; margin-left: auto; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 8px; background: var(--surface-2); color: var(--muted); }
.nav-item .badge { margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 800; display: grid; place-items: center; }
.sidebar .grow { flex: 1; }
.shell.collapsed .nav-item span, .shell.collapsed .nav-item .tag { display: none; }
.shell.collapsed .nav-item { justify-content: center; }

.main { padding: 24px 28px 60px; min-width: 0; background: linear-gradient(180deg, var(--bg-2), var(--bg) 220px); }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 20px; margin: 0; font-weight: 800; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 800; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { border-color: rgba(255, 114, 114, .5); color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { background: transparent; }
.btn.big { height: 54px; font-size: 16px; padding: 0 22px; }
.btn.block { width: 100%; }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn.with-arrow { justify-content: space-between; min-width: 150px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 600; }

/* ---------- formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > label, .label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.label .opt { font-weight: 500; color: var(--faint); }
.input, select.input, textarea.input {
  width: 100%; height: 40px; padding: 0 12px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); outline: 0;
}
textarea.input { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.money { font-variant-numeric: tabular-nums; }
.input.lg { height: 48px; font-size: 18px; font-weight: 700; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1 1 120px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 6px 11px; border-radius: 16px; cursor: pointer; font-size: 13px; font-weight: 500;
}
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; flex: none; }
.seg button { border: 0; background: var(--bg-2); padding: 0 11px; height: 40px; cursor: pointer; color: var(--muted); font-weight: 700; }
.seg button[aria-pressed="true"] { background: var(--head); color: var(--accent); }
.input-group { display: flex; gap: 6px; }
.input-group .input { flex: 1; min-width: 0; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-2); }
.stepper button { width: 36px; height: 40px; border: 0; background: none; cursor: pointer; font-size: 18px; color: var(--muted); }
.stepper button:hover { color: var(--text); background: var(--surface-2); }
.stepper input { width: 46px; text-align: center; border: 0; background: none; height: 40px; outline: 0; font-weight: 700; }
.stepper.sm button { width: 28px; height: 30px; font-size: 15px; }
.stepper.sm input { width: 34px; height: 30px; }
.err { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(255, 114, 114, .35); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13px; margin: 10px 0; }
.note { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; color: var(--muted); }
.note.warn { background: var(--warn-soft); border-color: rgba(246, 189, 79, .35); color: var(--warn); }
.note.ok { background: var(--accent-soft); border-color: rgba(34, 226, 122, .35); color: var(--accent); }

/* ---------- tarjetas y tablas ---------- */
.card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card h2 { font-size: 15px; margin: 0 0 14px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.card h2 .count { margin-left: auto; color: var(--muted); font-weight: 600; font-size: 13px; }
.grid { display: grid; gap: 16px; }
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; background: var(--surface); }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
.t th {
  background: var(--head); text-align: left; font-weight: 700; padding: 12px 14px; white-space: nowrap; color: var(--text); position: sticky; top: 0; z-index: 1;
}
.t td { padding: 12px 14px; border-top: 1px solid var(--border-soft); vertical-align: middle; }
.t tbody tr:hover td { background: rgba(255, 255, 255, .025); }
.t tr.clickable { cursor: pointer; }
.t .num, .t .right { text-align: right; }
.t .title { color: var(--accent); font-weight: 600; }
.t .meta { color: var(--muted); font-size: 12px; }
.t tfoot td { font-weight: 800; background: var(--surface-2); }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty svg { color: var(--faint); margin-bottom: 8px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 12px; font-size: 11px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap;
}
.badge.ok { background: var(--accent-soft); color: var(--accent); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.neutral { background: var(--surface-2); color: var(--muted); }

/* ---------- vender ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 440px); gap: 18px; align-items: start; }
.pos .ticket { position: sticky; top: 84px; }
.ticket-lines { display: flex; flex-direction: column; max-height: 46vh; overflow-y: auto; margin: 0 -18px; }
.ticket-line { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 11px 18px; border-top: 1px solid var(--border-soft); }
.ticket-line .desc { font-weight: 600; color: var(--accent); overflow-wrap: anywhere; }
.ticket-line .sub { font-size: 12px; color: var(--muted); }
.ticket-line .amt { text-align: right; font-weight: 700; min-width: 86px; }
.ticket-line .amt s { color: var(--faint); font-weight: 500; font-size: 12px; display: block; }
.totals { border-top: 1px solid var(--border); margin: 0 -18px; padding: 14px 18px 0; }
.totals .line { display: flex; justify-content: space-between; padding: 3px 0; color: var(--muted); }
.totals .grand { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0 14px; font-size: 15px; font-weight: 700; }
.totals .grand .num { font-size: 30px; font-weight: 800; color: var(--text); }
.locked-ticket { opacity: .65; pointer-events: none; }

.medios { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.medio-btn {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius); padding: 12px 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; color: var(--muted);
}
.medio-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.pago-row { display: grid; grid-template-columns: 130px 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.cobro-total { text-align: center; padding: 6px 0 16px; }
.cobro-total .num { font-size: 38px; font-weight: 800; display: block; line-height: 1.1; }
.status-line { display: flex; justify-content: space-between; padding: 11px 14px; border-radius: var(--radius-sm); background: var(--surface-2); font-weight: 700; margin: 12px 0; }
.status-line.ok { background: var(--accent-soft); color: var(--accent); }
.status-line.bad { background: var(--warn-soft); color: var(--warn); }

/* ---------- dashboard ---------- */
.periodos { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 14px 16px; }
.kpi .k-label { font-size: 12px; color: var(--muted); font-weight: 700; }
.kpi .k-value { font-size: 22px; font-weight: 800; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .k-src { font-size: 11px; color: var(--faint); }
.kpi.accent { border-color: rgba(34, 226, 122, .4); background: linear-gradient(160deg, rgba(34, 226, 122, .10), var(--surface) 60%); }
.kpi.accent .k-value { color: var(--accent); }
.chart { width: 100%; height: 220px; }
.chart .bar { fill: var(--accent); }
.chart .bar:hover { fill: #7cf3b2; }
.chart .axis { fill: var(--faint); font-size: 10px; }
.chart .gridline { stroke: var(--border-soft); }
.dash-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(4, 12, 16, .66); display: grid; place-items: center; padding: 16px; z-index: 60; animation: fade .12s ease; }
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px);
  display: flex; flex-direction: column; box-shadow: var(--shadow); animation: pop .14s ease;
}
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border-soft); }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 800; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border-soft); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.toast-host { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--head); border: 1px solid var(--border); border-left: 4px solid var(--accent); padding: 11px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow); max-width: 360px; font-weight: 600; }
.toast.bad { border-left-color: var(--danger); }

/* ---------- comprobante (vista en pantalla) ---------- */
.comp {
  background: #fff; color: #111; border-radius: 8px; padding: 18px 18px 14px; font: 13px/1.4 var(--mono); max-width: 380px; margin: 0 auto;
}
.comp h4 { margin: 0; text-align: center; font-size: 15px; font-family: var(--font); }
.comp .tipo { text-align: center; font-weight: 800; letter-spacing: .08em; margin: 6px 0 2px; font-family: var(--font); }
.comp .nofiscal { border: 2px solid #111; text-align: center; font-weight: 800; padding: 5px; margin: 8px 0; font-family: var(--font); font-size: 12px; }
.comp .anulado { border: 3px solid #c00; color: #c00; text-align: center; font-weight: 900; font-size: 20px; padding: 6px; margin: 8px 0; letter-spacing: .1em; font-family: var(--font); }
.comp hr { border: 0; border-top: 1px dashed #777; margin: 8px 0; }
.comp .r { display: flex; justify-content: space-between; gap: 10px; }
.comp .r span:last-child { text-align: right; white-space: nowrap; }
.comp .it { margin: 5px 0; }
.comp .it .m { color: #555; font-size: 11px; }
.comp .tot { font-size: 16px; font-weight: 800; }
.comp .pie { text-align: center; font-size: 11px; color: #444; margin-top: 8px; }

#print { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .pos { grid-template-columns: 1fr; }
  .pos .ticket { position: static; }
}
@media (max-width: 860px) {
  .shell, .shell.collapsed { grid-template-columns: 1fr; grid-template-rows: 56px 1fr auto; background: none; }
  .topbar { padding: 0 12px; gap: 8px; height: 56px; }
  .topbar .brand { width: auto; }
  .topbar .brand-text, #toggleSidebar, .user-chip .who, .topbar .search { display: none; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto; flex-direction: row; padding: 6px; gap: 2px; z-index: 30;
    border-right: 0; border-top: 1px solid var(--border); justify-content: space-around; overflow: visible;
  }
  .sidebar .grow, .sidebar .nav-item.secondary { display: none; }
  .nav-item { flex-direction: column; gap: 3px; font-size: 10.5px; padding: 6px 4px; justify-content: center; text-align: center; }
  .nav-item.active::before { display: none; }
  .nav-item .badge { position: absolute; top: 0; right: 8px; margin: 0; }
  .main { padding: 18px 16px 96px; }
  .medios { grid-template-columns: repeat(2, 1fr); }
  .pago-row { grid-template-columns: 1fr 1fr; }
  .pago-row > :last-child { grid-column: span 2; }
  .modal-back { place-items: end center; padding: 0; }
  .modal { max-height: 92vh; border-radius: 16px 16px 0 0; }
  .toast-host { left: 16px; right: 16px; bottom: 84px; }
}

/* ---------- impresión: solo el comprobante ---------- */
@media print {
  @page { size: 80mm auto; margin: 4mm; }
  body { background: #fff !important; color: #000; }
  #app, .modal-back, .toast-host, .demo-banner { display: none !important; }
  #print { display: block !important; }
  #print .comp { max-width: none; padding: 0; border-radius: 0; }
}
