/* =============================================================================
   OTS Discovery — design system extracted from mockup v2.
   Mobile-first. Desktop wraps the mobile canvas in a dark showcase.
   ============================================================================= */

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-font-smoothing: antialiased; }

:root {
  /* Primary brand yellow — matches the Brand Makers logo (#FFD22F).
     Source: docs/logo/SVG_BrandMakers_Logo_Color.svg, .st0 fill. */
  --bm-yellow:       #FFD22F;
  --bm-yellow-dark:  #D9AB00; /* hover / pressed — ~20% darker than primary */
  --bm-yellow-soft:  #FFEFA8; /* mid tint */
  --bm-yellow-tint:  #FFF8DA; /* lightest tint, ~96% L */
  --bm-black:        #0A0A0A;
  --bm-dark:         #1A1A1A;
  --bm-gray-1:       #2A2A2A;
  --bm-gray-2:       #555555;
  --bm-gray-3:       #999999;
  --bm-light:        #F5F5F5;
  --bm-line:         #ECECEC;
  --bm-white:        #FFFFFF;

  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-xl:   24px;

  --canvas-max:  480px;
}

html, body { height: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bm-white);
  color: var(--bm-black);
  line-height: 1.5;
  min-height: 100dvh;
}

button, input, textarea, select { font-family: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }

/* ----- App canvas: full screen on mobile, framed on desktop ----- */

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bm-white);
}

@media (min-width: 720px) {
  /* Tablet stays white edge-to-edge — we used to wrap the mobile canvas
     in a dark "phone on a stage" frame here, but it caused a jarring
     transition between mobile (white) and desktop (white) when the
     browser was resized through the 720–1023 range. The dark mockup
     metaphor is kept only as a design artifact in docs/.
     The content frames cap themselves below so a 1000px-wide tablet
     doesn't sprawl a 1000px-wide question column. */
  body { padding: 24px 0; }
}

/* Tablet content caps — keep .frame-welcome / .frame-start / .reactive from
   sprawling across the full viewport on a wide tablet. Desktop (>=1024px)
   redefines these with its own max-widths further below. */
@media (min-width: 720px) {
  .frame-welcome,
  .frame-start,
  .reactive {
    max-width: 640px;
    margin: 0 auto;
    width: 100%;
  }
}

/* Admin variant: full-width canvas (no phone frame). Used by /admin/*. */

.app-shell.app-shell--full {
  max-width: 100%;
  border-radius: 0;
  box-shadow: none;
  background: var(--bm-light);
  min-height: 100dvh;
}

body:has(.app-shell--full) {
  background: var(--bm-light);
  padding: 0;
}

/* =============================================================================
   TOPBAR (desktop client header)
   ============================================================================= */

.topbar {
  display: none;
  background: var(--bm-white);
  padding: 14px 28px;
  border-bottom: 1px solid var(--bm-line);
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.topbar--dark {
  background: var(--bm-black);
  border-bottom-color: var(--bm-gray-1);
  color: var(--bm-white);
}

@media (min-width: 720px) {
  .topbar { display: flex; }
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-logo-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.topbar-logo {
  display: block;
  height: 28px;
  width: auto;
  /* Logo is ~5:1, so 28px tall → ~140px wide. Keeps the topbar compact. */
}

.topbar-name {
  font-weight: 700;
  font-size: 14px;
}
.topbar-name .topbar-sub {
  display: block;
  font-size: 10px;
  color: var(--bm-gray-3);
  font-weight: 400;
}

.user-menu {
  position: relative;
  display: inline-block;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--bm-gray-2);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 10px 6px 12px;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
  font-family: inherit;
}
.topbar-user:hover,
.topbar-user[aria-expanded="true"] {
  background: var(--bm-light);
  color: var(--bm-black);
}
.topbar-user:hover .topbar-avatar,
.topbar-user[aria-expanded="true"] .topbar-avatar {
  box-shadow: 0 0 0 2px var(--bm-black);
}
.topbar--dark .topbar-user:hover,
.topbar--dark .topbar-user[aria-expanded="true"] {
  background: var(--bm-gray-1);
  color: var(--bm-white);
}
.topbar-avatar { transition: box-shadow 0.15s ease; }

/* Dropdown popover anchored to the user avatar */
.user-menu-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: var(--bm-white);
  border: 1px solid var(--bm-line);
  border-radius: 12px;
  padding: 6px;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.12),
    0 2px 6px rgba(0, 0, 0, 0.08);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: ots-fade-in 0.15s ease;
}

