/* Material Design 3 — tokens con los colores de sanmartinbakery.com
   (azul rey #002E94 como primario, navy #0F1938 en la barra de marca).
   Roles M3 asignados a mano y revisados por contraste. Solo modo claro. Solo CSS. */

:root {
  /* Marca (sanmartinbakery.com): navy de la barra, azul rey de títulos,
     azul grisáceo de chips, azul claro y beige de fondos */
  --brand-bar: #0F1938;
  --on-brand-bar: #FFFFFF;
  --warm-bg: #F6F2EC;            /* beige del sitio, aclarado para fondo de página */

  --md-sys-color-primary: #002E94;
  --md-sys-color-on-primary: #FFFFFF;
  --md-sys-color-primary-container: #DCE2FF;
  --md-sys-color-on-primary-container: #001C63;
  --md-sys-color-secondary: #535D84;
  --md-sys-color-on-secondary: #FFFFFF;
  --md-sys-color-secondary-container: #9BB0CC;
  --md-sys-color-on-secondary-container: #0F1938;
  --md-sys-color-tertiary: #6B5E4F;
  --md-sys-color-on-tertiary: #FFFFFF;
  --md-sys-color-tertiary-container: #EDE8E1;
  --md-sys-color-on-tertiary-container: #3A3128;
  --md-sys-color-error: #BA1A1A;
  --md-sys-color-on-error: #FFFFFF;
  --md-sys-color-error-container: #FFDAD6;
  --md-sys-color-on-error-container: #93000A;
  --md-sys-color-surface: #FFFFFF;
  --md-sys-color-on-surface: #0F1938;
  --md-sys-color-surface-variant: #E1E6F0;
  --md-sys-color-on-surface-variant: #444652;
  --md-sys-color-surface-container-lowest: #FFFFFF;
  --md-sys-color-surface-container-low: #F5F9FE;
  --md-sys-color-surface-container: #ECF5FE;
  --md-sys-color-surface-container-high: #E2ECF8;
  --md-sys-color-surface-container-highest: #D8E3F2;
  --md-sys-color-inverse-surface: #0F1938;
  --md-sys-color-inverse-on-surface: #ECF5FE;
  --md-sys-color-inverse-primary: #B6C4FF;
  --md-sys-color-outline: #747684;
  --md-sys-color-outline-variant: #C9D3E3;
  --md-sys-color-scrim: #000000;

  --md-sys-shape-xs: 4px;
  --md-sys-shape-sm: 8px;
  --md-sys-shape-md: 12px;
  --md-sys-shape-lg: 16px;
  --md-sys-shape-xl: 28px;
  --md-sys-shape-full: 999px;

  --md-elev-1: 0 1px 2px rgb(0 0 0 / .3), 0 1px 3px 1px rgb(0 0 0 / .15);
  --md-elev-2: 0 1px 2px rgb(0 0 0 / .3), 0 2px 6px 2px rgb(0 0 0 / .15);
  --md-elev-3: 0 4px 8px 3px rgb(0 0 0 / .15), 0 1px 3px rgb(0 0 0 / .3);

  --font: "Roboto Flex", Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  /* San Martin usa siempre fondo claro: sin modo oscuro */
  color-scheme: light;
}

/* --- Base -------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5rem;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
}
[x-cloak] { display: none !important; }
img { max-width: 100%; height: auto; }
a { color: var(--md-sys-color-primary); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Escala tipográfica (subconjunto) */
.display-s { font-size: 2.25rem; line-height: 2.75rem; font-weight: 400; margin: 0; }
.headline-s { font-size: 1.5rem; line-height: 2rem; font-weight: 400; margin: 0; }
.title-l { font-size: 1.375rem; line-height: 1.75rem; font-weight: 400; margin: 0; }
.title-m { font-size: 1rem; line-height: 1.5rem; font-weight: 500; margin: 0; }
.body-m { font-size: .875rem; line-height: 1.25rem; }
.label-l { font-size: .875rem; line-height: 1.25rem; font-weight: 500; letter-spacing: .006em; }
.muted { color: var(--md-sys-color-on-surface-variant); }

.material-symbols-rounded {
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  font-size: 24px; line-height: 1; vertical-align: middle; user-select: none;
}

