/* =====================================================================
   DoctorFirm · sistema de diseño con la marca ESSALUDNET
   Aqua de la cruz del logo (#00C8D0) + azul marino del texto (#00477A),
   con un degradado aqua → verde menta. Temas: día, noche y automático.
   ===================================================================== */
:root {
  /* Marca (fija en ambos temas) */
  --brand: #00C8D0;
  --brand-mint: #19D3A2;
  --brand-navy: #00477A;
  --grad: linear-gradient(135deg, #00C8D0 0%, #13CFB0 55%, #2AD69A 100%);
  --grad-deep: linear-gradient(135deg, #00A9B3 0%, #0FB394 100%);

  /* Día */
  --bg: #F1F9FA;
  --bg-glow: radial-gradient(1200px 500px at 85% -10%, rgba(0, 200, 208, .14), transparent 60%),
             radial-gradient(900px 420px at -10% 110%, rgba(25, 211, 162, .10), transparent 60%);
  --surface: #FFFFFF;
  --surface-2: #E9F6F7;
  --surface-3: #F6FBFC;
  --border: #D6E8EC;
  --text: #0A2540;
  --text-2: #476175;
  --text-3: #8BA2B0;
  --accent: #00838F;          /* texto/enlaces sobre blanco (AA) */
  --accent-strong: #006D77;
  --accent-soft: #DDF7F7;
  --on-brand: #00303F;        /* texto sobre aqua (contraste ~7:1) */
  --ok: #0E9F6E;   --ok-soft: #DCF7EC;
  --warn: #B45309; --warn-soft: #FEF3C7;
  --bad: #C2302F;  --bad-soft: #FDE7E7;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(10, 37, 64, .05);
  --shadow: 0 1px 2px rgba(10, 37, 64, .04), 0 8px 24px -8px rgba(10, 37, 64, .10);
  --shadow-brand: 0 10px 30px -10px rgba(0, 168, 179, .55);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", monospace;
  color-scheme: light;
}

/* Noche: definido una vez y aplicado por preferencia del sistema o por elección del usuario */
:root[data-theme="dark"] {
  --bg: #061823;
  --bg-glow: radial-gradient(1100px 520px at 85% -10%, rgba(0, 200, 208, .16), transparent 60%),
             radial-gradient(900px 420px at -10% 110%, rgba(25, 211, 162, .10), transparent 60%);
  --surface: #0B2230;
  --surface-2: #10303F;
  --surface-3: #0D2735;
  --border: #1A3D4E;
  --text: #E4F4F7;
  --text-2: #9CB8C6;
  --text-3: #6A8898;
  --accent: #3FDDE3;
  --accent-strong: #7CE9ED;
  --accent-soft: #0E3B47;
  --on-brand: #00262F;
  --ok: #34D399;   --ok-soft: #0B3B2E;
  --warn: #FBBF24; --warn-soft: #3A2A07;
  --bad: #F87171;  --bad-soft: #3D1414;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .6);
  --shadow-brand: 0 10px 30px -10px rgba(0, 200, 208, .45);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #061823;
    --bg-glow: radial-gradient(1100px 520px at 85% -10%, rgba(0, 200, 208, .16), transparent 60%),
               radial-gradient(900px 420px at -10% 110%, rgba(25, 211, 162, .10), transparent 60%);
    --surface: #0B2230; --surface-2: #10303F; --surface-3: #0D2735; --border: #1A3D4E;
    --text: #E4F4F7; --text-2: #9CB8C6; --text-3: #6A8898;
    --accent: #3FDDE3; --accent-strong: #7CE9ED; --accent-soft: #0E3B47; --on-brand: #00262F;
    --ok: #34D399; --ok-soft: #0B3B2E; --warn: #FBBF24; --warn-soft: #3A2A07; --bad: #F87171; --bad-soft: #3D1414;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .6);
    --shadow-brand: 0 10px 30px -10px rgba(0, 200, 208, .45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); background-image: var(--bg-glow); background-attachment: fixed; color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; transition: background-color .25s, color .25s; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-family: var(--font-display); letter-spacing: -.015em; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.12rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--accent); }
h1:focus { outline: none; }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); letter-spacing: .04em; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
::selection { background: color-mix(in srgb, var(--brand) 35%, transparent); }

/* Iconos: tamaño fijo y discreto */
svg.i { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.verdict svg.i { width: 26px; height: 26px; }
.drop svg.icon { width: 30px; height: 30px; }

/* ---------- Estructura ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side { background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(14px); border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 3px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 22px; }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; background: var(--grad); display: grid; place-items: center; box-shadow: var(--shadow-brand); flex: none; }
.brand-mark svg { width: 22px; height: 22px; }
.brand-name { font-family: var(--font-display); font-weight: 750; font-size: 1.12rem; letter-spacing: -.02em; line-height: 1.1; }
.brand-name small { display: block; font-size: .68rem; font-weight: 600; color: var(--text-3); letter-spacing: .06em; text-transform: uppercase; }
.nav-label { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); padding: 14px 12px 6px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text-2); text-decoration: none; font-weight: 550; transition: background .15s, color .15s; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-strong); }
.nav-item.active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--grad); }
.side-foot { margin-top: auto; padding: 12px 12px 2px; display: flex; flex-direction: column; gap: 2px; font-size: .74rem; color: var(--text-3); }
.side-foot a { color: var(--text-2); text-decoration: none; }
.side-foot a:hover { color: var(--accent); text-decoration: underline; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 32px; position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.topbar .spacer { flex: 1; }
.content { padding: 28px 32px 48px; max-width: 1120px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin-top: 6px; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }

/* Selector de tema (Día / Noche / Auto) */
.theme-switch { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.theme-switch button { border: 0; background: transparent; color: var(--text-2); width: 34px; height: 30px; border-radius: 999px; display: grid; place-items: center; cursor: pointer; transition: background .15s, color .15s; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button.on { background: var(--surface); color: var(--accent-strong); box-shadow: var(--shadow-sm); }
.theme-switch svg.i { width: 16px; height: 16px; }

/* Píldora de sesión */
.session { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; font-size: .86rem; font-weight: 550; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); text-decoration: none; box-shadow: var(--shadow-sm); }
.session .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.session.on { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.session.on .dot { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 22%, transparent); animation: pulse 2s infinite; }
.session .first { font-weight: 650; }
.session .rest { display: inline-block; max-width: 0; overflow: hidden; white-space: nowrap; vertical-align: bottom; opacity: 0; transition: max-width .3s ease, opacity .25s ease; }
.session:hover .rest, .session:focus .rest { max-width: 260px; opacity: 1; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--ok) 0%, transparent); } }

