/* Diseño estándar "Buffalo Analytics" (bóveda: Reseñas - Diseño del login), el mismo del Radar de reseñas.
   Abre en oscuro (data-theme="dark" en <html>); el botón ☼/☾ cambia a claro mientras la página está abierta. */
:root {            /* claro */
  --bg: #f4f3f0;
  --surface: #fff;
  --ink: #1f1f21;
  --ink-2: #696862;
  --line: #e1dfd9;
  --gold: #e4b92e;
  --gold-ink: #9a750a;
  --gold-soft: #f8efcf;
  --muted-bar: #c9c6bf;
  --ok: #2e9a5c;
  --bad: #d64545;
  --bad-soft: #fbe8e8;
  --shadow: 0 14px 36px rgba(30, 28, 22, .08);
  --f-display: Inter, Aptos, "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
  --f-body: Inter, Aptos, "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
  --f-mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, monospace;
  --r: 10px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #101011; --surface: #202022; --ink: #f5f1e8; --ink-2: #aaa7a0; --line: #323235;
  --gold: #e4b92e; --gold-ink: #e4b92e; --gold-soft: #2c2713; --muted-bar: #414146;
  --ok: #45c77a; --bad: #f06464; --bad-soft: #3a1b1b; --shadow: 0 6px 24px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(circle at 78% -18%, rgba(228,185,46,.07), transparent 32rem), var(--bg); background-attachment: fixed; color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.5; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
button, select, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
.wrap { max-width: 1180px; margin-inline: auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* Barra superior */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding-block: 12px; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand-logo { width: 40px; height: 40px; border-radius: 50%; object-fit: contain; mix-blend-mode: multiply; }
:root[data-theme="dark"] .brand-logo, :root[data-theme="dark"] .login-logo { mix-blend-mode: screen; }  /* logo negro con letras blancas */
.theme-toggle { min-width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); cursor: pointer; }
.brand-name { font-family: var(--f-display); font-weight: 700; font-size: 15px; letter-spacing: -.01em; line-height: 1.1; }
.brand-sub { font-size: 12px; color: var(--ink-2); }
.who { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.who label { font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.who select { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 6px 10px; max-width: 260px; }
.user-chip { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
.link { border: 0; background: none; padding: 0; font-size: 13px; color: var(--ink-2); text-decoration: underline; cursor: pointer; }
.tabs .wrap { display: flex; gap: 4px; padding-block: 0; }
.tab { border: 0; background: none; padding: 10px 14px; border-bottom: 3px solid transparent; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--gold); }

main { padding-block: 24px 48px; }
.view { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr); }
.view > * { min-width: 0; } /* el carril con scroll horizontal no debe ensanchar la columna */
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-ink); }
.scope { margin: 4px 0 0; color: var(--ink-2); }

/* Carril de campañas */
.rail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.rail { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; }
.camp { flex: 0 0 auto; min-width: 190px; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 12px 14px; cursor: pointer; scroll-snap-align: start; display: grid; gap: 4px; }
.camp:hover { border-color: var(--ink-2); }
.camp[aria-pressed="true"] { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); background: var(--gold-soft); }
.camp-name { font-weight: 600; line-height: 1.25; }
.camp-dates { font-family: var(--f-mono); font-size: 12px; color: var(--ink-2); }
.pill { justify-self: start; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); }
.pill.live { color: var(--ok); border-color: currentColor; }

