/* ============================================================
   SERENO · armazón de la app (fase 3): barra superior + menú
   Basado en mockup-menu. Usa los tokens de sereno.css.
   ============================================================ */
.sr-i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ── Barra superior (inicio y módulos) ─────────────────────── */
html body .topbar,
html body.theme-dark .topbar,
html body:not(.theme-dark) .topbar {
  height: 60px; padding: 0 28px; gap: 16px;
  background: var(--surface) !important; color: var(--text);
  border: 0 !important; border-bottom: 1px solid var(--line) !important;
  box-shadow: none !important; position: sticky; top: 0; z-index: 500;
  justify-content: flex-start;
}
html body .topbar::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--grad); }
html body .topbar-logo img { height: 42px; width: auto; display: block; }
.sr-spacer { flex: 1; }
.sr-sep { width: 1px; height: 24px; background: var(--line); }
.sr-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px;
           font-size: 12.5px; color: var(--text-2); background: var(--surface); white-space: nowrap; }
.sr-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.sr-chip.cerrado .dot { background: var(--muted); }
.sr-chip.fb .dot { background: var(--accent); }
.sr-theme { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.sr-theme button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12px; color: var(--text-3); }
.sr-theme button .sr-i { width: 14px; height: 14px; }
.sr-theme button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }

/* ── Usuario ───────────────────────────────────────────────── */
html body .profile, html body.theme-dark .profile {
  display: flex; align-items: center; gap: 10px; padding: 4px 6px; border-radius: var(--r); background: transparent !important;
  border: 0 !important; box-shadow: none !important; cursor: pointer; position: relative; color: var(--text);
}
html body .profile:hover { background: var(--surface-2) !important; transform: none; }
html body .profile-text { align-items: flex-end; gap: 0; line-height: 1.2; }
html body .profile-name { font-size: 13px !important; font-weight: 600 !important; color: var(--text); order: 1; }
html body .profile-welcome { font-size: 11.5px !important; opacity: 1 !important; color: var(--text-3); order: 2; }
html body .foto-avatar-wrap { width: 34px !important; height: 34px !important; border-radius: 50% !important; border: 1px solid var(--accent-line) !important;
  box-shadow: none !important; background: var(--accent-soft) !important; padding: 0 !important; overflow: hidden; }
html body .foto-avatar-wrap img { width: 100%; height: 100%; object-fit: cover; }
html body .profile-dropdown, html body.theme-dark .profile-dropdown {
  background: var(--surface) !important; border: 1px solid var(--line) !important; border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop) !important; color: var(--text); padding: 6px; min-width: 220px;
}
html body .profile-dropdown-item, html body.theme-dark .profile-dropdown-item { padding: 9px 12px; border-radius: 8px; font-size: 13.5px; color: var(--text-2); }
html body .profile-dropdown-item:hover, html body.theme-dark .profile-dropdown-item:hover { background: var(--surface-2); color: var(--text); }
#theme-toggle-btn { display: none !important; } /* el tema se cambia con el selector de la barra */

/* ── Barra del módulo: Regresar discreto + título ──────────── */
html body #moduloView .btn-regresar, html body.theme-dark #moduloView .btn-regresar {
  all: unset; box-sizing: border-box; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px;
  border-radius: var(--r-btn); border: 0 !important; background: var(--grad) !important; color: #fff !important;
  font: 600 13px var(--font-base); box-shadow: var(--btn-shadow) !important; text-shadow: none !important;
}
html body #moduloView .btn-regresar:hover { filter: brightness(1.06); transform: none !important; }
html body #moduloView .btn-regresar:focus-visible { box-shadow: var(--btn-shadow), var(--focus) !important; }
#moduloView .topbar #tituloModulo { font: 600 15px var(--font-display-base) !important; color: var(--text); }
/* PO 2026-11-05 (opción A): título al centro exacto de la barra; Regresar se queda a la izquierda */
#moduloView .topbar #tituloModulo { position: absolute; left: 50%; transform: translateX(-50%); max-width: calc(100% - 320px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
@media (max-width: 640px) {
  #moduloView .topbar #tituloModulo { max-width: calc(100% - 132px); }
  html body #moduloView .btn-regresar { font-size: 0 !important; width: 44px; padding: 0 !important; justify-content: center; gap: 0 !important; }
  html body #moduloView .btn-regresar svg { width: 18px; height: 18px; }
}

/* ── Menú ──────────────────────────────────────────────────── */
html body #apps.apps { display: block; width: 100%; max-width: 1120px; margin: 0 auto; padding: 36px 32px 56px; gap: 0; box-sizing: border-box; justify-self: stretch; align-self: stretch; }
html body #apps .sr-group, html body #apps .sr-hello { width: 100%; }
.sr-hello { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 8px; }
.sr-hello h1 { font-size: 28px; font-weight: 600; letter-spacing: -.02em; margin: 0; color: var(--text); }
.sr-hello p { margin: 6px 0 0; color: var(--text-2); font-size: 14px; }
.sr-group { margin-top: 26px; }
.sr-group-h { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font: 600 11px var(--font-base); letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.sr-group-h::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.sr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 12px; }

html body #apps .sr-mod {
  position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 14px; width: auto; padding: 18px; min-height: 132px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; animation: none; text-align: left; color: var(--text);
}
html body #apps .sr-mod:hover { border-color: var(--accent-line); box-shadow: var(--shadow-2); transform: translateY(-1px); }
html body #apps .sr-mod:active { transform: translateY(0); }
html body #apps .sr-mod:focus-visible { outline: none; box-shadow: var(--shadow-2), var(--focus); }
html body #apps .sr-mod::after { display: none; }
.sr-mod .sr-ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink);
                  border: 1px solid var(--accent-line); overflow: hidden; }
