/* =========================================================
   Librería Betania · estilos
   ========================================================= */
:root {
  /* Paleta tomada de la foto de la Dra. Ilya Carrera: rosa vino + dorado de su firma */
  --brand: #8c4a54;
  --brand-600: #773d47;
  --brand-800: #5c2b35;
  --brand-50: #f8ecee;
  --gold: #c8961e;
  --gold-600: #9e7310;
  --gold-50: #fcf4dc;
  --bg: #f8f2f3;
  --surface: #ffffff;
  --surface-2: #fbf7f8;
  --text: #2b1c21;
  --muted: #76646a;
  --border: #eddfe2;
  --border-strong: #dccacf;
  --ok: #2f7d4f;
  --ok-50: #e8f5ee;
  --warn: #a2650d;
  --warn-50: #fdf3e1;
  --danger: #b42318;
  --danger-50: #fdecea;
  --info: #1f5fae;
  --info-50: #e8f0fb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, .28);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3, h4, p { margin: 0; }
.ic { flex: none; display: block; }
.muted { color: var(--muted); }
.ok-text { color: var(--ok); }
.danger-text { color: var(--danger); }
.spacer { flex: 1; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; color: #4b5563; }
.t-sub { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 20px 14px;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-800) 100%);
  color: #f7e8eb;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px 20px; margin-bottom: 14px; border-bottom: 1px solid rgba(255,255,255,.16); text-decoration: none; }
.brand img { width: 50px; height: 50px; flex: none; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px rgba(255,255,255,.55); }
.brand strong { display: block; font-family: var(--font-display); font-size: 18px; font-weight: 800; color: #fff; letter-spacing: -.01em; line-height: 1.15; }
.brand span { font-size: 12px; color: #ecd2d8; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: #f3e0e4; text-decoration: none; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav a.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 #fff; }
.nav-count {
  margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px;
  display: grid; place-items: center;
  border-radius: 99px; background: rgba(255,255,255,.22); color: #fff;
  font-style: normal; font-size: 11px; font-weight: 700;
}
.nav-count.warn { background: #ffcf4d; color: #5a3d00; }

.sidebar-foot { margin-top: auto; padding: 14px 4px 0; border-top: 1px solid rgba(255,255,255,.16); display: flex; flex-direction: column; gap: 10px; font-size: 12px; color: #ecd2d8; }
.demo-pill { align-self: flex-start; margin-left: 4px; padding: 2px 10px; border-radius: 99px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.3); color: #fff; font-weight: 700; font-size: 10.5px; letter-spacing: .5px; text-transform: uppercase; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: rgba(0,0,0,.12); }
.sidebar-user > div { flex: 1; min-width: 0; }
.sidebar-user strong { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user small { color: #ecd2d8; }
.avatar { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #fff; color: var(--brand); font-weight: 800; font-size: 14px; }
.sidebar-user .icon-btn { color: #f7e8eb; }
.sidebar-user .icon-btn:hover { background: rgba(255,255,255,.16); color: #fff; }

.scrim { display: none; position: fixed; inset: 0; z-index: 35; background: rgba(15,23,42,.45); }
.scrim.open { display: block; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px;
  padding: 16px 28px;
  background: rgba(242,246,250,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { min-width: 0; }
.topbar h1 { font-family: var(--font-display); font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--text); line-height: 1.2; }
.topbar p { margin-top: 2px; color: var(--muted); font-size: 13px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.today { color: var(--muted); font-size: 13px; white-space: nowrap; }
.menu-btn { display: none !important; }
.view { width: 100%; max-width: 1440px; padding: 24px 28px 56px; outline: none; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 13.5px; white-space: nowrap; text-decoration: none;
  cursor: pointer; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: #cfb6bc; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-600); border-color: var(--gold-600); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(31,58,95,.06); border-color: transparent; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #8f1c13; border-color: #8f1c13; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { height: 52px; font-size: 16px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.danger-text { color: var(--danger); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--muted);
  cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: rgba(31,58,95,.08); color: var(--brand); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.danger:hover { background: var(--danger-50); color: var(--danger); }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- formularios ---------- */
input:not([type=checkbox]):not([type=file]), select, textarea {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 72px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,58,95,.13); }
input:disabled { background: var(--surface-2); color: var(--muted); }
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 600; color: #3d4656; }
.field small { color: var(--muted); font-size: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span-2 { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.input-group { display: flex; gap: 6px; }
.input-group .btn { flex: none; height: 38px; }
.hint { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12.5px; }

.search { position: relative; flex: 1 1 240px; max-width: 420px; }
.search > .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 38px !important; }
.search.big { max-width: none; flex: none; }
.search.big input { height: 50px; font-size: 15px; border-radius: 12px; padding-left: 46px !important; box-shadow: var(--shadow); }
.search.big > .ic { left: 16px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.toolbar select { width: auto; min-width: 170px; }
label.inline { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--muted); }
label.inline input { width: auto; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button, .chip {
  height: 34px; padding: 0 13px;
  border: 1px solid var(--border-strong); border-radius: 99px;
  background: var(--surface); color: #3d4656;
  font-weight: 600; font-size: 12.5px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.seg button { flex: 1 1 auto; }
.seg.pay { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg.pay button { padding: 0 6px; }
.seg button:hover, .chip:hover { border-color: var(--brand); }
.seg button.active, .chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.chips .chip { flex: none; }

/* ---------- tarjetas y KPIs ---------- */
.card { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-head > :last-child:not(h3) { margin-left: auto; }
.card-head .link { font-size: 13px; font-weight: 600; text-decoration: none; }
.card-head .link:hover { text-decoration: underline; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { display: flex; gap: 14px; align-items: flex-start; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.kpi-ic { flex: none; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 11px; background: var(--brand-50); color: var(--brand); }
.kpi.gold .kpi-ic { background: var(--gold-50); color: var(--gold-600); }
.kpi.warn .kpi-ic { background: var(--warn-50); color: var(--warn); }
.kpi.ok .kpi-ic { background: var(--ok-50); color: var(--ok); }
.kpi-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.kpi-value { margin: 2px 0; font-size: 24px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-hint { font-size: 12.5px; color: var(--muted); }

.grid-main { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.grid-2col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }

.welcome {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  margin-bottom: 20px; padding: 18px 20px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand), var(--brand-800)); color: #fff;
  box-shadow: var(--shadow);
}
.welcome img { width: 56px; height: 56px; flex: none; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px rgba(255,255,255,.55); }
.welcome div { flex: 1 1 300px; }
.welcome strong { display: block; font-family: var(--font-display); font-size: 18px; font-weight: 800; margin-bottom: 2px; }
.welcome p { color: #f3e0e4; font-size: 13.5px; }
.welcome .btn { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); color: #fff; }
.welcome .btn:hover { background: rgba(255,255,255,.2); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px; border-radius: 99px; background: #eef0f3; color: #4b5563; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.badge.ok { background: var(--ok-50); color: var(--ok); }
.badge.warn { background: var(--warn-50); color: var(--warn); }
.badge.danger { background: var(--danger-50); color: var(--danger); }
.badge.info { background: var(--info-50); color: var(--info); }
.badge.gold { background: var(--gold-50); color: var(--gold-600); }
.stock { display: inline-flex; justify-content: center; min-width: 38px; padding: 2px 8px; border-radius: 8px; font-weight: 700; }
.stock.ok { background: var(--ok-50); color: var(--ok); }
.stock.warn { background: var(--warn-50); color: var(--warn); }
.stock.danger { background: var(--danger-50); color: var(--danger); }
.cat-dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--c); vertical-align: middle; }

/* ---------- tablas ---------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  padding: 11px 14px; text-align: left; white-space: nowrap;
  font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #fcf6f7; }
.tbl tr.click { cursor: pointer; }
.tbl tr.is-void td { color: var(--muted); }
.tbl tr.is-void .num strong { text-decoration: line-through; }
.tbl .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.t-title strong { display: block; font-weight: 600; }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; }
.tbl tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); }

.summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.sum-chip { padding: 6px 14px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); font-size: 13px; color: var(--muted); }
.sum-chip b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- listas ---------- */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row > div { flex: 1; min-width: 0; }
.list-row strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row small { color: var(--muted); font-size: 12px; }
.list-row .num { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank { flex: none; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--gold-50); color: var(--gold-600); font-weight: 800; font-size: 12px; }
.empty { padding: 30px 18px; text-align: center; color: var(--muted); }
.empty .ic { margin: 0 auto 10px; opacity: .45; }
.empty.small { padding: 26px 16px; }

/* ---------- gráficos ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 210px; }
.bar-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; }
.bar-val { font-size: 10.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.bar { width: 100%; max-width: 36px; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, #b26f7a, var(--brand)); transition: background .15s; }
.bar.cero { background: var(--border); }
.bar-col:hover .bar { background: var(--gold); }
.bar-col:hover .bar-val { color: var(--text); }
.bar-lbl { font-size: 11px; line-height: 1.2; text-align: center; color: var(--muted); }
.bar-lbl.hoy { color: var(--brand); font-weight: 800; }

.hbars { display: flex; flex-direction: column; gap: 14px; }
.hbar-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; font-size: 13px; }
.hbar-top span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar-track { height: 8px; overflow: hidden; border-radius: 99px; background: #f1e4e7; }
.hbar-fill { height: 100%; border-radius: 99px; background: var(--c, var(--brand)); }

/* ---------- punto de venta ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; }
.pos-left { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.prod {
  position: relative; min-height: 152px;
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px; text-align: left;
  border: 1px solid var(--border); border-top: 4px solid var(--c, var(--brand)); border-radius: 12px;
  background: var(--surface); box-shadow: var(--shadow);
  cursor: pointer; transition: transform .12s, box-shadow .12s;
}
.prod:hover { transform: translateY(-2px); box-shadow: 0 10px 22px -12px rgba(16,24,40,.35); }
.prod:active { transform: translateY(0); }
.prod:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: var(--shadow); }
.prod-cat { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--c, var(--brand)); }
.prod-title { font-weight: 700; font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.prod-author { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prod-foot { margin-top: auto; padding-top: 8px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; }
.prod-foot strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.prod-qty { position: absolute; top: -9px; right: -7px; min-width: 24px; height: 24px; padding: 0 6px; display: grid; place-items: center; border-radius: 99px; background: var(--gold); color: #fff; font-weight: 800; font-size: 12px; box-shadow: 0 2px 6px rgba(0,0,0,.2); }

.pos-right { position: sticky; top: 92px; }
.cart { display: flex; flex-direction: column; max-height: calc(100vh - 112px); overflow-y: auto; }
.cart-items { min-height: 90px; }
.cart-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 8px; align-items: center; padding: 10px 14px 10px 16px; border-bottom: 1px solid var(--border); }
.cart-info strong { display: block; font-size: 13px; font-weight: 600; line-height: 1.3; }
.cart-info small { color: var(--muted); font-size: 12px; }
.qty { display: flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); }
.qty input { width: 36px !important; height: 28px !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important; text-align: center; box-shadow: none !important; -moz-appearance: textfield; appearance: textfield; }
.qty input::-webkit-inner-spin-button, .qty input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.cart-line { min-width: 66px; text-align: right; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.cart-form { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--border); }
.cash-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cash-chips:empty { display: none; }
.totals { padding: 12px 16px; background: var(--surface-2); border-top: 1px solid var(--border); }
.t-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-variant-numeric: tabular-nums; }
.t-row.total { margin-top: 4px; padding-top: 9px; border-top: 1px dashed var(--border-strong); font-size: 20px; font-weight: 800; color: var(--brand); }
.t-row.neg { color: var(--danger); font-weight: 700; }
.t-row.pos { color: var(--ok); font-weight: 700; }
.cart-cta { padding: 14px 16px 16px; }

.cart-fab {
  display: none; position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 20;
  height: 52px; align-items: center; justify-content: center; gap: 10px;
  border: 0; border-radius: 14px; background: var(--brand); color: #fff;
  font-weight: 700; font-size: 15px; box-shadow: var(--shadow-lg); cursor: pointer;
}

.cart-fab.oculto { display: none !important; }

/* ---------- modal ---------- */
#modal-root:empty { display: none; }
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(15,23,42,.5); animation: aparecer .15s ease-out; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); animation: subir .18s ease-out; }
.modal.lg { width: min(880px, 100%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { flex: 1; font-size: 17px; font-weight: 700; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 14px 20px; background: var(--surface-2); border-top: 1px solid var(--border); border-radius: 0 0 16px 16px; }
.confirm-msg { font-size: 14.5px; line-height: 1.55; }
@keyframes aparecer { from { opacity: 0; } }
@keyframes subir { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ---------- toasts ---------- */
#toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; max-width: 380px; padding: 12px 16px; border-radius: 12px; background: #1c2433; color: #fff; font-weight: 500; box-shadow: var(--shadow-lg); animation: subir .2s ease-out; transition: opacity .3s; }
.toast.ok .ic { color: #7ee2a8; }
.toast.warn { background: #7a4b06; }
.toast.error { background: var(--danger); }

/* ---------- factura ---------- */
.inv-preview { padding: 34px; background: #fff; border: 1px solid var(--border); border-radius: 12px; }
.inv { position: relative; overflow: hidden; color: #1c2433; font-size: 13px; }
.inv-head { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 2px solid var(--brand); }
.inv-brand { display: flex; gap: 14px; align-items: flex-start; }
.inv-brand .logo { width: 66px; height: 66px; flex: none; border-radius: 50%; object-fit: cover; }
.inv-brand strong { display: block; font-family: var(--font-display); font-size: 20px; font-weight: 800; letter-spacing: -.01em; line-height: 1.2; color: var(--brand); }
.inv-brand span { display: block; margin-bottom: 4px; font-weight: 600; color: var(--gold-600); }
.inv-brand small { display: block; font-size: 11.5px; color: #5b6472; }
.inv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.inv-doc { font-size: 11.5px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.inv-num { font-size: 21px; font-weight: 800; color: var(--brand); }
.inv-meta .badge { margin-top: 6px; }
.inv-client { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.inv-client label { display: block; margin-bottom: 2px; font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.inv-client small { display: block; color: var(--muted); }
.inv-items { width: 100%; margin: 14px 0; border-collapse: collapse; }
.inv-items th { padding: 8px 6px; text-align: left; font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border-strong); }
.inv-items td { padding: 9px 6px; vertical-align: top; border-bottom: 1px solid #f1e7e9; }
.inv-items td small { display: block; font-size: 11px; color: var(--muted); }
.inv-items .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.inv-items .c { text-align: center; }
.ex { margin-left: 5px; padding: 0 4px; border: 1px solid var(--border-strong); border-radius: 4px; font-style: normal; font-size: 10px; font-weight: 700; color: var(--muted); }
.inv-bottom { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.inv-notes { flex: 1; font-size: 12px; }
.inv-notes p { margin-bottom: 6px; }
.inv-totals { min-width: 260px; }
.inv-totals > div { display: flex; justify-content: space-between; gap: 16px; padding: 4px 0; font-variant-numeric: tabular-nums; }
.inv-totals .grand { margin-top: 6px; padding-top: 8px; border-top: 2px solid var(--brand); font-size: 17px; font-weight: 800; color: var(--brand); }
.inv-totals .saldo { font-weight: 800; color: var(--danger); }
.inv-pagos { margin-top: 14px; font-size: 12px; }
.inv-pagos h4 { margin-bottom: 4px; font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.inv-pagos div { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 1px dotted var(--border-strong); }
.inv-foot { margin-top: 22px; padding-top: 14px; text-align: center; color: #5b6472; border-top: 1px solid var(--border); }
.inv-foot p { margin-bottom: 4px; font-style: italic; }
.inv-watermark { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; font-size: 92px; font-weight: 900; letter-spacing: .1em; color: rgba(180,35,24,.11); transform: rotate(-18deg); }

/* ---------- acceso (login) ---------- */
body.sin-sesion .app { display: none; }
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(400px, 1fr); }
.login-brand {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  padding: 48px 32px; text-align: center; color: #fff;
  background:
    radial-gradient(60% 50% at 15% 10%, rgba(255,255,255,.14), transparent 70%),
    radial-gradient(55% 45% at 90% 95%, rgba(0,0,0,.18), transparent 70%),
    var(--brand);
}
.login-brand img { position: relative; width: min(380px, 78%); height: auto; aspect-ratio: 1; border-radius: 28px; box-shadow: 0 30px 60px -20px rgba(40, 10, 18, .55), 0 0 0 1px rgba(255,255,255,.18); }
.login-brand p { position: relative; max-width: 360px; color: #f3e0e4; font-size: 15px; line-height: 1.5; }
.login-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; }
.login-kicker { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--brand); }
.login-kicker img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.login-card h1 { font-size: 27px; font-weight: 800; letter-spacing: -.02em; }
.login-card > p { color: var(--muted); margin-top: -8px; }
.login-card input:not([type=checkbox]) { height: 46px; font-size: 15px; }
.input-ic { position: relative; }
.input-ic > .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-ic input { padding-left: 42px !important; }
.input-ic input[type=password], .input-ic input[data-clave] { padding-right: 46px !important; }
.input-ic .icon-btn { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); }
.login-error { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--danger-50); color: var(--danger); font-weight: 600; font-size: 13px; }
.link-btn { align-self: center; padding: 4px 6px; border: 0; background: none; color: var(--brand); font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.login-foot { margin-top: 36px; color: var(--muted); font-size: 12px; text-align: center; }
.shake { animation: sacudir .35s; }
@keyframes sacudir { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-brand { gap: 12px; padding: 28px 20px 24px; }
  .login-brand img { width: 128px; }
  .login-brand p { font-size: 13px; }
  .login-panel { justify-content: flex-start; padding: 28px 20px; }
  .login-kicker { display: none; }
}

#print-area { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .pos { grid-template-columns: minmax(0, 1fr) 350px; }
}
@media (max-width: 1040px) {
  .pos { grid-template-columns: 1fr; }
  .pos-right { position: static; }
  .cart { max-height: none; overflow: visible; }
  .cart-fab { display: flex; }
  .grid-main, .grid-2col { grid-template-columns: 1fr; }
  .view.has-fab { padding-bottom: 96px; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: 270px; transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-grid !important; margin-left: -6px; }
  .topbar { padding: 12px 16px; gap: 10px; }
  .topbar h1 { font-size: 20px; }
  .today { display: none; }
  .view { padding: 16px 16px 48px; }
}
@media (max-width: 620px) {
  .topbar p { display: none; }
  .topbar .btn-gold .lbl { display: none; }
  .topbar .btn-gold { width: 40px; padding: 0; }
  .grid-2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { flex-direction: column; gap: 8px; padding: 14px; }
  .kpi-ic { width: 34px; height: 34px; }
  .kpi-value { font-size: 18px; }
  .prod-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .prod { min-height: 140px; padding: 12px; }
  .search { flex-basis: 100%; max-width: none; }
  .toolbar select { flex: 1; min-width: 0; }
  .toolbar label.inline { flex: 1; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { max-height: 92vh; border-radius: 18px 18px 0 0; }
  .modal-body { padding: 14px; }
  .modal-foot { border-radius: 0; padding: 12px 14px; }
  .modal-foot .spacer { display: none; }
  .modal-foot .btn { flex: 1 1 auto; }
  .inv-preview { padding: 14px 12px; }
  .inv-items th { padding: 6px 3px; letter-spacing: .02em; }
  .inv-items td { padding: 7px 3px; font-size: 12px; }
  .inv-watermark { font-size: 52px; }
  .inv-head { flex-direction: column; }
  .inv-meta { align-items: flex-start; text-align: left; }
  .inv-client { grid-template-columns: 1fr 1fr; }
  .inv-client > div:first-child { grid-column: 1 / -1; }
  .inv-bottom { flex-direction: column; }
  .inv-totals { min-width: 0; width: 100%; }
  #toast-root { left: 16px; right: 16px; bottom: 80px; align-items: stretch; }
  .bars { gap: 3px; }
  .bar-val { display: none; }
}

/* ---------- impresión ---------- */
@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
  .inv { font-size: 12px; }
  .inv-items tr { break-inside: avoid; }
  #print-area.ticket { width: 72mm; margin: 0 auto; }
  #print-area.ticket .inv { font-size: 10.5px; }
  #print-area.ticket .inv-head { flex-direction: column; align-items: center; gap: 8px; text-align: center; }
  #print-area.ticket .inv-brand { flex-direction: column; align-items: center; gap: 6px; }
  #print-area.ticket .inv-brand .logo { width: auto; height: 42px; }
  #print-area.ticket .inv-brand strong { font-size: 14px; }
  #print-area.ticket .inv-meta { align-items: center; text-align: center; }
  #print-area.ticket .inv-num { font-size: 14px; }
  #print-area.ticket .inv-client { grid-template-columns: 1fr; gap: 4px; }
  #print-area.ticket .inv-items th, #print-area.ticket .inv-items td { padding: 4px 2px; }
  #print-area.ticket .inv-items td small { display: none; }
  #print-area.ticket .inv-bottom { flex-direction: column; gap: 8px; }
  #print-area.ticket .inv-totals { min-width: 0; width: 100%; }
  #print-area.ticket .inv-totals .grand { font-size: 13px; }
  #print-area.ticket .inv-watermark { font-size: 40px; }
}