/* Encabezado del detalle */
.detail-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 16px; }
.detail-head h1 { font-family: var(--f-display); font-weight: 700; font-size: clamp(26px, 4vw, 36px); line-height: 1.1; letter-spacing: -.02em; margin: 4px 0 6px; text-wrap: balance; }
.detail-meta { color: var(--ink-2); font-size: 14px; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.detail-meta b { color: var(--ink); font-weight: 600; }
.field { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }
.field select { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 12px; min-width: 220px; max-width: 100%; font-size: 15px; color: var(--ink); }
.takeaway { font-size: 17px; max-width: 70ch; margin: 0; }
.takeaway b { font-weight: 600; }

/* Tarjetas de indicadores */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: grid; gap: 4px; align-content: start; }
.tile .k { font-size: 13px; color: var(--ink-2); }
.tile .v { font-family: var(--f-display); font-weight: 700; font-size: 34px; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.bench { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.bench-track { flex: 1; height: 6px; border-radius: 3px; background: var(--line); position: relative; }
.bench-me { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--gold); }
.bench-red { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); }
.bench-lbl { font-family: var(--f-mono); font-size: 11px; color: var(--ink-2); white-space: nowrap; }
.up { color: var(--ok); }
.down { color: var(--bad); }

/* Tarjetas y gráficos */
.grid2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; min-width: 0; }
.card h2 { font-family: var(--f-display); font-weight: 700; font-size: 18px; margin: 0; letter-spacing: -.01em; }
.card .note { font-size: 13px; color: var(--ink-2); margin: 2px 0 12px; }
.chart { position: relative; min-height: 220px; }
.chart svg { display: block; width: 100%; height: auto; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.sw-antes { background: var(--muted-bar); }
.sw-camp { background: var(--gold); }
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 6px 10px; font-size: 12px; white-space: nowrap; z-index: 3; font-variant-numeric: tabular-nums; }
.tip .d { color: var(--ink-2); }

/* Tabla por local */
.tablewrap { overflow: auto; max-height: 420px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
th { position: sticky; top: 0; background: var(--surface); text-align: right; font-weight: 600; font-size: 12px; color: var(--ink-2); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--bg); }
tr.sel td { background: var(--gold-soft); }
tr.total td { font-weight: 600; }
@media (max-width: 560px) { .hide-n { display: none; } .tile .v { font-size: 28px; } }

details.method summary { cursor: pointer; font-weight: 600; }
details.method ul { margin: 10px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 14px; display: grid; gap: 6px; }

.skel { background: linear-gradient(90deg, var(--line), var(--bg), var(--line)); background-size: 200% 100%; border-radius: 6px; color: transparent !important; }
@media (prefers-reduced-motion: no-preference) { .skel { animation: sh 1.4s linear infinite; } @keyframes sh { to { background-position: -200% 0; } } }

.state { padding: 28px; text-align: center; color: var(--ink-2); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r); }
.state b { color: var(--ink); display: block; font-size: 16px; margin-bottom: 4px; }

