/* Gestión de Cuentas por Cobrar */
:root {
  --navy: #0b1d36;
  --navy-2: #0f2544;
  --navy-line: #1f3556;
  --bg: #f4f6fa;
  --card: #ffffff;
  --line: #e3e8ef;
  --text: #0f172a;
  --muted: #5b6475;
  --placeholder: #9aa3b2;
  --blue: #1a5fd8;
  --blue-soft: #eaf2ff;
  --green: #17913e;
  --green-soft: #ecf9f0;
  --red: #e5251f;
  --red-soft: #fff0ef;
  --orange: #f59e0b;
  --orange-soft: #fff7e6;
  --purple: #6b35b8;
  --purple-soft: #f3edfc;
  --teal: #0f9488;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05);
  --accent: var(--blue);
  --sidebar: 264px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg.i { width: 1em; height: 1em; flex: none; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex: none; background: var(--navy); color: #fff;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  z-index: 30; transition: transform .2s;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 14px; }
.brand svg { width: 42px; height: 42px; }
.brand b { display: block; font-size: 19px; letter-spacing: .2px; line-height: 1.2; }
.brand small { font-size: 12.5px; opacity: .85; }
.nav { padding: 4px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px;
  font-size: 15px; font-weight: 500; color: #dbe3ee; white-space: nowrap;
}
.nav a svg { width: 22px; height: 22px; opacity: .9; }
.nav a:hover { background: var(--navy-2); color: #fff; }
.nav a.active { background: var(--accent); color: #fff; }
.nav .badge { margin-left: auto; background: var(--red); color: #fff; border-radius: 10px; font-size: 11.5px; padding: 1px 7px; font-weight: 600; }
.admin-box {
  margin: auto 10px 12px; border: 1px solid var(--navy-line); border-radius: 8px; padding: 12px 14px;
  background: var(--navy-2); text-align: left; color: #fff; width: calc(100% - 20px);
}
.admin-box .row { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 13.5px; letter-spacing: .3px; }
.admin-box .row svg:last-child { margin-left: auto; }
.admin-box p { margin: 6px 0 0 26px; font-size: 12.5px; opacity: .8; line-height: 1.4; }
.user-box { border-top: 1px solid var(--navy-line); padding: 14px 20px; display: flex; align-items: center; gap: 12px; }
.user-box .av { width: 40px; height: 40px; border-radius: 50%; background: #fff; color: var(--navy); display: grid; place-items: center; flex: none; }
.user-box .av svg { width: 26px; height: 26px; }
.user-box b { display: block; font-size: 15px; }
.user-box small { opacity: .8; font-size: 12.5px; }
.user-box .icon-btn { color: #fff; }
.user-box .icon-btn:hover { background: var(--navy-2); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--line); padding: 14px 24px;
  display: flex; align-items: center; gap: 14px; min-height: 68px;
}
.topbar .menu-btn { background: none; border: 0; padding: 4px; display: none; }
.topbar .menu-btn svg { width: 24px; height: 24px; }
.topbar .title { margin: 0; font-size: 19px; font-weight: 700; color: var(--navy); letter-spacing: .4px; flex: 1; min-width: 0; }
.topbar .tools { display: flex; align-items: center; gap: 18px; margin-left: auto; }
.page-head { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.page-head .ph-icon svg { width: 40px; height: 40px; }
.page-head .ph-icon.box { width: 52px; height: 40px; border-radius: 6px; display: grid; place-items: center; color: #fff; }
.page-head .ph-icon.box svg { width: 26px; height: 26px; }
.page-head h1 { margin: 0; font-size: 23px; font-weight: 700; color: var(--navy); line-height: 1.2; }
.page-head p { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.datebox {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; display: flex; align-items: center; gap: 10px;
  font-size: 13.5px; text-align: center; line-height: 1.5; background: #fff; white-space: nowrap;
}
.datebox svg { width: 20px; height: 20px; color: var(--muted); }
.status { display: flex; align-items: center; gap: 8px; font-size: 14px; white-space: nowrap; color: #27324a; }
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); }
.status .dot.off { background: var(--red); }
.status svg { width: 22px; height: 22px; }
.icon-btn { background: none; border: 0; padding: 6px; border-radius: 6px; display: grid; place-items: center; color: inherit; }
.icon-btn:hover { background: #f1f4f9; }
.icon-btn svg { width: 22px; height: 22px; }

.content { padding: 18px 22px 22px; flex: 1; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.grid-main > * { min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---------- Cards / forms ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.card h2 { margin: 0 0 12px; font-size: 16.5px; font-weight: 700; color: var(--navy); }
.card h2.big { font-size: 18px; }
.card .card-head { margin: -16px -18px 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: #f8fafc; border-radius: var(--radius) var(--radius) 0 0; }
.card .card-head h2 { margin: 0; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.field label { font-size: 13.5px; color: #334155; font-weight: 500; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid #cfd6e0; border-radius: 6px; background: #fff; padding: 9px 12px; font-size: 15px; outline: none; min-height: 42px;
}
.input::placeholder { color: var(--placeholder); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea.input { resize: vertical; min-height: 64px; }
.input-group { display: flex; border: 1px solid #cfd6e0; border-radius: 6px; overflow: hidden; background: #fff; }
.input-group:focus-within { border-color: var(--accent); }
.input-group > span { padding: 9px 12px; background: #f1f4f8; border-right: 1px solid #cfd6e0; color: var(--muted); display: grid; place-items: center; }
.input-group .input { border: 0; border-radius: 0; box-shadow: none !important; }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: #5b6475; pointer-events: none; }
.input-icon .input { padding-left: 40px; }
.err { color: var(--red); font-size: 13px; }
.input.invalid { border-color: var(--red); }
.form-grid { display: grid; gap: 10px 12px; align-items: end; }
.form-grid .field { margin: 0; }
.add-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.add-grid .field:nth-child(1) { grid-column: span 2; }
.add-grid .span2 { grid-column: span 4; }
.add-grid .field:nth-child(3), .add-grid .field:nth-child(4), .add-grid > .btn { grid-column: span 2; }
.filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 8px; border: 1px solid transparent;
  padding: 9px 16px; font-weight: 600; font-size: 14.5px; min-height: 42px; white-space: nowrap;
}
.btn svg { width: 20px; height: 20px; }
.btn-lg { padding: 12px 24px; font-size: 16px; min-height: 50px; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-purple { background: var(--purple); color: #fff; }
.btn-gray { background: #f1f3f6; border-color: #dfe3ea; color: #111; }
.btn-outline { background: var(--blue-soft); border-color: #b9d1f5; color: var(--blue); }
.btn-print { background: #eef4ff; border-color: #c9dafa; color: var(--blue); }
.btn-wa { background: var(--green-soft); border-color: #cbead5; color: var(--green); }
.btn-pdf { background: var(--red-soft); border-color: #f8d2cf; color: var(--red); }
.btn-danger-soft { background: var(--red-soft); border-color: #f6c4c1; color: var(--red); }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: 13.5px; font-weight: 500; }
.btn-xs { padding: 3px 10px; min-height: 28px; font-size: 12.5px; font-weight: 500; border-radius: 5px; }
.btn-xs svg { width: 16px; height: 16px; }
.btn-icon { padding: 4px; min-height: 30px; min-width: 30px; background: #f1f3f6; border-color: #dfe3ea; color: #334155; }
.btn-icon svg { width: 17px; height: 17px; }
.btn-select { background: #5aa1f5; color: #fff; }
.btn-select.on { background: var(--green); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:not(:disabled):hover { filter: brightness(.96); }
.btn-text { background: none; border: 0; color: var(--blue); font-weight: 700; font-size: 16px; }
.trash { background: none; border: 0; color: var(--red); padding: 4px; border-radius: 5px; }
.trash:hover { background: var(--red-soft); }
.trash svg { width: 19px; height: 19px; }

.money-red { color: var(--red); font-weight: 700; }
.money-green { color: var(--green); font-weight: 700; }
.money-blue { color: var(--blue); font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.center { text-align: center; }
.flex { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.mt { margin-top: 14px; }
.grow { flex: 1; min-width: 0; }

/* Client selector block */
.client-pick { position: relative; }
.suggest {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 10px 30px rgba(15, 23, 42, .12); max-height: 280px; overflow: auto;
}
.suggest button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 14px; border-bottom: 1px solid #f0f2f5; }
.suggest button:hover, .suggest button.hl { background: var(--blue-soft); }
.suggest small { color: var(--muted); }
.client-card { margin-top: 12px; background: #f6f9ff; border: 1px solid #dbe6f7; border-radius: 8px; padding: 14px 16px; }
.client-card .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.client-card b.name { font-size: 16.5px; }
.client-card .meta { font-size: 13.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.client-card .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.client-card .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px 16px; margin-top: 12px; padding-top: 12px; border-top: 1px solid #dbe6f7; }
.client-card .stat small { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.client-card .stat b { font-size: 17px; white-space: nowrap; }
.empty-client { margin-top: 12px; border: 1px dashed #c8d3e3; border-radius: 8px; padding: 18px; text-align: center; color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { background: #f4f6f9; font-weight: 600; font-size: 12.5px; color: #334155; text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 8px; border-bottom: 1px solid #edf0f4; vertical-align: middle; }
table.t th:first-child, table.t td:first-child { padding-left: 12px; }
table.t th:last-child, table.t td:last-child { padding-right: 12px; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.num, table.t th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.t td.nw, table.t th.nw { white-space: nowrap; }
table.t th.wide { min-width: 220px; }
table.t td .btn, table.t td .trash { vertical-align: middle; }
table.t td.c, table.t th.c { text-align: center; }
table.t td.acts { white-space: nowrap; text-align: right; }
table.t td.acts .btn + .btn, table.t td.acts .btn + .trash { margin-left: 4px; }
table.t tfoot td { background: #f4f6f9; font-weight: 700; font-size: 15px; padding: 12px 10px; white-space: nowrap; }
table.t tbody tr.clickable { cursor: pointer; }
table.t tbody tr.clickable:hover { background: #f7faff; }
table.t input.input { min-height: 34px; padding: 4px 8px; font-size: 14px; text-align: center; }
input.cell { width: 100%; border: 1px solid transparent; background: transparent; border-radius: 4px; padding: 6px 6px; font-size: 14px; outline: none; }
input.cell.c { text-align: center; max-width: 100px; }
input.cell:hover { border-color: #dde3ec; background: #fff; }
input.cell:focus { border-color: var(--accent); background: #fff; }
.tipo-CARGO { color: var(--red); font-weight: 600; }
.tipo-PAGO { color: var(--green); font-weight: 600; }
.tipo-DEVOLUCION { color: var(--purple); font-weight: 600; }
.tipo-AJUSTE { color: var(--orange); font-weight: 600; }
.tipo-SALDO { color: var(--muted); font-weight: 600; }
.empty { padding: 24px; text-align: center; color: var(--muted); white-space: normal; }

/* Summary rows */
.kv { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; font-size: 14.5px; }
.kv .v { font-weight: 500; text-align: right; }
.kv .v.big { font-size: 22px; font-weight: 700; }
.kv-stack > div { padding: 12px 0; border-bottom: 1px solid var(--line); }
.kv-stack > div:last-child { border-bottom: 0; }
.kv-stack .k { font-size: 13.5px; color: var(--muted); }
.kv-stack .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.total-box { border-radius: 8px; padding: 12px 14px; }
.total-box.red { background: var(--red-soft); border: 1px solid #f8d6d3; }
.total-box.green { background: var(--green-soft); border: 1px solid #cdebd6; }
.total-box .v { font-size: 26px; font-weight: 700; text-align: right; white-space: nowrap; }
.info-box { background: #eef5ff; border: 1px solid #cfe0fa; border-radius: 8px; padding: 12px 14px; display: flex; gap: 10px; font-size: 13.5px; align-items: flex-start; }
.info-box svg { width: 22px; height: 22px; color: var(--blue); flex: none; }
.ok-box { background: var(--green-soft); border: 1px solid #cdebd6; border-radius: 8px; padding: 10px 14px; display: flex; gap: 12px; align-items: center; font-size: 14px; }
.ok-box svg { width: 28px; height: 28px; color: var(--green); flex: none; }
.ok-box b { color: var(--green); }
.ok-box.warn { background: var(--orange-soft); border-color: #f6dfb1; }
.ok-box.warn svg, .ok-box.warn b { color: #b86e00; }
.ok-box.danger { background: var(--red-soft); border-color: #f6c4c1; }
.ok-box.danger svg, .ok-box.danger b { color: var(--red); }

.radio { display: flex; align-items: center; gap: 10px; margin: 6px 0; font-size: 14.5px; cursor: pointer; }
.radio input { width: 17px; height: 17px; accent-color: var(--blue); }

/* Toggle */
.switch { position: relative; width: 50px; height: 28px; display: inline-block; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cbd2dc; border-radius: 30px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::before { transform: translateX(22px); }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #eef1f5; font-size: 14.5px; }
.toggle-row:last-of-type { border-bottom: 0; }

.stars { display: flex; gap: 8px; justify-content: center; margin: 10px 0; }
.stars button { background: none; border: 0; padding: 0; color: #e5e7eb; }
.stars button.on { color: #f5b301; }
.stars svg { width: 36px; height: 36px; }

/* ---------- Dashboard ---------- */
.greet { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 16px; }
.greet h2 { margin: 4px 0 4px; font-size: 24px; }
.greet p { margin: 0; font-size: 14.5px; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; display: block; }
.kpi .top { display: flex; gap: 12px; align-items: center; min-width: 0; }
.kpi .circle { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; }
.kpi .circle svg { width: 23px; height: 23px; }
.kpi .lbl { font-size: 12px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; line-height: 1.3; min-width: 0; }
.kpi .val { font-size: clamp(21px, 1.3vw + 10px, 28px); font-weight: 700; margin-top: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.kpi .sub { margin-top: 2px; font-size: 13px; color: var(--muted); }
.alerts { margin-top: 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.alerts .h { padding: 12px 18px; color: var(--red); font-weight: 700; font-size: 13px; letter-spacing: .5px; border-bottom: 1px solid var(--line); }
.alerts .items { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
.alert-item { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-right: 1px solid var(--line); background: #fff; text-align: left; font-size: 14px; min-width: 0; }
.alert-item:last-child { border-right: 0; }
.alert-item:hover { background: #f7faff; }
.alert-item > span:not(.circle):not(.count) { flex: 1; min-width: 0; }
.alert-item .circle { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; }
.alert-item .circle svg { width: 22px; height: 22px; }
.alert-item .chev { width: 20px; height: 20px; color: var(--muted); flex: none; }
.alert-item .count { font-size: 22px; color: var(--blue); font-weight: 700; flex: none; }
.quick { margin-top: 16px; }
.quick h3 { margin: 0 0 12px; font-size: 13px; letter-spacing: .5px; color: var(--muted); }
.quick .tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.tile { border: 0; border-radius: 12px; color: #fff; padding: 22px 10px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; min-height: 150px; justify-content: center; font-weight: 700; font-size: 15px; line-height: 1.3; text-align: center; }
.tile svg { width: 54px; height: 54px; }
.tile:hover { filter: brightness(1.07); }
.dash-foot { display: flex; align-items: center; justify-content: space-between; gap: 20px; background: #fff; padding: 12px 24px; border-top: 1px solid var(--line); font-size: 13.5px; flex-wrap: wrap; }
.dash-foot .ic { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.dash-foot .ic svg { width: 24px; height: 24px; }
.pill { display: inline-block; background: #dff3e5; color: var(--green); border-radius: 6px; padding: 1px 8px; font-size: 12px; font-weight: 600; }
.pill.off { background: #eceff3; color: var(--muted); }

/* Action bar at the bottom of operational screens */
.actions-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: #fff; padding: 12px 22px; border-top: 1px solid var(--line); }
.actions-bar .left { flex: 1; min-width: 240px; }
.actions-bar .right { display: flex; gap: 10px; flex-wrap: wrap; margin-left: auto; }

/* Comprobante / ticket */
.ticket { background: #f7faf8; border: 1px solid #e4ece6; border-radius: 8px; padding: 16px; font-size: 13.5px; }
.ticket h3 { text-align: center; margin: 0 0 10px; font-size: 16px; }
.ticket .dash { border-top: 2px dashed #b9c1cb; margin: 10px 0; }
.ticket .head { text-align: center; }
.ticket .head b { font-size: 17px; display: block; }
.ticket .stamp { display: inline-block; background: #e9ecef; padding: 6px 16px; border-radius: 4px; font-weight: 700; margin: 10px 0 4px; font-size: 12.5px; }
.ticket .tk { display: grid; grid-template-columns: 90px 10px 1fr; row-gap: 4px; }
.ticket .tk span:last-child { min-width: 0; overflow-wrap: anywhere; }
.ticket .thanks { text-align: center; font-weight: 600; }

/* Lists */
.chip { display: inline-block; border-radius: 20px; padding: 2px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip.ok { background: var(--green-soft); color: var(--green); }
.chip.bad { background: var(--red-soft); color: var(--red); }
.chip.warn { background: var(--orange-soft); color: #b86e00; }
.chip.off { background: #eef0f3; color: var(--muted); }
.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 6px 14px; font-size: 13.5px; }
.big-tabs button { padding: 8px 18px; font-size: 14.5px; font-weight: 500; }
.tabs button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(11, 29, 54, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: min(720px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal.sm { width: min(440px, 100%); }
.modal.lg { width: min(1040px, 100%); }
.modal .mh { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal .mh h3 { margin: 0; font-size: 17px; }
.modal .mb { padding: 16px 18px; }
/* Catálogo de productos (modal) */
.cat-pick { display: flex; flex-direction: column; gap: 12px; }
.cat-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.cat-tab { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 5px 13px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.cat-tab.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.cat-list { max-height: 54vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.cat-h { position: sticky; top: 0; background: #f6f8fb; padding: 7px 14px; font-size: 12px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); z-index: 1; }
.cat-row { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px; border: 0; background: none; text-align: left; padding: 9px 14px; border-bottom: 1px solid #f0f2f5; cursor: pointer; }
.cat-row:hover { background: var(--blue-soft); }
.cat-row[data-agotado] { opacity: .55; }
.cat-row .nm b { display: block; font-size: 14px; }
.cat-row .nm small { color: var(--muted); }
.cat-row .dt { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.cat-row .pr { font-size: 14px; min-width: 76px; text-align: right; }

.modal .mf { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #0b1d36; color: #fff; padding: 12px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: 360px; font-size: 14px; animation: tin .2s; }
.toast.ok { background: var(--green); }
.toast.bad { background: var(--red); }
@keyframes tin { from { transform: translateY(10px); opacity: 0; } }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #0b1d36, #163a6b); padding: 16px; }
.login-card { background: #fff; border-radius: 16px; padding: 32px; width: min(420px, 100%); text-align: center; }
.login-card .brand { justify-content: center; color: var(--navy); padding: 0 0 4px; }
.login-card h2 { margin: 18px 0 4px; font-size: 20px; }
.login-card .opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.login-card .foot { margin-top: 18px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }

/* Print */
#print-area { display: none; }
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { display: block; position: absolute; left: 0; top: 0; width: 100%; font-family: "Courier New", monospace; color: #000; }
  #print-area.ticket80 { width: 76mm; font-size: 12px; }
  #print-area table { width: 100%; border-collapse: collapse; }
  #print-area th, #print-area td { padding: 3px 4px; font-size: 11px; text-align: left; }
  #print-area .r { text-align: right; }
  #print-area hr { border: 0; border-top: 1px dashed #000; }
  #print-area.a4 { font-family: Arial, sans-serif; padding: 10mm; }
  #print-area.a4 th, #print-area.a4 td { border-bottom: 1px solid #ccc; font-size: 12px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .grid-main { grid-template-columns: minmax(0, 1fr) 300px; }
  .quick .tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .tile { font-size: 13.5px; min-height: 130px; }
  .tile svg { width: 44px; height: 44px; }

}
@media (max-width: 1100px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); }
  .app.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
  .topbar .menu-btn { display: block; }
  .grid-main { grid-template-columns: minmax(0, 1fr) !important; }
  .alerts .items { grid-template-columns: 1fr; }
  .alert-item { border-right: 0; border-bottom: 1px solid var(--line); }
  .alert-item:last-child { border-bottom: 0; }
  .quick .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {

  .filter-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 680px) {
  .add-grid .field:nth-child(1), .add-grid .field:nth-child(3), .add-grid .field:nth-child(4) { grid-column: span 3; }
  .add-grid .span2, .add-grid > .btn { grid-column: 1 / -1; }
  .content { padding: 12px 14px 16px; }
  .topbar { padding: 10px 14px; gap: 10px; min-height: 60px; }
  .topbar .tools { gap: 10px; }
  .page-head { gap: 10px; }
  .page-head h1 { font-size: 19px; }
  .page-head p { font-size: 13px; }
  .page-head .ph-icon svg { width: 32px; height: 32px; }
  .page-head .ph-icon.box { width: 42px; height: 34px; }
  .datebox, .status .txt, .topbar .hide-sm { display: none; }
  .row2, .pay-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .btn-lg { padding: 11px 16px; font-size: 15px; min-height: 46px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .circle { width: 40px; height: 40px; }
  .kpi .circle svg { width: 22px; height: 22px; }
  .kpi .val { font-size: 19px; }
  .quick .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .greet { flex-direction: column; gap: 6px; }
  .greet h2 { font-size: 20px; }
  .dash-foot { padding: 12px 14px; }
  .actions-bar { padding: 12px 14px; }
  .actions-bar .right { width: 100%; }
  .actions-bar .right .btn { flex: 1; }
  .client-card .acts { width: 100%; }
  .client-card .acts .btn { flex: 1; }
  .card { padding: 14px; }
  .card .card-head { margin: -14px -14px 12px; padding: 12px 14px; }
}


/* ═══ Modo demo ═══════════════════════════════════════════════════════════
   Solo aparece con DEMO=1. El aviso del login muestra la clave (es pública a propósito)
   y la cinta recuerda en cada pantalla que los datos son de ejemplo. */
.demo-login { margin-top: 18px; padding: 14px 16px; border-radius: 12px; text-align: left;
              background: var(--orange-soft); border: 1px solid #f6dfb1; display: grid; gap: 8px;
              font-size: 13.5px; color: var(--text); }
.demo-login > b { color: #8a5200; font-size: 14px; }
.demo-login .demo-clave { display: inline-block; padding: 1px 8px; border-radius: 6px;
                          background: #fff; border: 1px solid #f6dfb1; letter-spacing: .08em; }
.demo-login small { color: var(--muted); font-size: 12px; }
.demo-login .btn { justify-self: start; }
.demo-cinta { display: flex; gap: 10px; align-items: center; padding: 9px 16px;
              background: var(--orange-soft); border-bottom: 1px solid #f6dfb1;
              color: #6b4200; font-size: 13.5px; }
.demo-cinta svg { width: 18px; height: 18px; flex: none; color: #b86e00; }
.demo-cinta a { color: #6b4200; font-weight: 600; }
