:root {
  /* Colores de Novera: naranja (principal), verde (acento) y negro */
  --teal: #ff5500;
  --teal-dark: #d94800;
  --teal-soft: #ffeee5;
  --orange: #00cb79;
  --orange-soft: #fef3c7;
  --on-accent: #04291a;
  --warn: #b45309;
  --black: #111111;
  --green: #00cb79;
  --red: #e5484d;
  --red-soft: #fdecec;
  --ink: #1f2933;
  --muted: #6b7680;
  --line: #e4e8eb;
  --bg: #f5f7f8;
  --card: #ffffff;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--teal-dark); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.right { text-align: right; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* botones y campos */
.btn { border: 1px solid var(--line); background: var(--card); padding: 9px 16px; border-radius: 10px; font-weight: 600; }
.btn:hover { border-color: var(--teal); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-orange { background: var(--orange); border-color: var(--orange); color: var(--on-accent); }
.btn-green { background: var(--green); border-color: var(--green); color: var(--on-accent); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 14px; }
.btn-block { width: 100%; }
label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 4px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal); border-color: transparent; }
input[type=checkbox] { width: auto; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.error { color: var(--red); font-size: 14px; min-height: 20px; margin-top: 8px; }

/* login */
.auth { min-height: 100%; display: grid; place-items: center; padding: 16px; background: var(--black); }
.auth-card { background: #fff; padding: 32px; border-radius: 18px; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.15); }
.auth-card h1 { margin: 0 0 4px; color: var(--teal-dark); }
.auth-card .btn { margin-top: 18px; padding: 12px; }

/* tarjetas y tablas */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; vertical-align: middle; }
th { background: #fafbfc; font-weight: 600; color: var(--muted); position: sticky; top: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--teal-soft); }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--teal-soft); color: var(--teal-dark); }
.badge-orange { background: var(--orange-soft); color: var(--warn); }
.badge-red { background: var(--red-soft); color: var(--red); }

/* modal y aviso */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 30, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 16px; padding: 22px; width: 100%; max-width: 480px; max-height: 92vh; overflow: auto; }
.modal.wide { max-width: 760px; }
.modal h2 { margin: 0 0 8px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px; z-index: 100; max-width: 90vw; }
.toast.err { background: var(--red); }

/* ---------- punto de venta ---------- */
.pos { display: grid; grid-template-columns: 1fr 380px; height: 100vh; }
.pos-main { display: grid; grid-template-rows: auto 1fr; min-width: 0; }
.pos-top { display: flex; gap: 10px; align-items: center; padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--line); }
.pos-top .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: #fff; white-space: nowrap; }
.pos-top .brand img { height: 34px; }
.pos-top { background: var(--black) !important; border-bottom: 3px solid var(--teal) !important; }
.pos-top .btn-ghost, .pos-top .muted { color: #fff; }
.pos-top input { border-color: #333; }
.pos-top input { flex: 1; font-size: 17px; }
.pos-body { display: grid; grid-template-columns: 150px 1fr; min-height: 0; }
.cats { overflow: auto; background: #fff; border-right: 1px solid var(--line); }
.cats button { display: block; width: 100%; padding: 13px 10px; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--teal-dark); font-weight: 600; text-align: center; }
.cats button.active { background: var(--teal); color: #fff; }
.products { overflow: auto; padding: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; align-content: start; }
.prod { background: #fff; border: 2px solid transparent; border-radius: 14px; padding: 8px; text-align: center; position: relative; }
.prod:hover { border-color: var(--teal); }
.prod .price { display: inline-block; background: var(--teal-dark); color: #fff; font-weight: 700; font-size: 13px; padding: 3px 10px; border-radius: 999px; }
.prod .img { height: 100px; display: grid; place-items: center; margin: 6px 0; }
.prod .img img { max-height: 100px; max-width: 100%; object-fit: contain; }
.prod .img .ph { width: 72px; height: 72px; border-radius: 50%; background: var(--teal-soft); color: var(--teal-dark); display: grid; place-items: center; font-size: 28px; font-weight: 800; }
.prod .stock { display: inline-block; background: var(--orange); color: var(--on-accent); font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.prod .stock.zero { background: var(--red); color: #fff; }
.prod .name { font-size: 14px; margin-top: 6px; line-height: 1.25; }

.cart { display: grid; grid-template-rows: auto 1fr auto; background: #fff; border-left: 1px solid var(--line); min-height: 0; }
.cart-head { background: var(--black); color: #fff; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; border-bottom: 5px solid var(--teal); }
.cart-head button { background: rgba(255,255,255,.2); border: 0; color: #fff; border-radius: 8px; padding: 6px 10px; font-weight: 600; }
.cart-items { overflow: auto; padding: 10px; }
.cart-empty { text-align: center; color: var(--muted); margin-top: 40px; }
.line { border: 2px solid var(--line); border-radius: 12px; padding: 8px 10px; margin-bottom: 8px; display: grid; grid-template-columns: 1fr auto auto; gap: 6px; align-items: center; cursor: pointer; }
.line.sel { background: var(--orange); border-color: var(--orange); color: var(--on-accent); }
.line .ln-name { font-weight: 600; }
.line .ln-sub { font-size: 13px; opacity: .85; }
.line .ln-total { font-weight: 700; font-size: 17px; }
.line .x { border: 0; background: none; color: inherit; font-size: 20px; padding: 0 4px; }
.cart-foot { padding: 12px 14px; border-top: 1px solid var(--line); }
.total-row { display: flex; justify-content: space-between; align-items: baseline; }
.total-row .big { font-size: 34px; font-weight: 800; }
.pad-tabs { display: flex; gap: 6px; margin: 10px 0; }
.pad-tabs button { flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px; font-size: 13px; font-weight: 600; }
.pad-tabs button.active { background: var(--orange); color: var(--on-accent); border-color: var(--orange); }
.pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pad button { height: 48px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 20px; font-weight: 600; }
.pad button:active { background: var(--teal-soft); }
.pad-display { background: var(--bg); border-radius: 10px; padding: 8px 12px; text-align: right; font-size: 20px; font-weight: 700; margin-bottom: 8px; min-height: 44px; }
.pay-btns { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; margin-top: 10px; }
.pay-btns .btn { padding: 14px; font-size: 17px; }

.methods { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.methods button { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 14px 6px; font-weight: 700; }
.methods button.active { background: var(--orange); border-color: var(--orange); color: var(--on-accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 7px 16px; font-weight: 600; }
.seg button.active { background: var(--teal); color: #fff; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.quick button { flex: 1; min-width: 70px; border: 1px solid var(--line); background: var(--teal-soft); color: var(--teal-dark); border-radius: 10px; padding: 10px; font-weight: 700; }
.change-box { background: var(--teal-soft); border-radius: 12px; padding: 12px; display: flex; justify-content: space-between; font-size: 20px; font-weight: 700; margin-top: 10px; }
.success-big { text-align: center; }
.success-big .ok { font-size: 54px; color: var(--green); }
.success-big .vuelto { font-size: 36px; font-weight: 800; }

/* ---------- administración ---------- */
.admin { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: #fff; border-right: 1px solid var(--line); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.side .brand { padding: 4px 10px 14px; }
.side .brand img { width: 100%; max-width: 180px; display: block; }
.side .brand span { display: none; }
.side a { display: block; padding: 10px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 500; }
.side a:hover { background: var(--bg); }
.side a.active { background: var(--teal-soft); color: var(--teal-dark); font-weight: 700; }
.side .go-pos { background: var(--teal); color: #fff; text-align: center; font-weight: 700; margin-bottom: 10px; }
.side .go-pos:hover { background: var(--teal-dark); }
.content { padding: 22px; min-width: 0; }
.content h1 { margin: 0 0 16px; font-size: 26px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .k-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi .k-val { font-size: 26px; font-weight: 800; margin-top: 4px; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols2 h3 { margin: 0 0 10px; font-size: 16px; }
.bar { height: 8px; background: var(--teal); border-radius: 4px; }
.menu-toggle { display: none; }

@media (max-width: 900px) {
  .pos { grid-template-columns: 1fr; grid-template-rows: 1fr auto; height: auto; min-height: 100vh; }
  .pos-body { grid-template-columns: 1fr; }
  .cats { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .cats button { white-space: nowrap; width: auto; border-bottom: 0; border-right: 1px solid var(--line); }
  .products { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); max-height: 55vh; }
  .cart { border-left: 0; border-top: 1px solid var(--line); }
  .admin { grid-template-columns: 1fr; }
  .side { position: static; height: auto; display: none; }
  .side.open { display: block; }
  .menu-toggle { display: inline-block; margin-bottom: 10px; }
  .cols2, .grid2 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}

/* ---------- ticket ---------- */
.ticket { width: 76mm; margin: 0 auto; padding: 8px; background: #fff; font-family: "Courier New", monospace; font-size: 12px; color: #000; }
.ticket h2 { text-align: center; margin: 0; font-size: 15px; }
.ticket .c { text-align: center; }
.ticket table { background: none; }
.ticket td, .ticket th { border: 0; padding: 2px 0; font-size: 12px; color: #000; background: none; }
.ticket hr { border: 0; border-top: 1px dashed #000; }
.no-print { text-align: center; margin: 14px; }
@media print {
  body { background: #fff; }
  .no-print { display: none; }
  @page { size: 80mm auto; margin: 0; }
}
.toolbar input[type=checkbox] { min-width: 0; width: auto; }
.toolbar label { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; }
label:has(> input[type=checkbox]) { display: flex; gap: 8px; align-items: center; font-weight: 500; }

/* logo en el ingreso */
.auth-logo { display: block; width: 220px; max-width: 100%; margin: 0 auto 12px; }
.auth-card h1 { text-align: center; }
.auth-card > .muted { text-align: center; }

/* precios por mayor y promociones */
.prod .tier-hint { margin-top: 4px; font-size: 11px; font-weight: 700; color: #017a49; line-height: 1.3; }
.tier-picker { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tier-picker button { flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 8px; font-size: 13px; font-weight: 600; }
.tier-picker button.active { background: var(--black); color: #fff; border-color: var(--black); }
.tier-picker button:disabled { opacity: .45; cursor: not-allowed; }
.tier-row { display: grid; grid-template-columns: 150px 1fr 76px 76px 130px auto; gap: 6px; align-items: center; margin-bottom: 8px; }
.tier-row .tier-help { font-size: 12px; grid-column: 1 / -1; margin-top: -2px; }
.tier-row [data-k=barcode].hidden { display: block !important; visibility: hidden; }

/* pago dividido */
.split-row { display: grid; grid-template-columns: 1fr 130px auto; gap: 8px; margin-bottom: 8px; }

@media (max-width: 900px) {
  .tier-row { grid-template-columns: 1fr 1fr; }
}
a.btn { text-decoration: none; color: inherit; display: inline-block; }
a.btn-primary { color: #fff; }

/* v3: tiendas, avisos, compras, lector */
.store-pick { display: block; padding: 6px 12px; font-size: 12px; color: var(--muted); }
.store-pick select { margin-top: 4px; font-weight: 600; }
.store-pick.hidden { display: none; }
.alert-banner { display: block; padding: 12px 16px; margin-bottom: 14px; border-radius: 10px; background: var(--orange-soft); color: var(--warn); text-decoration: none; border: 1px solid #f3c58a; }
.alert-banner:hover { filter: brightness(.98); }
.grid4 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.scan-box { position: relative; }
.scan-box input { font-size: 16px; padding: 12px; }
.scan-results { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 320px; overflow: auto; }
.scan-results button { display: flex; justify-content: space-between; width: 100%; border: 0; background: none; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.scan-results button:hover { background: var(--teal-soft); }
.pack-choice { display: grid; gap: 8px; }
.pack-choice button { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 16px; cursor: pointer; }
.pack-choice button:hover, .pack-choice button:focus { border-color: var(--teal); background: var(--teal-soft); outline: none; }
.pack-choice button b { font-size: 18px; }
.pos-store { font-weight: 600; padding: 6px 8px; border-radius: 8px; }
@media (max-width: 900px) {
  .grid4 { grid-template-columns: 1fr; }
}

/* v4: permisos y reinicios */
.perm-list { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
.perm-list label { margin: 4px 0; font-weight: 400; }
.danger-zone { border-color: #f5b5b5; }
.danger-zone .btn { margin-top: 8px; }
@media (max-width: 900px) { .perm-list { grid-template-columns: 1fr; } }

/* v5: ticket electrónico */
.ticket .qr svg { width: 120px; height: 120px; margin: 8px auto 4px; display: block; }

/* Punto de venta en PC: solo se deslizan los productos (y la lista del carrito); el total, el teclado y Cobrar quedan siempre a la vista */
@media (min-width: 901px) {
  .pos { height: 100vh; overflow: hidden; }
  .pos-main { grid-template-rows: auto minmax(0, 1fr); min-height: 0; }
  .pos-body { grid-template-rows: minmax(0, 1fr); }
  .cats, .products { min-height: 0; }
  .cart { grid-template-rows: auto minmax(0, 1fr) auto; height: 100vh; overflow: hidden; }
}