.user-menu-popover[hidden] { display: none; }

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--bm-black);
  text-decoration: none;
  cursor: pointer;
  /* Reset for <button> use — keeps the visual identical between <a> and <button>. */
  background: transparent;
  border: 0;
  text-align: left;
  font-family: inherit;
}
.user-menu-item:hover {
  background: var(--bm-yellow-tint);
}
.user-menu-item--danger {
  color: #b91c1c;
  border-top: 1px solid var(--bm-line);
  margin-top: 4px;
  padding-top: 12px;
}
.user-menu-item--danger:hover {
  background: #fee2e2;
}
.user-menu-icon {
  display: inline-flex;
  width: 20px;
  justify-content: center;
  font-size: 14px;
}

/* ---------- Profile modal ---------- */

.modal-loading {
  padding: 32px;
  text-align: center;
  color: var(--bm-gray-2);
  font-size: 13px;
}

.profile-meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
}
.profile-meta-key {
  display: inline-block;
  min-width: 72px;
  color: var(--bm-gray-2);
  font-weight: 600;
  margin-right: 8px;
}

.topbar--dark .topbar-user { color: var(--bm-gray-3); }

.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bm-yellow);
  color: var(--bm-black);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

/* =============================================================================
   ADMIN DASHBOARD
   ============================================================================= */

.admin-tabs {
  display: flex;
  gap: 4px;
  background: var(--bm-white);
  padding: 0 28px;
  border-bottom: 1px solid var(--bm-line);
  overflow-x: auto;
}

.admin-tab {
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--bm-gray-2);
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}

.admin-tab.active {
  color: var(--bm-black);
  border-bottom-color: var(--bm-yellow);
  font-weight: 700;
}

/* Admin content fills the available screen width. Tables inside use 100%
   of this area so big monitors don't waste space. */
.admin-main { padding: 24px 32px; width: 100%; }

.admin-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.admin-title h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--bm-black);
  margin-bottom: 4px;
}
.admin-title .subtitle { font-size: 13px; color: var(--bm-gray-2); }

.admin-filters { display: flex; gap: 8px; flex-wrap: wrap; }

.admin-filter-btn {
  padding: 8px 14px;
  background: var(--bm-white);
  border: 1px solid var(--bm-line);
  border-radius: 6px;
  font-size: 12px;
  color: var(--bm-black);
  font-weight: 600;
}

.admin-filter-btn.primary {
  background: var(--bm-black);
  color: var(--bm-white);
  border-color: var(--bm-black);
}

/* KPI grid */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

@media (min-width: 720px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
}

.kpi-card {
  background: var(--bm-white);
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--bm-line);
  border-top: 3px solid var(--bm-yellow);
}

.kpi-label {
  font-size: 11px;
  color: var(--bm-gray-2);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--bm-black);
  line-height: 1;
}

.kpi-meta {
  font-size: 11px;
  color: var(--bm-gray-2);
  margin-top: 6px;
}

