/* =====================================================================
   AMV NPS — Panel de administración
   Construido ENCIMA de theme.css (variables + .glass-card/.btn/.input/.badge).
   No redefine variables del tema; solo agrega layout y componentes del admin.
   ===================================================================== */

:root {
  --star:      #f5c451;
  --star-off:  rgba(255,255,255,.16);
  --shell-max: 1320px;
  --nav-h:     64px;
}

body { min-height: 100vh; line-height: 1.45; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.015em; }
p { margin: 0; }
.muted { color: var(--ink-soft); }
.mono { font-family: ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ top bar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(13,17,32,.62);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--shell-max); margin: 0 auto; height: var(--nav-h);
  display: flex; align-items: center; gap: 1.5rem; padding: 0 1.5rem;
}
.brand { display: flex; align-items: center; gap: .7rem; color: var(--ink); flex-shrink: 0; }
.brand:hover { color: var(--ink); }
.brand-logo {
  height: 34px; width: auto; border-radius: 9px; background: #011c31;
  padding: 4px 7px; box-shadow: 0 0 0 1px var(--line-2);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: .95rem; font-weight: 700; }
.brand-text span { font-size: .72rem; color: var(--ink-soft); letter-spacing: .04em; text-transform: uppercase; }

.nav { display: flex; align-items: center; gap: .25rem; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  display: inline-flex; align-items: center; gap: .5rem; white-space: nowrap;
  padding: .5rem .95rem; border-radius: var(--radius-btn);
  color: var(--ink-soft); font-size: .9rem; font-weight: 600;
  transition: background-color .16s ease-out, color .16s ease-out;
}
.nav a svg { width: 17px; height: 17px; opacity: .85; }
.nav a:hover { color: var(--ink); background: rgba(255,255,255,.06); }
.nav a.is-active {
  color: var(--ink); background: rgba(77,141,255,.18);
  box-shadow: inset 0 0 0 1px rgba(77,141,255,.35);
}
.nav a.is-active svg { color: var(--accent); opacity: 1; }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-soft); opacity: .6; }
.nav-dot.on { background: var(--good); opacity: 1; box-shadow: 0 0 0 3px rgba(52,209,126,.2); }

.user-chip { display: flex; align-items: center; gap: .65rem; flex-shrink: 0; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: .82rem; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-cyan));
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta strong { font-size: .85rem; font-weight: 650; }
.user-meta span { font-size: .72rem; color: var(--ink-soft); text-transform: capitalize; }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%;
  color: var(--ink-soft); border: 1px solid var(--line); background: rgba(255,255,255,.04);
  transition: background-color .16s, color .16s;
}
.icon-btn:hover { color: var(--ink); background: rgba(255,255,255,.1); }
.icon-btn svg { width: 17px; height: 17px; }