/* ---------- Componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid > .card + .card, .grid > .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-title { display: flex; align-items: center; gap: 10px; }
.chip-ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong); flex: none; }
.chip-ico.grad { background: var(--grad); color: var(--on-brand); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Héroe de bienvenida */
.hero { position: relative; overflow: hidden; border-radius: 22px; padding: 28px 30px; background: var(--grad); color: var(--on-brand); box-shadow: var(--shadow-brand); }
.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 260px; height: 260px; border-radius: 50%; background: rgba(255, 255, 255, .18); }
.hero::before { content: ""; position: absolute; right: 90px; bottom: -90px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.hero h1 { font-size: 1.9rem; }
.hero p { opacity: .85; margin-top: 6px; max-width: 520px; }
.hero .row { position: relative; z-index: 1; margin-top: 18px; }
.hero .btn { background: #FFFFFF; color: #00303F; border-color: transparent; }
.hero .btn.ghost-light { background: rgba(255, 255, 255, .22); color: #00303F; }

/* Estadísticas */
.stat-card { display: flex; align-items: center; gap: 14px; padding: 18px; }
.stat { display: flex; flex-direction: column; gap: 1px; }
.stat b { font-family: var(--font-display); font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: .8rem; color: var(--text-2); }

/* Accesos rápidos */
.quick { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; transition: transform .15s, border-color .15s, box-shadow .15s; }
.quick:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--brand) 55%, var(--border)); box-shadow: var(--shadow), var(--shadow-brand); }
.quick .go { margin-top: auto; font-size: .85rem; font-weight: 650; color: var(--accent); display: inline-flex; gap: 6px; align-items: center; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 9px 16px; border-radius: var(--radius-sm); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, transform .06s, box-shadow .15s, filter .15s; min-height: 40px; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--grad); border-color: transparent; color: var(--on-brand); box-shadow: var(--shadow-brand); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.05) saturate(1.1); }
.btn.big { padding: 14px 28px; font-size: 1.04rem; border-radius: 14px; min-height: 54px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn svg.i { width: 17px; height: 17px; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: .84rem; font-weight: 600; color: var(--text-2); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; min-height: 42px; width: 100%; transition: border-color .15s, box-shadow .15s, background .15s; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); }
input:focus, select:focus, textarea:focus { outline: none; background: var(--surface); border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 22%, transparent); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--brand); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 550; color: var(--text); cursor: pointer; }
textarea { min-height: 84px; resize: vertical; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .76rem; font-weight: 650; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.brand { background: var(--accent-soft); color: var(--accent-strong); }

.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: .9rem; display: flex; gap: 10px; align-items: flex-start; }
.alert.info { background: var(--accent-soft); color: var(--accent-strong); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }

/* Zona para soltar PDFs */
.drop { position: relative; border: 2px dashed color-mix(in srgb, var(--brand) 45%, var(--border)); border-radius: var(--radius); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); padding: 34px 20px; text-align: center; transition: border-color .15s, background .15s, transform .15s; }
.drop:hover, .drop.over { border-color: var(--brand); background: color-mix(in srgb, var(--accent-soft) 80%, var(--surface)); transform: scale(1.005); }
.drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.drop .drop-ico { width: 60px; height: 60px; margin: 0 auto 12px; border-radius: 18px; background: var(--grad); color: var(--on-brand); display: grid; place-items: center; box-shadow: var(--shadow-brand); }
.drop strong { display: block; font-size: 1.08rem; margin-bottom: 4px; }

.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border); }
.doc-list li:last-child { border-bottom: none; }
.doc-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.doc-ico { width: 36px; height: 36px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); display: grid; place-items: center; font-size: .62rem; font-weight: 800; flex: none; }

.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--grad); transition: width .2s; border-radius: 999px; }

.rx-item { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 10px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-3); position: relative; }
.rx-item .num { position: absolute; left: -10px; top: -10px; width: 24px; height: 24px; border-radius: 50%; background: var(--grad); color: var(--on-brand); font-size: .75rem; font-weight: 800; display: grid; place-items: center; }
.rx-item .rm { position: absolute; top: 6px; right: 6px; }

/* Barra de acción fija (formularios largos) */
.action-bar { position: sticky; bottom: 16px; z-index: 4; margin-top: 18px; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 18px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(12px); border: 1px solid var(--border); box-shadow: var(--shadow); }

.verdict { display: flex; gap: 14px; align-items: flex-start; padding: 18px; border-radius: var(--radius); }
.verdict.ok { background: var(--ok-soft); color: var(--ok); }
.verdict.warn { background: var(--warn-soft); color: var(--warn); }
.verdict.bad { background: var(--bad-soft); color: var(--bad); }
.verdict p, .verdict h2 { color: inherit; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: .9rem; margin-top: 14px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; word-break: break-word; }

.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); margin-bottom: 18px; overflow-x: auto; max-width: 100%; }
.tab { padding: 8px 14px; border: none; background: none; font: inherit; font-weight: 600; color: var(--text-2); border-radius: 10px; cursor: pointer; white-space: nowrap; transition: background .15s, color .15s; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--accent-strong); box-shadow: var(--shadow-sm); }

.key-option { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; cursor: pointer; background: var(--surface-3); text-align: left; width: 100%; font: inherit; color: inherit; transition: border-color .15s, transform .1s, box-shadow .15s; }
.key-option:hover:not(:disabled) { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent); }
.key-option:disabled { opacity: .55; cursor: not-allowed; }
.key-option .grow { flex: 1; min-width: 0; }

.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.activity li:last-child { border-bottom: 0; }
.activity .what { flex: 1; min-width: 0; }
.activity .what b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