.kpi-meta.up   { color: #166534; }
.kpi-meta.warn { color: #854d0e; }
.kpi-meta.down { color: #b91c1c; }

/* Two-panel grid: table left, archetype panel right */

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 1024px) {
  .dashboard-grid { grid-template-columns: 2fr 1fr; }
}

.panel {
  background: var(--bm-white);
  border-radius: 8px;
  border: 1px solid var(--bm-line);
  overflow: hidden;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--bm-line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.panel-title { font-size: 14px; font-weight: 700; color: var(--bm-black); }
.panel-link  { font-size: 11px; color: var(--bm-gray-2); font-weight: 600; }

/* Sucursales table */

.dtable { width: 100%; border-collapse: collapse; }

.dtable thead { background: var(--bm-light); }

.dtable th {
  padding: 10px 20px;
  text-align: left;
  font-size: 10px;
  color: var(--bm-gray-2);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  border-bottom: 1px solid var(--bm-line);
}

.dtable td {
  padding: 12px 20px;
  font-size: 13px;
  color: var(--bm-black);
  border-bottom: 1px solid var(--bm-light);
}

/* Numeric columns: right-aligned both in header and cells. Pair the class on
   BOTH <th> and <td> — otherwise the header reads left while the data reads
   right and the column looks broken. */
.dtable th.num,
.dtable td.num { text-align: right; font-weight: 600; }

/* Action columns (delete buttons, row menus) — right-align so the buttons
   line up with the row edge and match the header label. */
.dtable th.actions,
.dtable td.actions { text-align: right; }

.progress-mini {
  display: inline-block;
  width: 80px;
  height: 6px;
  background: var(--bm-line);
  border-radius: 3px;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 6px;
}

.progress-mini-fill {
  height: 100%;
  background: var(--bm-yellow);
  border-radius: 3px;
}

.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status-pill.completed { background: #dcfce7; color: #166534; }
.status-pill.active    { background: #fef3c7; color: #854d0e; }
.status-pill.pending   { background: #f1f5f9; color: #475569; }

/* Archetype distribution panel */

.archetypes { padding: 12px 20px; }

.archetype-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--bm-light);
}

.archetype-row:last-child { border-bottom: 0; }

.archetype-icon {
  width: 36px;
  height: 36px;
  background: #FAFAA0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.archetype-info { flex: 1; }

.archetype-name { font-size: 13px; font-weight: 700; color: var(--bm-black); }

.archetype-bar {
  height: 4px;
  background: var(--bm-line);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.archetype-fill { height: 100%; background: var(--bm-yellow); }

.archetype-pct {
  font-size: 13px;
  font-weight: 700;
  color: var(--bm-black);
  min-width: 36px;
  text-align: right;
}

/* ----- Subtle top eyebrow (logo + product tag) ----- */

.app-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--bm-gray-2);
  letter-spacing: 1.5px;
  padding: 22px 28px 0;
}

.app-eyebrow .yellow-dot {
  width: 8px;
  height: 8px;
  background: var(--bm-yellow);
  border-radius: 50%;
  flex-shrink: 0;
}

/* ----- Frame entrance animation (used by HTMX swapped sections) ----- */

@keyframes ots-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ots-frame {
  animation: ots-fade-in 0.4s ease;
}

/* =============================================================================
   FRAME — WELCOME / LANDING
   ============================================================================= */

.frame-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px 28px;
  text-align: center;
  gap: 24px;
}

.welcome-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 28px;
}

.welcome-illustration {
  width: 140px;
  height: 140px;
}

.welcome-illustration .circle-bg {
  width: 100%;
  height: 100%;
  background: var(--bm-yellow);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-illustration svg {
  width: 80px;
  height: 80px;
}

.welcome-greeting {
  font-size: 28px;
  font-weight: 800;
  color: var(--bm-black);
  line-height: 1.15;
  letter-spacing: -0.5px;
  max-width: 320px;
}

.welcome-subtext {
  font-size: 15px;
  color: var(--bm-gray-2);
  line-height: 1.5;
  max-width: 280px;
}

.btn-primary {
  width: 100%;
  padding: 18px;
  background: var(--bm-black);
  color: var(--bm-white);
  border-radius: var(--radius-lg);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary .arrow { font-size: 20px; color: var(--bm-yellow); line-height: 1; }

.btn-ghost {
  width: 100%;
  padding: 16px;
  background: transparent;
  color: var(--bm-black);
  border-radius: var(--radius-lg);
  font-size: 15px;
  font-weight: 600;
  border: 2px solid var(--bm-line);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}

.btn-ghost:hover { border-color: var(--bm-black); }

/* =============================================================================
   FRAME — START (invite code)
   ============================================================================= */

.frame-start {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 28px 28px;
  gap: 22px;
}

.start-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--bm-black);
  line-height: 1.15;
  letter-spacing: -0.5px;
}

.start-sub {
  font-size: 14px;
  color: var(--bm-gray-2);
  line-height: 1.5;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--bm-gray-2);
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.field-input {
  width: 100%;
  padding: 16px 18px;
  background: var(--bm-light);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  color: var(--bm-black);
  letter-spacing: 0.5px;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.field-input:focus {
  border-color: var(--bm-black);
  background: var(--bm-white);
}

.field-help { font-size: 12px; color: var(--bm-gray-3); }
.field-error { font-size: 12px; color: #c92a2a; }

.start-actions { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

/* =============================================================================
   PROGRESS — used by every block-level frame
   ============================================================================= */

.progress-bar {
  margin-bottom: 18px;
}

.progress-track {
  height: 4px;
  background: var(--bm-line);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--bm-yellow);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* Progress widths in 5% steps (used by .progress-fill since templ disallows
   expression-based style attributes). */
.w-0 { width: 0%; } .w-5 { width: 5%; } .w-10 { width: 10%; }
.w-15 { width: 15%; } .w-20 { width: 20%; } .w-25 { width: 25%; }
.w-30 { width: 30%; } .w-35 { width: 35%; } .w-40 { width: 40%; }
.w-45 { width: 45%; } .w-50 { width: 50%; } .w-55 { width: 55%; }
.w-60 { width: 60%; } .w-65 { width: 65%; } .w-70 { width: 70%; }
.w-75 { width: 75%; } .w-80 { width: 80%; } .w-85 { width: 85%; }
.w-90 { width: 90%; } .w-95 { width: 95%; } .w-100 { width: 100%; }

.progress-label {
  font-size: 10px;
  color: var(--bm-gray-3);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Common reactive layout */

.reactive {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 22px 24px 24px;
  background: var(--bm-white);
}

.q-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--bm-black);
  line-height: 1.2;
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}

.q-instruction {
  font-size: 13px;
  color: var(--bm-gray-2);
  margin-bottom: 18px;
  line-height: 1.4;
}

/* =============================================================================
   FRAME — R1 IMAGE GRID
   ============================================================================= */

.image-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  align-content: start;
}

.image-card {
  aspect-ratio: 1;
  background: var(--bm-light);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  border: 3px solid transparent;
}

.image-card .photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.image-card .photo-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.3) 35%, transparent 60%);
}

