/* Natura POS demo — tonos cálidos de cafetería */
:root {
  --bg: #f3e8de;
  --bg-elev: #fff8f0;
  --bg-soft: #ece1d3;
  --ink: #4a2a14;
  --muted: #6b5e52;
  --line: #e6d8c6;
  --green: #7d8560;
  --green-d: #4a5340;
  --green-l: #e8eadf;
  --clay: #c26a3e;
  --gold: #d4a15a;
  --danger: #b33a3a;
  --ok: #5c6b45;
  --warn: #c47b16;
  --brown: #4a2a14;
  --shadow: 0 12px 40px rgba(74, 42, 20, 0.08);
  --radius: 16px;
  --header: 64px;
  --banner: 34px;
  --cart: 360px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body {
  font-family: "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  line-height: 1.4;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
a { color: var(--green); }

.boot { padding: 48px; text-align: center; color: var(--muted); }

/* Login */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 10% -10%, #e7d3b8 0%, transparent 50%),
    radial-gradient(900px 400px at 110% 10%, #d9e4d4 0%, transparent 46%),
    var(--bg);
}
.login-card {
  width: min(420px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 32px 28px 28px;
}
.login-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-card .brand { justify-content: center; }
.login-card .brand img { width: min(240px, 72%); height: auto; }
.login-card h1 { font-size: 1.15rem; margin: 8px 0 4px; font-weight: 650; }
.login-card p.lead { color: var(--muted); margin: 0 0 20px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field span { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(125, 133, 96, 0.22);
}
.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 650;
  background: var(--green);
  color: #fff;
  min-height: 44px;
}
.btn:hover { background: var(--green-d); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.secondary { background: var(--bg-soft); color: var(--ink); }
.btn.secondary:hover { background: var(--line); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.clay { background: var(--clay); color: #fff; }
.btn.block { width: 100%; }
.btn.small { padding: 8px 12px; min-height: 36px; font-size: 0.9rem; }
.error { color: var(--danger); font-size: 0.9rem; margin: 0 0 12px; }
.hint { color: var(--muted); font-size: 0.82rem; }

/* Chrome */
.app-shell { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  height: var(--header);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: #3f3628;
  color: #f6efe6;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar .logo {
  height: 52px; width: auto; filter: none;
  background: #f3e8de; border-radius: 10px; padding: 3px 8px;
}
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.topbar nav a {
  color: #f6efe6;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.92rem;
}
.topbar nav a.active, .topbar nav a:hover { background: rgba(255,255,255,0.12); }
.topbar .who { font-size: 0.82rem; opacity: 0.9; text-align: right; }
.banner-demo {
  height: var(--banner);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #efe1c4;
  color: #6a4b16;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-bottom: 1px solid #e0cc9e;
}

/* POS */
.pos {
  display: grid;
  grid-template-columns: 1fr var(--cart);
  min-height: calc(100dvh - var(--header) - var(--banner));
}
.pos-main { padding: 16px 18px 40px; min-width: 0; }
.search-wrap { position: relative; }
.search-wrap input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 16px;
  padding: 16px 18px 16px 46px;
  font-size: 1.15rem;
  outline: none;
  box-shadow: var(--shadow);
}
.search-wrap input:focus { border-color: var(--green); }
.search-wrap .ico {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none; font-size: 1.1rem;
}
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); max-height: 340px; overflow: auto; z-index: 20;
}
.suggest button {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 0; background: transparent; text-align: left;
}
.suggest button:hover, .suggest button.active { background: var(--green-l); }
.suggest img { width: 44px; height: 44px; border-radius: 10px; }
.suggest .meta { flex: 1; min-width: 0; }
.suggest .meta b { display: block; }
.suggest .meta small { color: var(--muted); }
.suggest .price { font-weight: 700; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.chip {
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-left: 6px solid var(--gold);
  min-height: 44px;
}
.chip.active { background: #fff; box-shadow: var(--shadow); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
}
.pcard {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  text-align: left;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 168px;
  transition: transform .12s ease, box-shadow .12s ease;
}
.pcard:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.pcard img { width: 100%; height: 92px; object-fit: cover; background: #f6eee4; }
.pcard .body { padding: 10px 12px 12px; }
.pcard .name { font-weight: 700; font-size: 0.95rem; }
.pcard .price { color: var(--green-d); font-weight: 750; margin-top: 4px; }
.pcard .stock { color: var(--muted); font-size: 0.75rem; }

.cart {
  background: var(--bg-elev);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: calc(var(--header) + var(--banner));
  height: calc(100dvh - var(--header) - var(--banner));
}
.cart h2 { margin: 0; padding: 16px 16px 8px; font-size: 1.05rem; }
.cart-items { flex: 1; overflow: auto; padding: 0 12px 12px; }
.cart-empty { color: var(--muted); padding: 24px 8px; text-align: center; }
.cline {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}
.cline .nm { font-weight: 650; }
.qty {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 6px;
}
.qty button {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; font-weight: 800;
}
.cart-totals { padding: 12px 16px 16px; border-top: 1px solid var(--line); background: #fffaf3; }
.row { display: flex; justify-content: space-between; margin: 4px 0; color: var(--muted); }
.row.total { color: var(--ink); font-size: 1.25rem; font-weight: 800; margin-top: 8px; }
.cart-totals .btn { margin-top: 10px; }

/* Pages */
.page { padding: 20px 22px 48px; }
.page h1 { margin: 0 0 6px; font-size: 1.4rem; }
.toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  margin: 16px 0; padding: 12px 14px;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
}
.toolbar .field { margin: 0; min-width: 150px; }
.toolbar .field.grow { flex: 1 1 260px; min-width: 200px; }
.toolbar .field input, .toolbar .field select { height: 44px; padding: 0 14px; width: 100%; }
.toolbar .field input[type="color"] { padding: 4px; width: 64px; }
.toolbar .btn { height: 44px; min-height: 44px; padding: 0 18px; white-space: nowrap; }
.toolbar .push-right { margin-left: auto; }
.field select {
  appearance: none; -webkit-appearance: none;
  min-width: 150px; height: 44px; padding: 0 40px 0 14px;
  font-size: 0.95rem; color: var(--ink); cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%234a2a14' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.chips.bar { align-items: center; margin: 12px 0 4px; }
@media (max-width: 720px) {
  .toolbar { gap: 10px; }
  .toolbar .field, .toolbar .field.grow { flex: 1 1 100%; }
  .toolbar .btn, .toolbar .push-right { flex: 1 1 100%; margin-left: 0; }
}
.table-wrap { overflow: auto; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); background: #f7f0e6; }
tr:hover td { background: #fffdf8; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.badge.ok { background: #e1f3e7; color: var(--ok); }
.badge.warn { background: #fff0d6; color: var(--warn); }
.badge.bad { background: #fde4e4; color: var(--danger); }
.badge.demo { background: #efe1c4; color: #6a4b16; }
.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }

/* Modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(44,36,28,0.45);
  display: grid; place-items: center; padding: 16px; z-index: 50;
}
.modal {
  width: min(560px, 100%);
  background: var(--bg-elev);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow);
  max-height: 92dvh;
  overflow: auto;
}
.modal.wide { width: min(820px, 100%); }
.modal h3 { margin: 0 0 12px; }
.pay-medios { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.pay-line { display: grid; grid-template-columns: 1.2fr 1fr 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.pay-line input { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; }

/* Ticket */
.ticket-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
#ticket-print {
  width: 80mm;
  margin: 0 auto;
  background: #fff;
  color: #111;
  padding: 8px 10px 16px;
  font-family: "Courier New", ui-monospace, monospace;
  font-size: 12px;
}
#ticket-print .center { text-align: center; }
#ticket-print .logo-word { font-family: Georgia, serif; font-size: 22px; font-weight: 700; }
#ticket-print hr { border: 0; border-top: 1px dashed #333; margin: 8px 0; }
#ticket-print .trow { display: flex; justify-content: space-between; gap: 8px; }
#ticket-print .big { font-size: 16px; font-weight: 800; }

#ticket-print .ticket-logo {
  width: 42mm; height: auto; margin: 0 auto 6px;
  filter: none;
}
#ticket-print .logo-word { font-size: 13px; letter-spacing: 0.04em; }

#corte-print {
  background: #fff;
  color: #111;
  padding: 16px 18px 20px;
  border: 1px dashed var(--line);
  border-radius: 12px;
}
#corte-print h2 { margin: 0 0 4px; font-size: 1.15rem; }
#corte-print .corte-logo { width: 88px; height: auto; margin: 0 auto 8px; }
#corte-print table { font-size: 0.9rem; }
#corte-print .dif-ok { color: var(--ok); font-weight: 700; }
#corte-print .dif-bad { color: var(--danger); font-weight: 700; }

@media print {
  html, body { background: #fff !important; }
  body * { visibility: hidden; }
  body.print-ticket #ticket-print,
  body.print-ticket #ticket-print * { visibility: visible; }
  body.print-corte #corte-print,
  body.print-corte #corte-print * { visibility: visible; }
  body.print-ticket #ticket-print,
  body.print-corte #corte-print {
    position: absolute; left: 0; top: 0;
    box-shadow: none; margin: 0; border: 0;
    background: #fff;
  }
  body.print-ticket #ticket-print { width: 80mm; }
  body.print-corte #corte-print { width: 100%; max-width: 190mm; }
}

/* Alerts / reports */
.alert-list { display: grid; gap: 8px; margin: 12px 0 20px; }
.alert-item {
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff;
}
.alert-item.vencido { border-color: #f0b4b4; background: #fff5f5; }
.alert-item.por_vencer { border-color: #f0d39a; background: #fff8ea; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.perm { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.muted { color: var(--muted); }

#toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 80;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--green-d); color: #fff; padding: 10px 14px;
  border-radius: 10px; box-shadow: var(--shadow); max-width: 320px;
}
.toast.err { background: var(--danger); }

@media (max-width: 980px) {
  .pos { grid-template-columns: 1fr; }
  .cart {
    position: relative; top: auto; height: auto;
    border-left: 0; border-top: 1px solid var(--line);
  }
  .cols-2 { grid-template-columns: 1fr; }
  .pay-line { grid-template-columns: 1fr 1fr; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; }
  .topbar nav { order: 3; width: 100%; }
}

/* Reportes, corte, historial, configuración */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin: 12px 0 18px; }
.kpi {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px;
}
.kpi .lbl { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; }
.kpi .num { font-size: 1.25rem; font-weight: 800; margin-top: 4px; color: var(--brown); }
.chart-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 8px 8px 0; }
.chart { width: 100%; height: auto; min-height: 260px; display: block; }
.reporte-vacio { color: var(--muted); padding: 28px 8px; text-align: center; }
.hist-row.anulado td { opacity: 0.65; text-decoration: line-through; text-decoration-thickness: 1px; }
.hist-row.anulado td:last-child { text-decoration: none; opacity: 1; }
.cfg-card {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px 18px; margin: 0 0 16px;
}
.cfg-card h2 { margin: 0 0 10px; font-size: 1.05rem; }
.cfg-row {
  display: grid; grid-template-columns: 28px 1.4fr 90px 88px 70px auto;
  gap: 8px; align-items: center; margin-bottom: 8px;
}
.cfg-row input[type="text"], .cfg-row input[type="number"], .cfg-row input[type="color"] {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; width: 100%;
}
.cfg-row input[type="color"] { padding: 4px; height: 40px; }
.corte-table input[type="number"] {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; width: 140px;
}
.dif-ok { color: var(--ok); font-weight: 700; }
.dif-bad { color: var(--danger); font-weight: 700; }
.banner-anulado {
  background: #fde4e4; color: var(--danger); font-weight: 800;
  text-align: center; padding: 6px; border-radius: 8px; margin-bottom: 8px;
}
@media (max-width: 720px) {
  .cfg-row { grid-template-columns: 1fr 1fr; }
}

.pager {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 12px; flex-wrap: wrap;
  margin: 10px 0 14px; color: var(--muted); font-size: 0.9rem;
}
.pager .btn { height: 36px; min-height: 36px; }
.sin-costo { color: var(--muted); font-style: italic; font-size: 0.85rem; }
.lote-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; justify-content: flex-end; }

/* Configuración: acordeón */
.accordion { display: grid; gap: 10px; margin-top: 14px; }
.acc { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.acc.open { box-shadow: var(--shadow); }
.acc-head {
  width: 100%; display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; border: 0; background: transparent; text-align: left; cursor: pointer; min-height: 64px;
}
.acc-head:hover { background: rgba(125, 133, 96, 0.08); }
.acc-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.acc-txt b { font-size: 1rem; color: var(--ink); }
.acc-txt small { color: var(--muted); font-size: 0.86rem; }
.acc-meta { color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
.acc-caret { font-size: 1.1rem; color: var(--muted); width: 18px; text-align: center; }
.acc-body { padding: 4px 18px 18px; border-top: 1px solid var(--line); }
.cfg-flags { display: flex; gap: 22px; flex-wrap: wrap; margin: 14px 0 6px; }
.cfg-hint { font-size: 0.82rem; margin: 6px 0 8px; }
.cfg-form { display: grid; gap: 10px; max-width: 520px; margin-top: 12px; }
.cat-list { display: grid; gap: 6px; margin: 8px 0 4px; }
.cat-row {
  display: flex; align-items: center; gap: 12px;
  height: 48px; padding: 0 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.cat-row.off { opacity: 0.6; }
.cat-row.simple { justify-content: space-between; }
.cat-arrows { display: inline-flex; gap: 4px; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg-elev); cursor: pointer; font-weight: 700; line-height: 1;
}
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.cat-row .cat-nombre {
  width: 240px; max-width: 45vw; height: 34px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 0.95rem;
}
.cat-row .cat-nombre:focus { border-color: var(--green); outline: none; }
.swatch { position: relative; width: 30px; height: 30px; flex: none; cursor: pointer; }
.swatch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.swatch span { display: block; width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.9rem; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span {
  position: relative; width: 40px; height: 22px; border-radius: 22px; background: #cfc8bd; transition: background .15s; flex: none;
}
.switch span::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--green-d); outline-offset: 2px; }
.cat-row .switch { margin-left: auto; }
@media (max-width: 720px) {
  .cat-row { gap: 8px; }
  .cat-row .cat-nombre { width: auto; flex: 1; min-width: 0; }
  .acc-meta { display: none; }
}

/* Recepción y alertas: acciones por lote */
.alert-item .lote-actions { grid-column: 1 / -1; margin-top: 2px; }
.alert-side { text-align: right; }

/* Mermas */
.aviso {
  background: #fff8ea; border: 1px solid #f0d39a; color: #7a5310;
  padding: 10px 14px; border-radius: 12px; margin: 12px 0;
}
.merma-form .search-wrap { position: relative; }
.merma-form .search-wrap input { height: 44px; padding-left: 40px; }
.merma-form .search-wrap .ico { left: 14px; }
.merma-form .suggest { z-index: 30; }
.merma-form .field select[name="lote"] { min-width: 230px; }
.merma-sel { margin-top: -6px; }
table tfoot th { text-align: left; border-top: 2px solid var(--line); padding-top: 10px; }