.empty { text-align: center; padding: 26px; color: var(--text-2); }
.fade-in { animation: fade .25s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

/* ---------- Celular: la barra lateral pasa a pestañas inferiores ---------- */
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .topbar { padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); gap: 8px; }
  .topbar .mobile-brand .label { display: none; }
  .theme-switch button { width: 30px; height: 28px; }
  .session { padding: 6px 10px; }
  .topbar .mobile-brand { display: flex; }
  .content { padding: 16px 16px 100px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-3.cols-1-mobile, .grid-2.cols-1-mobile { grid-template-columns: 1fr; }
  .rx-item { grid-template-columns: 1fr 1fr; }
  .rx-item > :first-of-type { grid-column: 1 / -1; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 6px; }
  .btn.big { width: 100%; }
  .hero { padding: 22px; }
  .hero h1 { font-size: 1.45rem; }
  .session .when { display: none; }
  .action-bar { bottom: 84px; }
}
.mobile-brand { display: none; align-items: center; gap: 8px; font-weight: 750; min-width: 0; }
@media (min-width: 421px) and (max-width: 760px) { .topbar .mobile-brand .label { display: inline; } }
.mobile-brand .brand-mark { width: 30px; height: 30px; border-radius: 9px; }
.mobile-brand .brand-mark svg { width: 18px; height: 18px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

#blazor-error-ui { background: var(--warn-soft); color: var(--warn); bottom: 0; display: none; left: 0; padding: .6rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
.status-bar-safe-area { display: none; }

/* ---------- Dictation (voice / photo → prescription) ---------- */
.dictation { border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); background: linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 55%, var(--surface)) 0%, var(--surface) 70%); }
.dictation-text { width: 100%; min-height: 84px; font-size: 1.02rem; line-height: 1.5; resize: vertical; }
.btn.rec { background: var(--bad); color: #fff; border-color: transparent; animation: rec-pulse 1.4s infinite; }
@keyframes rec-pulse { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--bad) 18%, transparent); } }
.btn.small { min-height: 32px; padding: 5px 12px; font-size: .86rem; }
label.btn.disabled { opacity: .5; pointer-events: none; }
.understood { margin-top: 12px; display: grid; gap: 8px; }
.understood-item { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); }
.understood-item .muted { margin-right: 2px; }
.ai-answer { white-space: pre-wrap; margin-top: 10px; padding: 12px; border-radius: 12px; background: var(--surface-2); font-size: .95rem; }
.progress > .indeterminate { width: 35%; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }

/* ---------- Medical data search ---------- */
.search { width: 100%; font-size: 1.02rem; }
.results { display: grid; gap: 8px; margin-top: 12px; }
.result { display: block; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); color: inherit; text-decoration: none; }
a.result:hover { background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface-2)); }
.result .badge { margin-left: 4px; }
@media (max-width: 640px) { .grid-4.cols-2-mobile { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Guided forms: collapsible steps, progressive fields, soft neon ---------- */
:root { --neon: rgba(0, 200, 208, .38); --neon-soft: rgba(0, 200, 208, .16); }
:root[data-theme="dark"] { --neon: rgba(63, 221, 227, .32); --neon-soft: rgba(63, 221, 227, .12); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) { --neon: rgba(63, 221, 227, .32); --neon-soft: rgba(63, 221, 227, .12); }
}

/* Soft neon on action buttons: a faint halo, never a strong glow */
.btn.primary { box-shadow: var(--shadow-brand), 0 0 0 1px var(--neon-soft), 0 0 14px var(--neon-soft); }
.btn.primary:hover:not(:disabled) { box-shadow: var(--shadow-brand), 0 0 0 1px var(--neon), 0 0 18px var(--neon); }
.btn.glow { box-shadow: var(--shadow-brand), 0 0 0 1px var(--neon), 0 0 16px var(--neon); }
.btn.pulse { animation: neon-breathe 2.6s ease-in-out infinite; }
@keyframes neon-breathe {
  0%, 100% { box-shadow: var(--shadow-brand), 0 0 0 1px var(--neon-soft), 0 0 10px var(--neon-soft); }
  50%      { box-shadow: var(--shadow-brand), 0 0 0 1px var(--neon), 0 0 22px var(--neon); }
}
@media (prefers-reduced-motion: reduce) { .btn.pulse { animation: none; } }

/* Progress */
.form-progress { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; }
.form-progress-track { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.form-progress-fill { height: 100%; border-radius: 999px; background: var(--grad); box-shadow: 0 0 10px var(--neon); transition: width .35s cubic-bezier(.2, .8, .2, 1); }
.form-progress .small { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Steps */
.step { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); margin-bottom: 10px; overflow: hidden; transition: border-color .2s, box-shadow .2s; }
.step.open { border-color: color-mix(in srgb, var(--brand) 55%, var(--border)); box-shadow: var(--shadow), 0 0 0 3px var(--neon-soft); }
.step-head { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.step-head:hover { background: var(--surface-3); }
.step-num { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .9rem; background: var(--surface-2); color: var(--text-2); transition: background .2s, color .2s, box-shadow .2s; }
.step.open .step-num { background: var(--grad); color: var(--on-brand); box-shadow: 0 0 12px var(--neon); }
.step.done:not(.open) .step-num { background: var(--ok-soft); color: var(--ok); }
.step-num .i { width: 16px; height: 16px; }
.step-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.step-title b { font-size: 1rem; }
.step-summary { font-size: .84rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step.done:not(.open) .step-summary { color: var(--text); }
.step-chevron { color: var(--text-3); transition: transform .2s; display: grid; }
.step-chevron .i { transform: rotate(90deg); }
.step.open .step-chevron { transform: rotate(180deg); }
.step-body { padding: 4px 16px 16px; animation: step-open .28s cubic-bezier(.2, .8, .2, 1) both; }
.step-foot { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
@keyframes step-open { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Fields appear one after another */
.reveal { animation: reveal .3s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes reveal { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .reveal, .step-body { animation: none; } }

/* A value the app filled for you (e.g. computed quantity) */
input.auto { border-color: color-mix(in srgb, var(--brand) 60%, var(--border)); background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }

/* ---------- Game-like start: signed / unsigned, then voice · photo · text ---------- */
.mode-chooser { text-align: center; padding: 8px 0 4px; }
.mode-q { font-family: var(--font-display); font-size: 1.45rem; margin: 6px 0 16px; }
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.mode-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 26px 18px 20px; border-radius: 22px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; text-align: center; cursor: pointer; box-shadow: var(--shadow); transition: transform .15s, box-shadow .2s, border-color .2s; }
.mode-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--brand) 55%, var(--border)); box-shadow: var(--shadow), 0 0 0 3px var(--neon-soft), 0 0 22px var(--neon-soft); }
.mode-card:active { transform: translateY(0) scale(.99); }
.mode-card.signed { border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); box-shadow: var(--shadow), 0 0 0 1px var(--neon-soft), 0 0 16px var(--neon-soft); }
.mode-ico { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent-strong); }
.mode-ico.grad { background: var(--grad); color: var(--on-brand); box-shadow: 0 0 18px var(--neon); }
.mode-ico .i { width: 30px; height: 30px; }
.mode-text { display: flex; flex-direction: column; gap: 4px; }
.mode-text b { font-size: 1.12rem; }
.mode-text span { color: var(--text-2); font-size: .9rem; line-height: 1.35; }
.mode-card .badge { position: absolute; top: 12px; right: 12px; }
.mode-pill { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.link-btn { background: none; border: 0; padding: 4px 6px; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.demo-note { margin-bottom: 14px; }

.input-chooser { text-align: center; padding: 6px 0 2px; }
.input-q { font-weight: 700; font-size: 1.05rem; margin: 0 0 14px; }
.input-row { display: grid; grid-template-columns: repeat(3, minmax(0, 132px)); justify-content: center; align-items: start; gap: 18px; }
.input-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; background: none; border: 0; color: var(--text); font: inherit; cursor: pointer; }
.input-btn .input-ico { width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--accent-strong); border: 1px solid var(--border); transition: transform .15s, box-shadow .2s; }
.input-btn:hover .input-ico { transform: translateY(-2px); box-shadow: 0 0 0 3px var(--neon-soft), 0 0 16px var(--neon-soft); }
.input-btn.voice .input-ico { width: 74px; height: 74px; background: var(--grad); color: var(--on-brand); border: 0; animation: neon-breathe-ring 2.8s ease-in-out infinite; }
.input-btn .input-ico .i { width: 30px; height: 30px; }
.input-btn b { font-size: .95rem; }
.input-btn.disabled { opacity: .5; pointer-events: none; }
@keyframes neon-breathe-ring { 0%, 100% { box-shadow: 0 0 0 0 var(--neon-soft), 0 0 12px var(--neon-soft); } 50% { box-shadow: 0 0 0 8px var(--neon-soft), 0 0 24px var(--neon); } }
@media (prefers-reduced-motion: reduce) { .input-btn.voice .input-ico { animation: none; } }

.step-kicker { font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.step.done:not(.open) .step-num { animation: pop .35s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes pop { from { transform: scale(.6); } to { transform: scale(1); } }
.speed-badge { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; padding: 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; box-shadow: 0 0 12px var(--neon-soft); }

@media (max-width: 640px) {
  .mode-grid { grid-template-columns: 1fr; }
  .mode-card { flex-direction: row; text-align: left; padding: 16px; }
  .mode-ico { width: 52px; height: 52px; flex: none; }
  .mode-card .badge { position: static; margin-left: auto; align-self: flex-start; }
}

/* ---------- Receta wizard: one question at a time, background shifts per question ---------- */
.wizard { --h: 180; position: relative; min-height: calc(100vh - 140px); margin: -8px -8px 0; padding: 18px 18px 28px; border-radius: 24px;
  background:
    radial-gradient(900px 420px at 85% -10%, color-mix(in srgb, hsl(var(--h) 85% 50%) 16%, transparent), transparent 65%),
    radial-gradient(700px 380px at -10% 110%, color-mix(in srgb, hsl(calc(var(--h) + 40) 80% 50%) 12%, transparent), transparent 65%),
    color-mix(in srgb, hsl(var(--h) 70% 50%) 5%, var(--bg));
  transition: background .7s ease; }
.wz-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wz-top .spacer { flex: 1; }
.wz-count { font-variant-numeric: tabular-nums; font-weight: 700; }
.wz-bar { height: 6px; border-radius: 999px; background: color-mix(in srgb, var(--surface-2) 80%, transparent); margin: 10px 0 6px; overflow: hidden; }
.wz-bar > div { height: 100%; border-radius: 999px; background: var(--grad); box-shadow: 0 0 10px var(--neon); transition: width .45s cubic-bezier(.2, .8, .2, 1); }
.wz-recap { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; margin: 8px 0 4px; }
.wz-chip { border: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 75%, transparent); color: var(--text-2); font: inherit; font-size: .78rem; padding: 4px 10px; border-radius: 999px; cursor: pointer; animation: reveal .3s both; }
.wz-chip:hover { color: var(--text); border-color: color-mix(in srgb, var(--brand) 50%, var(--border)); }
.wz-card { max-width: 680px; margin: 22px auto 0; padding: 26px 24px; border-radius: 24px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); border: 1px solid var(--border); box-shadow: var(--shadow), 0 0 0 1px var(--neon-soft); }
.wz-slide { animation: wz-in .38s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes wz-in { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .wz-slide, .wizard { animation: none; transition: none; } }
.wz-kicker { display: inline-block; font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.wz-q { font-family: var(--font-display); font-size: clamp(1.45rem, 4.2vw, 2rem); line-height: 1.2; margin: 6px 0 18px; }
.wz-input { width: 100%; font-size: 1.25rem; padding: 14px 16px; border-radius: 16px; min-height: 58px; }
textarea.wz-input { min-height: 110px; }
.wz-options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.wz-opt { border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 14px; cursor: pointer; transition: transform .12s, box-shadow .2s, border-color .2s; }
.wz-opt:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--brand) 55%, var(--border)); box-shadow: 0 0 0 3px var(--neon-soft); }
.wz-opt.on { background: var(--grad); color: var(--on-brand); border-color: transparent; box-shadow: 0 0 14px var(--neon); }
.wz-help { margin: 12px 0 0; color: var(--accent-strong); font-weight: 600; font-size: .92rem; display: flex; gap: 6px; align-items: center; }
.wz-error { margin: 10px 0 0; color: var(--bad); font-size: .9rem; display: flex; gap: 6px; align-items: center; }
.wz-nav { display: flex; align-items: center; gap: 10px; margin-top: 22px; }
.wz-nav .btn.primary { margin-left: auto; }
.wz-hint { margin: 8px 0 0; text-align: right; }
.i.flip { transform: rotate(180deg); }
.review { display: grid; gap: 8px; }
.review-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); cursor: pointer; transition: box-shadow .2s; }
.review-row:hover { box-shadow: 0 0 0 2px var(--neon-soft); }
.review-row > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.review-row .i { color: var(--accent); flex: none; margin-top: 2px; }
.result-card { text-align: center; }
.result-ico { width: 74px; height: 74px; margin: 0 auto 6px; border-radius: 50%; display: grid; place-items: center; background: var(--grad); color: var(--on-brand); box-shadow: 0 0 26px var(--neon); animation: pop .45s cubic-bezier(.2, 1.6, .4, 1) both; }
.result-ico .i { width: 36px; height: 36px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, #00141d 55%, transparent); backdrop-filter: blur(6px); }
.modal-card { position: relative; width: min(640px, 100%); padding: 26px 22px 22px; border-radius: 26px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow), 0 0 0 1px var(--neon-soft), 0 0 40px var(--neon-soft); }
.modal-x { position: absolute; top: 10px; right: 10px; }
.dictation .input-chooser + * { margin-top: 0; }
@media (max-width: 640px) {
  .wizard { margin: -4px -4px 0; padding: 12px 10px 90px; border-radius: 18px; }
  .wz-card { padding: 20px 16px; margin-top: 12px; }
  .wz-input { font-size: 1.1rem; }
  .desk-only { display: none !important; }
}