.image-card .img-label {
  position: absolute;
  bottom: 6px;
  left: 8px;
  right: 8px;
  z-index: 2;
  font-size: 10px;
  font-weight: 700;
  color: var(--bm-white);
  letter-spacing: 0.3px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.image-card .selection-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  background: var(--bm-yellow);
  color: var(--bm-black);
  font-weight: 900;
  font-size: 14px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3;
  border: 2px solid var(--bm-black);
}

.image-card.selected {
  border-color: var(--bm-yellow);
  box-shadow: 0 0 0 1px var(--bm-black), 0 4px 16px rgba(244, 243, 0, 0.5);
  transform: translateY(-2px);
}

.image-card.selected .selection-badge { display: flex; }

.reactive-cta {
  margin-top: 16px;
}

/* =============================================================================
   FRAME — STIMULUS (block 3 placeholders, kept for future use)
   ============================================================================= */

.stimulus-card {
  background: var(--bm-light);
  border-radius: var(--radius-lg);
  margin-bottom: 18px;
  overflow: hidden;
}

.emoji-row {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 18px;
}

.emoji-option {
  flex: 1;
  background: var(--bm-light);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.emoji-option .emoji { font-size: 22px; }
.emoji-option .label { font-size: 9px; color: var(--bm-gray-2); font-weight: 600; text-align: center; }
.emoji-option:hover, .emoji-option.selected {
  border-color: var(--bm-yellow);
  background: var(--bm-yellow-tint);
}
.emoji-option.selected {
  background: var(--bm-yellow);
  border-color: var(--bm-black);
}

/* =============================================================================
   FRAME — TOPICS GRID (R9)
   ============================================================================= */

.topics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  align-content: start;
}