/* --- Botones ----------------------------------------------------------- */
.btn {
  --_bg: transparent; --_fg: var(--md-sys-color-primary);
  position: relative; isolation: isolate; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 24px;
  border: 0; border-radius: var(--md-sys-shape-full);
  background: var(--_bg); color: var(--_fg);
  font: 500 .875rem/1.25rem var(--font); letter-spacing: .006em;
  text-decoration: none; cursor: pointer;
  transition: box-shadow .2s;
}
.btn::after { /* state layer */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--_fg); opacity: 0; transition: opacity .15s;
}
.btn:hover::after { opacity: .08; }
.btn:focus-visible { outline: 3px solid var(--md-sys-color-secondary); outline-offset: 2px; }
.btn:focus-visible::after, .btn:active::after { opacity: .1; }
.btn:disabled, .btn[aria-disabled="true"] {
  --_bg: color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent);
  --_fg: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);
  cursor: default; box-shadow: none; border-color: transparent;
}
.btn:disabled::after { display: none; }
.btn-filled { --_bg: var(--md-sys-color-primary); --_fg: var(--md-sys-color-on-primary); }
.btn-filled:hover:not(:disabled) { box-shadow: var(--md-elev-1); }
.btn-tonal { --_bg: var(--md-sys-color-secondary-container); --_fg: var(--md-sys-color-on-secondary-container); }
.btn-outlined { border: 1px solid var(--md-sys-color-outline); }
.btn-text { padding: 0 12px; }
.btn-danger { --_fg: var(--md-sys-color-error); }
.btn-lg { min-height: 56px; padding: 0 32px; font-size: 1rem; }
.btn-block { width: 100%; }
.icon-btn {
  --_fg: var(--md-sys-color-on-surface-variant);
  position: relative; isolation: isolate; overflow: hidden;
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: 50%; background: transparent; color: var(--_fg);
  cursor: pointer; text-decoration: none;
}
.icon-btn::after { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--_fg); opacity: 0; }
.icon-btn:hover::after { opacity: .08; }

/* --- Cards y superficies ---------------------------------------------- */
.card {
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-xl);
  padding: 24px;
}
.card-filled { background: var(--md-sys-color-surface-container-low); border-color: transparent; }
.stack { display: grid; gap: 16px; }
.stack-lg { display: grid; gap: 24px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.divider { border: 0; border-top: 1px solid var(--md-sys-color-outline-variant); margin: 0; }

/* --- Campos (outlined) ------------------------------------------------- */
.field { display: grid; gap: 4px; }
.field > label, .field-label { font: 500 .875rem/1.25rem var(--font); color: var(--md-sys-color-on-surface-variant); }
.input, .select, .textarea {
  width: 100%; min-height: 56px; padding: 16px;
  font: 400 1rem/1.5rem var(--font);
  color: var(--md-sys-color-on-surface);
  background: transparent;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-xs);
}
.textarea { min-height: 112px; resize: vertical; }
.select { appearance: none; padding-right: 48px; background:
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%23747684' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 12px center; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--md-sys-color-on-surface); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--md-sys-color-primary); box-shadow: inset 0 0 0 1px var(--md-sys-color-primary);
}
.field.has-error .input, .field.has-error .select { border-color: var(--md-sys-color-error); }
.supporting { font-size: .75rem; line-height: 1rem; color: var(--md-sys-color-on-surface-variant); }
.error-text { font-size: .75rem; line-height: 1rem; color: var(--md-sys-color-error); display: flex; gap: 4px; align-items: center; }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; min-height: 48px; }
.switch input { appearance: none; width: 52px; height: 32px; margin: 0; border-radius: 16px; position: relative; cursor: pointer;
  background: var(--md-sys-color-surface-container-highest); border: 2px solid var(--md-sys-color-outline); transition: background .2s; }
.switch input::before { content: ""; position: absolute; top: 6px; left: 6px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--md-sys-color-outline); transition: all .2s cubic-bezier(.2, 0, 0, 1); }
.switch input:checked { background: var(--md-sys-color-primary); border-color: var(--md-sys-color-primary); }
.switch input:checked::before { left: 22px; top: 2px; width: 24px; height: 24px; background: var(--md-sys-color-on-primary); }
.switch input:focus-visible { outline: 3px solid var(--md-sys-color-secondary); outline-offset: 2px; }

/* --- Opciones de respuesta -------------------------------------------- */
/* Botones segmentados: escala 1–5 y Sí/No (radios nativos, accesibles) */
.segmented { display: flex; border: 1px solid var(--md-sys-color-outline); border-radius: var(--md-sys-shape-full); overflow: hidden; }
.segmented label { flex: 1; position: relative; isolation: isolate; display: grid; place-items: center; min-height: 48px; cursor: pointer;
  font: 500 1rem/1.25rem var(--font); color: var(--md-sys-color-on-surface); }