/* ---------- Signed / unsigned: black stage, faint white neon frames (same in day and night) ---------- */
.modal-backdrop { background: rgba(0, 0, 0, .82); backdrop-filter: blur(16px) saturate(1.1); -webkit-backdrop-filter: blur(16px) saturate(1.1); }
.modal-card { background: #000; border: 1px solid rgba(255, 255, 255, .55); box-shadow: 0 0 0 1px rgba(255, 255, 255, .08), 0 0 28px rgba(255, 255, 255, .14), inset 0 0 22px rgba(255, 255, 255, .04); color: #fff; }
.modal-card .modal-x { color: rgba(255, 255, 255, .7); }
.modal-card .modal-x:hover { background: rgba(255, 255, 255, .08); }
.modal-card .alert { background: rgba(255, 255, 255, .06); color: rgba(255, 255, 255, .85); border: 1px solid rgba(255, 255, 255, .2); }
.mode-chooser { text-align: center; padding: 10px 0 4px; }
.mode-q { font-family: var(--font-display); font-weight: 300; letter-spacing: .02em; font-size: clamp(1.3rem, 4vw, 1.75rem); margin: 4px 0 22px; color: #fff; }
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.mode-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 170px; padding: 22px 14px; border-radius: 20px;
  background: #000; color: #fff; font: inherit; cursor: pointer; border: 1px solid rgba(255, 255, 255, .5);
  box-shadow: 0 0 10px rgba(255, 255, 255, .12), inset 0 0 14px rgba(255, 255, 255, .04);
  transition: transform .15s, box-shadow .25s, border-color .25s; }
.mode-card:hover, .mode-card:focus-visible { outline: none; transform: translateY(-3px); border-color: rgba(255, 255, 255, .9);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .25), 0 0 26px rgba(255, 255, 255, .28), inset 0 0 18px rgba(255, 255, 255, .07); }
.mode-card:active { transform: scale(.98); }
.mode-card b { font-size: 1.15rem; font-weight: 600; letter-spacing: .03em; }
.mode-ico { width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; background: transparent; color: #fff;
  border: 1px solid rgba(255, 255, 255, .45); box-shadow: 0 0 14px rgba(255, 255, 255, .18); }
.mode-ico .i { width: 28px; height: 28px; }
@media (max-width: 640px) {
  .mode-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .mode-card { flex-direction: column; text-align: center; min-height: 140px; padding: 18px 10px; }
  .mode-ico { width: 54px; height: 54px; }
}

/* =====================================================================
   Immersive shell: ambient background, glass frame, page transitions,
   one reusable overlay (.immersive-backdrop + .immersive-sheet) and
   "stage" building blocks for every module. Later rules override above.
   ===================================================================== */
:root {
  --glass: rgba(255, 255, 255, .62);
  --glass-strong: rgba(255, 255, 255, .86);
  --glass-border: rgba(255, 255, 255, .8);
  --glass-line: rgba(10, 37, 64, .08);
  --sheet: #FFFFFF;
  --sheet-text: #0A2540;
  --scrim: rgba(240, 249, 250, .30);
  --amb-1: rgba(0, 200, 208, .30);
  --amb-2: rgba(25, 211, 162, .24);
  --amb-3: rgba(0, 71, 122, .14);
  --note: #E9F2F5; --note-text: #24435A;
}
:root[data-theme="dark"] {
  --glass: rgba(11, 34, 48, .58);
  --glass-strong: rgba(11, 34, 48, .86);
  --glass-border: rgba(124, 233, 237, .14);
  --glass-line: rgba(124, 233, 237, .10);
  --sheet: #0A1F2B;
  --sheet-text: #E4F4F7;
  --scrim: rgba(2, 12, 18, .45);
  --amb-1: rgba(0, 200, 208, .20);
  --amb-2: rgba(25, 211, 162, .13);
  --amb-3: rgba(0, 95, 160, .30);
  --note: #10303F; --note-text: #CFE6EE;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --glass: rgba(11, 34, 48, .58); --glass-strong: rgba(11, 34, 48, .86); --glass-border: rgba(124, 233, 237, .14); --glass-line: rgba(124, 233, 237, .10);
    --sheet: #0A1F2B; --sheet-text: #E4F4F7; --scrim: rgba(2, 12, 18, .45);
    --amb-1: rgba(0, 200, 208, .20); --amb-2: rgba(25, 211, 162, .13); --amb-3: rgba(0, 95, 160, .30);
    --note: #10303F; --note-text: #CFE6EE;
  }
}

/* Ambient: three soft blobs drifting slowly behind everything (aqua → mint → navy) */
body { background-image: none; }
.ambient { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; background: var(--bg); }
.ambient i { position: absolute; width: 75vmax; height: 75vmax; border-radius: 50%; }
.ambient i:nth-child(1) { top: -38vmax; right: -26vmax; background: radial-gradient(closest-side, var(--amb-1), transparent); animation: amb-a 42s ease-in-out infinite alternate; }
.ambient i:nth-child(2) { bottom: -40vmax; left: -28vmax; background: radial-gradient(closest-side, var(--amb-2), transparent); animation: amb-b 54s ease-in-out infinite alternate; }
.ambient i:nth-child(3) { top: 20vh; left: 30vw; width: 60vmax; height: 60vmax; background: radial-gradient(closest-side, var(--amb-3), transparent); animation: amb-c 66s ease-in-out infinite alternate; }
@keyframes amb-a { to { transform: translate(-14vmax, 12vmax) scale(1.12); } }
@keyframes amb-b { to { transform: translate(16vmax, -10vmax) scale(1.08); } }
@keyframes amb-c { to { transform: translate(-18vmax, -14vmax) scale(.9); } }

/* Glass frame */
.side { background: var(--glass); backdrop-filter: blur(22px) saturate(1.35); -webkit-backdrop-filter: blur(22px) saturate(1.35); border-right: 1px solid var(--glass-border); transition: opacity .35s ease, filter .35s ease; }
.topbar { background: color-mix(in srgb, var(--glass) 70%, transparent); backdrop-filter: blur(22px) saturate(1.35); -webkit-backdrop-filter: blur(22px) saturate(1.35); border-bottom: 1px solid var(--glass-line); }
.nav-item:hover { background: color-mix(in srgb, var(--surface) 55%, transparent); }
.nav-item.active { background: color-mix(in srgb, var(--accent-soft) 85%, transparent); box-shadow: 0 0 0 1px var(--neon-soft), 0 0 16px var(--neon-soft); }

/* Focus mode: while a one-question card is on screen, the sidebar steps back (hover brings it back) */
@media (min-width: 761px) {
  .shell:has(.wz-slide) .side { opacity: .42; filter: saturate(.5); }
  .shell:has(.wz-slide) .side:hover, .shell:has(.wz-slide) .side:focus-within { opacity: 1; filter: none; }
}