.topic-card {
  background: var(--bm-light);
  border-radius: var(--radius-md);
  padding: 12px 6px;
  text-align: center;
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  min-height: 90px;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
}
.topic-card.selected { border-color: var(--bm-black); background: var(--bm-yellow); }
.topic-icon { font-size: 24px; }
.topic-label { font-size: 9px; font-weight: 700; color: var(--bm-black); line-height: 1.15; }
.topic-rank {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  background: var(--bm-black);
  color: var(--bm-yellow);
  font-weight: 900;
  font-size: 12px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bm-yellow);
}

/* =============================================================================
   FRAME — VOICE NOTE (block 4)
   ============================================================================= */

.voice-context {
  background: var(--bm-light);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 30px;
  border-left: 4px solid var(--bm-yellow);
}
.voice-scenario-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--bm-gray-2);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.voice-scenario-text { font-size: 15px; font-weight: 600; color: var(--bm-black); line-height: 1.4; }
.voice-recorder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  flex: 1;
  justify-content: center;
}
.record-button {
  width: 110px;
  height: 110px;
  background: var(--bm-yellow);
  border-radius: 50%;
  border: 4px solid var(--bm-black);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 8px 30px rgba(244, 243, 0, 0.4);
}
.record-button::before {
  content: "";
  width: 36px;
  height: 36px;
  background: var(--bm-black);
  border-radius: 50%;
}
.record-pulse {
  position: absolute;
  inset: -8px;
  border: 2px solid var(--bm-yellow);
  border-radius: 50%;
  animation: pulse 2s infinite;
  opacity: 0.5;
}
@keyframes pulse {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(1.15); opacity: 0; }
}
.voice-time {
  font-size: 32px;
  font-weight: 800;
  color: var(--bm-black);
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
}
.voice-status { font-size: 14px; color: var(--bm-gray-2); font-weight: 500; }
.voice-alt { font-size: 12px; color: var(--bm-gray-3); text-decoration: underline; cursor: pointer; }

/* =============================================================================
   FRAME — DELIVERY (after Discovery)
   ============================================================================= */

.frame-delivery {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 28px 28px 24px;
  background: var(--bm-black);
  color: var(--bm-white);
  position: relative;
  overflow: hidden;
}
.delivery-yellow-strip {
  position: absolute; top: 0; left: 0; width: 6px; height: 100%;
  background: var(--bm-yellow);
}
.delivery-label {
  font-size: 10px; font-weight: 700; color: var(--bm-yellow);
  letter-spacing: 2px; text-transform: uppercase; margin-bottom: 8px;
}
.delivery-archetype-name {
  font-size: 36px; font-weight: 900; color: var(--bm-yellow);
  line-height: 1.05; letter-spacing: -1px; margin-bottom: 14px;
}

/* =============================================================================
   ADMIN — Tenants list + onboarding form + Surveys catalog
   ============================================================================= */

.survey-pill {
  display: inline-block;
  padding: 3px 8px;
  background: var(--bm-light);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  color: var(--bm-gray-2);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-right: 4px;
}

.badge-premium {
  display: inline-block;
  padding: 2px 6px;
  background: var(--bm-yellow);
  color: var(--bm-black);
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
  margin-left: 6px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  vertical-align: middle;
}

.flash {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}
.flash--ok    { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.flash--error { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }

.form-card {
  background: var(--bm-white);
  border-radius: 8px;
  border: 1px solid var(--bm-line);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  max-width: 920px;
}

.form-section { display: flex; flex-direction: column; gap: 14px; }
.form-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--bm-gray-2);
}
.form-section-help { font-size: 13px; color: var(--bm-gray-2); }

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 720px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
}

.checkbox-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 720px) {
  .checkbox-row { grid-template-columns: 1fr 1fr; }
}

.checkbox-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bm-light);
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.checkbox-card:has(input:checked) {
  border-color: var(--bm-black);
  background: var(--bm-yellow-tint);
}

.checkbox-card input { margin-top: 2px; accent-color: var(--bm-black); }

.checkbox-title { font-weight: 700; font-size: 14px; color: var(--bm-black); margin-bottom: 4px; }
.checkbox-sub   { font-size: 12px; color: var(--bm-gray-2); }

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.form-actions .btn-primary,
.form-actions .btn-ghost { width: auto; min-width: 160px; }

