/* Panel del dueño · LaPrevia — claro y simple para usar desde el celu */
:root {
  --canvas: #f2f4f5;
  --surface: #ffffff;
  --ink: #1b1840;
  --ink-2: #4a4746;
  --muted: #787574;
  --border: #e6e6e6;
  --grid: #ececec;
  --brand: #7e3fc4;
  --brand-wash: #efe6fa;
  --ok: #1a8f47;
  --ok-wash: #e3f5ea;
  --warn: #b25e00;
  --warn-wash: #fff1dc;
  --off: #6b6b6b;
  --off-wash: #efefef;
  --shadow: rgba(0, 0, 0, 0.08) 0 4px 6px -1px, rgba(0, 0, 0, 0.06) 0 2px 4px -2px;
  --r: 22px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Bricolage Grotesque", "Arial Black", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 15px/1.4 var(--font); letter-spacing: -0.01em; -webkit-font-smoothing: antialiased; }
img { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2 { margin: 0; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.muted { color: var(--muted); font-size: 13px; }

/* botones y campos */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap;
}
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-ghost { background: transparent; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.field { display: grid; gap: 6px; }
.field span { font-size: 12px; color: var(--muted); }
.field input, select, input[type="search"] {
  height: 44px; padding: 0 16px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); outline: 0;
}
.field input:focus, select:focus, input[type="search"]:focus { border-color: var(--ink); }

/* ingreso */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; background: var(--ink); }
.login-card { width: min(380px, 100%); display: grid; gap: 14px; padding: 28px 24px; border-radius: 28px; background: var(--surface); }
.login-card img { width: 180px; margin: 0 auto; }
.login-card h1 { font-family: var(--display); font-weight: 400; font-size: 34px; text-transform: uppercase; text-align: center; }
.login-card .muted { text-align: center; }
.error { color: var(--brand); font-size: 13px; }

/* barra superior y pestañas */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--ink); color: #fff;
}
.top-logo { font-size: 26px; }
.wm { display: inline-block; margin: 0; font-family: var(--display); font-weight: 800; letter-spacing: -0.045em; line-height: 1; padding: 0.1em 0.06em 0.08em; color: transparent; background: linear-gradient(95deg, #ffe08a 0%, #ffb547 28%, #f47a3a 55%, #ff6f9a 80%, #e05aa8 100%); -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0.05em 0.05em 0 #22207a); }
.wm b { font-weight: inherit; }
.wm-login { font-size: 44px; justify-self: center; }
.top-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-right: auto; }
.top-title strong { font-family: var(--display); font-weight: 400; font-size: 20px; letter-spacing: 0.01em; text-transform: uppercase; }
.top .btn { height: 36px; padding: 0 14px; color: #fff; border-color: rgba(255, 255, 255, 0.25); font-size: 13px; }
.top-actions { display: flex; gap: 6px; }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-demo { background: #ffd23f; color: var(--ink); }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #9ff0b8; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: #2ad06a; animation: pulso 1.6s infinite; }
@keyframes pulso { 50% { opacity: 0.3; } }

.tabs {
  position: sticky; top: 56px; z-index: 15; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding: 10px 16px; background: rgba(242, 244, 245, 0.92); backdrop-filter: blur(10px);
}
.tabs button {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-weight: 600; font-size: 14px;
}
.tabs button[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 11px; }

main { max-width: 1100px; margin: 0 auto; padding: 8px 16px 60px; }
section[data-tab] { display: grid; gap: 14px; }
.card { display: grid; gap: 12px; padding: 18px; border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); }
.card h2 { font-size: 17px; letter-spacing: -0.03em; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }

/* resumen: número principal y fichas */
.hero-tile { display: grid; gap: 4px; padding: 20px; border-radius: var(--r); background: var(--ink); color: #fff; }
.hero-tile .label { font-size: 13px; color: rgba(255, 255, 255, 0.7); }
.hero-num { font-size: 48px; font-weight: 600; letter-spacing: -0.04em; line-height: 1.05; }
.hero-tile .sub { font-size: 13px; color: rgba(255, 255, 255, 0.7); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { display: grid; gap: 2px; padding: 14px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.tile .label { font-size: 12px; color: var(--muted); }
.tile strong { font-size: 22px; font-weight: 600; letter-spacing: -0.03em; }
.tile .sub { font-size: 12px; color: var(--muted); }

/* gráfico de columnas */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--brand); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .bar, .chart .bar.is-hover { fill: #a90520; }
.chart .peak { fill: var(--ink); font-size: 11px; font-weight: 600; }
.table-view summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.table-view table { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { padding: 6px 4px; border-top: 1px solid var(--grid); text-align: left; }
.table-view td:last-child, .table-view th:last-child { text-align: right; }
.tooltip {
  position: fixed; z-index: 50; pointer-events: none; padding: 8px 10px; border-radius: 10px;
  background: var(--ink); color: #fff; font-size: 12px; line-height: 1.35; box-shadow: var(--shadow);
}

/* ranking: barras horizontales */
.ranking { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.ranking li { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; }
.ranking img { width: 34px; height: 34px; object-fit: contain; }
.ranking .ph { width: 34px; height: 34px; border-radius: 50%; background: var(--canvas); }
.ranking .name { font-size: 13px; font-weight: 600; }
.ranking .track { height: 10px; margin-top: 5px; border-radius: 0 4px 4px 0; }
.ranking .fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--brand); }
.ranking .val { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.empty-msg { padding: 18px; text-align: center; color: var(--muted); font-size: 14px; }

/* filtros y pedidos */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters input[type="search"] { flex: 1 1 220px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg button { height: 36px; padding: 0 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 13px; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.resumen-filtro { font-size: 13px; }
.pedidos { display: grid; gap: 10px; }
.pedido { display: grid; gap: 10px; padding: 16px; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.pedido.is-nuevo { animation: nuevo 2.4s ease-out; }
@keyframes nuevo { 0%, 30% { box-shadow: 0 0 0 3px var(--brand); } }
.pedido-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pedido-head .num { font-family: var(--display); font-size: 22px; font-weight: 400; }
.pedido-head .fecha { color: var(--muted); font-size: 13px; margin-right: auto; }
.estado { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.estado::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.estado-pendiente { background: var(--warn-wash); color: var(--warn); }
.estado-entregado { background: var(--ok-wash); color: var(--ok); }
.estado-cancelado { background: var(--off-wash); color: var(--off); }
.estado-sin_confirmar { background: transparent; color: var(--ink-2); border: 1px dashed var(--muted); }

/* pedidos que esperan el WhatsApp del cliente */
.esperando { display: grid; gap: 12px; padding: 16px; border: 2px dashed #cfcfcf; border-radius: var(--r); }
.esperando[hidden] { display: none; }
.esperando-head { display: grid; gap: 4px; }
.esperando-head h2 { display: flex; align-items: center; gap: 8px; font-size: 17px; letter-spacing: -0.03em; }
.esperando .pedido { box-shadow: none; border: 1px solid var(--border); }
.count-soft { background: var(--ink); }
.pedido-info { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--ink-2); }
.pedido-items { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 14px; }
.pedido-items li { display: flex; justify-content: space-between; gap: 10px; }
.pedido-items span:last-child { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.pedido-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 10px; border-top: 1px solid var(--grid); }
.pedido-foot .total { margin-right: auto; font-size: 18px; font-weight: 600; letter-spacing: -0.03em; }
.pedido-foot .total small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.pedido-foot .btn { height: 36px; padding: 0 14px; font-size: 13px; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }

/* precios y stock */
.prods { display: grid; gap: 8px; }
.prod {
  display: grid; grid-template-columns: 46px 1fr; gap: 10px 12px; align-items: center;
  padding: 12px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow);
}
.prod.is-off { opacity: 0.6; }
.prod-img { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 12px; background: var(--canvas); }
.prod-img img { height: 40px; width: auto; }
.prod-name { font-weight: 600; font-size: 14px; }
.prod-name small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.prod-fields { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.prod-fields .field { min-width: 0; }
.prod-fields .field input { width: 100%; min-width: 0; height: 40px; padding: 0 12px; border-radius: 12px; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
/* sin las flechitas del número: ocupaban lugar y cortaban precios como 19700 */
.prod-fields .field input::-webkit-inner-spin-button, .prod-fields .field input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.toggles { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.switch input { appearance: none; width: 40px; height: 24px; margin: 0; border-radius: 999px; background: var(--stone, #ccc); position: relative; transition: background 0.2s; cursor: pointer; }
.switch input::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: translate 0.2s; }
.switch input:checked::after { translate: 16px 0; }
.switch-agotado input:checked { background: var(--brand); }
.switch-visible input:checked { background: var(--ok); }
.guardado { margin-left: auto; font-size: 12px; color: var(--muted); }
.guardado.ok { color: var(--ok); }
.guardado.err { color: var(--brand); }

form.inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.conexion-ok { color: var(--ok); font-weight: 600; }
.conexion-demo { display: grid; gap: 8px; font-size: 14px; color: var(--ink-2); }
.conexion-demo ol { margin: 0; padding-left: 20px; display: grid; gap: 4px; }

.toast {
  position: fixed; z-index: 60; left: 50%; bottom: 18px; translate: -50% 0; width: min(420px, calc(100% - 32px));
  padding: 14px 18px; border-radius: 16px; background: var(--ink); color: #fff; font-size: 14px; box-shadow: var(--shadow);
}

@media (min-width: 760px) {
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hero-num { font-size: 60px; }
  .chart svg { height: 260px; }
}
/* productos en una sola fila solo cuando hay lugar para que los precios se lean enteros */
@media (min-width: 1040px) {
  .prod { grid-template-columns: 46px minmax(180px, 1fr) minmax(300px, 1.6fr) auto; }
  .prod-fields { grid-column: auto; grid-template-columns: repeat(3, minmax(96px, 1fr)); }
  .toggles { grid-column: auto; }
}

/* qué productos descuenta cada promo */
.prod-name .prod-usa { display: block; margin-top: 4px; color: #f0a64a; font-weight: 600; }

/* datos para transferencia */
.form-transfer { display: grid; gap: 12px; max-width: 520px; margin-top: 12px; }
.form-transfer .btn { justify-self: start; }
