:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e3e5e8;
  --text: #1b1f24;
  --muted: #6b7280;
  --primary: #1f6f5c;
  --primary-hover: #185a4a;
  --primary-soft: #e3f1ec;
  --danger: #c0392b;
  --danger-soft: #fbeaea;
  --warn: #a15c00;
  --warn-soft: #fdf1dc;
  --ok: #1f7a3d;
  --ok-soft: #e4f4e8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .06);
  --topbar-h: 56px;
  --seg-bg: #e9ebee;
  --hover: rgba(0, 0, 0, .06);
  --thumb-bg-l: 92%;
  --thumb-fg-l: 32%;
  --toast-bg: #1b1f24;
  color-scheme: light;
}

/* Modo oscuro: elegido con el botón, o el del sistema si no se eligió ninguno. */
:root[data-theme="dark"] {
  --bg: #0f1214;
  --surface: #171b1f;
  --surface-2: #1e2328;
  --border: #2d343b;
  --text: #e6e9ed;
  --muted: #9aa4ae;
  --primary: #3fae8d;
  --primary-hover: #5cc3a4;
  --primary-soft: #17352c;
  --danger: #f0776a;
  --danger-soft: #3b1f1c;
  --warn: #e6a64e;
  --warn-soft: #3a2d17;
  --ok: #55c785;
  --ok-soft: #173424;
  --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 4px 14px rgba(0, 0, 0, .35);
  --seg-bg: #23292f;
  --hover: rgba(255, 255, 255, .08);
  --thumb-bg-l: 22%;
  --thumb-fg-l: 78%;
  --toast-bg: #2b3238;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1214;
    --surface: #171b1f;
    --surface-2: #1e2328;
    --border: #2d343b;
    --text: #e6e9ed;
    --muted: #9aa4ae;
    --primary: #3fae8d;
    --primary-hover: #5cc3a4;
    --primary-soft: #17352c;
    --danger: #f0776a;
    --danger-soft: #3b1f1c;
    --warn: #e6a64e;
    --warn-soft: #3a2d17;
    --ok: #55c785;
    --ok-soft: #173424;
    --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 4px 14px rgba(0, 0, 0, .35);
    --seg-bg: #23292f;
    --hover: rgba(255, 255, 255, .08);
    --thumb-bg-l: 22%;
    --thumb-fg-l: 78%;
    --toast-bg: #2b3238;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.boot, .fatal { padding: 48px; text-align: center; color: var(--muted); }
.fatal { color: var(--danger); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); font-weight: 600; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--hover); }
.btn.block { width: 100%; }
.btn.lg { padding: 14px 18px; font-size: 16px; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: none; background: transparent;
  display: inline-grid; place-items: center; font-size: 20px; line-height: 1; color: var(--muted);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.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(--primary-soft); color: var(--primary); }

.banner { padding: 10px 16px; font-size: 13px; background: var(--warn-soft); color: var(--warn); }
.banner.danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Selector de sede ---------- */
.sede-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.sede-box { width: 100%; max-width: 640px; text-align: center; }
.sede-box .brand { font-weight: 700; color: var(--primary); letter-spacing: .02em; }
.sede-box h1 { font-size: 26px; margin: 8px 0 28px; }
.sede-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.sede-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 32px 20px; border-radius: 14px; border: 2px solid var(--border); background: var(--surface);
  box-shadow: var(--shadow); transition: border-color .15s, transform .15s;
}
.sede-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.sede-prefix {
  width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 18px;
}
.sede-name { font-size: 20px; font-weight: 700; }
.sede-card .badge { position: absolute; top: 10px; right: 10px; }
.sede-loc { font-size: 12px; }
.sede-box .banner { margin-top: 24px; border-radius: 10px; text-align: left; }