.surveys-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 720px) {
  .surveys-grid { grid-template-columns: 1fr 1fr; }
}

.survey-card {
  background: var(--bm-white);
  border-radius: 12px;
  border: 1px solid var(--bm-line);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.survey-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.survey-card-title { font-size: 16px; font-weight: 800; color: var(--bm-black); }
.survey-card-desc { font-size: 13px; color: var(--bm-gray-2); line-height: 1.5; }

.survey-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  font-size: 12px;
}
.survey-meta dt { color: var(--bm-gray-2); }
.survey-meta dd { color: var(--bm-black); font-weight: 600; }

/* =============================================================================
   Tenants table — extended columns
   ============================================================================= */

.panel--scroll-x { overflow-x: auto; }
.dtable--wide { min-width: 1100px; width: 100%; }

.cell-sub {
  display: block;
  font-size: 11px;
  color: var(--bm-gray-2);
  margin-top: 2px;
  font-weight: 400;
}

.code-pill {
  display: inline-block;
  padding: 2px 8px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  background: var(--bm-light);
  border-radius: 4px;
  color: var(--bm-gray-2);
}

.code-link {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--bm-black);
  text-decoration: none;
  border-bottom: 1px dashed var(--bm-gray-3);
}
.code-link:hover {
  color: #c9a700;
  border-bottom-color: var(--bm-yellow);
}

/* =============================================================================
   Users list — rows, role badges, back link
   ============================================================================= */

.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-row-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bm-yellow);
  color: var(--bm-black);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}

.role-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bm-light);
  color: var(--bm-gray-2);
}
.role-badge--admin   { background: var(--bm-black); color: var(--bm-yellow); }
.role-badge--support { background: #1e3a8a; color: #dbeafe; }
.role-badge--rh      { background: #166534; color: #dcfce7; }
.role-badge--leader  { background: #854d0e; color: #fef3c7; }
.role-badge--subject { background: #f1f5f9; color: #475569; }

.back-link {
  display: inline-block;
  font-size: 12px;
  color: var(--bm-gray-2);
  text-decoration: none;
  margin-bottom: 6px;
}
.back-link:hover { color: var(--bm-black); }

/* =============================================================================
   Modal — overlay panel for forms (Nuevo usuario, etc.)
   ============================================================================= */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: ots-fade-in 0.15s ease;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.5);
  backdrop-filter: blur(2px);
}

.modal-panel {
  position: relative;
  background: var(--bm-white);
  border-radius: 16px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.35),
    0 4px 12px rgba(0, 0, 0, 0.15);
  max-height: calc(100vh - 40px);
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal--sm .modal-panel { max-width: 480px; }
.modal--md .modal-panel { max-width: 640px; }
.modal--lg .modal-panel { max-width: 920px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--bm-line);
  flex-shrink: 0;
}

.modal-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--bm-black);
  letter-spacing: -0.2px;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--bm-gray-2);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}
.modal-close:hover {
  background: var(--bm-light);
  color: var(--bm-black);
}

.modal-body {
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

/* Form when rendered inside a modal — no extra padding (modal has its own). */
.form-card--flat {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 24px;
  max-width: none;
  box-shadow: none;
}

/* Bare-button styled like a link, for inline triggers ("Crea el primero →"). */
.link-button {
  background: transparent;
  border: none;
  color: var(--bm-black);
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
}

.badge-tenant {
  display: inline-block;
  padding: 2px 6px;
  background: var(--bm-light);
  color: var(--bm-gray-2);
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
  margin-left: 6px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  vertical-align: middle;
}

/* =============================================================================
   Settings / catalog UI — multiselect dropdown + settings page
   ============================================================================= */

.multiselect {
  position: relative;
  margin-top: 6px;
}
.multiselect-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--bm-line);
  border-radius: 10px;
  background: var(--bm-white);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--bm-black);
  text-align: left;
  transition: border-color .12s ease;
}
.multiselect-trigger:hover { border-color: var(--bm-gray-3); }
.multiselect-trigger[aria-expanded="true"] {
  border-color: var(--bm-yellow-dark);
  box-shadow: 0 0 0 3px var(--bm-yellow-tint);
}
.multiselect-summary { flex: 1; }
.multiselect-summary--empty { color: var(--bm-gray-3); font-weight: 400; }
.multiselect-caret {
  color: var(--bm-gray-2);
  font-size: 11px;
  transition: transform .12s ease;
}
.multiselect-trigger[aria-expanded="true"] .multiselect-caret { transform: rotate(180deg); }