.segmented label + label { border-left: 1px solid var(--md-sys-color-outline); }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented label::after { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--md-sys-color-on-surface); opacity: 0; }
.segmented label:hover::after { opacity: .08; }
.segmented label:has(input:checked) { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--md-sys-color-secondary); outline-offset: -3px; }
.scale-legend { display: flex; justify-content: space-between; font-size: .75rem; color: var(--md-sys-color-on-surface-variant); padding: 0 8px; }

/* Tarjetas seleccionables (elegir encuesta) */
.choice { position: relative; isolation: isolate; display: flex; align-items: center; gap: 16px; min-height: 72px; padding: 12px 16px;
  border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--md-sys-shape-lg); cursor: pointer; overflow: hidden; }
.choice input { position: absolute; opacity: 0; }
.choice::after { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--md-sys-color-on-surface); opacity: 0; }
.choice:hover::after { opacity: .08; }
.choice .material-symbols-rounded { color: var(--md-sys-color-on-surface-variant); }
.choice:has(input:checked) { background: var(--md-sys-color-primary); border-color: transparent; color: var(--md-sys-color-on-primary); }
.choice:has(input:checked) .material-symbols-rounded { color: inherit; font-variation-settings: "FILL" 1; }
.choice:has(input:focus-visible) { outline: 3px solid var(--md-sys-color-secondary); outline-offset: 2px; }

/* --- Avisos ------------------------------------------------------------ */
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border-radius: var(--md-sys-shape-md);
  background: var(--md-sys-color-surface-container-high); }
.banner-error { background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); }
.banner-ok { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.snackbar { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  min-height: 48px; padding: 14px 16px; border-radius: var(--md-sys-shape-xs); box-shadow: var(--md-elev-3);
  background: var(--md-sys-color-inverse-surface); color: var(--md-sys-color-inverse-on-surface); font-size: .875rem; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: var(--md-sys-shape-sm);
  font: 500 .75rem/1rem var(--font); background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface-variant); }
.chip-on { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }

/* --- Público ----------------------------------------------------------- */
body.public { background: var(--warm-bg); }
.brand-bar { background: var(--brand-bar); color: var(--on-brand-bar); padding: 20px 16px 72px; text-align: center; }
.brand-bar img { height: 36px; width: auto; }
.brand-bar .hero { margin: 14px auto 0; max-width: 560px; font: 500 1.375rem/1.75rem var(--font); letter-spacing: -.01em; }
.brand-bar .intro { max-width: 560px; margin: 8px auto 0; font-size: .875rem; line-height: 1.25rem; opacity: .9; }
.public-main { max-width: 600px; margin: -56px auto 0; padding: 0 16px 48px; position: relative; }
.public-main .card { box-shadow: var(--md-elev-1); border: 0; }
.public-main h1 { color: var(--md-sys-color-primary); }
.center { text-align: center; }
.rich h3, .rich h4, .rich h5 { font-size: 1rem; line-height: 1.5rem; font-weight: 500; margin: .25rem 0; }
.rich p { margin: .5rem 0; }

/* Tarjeta de bienvenida */
.welcome { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: start; }
.welcome .bubble { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  background: var(--md-sys-color-primary-container); color: var(--md-sys-color-primary); }
.welcome .bubble .material-symbols-rounded { font-variation-settings: "FILL" 1; }
.welcome .rich { font-size: .875rem; line-height: 1.375rem; color: var(--md-sys-color-on-surface-variant); }
.welcome .rich br + br { display: none; }
.perks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.perk { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--md-sys-shape-sm);
  background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); font: 500 .8125rem/1 var(--font); }
.perk .material-symbols-rounded { font-size: 18px; }

/* Progreso fijo arriba */
.progress { position: sticky; top: 0; z-index: 5; margin: 0 -16px; padding: 10px 16px;
  background: color-mix(in srgb, var(--warm-bg) 88%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.progress-row { display: flex; justify-content: space-between; font: 500 .75rem/1rem var(--font); color: var(--md-sys-color-on-surface-variant); margin-bottom: 6px; }
.progress-track { height: 6px; border-radius: 3px; background: var(--md-sys-color-surface-container-highest); overflow: hidden; }
.progress-fill { height: 100%; background: var(--md-sys-color-primary); border-radius: 3px; transition: width .4s cubic-bezier(.2, 0, 0, 1); }

/* Una tarjeta por pregunta */
.q-card { background: var(--md-sys-color-surface-container-lowest); border-radius: var(--md-sys-shape-xl); padding: 20px;
  box-shadow: 0 1px 2px rgb(15 25 56 / .06), 0 2px 8px rgb(15 25 56 / .05); border: 2px solid transparent;
  transition: border-color .2s, box-shadow .2s; scroll-margin-top: 72px; margin: 0; min-width: 0; }
.q-card.has-error { border-color: var(--md-sys-color-error); }
.q-card.done .q-num { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }
.q-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; padding: 0; }
.q-num { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; margin-top: -2px;
  background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface-variant);
  font: 600 .8125rem/1 var(--font); transition: background .2s, color .2s; }