/* Page transition, keyed by route in MainLayout */
.page-enter { animation: page-in .42s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes page-in { from { opacity: 0; transform: translateY(12px); } }

/* Cards read as glass over the ambient background */
.card { background: var(--glass-strong); border-color: var(--glass-border); }
.glass { background: var(--glass); border: 1px solid var(--glass-border); border-radius: 22px; box-shadow: var(--shadow); }
.glass.strong { background: var(--glass-strong); }

/* Informational notes: neutral, never amber. Real errors stay red. */
.alert.warn, .alert.note { background: var(--note); color: var(--note-text); border: 1px solid var(--glass-line); }
.alert.warn svg.i, .alert.note svg.i { color: var(--accent); }
.badge.warn { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
#blazor-error-ui { background: var(--bad-soft); color: var(--bad); }

/* ---------- One reusable immersive overlay ---------- */
.immersive-backdrop { position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; padding: 16px;
  background: var(--scrim); backdrop-filter: blur(18px) saturate(1.15); -webkit-backdrop-filter: blur(18px) saturate(1.15);
  animation: im-fade .25s ease-out both; }
.immersive-sheet { position: relative; width: min(560px, 100%); max-height: min(92vh, 940px); overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 14px; padding: 26px 24px 22px; border-radius: 28px;
  background: var(--sheet); color: var(--sheet-text); border: 1px solid var(--border);
  box-shadow: 0 30px 80px -20px rgba(10, 37, 64, .38), 0 0 0 1px var(--neon-soft), 0 0 40px var(--neon-soft);
  animation: im-rise .38s cubic-bezier(.2, .8, .2, 1) both; }
.immersive-sheet:focus { outline: none; }
.immersive-sheet.wide { width: min(760px, 100%); }
.immersive-x { position: absolute; top: 10px; right: 10px; min-height: 36px; padding: 6px; color: var(--text-2); }
.immersive-kicker { font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.immersive-title { font-family: var(--font-display); font-size: clamp(1.3rem, 3.6vw, 1.7rem); line-height: 1.2; margin: 0 40px 0 0; }
.immersive-grab { display: none; }
@keyframes im-fade { from { opacity: 0; } }
@keyframes im-rise { from { opacity: 0; transform: translateY(22px) scale(.98); } }

/* ---------- Stage: one focused module, title + big action ---------- */
.stage { max-width: 920px; margin: 0 auto; }
.stage-head { text-align: center; margin: 6px auto 22px; max-width: 640px; }
.stage-head h1 { font-size: clamp(1.7rem, 4.6vw, 2.4rem); letter-spacing: -.025em; }
.stage-head .eyebrow { justify-content: center; }
.stage-sub { margin-top: 8px; color: var(--text-2); }
.stage-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* Big choice cards (Mi firma, etc.) */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
.choice { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 196px; padding: 26px 18px;
  border-radius: 26px; border: 1px solid var(--glass-border); background: var(--glass-strong); color: var(--text); font: inherit; text-align: center; cursor: pointer; text-decoration: none;
  box-shadow: var(--shadow); transition: transform .18s cubic-bezier(.2, .8, .2, 1), box-shadow .25s, border-color .25s; animation: reveal .4s cubic-bezier(.2, .8, .2, 1) both; }
.choice:nth-child(2) { animation-delay: .06s; } .choice:nth-child(3) { animation-delay: .12s; } .choice:nth-child(4) { animation-delay: .18s; }
.choice:hover, .choice:focus-visible { outline: none; transform: translateY(-4px); border-color: color-mix(in srgb, var(--brand) 60%, transparent); box-shadow: var(--shadow), 0 0 0 1px var(--neon), 0 0 28px var(--neon-soft); }
.choice:active { transform: scale(.985); }
.choice:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.choice b { font-size: 1.15rem; font-weight: 650; }
.choice small { color: var(--text-2); font-size: .85rem; margin-top: -8px; }
.choice-ico { width: 72px; height: 72px; border-radius: 24px; display: grid; place-items: center; background: var(--grad); color: var(--on-brand); box-shadow: 0 0 22px var(--neon); }
.choice-ico .i { width: 34px; height: 34px; }
.choice .badge { position: absolute; top: 12px; right: 12px; }
.choice-text { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

/* Collapsible drawer (<details>) */
.drawer { border-radius: 20px; background: var(--glass-strong); border: 1px solid var(--glass-border); box-shadow: var(--shadow-sm); overflow: hidden; }
.drawer + .drawer { margin-top: 12px; }
.drawer > summary { display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; list-style: none; font-weight: 650; }
.drawer > summary::-webkit-details-marker { display: none; }
.drawer > summary::after { content: ""; width: 9px; height: 9px; margin-left: auto; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(45deg); transition: transform .2s; flex: none; }
.drawer[open] > summary::after { transform: rotate(225deg); }
.drawer > summary:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.drawer > summary .muted { font-weight: 500; }
.drawer > summary .chip-ico { width: 34px; height: 34px; }
.drawer-body { padding: 4px 16px 16px; animation: step-open .28s cubic-bezier(.2, .8, .2, 1) both; }

/* Pill chips (tabs) */
.pills { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--glass-border); background: var(--glass-strong);
  color: var(--text-2); font: inherit; font-weight: 600; cursor: pointer; transition: color .15s, box-shadow .2s, background .2s, transform .12s; }
.pill:hover { color: var(--text); transform: translateY(-1px); }
.pill.on { background: var(--grad); color: var(--on-brand); border-color: transparent; box-shadow: 0 0 0 1px var(--neon-soft), 0 0 16px var(--neon); }
.pill svg.i { width: 16px; height: 16px; }
.pills.small .pill { padding: 6px 12px; font-size: .86rem; }

/* Big field (CAN, search…) */
.big-field { width: 100%; font-size: 1.3rem; padding: 16px 18px; min-height: 62px; border-radius: 18px; background: var(--glass-strong); border-color: var(--glass-border); box-shadow: var(--shadow-sm); }
.big-field:focus { box-shadow: 0 0 0 4px var(--neon-soft), 0 0 22px var(--neon-soft); }
.slide-in { animation: slide-in .38s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes slide-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Phones: the "Más" sheet and choice cards ---------- */
@media (max-width: 760px) {
  .immersive-backdrop { padding: 0; place-items: end stretch; }
  .immersive-sheet, .immersive-sheet.wide { width: 100%; max-height: 92vh; border-radius: 26px 26px 0 0; padding: 14px 16px calc(18px + env(safe-area-inset-bottom)); animation-name: im-up; }
  .immersive-grab { display: block; width: 44px; height: 5px; border-radius: 999px; background: var(--border); margin: 0 auto 2px; flex: none; }
  .choice-grid { grid-template-columns: 1fr; gap: 12px; }
  .choice { flex-direction: row; justify-content: flex-start; text-align: left; min-height: 0; padding: 16px; gap: 14px; border-radius: 22px; }
  .choice-ico { width: 56px; height: 56px; border-radius: 18px; flex: none; }
  .choice-ico .i { width: 28px; height: 28px; }
  .choice small { margin-top: 0; }
  .choice-text { gap: 2px; }
  .choice .badge { position: static; margin-left: auto; }
  .stage-head { margin-bottom: 16px; }
}
@keyframes im-up { from { transform: translateY(100%); } }
.more-head { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.more-head svg.i { width: 16px; height: 16px; color: var(--accent); }
.more-foot { margin: 0; text-align: center; font-size: .85rem; color: var(--text-3); }
.more-foot a { color: var(--text-2); }
.more-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.more-tile { display: flex; flex-direction: row; align-items: center; gap: 10px; min-width: 0; padding: 10px 12px; border-radius: 16px; font-size: .92rem; line-height: 1.15; text-decoration: none; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); font-weight: 650; transition: box-shadow .2s, transform .12s; }
.more-tile:hover, .more-tile.active { box-shadow: 0 0 0 1px var(--neon), 0 0 18px var(--neon-soft); }
.more-tile .chip-ico { width: 36px; height: 36px; border-radius: 12px; }

@media (prefers-reduced-motion: reduce) {
  .ambient i, .page-enter, .immersive-backdrop, .immersive-sheet, .choice, .slide-in, .drawer-body { animation: none !important; }
}

/* =====================================================================
   Navigation: four calm entries (Emitir · Verificar · Mi consultorio · Herramientas).
   Desktop folds groups (one open at a time); phones get 4 tabs + the "Más" sheet.
   ===================================================================== */
.nav-groups { display: flex; flex-direction: column; gap: 4px; }
.nav-item:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.nav-head { width: 100%; border: 0; background: none; font: inherit; font-weight: 650; line-height: inherit; cursor: pointer; text-align: left; }
.nav-top { font-weight: 650; }
.nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
svg.i.nav-chev { width: 16px; height: 16px; color: var(--text-3); transition: transform .28s cubic-bezier(.2, .8, .2, 1); }
.nav-group.open svg.i.nav-chev { transform: rotate(180deg); }
.nav-group.has-active > .nav-head { color: var(--accent-strong); }
.nav-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--brand); box-shadow: 0 0 8px var(--neon), 0 0 0 3px var(--neon-soft); opacity: 0; transform: scale(.4); transition: opacity .2s, transform .2s; }
.nav-group.has-active:not(.open) .nav-dot { opacity: 1; transform: none; }

/* Fold: the grid row animates from 0fr to 1fr, so the height follows the content */
.nav-sub { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows .3s cubic-bezier(.2, .8, .2, 1), opacity .22s ease; }
.nav-group.open .nav-sub { grid-template-rows: 1fr; opacity: 1; }
.nav-sub-in { min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 2px; margin-left: 21px; padding: 2px 6px 6px 12px; border-left: 1px solid var(--glass-line, var(--border)); }
.nav-child { padding: 8px 10px; font-size: .93rem; }
.nav-child svg.i { width: 16px; height: 16px; }
.nav-item.nav-child.active { box-shadow: 0 0 0 1px var(--neon-soft), 0 0 10px var(--neon-soft); }
.nav-item.nav-child.active::before { left: -13px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; box-shadow: 0 0 8px var(--neon); }

/* Phones: bottom tab bar (hidden on desktop) */
.tabbar { display: none; }
@media (max-width: 760px) {
  .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around; gap: 2px; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--glass-strong); backdrop-filter: blur(22px) saturate(1.35); -webkit-backdrop-filter: blur(22px) saturate(1.35); border-top: 1px solid var(--glass-border); }
  .tb-item { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 4px 6px; border: 0; border-radius: 14px; background: none;
    font: inherit; font-size: .7rem; font-weight: 650; line-height: 1.1; color: var(--text-2); text-decoration: none; cursor: pointer; transition: color .15s, background .15s; }
  .tb-item svg.i { width: 22px; height: 22px; }
  .tb-item:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
  .tb-item.active { color: var(--accent-strong); background: color-mix(in srgb, var(--accent-soft) 70%, transparent); }
  .tb-item.active::before { content: ""; position: absolute; left: 30%; right: 30%; top: -6px; height: 3px; border-radius: 0 0 4px 4px; background: var(--grad); box-shadow: 0 0 10px var(--neon); }
  .tb-item.active svg.i { filter: drop-shadow(0 0 6px var(--neon)); }
}