.multiselect-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 60;
  background: var(--bm-white);
  border: 1px solid var(--bm-line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12), 0 2px 6px rgba(0,0,0,.06);
  max-height: 320px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.multiselect-panel[hidden] { display: none; }
.multiselect-search {
  padding: 10px;
  border-bottom: 1px solid var(--bm-line);
}
.multiselect-search input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--bm-line);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bm-light);
}
.multiselect-search input:focus {
  outline: none;
  background: var(--bm-white);
  border-color: var(--bm-yellow-dark);
}
.multiselect-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  flex: 1;
}
.multiselect-option { padding: 0; }
.multiselect-option[hidden] { display: none; }
.multiselect-option label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.multiselect-option label:hover { background: var(--bm-yellow-tint); }
.multiselect-option input { margin: 0; }
.multiselect-option:has(input:checked) label { background: var(--bm-yellow-tint); }

.inline-link {
  color: var(--bm-black);
  font-weight: 600;
  text-decoration: underline;
}

/* =============================================================================
   Pagination — table footer with info + nav + page-size selector
   ============================================================================= */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-top: 1px solid var(--bm-line);
  background: var(--bm-white);
  border-radius: 0 0 12px 12px;
  flex-wrap: wrap;
}
.pagination-info {
  font-size: 12px;
  color: var(--bm-gray-2);
}
.pagination-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--bm-black);
  background: transparent;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
}
.pagination-btn:hover {
  background: var(--bm-yellow-tint);
  border-color: var(--bm-line);
}
.pagination-btn.disabled {
  color: var(--bm-gray-3);
  cursor: not-allowed;
  pointer-events: none;
}
.pagination-current {
  padding: 0 10px;
  font-size: 12px;
  color: var(--bm-gray-2);
  font-weight: 600;
}
.pagination-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pagination-size-label {
  font-size: 12px;
  color: var(--bm-gray-2);
  margin-right: 6px;
}
.pagination-size-select {
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--bm-line);
  border-radius: 6px;
  background: var(--bm-white);
  font-family: inherit;
}

/* Sub-nav scoped to /admin/settings/* — looks like top admin tabs but lives
   inside the page so the active catalog is obvious without losing the global
   topbar context. */
.subnav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--bm-line);
  margin: 14px 0 8px 0;
  overflow-x: auto;
}
.subnav-tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--bm-gray-2);
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.subnav-tab:hover {
  color: var(--bm-black);
}
.subnav-tab.active {
  color: var(--bm-black);
  border-bottom-color: var(--bm-yellow);
  font-weight: 700;
}
.subnav-tab--disabled {
  color: var(--bm-gray-3);
  cursor: not-allowed;
}
.subnav-tab--disabled:hover { color: var(--bm-gray-3); }

.badge-soon {
  display: inline-block;
  padding: 2px 6px;
  background: var(--bm-light);
  color: var(--bm-gray-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  border-radius: 4px;
}

.settings-section { margin-top: 24px; }
.settings-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 14px;
}
.settings-section-header h2 {
  font-size: 18px;
  margin: 0 0 4px 0;
}

.settings-inline-form {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--bm-line);
  border-radius: 12px;
}

/* Inline action button — overrides .btn-ghost's full-width defaults so it
   fits naturally inside table cells, row toolbars or sentence flow. */
.btn-ghost--sm {
  width: auto;
  display: inline-flex;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  min-height: 0;
  border-width: 1px;
  border-radius: 6px;
  vertical-align: middle;
}
.btn-ghost--sm + .btn-ghost--sm { margin-left: 6px; }

.btn-ghost--danger {
  color: #b91c1c;
  border-color: #fecaca;
}
.btn-ghost--danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