.q-num .material-symbols-rounded { font-size: 18px; }
.q-title { font: 500 1.0625rem/1.5rem var(--font); margin: 0; }
.q-title .opt { font-weight: 400; color: var(--md-sys-color-on-surface-variant); font-size: .8125rem; }
.questions { display: grid; gap: 12px; margin-top: 12px; }

/* Caritas 1–5 */
.faces { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.face { position: relative; isolation: isolate; display: grid; justify-items: center; gap: 4px; padding: 10px 2px 8px;
  border-radius: var(--md-sys-shape-lg); cursor: pointer; color: var(--md-sys-color-on-surface-variant); overflow: hidden;
  transition: background .2s, color .2s, transform .15s; -webkit-tap-highlight-color: transparent; }
.face input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.face .material-symbols-rounded { font-size: 40px; font-variation-settings: "FILL" 0, "wght" 300; transition: font-variation-settings .2s, transform .2s; }
.face small { font: 500 .6875rem/1rem var(--font); text-align: center; }
.face::after { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--md-sys-color-on-surface); opacity: 0; }
.face:hover::after { opacity: .06; }
.face:active { transform: scale(.94); }
.face:has(input:checked) { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-primary); }
.face:has(input:checked) .material-symbols-rounded { font-variation-settings: "FILL" 1, "wght" 400; transform: scale(1.12); }
.face:has(input:focus-visible) { outline: 3px solid var(--md-sys-color-primary); outline-offset: 2px; }

/* Sí / No y chips de opción */
.choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pill { position: relative; isolation: isolate; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px;
  padding: 8px 16px; border-radius: var(--md-sys-shape-full); border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-lowest); cursor: pointer; overflow: hidden; font: 500 .9375rem/1.25rem var(--font);
  transition: background .2s, color .2s, border-color .2s, transform .15s; -webkit-tap-highlight-color: transparent; }
.pill input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pill::after { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--md-sys-color-on-surface); opacity: 0; }
.pill:hover::after { opacity: .06; }
.pill:active { transform: scale(.97); }
.pill .material-symbols-rounded { font-size: 22px; }
.pill:has(input:checked) { background: var(--md-sys-color-primary); border-color: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }
.pill:has(input:checked) .material-symbols-rounded { font-variation-settings: "FILL" 1; }
.pill:has(input:focus-visible) { outline: 3px solid var(--md-sys-color-primary); outline-offset: 2px; }
.chips-choice { display: flex; flex-wrap: wrap; gap: 8px; }
.chips-choice .pill { min-height: 44px; padding: 8px 18px; }
.textarea.soft { min-height: 96px; border-radius: var(--md-sys-shape-lg); border-color: var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-low); }

.submit-bar { margin-top: 20px; display: grid; gap: 8px; }
.submit-bar .btn { min-height: 60px; font-size: 1.0625rem; box-shadow: var(--md-elev-1); }
.submit-hint { text-align: center; font-size: .75rem; color: var(--md-sys-color-on-surface-variant); }

/* Ticket del cupón */
.celebrate { display: grid; justify-items: center; gap: 4px; text-align: center; }
.celebrate .badge { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 8px;
  background: var(--md-sys-color-primary-container); color: var(--md-sys-color-primary); animation: pop .5s cubic-bezier(.2, 0, 0, 1.4) both; }
.celebrate .badge .material-symbols-rounded { font-size: 40px; font-variation-settings: "FILL" 1; }
.celebrate h1 { font: 500 2rem/2.5rem var(--font); margin: 0; }
.ticket { position: relative; border-radius: var(--md-sys-shape-xl); background: var(--md-sys-color-surface-container-lowest);
  box-shadow: var(--md-elev-2); overflow: hidden; animation: rise .5s .1s cubic-bezier(.2, 0, 0, 1) both; }