/* Chat */
.chat { display: grid; grid-template-rows: 1fr auto; gap: 12px; min-height: 60vh; }
.chat-log { display: grid; gap: 14px; align-content: start; }
.msg { max-width: min(760px, 100%); padding: 12px 16px; border-radius: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.msg.me { justify-self: end; background: var(--ink); color: var(--bg); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.bot { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.bot p { margin: 0 0 8px; } .msg.bot p:last-child { margin: 0; }
.msg.bot ul { margin: 4px 0 8px; padding-left: 18px; }
.msg .status { display: block; font-size: 12px; color: var(--ink-2); font-family: var(--f-mono); }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; }
.suggest button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; text-align: left; }
.suggest button:hover { border-color: var(--gold); }
.composer { position: sticky; bottom: max(12px, env(safe-area-inset-bottom, 0px)); display: flex; gap: 8px; align-items: end; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px; box-shadow: var(--shadow); }
.composer textarea { flex: 1; min-width: 0; border: 0; background: none; resize: none; min-height: 44px; max-height: 160px; padding: 8px; outline: none; }
.btn { border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 600; cursor: pointer; background: var(--gold); color: #171718; }
.btn.ghost { background: none; border: 1px solid var(--line); color: var(--ink); }
.btn:disabled { opacity: .5; cursor: default; }
.chat-intro { display: grid; gap: 10px; }
.chat-intro h1 { font-family: var(--f-display); font-weight: 700; font-size: 28px; margin: 0; letter-spacing: -.02em; }
.chat-intro p { margin: 0; color: var(--ink-2); max-width: 65ch; }

/* Login */
.login { min-height: 70vh; display: grid; place-items: center; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--gold); border-radius: 10px;
  padding: 32px 28px 26px; box-shadow: var(--shadow); }
.login-logo { width: 64px; height: 64px; border-radius: 50%; mix-blend-mode: multiply; margin-bottom: 6px; }
.login h1 { font-family: var(--f-display); font-weight: 700; font-size: 1.4rem; line-height: 1.2; letter-spacing: -.025em; margin: 0 0 2px; text-wrap: balance; }
.login p { margin: 0; color: var(--ink-2); }
.login .muted { margin: 0 0 14px; font-size: 13px; }
.g-boton { min-height: 44px; }  /* reserva el alto del botón de Google para que no salte */
.login .err { margin-top: 10px; font-size: 12.5px; }
.err { color: var(--bad) !important; }

/* PedidosYa: alerta de conectividad */
.tab-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; vertical-align: 1px; }
.alerta { display: flex; gap: 14px; align-items: start; background: var(--bad-soft); border: 1px solid var(--bad); border-radius: var(--r); padding: 16px 18px; }
.alerta-ico { flex: 0 0 28px; height: 28px; border-radius: 50%; background: var(--bad); color: #fff; display: grid; place-items: center; font-weight: 800; }
.alerta h2 { font-family: var(--f-display); font-weight: 700; font-size: 18px; margin: 0 0 4px; letter-spacing: -.01em; }
.alerta p { margin: 0 0 8px; color: var(--ink-2); font-size: 14px; max-width: 75ch; }
.alerta ul { margin: 0; padding-left: 18px; display: grid; gap: 2px; font-variant-numeric: tabular-nums; font-size: 14px; columns: 2 240px; }
.link-local { border: 0; background: none; padding: 0; font: inherit; color: var(--ink); text-decoration: underline; text-decoration-color: var(--line); cursor: pointer; }
.tile-alerta { border-color: var(--bad); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); margin-right: 6px; vertical-align: 1px; }
.nota-int { display: block; font-size: 12px; color: var(--ink-2); font-style: italic; }
.tile-destacada { border-color: var(--gold); background: var(--gold-soft); }
.tile-destacada .k { color: var(--gold-ink); font-weight: 600; }

/* Usuarios (administración de accesos) */
.u-total { font-family: var(--f-mono); font-size: 15px; font-weight: 500; color: var(--ink-2); letter-spacing: 0; }
.field input { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 12px; min-width: 0; font-size: 15px; color: var(--ink); }
.u-form { display: grid; gap: 10px 12px; grid-template-columns: minmax(200px, 1.4fr) minmax(130px, .6fr) minmax(200px, 1.6fr) minmax(160px, 1fr) auto; align-items: end; }
.u-form .field select { min-width: 0; width: 100%; }
.u-msg { grid-column: 1 / -1; margin: 0; min-height: 1.2em; font-size: 13px; color: var(--ok); }
.u-msg.err { color: var(--bad); }
.u-tabla { max-height: none; padding: 0; }
.u-tabla td, .u-tabla th { text-align: left; }
.u-tabla tbody tr { cursor: default; }
.u-tabla td.nota { color: var(--ink-2); font-size: 13px; }
.u-tabla td.acc { text-align: right; white-space: nowrap; }
.btn-quitar { border: 1px solid var(--bad); color: var(--bad); background: none; border-radius: 8px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.btn-quitar:disabled { opacity: .5; cursor: default; }
.u-ro { font-size: 12px; color: var(--ink-2); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 860px) { .u-form { grid-template-columns: 1fr 1fr; } .u-form .btn { grid-column: 1 / -1; } }
@media (max-width: 520px) { .u-form { grid-template-columns: 1fr; } }