/* =============================================================================
   DESKTOP RESPONSIVE LAYER — OTS Discovery flow (subject experience).
   Tablet (>=720px) wraps a 480px canvas in a dark showcase. At >=1024px we
   leave that "card on a stage" metaphor behind and switch to a real laptop
   layout: white edge-to-edge, side-by-side hero, content max-width on the
   reactives. Does NOT touch .app-shell--full (used by /admin/*).
   ============================================================================= */

@media (min-width: 1024px) {
  /* Drop the dark stage + framed-card look. The subject sees a normal
     white desktop app, not a phone screen scaled up. */
  body:not(:has(.app-shell--full)) {
    background: var(--bm-white);
    padding: 0;
  }
  .app-shell:not(.app-shell--full) {
    max-width: 100%;
    border-radius: 0;
    box-shadow: none;
    min-height: 100dvh;
  }

  /* Common content max-width for all subject frames so a 1600px monitor
     doesn't end up with a 1600px-wide text column. The frames center
     themselves within the viewport. */
  .frame-welcome,
  .frame-start,
  .reactive {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
  }

  /* ---- Welcome: side-by-side hero (illustration left, copy right) ---- */
  .frame-welcome {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    text-align: left;
    gap: 80px;
    padding: 96px 56px;
    min-height: calc(100dvh - 64px); /* topbar height */
  }
  .welcome-illustration {
    flex-shrink: 0;
    width: 320px;
    height: 320px;
  }
  .welcome-illustration svg { width: 160px; height: 160px; }
  .welcome-content {
    flex: 0 1 520px;
    align-items: flex-start;
    text-align: left;
    gap: 28px;
  }
  .welcome-greeting {
    font-size: 44px;
    line-height: 1.1;
    max-width: none;
  }
  .welcome-subtext {
    font-size: 17px;
    max-width: none;
  }
  .frame-welcome .btn-primary {
    width: auto;
    align-self: flex-start;
    padding: 16px 32px;
  }

  /* ---- Start: centered form, comfortable vertical space ---- */
  .frame-start {
    max-width: 520px;
    padding: 96px 24px 80px;
    gap: 28px;
  }
  .start-title { font-size: 32px; }
  .start-sub   { font-size: 15px; }
  .start-actions {
    flex-direction: row;
    justify-content: flex-end;
    margin-top: 8px;
  }
  .start-actions .btn-primary { width: auto; padding: 14px 28px; }
  .start-actions .btn-ghost   { width: auto; padding: 14px 20px; }

  /* ---- Reactives (discovery questions) ---- */
  .reactive { padding: 56px 64px 64px; max-width: 960px; }

  .q-title       { font-size: 30px; line-height: 1.15; margin-bottom: 10px; }
  .q-instruction { font-size: 15px; margin-bottom: 28px; }

  /* Image-pick grid: mobile 2 cols -> desktop 5 in one row. */
  .image-grid { grid-template-columns: repeat(5, 1fr); gap: 12px; }
  .image-card .img-label       { font-size: 12px; bottom: 10px; left: 12px; right: 12px; }
  .image-card .selection-badge { width: 32px; height: 32px; font-size: 16px; top: 10px; right: 10px; }

  /* Topics grid stays 3-col, tiles get roomier so icons aren't stranded. */
  .topics-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .topic-card  { padding: 22px 12px; min-height: 130px; gap: 12px; }
  .topic-icon  { font-size: 36px; }
  .topic-label { font-size: 12px; }

  .emoji-row    { gap: 12px; }
  .emoji-option { padding: 18px 10px; }
  .emoji-option .emoji { font-size: 32px; }
  .emoji-option .label { font-size: 11px; }

  .voice-context       { padding: 24px 28px; margin-bottom: 36px; }
  .voice-scenario-text { font-size: 17px; }
  .voice-recorder      { gap: 24px; }

  /* CTAs: never render a viewport-wide black bar on desktop. */
  .reactive-cta { margin-top: 28px; display: flex; justify-content: center; }
  .reactive-cta .btn-primary,
  .reactive-cta .btn-ghost { max-width: 320px; }

  /* Progress bar reads better with a touch more space below it. */
  .progress-bar   { padding-bottom: 8px; }
  .progress-label { font-size: 12px; }
}