/* ---------- Barra superior ---------- */
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 16px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: 4px; }
.tab { padding: 8px 14px; border: none; border-radius: 8px; background: transparent; font-weight: 600; color: var(--muted); }
.tab.active { background: var(--primary-soft); color: var(--primary); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.sede-chip { display: inline-flex; align-items: center; gap: 8px; }
.sede-chip strong { color: var(--primary); }

/* ---------- Vender ---------- */
.pos { display: grid; grid-template-columns: 1fr 400px; height: calc(100vh - var(--topbar-h)); }
.with-banner .pos { height: calc(100vh - var(--topbar-h) - 38px); }
.catalog { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.catalog-bar { display: flex; gap: 8px; padding: 12px 16px; }
.catalog-bar input { flex: 1; }
.cat-status { padding: 0 16px 8px; font-size: 12px; color: var(--muted); min-height: 22px; }
.product-grid {
  flex: 1; overflow: auto; padding: 4px 16px 16px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; align-content: start;
  /* Sin esto, con muchas filas el navegador encoge las tarjetas para que quepan. */
  grid-auto-rows: max-content;
}
.product-card {
  display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
}
.product-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.product-card:active { transform: scale(.98); }
.thumb {
  flex: none; aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden;
  background: hsl(var(--h, 160) 35% var(--thumb-bg-l)); color: hsl(var(--h, 160) 35% var(--thumb-fg-l)); font-weight: 700; font-size: 22px;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.pc-body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.pc-title { font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pc-meta { font-size: 12px; color: var(--muted); }
.pc-foot { margin-top: auto; padding-top: 6px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.pc-price { font-weight: 700; }
.stock { font-size: 11px; font-weight: 600; color: var(--muted); }
.stock.out { color: var(--danger); }
.grid-msg { grid-column: 1 / -1; padding: 40px 16px; text-align: center; color: var(--muted); }

.cart { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--border); }
.cart-customer { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.customer-card { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--primary-soft); }
.avatar {
  width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 13px;
}
.customer-card .info { flex: 1; min-width: 0; }
.customer-card .info div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-lines { flex: 1; overflow: auto; padding: 4px 16px; }
.cart-empty { padding: 48px 8px; text-align: center; color: var(--muted); }
.line { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.line-title { font-weight: 600; }
.line-sub { font-size: 12px; color: var(--muted); }
.line-total { font-weight: 700; text-align: right; }
.line-controls { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.qty button { width: 32px; height: 30px; border: none; background: var(--surface-2); font-size: 16px; }
.qty input { width: 48px; height: 30px; border: none; border-radius: 0; padding: 0; text-align: center; box-shadow: none; }
.line-controls .unit { font-size: 12px; color: var(--muted); }
.line-controls .icon-btn { margin-left: auto; font-size: 16px; width: 28px; height: 28px; }
.cart-footer { padding: 12px 16px 16px; border-top: 1px solid var(--border); background: var(--surface-2); }
.trow { display: flex; justify-content: space-between; padding: 3px 0; }
.trow.total { font-size: 20px; font-weight: 700; padding-top: 8px; }
.trow .link { border: none; background: none; color: var(--danger); font-size: 12px; padding: 0 4px; }
.cart-actions { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.cart-actions .btn { flex: 1; padding: 7px 8px; font-size: 13px; }
.note-preview { font-size: 12px; color: var(--muted); padding: 2px 0 4px; white-space: pre-line; }

/* ---------- Facturas ---------- */
.invoices { padding: 16px; max-width: 1200px; margin: 0 auto; }
.inv-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.date-nav { display: flex; align-items: center; gap: 6px; }
.date-nav input { width: 160px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--seg-bg); flex-wrap: wrap; }
.seg button { padding: 6px 12px; border: none; border-radius: 8px; background: transparent; font-weight: 600; color: var(--muted); font-size: 13px; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.inv-toolbar .search { margin-left: auto; width: 260px; }
.day-title { font-size: 18px; font-weight: 700; margin: 4px 0 12px; text-transform: capitalize; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.card .k { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.card .v { font-size: 22px; font-weight: 700; margin-top: 4px; }
.card .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.methods { list-style: none; margin: 6px 0 0; padding: 0; }
.methods li { display: flex; justify-content: space-between; padding: 2px 0; font-size: 13px; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); }
td.r, th.r { text-align: right; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
.empty-row td { text-align: center; color: var(--muted); padding: 40px; cursor: default; }

/* ---------- Modales ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 20, 25, .45); z-index: 50;
  display: grid; place-items: center; padding: 16px; animation: fade .12s ease-out;
}
.modal {
  width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow: auto;
  background: var(--surface); border-radius: 14px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
.modal.wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 20px 8px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 8px 20px 20px; }
.modal .seg { margin: 0 20px 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.list { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; max-height: 340px; overflow: auto; }
.list-item {
  display: flex; align-items: center; gap: 10px; padding: 10px; text-align: left;
  border: 1px solid transparent; border-radius: 8px; background: transparent;
}
.list-item:hover { background: var(--surface-2); border-color: var(--border); }
.list-item small { display: block; color: var(--muted); }
.list-item .grow { flex: 1; min-width: 0; }
.list-msg { padding: 24px; text-align: center; color: var(--muted); }
@keyframes fade { from { opacity: 0; } }

.ck-total { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); margin-bottom: 14px; }
.ck-total strong { font-size: 26px; }
.method-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-bottom: 10px; }
.method-btn { padding: 12px 8px; border: 2px solid var(--border); border-radius: 10px; background: var(--surface); font-weight: 600; }
.method-btn.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.amount-row { display: flex; gap: 8px; }
.amount-row input { font-size: 18px; font-weight: 600; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pay-list { list-style: none; margin: 14px 0 0; padding: 0; }
.pay-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.pay-list .icon-btn { width: 26px; height: 26px; font-size: 16px; }
.ck-status { display: flex; justify-content: space-between; margin-top: 12px; font-size: 15px; font-weight: 600; }
.ck-status .change { color: var(--ok); }
.ck-status .remaining { color: var(--warn); }
.ck-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

.done { text-align: center; padding: 28px 20px 20px; }
.done .check { width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; font-size: 28px; }
.done h2 { margin: 0 0 4px; }
.done .num-big { font-size: 22px; font-weight: 700; color: var(--primary); }
.done .change-big { margin-top: 14px; padding: 12px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); font-size: 20px; font-weight: 700; }
.done .balance-big { margin-top: 14px; padding: 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-weight: 700; }
.done .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 20px; }

.detail-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.detail-section { margin-top: 16px; }
.detail-section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin: 0 0 6px; }
.detail-table td, .detail-table th { padding: 7px 8px; white-space: normal; }
.detail-table tbody tr { cursor: default; }
.detail-table tbody tr:hover { background: none; }
.pay-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; margin-top: 10px; padding: 12px; border-radius: 10px; background: var(--surface-2); }
.sync-box { margin-top: 16px; padding: 10px 12px; border-radius: 10px; font-size: 13px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.sync-box.err { background: var(--danger-soft); color: var(--danger); }
.sync-box.ok { background: var(--ok-soft); color: var(--ok); }
.sync-box.pending { background: var(--warn-soft); color: var(--warn); }
.detail-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* ---------- Bolívares y caja ---------- */
.rate-chip strong { color: var(--primary); }
.trow.bs { color: var(--muted); font-size: 13px; padding-top: 0; }
.ck-total-amounts { display: flex; flex-direction: column; align-items: flex-end; }
.ck-total-amounts span { color: var(--muted); font-size: 14px; }
.method-btn small { font-size: 10px; font-weight: 700; color: var(--muted); }
.conv { font-size: 13px; color: var(--muted); margin: 4px 0 2px; min-height: 18px; }
.change-big .sub { font-size: 14px; font-weight: 600; opacity: .85; }
tr.voided td { color: var(--muted); text-decoration: line-through; }
tr.voided td:last-child { text-decoration: none; }
.check-label { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--text); }
.check-label input { width: auto; }
.ret-sum { margin: 12px 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.ret-line { display: grid; grid-template-columns: minmax(140px, 1fr) 140px 28px 32px; gap: 8px; align-items: center; margin-bottom: 6px; }
.ret-line .conv { grid-column: 1 / -1; margin: -2px 0 4px; }
.rf-cur { font-weight: 600; color: var(--muted); }
.ret-line-actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 8px; }
.ret-total { font-size: 14px; margin-bottom: 12px; }
.ret-none { margin: 4px 0 8px; }
.detail-table input.ret-qty { width: 72px; text-align: right; padding: 6px 8px; }
.toolbar-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.caja-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-bottom: 12px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.panel h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.panel .table-wrap { border: none; }
table.kv td, table.kv th { padding: 6px 4px; white-space: normal; }
table.kv tbody tr, table.kv tr { cursor: default; }
table.kv tr:hover { background: none; }
table.kv tr.strong td { font-weight: 700; }
.bills input { width: 90px; text-align: right; padding: 6px 8px; }
.outflow-form { display: grid; grid-template-columns: 1fr 100px auto; gap: 8px; margin-top: 10px; }
.caja-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 0 24px; }
.ok-text { color: var(--ok); }
.danger-text { color: var(--danger); }

/* ---------- Sesión, usuario y tema ---------- */
.corner-bar { position: fixed; top: 12px; right: 16px; display: flex; align-items: center; gap: 10px; z-index: 5; }
.login-box {
  width: 100%; max-width: 380px; padding: 28px 24px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
}
.login-box .brand { font-weight: 700; color: var(--primary); }
.login-box h1 { font-size: 22px; margin: 4px 0 10px; }
.login-box label { margin-top: 6px; }
.login-box .btn.lg { margin-top: 14px; }
.login-box .banner { border-radius: 8px; margin-bottom: 6px; }
.login-box .ck-actions { margin-top: 14px; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; padding: 5px 10px 5px 5px; }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.user-chip .user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.theme-btn { border: 1px solid var(--border); }
span.sede-chip { padding: 9px 4px; font-weight: 600; }
.mode-seg { margin-bottom: 12px; }
@media (max-width: 600px) {
  .user-chip .user-name { display: none; }
  .corner-bar { position: static; justify-content: flex-end; margin-bottom: 12px; }
}

/* ---------- Toasts ---------- */
#toast-root { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { padding: 10px 16px; border-radius: 10px; background: var(--toast-bg); color: #fff; box-shadow: var(--shadow); font-weight: 500; animation: fade .15s; max-width: 90vw; }
.toast.error { background: var(--danger); }
.toast.warn { background: var(--warn); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .pos { grid-template-columns: 1fr; height: auto; }
  .with-banner .pos { height: auto; }
  .product-grid { max-height: 55vh; }
  .cart { border-left: none; border-top: 1px solid var(--border); }
  .cart-lines { max-height: none; }
  .inv-toolbar .search { margin-left: 0; width: 100%; }
}
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 16px; gap: 8px; }
  .topbar-right { margin-left: 0; width: 100%; justify-content: space-between; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .form-grid, .pay-form, .ck-actions, .done .actions { grid-template-columns: 1fr; }
}

/* ---------- Impresión (recibo 80 mm) ---------- */
#print-area { display: none; }
@media print {
  @page { size: 80mm auto; margin: 4mm; }
  body { background: #fff; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; font-family: "Courier New", monospace; font-size: 11px; color: #000; width: 72mm; }
  .rc-center { text-align: center; }
  .rc-title { font-size: 14px; font-weight: 700; }
  .rc-sep { border-top: 1px dashed #000; margin: 6px 0; }
  .rc-row { display: flex; justify-content: space-between; gap: 6px; }
  .rc-bold { font-weight: 700; }
  .rc-item { margin-bottom: 3px; }
}
.fund-edit { margin-left: 6px; padding: 2px 8px; font-size: 12px; }
.adjust-row td { color: var(--muted); font-style: italic; }