.sr-mod .sr-ico .sr-i { width: 20px; height: 20px; stroke-width: 1.6; }
.sr-mod .sr-ico img { width: 30px; height: 30px; object-fit: contain; }
.sr-mod .sr-ico span { font-size: 20px; line-height: 1; }
.sr-sys .sr-mod .sr-ico { background: var(--surface-2); color: var(--text-2); border-color: var(--line); }
html body #apps .sr-mod .app-title { font: 600 15px var(--font-display-base); color: var(--text) !important; margin: 0; text-align: left; text-shadow: none; max-width: none; }
.sr-mod p { margin: 3px 0 0; font-size: 12.5px; color: var(--text-3); line-height: 1.45; }
.sr-mod .sr-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; min-height: 22px; }
.sr-mod .sr-go { color: var(--text-3); opacity: 0; transition: opacity .15s; display: inline-flex; }
.sr-mod:hover .sr-go { opacity: 1; color: var(--accent-ink); }
.sr-badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font: 600 12px var(--font-base); white-space: nowrap; }
.sr-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.sr-b-ok { color: var(--ok); background: var(--ok-soft); }
.sr-b-warn { color: var(--warn); background: var(--warn-soft); }
.sr-b-muted { color: var(--muted); background: var(--muted-soft); }
.sr-b-bad { color: var(--bad); background: var(--bad-soft); }
.sr-b-accent { color: var(--accent-ink); background: var(--accent-soft); }
.sr-solo-movil { display: none; }

/* ── Móvil (≤ 640 px): barra compacta, menú a 2 columnas, áreas táctiles de 44 px ── */
@media (max-width: 640px) {
  html body .topbar, html body.theme-dark .topbar, html body:not(.theme-dark) .topbar { height: 56px; padding: 0 12px 0 16px; gap: 8px; }
  .topbar .sr-chip, .topbar .sr-sep, html body .profile-text { display: none !important; }
  .sr-theme { padding: 0; }
  .sr-theme button { width: 44px; height: 44px; padding: 0; justify-content: center; font-size: 0; gap: 0; }
  .sr-theme button .sr-i { width: 17px; height: 17px; }
  html body .foto-avatar-wrap { width: 40px !important; height: 40px !important; }
  html body .topbar-logo img { height: 34px; }
  html body #moduloView .btn-regresar { height: 44px; }
  html body #apps.apps { padding: 20px 16px 40px; }
  .sr-hello { flex-direction: column; align-items: stretch; gap: 10px; }
  .sr-hello h1 { font-size: 24px; }
  .sr-solo-movil { display: inline-flex; margin-top: 10px; }
  .sr-group { margin-top: 22px; }
  .sr-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  html body #apps .sr-mod { min-height: 0; padding: 14px; gap: 12px; }
  .sr-mod p, .sr-mod .sr-go { display: none; }
  html body #apps .sr-mod .app-title { font-size: 14.5px; }
  .sr-mod .sr-foot { margin-top: 0; min-height: 0; }
  .sr-mod .sr-foot:has(> span:first-child:empty) { display: none; }
  .sr-grid > .sr-mod:last-child:nth-child(odd) { grid-column: span 2; flex-direction: row; align-items: center; }
  .sr-grid > .sr-mod:last-child:nth-child(odd) p { display: block; }
  .sr-grid > .sr-mod:last-child:nth-child(odd) .sr-foot { margin-left: auto; }
}

/* ── Suplantación (sólo lectura) y modal ─────────────────────── */
.sr-suplan-banner { position: sticky; top: 0; z-index: 600; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 28px; background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  font: 600 13px var(--font-base); }
.sr-suplan-banner strong { color: var(--text); }
.sr-suplan-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); margin-right: 8px; vertical-align: middle; }
.sr-suplan-salir { all: unset; cursor: pointer; height: 30px; padding: 0 12px; border-radius: var(--r-btn); background: var(--surface); color: var(--text);
  border: 1px solid var(--line); font: 600 12.5px var(--font-base); display: inline-flex; align-items: center; }
.sr-suplan-salir:hover { background: var(--surface-2); }
body:has(#suplan-banner[style*="flex"]) .topbar { top: 47px; }

.sr-modal-fondo { position: fixed; inset: 0; z-index: 2000; background: rgba(12,15,20,.45); align-items: center; justify-content: center; padding: 20px; }
.sr-modal { width: 440px; max-width: 100%; max-height: 80vh; overflow-y: auto; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); padding: 22px 24px; }
.sr-modal h3 { margin: 0 0 6px; font: 600 17px var(--font-display-base); color: var(--text); }
.sr-modal p { margin: 0 0 16px; font-size: 13.5px; line-height: 1.55; color: var(--text-2); }
.sr-modal-cargando { padding: 16px 0; text-align: center; color: var(--text-3); font-size: 13px; }
.sr-modal select { width: 100%; height: 40px; padding: 0 10px; margin-bottom: 18px; border-radius: var(--r); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font: 400 14px var(--font-base); }
.sr-modal select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.sr-modal-acciones { display: flex; justify-content: flex-end; gap: 8px; }
.sr-modal .sr-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Pantalla de carga: logo un poco más grande (PO 2026-11-05) */
html body .splash-logo { height: 88px; }

/* RET-04: chips con clic */
.sr-chip.sr-chip-link{cursor:pointer;transition:transform .12s ease,box-shadow .12s ease}
.sr-chip.sr-chip-link:hover{transform:translateY(-1px);box-shadow:0 2px 8px color-mix(in srgb,var(--accent) 22%,transparent)}
.sr-chip.sr-chip-link:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
