:root {
  --brand: #0d4f96;
  --brand-dark: #08396f;
  --brand-soft: #e7f0fb;
  --accent: #19b3ea;
  --bg: #f2f5f9;
  --card: #ffffff;
  --text: #13233a;
  --muted: #64748b;
  --border: #dbe3ed;
  --ok: #15803d;
  --ok-soft: #e6f6ec;
  --warn: #b45309;
  --warn-soft: #fdf3e2;
  --danger: #c62828;
  --danger-soft: #fdecec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 35, 60, .06), 0 4px 14px rgba(16, 35, 60, .05);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: 12px; }
.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)); }
.span2 { grid-column: span 2; }

/* ---------- Login ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 20% -10%, #123c6e 0%, transparent 60%), linear-gradient(160deg, #050b14, #0a1a2f 60%, #08396f);
}
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 28px 28px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card .logo { display: block; width: 210px; max-width: 70%; margin: 0 auto 18px; }
.login-card h2 { font-size: 16px; text-align: center; color: var(--muted); font-weight: 500; margin-bottom: 18px; }
.login .slogan { width: 260px; max-width: 70%; margin-top: 26px; opacity: .9; }
.login-wrap { display: flex; flex-direction: column; align-items: center; width: 100%; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: #fff; border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { padding: 16px 18px 10px; border-bottom: 1px solid var(--border); }
.sidebar .brand img { width: 100%; display: block; }
.nav { padding: 10px 10px 16px; display: flex; flex-direction: column; gap: 2px; }
.nav .sec { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
.nav a svg { width: 18px; height: 18px; flex: none; color: var(--brand); }
.nav a:hover { background: var(--brand-soft); }
.nav a.active { background: var(--brand); color: #fff; }
.nav a.active svg { color: #fff; }
.nav .badge { margin-left: auto; }
.sidebar .slogan-box { margin-top: auto; background: #050b14; padding: 14px 18px; }
.sidebar .slogan-box img { width: 100%; display: block; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 22px; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar .menu-btn { display: none; }
.branch-pill { background: var(--brand-soft); color: var(--brand-dark); padding: 4px 10px; border-radius: 999px; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.content { padding: 20px 22px 40px; }

/* ---------- Components ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-h h3 { font-size: 15px; }
.card-b { padding: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: #fff; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; white-space: nowrap; text-decoration: none; color: var(--text); }
.btn:hover { background: #f5f8fc; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: #f1c4c4; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.sm { padding: 5px 9px; font-size: 12.5px; }
.btn.lg { padding: 12px 18px; font-size: 16px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { border-color: transparent; background: transparent; }
label.f { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 12.5px; color: #33445c; }
label.f .hint { font-weight: 400; color: var(--muted); }
input, select, textarea { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: #fff; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(25, 179, 234, .35); border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
input[type=checkbox] { width: auto; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; background: #eef2f7; color: #334155; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--brand-soft); color: var(--brand-dark); }
.badge.dot { background: var(--danger); color: #fff; }
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
table.t th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f8fafc; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: #fafcff; }
table.t td.actions { white-space: nowrap; text-align: right; }
table.t td.actions .btn { margin-left: 4px; }
table.t tr.clickable { cursor: pointer; }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; }
.kpi .l { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 9px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters label.f { min-width: 140px; }
.filters .grow { flex: 1; min-width: 200px; }
.alert { padding: 10px 14px; border-radius: 8px; background: var(--brand-soft); color: var(--brand-dark); border: 1px solid #c9dcf3; }
.alert.warn { background: var(--warn-soft); color: var(--warn); border-color: #f2d9ad; }
.alert.danger { background: var(--danger-soft); color: var(--danger); border-color: #f1c4c4; }
.stack > * + * { margin-top: 14px; }
.bar { height: 8px; background: #eef2f7; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(8, 20, 38, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 640px; box-shadow: 0 24px 64px rgba(0,0,0,.25); }
.modal.wide { max-width: 940px; }
.modal.xwide { max-width: 1180px; }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-h h3 { font-size: 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.modal-b { padding: 18px; }
.modal-f { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.x { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); margin-left: auto; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { background: #13233a; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: 420px; animation: tin .2s ease-out; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 16px; align-items: start; }
.pos-search { position: relative; }
.pos-search input { font-size: 16px; padding: 12px 14px 12px 42px; }
.pos-search svg { position: absolute; left: 13px; top: 13px; width: 20px; height: 20px; color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.chip { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 5px 12px; cursor: pointer; font-weight: 600; font-size: 12.5px; }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.pcard { text-align: left; border: 1px solid var(--border); background: #fff; border-radius: 10px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; min-height: 118px; }
.pcard:hover { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(25,179,234,.15); }
.pcard .n { font-weight: 600; line-height: 1.25; }
.pcard .p { font-size: 17px; font-weight: 700; color: var(--brand-dark); margin-top: auto; }
.pcard.out { opacity: .55; }
.cart { position: sticky; top: 74px; }
.cart-items { max-height: 42vh; overflow-y: auto; }
.cline { padding: 10px 14px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; }
.cline .d { font-weight: 600; }
.cline .meta { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.qty button { border: 0; background: #f5f8fc; width: 28px; height: 28px; cursor: pointer; font-weight: 700; }
.qty input { width: 44px; border: 0; text-align: center; padding: 4px; border-radius: 0; }
.cline .disc { width: 72px; padding: 4px 6px; }
.cline .meta { gap: 6px; }
.totals { padding: 12px 14px; border-top: 1px solid var(--border); }
.totals .r { display: flex; justify-content: space-between; padding: 2px 0; }
.totals .big { font-size: 26px; font-weight: 800; color: var(--brand-dark); }
.paybox { padding: 12px 14px; border-top: 1px solid var(--border); display: grid; gap: 10px; }
.pay-methods { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.pay-methods button { border: 1px solid var(--border); background: #fff; padding: 9px 6px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 12.5px; }
.pay-methods button.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }
.edit-banner { background: var(--warn-soft); color: var(--warn); padding: 10px 14px; font-weight: 600; border-bottom: 1px solid #f2d9ad; }
.serial-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.serial-list label { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.serial-list label:last-child { border-bottom: 0; }
.serial-list label:hover { background: #fafcff; }
.lines-table input, .lines-table textarea { padding: 6px 8px; }

/* ---------- Fotos ---------- */
.ph { display: flex; align-items: center; justify-content: center; background: #f3f6fa; border-radius: 8px; overflow: hidden; color: #b7c3d3; flex: none; }
.ph img { width: 100%; height: 100%; object-fit: contain; background: #fff; display: block; }
.ph svg { width: 40%; height: 40%; }
.ph.pc { width: 100%; height: 96px; }
.ph.sm { width: 42px; height: 42px; }
.ph.md { width: 96px; height: 96px; }
.ph.lg { width: 170px; height: 170px; }
.photo-edit { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }

/* ---------- Rastreo ---------- */
.trace-head { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.trace-head .serial { font-family: ui-monospace, Consolas, monospace; font-size: 20px; font-weight: 700; letter-spacing: .02em; word-break: break-all; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.timeline li { position: relative; padding: 0 0 18px 30px; }
.timeline li::before { content: ""; position: absolute; left: 8px; top: 20px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .dot { position: absolute; left: 0; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--brand); border: 3px solid #fff; box-shadow: 0 0 0 1px var(--border); }
.timeline .dot.in { background: var(--ok); }
.timeline .dot.move { background: var(--warn); }
.timeline .dot.back { background: var(--accent); }
.timeline .dot.out { background: var(--danger); }
.timeline .t { font-weight: 700; }
.timeline .d { color: var(--muted); font-size: 12.5px; }

/* ---------- Print ---------- */
#print-area { display: none; }
.ticket { width: 74mm; font-family: "Segoe UI", Arial, sans-serif; font-size: 11px; color: #000; padding: 3mm; background: #fff; line-height: 1.35; }
.ticket img { width: 65%; display: block; margin: 0 auto 2mm; }
.paper-wrap { background: #e9eef5; border-radius: 10px; padding: 16px; display: flex; justify-content: center; align-items: flex-start; max-height: 70vh; overflow: auto; }
.paper-wrap .paper { background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.label { box-sizing: border-box; background: #fff; overflow: hidden; position: relative; flex: none; }
.label.empty { outline: 1px dashed #b9c4d3; background: #fafbfd; }
.lb-in { box-sizing: border-box; color: #000; font-family: Arial, "Segoe UI", sans-serif; display: flex; flex-direction: column; gap: .4mm; overflow: hidden; line-height: 1.1; }
.lb-in.rot { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.label-row { display: flex; box-sizing: border-box; overflow: hidden; background: #fff; page-break-after: always; break-after: page; }
.label-row:last-child { page-break-after: auto; break-after: auto; }
.label-sheet { display: grid; }
.label-sheet .label { outline: 1px dashed #ccc; }
.lb-top { display: flex; justify-content: space-between; align-items: center; gap: 1mm; flex: none; }
.lb-logo { display: block; width: 100%; height: auto; max-height: 7mm; object-fit: contain; flex: none; }
.lb-mid { display: flex; justify-content: space-between; align-items: flex-start; gap: 1mm; flex: none; }
.lb-mid .lb-name { flex: 1; min-width: 0; }
.lb-price { font-size: 1.35em; white-space: nowrap; }
.lb-name { font-weight: 700; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; flex: none; }
.label svg.bc { display: block; width: 100%; flex: 1 1 auto; min-height: 5mm; }
.lb-code { text-align: center; font-family: ui-monospace, Consolas, monospace; font-size: .95em; letter-spacing: .03em; flex: none; white-space: nowrap; overflow: hidden; }
.lb-zoom { zoom: 1.8; }
.ticket .c { text-align: center; }
.ticket hr { border: 0; border-top: 1px dashed #000; margin: 2mm 0; }
.ticket table { width: 100%; border-collapse: collapse; }
.ticket td { padding: 1px 0; vertical-align: top; }
.ticket .tot td { font-weight: 700; font-size: 13px; }
.doc { font-family: "Segoe UI", Arial, sans-serif; color: #000; font-size: 12px; padding: 10mm; }
.doc .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-bottom: 2px solid #0d4f96; padding-bottom: 8px; margin-bottom: 10px; }
.doc .head img { width: 55mm; }
.doc table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.doc th, .doc td { border: 1px solid #bbb; padding: 4px 6px; text-align: left; }
.doc th { background: #e7f0fb; }
@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
  html, body { background: #fff; }
  @page { margin: 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .pos { grid-template-columns: 1fr; }
  .cart { position: static; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 60; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .sidebar.open { transform: none; }
  .topbar { padding: 10px 16px; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar .uname { display: none; }
  .content { padding: 16px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .modal-bg { padding: 12px; }
}