/* "Receta | Descanso" segmented switch: phones only (desktop has both under Emitir) */
.emit-bar { display: none; }
@media (max-width: 760px) {
  .emit-bar { display: flex; justify-content: center; padding: 12px 16px 0; }
  .emit-switch { position: relative; display: grid; grid-template-columns: 1fr 1fr; width: min(100%, 320px); padding: 4px; border-radius: 999px;
    background: var(--glass-strong); border: 1px solid var(--glass-border); box-shadow: var(--shadow-sm); }
  .emit-switch a { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 10px; border-radius: 999px;
    font-weight: 700; font-size: .9rem; color: var(--text-2); text-decoration: none; transition: color .2s; }
  .emit-switch a svg.i { width: 16px; height: 16px; }
  .emit-switch a.on { color: var(--on-brand); }
  .emit-switch a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
  .emit-pill { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 999px; background: var(--grad); box-shadow: 0 0 0 1px var(--neon-soft), 0 0 14px var(--neon);
    transition: transform .3s cubic-bezier(.2, .8, .2, 1); }
  .emit-switch.right .emit-pill { transform: translateX(100%); }
  .emit-bar + .content { padding-top: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .nav-sub, .nav-chev, .nav-dot, .emit-pill { transition: none !important; }
}

/* =====================================================================
   Receta: sections, doctor identity, medicine search and the one-window table
   ===================================================================== */
.wz-nav { flex-wrap: wrap; }
.wz-kicker svg.i { width: 14px; height: 14px; vertical-align: -2px; margin-right: 2px; }
.rx-sections { display: flex; gap: 4px; margin: 4px 0 0; overflow-x: auto; scrollbar-width: none; }
.rx-sections::-webkit-scrollbar { display: none; }
.rx-sec { display: inline-flex; align-items: center; gap: 6px; flex: none; border: 0; background: none; font: inherit; font-size: .8rem; font-weight: 650; color: var(--text-3);
  padding: 4px 9px 4px 5px; border-radius: 999px; white-space: nowrap; min-height: 0; }
.rx-sec:disabled { cursor: default; }
.rx-sec.on { color: var(--accent-strong); background: color-mix(in srgb, var(--accent-soft) 85%, transparent); box-shadow: 0 0 0 1px var(--neon-soft); }
.rx-sec.done { color: var(--text-2); cursor: pointer; }
.rx-sec.done:hover { color: var(--text); }
.rx-sec-dot { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 2px solid currentColor; display: grid; place-items: center; }
.rx-sec.on .rx-sec-dot { background: currentColor; box-shadow: 0 0 8px var(--neon); }
.rx-sec.done .rx-sec-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.rx-sec-dot svg.i { width: 12px; height: 12px; }
.rx-sec.done .rx-sec-dot svg.i circle { display: none; }

.rx-avatar { width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--grad); color: var(--on-brand); display: grid; place-items: center; font-weight: 800; font-size: .9rem; box-shadow: 0 0 12px var(--neon-soft); }
.rx-avatar.big { width: 60px; height: 60px; font-size: 1.2rem; }
.rx-doctor-bar { display: flex; align-items: center; gap: 12px; width: 100%; margin: 0 0 18px; padding: 10px 14px; text-align: left; font: inherit; color: var(--text); cursor: pointer;
  border: 1px solid var(--border); border-radius: 18px; background: color-mix(in srgb, var(--accent-soft) 40%, var(--surface)); transition: box-shadow .2s, border-color .2s; }
