:root {
  --fg: #0a0a0a;
  --muted: #525252;
  --border: #e5e5e5;
  --bg: #fff;
  --surface: #fafafa;
  --danger: #b91c1c;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; }
.wrap { max-width: 72rem; margin: 0 auto; padding: 16px; }
.label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.35rem;
}
.muted { color: var(--muted); }
.btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  font-family: inherit;
}
.btn-primary { background: var(--fg); color: #fff; border-color: var(--fg); }
.btn-outline { background: var(--bg); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-block { width: 100%; }
input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
  background: var(--bg);
}
label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 0.75rem;
}
label input, label select { margin-top: 4px; }
.card-form {
  border: 1px solid var(--border);
  padding: 1rem;
  background: var(--surface);
}
.alert {
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background: var(--surface);
}
.alert--err { border-color: #fecaca; color: var(--danger); }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.topbar strong { letter-spacing: -0.02em; }
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin: 16px 0;
}
.stat {
  background: var(--bg);
  padding: 14px 16px;
}
.stat .n {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.table th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.table-foot td {
  border-top: 1px solid var(--border);
  border-bottom: none;
  padding-top: 12px;
  font-weight: 700;
  font-size: 14px;
}
.table tfoot { border-top: 1px solid var(--border); }
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 2px;
}
.online-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; margin-right: 6px;
  background: #16a34a;
}
.online-dot.off { background: #a3a3a3; }

/* POS — viewport fijo; scroll solo en grid / carrito */
body.pos-page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}
body.pos-page .topbar,
body.pos-page .shift-warn { flex-shrink: 0; }
body.pos-fullscreen .topbar { display: none; }
body.pos-fullscreen .shift-warn { display: none !important; }
.pos-layout {
  /* Estado por defecto = catálogo grande (touch/búsqueda). Solo 2 posiciones. */
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(240px, 0.65fr);
  flex: 1;
  min-height: 0;
  overflow: hidden;
  transition: grid-template-columns 0.22s ease;
}
/* Escáner: carrito grande, catálogo compacto */
.pos-layout.is-scan {
  grid-template-columns: minmax(160px, 0.55fr) minmax(360px, 1.25fr);
}
@media (max-width: 800px) {
  .pos-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .pos-layout.is-scan {
    grid-template-columns: 1fr;
  }
  .pos-catalog { border-right: none; }
  .pos-cart {
    border-top: 1px solid var(--border);
    max-height: 30dvh;
    transition: max-height 0.22s ease;
  }
  .pos-layout.is-scan .pos-cart { max-height: 58dvh; }
}
.pos-catalog {
  padding: 12px 16px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.pos-catalog-head { flex-shrink: 0; }
.pos-search { margin-bottom: 12px; }
.cat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  max-height: 72px;
  overflow-y: auto;
}
.cat-chips button {
  font: inherit;
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 4px;
  cursor: pointer;
  color: var(--muted);
}
.cat-chips button.is-on {
  background: var(--fg);
  color: #fff;
  border-color: var(--fg);
}
.prod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  align-content: start;
  -webkit-overflow-scrolling: touch;
}
.prod-card {
  background: var(--bg);
  padding: 12px;
  cursor: pointer;
  border: none;
  text-align: left;
  font: inherit;
}
.prod-card:active { background: var(--surface); }
.prod-card .price { font-weight: 700; margin-top: 4px; }
.pos-cart {
  padding: 12px 16px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.cart-lines { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; }
.cart-totals {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 4px;
}
.cart-tot-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 2px;
}
.pos-keys {
  font-size: 11px;
  margin: 0 0 10px;
  line-height: 1.35;
}
.ticket-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 10px;
  flex-shrink: 0;
}
.ticket-tab {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 4px;
  cursor: pointer;
  color: var(--muted);
  max-width: 100%;
}
.ticket-tab.is-on {
  background: var(--fg);
  color: #fff;
  border-color: var(--fg);
}
.ticket-tab--new {
  min-width: 32px;
  font-weight: 700;
  color: var(--fg);
}
.cart-line {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "name total"
    "meta total"
    "qty  total";
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.cart-line__name {
  grid-area: name;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cart-line__meta {
  grid-area: meta;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.cart-line .qty-btns {
  grid-area: qty;
}
.cart-line__qty {
  min-width: 2.25rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.cart-line__total {
  grid-area: total;
  font-weight: 700;
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
  min-width: 4.75rem;
}
.cart-total {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 12px 0;
  font-variant-numeric: tabular-nums;
}

/* Modo escáner: catálogo denso + ticket en columnas alineadas */
.pos-layout.is-scan .pos-keys { display: none; }
.pos-layout.is-scan .prod-grid {
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
}
.pos-layout.is-scan .prod-card {
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.25;
}
.pos-layout.is-scan .prod-card .price {
  margin-top: 2px;
  font-size: 12px;
}
.pos-layout.is-scan .prod-card .muted {
  display: none;
}
.pos-layout.is-scan .cart-line {
  grid-template-columns: minmax(0, 1fr) 4.75rem 6.5rem 5rem;
  grid-template-areas: "name meta qty total";
  padding: 5px 0;
  column-gap: 8px;
  row-gap: 0;
}
.pos-layout.is-scan .cart-line__meta {
  text-align: right;
  font-size: 12px;
  color: var(--muted);
}
.pos-layout.is-scan .qty-btns {
  justify-content: flex-end;
}
.pos-layout.is-scan .qty-btns button {
  width: 24px;
  height: 24px;
  font-size: 12px;
}
.pos-layout.is-scan .cart-total {
  font-size: 1.25rem;
  margin: 8px 0;
}
.pos-layout.is-scan .pay-btn {
  min-height: 42px;
  padding: 8px;
  font-size: 13px;
}
.pay-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.pay-btn {
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  min-height: 52px;
  padding: 12px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pay-btn:active:not(:disabled) { background: var(--surface); }
.pay-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.pay-btn--primary {
  grid-column: 1 / -1;
  min-height: 64px;
  font-size: 17px;
  background: var(--fg);
  color: #fff;
  border-color: var(--fg);
}
.pay-btn--primary:active:not(:disabled) { opacity: 0.9; background: var(--fg); }
.cash-dlg { max-width: 360px; }
.cash-due {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 16px;
}
.cash-change {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}
.cash-change.is-short { color: var(--danger); }
.cash-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.cash-chips button {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  cursor: pointer;
}
.cash-chips button:active { background: var(--surface); }
.inv-hits {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-top: 8px;
  max-height: 240px;
  overflow-y: auto;
}
.inv-hits:empty { display: none; }
@media (max-width: 640px) {
  .nav-links {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    padding-bottom: 2px;
  }
  .nav-links a { white-space: nowrap; }
}
.dlg-scroll {
  max-height: min(85dvh, 640px);
  overflow-y: auto;
}
.inv-hit {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  background: var(--bg);
  font: inherit;
  cursor: pointer;
}
.inv-hit:active { background: var(--surface); }
.shift-warn {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  font-size: 13px;
}
.shift-warn a { font-weight: 600; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--fg);
  color: #fff;
  padding: 12px 18px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  z-index: 50;
  max-width: calc(100% - 32px);
  cursor: default;
  box-shadow: none;
}
.toast--err {
  background: #fff;
  color: var(--danger);
  border: 1px solid #fecaca;
}
.toast[hidden] { display: none !important; }
.week-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 88px;
  margin: 8px 0 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.week-bar {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  position: relative;
}
.week-bar-fill {
  width: 100%;
  background: var(--fg);
  border-radius: 2px 2px 0 0;
  min-height: 4px;
}
.week-bar span {
  font-size: 10px;
  color: var(--muted);
  position: absolute;
  bottom: -16px;
}
.nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  justify-content: flex-end;
}
.nav-links a {
  font-size: 13px;
  text-decoration: none;
  color: var(--muted);
}
.nav-links a:hover,
.nav-links a.is-active { text-decoration: underline; color: var(--fg); }
.nav-links .nav-disabled {
  font-size: 13px;
  color: #c4c4c4;
  cursor: not-allowed;
  user-select: none;
}
.nav-drop.is-disabled .nav-drop__btn,
.nav-drop__btn:disabled {
  color: #c4c4c4;
  cursor: not-allowed;
}
.nav-drop.is-disabled .nav-drop__btn::after {
  opacity: 0.35;
}
.nav-drop {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.nav-drop__btn {
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.nav-drop__btn::after {
  content: ' ▾';
  font-size: 10px;
  opacity: 0.7;
}
.nav-drop.is-active .nav-drop__btn,
.nav-drop__btn[aria-expanded="true"],
.nav-drop__btn:hover {
  color: var(--fg);
  text-decoration: underline;
}
.nav-drop__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 10rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 16px rgba(0,0,0,.06);
}
.nav-drop__menu[hidden] { display: none !important; }
.nav-drop__menu a {
  display: block;
  padding: 8px 12px;
  white-space: nowrap;
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
}
.nav-drop__menu a:hover,
.nav-drop__menu a.is-active {
  background: var(--surface);
  color: var(--fg);
  text-decoration: none;
}
.page-title {
  margin: 0;
  letter-spacing: -0.02em;
  font-size: 1.5rem;
}
.row-between {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin: 16px 0;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.filters label { margin: 0; min-width: 140px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger {
  background: var(--bg);
  color: var(--danger);
  border-color: #fecaca;
}
.row-muted { opacity: 0.55; }
.check-inline {
  display: flex !important;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.check-inline input { width: auto; margin: 0; }
.dlg {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem;
  max-width: 420px;
  width: calc(100% - 32px);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.dlg::backdrop { background: rgba(0,0,0,0.35); }
.dlg.is-saving {
  pointer-events: none;
  opacity: 0.92;
}
.save-flash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(2px);
}
.save-flash[hidden] { display: none !important; }
.save-flash__card {
  border: 1px solid var(--border);
  background: var(--bg, #fff);
  padding: 20px 28px;
  border-radius: 4px;
  text-align: center;
  min-width: 200px;
  transform: translateY(8px);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
}
.save-flash.is-on .save-flash__card {
  transform: none;
  opacity: 1;
}
.save-flash__ok {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.save-flash__sub {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.dlg-body { min-width: min(100%, 280px); }
.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  min-height: 40px;
}
.dlg-head .label {
  margin: 0;
  padding: 0;
  line-height: 1.2;
}
.dlg-x {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface, #fafafa);
  color: var(--fg);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.dlg-x:hover { background: var(--fg); color: #fff; border-color: var(--fg); }
.dlg-x:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.table-wrap { overflow-x: auto; }
.qty-btns { display: flex; gap: 4px; align-items: center; }
.qty-btns button {
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}