.ticket-top { padding: 20px 20px 16px; text-align: center; background: var(--md-sys-color-tertiary-container); }
.ticket-top img { width: min(60%, 220px); display: block; margin: 0 auto; }
.ticket-cut { position: relative; height: 0; border-top: 2px dashed var(--md-sys-color-outline-variant); margin: 0 20px; }
.ticket-cut::before, .ticket-cut::after { content: ""; position: absolute; top: -13px; width: 24px; height: 24px; border-radius: 50%; background: var(--warm-bg); }
.ticket-cut::before { left: -32px; } .ticket-cut::after { right: -32px; }
.ticket-body { padding: 20px; display: grid; gap: 12px; text-align: center; }
.coupon-code { font: 700 2rem/2.5rem ui-monospace, "Roboto Mono", monospace; letter-spacing: .12em; color: var(--md-sys-color-primary); word-break: break-all; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* --- Admin ------------------------------------------------------------- */
.admin { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.drawer { background: var(--md-sys-color-surface-container-low); padding: 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px 20px; }
.drawer-head .logo { background: var(--brand-bar); border-radius: var(--md-sys-shape-md); padding: 8px 12px; }
.drawer-head .logo img { height: 18px; display: block; }
.drawer h2 { font: 500 .875rem/1.25rem var(--font); color: var(--md-sys-color-on-surface-variant); padding: 16px 16px 8px; margin: 0; }
.nav-item { position: relative; isolation: isolate; overflow: hidden; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 24px 0 16px;
  border-radius: var(--md-sys-shape-full); color: var(--md-sys-color-on-surface-variant); text-decoration: none; font: 500 .875rem/1.25rem var(--font); }
.nav-item::after { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--md-sys-color-on-surface); opacity: 0; }
.nav-item:hover::after { opacity: .08; }
.nav-item[aria-current="page"] { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.nav-item[aria-current="page"] .material-symbols-rounded { font-variation-settings: "FILL" 1; }
.admin-main { padding: 24px clamp(16px, 4vw, 40px) 64px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; min-height: 64px; margin-bottom: 16px; }
.topbar .menu-btn { display: none; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.scrim { display: none; }

@media (max-width: 839px) {
  .admin { grid-template-columns: 1fr; }
  .drawer { position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(320px, 85vw); border-radius: 0 var(--md-sys-shape-lg) var(--md-sys-shape-lg) 0;
    transform: translateX(-105%); transition: transform .25s cubic-bezier(.2, 0, 0, 1); box-shadow: var(--md-elev-1); }
  .drawer.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; z-index: 30; background: rgb(0 0 0 / .32); }
  .topbar .menu-btn { display: inline-grid; }
}

.table-wrap { overflow-x: auto; border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--md-sys-shape-lg); background: var(--md-sys-color-surface-container-lowest); }
table.data { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.data th { text-align: left; font-weight: 500; color: var(--md-sys-color-on-surface-variant); padding: 12px 16px; border-bottom: 1px solid var(--md-sys-color-outline-variant); white-space: nowrap; }
table.data td { padding: 10px 16px; border-bottom: 1px solid var(--md-sys-color-outline-variant); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: color-mix(in srgb, var(--md-sys-color-on-surface) 4%, transparent); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .actions { text-align: right; white-space: nowrap; }

.form-grid { display: grid; gap: 16px 24px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.section-title { font: 500 1rem/1.5rem var(--font); margin: 8px 0 0; }

.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { min-width: 160px; flex: 1 1 160px; }
.filters .input, .filters .select { min-height: 48px; padding-top: 10px; padding-bottom: 10px; }

.kpis { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpi { padding: 20px 24px; border-radius: var(--md-sys-shape-lg); background: var(--md-sys-color-surface-container-low); }
.kpi .value { font-size: 2.25rem; line-height: 2.75rem; font-variant-numeric: tabular-nums; }
.kpi .label { color: var(--md-sys-color-on-surface-variant); font-size: .875rem; }

/* Barras horizontales de una sola serie (color primario, texto en tinta) */
.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(2ch, 33%) minmax(0, 1fr) 11ch; gap: 12px; align-items: center; font-size: .875rem; }
.bar-row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { height: 20px; border-radius: 0 4px 4px 0; background: var(--md-sys-color-surface-container); }
.bar-row .fill { height: 100%; min-width: 2px; background: var(--md-sys-color-primary); border-radius: 0 4px 4px 0; }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--md-sys-color-on-surface-variant); }
.cols { display: flex; align-items: flex-end; gap: 2px; height: 120px; border-bottom: 1px solid var(--md-sys-color-outline-variant); }
.cols > div { flex: 1; min-width: 4px; background: var(--md-sys-color-primary); border-radius: 4px 4px 0 0; position: relative; }
.cols > div:hover { background: var(--md-sys-color-secondary); }
.cols-axis { display: flex; justify-content: space-between; font-size: .75rem; color: var(--md-sys-color-on-surface-variant); margin-top: 4px; }
.q-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.comment { padding: 10px 0; border-top: 1px solid var(--md-sys-color-outline-variant); font-size: .875rem; }
.comment:first-child { border-top: 0; }
.comments { max-height: 360px; overflow-y: auto; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--warm-bg); }
.login-wrap .card { width: min(400px, 100%); }

/* Login */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 5fr) 7fr; background: var(--warm-bg); }
.login-brand { background: var(--brand-bar); color: var(--on-brand-bar); padding: 48px clamp(32px, 5vw, 72px); display: flex; flex-direction: column;
  justify-content: space-between; gap: 40px; position: relative; overflow: hidden; }
