/* =====================================================================
   Abundia Gestión · estilos mobile-first, claro / oscuro
   Colores tomados del logo: verde salvia + dorado sobre crema
   ===================================================================== */
:root {
  --bg: #f6f3ee; --surface: #ffffff; --surface-2: #efe9e0; --text: #23211d; --muted: #6f6a61;
  --line: #ddd5c8; --accent: #5f7d4a; --accent-ink: #ffffff; --gold: #b8893b;
  --ok: #3f7d4a; --warn: #b5482f; --warn-bg: #fbe6e0; --ok-bg: #e3efe0;
  --radius: 14px; --nav-h: 66px; --tap: 48px;
  --shadow: 0 6px 20px rgba(40, 30, 20, .12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161513; --surface: #201f1c; --surface-2: #2a2824; --text: #f1ece3; --muted: #a8a196;
    --line: #3a372f; --accent: #8fb070; --accent-ink: #13170f; --gold: #d8ad5f;
    --ok: #8fc78f; --warn: #ff9a85; --warn-bg: #3b221c; --ok-bg: #1f2f20;
    --shadow: 0 6px 20px rgba(0, 0, 0, .45); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161513; --surface: #201f1c; --surface-2: #2a2824; --text: #f1ece3; --muted: #a8a196;
  --line: #3a372f; --accent: #8fb070; --accent-ink: #13170f; --gold: #d8ad5f;
  --ok: #8fc78f; --warn: #ff9a85; --warn-bg: #3b221c; --ok-bg: #1f2f20;
  --shadow: 0 6px 20px rgba(0, 0, 0, .45); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--nav-h) + 90px + env(safe-area-inset-bottom));
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.topbar-logo { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; }
.topbar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar-title strong { font-size: 17px; }
.topbar-title span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: var(--tap); height: var(--tap); border: 0; background: transparent; border-radius: 12px; display: grid; place-items: center; color: var(--text); }
.icon-btn:active { background: var(--surface-2); }
.icon-btn.on { color: var(--accent); background: var(--surface-2); }
#bellBtn.off { opacity: .55; }
textarea { font-family: inherit; }
.topbar-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 440px) {
  .topbar { gap: 4px; }
  .topbar .icon-btn { width: 36px; }
  .topbar-title strong { font-size: 15px; }
}
/* Vista previa del cartel de la tienda */
.mq-prev { position: relative; overflow: hidden; border-radius: 4px; }
.mq-bulbs { display: block; height: 10px; background-size: 16px 10px; background-repeat: repeat-x; animation: mq-chase .55s steps(2) infinite; }
.mq-bulbs.rev { animation-direction: reverse; }
.mq-track { overflow: hidden; white-space: nowrap; padding: 5px 0 4px; }
.mq-text { display: inline-block; padding-left: 100%; animation: mq-scroll 14s linear infinite; font-weight: 800; font-size: 15px; letter-spacing: .12em; text-transform: uppercase; }
@keyframes mq-chase { from { background-position: 0 0 } to { background-position: 16px 0 } }
@keyframes mq-scroll { from { transform: translateX(0) } to { transform: translateX(-100%) } }

/* ---------- Contenido ---------- */
.view { max-width: 1100px; margin: 0 auto; padding: 12px; }
.section-title { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 18px 4px 8px; font-weight: 700; }
.hint { color: var(--muted); font-size: 14px; padding: 18px 6px; text-align: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }

.search {
  position: sticky; top: calc(62px + env(safe-area-inset-top)); z-index: 10; background: var(--bg); padding: 4px 0 10px;
}
.search input {
  width: 100%; height: 52px; padding: 0 16px 0 44px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%23888' stroke-width='2'%3E%3Ccircle cx='9' cy='9' r='7'/%3E%3Cpath d='m19 19-5-5'/%3E%3C/svg%3E") no-repeat 14px center;
  font-size: 17px; outline: none;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }

/* Chips (vendedores, medios de pago, filtros) */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chip {
  flex: none; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: 15px;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip small { opacity: .75; font-weight: 500; margin-left: 4px; }

/* Filas de producto */
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
}
.row.sel { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.row-title { font-weight: 700; font-size: 15px; line-height: 1.25; }
.row-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.row-meta { font-size: 13px; margin-top: 4px; color: var(--muted); }
.row-meta b { color: var(--text); }
.row-ctrl { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.money-input { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.money-input input {
  width: 92px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2);
  padding: 0 8px; text-align: right; font-size: 15px;
}
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.stepper button { width: 46px; height: 46px; border: 0; background: var(--surface-2); font-size: 24px; font-weight: 700; line-height: 1; }
.stepper button:active { background: var(--line); }
.stepper input { width: 46px; height: 46px; border: 0; text-align: center; background: var(--surface); font-weight: 700; font-size: 17px; }

/* Botón flotante de guardar */
.fab {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom));
  width: min(560px, calc(100% - 24px)); min-height: 56px; border: 0; border-radius: 16px;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 17px; box-shadow: var(--shadow);
}
.fab:disabled { opacity: .55; }

/* Barra de navegación inferior */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.bottomnav button {
  position: relative; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--muted); font-size: 11.5px; font-weight: 600;
}
.bottomnav svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bottomnav button.on { color: var(--accent); }
.bottomnav button.on::before { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
.badge { position: absolute; top: 6px; right: calc(50% - 22px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn); color: #fff; font-size: 11px; font-style: normal; line-height: 18px; }

/* Botones generales */
.btn { min-height: var(--tap); padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--warn); }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Estado del stock */
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.stock-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.stock-card.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.stock-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.stock-nums { display: grid; grid-template-columns: repeat(var(--cols, 5), 1fr); gap: 6px; margin-top: 10px; }
.stock-nums div { background: var(--surface-2); border-radius: 10px; padding: 6px 4px; text-align: center; }
.stock-nums small { display: block; font-size: 11px; color: var(--muted); }
.stock-nums b { font-size: 18px; }
.stock-nums .total { background: color-mix(in srgb, var(--accent) 18%, var(--surface-2)); }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 6px; margin-bottom: 10px; }
.summary .card { padding: 8px 10px; }
.summary small { color: var(--muted); font-size: 11.5px; }
.summary b { display: block; font-size: 20px; }

/* Ventas del día */
.sale-line { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.sale-line:last-child { border-bottom: 0; }

/* Login */
.login { max-width: 380px; margin: 8vh auto 0; display: flex; flex-direction: column; gap: 12px; }
.login img { width: 96px; height: 96px; border-radius: 22px; align-self: center; }
.login h1 { text-align: center; margin: 4px 0 8px; font-size: 24px; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.field input, .field select {
  width: 100%; height: 50px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 14px; font-size: 16px;
}
.error { color: var(--warn); font-size: 14px; }

/* Toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 80px + env(safe-area-inset-bottom)); z-index: 60;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 600; box-shadow: var(--shadow);
}
.toast.err { background: var(--warn); color: #fff; }

/* Modal */
dialog { border: 0; border-radius: 18px; padding: 18px; width: min(460px, calc(100% - 24px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog form { display: flex; flex-direction: column; gap: 10px; }
dialog h2 { margin: 0 0 4px; font-size: 20px; }

.demo-banner { background: var(--gold); color: #1d160a; font-size: 13px; font-weight: 700; text-align: center; padding: 6px; border-radius: 10px; margin-bottom: 10px; }
.more { margin: 12px auto; display: block; }
a { color: var(--accent); }

/* Netlify inyecta un cartel "Powered by Netlify" fijo abajo a la derecha que tapa la barra de navegación */
#nl-badge-frame { display: none !important; }

/* ---------- PC / tablet ---------- */
@media (min-width: 900px) {
  .list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .stock-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .bottomnav { left: 50%; transform: translateX(-50%); width: 640px; bottom: 12px; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); height: var(--nav-h); padding-bottom: 0; }
}
