:root {
  --bg: #f5f5f4; --panel: #ffffff; --panel-2: #fafaf9; --line: #e7e5e4; --line-2: #d6d3d1;
  --ink: #0c0a09; --ink-2: #44403c; --muted: #78716c;
  --accent: #0c0a09; --accent-ink: #ffffff;
  --ok: #15803d; --ok-bg: #dcfce7; --warn: #b45309; --warn-bg: #fef3c7; --bad: #b91c1c; --bad-bg: #fee2e2; --info: #1d4ed8; --info-bg: #dbeafe;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
  --side: 232px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0c; --panel: #141416; --panel-2: #1a1a1d; --line: #26262a; --line-2: #34343a;
    --ink: #f4f4f5; --ink-2: #d4d4d8; --muted: #8b8b93; --accent: #f4f4f5; --accent-ink: #0b0b0c;
    --ok: #4ade80; --ok-bg: #12301d; --warn: #fbbf24; --warn-bg: #3a2a0b; --bad: #f87171; --bad-bg: #3b1414; --info: #93c5fd; --info-bg: #13243f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0b0c; --panel: #141416; --panel-2: #1a1a1d; --line: #26262a; --line-2: #34343a;
  --ink: #f4f4f5; --ink-2: #d4d4d8; --muted: #8b8b93; --accent: #f4f4f5; --accent-ink: #0b0b0c;
  --ok: #4ade80; --ok-bg: #12301d; --warn: #fbbf24; --warn-bg: #3a2a0b; --bad: #f87171; --bad-bg: #3b1414; --info: #93c5fd; --info-bg: #13243f;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 Inter, system-ui, -apple-system, Segoe UI, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 700; } h2 { font-size: 16px; font-weight: 600; } h3 { font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); }
.show-m { display: none; } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* Layout */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 10px 16px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.brand .logo-img { height: 74px; width: auto; }
.logo-img { display: block; }
.mobile-logo { height: 34px; width: auto; }
.auth-logo { height: 120px; width: auto; margin: 0 auto 4px; }
/* en modo oscuro el logo se ve en blanco */
:root[data-theme="dark"] .logo-img { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-img { filter: invert(1); } }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--panel-2); }
.nav a.on { background: var(--accent); color: var(--accent-ink); }
.nav .sep { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 4px; }
.nav svg { width: 18px; height: 18px; flex: none; }
.side .foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.main { min-width: 0; padding: 22px 28px 60px; }
.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.top h1 { margin-right: auto; }
.mobile-bar { display: none; }

/* UI */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card.pad { padding: 16px; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-h h2 { margin-right: auto; }
.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)); }
.kpi { padding: 14px 16px; }
.kpi .l { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .v { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; font-weight: 500; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { opacity: .9; }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.lg { height: 48px; font-size: 16px; font-weight: 600; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
input, select, textarea { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel); outline: none; }
textarea { height: auto; min-height: 70px; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 12%, transparent); }
input[type=checkbox] { width: auto; height: auto; }
label { display: grid; gap: 4px; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.form { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }
.row > .auto { flex: none; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters > * { width: auto; min-width: 140px; }
.filters input[type=search] { flex: 1; min-width: 200px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--panel); padding: 0 12px; height: 34px; cursor: pointer; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.click:hover { background: var(--panel-2); }
.t .num, .t .r { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px 12px; border-top: 1px solid var(--line); }
.note { padding: 10px 12px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.note.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--line); }
.list-plain li:last-child { border-bottom: 0; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding: 16px 16px 0; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .b i { display: block; width: 100%; max-width: 28px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .b span { font-size: 10px; color: var(--muted); padding-bottom: 8px; }
.hbar { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.hbar i { display: block; height: 100%; background: var(--accent); }

/* POS */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 14px; align-items: start; }
.pos-search { position: relative; }
.pos-search input { height: 48px; font-size: 16px; padding-left: 42px; }
.pos-search svg { position: absolute; left: 14px; top: 15px; width: 18px; height: 18px; color: var(--muted); }
.results { margin-top: 10px; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.prod { text-align: left; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); cursor: pointer; display: grid; gap: 4px; }
.prod:hover { border-color: var(--ink); }
.prod .n { font-weight: 600; font-size: 13px; line-height: 1.3; }
.prod .p { font-weight: 700; font-variant-numeric: tabular-nums; }
.prod.out { opacity: .55; }
.cart { position: sticky; top: 16px; display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.cart-items { overflow-y: auto; flex: 1; min-height: 120px; }
.ci { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.ci .n { font-weight: 500; font-size: 13px; }
.ci .ctl { display: flex; align-items: center; gap: 6px; }
.ci .ctl input { width: 64px; height: 30px; text-align: center; padding: 0 4px; }
.ci .ctl input.price { width: 100px; text-align: right; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: 8px; }
.qty button { width: 28px; height: 28px; border: 0; background: none; cursor: pointer; font-size: 16px; }
.qty input { border: 0 !important; box-shadow: none !important; width: 44px !important; }
.cart-foot { padding: 14px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.tot { display: flex; justify-content: space-between; align-items: baseline; }
.tot .big { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.pay-methods { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.pay-methods button { height: 44px; }
.pay-line { display: grid; grid-template-columns: 1fr 140px 32px; gap: 8px; align-items: center; }
.ac { position: relative; }
.ac-list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; }
.ac-list div { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--line); }
.ac-list div:hover, .ac-list div.sel { background: var(--panel-2); }

/* Modal y toasts */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .12s; }
.modal { background: var(--panel); 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,.3); }
.modal.wide { width: min(860px, 100%); }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-h h2 { margin-right: auto; }
.modal-b { padding: 18px; overflow-y: auto; }
.modal-f { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
#toasts { position: fixed; bottom: 16px; right: 16px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); font-weight: 500; max-width: 360px; animation: up .15s; }
.toast.err { background: var(--bad); color: #fff; }
@keyframes fade { from { opacity: 0 } }
@keyframes up { from { transform: translateY(8px); opacity: 0 } }

/* Auth */
body.auth, .auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 20px; }

/* Responsive */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .pos { grid-template-columns: 1fr; } .cart { position: static; max-height: none; } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .row > label { flex: 1 1 140px; }
  .side { height: 100vh; height: 100dvh; max-height: 100dvh; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .side .foot { padding-bottom: 8px; }
  .side-bg { display: none; position: fixed; inset: 0; z-index: 39; background: rgba(0,0,0,.45); }
  body.menu-open { overflow: hidden; }
  body.menu-open .side-bg { display: block; }
  .mobile-bar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 16px; font-weight: 700; }
  .main { padding: 16px 16px 60px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .hide-m { display: none; }
  .show-m { display: block; }
  .t th, .t td { padding: 9px 8px; }
  .filters > * { flex: 1; min-width: 0; }
  .pay-line { grid-template-columns: 1fr 110px 32px; }
}
@media print { .side, .mobile-bar, .top .btn { display: none !important; } .shell { display: block; } }