/* ==========================================================================
   Bon Gout · MVP · estilos
   Paleta tomada del logo: negro, blanco y dorado.
   ========================================================================== */

:root {
  /* Misma paleta que la landing: pizarra profunda, papel cálido y el dorado
     del logo como único acento. */
  --ink:        #1F2E33;
  --ink-2:      #26383E;
  --ink-3:      #2F454C;
  --gold:       #C9A227;
  --gold-soft:  #E3C35B;
  --gold-dim:   rgba(201,162,39,.13);
  --bg:         #FAF6EF;
  --card:       #ffffff;
  --line:       #E4DACA;
  --line-2:     #F1EADD;
  --txt:        #22282A;
  --txt-2:      #5C6A6E;
  --txt-3:      #8A9599;
  --ok:         #2F6B46;
  --warn:       #A96B12;
  --bad:        #A33A32;
  --info:       #2F5773;
  --radius:     0;
  --fuente-ui:  'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --fuente-serif: 'Prata', Georgia, 'Times New Roman', serif;
  --shadow:     0 1px 2px rgba(31,46,51,.05), 0 8px 24px rgba(31,46,51,.06);
  --shadow-lg:  0 12px 40px rgba(31,46,51,.2);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: var(--fuente-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
a { color: inherit; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------- Logo ---------- */
.logo {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: #000;
  color: #fff;
  padding: 14px 30px 11px;
  border-radius: 4px;
  line-height: 1;
  user-select: none;
}
.logo .logo-name {
  font-family: var(--fuente-serif);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: .01em;
  display: flex;
  align-items: flex-start;
  gap: 5px;
}
.logo .logo-star { color: var(--gold-soft); font-size: 13px; line-height: 1; margin-top: 3px; }
.logo .logo-tag {
  margin-top: 7px;
  font-size: 8px;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: #cfcfcf;
  padding-left: .34em;
}
.logo.sm { padding: 8px 16px 7px; border-radius: 3px; }
.logo.sm .logo-name { font-size: 19px; gap: 3px; }
.logo.sm .logo-star { font-size: 9px; margin-top: 2px; }
.logo.sm .logo-tag { font-size: 6px; margin-top: 4px; letter-spacing: .3em; }
.logo.lg { padding: 22px 46px 18px; }
.logo.lg .logo-name { font-size: 46px; }
.logo.lg .logo-star { font-size: 19px; margin-top: 5px; }
.logo.lg .logo-tag { font-size: 10px; margin-top: 11px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  background: var(--ink);
}
.login-hero {
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  background:
    radial-gradient(900px 500px at 15% 15%, rgba(201,162,39,.13), transparent 60%),
    linear-gradient(160deg, #0b0b0d 0%, #17181b 100%);
  color: #fff;
}
.login-hero h1 { font-size: 34px; font-weight: 600; max-width: 12em; line-height: 1.2; }
.login-hero p  { color: #9ba0a6; max-width: 32em; margin: 0; }
.hero-feats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.hero-feats span {
  font-size: 12.5px; padding: 6px 12px; border-radius: 100px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.09); color: #cfd3d7;
}
.login-panel {
  background: var(--card);
  padding: 56px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-panel h2 { font-size: 21px; margin-bottom: 4px; }
.login-panel .sub { color: var(--txt-2); font-size: 13.5px; margin-bottom: 26px; }
.demo-users { margin-top: 26px; border-top: 1px solid var(--line); padding-top: 18px; }
.demo-users .t { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--txt-3); margin-bottom: 10px; }
.demo-chip {
  display: block; width: 100%; text-align: left; margin-bottom: 6px;
  padding: 9px 12px; border: 1px solid var(--line); background: #fbfbfa;
  border-radius: 9px; cursor: pointer; font-size: 13px; transition: .13s;
}
.demo-chip:hover { border-color: var(--gold); background: var(--gold-dim); }
.demo-chip b { font-weight: 600; }
.demo-chip span { color: var(--txt-3); font-family: ui-monospace, monospace; font-size: 12px; }

/* ---------- Layout app ---------- */
.topbar {
  background: var(--ink);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 20px;
  position: sticky; top: 0; z-index: 60;
}
.topbar .spacer { flex: 1; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav button {
  background: transparent; border: 0; color: #a9aeb4; cursor: pointer;
  padding: 8px 13px; border-radius: 8px; font-size: 13.5px; font-weight: 500; transition: .13s;
  white-space: nowrap;
}
.nav button:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav button.on { color: var(--ink); background: var(--gold-soft); font-weight: 600; }
.nav button .dot {
  display: inline-block; min-width: 17px; padding: 0 5px; margin-left: 6px;
  background: var(--bad); color: #fff; border-radius: 100px; font-size: 10.5px; font-weight: 700;
  vertical-align: middle;
}
.nav button.on .dot { background: var(--ink); color: var(--gold-soft); }
.who { font-size: 12.5px; color: #9ba0a6; text-align: right; line-height: 1.35; }
.who b { color: #fff; display: block; font-weight: 600; font-size: 13px; }

.page { max-width: 1280px; margin: 0 auto; padding: 24px 20px 96px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; }
.page-head p { margin: 3px 0 0; color: var(--txt-2); font-size: 13.5px; }
.page-head .spacer { flex: 1; }

/* ---------- Componentes ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 18px; }
.card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
.card-head h3 { font-size: 15px; }
.card-head .spacer { flex: 1; }
.grid { display: grid; gap: 16px; }
.muted { color: var(--txt-2); }
.tiny { font-size: 12.5px; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--card); color: var(--txt); cursor: pointer; font-size: 13.5px; font-weight: 550;
  transition: .13s; white-space: nowrap;
}
.btn:hover { border-color: #cfcec8; background: #fbfbfa; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: var(--ink-3); }
.btn.gold { background: var(--gold); color: #16130a; border-color: var(--gold); font-weight: 650; }
.btn.gold:hover { background: var(--gold-soft); }
.btn.ok   { background: var(--ok);   color: #fff; border-color: var(--ok); }
.btn.bad  { background: #fff; color: var(--bad); border-color: #f0c9c9; }
.btn.bad:hover { background: #fef4f4; }
.btn.wa   { background: #25D366; color: #06301a; border-color: #25D366; font-weight: 650; }
.btn.wa:hover { background: #3ee07a; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; }

.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--txt-2); margin-bottom: 5px; letter-spacing: .01em; }
.field .hint { font-size: 11.5px; color: var(--txt-3); margin-top: 4px; }
.input, .select, textarea.input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 9px; background: #fff; outline: none; transition: .13s;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-dim); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 150px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 100px; font-size: 11.5px; font-weight: 650;
  background: var(--line-2); color: var(--txt-2);
}
.badge .pip { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--txt-3); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line);
  background: #fafaf8; position: sticky; top: 0;
}
table.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tr.clickable { cursor: pointer; }
table.tbl tr.clickable:hover td { background: #fbfaf6; }
.num, table.tbl th.num, table.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.num { white-space: nowrap; }
.table-wrap { overflow-x: auto; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px; }
.kpi .k { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--txt-3); font-weight: 600; }
.kpi .v { font-size: 25px; font-weight: 650; margin-top: 5px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--txt-2); margin-top: 2px; }
.kpi.alert { border-color: #f3d6a8; background: #fffaf1; }
.kpi.alert .v { color: var(--warn); }

/* ---------- Catálogo ---------- */
.cat-layout { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.prods { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 13px; }
.prod {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 9px; transition: .13s;
}
.prod:hover { border-color: #d6d4cb; box-shadow: var(--shadow); }
.prod .cat-tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); font-weight: 700; }
.prod .nom { font-weight: 600; font-size: 14px; line-height: 1.3; }
.prod .meta { font-size: 11.5px; color: var(--txt-3); }
.prod .precio { font-size: 19px; font-weight: 650; letter-spacing: -.02em; }
.prod .precio small { font-size: 11.5px; font-weight: 500; color: var(--txt-3); letter-spacing: 0; }
.prod .foot { margin-top: auto; display: flex; align-items: center; gap: 8px; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.stepper button { width: 30px; height: 34px; border: 0; background: #fafaf8; cursor: pointer; font-size: 16px; color: var(--txt-2); }
.stepper button:hover { background: var(--gold-dim); color: var(--ink); }
.stepper input { width: 46px; height: 34px; border: 0; text-align: center; outline: none; font-weight: 600; font-variant-numeric: tabular-nums; }
.stock-pill { font-size: 11px; font-weight: 650; padding: 2px 8px; border-radius: 100px; }
.stock-ok   { background: #e8f6ec; color: #14733b; }
.stock-low  { background: #fdf0dc; color: #9a5b06; }
.stock-out  { background: #fbe9e9; color: #a41d1d; }

.cart { position: sticky; top: 74px; }
.cart-items { max-height: 46vh; overflow-y: auto; }
.cart-item { padding: 11px 14px; border-bottom: 1px solid var(--line-2); display: flex; gap: 10px; align-items: flex-start; }
.cart-item .n { flex: 1; font-size: 12.8px; line-height: 1.35; }
.cart-item .q { font-size: 11.5px; color: var(--txt-3); margin-top: 2px; }
.cart-item .p { font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cart-item .x { border: 0; background: none; color: var(--txt-3); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.cart-item .x:hover { color: var(--bad); }
.totals { padding: 14px; border-top: 1px solid var(--line); }
.totals .l { display: flex; justify-content: space-between; font-size: 13px; color: var(--txt-2); padding: 3px 0; }
.totals .l.big { font-size: 17px; font-weight: 650; color: var(--txt); padding-top: 9px; margin-top: 6px; border-top: 1px solid var(--line-2); }

/* ---------- Avisos ---------- */
.notice {
  padding: 11px 14px; border-radius: 10px; font-size: 13px;
  border: 1px solid var(--line); background: #fafaf8; display: flex; gap: 9px; align-items: flex-start;
}
.notice.warn { background: #fffaf0; border-color: #f2dcb4; color: #7c4f06; }
.notice.bad  { background: #fdf3f3; border-color: #f3cccc; color: #97201f; }
.notice.ok   { background: #f1faf3; border-color: #c9e8d3; color: #14653a; }
.notice.info { background: #f2f6fe; border-color: #cfdcf7; color: #1e429f; }
.notice b { font-weight: 650; }

/* ---------- Timeline vencimientos ---------- */
.tl-wrap { overflow-x: auto; padding: 6px 0 4px; }
.tl { position: relative; min-width: 780px; }
.tl-axis { position: relative; height: 26px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.tl-axis .m {
  position: absolute; top: 4px; font-size: 10.5px; color: var(--txt-3);
  border-left: 1px solid var(--line); padding-left: 5px; height: 22px; white-space: nowrap;
}
.tl-row { position: relative; height: 48px; border-bottom: 1px solid var(--line-2); }
.tl-row:hover { background: #fbfaf6; }
.tl-label {
  position: absolute; left: 0; top: 15px; font-size: 12px; width: 230px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; z-index: 2;
  background: linear-gradient(90deg, #fff 84%, transparent); padding-right: 14px;
}
.tl-track { position: absolute; left: 240px; right: 8px; top: 0; bottom: 0; }
.tl-chip {
  position: absolute; transform: translateX(-50%);
  padding: 2px 7px; border-radius: 100px; font-size: 10.5px; font-weight: 650; white-space: nowrap;
  border: 1px solid transparent; cursor: default; z-index: 2;
}
.tl-chip:hover { z-index: 5; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.tl-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); z-index: 1; opacity: .55; }
.tl-hoy-tag {
  position: absolute; top: 3px; transform: translateX(-50%);
  font-size: 9.5px; font-weight: 700; background: var(--ink); color: #fff;
  padding: 1px 6px; border-radius: 3px; z-index: 3;
}
.v-vencido { background: #fbe9e9; color: #a41d1d; border-color: #f0c9c9; }
.v-critico { background: #fdf0dc; color: #9a5b06; border-color: #f2dcb4; }
.v-pronto  { background: #fdf9e3; color: #7a6206; border-color: #ece1a6; }
.v-ok      { background: #e8f6ec; color: #14733b; border-color: #cbe8d5; }

/* ---------- Mapa ---------- */
.mapa-layout { display: grid; grid-template-columns: 330px 1fr; gap: 16px; align-items: start; }
#mapa { height: 620px; border-radius: var(--radius); border: 1px solid var(--line); z-index: 1; }
/* Sin acceso a las imágenes de OpenStreetMap: fondo de plano en vez de gris roto */
#mapa.sin-calles {
  background:
    linear-gradient(rgba(201,162,39,.07) 1px, transparent 1px) 0 0 / 100% 34px,
    linear-gradient(90deg, rgba(201,162,39,.07) 1px, transparent 1px) 0 0 / 34px 100%,
    #f2f1ed;
}
#mapa.sin-calles .leaflet-tile-pane { display: none; }
.paradas { max-height: 420px; overflow-y: auto; }
.parada {
  display: flex; gap: 10px; padding: 10px 13px; border-bottom: 1px solid var(--line-2); align-items: flex-start;
}
.parada .ord {
  width: 23px; height: 23px; border-radius: 50%; background: var(--ink); color: var(--gold-soft);
  display: flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 700; flex-shrink: 0;
}
.parada .info { flex: 1; min-width: 0; }
.parada .info b { font-size: 13px; display: block; }
.parada .info span { font-size: 11.5px; color: var(--txt-3); }

/* ---------- Escáner ---------- */
.scan-box {
  border: 2px dashed var(--gold); background: var(--gold-dim);
  border-radius: var(--radius); padding: 16px;
}
.scan-box input.input { font-size: 19px; font-family: ui-monospace, monospace; letter-spacing: .05em; text-align: center; padding: 12px; }
.scan-modes { display: flex; gap: 7px; margin-top: 10px; flex-wrap: wrap; }
#cam-video { width: 100%; max-width: 460px; border-radius: 10px; background: #000; display: block; }
.cam-frame { position: relative; }
.cam-frame::after {
  content: ''; position: absolute; left: 8%; right: 8%; top: 36%; bottom: 36%;
  border: 2px solid var(--gold-soft); border-radius: 8px; pointer-events: none;
  box-shadow: 0 0 0 2000px rgba(0,0,0,.28);
}

/* ---------- Modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(12,13,15,.55); backdrop-filter: blur(2px);
  z-index: 200; display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
}
.modal {
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 620px; overflow: hidden;
}
.modal.wide { max-width: 900px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.modal-head h3 { font-size: 16px; }
.modal-head .spacer { flex: 1; }
.modal-head .x { border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--txt-3); line-height: 1; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 9px; justify-content: flex-end; background: #fafaf8; }

/* ---------- WhatsApp flotante ---------- */
.wa-float {
  position: fixed; right: 20px; bottom: 20px; z-index: 150;
  width: 56px; height: 56px; border-radius: 50%; background: #25D366;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 22px rgba(37,211,102,.42); cursor: pointer; border: 0;
  transition: .16s; text-decoration: none;
}
.wa-float:hover { transform: scale(1.07); }
.wa-float svg { width: 30px; height: 30px; fill: #fff; }

/* ---------- Toast ---------- */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 100px;
  font-size: 13.5px; box-shadow: var(--shadow-lg); animation: pop .2s ease;
  max-width: 90vw; text-align: center;
}
.toast.bad { background: var(--bad); }
.toast.ok  { background: var(--ok); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Timeline de estados del pedido ---------- */
.steps { display: flex; gap: 0; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--txt-3); }
.step + .step::before { content: '›'; margin: 0 9px; color: var(--line); font-size: 15px; }
.step.done { color: var(--txt); font-weight: 600; }
.step .pip { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.step.done .pip { background: currentColor; }

/* ---------- Impresión (remito PDF) ---------- */
.print-only { display: none; }
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { position: absolute; left: 0; top: 0; width: 100%; padding: 0; }
  .print-only { display: block; }
  .no-print { display: none !important; }
  @page { margin: 16mm; }
}
#print-area { display: none; }
#print-area.on { display: block; }

.remito { font-size: 12px; color: #000; }
.remito h1 { font-size: 20px; margin-bottom: 2px; }
.remito table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.remito th, .remito td { border: 1px solid #999; padding: 6px 8px; text-align: left; }
.remito th { background: #eee; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .cat-layout, .mapa-layout { grid-template-columns: 1fr; }
  .cart { position: static; }
  #mapa { height: 420px; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { padding: 36px 24px; }
  .login-panel { padding: 32px 24px 56px; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .topbar .spacer { display: none; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .page { padding: 16px 12px 90px; }
  .prods { grid-template-columns: 1fr 1fr; }
  .who { flex: 1; text-align: right; }
  .tl-label { width: 130px; }
  .tl-track { left: 140px; }
}
@media (max-width: 420px) {
  .prods { grid-template-columns: 1fr; }
}