.login-brand::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 360px; height: 360px; border-radius: 50%;
  background: radial-gradient(circle, rgb(155 176 204 / .22), transparent 70%); pointer-events: none; }
.login-logo { height: 44px; width: auto; align-self: flex-start; }
.login-pitch h2 { font: 500 clamp(1.75rem, 2.6vw, 2.25rem)/1.25 var(--font); margin: 0 0 28px; letter-spacing: -.01em; }
.login-pitch ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.login-pitch li { display: flex; gap: 14px; align-items: center; font-size: 1rem; color: rgb(255 255 255 / .88); }
.login-pitch li .material-symbols-rounded { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: rgb(155 176 204 / .22); color: #fff; font-size: 22px; }
.login-foot { margin: 0; font-size: .75rem; color: rgb(255 255 255 / .6); }
.login-side { display: grid; place-items: center; padding: 32px 16px; position: relative; z-index: 1; }
.login-card { width: min(420px, 100%); background: var(--md-sys-color-surface-container-lowest); border-radius: var(--md-sys-shape-xl);
  padding: 32px; box-shadow: 0 1px 2px rgb(15 25 56 / .06), 0 8px 24px rgb(15 25 56 / .08); }
.login-wave { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 6px;
  background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); }
.login-wave .material-symbols-rounded { font-variation-settings: "FILL" 1; animation: wave 1.6s ease-in-out .3s 2; transform-origin: 70% 70%; }
@keyframes wave { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(16deg); } 50% { transform: rotate(-8deg); } 75% { transform: rotate(12deg); } }
.input-icon { position: relative; }
.input-icon > .material-symbols-rounded { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--md-sys-color-on-surface-variant); pointer-events: none; }
.input-icon .input { padding-left: 48px; border-radius: var(--md-sys-shape-md); }
.input-icon .input-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.input-icon:has(.input-toggle) .input { padding-right: 52px; }
@media (max-width: 839px) {
  .login { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-brand { padding: 28px 16px 88px; align-items: center; text-align: center; gap: 0; }
  .login-logo { align-self: center; height: 36px; }
  .login-pitch, .login-foot { display: none; }
  .login-side { place-items: start center; padding: 0 16px 32px; margin-top: -64px; }
  .login-card { padding: 24px; }
}

/* Selección de lugar */
.choice { border-radius: var(--md-sys-shape-xl); min-height: 76px; }
.choice-icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); }
.choice-check { opacity: 0; transform: scale(.6); transition: opacity .2s, transform .2s; }
.choice:has(input:checked) { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }
.choice:has(input:checked) .choice-icon { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }
.choice:has(input:checked) .choice-check { opacity: 1; transform: none; color: var(--md-sys-color-primary); font-variation-settings: "FILL" 1; }

/* --- Admin cálido ------------------------------------------------------ */
.admin-main { background: var(--warm-bg); }
/* El color del menú sigue hasta abajo aunque la página sea más alta que la pantalla */
@media (min-width: 840px) {
  .admin { background: linear-gradient(to right, var(--md-sys-color-surface-container-low) 280px, var(--warm-bg) 280px); }
}
.admin-main .card, .admin-main .table-wrap { border: 0; box-shadow: 0 1px 2px rgb(15 25 56 / .06), 0 2px 8px rgb(15 25 56 / .05); }
.admin-main .filters.card { background: var(--md-sys-color-surface-container-lowest); }
.enc-link { color: inherit; text-decoration: none; }
.enc-link:hover { color: var(--md-sys-color-primary); text-decoration: underline; }
.chip-ok { background: #DDF3E4; color: #0B5A2A; }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.kpis { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.kpi { position: relative; background: var(--md-sys-color-surface-container-lowest); border-radius: var(--md-sys-shape-xl);
  box-shadow: 0 1px 2px rgb(15 25 56 / .06), 0 2px 8px rgb(15 25 56 / .05); padding: 20px 24px; }
