/* "Primeros pasos" onboarding panel — public/onboarding.js. Page-private to index.html. */
.onboarding-panel {
  background: #fff;
  border: 1px solid var(--gray-200, #e2e8f0);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 16px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
  /* Own text colour: .dashboard-empty sets a muted slate for its hero, which washed out
     every title on this white card. */
  color: #0f172a;
}
.onboarding-panel.hidden { display: none; }
.onboarding-welcome { margin: 0 0 14px; padding: 0 0 14px; border-bottom: 1px solid var(--gray-100, #f1f5f9); }
.onboarding-welcome h2 { margin: 0 0 6px; font-size: 18px; font-weight: 700; color: #0f172a; }
.onboarding-welcome p { margin: 0; font-size: 14px; color: var(--gray-600, #475569); line-height: 1.5; }
.onboarding-guide { margin: 10px 0 0; font-size: 12px; color: var(--gray-600, #475569); display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.onboarding-guide a { color: #1f6feb; font-weight: 600; }
.onboarding-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.onboarding-head h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.onboarding-progress { font-size: 12px; color: var(--gray-600, #475569); }
.onboarding-bar { height: 4px; background: var(--gray-200, #e2e8f0); border-radius: 2px; margin: 10px 0 6px; overflow: hidden; }
.onboarding-bar span { display: block; height: 100%; background: #1f6feb; transition: width .3s ease; }
.onboarding-steps { list-style: none; margin: 0; padding: 0; }
.onboarding-step { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--gray-100, #f1f5f9); }
.onboarding-step:last-child { border-bottom: 0; }
.onboarding-step-icon { font-size: 20px; color: var(--gray-400, #94a3b8); margin-top: 1px; }
.onboarding-step.is-done .onboarding-step-icon { color: #0f9d58; }
.onboarding-step.is-done .onboarding-step-title,
.onboarding-step.is-skipped .onboarding-step-title { color: var(--gray-500, #64748b); }
.onboarding-state { font-weight: 400; font-size: 12px; }
.onboarding-step.is-done .onboarding-state { color: #0f7a45; }
/* Link shared, no patient yet: in progress, not done (amber, not the green check). */
.onboarding-step.is-waiting .onboarding-step-icon,
.onboarding-step.is-waiting .onboarding-state { color: #b45309; }
.onboarding-seeding { margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }
.onboarding-hint-warn { color: #9a3412; }
.onboarding-step-body { flex: 1; min-width: 0; }
.onboarding-step-title { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.onboarding-step-actions { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.onboarding-url { font-size: 12px; background: var(--gray-50, #f8fafc); border: 1px solid var(--gray-200, #e2e8f0); border-radius: 6px; padding: 4px 8px; word-break: break-all; }
.onboarding-linkbtn { background: none; border: 0; padding: 0; font-size: 12px; color: var(--gray-600, #475569); text-decoration: underline; cursor: pointer; }
.onboarding-slug-edit { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.onboarding-slug-edit.hidden { display: none; }
.onboarding-slug-edit input { padding: 4px 8px; border: 1px solid var(--gray-200, #e2e8f0); border-radius: 6px; font-size: 13px; min-width: 0; flex: 1 1 140px; }
.onboarding-slug-prefix { font-size: 12px; color: var(--gray-600, #475569); }
.onboarding-hint { flex-basis: 100%; margin: 2px 0 0; font-size: 12px; color: var(--gray-600, #475569); }
.onboarding-first-patient { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 12px; padding: 10px 14px; border-radius: 8px; background: #1f6feb; color: #fff; font-size: 14px; font-weight: 600; text-decoration: none; }
.onboarding-first-patient:hover { background: #1a5fd0; color: #fff; }
.onboarding-slug-confirm { flex-basis: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid #fed7aa; border-radius: 8px; background: #fff7ed; }
.onboarding-slug-confirm p { margin: 0 0 8px; font-size: 13px; line-height: 1.45; color: #7c2d12; }
.onboarding-proof { margin: 0 0 14px; padding: 12px 14px; border: 1px solid #fed7aa; border-radius: 10px; background: #fff7ed; }
.onboarding-proof p { margin: 0; font-size: 14px; line-height: 1.5; color: #7c2d12; }
.onboarding-proof .onboarding-first-patient { min-height: 44px; box-sizing: border-box; }
.onboarding-ask { margin-top: 10px; width: 100%; text-align: left; background: var(--gray-50, #f8fafc); border: 1px dashed var(--gray-200, #e2e8f0); border-radius: 8px; padding: 8px 10px; font-size: 13px; color: var(--gray-600, #475569); cursor: pointer; }
.onboarding-ask:hover { border-color: #1f6feb; color: #1f6feb; }
@media (max-width: 640px) { .onboarding-panel { margin: 10px; padding: 12px; } }
/* The dashboard empty-state is a flex ROW (overview hero + KPI cards); with the panel in it
   the cards were squeezed to ~270px. Stack the panel above the overview while it shows. */
.dashboard-empty:has(> .onboarding-panel:not(.hidden)) { flex-direction: column; align-items: stretch; }
.dashboard-empty > .onboarding-panel { flex: 0 0 auto; }
/* Own button style: .btn-secondary is restyled for the dark hero inside .dashboard-empty
   and rendered near-invisible on this white card. */
.onboarding-btn { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; font-size: 12px; font-weight: 600;
  color: #334155; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; cursor: pointer; }
.onboarding-btn:hover { border-color: #1f6feb; color: #1f6feb; }
/* Phone-only entry into the checklist, atop the patient list (index.html #sidebar). */
.onboarding-mobile-entry { display: none; }
@media (max-width: 768px) {
  .onboarding-mobile-entry:not(.hidden) {
    display: flex; align-items: center; gap: 8px; width: calc(100% - 24px); margin: 12px;
    padding: 12px 14px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 10px;
    color: #0f172a; font: inherit; font-size: 14px; text-align: left; cursor: pointer;
  }
  .onboarding-mobile-entry span { flex: 1; min-width: 0; }
  .onboarding-mobile-entry .ti-rocket { color: #1f6feb; font-size: 18px; }
}

/* "Su logo y color" dialog — public/branding-setup.js. Controls left, live preview right;
   stacked on phones. The previews are iframes (scaled real documents), never live DOM. */
.branding-dialog {
  width: min(1040px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  color: #0f172a;
  background: #fff;
}
.branding-dialog[open] { display: flex; flex-direction: column; }
.branding-dialog::backdrop { background: rgba(15, 23, 42, 0.5); }
/* .btn-secondary is styled for the navy app chrome (white-on-dark); on this white dialog
   it read as disabled. Same override as the PDF-export dialog. */
.branding-dialog .btn-secondary { color: var(--gray-700, #334155); background: var(--white, #fff); border-color: var(--gray-300, #cbd5e1); }
.branding-dialog .btn-secondary:hover { color: var(--gray-800, #1e293b); background: var(--gray-100, #f1f5f9); border-color: var(--gray-400, #94a3b8); }
.branding-head { display: flex; justify-content: space-between; gap: 12px; padding: 18px 22px 12px; border-bottom: 1px solid var(--gray-100, #f1f5f9); }
.branding-head h2 { margin: 0 0 4px; font-size: 18px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.branding-optional { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #0f7a45; background: #e7f6ee; border-radius: 999px; padding: 2px 8px; }
.branding-intro { margin: 0; font-size: 13px; color: var(--gray-600, #475569); line-height: 1.5; }
.branding-close { background: none; border: 0; font-size: 20px; color: var(--gray-500, #64748b); cursor: pointer; align-self: flex-start; min-width: 36px; min-height: 36px; }
.branding-body { display: grid; grid-template-columns: minmax(240px, 300px) 1fr; gap: 20px; padding: 16px 22px; overflow: auto; flex: 1 1 auto; min-height: 0; }
.branding-controls h3 { margin: 0 0 8px; font-size: 14px; }
.branding-controls h3:not(:first-child) { margin-top: 18px; }
.branding-logo-row { display: flex; align-items: center; gap: 12px; }
.branding-logo-box { width: 96px; height: 64px; flex: 0 0 auto; border: 1px dashed var(--gray-200, #e2e8f0); border-radius: 8px; display: flex; align-items: center; justify-content: center; background: var(--gray-50, #f8fafc); overflow: hidden; }
.branding-logo-box img { max-width: 88px; max-height: 56px; width: auto; height: auto; }
.branding-logo-empty { font-size: 12px; color: var(--gray-500, #64748b); }
.branding-logo-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.branding-file { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.branding-help { margin: 6px 0 0; font-size: 12px; color: var(--gray-600, #475569); line-height: 1.45; }
.branding-help.error { color: #b91c1c; }
.branding-check { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; font-size: 13px; line-height: 1.4; cursor: pointer; }
.branding-check input { margin-top: 2px; }
.branding-accent-row { display: flex; align-items: center; gap: 10px; }
.branding-accent-row input[type="color"] { width: 44px; height: 32px; padding: 0; border: 1px solid var(--gray-200, #e2e8f0); border-radius: 6px; background: none; cursor: pointer; }
.branding-accent-row .branding-help { margin: 0; }
.branding-preview { min-width: 0; }
.branding-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--gray-200, #e2e8f0); }
.branding-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; font-size: 13px; font-weight: 600; color: var(--gray-600, #475569); cursor: pointer; margin-bottom: -1px; }
.branding-tabs button.active { color: #1f6feb; border-bottom-color: #1f6feb; }
.branding-frame-wrap { position: relative; margin-top: 8px; border: 1px solid var(--gray-200, #e2e8f0); border-radius: 8px; background: var(--gray-100, #f1f5f9); padding: 8px; min-height: 220px; }
.branding-frame-wrap iframe { display: block; width: 100%; height: 240px; border: 0; background: #fff; box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12); }
.branding-frame-wrap iframe[hidden] { display: none; }
.branding-frame-status { position: absolute; inset: 8px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 12px; font-size: 13px; color: var(--gray-600, #475569); background: rgba(241, 245, 249, 0.85); }
.branding-frame-status[hidden] { display: none; }
.branding-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 22px 16px; border-top: 1px solid var(--gray-100, #f1f5f9); }
.branding-later { margin: 0; flex: 1 1 260px; font-size: 12px; color: var(--gray-600, #475569); display: flex; gap: 6px; align-items: flex-start; }
.branding-error { margin: 0; flex-basis: 100%; font-size: 13px; color: #b91c1c; }
.branding-error.hidden { display: none; }
.branding-foot-actions { display: flex; gap: 8px; margin-left: auto; }
@media (max-width: 760px) {
  .branding-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .branding-head, .branding-body, .branding-foot { padding-left: 14px; padding-right: 14px; }
  .branding-body { grid-template-columns: 1fr; }
  .branding-foot-actions { width: 100%; }
  .branding-foot-actions .btn { flex: 1; min-height: 40px; }
}

/* Welcome: spot art, one warm line, one button, then the team's two doors. Short on purpose:
   on a phone the first step must be in view on arrival (the art hides, last block of this file). */
.onboarding-welcome { display: flex; align-items: center; gap: 18px; }
.onboarding-welcome-text { flex: 1 1 auto; min-width: 0; }
.onboarding-welcome-art { flex: 0 0 auto; width: 148px; height: 148px; }
.onboarding-welcome .onboarding-btn-primary { margin-top: 10px; }
.onboarding-welcome-team { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--gray-200, #e2e8f0); }
.onboarding-welcome-team p { font-size: 13px; }
.onboarding-step-sub { font-weight: 400; font-size: 12px; color: var(--gray-500, #64748b); }
.onboarding-btn[disabled] { opacity: .75; cursor: progress; }
.onboarding-btn-primary { background: #1f6feb; border-color: #1f6feb; color: #fff; font-size: 14px; padding: 8px 14px; }
.onboarding-btn-primary:hover { background: #1a5fd0; color: #fff; }

/* How-To popup for the example report / practice receta: the tutorial page in embed mode
   (/howto/<slug>?embed=1, public/howto.js) inside an iframe. */
.onboarding-guide-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px); margin: auto; padding: 0; border: 0;
  border-radius: 14px; box-shadow: 0 20px 60px rgba(15, 23, 42, .3); color: #0f172a; display: none; flex-direction: column; }
.onboarding-guide-dialog[open] { display: flex; }
.onboarding-guide-dialog::backdrop { background: rgba(15, 23, 42, .5); }
.onboarding-guide-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid #e2e8f0; }
.onboarding-guide-head h2 { margin: 0; font-size: 17px; }
.onboarding-guide-close { background: none; border: 0; font-size: 20px; color: #475569; cursor: pointer; padding: 4px; }
.onboarding-guide-frame-wrap { position: relative; flex: 1 1 auto; min-height: 0; }
.onboarding-guide-frame { display: block; width: 100%; height: min(62vh, 560px); border: 0; background: #f8fafc; }
.onboarding-guide-loading { position: absolute; top: 40%; left: 50%; font-size: 28px; color: #94a3b8; }
.onboarding-guide-back { margin: 0; padding: 10px 18px; background: #eff6ff; border-top: 1px solid #bfdbfe; font-size: 13px; color: #1e3a8a;
  display: flex; align-items: flex-start; gap: 6px; }
.onboarding-guide-foot { display: flex; justify-content: flex-end; align-items: center; gap: 16px; padding: 12px 18px; }
@media (max-width: 640px) { .onboarding-guide-frame { height: 55vh; } .onboarding-guide-foot { justify-content: space-between; } }

/* Copiar and WhatsApp stay together, with their answer beside them. Same row on the team step. */
.onboarding-step-art { flex: 0 0 auto; width: 76px; height: 76px; align-self: center; }
.onboarding-share { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.onboarding-url { flex-basis: 100%; }
.onboarding-btn .ti-brand-whatsapp { color: #128c4a; font-size: 15px; }
.onboarding-link-status { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: #0f7a45; }

/* The patient link as a QR, for a patient at the desk. */
.onboarding-qr-dialog { width: min(380px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); margin: auto; padding: 20px; overflow: auto; border: 1px solid #e2e8f0; border-radius: 16px; background: #fff; color: #0f172a; }
.onboarding-qr-dialog::backdrop { background: rgba(15, 23, 42, 0.5); }
.onboarding-qr-dialog h2 { margin: 0 0 4px; font-size: 18px; }
.onboarding-qr-code { display: flex; justify-content: center; margin: 12px 0; }
.onboarding-qr-code svg { width: 216px; height: 216px; max-width: 100%; border: 1px solid #e2e8f0; border-radius: 12px; }
.onboarding-qr-dialog .onboarding-url { display: block; margin-bottom: 12px; overflow-wrap: anywhere; }
.onboarding-qr-actions { justify-content: flex-end; }

/* The checklist finished for real: art and one warm line above it. */
.onboarding-celebrate { display: flex; align-items: center; gap: 14px; margin: 0 0 14px; padding: 10px 14px; border: 1px solid #bbf7d0; border-radius: 12px; background: #f0fdf4; }
.onboarding-celebrate-art { flex: 0 0 auto; width: 92px; height: 92px; }
.onboarding-celebrate h2 { margin: 0 0 4px; font-size: 18px; font-weight: 700; color: #0f172a; }
.onboarding-celebrate p { margin: 0; font-size: 14px; line-height: 1.5; color: #334155; }

/* The chat on an example: one line near the input (index.html #chat-example-note). */
.chat-example-note { display: flex; align-items: flex-start; gap: 6px; margin-bottom: 8px; padding: 6px 10px; border: 1px solid #fde68a; border-radius: 8px; background: #fffbeb; color: #92400e; font-size: 13px; line-height: 1.4; }
.chat-example-note .ti { margin-top: 2px; }

/* Phones and small tablets, upright or on their side: finger-sized targets, and the first step
   in view on arrival. Last in the file, so these win over the base button styles above. */
@media (pointer: coarse), (max-width: 768px), (max-height: 480px) and (max-width: 950px) {
  .onboarding-linkbtn { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 6px; font-size: 14px; }
  .onboarding-btn { justify-content: center; min-height: 44px; padding: 8px 14px; font-size: 14px; }
  .onboarding-step-actions { gap: 6px 14px; }
  .onboarding-ask { min-height: 44px; font-size: 14px; }
  .onboarding-guide a { display: inline-flex; align-items: center; min-height: 44px; }
  .onboarding-guide { font-size: 14px; }
  .onboarding-first-patient { min-height: 44px; }
  .onboarding-slug-edit input { min-height: 44px; font-size: 16px; }
  .onboarding-guide-close { min-width: 44px; min-height: 44px; }
  .branding-close { min-width: 44px; min-height: 44px; }
  .branding-check { min-height: 44px; align-items: center; }
  .branding-tabs button { min-height: 44px; }
  .branding-foot-actions .btn { min-height: 44px; }
  .branding-accent-row input[type="color"] { height: 44px; }
}
@media (max-width: 640px) {
  .onboarding-welcome { margin-bottom: 10px; padding-bottom: 10px; }
  .onboarding-welcome-art, .onboarding-step-art { display: none; }
  .onboarding-welcome h2 { margin-bottom: 4px; }
  .onboarding-welcome .onboarding-btn-primary { width: 100%; margin-top: 8px; }
  .onboarding-welcome-team { margin-top: 8px; padding-top: 0; border-top: 0; }
  .onboarding-welcome-team .onboarding-share { flex-basis: 100%; }
  .onboarding-share .onboarding-btn { flex: 1 1 auto; white-space: nowrap; padding-left: 8px; padding-right: 8px; }
  .onboarding-celebrate-art { width: 64px; height: 64px; }
}
/* The narrowest phones keep the team's two buttons on one row. */
@media (max-width: 380px) {
  .onboarding-welcome-team .onboarding-share .ti { display: none; }
}
/* A phone on its side leaves about 240px between the header and the chat bar. */
@media (max-height: 480px) and (max-width: 950px) {
  .onboarding-welcome-art, .onboarding-welcome p, .onboarding-welcome-team { display: none; }
  .onboarding-welcome { margin-bottom: 4px; padding-bottom: 4px; }
  .onboarding-welcome-text { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .onboarding-welcome h2 { margin: 0; font-size: 16px; }
  .onboarding-welcome .onboarding-btn-primary { flex: 0 0 auto; margin-top: 0; }
  .onboarding-head > div { display: flex; align-items: baseline; gap: 8px; }
  .onboarding-bar { margin: 2px 0 0; }
  .onboarding-step { padding: 6px 0; }
  .onboarding-step-title { margin-bottom: 2px; }
}
