:root {
  --accent: #3C50E0; --accent-dark: #2536B8; --accent-soft: #EFF2FF; --sky: #80CAEE;
  --side: #1C2434; --side-active: #333A48; --side-text: #DEE4EE; --side-label: #8A99AF;
  --bg: #F1F5F9; --card: #FFFFFF; --line: #E2E8F0; --line-soft: #F1F5F9; --input: #CBD5E1;
  --text: #1C2434; --muted: #64748B; --muted-2: #475569;
  --ok: #047857; --ok-soft: #ECFDF3; --warn: #B54708; --warn-soft: #FFFAEB;
  --bad: #B42318; --bad-soft: #FEF3F2; --purple: #5925DC; --purple-soft: #F4F3FF;
  --radius: 10px;
  font-family: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 13px; }
.muted { color: var(--muted); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--side); color: var(--side-text); padding: 28px 20px; display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; color: #fff; font-size: 23px; font-weight: 800; letter-spacing: -0.02em; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; flex-shrink: 0; }
.nav { display: flex; flex-direction: column; gap: 20px; }
.nav-group { display: flex; flex-direction: column; gap: 3px; }
.nav-label { font-size: 12px; font-weight: 600; color: var(--side-label); padding: 0 12px 6px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 8px; color: var(--side-text); font-weight: 500; }
.nav a:hover { background: #283042; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; font-weight: 600; }
.nav .grow { flex-grow: 1; }
.badge { background: #DC3545; color: #fff; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
.side-close { display: none; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 76px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center;
  gap: 16px; padding: 0 32px; position: sticky; top: 0; z-index: 20;
}
.menu-btn { display: none; }
.topbar .spacer { flex-grow: 1; }
.chip { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.user { display: flex; align-items: center; gap: 12px; }
.user-text { text-align: right; line-height: 1.25; }
.user-name { font-weight: 600; }
.user-role { font-size: 13px; color: var(--muted); }
.avatar { width: 42px; height: 42px; border-radius: 999px; background: #E0E7FF; color: var(--accent); display: grid; place-items: center; font-weight: 700; }
.icon-btn { width: 44px; height: 44px; border-radius: 999px; border: 1px solid var(--line); background: #F8FAFC; display: grid; place-items: center; color: var(--text); }
.view { padding: 28px 32px 40px; display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.overlay { display: none; }

/* ---------- Components ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 22px 26px; }
.card h2 { margin: 0; font-size: 18px; font-weight: 700; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 8px; border: 1px solid transparent; font-weight: 600; font-size: 15px; background: var(--accent); color: #fff;
}
.btn:hover { background: var(--accent-dark); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: #fff; border-color: var(--input); color: var(--text); }
.btn-ghost:hover { background: #F8FAFC; color: var(--text); }
.btn-ok { background: var(--ok); } .btn-ok:hover { background: #065F46; }
.btn-danger-ghost { background: #fff; border-color: var(--line); color: var(--bad); }
.btn-danger-ghost:hover { background: var(--bad-soft); color: var(--bad); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-lg { min-height: 54px; font-size: 17px; font-weight: 700; border-radius: 10px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--line-soft); color: #334155; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--accent-soft); color: var(--accent-dark); }
.pill.purple { background: var(--purple-soft); color: var(--purple); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { font-size: 13px; font-weight: 600; color: #334155; }
.input { min-height: 46px; border: 1px solid var(--input); border-radius: 8px; padding: 0 12px; background: #fff; font-size: 16px; width: 100%; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.segmented { display: flex; background: var(--bg); border-radius: 8px; padding: 4px; gap: 4px; }
.segmented button { flex: 1; border: none; background: transparent; min-height: 40px; border-radius: 6px; color: var(--muted-2); font-weight: 500; font-size: 14px; }
.segmented button[aria-pressed="true"] { background: #fff; color: var(--text); font-weight: 700; box-shadow: 0 1px 2px rgba(15,23,42,.1); }
.alert { border-radius: 8px; padding: 12px 14px; font-size: 14px; line-height: 1.45; }
.alert.warn { background: var(--warn-soft); border: 1px solid #FEDF89; color: #93370D; }
.alert.bad { background: var(--bad-soft); border: 1px solid #FECDCA; color: var(--bad); }
.alert.ok { background: var(--ok-soft); border: 1px solid #ABEFC6; color: var(--ok); }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--side); color: #fff;
  padding: 12px 18px; border-radius: 10px; font-weight: 600; z-index: 100; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(15,23,42,.25);
}
.toast.bad { background: var(--bad); }

/* ---------- Dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; }
.kpi { padding: 22px 24px; display: flex; flex-direction: column; gap: 12px; }
.kpi-icon { width: 46px; height: 46px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.kpi-icon.bad { background: var(--bad-soft); color: var(--bad); }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.kpi-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; flex-wrap: wrap; }
.up { color: var(--ok); font-weight: 600; } .down { color: var(--bad); font-weight: 600; }
.charts { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.legend { display: flex; gap: 18px; font-size: 14px; color: var(--muted-2); flex-wrap: wrap; }
.dot { width: 10px; height: 10px; border-radius: 999px; display: inline-block; margin-right: 6px; }
.chart svg { width: 100%; height: auto; display: block; }
.bottom { display: grid; grid-template-columns: 3fr 2fr; gap: 24px; }
.aging { display: flex; flex-direction: column; gap: 14px; font-size: 14px; }
.aging-row { display: flex; flex-direction: column; gap: 6px; }
.aging-row > div:first-child { display: flex; justify-content: space-between; }
.bar { height: 10px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; color: var(--muted); font-weight: 600; padding: 12px 10px; background: #F8FAFC; white-space: nowrap; }
table.data td { padding: 13px 10px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
table.data th:first-child, table.data td:first-child { padding-left: 24px; }
table.data th:last-child, table.data td:last-child { padding-right: 24px; }
table.data .r { text-align: right; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: #F8FAFC; }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tabs button { flex-shrink: 0; border: none; background: transparent; color: var(--muted-2); min-height: 40px; padding: 0 14px; border-radius: 8px; font-size: 14px; font-weight: 500; }
.tabs button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar .filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar .input { min-height: 40px; font-size: 14px; width: auto; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted-2); gap: 12px; }

/* ---------- Nueva factura ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
.pos-head { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.search-box { position: relative; }
.scan { display: flex; align-items: center; gap: 10px; border: 2px solid var(--accent); border-radius: 8px; padding: 0 14px; min-height: 50px; color: var(--muted); background: #fff; }
.scan input { border: none; outline: none; width: 100%; font-size: 16px; background: transparent; min-height: 46px; }
.results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15,23,42,.14); z-index: 30; max-height: 340px; overflow-y: auto; padding: 6px;
}
.results button { display: flex; width: 100%; justify-content: space-between; gap: 12px; text-align: left; border: none; background: none; padding: 10px 12px; border-radius: 8px; min-height: 48px; align-items: center; }
.results button:hover, .results button:focus-visible { background: var(--accent-soft); }
.line-list .line-name { font-weight: 600; }
.line-list td:first-child { min-width: 190px; }
.line-list td { padding-left: 8px; padding-right: 8px; }
.line-list .line-input { width: 96px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--input); border-radius: 8px; }
.qty button { width: 38px; height: 36px; border: none; background: transparent; font-size: 18px; color: #334155; }
.qty span { min-width: 30px; text-align: center; font-weight: 600; }
.line-input { width: 110px; min-height: 36px; font-size: 14px; text-align: right; padding: 0 8px; }
.summary { display: flex; flex-direction: column; gap: 10px; font-size: 15px; }
.summary .row { display: flex; justify-content: space-between; }
.summary .total { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.pay-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pay-grid button { min-height: 46px; border: 1px solid var(--input); background: #fff; border-radius: 8px; font-size: 14px; }
.pay-grid button[aria-pressed="true"] { border: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.checkout-bar { display: none; }
.stack { display: flex; flex-direction: column; gap: 20px; }

/* ---------- Inventario ---------- */
.modal { border: none; padding: 0; background: transparent; width: min(720px, calc(100% - 24px)); max-height: calc(100dvh - 24px); }
.modal::backdrop { background: rgba(15,23,42,.55); }
.modal-card { background: #fff; border-radius: 14px; display: flex; flex-direction: column; max-height: calc(100dvh - 24px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 12px; }
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-card > .segmented { margin: 0 22px; }
.modal-body { padding: 18px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.code-row { display: flex; gap: 10px; }
.code-row .input { flex: 1; min-width: 0; background: #F8FAFC; font-size: 16px; font-weight: 700; letter-spacing: .03em; }
.hint { font-size: 13px; color: var(--muted); }
.hint-bad { color: var(--bad); font-weight: 600; }
.preview { min-height: 46px; display: flex; align-items: center; padding: 0 12px; border-radius: 8px; background: #F8FAFC; border: 1px dashed var(--input); font-weight: 600; }
textarea.input { padding: 10px 12px; min-height: 96px; resize: vertical; line-height: 1.5; }
.fs { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 16px; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.fs legend { font-size: 13px; font-weight: 700; color: var(--muted-2); padding: 0 6px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; min-height: 32px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.imei-cap { display: flex; flex-direction: column; gap: 8px; }
.scan-sm { min-height: 46px; } .scan-sm input { min-height: 42px; font-size: 16px; }
.imei-msg { font-size: 13px; min-height: 18px; color: var(--muted); }
.imei-msg.bad { color: var(--bad); font-weight: 600; }
.imei-msg.good { color: var(--ok); font-weight: 600; }
.imei-stock { font-size: 14px; color: var(--muted-2); }
.imei-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.imei-chips li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 6px 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: #F8FAFC; }
.imei-chips .chip-x { margin-left: auto; width: 32px; height: 32px; border: none; background: transparent; border-radius: 6px; font-size: 20px; line-height: 1; color: var(--muted); }
.imei-chips .chip-x:hover { background: var(--bad-soft); color: var(--bad); }
.escala-btns { display: flex; gap: 3px; justify-content: flex-end; margin-top: 4px; }
.escala-btns button { min-width: 28px; min-height: 26px; border: 1px solid var(--input); background: #fff; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--muted-2); padding: 0 6px; }
.escala-btns button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
#c-res { display: flex; flex-direction: column; gap: 16px; }
#c-res:empty { display: none; }
.art-card { display: flex; justify-content: space-between; gap: 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: #F8FAFC; }
.art-card-name { font-weight: 700; font-size: 16px; }
.art-card-stock { display: flex; flex-direction: column; align-items: flex-end; font-size: 13px; }
.art-card-stock strong { font-size: 24px; font-weight: 800; }
.costos-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.costos-grid .costo-field { grid-column: 1 / -1; }
.costos-grid .costo-field .input { max-width: 260px; }
.costos-grid .hint .up, .costos-grid .hint .down { font-size: 13px; }
.pick-list { display: flex; flex-direction: column; gap: 6px; }
.pick-list button { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 10px 12px; min-height: 52px; }
.pick-list button:hover { background: var(--accent-soft); border-color: var(--accent); }
.hist summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted-2); padding: 4px 0; }
.hist table.data th:first-child, .hist table.data td:first-child { padding-left: 10px; }
.hist table.data th:last-child, .hist table.data td:last-child { padding-right: 10px; }
.escalas { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 8px; }
.escalas > div { display: flex; flex-direction: column; padding: 8px 10px; border-radius: 8px; background: #F8FAFC; font-size: 13px; }
.escalas strong { font-size: 16px; }
@media (max-width: 639px) {
  .costos-grid { grid-template-columns: 1fr; }
  .costos-grid .costo-field .input { max-width: none; }
  .art-card { flex-direction: column; gap: 8px; }
  .art-card-stock { flex-direction: row; align-items: baseline; gap: 8px; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot #c-otro { order: 3; flex-basis: 100%; }
}
.modal-sm { width: min(560px, calc(100% - 24px)); }
.credit-box { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 2px solid var(--line); border-radius: 10px; cursor: pointer; }
.credit-box input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--accent); flex-shrink: 0; }
.credit-box:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.credit-box.is-disabled { cursor: not-allowed; opacity: .8; }
.datos { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.datos > div { display: flex; flex-direction: column; gap: 2px; }
.datos dt { font-size: 13px; color: var(--muted); font-weight: 600; }
.datos dd { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.stepper { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; }
.stepper li { flex: 1; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); color: var(--muted); font-weight: 600; font-size: 14px; }
.stepper-n { width: 28px; height: 28px; border-radius: 999px; display: grid; place-items: center; background: var(--line-soft); color: var(--muted-2); font-size: 13px; flex-shrink: 0; }
.stepper li.on { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 3px var(--accent-soft); }
.stepper li.on .stepper-n { background: var(--accent); color: #fff; }
.stepper li.done { color: var(--ok); }
.stepper li.done .stepper-n { background: var(--ok-soft); color: var(--ok); }
.search-row { display: flex; gap: 8px; }
.search-row .input { flex: 1; min-width: 0; }
.btn-icon { width: 50px; padding: 0; flex-shrink: 0; min-height: 46px; }
.res-list { list-style: none; margin: 0; padding: 0 0 8px; border-top: 1px solid var(--line); }
.res-list > li { border-bottom: 1px solid var(--line-soft); }
.res-list > li.open { background: #F8FAFC; }
.res-main { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 24px; }
.res-act { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.imei-pick { padding: 0 24px 16px; display: flex; flex-direction: column; gap: 8px; }
.imei-pick label { font-size: 13px; font-weight: 600; color: #334155; }
.imei-pick details summary { cursor: pointer; font-size: 13px; color: var(--accent); font-weight: 600; }
.imei-opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.imei-opts button { border: 1px solid var(--input); background: #fff; border-radius: 6px; padding: 6px 10px; }
.imei-opts button:hover { border-color: var(--accent); background: var(--accent-soft); }
.pay-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.segmented button:disabled { opacity: .45; cursor: not-allowed; }
.doc-actions { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
@media (max-width: 639px) {
  .stepper li { padding: 8px; font-size: 12px; gap: 6px; flex-direction: column; text-align: center; }
  .res-main { flex-direction: column; align-items: stretch; padding: 12px 16px; }
  .res-act { justify-content: space-between; }
  .imei-pick { padding: 0 16px 16px; }
  .pay-3 { grid-template-columns: 1fr; }
  .checkout-bar > .btn.btn-ghost { flex: 0 0 48px; }
}
.doc-lineas { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; font-size: 14px; }
.doc-lineas li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.elegir-btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.pend-list { list-style: none; margin: 0; padding: 0 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.pend-list button { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 14px; min-height: 56px; }
.pend-list button:hover { border-color: var(--accent); background: var(--accent-soft); }
.pend-list .num { text-align: right; }
.pend-elegir { font-size: 13px; font-weight: 700; color: var(--accent); }
.conf-tabs { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px; align-self: flex-start; }
.check-list { display: flex; flex-direction: column; gap: 4px; }
.check-list .check { align-items: flex-start; }
.check-list .check input { margin-top: 3px; flex-shrink: 0; }
.nivel-checks, .dias { display: flex; flex-wrap: wrap; gap: 8px; }
.nivel-check, .dia { position: relative; cursor: pointer; }
.nivel-check input, .dia input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.nivel-check span, .dia span { display: inline-flex; align-items: center; min-height: 42px; padding: 0 16px; border: 1px solid var(--input); border-radius: 8px; font-weight: 600; font-size: 14px; background: #fff; }
.dia span { min-width: 52px; justify-content: center; padding: 0 10px; }
.nivel-check input:checked + span, .dia input:checked + span { border: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.nivel-check input:focus-visible + span, .dia input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.nivel-check input:disabled + span, .dia input:disabled + span { opacity: .6; cursor: not-allowed; }
.filtros-sesion { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; align-items: end; }
tr.fila-fallida td { background: #FFF7F6; }
tr.fila-inactiva td { opacity: .65; }
.print-only { display: none; }
@media print { .print-only { display: block; margin-bottom: 12px; } .conf-tabs { display: none; } }
@media (max-width: 1023px) { .filtros-sesion { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 639px) { .filtros-sesion { grid-template-columns: 1fr; } .conf-tabs { align-self: stretch; } }
.art-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 24px; align-items: start; }
.stock-num { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; }
.stock-num .muted { font-size: 15px; font-weight: 500; letter-spacing: 0; }
.imei-list { list-style: none; margin: 0; padding: 0 0 8px; max-height: 420px; overflow-y: auto; }
.imei-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 26px; border-top: 1px solid var(--line-soft); flex-wrap: wrap; }
@media (max-width: 1023px) { .art-grid { grid-template-columns: 1fr; } }
@media (max-width: 639px) {
  .modal { width: 100%; max-width: 100%; max-height: 100dvh; height: 100dvh; margin: 0; }
  .modal-card { border-radius: 0; height: 100dvh; max-height: 100dvh; }
  .modal-head, .modal-body, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .modal-card > .segmented { margin: 0 16px; }
  .modal-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
  .form-grid { grid-template-columns: 1fr; }
  .code-row { flex-wrap: wrap; } .code-row .btn { flex: 1; }
  .imei-list li { padding: 8px 16px; }
  table.cards tr.inv-row { display: flex; flex-direction: column; }
  table.cards td.inv-desc { order: -1; display: block; text-align: left; padding-bottom: 6px !important; }
}

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--side); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; padding: 32px 28px; display: flex; flex-direction: column; gap: 18px; }
.login-card .brand { color: var(--text); padding: 0; }

/* ---------- Impresión de factura ---------- */
.invoice { max-width: 820px; margin: 0 auto; padding: 36px; }
.invoice-head { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.invoice table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 20px; }
.invoice th, .invoice td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.invoice .r { text-align: right; }
@media print {
  .sidebar, .topbar, .no-print, .checkout-bar { display: none !important; }
  .app { display: block; } .view { padding: 0; } body { background: #fff; }
  .card { border: none; }
}

/* ---------- Responsivo ---------- */
@media (max-width: 1279px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pos { grid-template-columns: minmax(0, 1fr) 340px; }
}
@media (max-width: 1023px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 300px; max-width: 85vw; z-index: 60; transform: translateX(-100%);
    transition: transform .22s ease; padding: 16px 14px 24px;
  }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .overlay { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 50; }
  .side-close { display: grid; margin-left: auto; width: 44px; height: 44px; border: none; background: transparent; color: var(--side-text); place-items: center; }
  .menu-btn { display: grid; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 8px; background: #fff; place-items: center; }
  .topbar { height: 64px; padding: 0 12px; gap: 10px; }
  .topbar .chip, .user-text { display: none; }
  .view { padding: 20px 16px 32px; gap: 16px; }
  .charts, .bottom, .pos { grid-template-columns: 1fr; }
  .kpis { gap: 12px; }
  .pos-head { grid-template-columns: 1fr; }
  .pos .desk-only { display: none; }
  .checkout-bar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: #fff; border-top: 1px solid var(--line);
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); gap: 12px; align-items: center;
    box-shadow: 0 -4px 12px rgba(15,23,42,.06);
  }
  body.has-checkout .view { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  body.has-checkout .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
  .checkout-bar .t { display: flex; flex-direction: column; line-height: 1.2; }
  .checkout-bar .t strong { font-size: 19px; font-weight: 800; white-space: nowrap; }
  .checkout-bar .btn { flex: 1; min-width: 0; font-size: 16px; padding: 0 12px; }
}
@media (max-width: 639px) {
  .page-head h1 { font-size: 22px; }
  .kpi { padding: 14px; gap: 6px; }
  .kpi-icon { display: none; }
  .kpi-value { font-size: 19px; }
  .kpi-foot { font-size: 13px; flex-direction: column; gap: 2px; }
  .card-pad { padding: 16px; }
  .page-head .actions .btn { flex-grow: 1; }
  .page-head .actions { width: 100%; }
  /* Tablas -> tarjetas */
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 10px; padding: 12px 14px; background: #fff; }
  table.cards td { border: none; padding: 3px 0 !important; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.cards td::before { content: attr(data-label); color: var(--muted); font-weight: 500; text-align: left; }
  table.cards td[data-label=""]::before { content: none; }
  table.cards td[data-label=""]:first-child { display: block; text-align: left; padding-bottom: 6px !important; }
  table.cards td.card-actions { justify-content: flex-end; padding-top: 10px !important; }
  .cards-wrap { padding: 12px; }
  .toolbar { padding: 12px; }
  .toolbar .filters { width: 100%; }
  .toolbar .filters .input { flex: 1; min-width: 0; }
  .toolbar .filters input[type="search"] { flex-basis: 100%; }
  table.cards td.mono::before { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 15px; }
  .pager { padding: 12px; }
  .line-input { width: 96px; }
}

/* ---------- Devoluciones, notas de crédito y contabilidad */
.btn-danger { background: var(--bad); } .btn-danger:hover { background: #912018; }
.alert.info { background: var(--accent-soft); border: 1px solid #C7D2FE; color: var(--accent-dark); }
.filtros-dev { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; border-bottom: 1px solid var(--line); }
.filtros-rep { display: grid; grid-template-columns: repeat(4, minmax(0, 220px)); gap: 12px 14px; align-items: end; }
.sol-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 16px 20px 20px; }
.sol { border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: #fff; }
.sol-top strong.num { white-space: nowrap; }
.sol-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; font-size: 16px; }
.sol-datos { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }
.sol-datos dt, .datos-grid dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.sol-datos dd { margin: 0; font-size: 14px; }
.sol-acc { display: flex; gap: 8px; flex-wrap: wrap; }
.dev-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; }
.datos-grid { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px !important; }
.datos-grid .span2 { grid-column: 1 / -1; }
.timeline { list-style: none; margin: 8px 0 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.timeline li { position: relative; }
.timeline li::before { content: ''; position: absolute; left: -25px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; }
.asientos { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }
.asiento { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.asiento-head { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; padding: 10px 14px; background: var(--bg); font-size: 14px; }
.asiento-tabla { width: 100%; border-collapse: collapse; font-size: 14px; }
.asiento-tabla th, .asiento-tabla td { padding: 7px 14px; border-top: 1px solid var(--line-soft); text-align: left; }
.asiento-tabla th { font-size: 12px; color: var(--muted); font-weight: 600; }
.asiento-tabla .r { text-align: right; }
.input-cant { width: 90px; min-height: 40px; text-align: right; margin-left: auto; }
.dev-total { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 16px; border-radius: 10px; background: var(--bg); font-weight: 600; }
.dev-total strong { font-size: 22px; }
.recibe { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.recibe-campos { display: grid; grid-template-columns: 110px 190px minmax(0, 1fr); gap: 10px; }
.rep-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.nc-uso { display: grid; grid-template-columns: minmax(0, 1fr) 130px; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.nc-uso .input { min-height: 40px; }
@media (max-width: 1023px) {
  .dev-grid, .rep-grid { grid-template-columns: minmax(0, 1fr); }
  .sol-list { grid-template-columns: 1fr; padding: 12px; }
  .filtros-dev { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .filtros-dev, .filtros-rep { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .filtros-dev .input, .filtros-rep .input { min-width: 0; }
  .datos-grid, .sol-datos { grid-template-columns: 1fr; }
  .recibe-campos { grid-template-columns: 1fr 1fr; }
  .recibe-obs { grid-column: 1 / -1; }
  .input-cant { width: 100px; }
}
.perm-grupo { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 10px 0 2px; }
.perm-grupo:first-child { margin-top: 0; }
.pay-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pay-grid button:disabled { opacity: .45; cursor: not-allowed; }
.sug-nc { display: flex; flex-wrap: wrap; gap: 8px; }
.sug-nc .chip { background: #fff; cursor: pointer; font-weight: 600; }
.sug-nc .chip:hover { border-color: var(--accent); color: var(--accent-dark); }
.nc-uso { grid-template-columns: minmax(0, 1fr) auto; background: var(--ok-soft); border-color: #ABEFC6; }
@media (max-width: 640px) { .pay-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Facturación: pública / privada, vendedor, filtros y acciones rápidas */
.pill.vis-pub, .pill.vis-priv { display: inline-flex; align-items: center; gap: 5px; }
.pill.vis-pub { background: #ECFDF3; color: #067647; }
.pill.vis-priv { background: #F4F3FF; color: #5925DC; }
.vend { display: inline-flex; align-items: center; gap: 8px; vertical-align: middle; }
.vend-cod { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 24px; padding: 0 7px; border-radius: 6px;
  background: var(--side); color: #fff; font: 700 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .02em; }
.vend-nom { font-size: 14px; }
tr.fila-priv td:first-child { box-shadow: inset 3px 0 0 #7A5AF8; }
.filtros-btn { display: none; gap: 6px; }
.filtros-btn .badge { margin-left: 2px; }
.filtros-fact { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; padding: 16px 20px; border-bottom: 1px solid var(--line); background: #FCFCFD; }
.filtros-fact .filtros-acc .actions { flex-wrap: nowrap; }
.res-resumen { padding: 12px 20px 0; font-size: 14px; color: var(--muted-2); }
.acciones-fila { white-space: nowrap; }
.icon-act { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; min-width: 36px; padding: 0 9px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: #334155; font-size: 13px; font-weight: 600; margin-left: 4px; }
.icon-act:hover { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-soft); }
.icon-act span { display: none; }
.icon-act-main { background: var(--accent); border-color: var(--accent); color: #fff; }
.icon-act-main:hover { background: var(--accent-dark); color: #fff; }
.icon-act-main span { display: inline; }
.lista-links { margin: 10px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.pos-bar { display: flex; align-items: center; gap: 14px 18px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 16px; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; }
.pos-vend { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.vis-toggle { display: inline-flex; background: var(--bg); border-radius: 9px; padding: 4px; gap: 4px; margin-left: auto; }
.vis-toggle button { display: inline-flex; align-items: center; gap: 6px; border: none; background: transparent; min-height: 36px; padding: 0 14px;
  border-radius: 7px; font-weight: 600; font-size: 14px; color: var(--muted-2); }
.vis-toggle button[data-vis="PUBLICA"][aria-pressed="true"] { background: #fff; color: #067647; box-shadow: 0 1px 2px rgba(15,23,42,.12); }
.vis-toggle button[data-vis="PRIVADA"][aria-pressed="true"] { background: #fff; color: #5925DC; box-shadow: 0 1px 2px rgba(15,23,42,.12); }
.vis-toggle button:disabled { cursor: not-allowed; opacity: .6; }
.vis-hint { font-size: 13px; order: 2; }
.vis-toggle { order: 3; }
@media (max-width: 1023px) {
  .filtros-btn { display: inline-flex; }
  .filtros-fact { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 14px 16px; }
  .filtros-fact .input { min-width: 0; }
  .filtros-fact .filtros-acc { grid-column: 1 / -1; }
  .filtros-fact .filtros-acc .label { display: none; }
  .icon-act span { display: inline; }
  .vis-toggle { margin-left: 0; width: 100%; }
  .vis-toggle button { flex: 1; justify-content: center; }
  .vis-hint { order: 4; flex-basis: 100%; }
  tr.fila-priv td:first-child { box-shadow: none; }
  table.cards tr.fila-priv { box-shadow: inset 4px 0 0 #7A5AF8; }
}
.tabla-fact td:first-child strong { white-space: nowrap; }

/* ---------- Resumen de factura / cotización (detalles bajo demanda) */
.resumen-doc { overflow: hidden; }
.res-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.res-total { display: flex; flex-direction: column; gap: 2px; }
.res-total span { font-size: 13px; color: var(--muted); font-weight: 600; }
.res-total strong { font-size: 30px; line-height: 1.1; letter-spacing: -.01em; }
.res-total em { font-style: normal; font-size: 13px; }
.res-acc { display: flex; gap: 8px; flex-wrap: wrap; }
.res-acc .btn { gap: 6px; }
.res-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 24px; padding: 18px 22px 20px; }
.res-dato { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.res-dato > span { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.res-dato > strong { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.ver-detalles { display: flex; align-items: center; gap: 10px; width: 100%; border: none; border-top: 1px solid var(--line); background: #FCFCFD;
  padding: 14px 22px; font-size: 15px; font-weight: 700; color: var(--accent-dark); text-align: left; cursor: pointer; }
.ver-detalles small { font-weight: 500; color: var(--muted); font-size: 13px; }
.ver-detalles:hover { background: var(--accent-soft); }
.ver-detalles .chev { transition: transform .15s; }
.ver-detalles[aria-expanded="true"] .chev { transform: rotate(180deg); }
.res-totales { max-width: 340px; margin: 12px 20px 16px auto; }
.res-extra { padding: 4px 22px 20px; }
.res-extra h3 { font-size: 15px; margin: 0; }
#f-detalles, #d-detalles { border-top: 1px solid var(--line); }
@media (max-width: 1023px) { .res-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .res-grid { grid-template-columns: 1fr; padding: 16px; }
  .res-top { padding: 16px; }
  .res-acc { width: 100%; }
  .res-acc .btn { flex: 1 1 auto; }
  .ver-detalles { padding: 14px 16px; flex-wrap: wrap; }
  .ver-detalles small { flex-basis: 100%; padding-left: 26px; }
  .res-totales { margin: 12px 16px 16px; max-width: none; }
  .res-extra { padding: 4px 16px 16px; }
}