.kpi-icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 12px;
  background: var(--md-sys-color-primary-container); color: var(--md-sys-color-primary); }
.kpi-icon .material-symbols-rounded { font-variation-settings: "FILL" 1; font-size: 22px; }
.kpi .value { color: var(--md-sys-color-on-surface); }
.kpi .value small { font-size: 1rem; color: var(--md-sys-color-on-surface-variant); }

.enc-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); }
.enc-card { display: grid; gap: 14px; align-content: start; padding: 20px; border-radius: var(--md-sys-shape-xl);
  background: var(--md-sys-color-surface-container-lowest); box-shadow: 0 1px 2px rgb(15 25 56 / .06), 0 2px 8px rgb(15 25 56 / .05); }
.enc-card.is-off { opacity: .72; }
.enc-head { display: flex; gap: 12px; align-items: flex-start; }
.enc-icon { width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); }
.enc-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.enc-stats > div { padding: 10px 12px; border-radius: var(--md-sys-shape-md); background: var(--md-sys-color-surface-container-low); display: grid; }
.enc-stats strong { font: 500 1.375rem/1.75rem var(--font); font-variant-numeric: tabular-nums; }
.enc-stats span { font-size: .75rem; color: var(--md-sys-color-on-surface-variant); }
.qr-line { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 12px; border-radius: var(--md-sys-shape-md);
  background: var(--md-sys-color-surface-container); color: var(--md-sys-color-on-surface-variant); min-width: 0; }
.qr-line code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .75rem; }
.enc-actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; border-top: 1px solid var(--md-sys-color-outline-variant); padding-top: 12px; }
.enc-actions .btn { min-height: 36px; padding: 0 14px; }
.enc-actions .btn-text { padding: 0 10px; }

.q-row { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-radius: var(--md-sys-shape-lg);
  background: var(--md-sys-color-surface-container-lowest); box-shadow: 0 1px 2px rgb(15 25 56 / .06), 0 2px 8px rgb(15 25 56 / .05); }
.q-row .q-num { margin: 0; }
.q-type { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--md-sys-color-primary-container); color: var(--md-sys-color-primary); }
.q-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 599px) {
  .q-row { flex-wrap: wrap; }
  .q-actions { width: 100%; border-top: 1px solid var(--md-sys-color-outline-variant); padding-top: 6px; }
  .topbar { flex-wrap: wrap; }
  .page-actions { margin-left: 0; width: 100%; }
}

.q-row.is-hidden { opacity: .6; background: var(--md-sys-color-surface-container-low); box-shadow: none; }
.q-row.is-hidden .q-type { background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface-variant); }

/* --- Reportería -------------------------------------------------------- */
/* Estado: color + ícono + texto, nunca solo color */
.delta { display: inline-flex; align-items: center; gap: 4px; margin-top: 10px; font: 500 .75rem/1rem var(--font); color: var(--md-sys-color-on-surface-variant); }
.delta .material-symbols-rounded { font-size: 16px; }
.delta.good { color: #146C2E; }
.delta.bad { color: var(--md-sys-color-error); }
.ranking td .delta { margin-top: 0; }
.kpi-icon.kpi-bad { background: var(--md-sys-color-error-container); color: var(--md-sys-color-error); }

.alert-banner { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-radius: var(--md-sys-shape-xl); text-decoration: none;
  background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); }
.alert-banner .btn { --_bg: var(--md-sys-color-error); --_fg: var(--md-sys-color-on-error); }
.alert-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; background: rgb(255 255 255 / .6); }

table.ranking th a.sort { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 2px; }
table.ranking th a.sort.on { color: var(--md-sys-color-primary); }
table.ranking th a.sort .material-symbols-rounded { font-size: 16px; }
table.ranking tr.few td { color: var(--md-sys-color-on-surface-variant); }
.low-cell { min-width: 180px; }
.low-cell { display: flex; align-items: center; gap: 10px; }
.low-bar { flex: 1; height: 10px; border-radius: 0 4px 4px 0; background: var(--md-sys-color-surface-container); }
.low-bar > span { display: block; height: 100%; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--md-sys-color-primary); }
.low-cell .num { width: 48px; text-align: right; font-variant-numeric: tabular-nums; }