/* ------------------------------------------------------------ shell */
.shell { max-width: var(--shell-max); margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem 2rem;
  flex-wrap: wrap; margin-bottom: 1.75rem;
}
.page-head h1 { font-size: 1.85rem; font-weight: 750; }
.page-head .lead { color: var(--ink-soft); margin-top: .35rem; max-width: 62ch; font-size: .96rem; }
.eyebrow {
  font-size: .72rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--accent-cyan); margin-bottom: .35rem;
}
.head-actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.btn svg { width: 16px; height: 16px; }
.btn-sm { padding: .45rem .95rem; font-size: .82rem; }
.btn-danger-ghost { background: rgba(239,90,90,.1); color: #ff9b9b; border-color: rgba(239,90,90,.3); }
.btn-danger-ghost:hover { background: rgba(239,90,90,.18); }
.btn-good {
  background: linear-gradient(135deg, #34d17e, #22a862); color: #04210f;
  box-shadow: 0 8px 20px rgba(52,209,126,.3);
}
.btn-good:hover { filter: brightness(1.06); }
.btn.is-loading { pointer-events: none; opacity: .75; }
.btn.is-loading::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.card { padding: 1.5rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.15rem; }
.card-head h2 { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: .55rem; }
.card-head .sub { font-size: .82rem; color: var(--ink-soft); margin-top: .2rem; }
.card-head a.link { font-size: .84rem; font-weight: 600; white-space: nowrap; }

/* ------------------------------------------------------------ flash toasts */
.toasts {
  position: fixed; top: calc(var(--nav-h) + 14px); right: 18px; z-index: 80;
  display: flex; flex-direction: column; gap: .6rem; width: min(400px, calc(100vw - 36px));
}
.toast {
  display: flex; align-items: flex-start; gap: .75rem; padding: .9rem 1rem;
  border-radius: 16px; border: 1px solid var(--line-2);
  background: rgba(26,32,56,.88); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: 0 16px 40px rgba(0,0,0,.45); font-size: .9rem;
  animation: toast-in .4s var(--spring) both;
}
.toast-icon { width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; }
.toast-icon svg { width: 13px; height: 13px; }
.toast-success .toast-icon { background: rgba(52,209,126,.22); color: var(--good); }
.toast-danger  .toast-icon { background: rgba(239,90,90,.22); color: var(--bad); }
.toast-info    .toast-icon { background: rgba(75,200,232,.22); color: var(--info); }
.toast-success { border-color: rgba(52,209,126,.35); }
.toast-danger  { border-color: rgba(239,90,90,.4); }
.toast-body { flex: 1; padding-top: 1px; word-break: break-word; }
.toast-close { background: none; border: 0; color: var(--ink-soft); cursor: pointer; padding: 0 2px; font-size: 1.1rem; line-height: 1; }
.toast-close:hover { color: var(--ink); }
.toast.is-leaving { animation: toast-out .25s ease-in both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* ------------------------------------------------------------ stars */
.stars { position: relative; display: inline-flex; vertical-align: middle; line-height: 0; }
.stars-track, .stars-fill { display: inline-flex; gap: 2px; }
.stars-track { color: var(--star-off); }
.stars-fill { position: absolute; inset: 0 auto 0 0; overflow: hidden; color: var(--star); white-space: nowrap; }
.stars svg { width: 14px; height: 14px; flex-shrink: 0; }
.stars-lg svg { width: 22px; height: 22px; }
.stars-md svg { width: 17px; height: 17px; }
.rating { display: inline-flex; align-items: center; gap: .5rem; }
.rating-num { font-weight: 750; font-variant-numeric: tabular-nums; font-size: .95rem; }

/* tonos por nivel de calificación (consistentes con alertas: ≤2 crítico, ≤3.4 atención) */
.tone-good { --tone: var(--good); --tone-bg: rgba(52,209,126,.16); --tone-ink: #6be8a8; }
.tone-info { --tone: var(--accent); --tone-bg: rgba(77,141,255,.16); --tone-ink: #8fb6ff; }
.tone-warn { --tone: var(--warn); --tone-bg: rgba(240,185,61,.16); --tone-ink: #ffd27a; }
.tone-bad  { --tone: var(--bad);  --tone-bg: rgba(239,90,90,.16);  --tone-ink: #ff9b9b; }
.tone-chip {
  display: inline-flex; align-items: center; gap: .35rem; padding: .25em .7em; border-radius: 999px;
  font-size: .74rem; font-weight: 700; background: var(--tone-bg); color: var(--tone-ink);
}

/* ------------------------------------------------------------ dashboard */
.kpi-grid { display: grid; grid-template-columns: 1.35fr repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
.kpi { padding: 1.3rem 1.4rem; display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.kpi-label { font-size: .78rem; font-weight: 650; color: var(--ink-soft); letter-spacing: .02em; display: flex; align-items: center; gap: .4rem; }
.kpi-value { font-size: 2.1rem; font-weight: 760; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-value small { font-size: 1rem; font-weight: 600; color: var(--ink-soft); letter-spacing: 0; }
.kpi-foot { font-size: .8rem; color: var(--ink-soft); margin-top: auto; }
.kpi-foot a { font-weight: 650; }
.kpi-hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(420px 220px at 100% 0%, color-mix(in srgb, var(--tone, var(--accent)) 28%, transparent), transparent 70%),
    linear-gradient(135deg, rgba(255,255,255,.1) 0%, rgba(255,255,255,.02) 40%, transparent 60%),
    var(--surface);
}
.kpi-hero .kpi-value { font-size: 3.1rem; }
.kpi-hero .rating { gap: .8rem; flex-wrap: wrap; }
.kpi-bar { height: 6px; border-radius: 6px; background: rgba(255,255,255,.08); overflow: hidden; margin-top: .4rem; }
.kpi-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-cyan)); }
.kpi.has-issue { box-shadow: 0 1px 0 rgba(255,255,255,.14) inset, 0 18px 46px rgba(0,0,0,.4), inset 0 0 0 1px rgba(239,90,90,.35); }
.kpi.has-issue .kpi-value { color: #ff9b9b; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.dash-col { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.dash-col-alerts { position: sticky; top: calc(var(--nav-h) + 16px); }

.cat-list { display: flex; flex-direction: column; gap: 1.05rem; }
.cat-row { display: grid; grid-template-columns: minmax(110px, 170px) 1fr auto; align-items: center; gap: 1rem; }
.cat-name { font-weight: 650; font-size: .93rem; text-transform: capitalize; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-name small { display: block; font-weight: 500; font-size: .74rem; color: var(--ink-soft); text-transform: none; }
.cat-track { position: relative; height: 12px; border-radius: 12px; background: rgba(255,255,255,.07); overflow: hidden; }
.cat-track::after { /* marcas de 1..5 */
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), rgba(13,17,32,.55) calc(25% - 1px) 25%);
}
.cat-fill {
  height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--tone) 70%, transparent), var(--tone));
  box-shadow: 0 0 18px color-mix(in srgb, var(--tone) 45%, transparent);
  transform-origin: left; animation: grow .9s var(--spring) both;
}
@keyframes grow { from { transform: scaleX(0); } }
.cat-score { display: flex; align-items: baseline; gap: .3rem; min-width: 64px; justify-content: flex-end; }
.cat-score strong { font-size: 1.2rem; font-weight: 760; color: var(--tone-ink); font-variant-numeric: tabular-nums; }
.cat-score span { font-size: .75rem; color: var(--ink-soft); }
.cat-scale { display: grid; grid-template-columns: minmax(110px, 170px) 1fr auto; gap: 1rem; margin-top: .4rem; }
.cat-scale div { display: flex; justify-content: space-between; font-size: .7rem; color: var(--ink-soft); opacity: .8; }
.cat-scale i { min-width: 64px; }
.cat-insight {
  margin-top: 1.2rem; padding: .8rem 1rem; border-radius: 14px; font-size: .86rem;
  background: rgba(255,255,255,.04); border: 1px solid var(--line); display: flex; gap: .6rem; align-items: flex-start;
}
.cat-insight svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; color: var(--accent-cyan); }

.chart-box { position: relative; height: 260px; }

/* alertas */
.alerts-card { border-color: rgba(239,90,90,.28); }
.alerts-card.is-calm { border-color: rgba(52,209,126,.25); }
.alert-count { font-size: .74rem; font-weight: 750; padding: .2em .65em; border-radius: 999px; background: rgba(239,90,90,.2); color: #ff9b9b; }
.alert-list { display: flex; flex-direction: column; gap: .6rem; max-height: min(640px, calc(100vh - 220px)); overflow-y: auto; margin: 0 -.35rem; padding: 0 .35rem; }
.alert {
  position: relative; padding: .85rem 1rem .85rem 1.15rem; border-radius: 14px;
  background: var(--tone-bg); border: 1px solid color-mix(in srgb, var(--tone) 30%, transparent);
}
.alert::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--tone);
}
.alert-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.alert-level { font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--tone-ink); }
.alert-time { font-size: .74rem; color: var(--ink-soft); white-space: nowrap; }
.alert-who { font-weight: 650; font-size: .92rem; margin: .3rem 0 .1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-meta { font-size: .76rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert .rating { margin-top: .45rem; }
.alert .rating-num { color: var(--tone-ink); }

/* comentario: siempre secundario */
.quote {
  margin-top: .45rem; font-size: .8rem; color: var(--ink-soft); font-style: italic; line-height: 1.4;
  padding-left: .7rem; border-left: 2px solid var(--line-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.quote.is-open { -webkit-line-clamp: unset; }
.quote[data-expandable] { cursor: pointer; }

/* feed de respuestas */
.feed { display: flex; flex-direction: column; }
.feed-row {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: .9rem; align-items: start;
  padding: .95rem 0; border-top: 1px solid var(--line);
}
.feed-row:first-child { border-top: 0; padding-top: .2rem; }
.feed-row .avatar { width: 40px; height: 40px; background: rgba(255,255,255,.08); color: var(--ink); font-size: .85rem; }
.feed-who { font-weight: 650; font-size: .93rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.feed-meta { font-size: .78rem; color: var(--ink-soft); margin-top: .1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-right { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
.feed-right time { font-size: .75rem; color: var(--ink-soft); white-space: nowrap; }

.origin-chip {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .7rem; font-weight: 650;
  padding: .15em .55em; border-radius: 999px; background: rgba(255,255,255,.07); color: var(--ink-soft);
}
.origin-chip svg { width: 11px; height: 11px; }

/* ------------------------------------------------------------ empty states */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: .55rem;
  padding: 2.2rem 1.25rem;
}
.empty-icon {
  width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; margin-bottom: .35rem;
  background: linear-gradient(135deg, rgba(77,141,255,.22), rgba(79,214,232,.12));
  border: 1px solid rgba(77,141,255,.3); color: var(--accent-cyan);
}
.empty-icon svg { width: 26px; height: 26px; }
.empty-icon.good { background: rgba(52,209,126,.14); border-color: rgba(52,209,126,.3); color: var(--good); }
.empty h3 { font-size: 1rem; font-weight: 700; }
.empty p { color: var(--ink-soft); font-size: .88rem; max-width: 44ch; }
.empty .btn { margin-top: .6rem; }
.empty-compact { padding: 1.4rem 1rem; }

.dash-empty-hero { padding: 2.5rem 2rem; margin-bottom: 1rem; display: grid; grid-template-columns: auto 1fr auto; gap: 1.5rem; align-items: center; }
.dash-empty-hero .empty-icon { margin: 0; width: 64px; height: 64px; }
.dash-empty-hero h2 { font-size: 1.2rem; }
.dash-empty-hero p { color: var(--ink-soft); margin-top: .3rem; max-width: 60ch; font-size: .93rem; }

/* ------------------------------------------------------------ encuestas */
.survey-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 1rem; }
.survey { padding: 1.4rem 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.survey.is-default {
  border-color: rgba(77,141,255,.45);
  background:
    radial-gradient(380px 200px at 100% 0%, rgba(77,141,255,.22), transparent 70%),
    linear-gradient(135deg, rgba(255,255,255,.09) 0%, rgba(255,255,255,.015) 32%, transparent 55%),
    var(--surface);
}
.survey.is-off { opacity: .72; }
.survey-top { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.survey-title { font-size: 1.12rem; font-weight: 720; }
.survey-badges { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .45rem; }
.survey-badges .badge svg { width: 12px; height: 12px; }
.q-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; counter-reset: q; }
.q-list li {
  counter-increment: q; display: grid; grid-template-columns: 22px 1fr; gap: .6rem; align-items: baseline;
  font-size: .88rem; padding: .55rem .75rem; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--line);
}
.q-list li::before { content: counter(q); font-size: .72rem; font-weight: 750; color: var(--ink-soft); text-align: center; }
.q-list code { font-size: .72rem; color: var(--accent-cyan); background: rgba(79,214,232,.1); padding: .05em .45em; border-radius: 6px; margin-left: .35rem; }
.survey-facts { display: flex; gap: 1.4rem; flex-wrap: wrap; font-size: .8rem; color: var(--ink-soft); }
.survey-facts strong { color: var(--ink); font-weight: 650; }
.survey-actions { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; padding-top: 1rem; border-top: 1px solid var(--line); margin-top: auto; }
.survey-actions .right { display: flex; gap: .5rem; flex-wrap: wrap; }
.survey-actions form { margin: 0; }
.hint-card { padding: 1.3rem 1.5rem; display: flex; gap: 1rem; align-items: flex-start; border-style: dashed; border-color: var(--line-2); background: rgba(255,255,255,.025); box-shadow: none; }
.hint-card .empty-icon { margin: 0; width: 44px; height: 44px; border-radius: 14px; flex-shrink: 0; }
.hint-card .empty-icon svg { width: 20px; height: 20px; }
.hint-card h3 { font-size: .98rem; margin-bottom: .25rem; }
.hint-card p { font-size: .86rem; color: var(--ink-soft); }

/* switch (botón dentro de <form method=post>) */
.switch {
  display: inline-flex; align-items: center; gap: .6rem; background: none; border: 0; padding: 0;
  color: var(--ink); font-family: var(--font); font-size: .85rem; font-weight: 600; cursor: pointer;
}
.switch-track {
  position: relative; width: 44px; height: 26px; border-radius: 26px; flex-shrink: 0;
  background: rgba(255,255,255,.14); border: 1px solid var(--line-2);
  transition: background-color .2s ease-out;
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); transition: transform .25s var(--spring);
}
.switch[aria-checked="true"] .switch-track { background: var(--good); border-color: transparent; }
.switch[aria-checked="true"] .switch-track::after { transform: translateX(18px); }
.switch:disabled { cursor: not-allowed; opacity: .55; }
.switch-xl .switch-track { width: 84px; height: 46px; border-radius: 46px; }
.switch-xl .switch-track::after { width: 38px; height: 38px; top: 3px; left: 3px; }
.switch-xl[aria-checked="true"] .switch-track::after { transform: translateX(38px); }
.switch-xl[aria-checked="true"] .switch-track { box-shadow: 0 0 0 6px rgba(52,209,126,.15), 0 0 30px rgba(52,209,126,.4); }

/* ------------------------------------------------------------ formularios */
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.25rem; align-items: start; }
.form-main { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.form-section { padding: 1.5rem 1.6rem; }
.section-head { display: flex; gap: .85rem; align-items: flex-start; margin-bottom: 1.2rem; }
.section-num {
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0;
  background: rgba(77,141,255,.18); color: #8fb6ff; font-weight: 750; font-size: .82rem;
}
.section-head h2 { font-size: 1.04rem; font-weight: 700; }
.section-head p { font-size: .84rem; color: var(--ink-soft); margin-top: .2rem; max-width: 64ch; }
.field { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
.field label, .label { font-size: .82rem; font-weight: 650; color: var(--ink); }
.field label .opt { color: var(--ink-soft); font-weight: 500; }
.help { font-size: .78rem; color: var(--ink-soft); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
textarea.input { resize: vertical; min-height: 84px; line-height: 1.45; }
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 2.4rem; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.5l5 5 5-5' fill='none' stroke='%23a9b6cc' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 1rem center;
}
select.input option { background: var(--surface-solid); color: var(--ink); }

.q-editor { display: flex; flex-direction: column; gap: .6rem; }
.q-head, .q-row { display: grid; grid-template-columns: 30px minmax(120px, 190px) minmax(0, 1fr) auto; gap: .6rem; align-items: center; }
.q-head { font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-soft); padding: 0 .1rem; }
.q-row {
  padding: .55rem; border-radius: 16px; background: rgba(255,255,255,.035); border: 1px solid var(--line);
  animation: toast-in .35s var(--spring) both;
}
.q-row .input { padding: .62rem .85rem; }
.q-row .input.mono { font-size: .86rem; }
.q-index { font-size: .8rem; font-weight: 750; color: var(--ink-soft); text-align: center; }
.q-tools { display: flex; gap: .25rem; }
.q-tools button {
  width: 32px; height: 32px; border-radius: 10px; border: 1px solid transparent; background: transparent;
  color: var(--ink-soft); cursor: pointer; display: grid; place-items: center;
}
.q-tools button:hover:not(:disabled) { background: rgba(255,255,255,.08); color: var(--ink); }
.q-tools button.del:hover:not(:disabled) { background: rgba(239,90,90,.15); color: #ff9b9b; }
.q-tools button:disabled { opacity: .3; cursor: not-allowed; }
.q-tools svg { width: 15px; height: 15px; }
.q-warn { grid-column: 2 / -1; font-size: .76rem; color: #ffd27a; display: none; }
.q-row.has-warn .q-warn { display: block; }
.q-row.is-dup .input.mono { border-color: var(--bad); }
.q-add {
  display: flex; align-items: center; justify-content: center; gap: .5rem; width: 100%;
  padding: .8rem; border-radius: 16px; border: 1.5px dashed var(--line-2); background: transparent;
  color: var(--ink-soft); font-family: var(--font); font-weight: 650; font-size: .88rem; cursor: pointer;
  transition: border-color .16s, color .16s, background-color .16s;
}
.q-add:hover { border-color: var(--accent); color: var(--ink); background: rgba(77,141,255,.07); }
.q-add svg { width: 16px; height: 16px; }

.threshold { display: grid; grid-template-columns: 130px 1fr; gap: 1.2rem; align-items: center; }
.threshold-explain {
  padding: .85rem 1rem; border-radius: 14px; background: rgba(52,209,126,.08); border: 1px solid rgba(52,209,126,.22);
  font-size: .86rem; line-height: 1.5;
}
.threshold-explain strong { color: #6be8a8; }

.form-footer {
  position: sticky; bottom: 14px; z-index: 20; padding: .9rem 1.1rem;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.form-footer .right { display: flex; gap: .6rem; }

/* vista previa */
.preview { position: sticky; top: calc(var(--nav-h) + 20px); padding: 1.3rem; }
.preview-label { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: .8rem; display: flex; align-items: center; gap: .4rem; }
.phone {
  border-radius: 22px; padding: 1.2rem 1.1rem; background: #f6f8fc; color: #1a2238;
  box-shadow: 0 0 0 6px rgba(255,255,255,.06), 0 20px 40px rgba(0,0,0,.4);
}
.phone-brand { display: flex; align-items: center; justify-content: center; margin-bottom: .9rem; }
.phone-brand img { height: 30px; border-radius: 7px; background: #011c31; padding: 3px 6px; }
.phone h4 { font-size: .98rem; text-align: center; margin-bottom: 1rem; color: #121a30; }
.phone-q { padding: .7rem 0; border-top: 1px solid #e3e8f2; }
.phone-q p { font-size: .84rem; font-weight: 600; margin-bottom: .45rem; color: #1a2238; }
.phone-q p.placeholder { color: #9aa5bd; font-style: italic; font-weight: 500; }
.phone-stars { display: flex; gap: 4px; color: #d4dae6; }
.phone-stars svg { width: 22px; height: 22px; }
.phone-cta { margin-top: .9rem; text-align: center; font-size: .8rem; font-weight: 700; color: #fff; background: #3568d6; border-radius: 999px; padding: .6rem; }
.preview-subject { margin-top: 1rem; font-size: .8rem; color: var(--ink-soft); }
.preview-subject strong { display: block; color: var(--ink); font-weight: 600; margin-top: .2rem; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ envíos */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin-bottom: 1rem; }
.segmented {
  display: inline-flex; gap: 2px; padding: 4px; border-radius: 999px; overflow-x: auto; max-width: 100%;
  background: rgba(255,255,255,.05); border: 1px solid var(--line);
}
.segmented a {
  display: inline-flex; align-items: center; gap: .4rem; padding: .42rem .9rem; border-radius: 999px; white-space: nowrap;
  font-size: .82rem; font-weight: 650; color: var(--ink-soft);
}
.segmented a:hover { color: var(--ink); background: rgba(255,255,255,.06); }
.segmented a.is-active { color: var(--ink); background: rgba(77,141,255,.25); box-shadow: inset 0 0 0 1px rgba(77,141,255,.4); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-pendiente { background: var(--ink-soft); }
.dot-enviado { background: var(--info); }
.dot-error { background: var(--bad); }
.dot-respondido { background: var(--good); }
.dot-expirado { background: #7d8bab; }
.search { position: relative; width: min(300px, 100%); }
.search svg { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--ink-soft); pointer-events: none; }
.search .input { padding: .55rem .9rem .55rem 2.4rem; border-radius: 999px; font-size: .86rem; }

.table-card { padding: .4rem 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .87rem; }
.table th {
  text-align: left; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-soft); padding: .85rem 1rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: .9rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .12s; }
.table tbody tr:hover { background: rgba(255,255,255,.035); }
.table th:first-child, .table td:first-child { padding-left: 1.4rem; }
.table th:last-child, .table td:last-child { padding-right: 1.4rem; text-align: right; }
.cell-main { font-weight: 650; }
.cell-sub { font-size: .78rem; color: var(--ink-soft); margin-top: .12rem; overflow-wrap: anywhere; }
.err-text { font-size: .74rem; color: #ff9b9b; margin-top: .35rem; max-width: 260px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.table .quote { max-width: 260px; }
.table form { margin: 0; display: inline; }
.no-results { display: none; padding: 2rem; text-align: center; color: var(--ink-soft); font-size: .9rem; }

.badge-estado { text-transform: capitalize; }
.badge-estado .dot { width: 6px; height: 6px; }

/* modal (<dialog>) */
dialog.modal {
  width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line-2); border-radius: 24px;
  color: var(--ink); background: rgba(24,30,54,.94);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
dialog.modal[open] { animation: toast-in .35s var(--spring) both; }
dialog.modal::backdrop { background: rgba(5,8,18,.6); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.modal-head { padding: 1.4rem 1.6rem 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.modal-head h2 { font-size: 1.2rem; font-weight: 720; }
.modal-head p { font-size: .86rem; color: var(--ink-soft); margin-top: .3rem; }
.modal-body { padding: 1.3rem 1.6rem; }
.modal-foot { padding: 1rem 1.6rem 1.4rem; display: flex; justify-content: flex-end; gap: .6rem; border-top: 1px solid var(--line); }

/* ------------------------------------------------------------ automatización */
.auto-hero { padding: 2rem; display: grid; grid-template-columns: 1fr auto; gap: 2rem; align-items: center; margin-bottom: 1rem; position: relative; overflow: hidden; }
.auto-hero.is-on { border-color: rgba(52,209,126,.45);
  background: radial-gradient(520px 260px at 100% 50%, rgba(52,209,126,.22), transparent 70%),
              linear-gradient(135deg, rgba(255,255,255,.09) 0%, rgba(255,255,255,.015) 32%, transparent 55%), var(--surface); }
.auto-hero.is-off { border-color: rgba(240,185,61,.32); }
.auto-state { display: inline-flex; align-items: center; gap: .55rem; font-size: .78rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.auto-state .pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--warn); }
.is-on .auto-state { color: #6be8a8; }
.is-on .auto-state .pulse { background: var(--good); animation: pulse 1.8s ease-out infinite; }
.is-off .auto-state { color: #ffd27a; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(52,209,126,.6); } 100% { box-shadow: 0 0 0 12px rgba(52,209,126,0); } }
.auto-hero h1 { font-size: 2rem; font-weight: 760; margin: .5rem 0 .55rem; }
.auto-hero .lead { color: var(--ink-soft); max-width: 62ch; font-size: .95rem; }
.auto-note {
  margin-top: 1.1rem; display: flex; gap: .7rem; align-items: flex-start; padding: .85rem 1rem; border-radius: 14px;
  background: rgba(240,185,61,.1); border: 1px solid rgba(240,185,61,.28); font-size: .87rem; max-width: 66ch;
}
.auto-note svg { width: 18px; height: 18px; color: var(--warn); flex-shrink: 0; margin-top: 1px; }
.auto-note.good { background: rgba(52,209,126,.1); border-color: rgba(52,209,126,.28); }
.auto-note.good svg { color: var(--good); }
.auto-switch { display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.auto-switch form { margin: 0; }
.auto-switch .help { text-align: center; max-width: 180px; }

.auto-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.big-num { font-size: 3rem; font-weight: 780; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.ready-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .75rem; }
.ready-list li { display: grid; grid-template-columns: 26px 1fr; gap: .7rem; align-items: start; font-size: .88rem; }
.ready-list .ck { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; }
.ready-list .ck svg { width: 14px; height: 14px; }
.ck.ok { background: rgba(52,209,126,.18); color: var(--good); }
.ck.no { background: rgba(240,185,61,.18); color: var(--warn); }
.ck.x  { background: rgba(239,90,90,.18); color: var(--bad); }
.ready-list strong { display: block; font-weight: 650; }
.ready-list span { color: var(--ink-soft); font-size: .82rem; }

.run-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-top: 1rem; }
.run-stat { padding: .85rem 1rem; border-radius: 14px; background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.run-stat b { display: block; font-size: 1.5rem; font-weight: 760; font-variant-numeric: tabular-nums; }
.run-stat span { font-size: .75rem; color: var(--ink-soft); }
.run-stat.bad b { color: #ff9b9b; }

.flow { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; counter-reset: step; }
.flow-step { position: relative; padding: 1rem 1.05rem; border-radius: 16px; background: rgba(255,255,255,.035); border: 1px solid var(--line); }
.flow-step .ico { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: rgba(77,141,255,.16); color: #8fb6ff; margin-bottom: .7rem; }
.flow-step .ico svg { width: 17px; height: 17px; }
.flow-step h4 { font-size: .9rem; font-weight: 700; margin-bottom: .25rem; }
.flow-step p { font-size: .8rem; color: var(--ink-soft); }

/* ------------------------------------------------------------ login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.login-card { width: min(420px, 100%); padding: 2.4rem 2.2rem 2rem; }
.login-logo { display: flex; justify-content: center; margin-bottom: 1.6rem; }
.login-logo img { height: 56px; border-radius: 14px; background: #011c31; padding: 8px 12px; box-shadow: 0 0 0 1px var(--line-2), 0 12px 30px rgba(0,0,0,.35); }
.login-card h1 { font-size: 1.45rem; font-weight: 750; text-align: center; }
.login-card .lead { text-align: center; color: var(--ink-soft); font-size: .9rem; margin: .4rem 0 1.6rem; }
.login-card .btn { width: 100%; margin-top: .5rem; padding: .85rem; }
.login-alert {
  display: flex; gap: .6rem; align-items: center; padding: .75rem .95rem; border-radius: 14px; margin-bottom: 1.1rem; font-size: .87rem;
  background: rgba(239,90,90,.12); border: 1px solid rgba(239,90,90,.35); color: #ffc0c0;
}
.login-alert.info { background: rgba(75,200,232,.1); border-color: rgba(75,200,232,.3); color: #bdeefa; }
.login-alert svg { width: 17px; height: 17px; flex-shrink: 0; }
.login-foot { text-align: center; font-size: .76rem; color: var(--ink-soft); margin-top: 1.5rem; opacity: .8; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 3rem; }
.pw-toggle { position: absolute; right: .45rem; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; background: transparent; color: var(--ink-soft); cursor: pointer; border-radius: 10px; display: grid; place-items: center; }
.pw-toggle:hover { color: var(--ink); background: rgba(255,255,255,.06); }
.pw-toggle svg { width: 17px; height: 17px; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-layout { grid-template-columns: 1fr; }
  .preview { position: static; }
  .flow { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-col-alerts { order: -1; position: static; }
  .auto-grid { grid-template-columns: 1fr; }
  .user-meta { display: none; }
  .brand-text { display: none; }
  .topbar-inner { gap: .8rem; padding: 0 1rem; }
  .nav a { padding: .5rem .7rem; }
  .auto-hero { grid-template-columns: 1fr; }
  .auto-switch { align-items: flex-start; flex-direction: row; }
  .auto-switch .help { text-align: left; }
  .dash-empty-hero { grid-template-columns: 1fr; text-align: left; }
  /* tabla → tarjetas */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: .8rem 1.1rem; border-bottom: 1px solid var(--line); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td { border: 0; padding: .3rem 0 !important; text-align: left !important; display: flex; gap: .8rem; }
  .table td::before { content: attr(data-label); flex: 0 0 96px; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); padding-top: .15rem; }
  .table td > * { min-width: 0; }
}
@media (max-width: 640px) {
  .shell { padding: 1.4rem 1rem 3rem; }
  .page-head h1 { font-size: 1.5rem; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-hero { grid-column: 1 / -1; }
  .survey-grid { grid-template-columns: 1fr; }
  .field-row, .threshold { grid-template-columns: 1fr; }
  .q-head { display: none; }
  .q-row { grid-template-columns: 24px 1fr auto; }
  .q-row .q-tools { grid-column: 3; grid-row: 1; }
  .q-row .q-etiqueta { grid-column: 2 / -1; grid-row: 2; }
  .cat-row, .cat-scale { grid-template-columns: 90px 1fr auto; gap: .6rem; }
  .run-stats { grid-template-columns: 1fr 1fr 1fr; }
  .flow { grid-template-columns: 1fr; }
  .nav a span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
