:root {
  --bg: #f4f5f7; --panel: #fff; --ink: #1d2330; --muted: #6b7385; --line: #e3e6ec; --soft: #f0f2f5;
  --brand: #1f5fbf; --brand-ink: #fff; --brand-soft: #e8f0fc;
  --ok: #1f8a4c; --ok-soft: #e6f4ec; --warn: #b46b00; --warn-soft: #fdf3e2; --bad: #c4352b; --bad-soft: #fbeaea;
  --r: 10px; --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 16px rgba(20, 30, 50, .05);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 24px 0 10px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .strong { font-weight: 600; } .mono { font-family: ui-monospace, Menlo, monospace; }
.ok-text { color: var(--ok); } .warn-text { color: var(--warn); } .bad-text { color: var(--bad); } .nowrap { white-space: nowrap; }
.big { font-size: 20px; }

/* Marco */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: #141b2b; color: #cfd5e2; display: flex; flex-direction: column; padding: 14px 10px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #fff; padding: 4px 8px 16px; }
.brand.big { color: var(--ink); font-size: 22px; padding: 0 0 4px; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo { width: 32px; height: 32px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; flex: none; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: auto; }
.side nav a { color: #cfd5e2; padding: 9px 10px; border-radius: 8px; display: flex; gap: 10px; align-items: center; }
.side nav a:hover { background: #1f283c; }
.side nav a.on { background: var(--brand); color: #fff; }
.nav-icon { width: 18px; text-align: center; opacity: .85; }
.cash-pill { margin: 10px 8px; padding: 7px 10px; border-radius: 99px; background: #2a3247; color: #ffcf8a; font-size: 13px; text-align: center; }
.cash-pill.open { color: #8fe0b0; }
.side-user { display: flex; align-items: center; justify-content: space-between; padding: 10px 8px 2px; border-top: 1px solid #2a3247; gap: 8px; }
.side-user small { display: block; color: #8b93a7; }
.side-user .btn { color: #cfd5e2; }
.main { min-width: 0; }
.topbar { display: none; }
.scrim { display: none; }
.page { padding: 24px 28px 60px; max-width: 1280px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

/* Controles */
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: var(--soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: #f0c8c4; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--soft); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.big { padding: 13px 18px; font-size: 17px; }
.btn.block { width: 100%; }
.icon-btn { border: 0; background: transparent; font-size: 20px; line-height: 1; padding: 4px 8px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--soft); color: var(--ink); }
.input { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; background: #fff; color: var(--ink); width: 100%; min-width: 0; }
.input:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea.input { resize: vertical; }
select.input { width: auto; }
.field select.input { width: 100%; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: 13px; font-weight: 600; color: #444c5e; }
.field small { color: var(--muted); font-size: 12px; }
.check { display: flex; gap: 8px; align-items: center; margin: 8px 0; cursor: pointer; }
.w-num { width: 76px !important; text-align: right; }
.w-money { width: 116px !important; text-align: right; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 4px; flex-wrap: nowrap; }
.row.between { justify-content: space-between; }
.row.center { justify-content: center; }
.grow { flex: 1; }
.gap { height: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
.card .grid2 > .card, .grid2 > .card { margin: 0 0 14px; }
.filters { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.filters .input { width: auto; }
.filters .input.grow { flex: 1; min-width: 220px; }
.seg { display: inline-flex; background: var(--soft); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font: inherit; cursor: pointer; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 6px 0 14px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; font: inherit; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--brand); border-color: var(--brand); font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 5px 12px; font: inherit; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--brand-soft); border-color: #bcd1f2; color: #174a96; }
.chip-x { border: 0; background: none; cursor: pointer; color: inherit; font-size: 15px; padding: 0; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--soft); color: var(--muted); font-weight: 600; }
.tag.ok { background: var(--ok-soft); color: var(--ok); } .tag.warn { background: var(--warn-soft); color: var(--warn); } .tag.bad { background: var(--bad-soft); color: var(--bad); }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--soft); padding: 1px 6px; border-radius: 5px; }
.link { border: 0; background: none; color: var(--brand); cursor: pointer; font: inherit; padding: 0; }
.note-bar { background: var(--brand-soft); border-radius: 8px; padding: 9px 12px; margin: 10px 0; font-size: 14px; }
.note-bar.ok { background: var(--ok-soft); color: var(--ok); font-weight: 600; } .note-bar.bad { background: var(--bad-soft); color: var(--bad); font-weight: 600; }

/* Tarjetas y tablas */
.card { background: var(--panel); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 560px; }
.card.narrow.wide-ok { max-width: 860px; }
.card h3:first-child, .card h2:first-child { margin-top: 0; }
.table-wrap { overflow: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; position: sticky; top: 0; z-index: 1; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table.compact td, .table.compact th { padding: 6px 8px; }
.table .n { text-align: right; white-space: nowrap; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: #f7f9fc; }
.table tr.voided td { opacity: .5; text-decoration: line-through; }
.table tr.voided td .tag { text-decoration: none; }
.sumbar { color: var(--muted); font-size: 14px; margin: 0 0 8px; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpis.three { grid-template-columns: repeat(3, 1fr); }
.kpi { background: var(--panel); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.modal .kpi { box-shadow: none; border: 1px solid var(--line); }
.kpi span { font-size: 13px; color: var(--muted); }
.kpi b { font-size: 22px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi.accent { background: var(--brand); color: #fff; }
.kpi.accent span, .kpi.accent small { color: #d6e4fa; }
a.kpi { color: inherit; }
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 100px; gap: 10px; align-items: center; font-size: 14px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; }
.price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.price-cell { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.totals { display: flex; flex-direction: column; gap: 4px; margin: 12px 0; align-items: flex-end; }
.totals > div { display: flex; gap: 24px; justify-content: space-between; min-width: 240px; }
.totals .grand { font-size: 18px; border-top: 1px solid var(--line); padding-top: 6px; }

/* Modal y avisos */
.overlay { position: fixed; inset: 0; background: rgba(15, 20, 35, .45); display: grid; place-items: center; z-index: 50; 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 20px 60px rgba(0, 0, 0, .25); }
.modal.wide { width: min(940px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #1d2330; color: #fff; padding: 10px 16px; border-radius: 9px; box-shadow: var(--shadow); max-width: 380px; }
.toast.error { background: var(--bad); }

/* Buscador */
.finder { position: relative; margin-bottom: 10px; }
.finder-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .12); z-index: 20; max-height: 340px; overflow: auto; margin: 0; padding: 4px; list-style: none; }
.finder-list li { padding: 8px 10px; border-radius: 7px; cursor: pointer; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.finder-list li.on { background: var(--brand-soft); }

/* Cobro */
.payments { margin: 8px 0; }
.pay-methods { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.pay-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.pay-row > span { flex: 1; }
.pay-row .input { width: 150px; text-align: right; }
.pay-rest { border-radius: 8px; padding: 8px 12px; font-weight: 600; margin-top: 6px; }
.pay-rest.ok { background: var(--ok-soft); color: var(--ok); } .pay-rest.warn { background: var(--warn-soft); color: var(--warn); }
.pay-rest.bad { background: var(--bad-soft); color: var(--bad); } .pay-rest.change { background: var(--brand-soft); color: #174a96; }

/* Punto de venta */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; padding: 20px 24px; align-items: start; }
.pos-main { min-width: 0; }
.pos-search .input { font-size: 17px; padding: 12px 14px; }
.pos-lines { background: #fff; border-radius: var(--r); box-shadow: var(--shadow); max-height: calc(100vh - 230px); }
.pos-empty { text-align: center; color: var(--muted); padding: 48px 16px !important; }
.pos-side { position: sticky; top: 16px; }
.pos-side .card { margin-bottom: 12px; }
.qty-cell { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.unit { color: var(--muted); font-size: 12px; }
.line-name { font-weight: 500; }
.pick-prod, .pick-cust { display: flex; flex-direction: column; }
.pick-prod .name, .pick-cust .name { font-weight: 600; }
.stock { font-size: 12px; color: var(--muted); }
.stock.out { color: var(--bad); }
.cust-box { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.card.totals { align-items: stretch; }
.row.total { font-size: 22px; font-weight: 700; }
.done { text-align: center; }
.done .icon { font-size: 40px; color: var(--ok); }
.done-total { font-size: 28px; font-weight: 700; }
.done-change { font-size: 18px; color: var(--brand); font-weight: 600; margin: 4px 0 12px; }
.doc-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.doc-tot { text-align: right; }
.notes { white-space: pre-wrap; color: var(--muted); }
.kpi em { font-style: normal; color: var(--muted); font-size: 12px; }
.kpi.accent em { color: #d6e4fa; }
.pos-lines .qty-cell .input { width: 72px; text-align: right; }
.pos-lines td .input { width: 110px; text-align: right; }
.pos-lines td:nth-child(4) .input { width: 64px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #141b2b, #1f5fbf); }
.login-card { width: min(380px, 100%); padding: 28px; }

/* Celular y tablet */
@media (max-width: 960px) {
  .pos { grid-template-columns: 1fr; padding: 14px; }
  .pos-side { position: static; }
  .pos-lines { max-height: none; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 60; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .menu-open .side { transform: none; }
  .menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 55; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  .topbar .brand-name { flex: 1; font-weight: 700; }
  .page { padding: 16px 14px 60px; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .kpis.three { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 90px 1fr 84px; }
  .table td, .table th { padding: 8px; }
  h1 { font-size: 20px; }
}
@media (max-width: 520px) { .grid3 { grid-template-columns: 1fr; } }