.filter-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: var(--md-sys-shape-sm);
  border: 1px solid var(--md-sys-color-outline-variant); color: var(--md-sys-color-on-surface-variant); text-decoration: none; font: 500 .875rem/1 var(--font);
  background: var(--md-sys-color-surface-container-lowest); }
.filter-chip .material-symbols-rounded { font-size: 18px; }
.filter-chip.on { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); border-color: transparent; }

.alert-card { display: grid; gap: 12px; padding: 20px; border-radius: var(--md-sys-shape-xl); background: var(--md-sys-color-surface-container-lowest);
  box-shadow: 0 1px 2px rgb(15 25 56 / .06), 0 2px 8px rgb(15 25 56 / .05); border-left: 4px solid var(--md-sys-color-error); }
.alert-card.done { border-left-color: #146C2E; opacity: .8; }
.alert-head { display: flex; gap: 12px; align-items: flex-start; }
.alert-score { width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--md-sys-color-error-container); color: var(--md-sys-color-error); }
.alert-score .material-symbols-rounded { font-size: 28px; font-variation-settings: "FILL" 1; }
.alert-lows, .alert-others { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.alert-lows li, .alert-others li { display: flex; gap: 10px; align-items: baseline; font-size: .9375rem; }
.alert-others { margin-top: 8px; }
.score-pill { flex: none; min-width: 24px; height: 24px; border-radius: 12px; display: inline-grid; place-items: center; font: 600 .8125rem/1 var(--font);
  background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface); }
.score-pill.s1, .score-pill.s2 { background: var(--md-sys-color-error); color: var(--md-sys-color-on-error); }
.alert-quote { margin: 0; display: flex; gap: 8px; padding: 12px 14px; border-radius: var(--md-sys-shape-md);
  background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); font-size: .9375rem; }
.alert-quote .material-symbols-rounded { font-size: 20px; opacity: .6; }
.alert-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--md-sys-color-outline-variant); padding-top: 12px; }
@media (max-width: 599px) {
  .alert-banner { flex-wrap: wrap; }
  .alert-head .btn { display: none; }
}

/* Mapa tienda × tema: una sola escala (rojo de error, claro → oscuro); el número siempre visible */
table.heatmap th { text-align: center; }
table.heatmap th:first-child { text-align: left; }
table.heatmap td.heat { text-align: center; font-variant-numeric: tabular-nums; font-weight: 500; border-left: 2px solid var(--md-sys-color-surface-container-lowest); min-width: 84px; }
table.heatmap tr.overall td { border-bottom: 2px solid var(--md-sys-color-outline-variant); }
.heat.h0 { background: #FBF3F1; color: #5C3F3E; }
.heat.h1 { background: #F8D9D4; color: #5C1F1A; }
.heat.h2 { background: #F0ADA4; color: #4A0F0A; }
.heat.h3 { background: #DD6B5F; color: #2B0503; }
.heat.h4 { background: #A8231B; color: #FFFFFF; }
.heat.h-na { background: var(--md-sys-color-surface-container-low); color: var(--md-sys-color-on-surface-variant); }
.heat .few { font-size: .75rem; font-weight: 400; }
.heat-legend { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.heat-legend .heat { padding: 4px 10px; border-radius: var(--md-sys-shape-xs); font-size: .75rem; font-weight: 500; }

.topic-compare { display: grid; gap: 14px; }
.tc-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 150px 130px; gap: 14px; align-items: center; }
.tc-name { font-weight: 500; }
.tc-bars { display: grid; gap: 4px; }
.tc-bar { height: 10px; border-radius: 0 4px 4px 0; background: var(--md-sys-color-surface-container); }
.tc-bar > span { display: block; height: 100%; min-width: 2px; border-radius: 0 4px 4px 0; }
.tc-bar.mine > span, .legend-sw.mine { background: var(--md-sys-color-primary); }
.tc-bar.net > span, .legend-sw.net { background: #9BB0CC; }
.tc-val { font-size: .875rem; font-variant-numeric: tabular-nums; }
.legend-sw { display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin-right: -10px; }
@media (max-width: 699px) { .tc-row { grid-template-columns: 1fr 1fr; } .tc-bars { grid-column: 1 / -1; grid-row: 2; } }