.rx-doctor-bar:hover, .rx-doctor-bar:focus-visible { outline: none; border-color: color-mix(in srgb, var(--brand) 55%, var(--border)); box-shadow: 0 0 0 3px var(--neon-soft); }
.rx-doctor-text { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.rx-doctor-text > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rx-doctor-edit { display: inline-flex; align-items: center; gap: 4px; flex: none; font-size: .85rem; font-weight: 650; color: var(--accent-strong); }
.rx-doctor-edit svg.i { width: 16px; height: 16px; }
.rx-doctor-card { display: flex; gap: 16px; align-items: center; padding: 16px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--border); }
.rx-doctor-card > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.rx-doctor-card svg.i { width: 15px; height: 15px; vertical-align: -2px; }
.rx-doctor-name { font-size: 1.2rem; }

.rx-search { position: relative; }
.rx-search .wz-input { padding-left: 50px; }
svg.i.rx-lens { position: absolute; left: 17px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; color: var(--text-3); pointer-events: none; }
.rx-search-meta { margin: 8px 2px 0; }
.rx-hits { display: grid; gap: 6px; margin-top: 10px; max-height: min(46vh, 460px); overflow-y: auto; padding: 2px; overscroll-behavior: contain; }
.rx-hit { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; text-align: left; font: inherit; color: var(--text); cursor: pointer;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface); transition: border-color .15s, box-shadow .2s, transform .12s; animation: reveal .25s both; }
.rx-hit:hover:not(:disabled), .rx-hit:focus-visible { outline: none; border-color: color-mix(in srgb, var(--brand) 55%, var(--border)); box-shadow: 0 0 0 3px var(--neon-soft); }
.rx-hit:active:not(:disabled) { transform: scale(.99); }
.rx-hit.added { opacity: .62; cursor: default; }
.rx-hit.free { border-style: dashed; background: transparent; }
.rx-hit-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rx-hit-main > * { overflow: hidden; text-overflow: ellipsis; }
.rx-hit-badges { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.rx-hit-add { width: 32px; height: 32px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong); }
.rx-hit-add svg.i { width: 18px; height: 18px; }
.rx-hit.added .rx-hit-add { background: var(--ok-soft); color: var(--ok); }

.rx-picked { display: grid; gap: 6px; margin-top: 18px; }
.rx-picked-head { font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.rx-picked-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 10px; border-radius: 14px; background: var(--surface-2); animation: reveal .3s both; }
.rx-picked-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rx-num { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--grad); color: var(--on-brand); font-weight: 800; font-size: .85rem; }
.rx-num svg.i { width: 18px; height: 18px; }
.rx-num svg.i circle { display: none; }
.rx-remove { min-height: 34px; padding: 5px; color: var(--text-3); flex: none; }
.rx-remove:hover { color: var(--bad); }

.immersive-sheet.rx-sheet { width: min(1220px, 100%); }
.rx-sheet-sub { margin: -6px 0 0; }
.rx-table { display: grid; gap: 10px; }
.rx-tr { display: grid; grid-template-columns: minmax(230px, 1.7fr) repeat(5, minmax(0, 1fr)) minmax(118px, 1fr); gap: 8px; align-items: start;
  padding: 10px; border-radius: 16px; background: var(--surface-2); border: 1px solid transparent; transition: border-color .2s, box-shadow .2s; }
.rx-tr.ok { border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.rx-tr.ok .rx-num { background: var(--ok); }
.rx-tr.bad { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.rx-th { padding: 0 10px; background: none; font-size: .72rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.rx-td { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rx-td select, .rx-td input { min-height: 40px; padding: 8px 10px; font-size: .92rem; background: var(--surface); }
.rx-td-name { flex-direction: row; align-items: flex-start; gap: 8px; }
.rx-td-name .rx-num { margin-top: 6px; }
.rx-name-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.rx-td input.rx-dci { font-weight: 700; font-size: 1rem; }
.rx-lbl { display: none; font-size: .76rem; font-weight: 650; color: var(--text-2); }
.rx-qty-note { font-size: .74rem; font-weight: 650; color: var(--accent-strong); text-align: left; }
.rx-missing { grid-column: 1 / -1; margin: 0; display: flex; gap: 6px; align-items: center; font-size: .82rem; color: var(--text-2); }
.rx-missing svg.i { width: 15px; height: 15px; flex: none; }
.rx-missing.bad { color: var(--bad); font-weight: 650; }
.rx-sheet-nav { position: sticky; bottom: -22px; z-index: 1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 -4px -6px; padding: 12px 4px 8px; background: var(--sheet); }
.rx-sheet-nav .btn.primary { margin-left: auto; }
@media (max-width: 1040px) {
  .rx-th { display: none; }
  .rx-tr { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 12px; gap: 10px; }
  .rx-td-name { grid-column: 1 / -1; }
  .rx-lbl { display: block; }
}
@media (max-width: 640px) {
  .rx-tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rx-sec:not(.on) .rx-sec-name { display: none; }
  .rx-doctor-edit span { display: none; }
  .rx-hit { padding: 9px 10px; gap: 10px; }
  .rx-hit-badges { flex-direction: column; align-items: flex-end; }
}
@media (max-width: 760px) {
  .rx-sheet-nav { bottom: calc(-18px - env(safe-area-inset-bottom)); }
}
