/* ==============================================================================
   CENTRO PSICOLÓGICO FAMILIAR VÍNCULOS · SISTEMA VISUAL UNIFICADO (2026-11-30)
   Paleta oficial derivada del logo: Magenta (#b4145a), Cobalto (#1747b5), Lima (#51a800)
   ============================================================================== */

:root {
  --v-ink: #1b223c;
  --v-muted: #525d7a;
  --v-surface: #ffffff;
  --v-surface-subtle: #f7f8fd;
  --v-canvas: #f4f6fb;
  --v-paper: #f4f6fb;
  --v-rule: #dfe4f0;
  --v-rule-strong: #c8d0e5;

  --v-accent: #b4145a;
  --v-accent-dark: #8e1048;
  --v-blush: #fdf1f6;
  --v-blush-border: #f2cde0;

  --v-deep: #1a2456;
  --v-rail: #1a2456;
  --v-rail-dark: #131b44;
  --v-rail-text: #f4f6ff;
  --v-rail-muted: #c7d0ee;

  --v-teal: #1747b5;
  --v-cobalt: #1747b5;
  --v-mint: #eef2fc;
  --v-mint-border: #cfdcf7;

  --v-lime: #51a800;
  --v-lime-soft: #f2f8e6;
  --v-lime-border: #d5e6b6;
  --v-lime-ink: #325e12;

  --v-focus: #b4145a;
  --v-content-gutter: 32px;
  --v-shadow: 0 2px 10px rgba(27, 34, 60, 0.045);
  --v-shadow-md: 0 10px 26px rgba(27, 34, 60, 0.08);

  /* Compatibilidad con tokens base */
  --primary: var(--v-accent);
  --primary-dark: var(--v-accent-dark);
  --primary-light: var(--v-blush);
  --primary-hover: #790d3c;
  --secondary: var(--v-cobalt);
  --bg-main: var(--v-paper);
  --bg-card: var(--v-surface);
  --text-main: var(--v-ink);
  --text-muted: var(--v-muted);
  --border-color: var(--v-rule);
}

/* Superficies del navegador */
::selection {
  background: #fce1ed;
  color: #1b223c;
}

body {
  color: var(--v-ink);
  background: var(--v-paper);
  caret-color: var(--v-accent);
}

a {
  text-underline-offset: 3px;
}

:is(#login-screen, #intake-screen, #portal-screen, #sidebar-backdrop, .modal-backdrop).hidden,
[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Enlaces y foco accesible */
.portal-skip-link {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 80;
  min-height: 44px;
  padding: 11px 15px;
  transform: translateY(calc(-100% - 18px));
  border: 1px solid var(--v-rule-strong);
  border-radius: 10px;
  background: var(--v-surface);
  color: var(--v-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 700;
  box-shadow: var(--v-shadow-md);
}
.portal-skip-link:focus-visible { transform: none; }

#portal-screen :is(button, a, input, select, textarea, summary):focus-visible,
.modal-backdrop :is(button, a, input, select, textarea, summary):focus-visible,
#intake-screen :is(button, a, input, select, textarea):focus-visible {
  outline: 2.5px solid var(--v-focus);
  outline-offset: 2px;
}

#portal-screen .main-content:focus-visible {
  outline: 2px solid var(--v-focus);
  outline-offset: -3px;
}

#portal-screen #app-container :is(h2, h3)[tabindex="-1"]:focus-visible {
  outline: 2px solid var(--v-focus);
  outline-offset: 5px;
  border-radius: 4px;
}

/* ==============================================================================
   ESTRUCTURA PRINCIPAL: SIDEBAR + HEADER + CONTENIDO
   ============================================================================== */

#portal-screen.portal-layout:not(.hidden),
#portal-screen .main-content {
  background: var(--v-paper);
}

@media (min-width: 1024px) {
  #portal-screen.portal-layout:not(.hidden) {
    grid-template-columns: 248px minmax(0, 1fr);
  }
  .main-header .brand-logo { display: none; }
  .user-pill .user-pill-info { display: grid; gap: 1px; }
  body.sidebar-open { overflow: auto; }
}

#portal-screen .app-sidebar {
  padding: 22px 14px 16px;
  color: var(--v-rail-text);
  background: linear-gradient(180deg, var(--v-rail) 0%, var(--v-rail-dark) 100%);
  border-right: 1px solid #2c3975;
  scrollbar-width: thin;
  scrollbar-color: #5b69a4 var(--v-rail);
}

#portal-screen .sidebar-brand {
  position: relative;
  min-height: 70px;
  margin-bottom: 18px;
  padding: 0 6px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

#portal-screen .sidebar-logo {
  width: 60px;
  height: 44px;
  padding: 3px 5px;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 3px 10px rgba(8, 12, 34, 0.25);
}

#portal-screen .sidebar-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#portal-screen .sidebar-brand strong {
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
}

#portal-screen .sidebar-brand span,
#portal-screen .sidebar-footer {
  color: var(--v-rail-muted);
}

#portal-screen .sidebar-footer {
  margin-top: 14px;
  padding: 13px 10px 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 0.76rem;
}

#portal-screen .sidebar-footer svg {
  width: 15px;
  height: 15px;
  color: #bde13b;
}

#portal-screen .app-sidebar .nav-container {
  gap: 4px;
}

#portal-screen .app-sidebar .nav-tab {
  gap: 11px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--v-rail-text);
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.32;
  transition: background-color 0.15s ease, color 0.15s ease;
}

#portal-screen .app-sidebar .nav-tab svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: var(--v-rail-muted);
  transition: color 0.15s ease;
}

#portal-screen .app-sidebar .nav-tab:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

#portal-screen .app-sidebar .nav-tab:hover svg {
  color: #ffffff;
}

#portal-screen .app-sidebar .nav-tab[aria-current="page"],
#portal-screen .app-sidebar .nav-tab.active {
  color: #6b0d38;
  background: #ffe6f2;
  border-color: #ffd3e8;
  box-shadow: inset 3px 0 0 var(--v-accent);
  font-weight: 750;
}

#portal-screen .app-sidebar .nav-tab[aria-current="page"] svg,
#portal-screen .app-sidebar .nav-tab.active svg {
  color: var(--v-accent);
}

#portal-screen .app-sidebar :is(button, a):focus-visible {
  outline-color: #e8f2a8;
  outline-offset: -2px;
}

/* Header superior */
#portal-screen .main-header {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--v-rule);
  box-shadow: 0 1px 0 rgba(27, 34, 60, 0.03);
}

#portal-screen .header-container {
  min-height: 68px;
  padding: 10px var(--v-content-gutter);
  gap: 12px;
}

#portal-screen .header-container .brand-section {
  margin-inline-end: auto;
  min-width: 0;
}

#portal-screen .brand-title {
  color: var(--v-ink);
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

#portal-screen .brand-title span {
  color: var(--v-accent);
}

#portal-screen .brand-subtitle {
  color: var(--v-muted);
  font-size: 0.78rem;
  max-width: 58ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#portal-screen #portal-badge {
  background: var(--v-mint);
  color: var(--v-cobalt);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.72rem;
  font-weight: 700;
}

#portal-screen .brand-section .brand-logo {
  background: #ffffff;
  border: 1px solid var(--v-rule);
  border-radius: 10px;
}

#portal-screen .user-pill {
  border-color: transparent;
  background: transparent;
  padding: 2px;
  gap: 10px;
}

#portal-screen .user-pill-avatar {
  width: 38px;
  height: 38px;
  border: 1.5px solid var(--v-rule);
  background: var(--v-mint);
}

#portal-screen .user-pill-name {
  color: var(--v-ink);
  font-size: 0.82rem;
  font-weight: 700;
}

#portal-screen .user-pill-role {
  color: var(--v-muted);
  font-size: 0.72rem;
  font-weight: 600;
}

#portal-screen .user-pill .btn {
  min-width: 44px;
  min-height: 40px;
}

/* Contenedor de vistas */
#portal-screen #app-container {
  max-width: 1400px;
  padding: 28px var(--v-content-gutter) 48px;
}

#portal-screen .main-content,
#portal-screen #app-container,
#portal-screen #app-container :is(h2, h3)[tabindex="-1"] {
  scroll-margin-top: 86px;
}

#portal-screen .view-heading,
#portal-screen .role-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin: 0 0 22px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--v-rule);
}

#portal-screen :is(.view-heading, .role-hero, .admin-brand-banner) h2 {
  color: var(--v-ink);
  font-size: clamp(1.55rem, 2.3vw, 2.05rem);
  font-weight: 800;
  line-height: 1.14;
  letter-spacing: -0.032em;
  text-wrap: balance;
}

#portal-screen :is(.view-heading, .role-hero, .admin-brand-banner) p {
  max-width: 65ch;
  margin-top: 6px;
  color: var(--v-muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.view-actions > *,
.role-actions > * {
  max-width: 100%;
}

/* ==============================================================================
   COMPONENTES COMPARTIDOS (TARJETAS, BOTONES, BADGES, FORMULARIOS, TABLAS)
   ============================================================================== */

#portal-screen .card,
#portal-screen .role-panel,
#portal-screen .access-card,
#portal-screen .patient-card,
#portal-screen .notice-column,
#portal-screen .intake-inbox {
  background: var(--v-surface);
  border: 1px solid var(--v-rule);
  border-radius: 14px;
  box-shadow: var(--v-shadow);
}

#portal-screen .card:hover {
  box-shadow: var(--v-shadow);
}

#portal-screen .card .card-header {
  min-height: 58px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--v-rule);
}

#portal-screen .card-title {
  color: var(--v-ink);
  font-size: 1.02rem;
  font-weight: 780;
  line-height: 1.35;
}

#portal-screen .card-title > svg,
#portal-screen .role-section-heading > svg {
  color: var(--v-cobalt);
}

#portal-screen .card .card-body {
  padding: 18px 20px;
}

/* Botones */
.btn {
  min-height: 44px;
  padding: 9px 16px;
  border-radius: 10px;
  font-weight: 650;
  text-align: center;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.btn-sm {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 0.78rem;
  border-radius: 8px;
}

.btn-primary {
  background: var(--v-accent);
  border-color: var(--v-accent);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--v-accent-dark);
  border-color: var(--v-accent-dark);
}

.btn-secondary {
  color: var(--v-ink);
  background: #ffffff;
  border: 1px solid var(--v-rule-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--v-mint);
  border-color: #b4c2ea;
}

.btn-access {
  color: #153b96;
  background: #f0f4ff;
  border: 1px solid #cad7f7;
}

.btn-access:hover:not(:disabled) {
  background: #e1e9ff;
}

.btn-whatsapp-soft {
  color: #195b37;
  background: #edf8f1;
  border: 1px solid #bde2ca;
}

.btn-whatsapp-soft:hover:not(:disabled) {
  background: #1f6c43;
  border-color: #1f6c43;
  color: #ffffff;
}

.btn-whatsapp {
  background: #1f6c43;
  border-color: #1f6c43;
  color: #ffffff;
}

.btn-whatsapp:hover:not(:disabled) {
  background: #165232;
  border-color: #165232;
}

/* Badges semánticos */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 700;
  line-height: 1.2;
}

.badge-teal { background: #fce6f0; color: #870f45; }
.badge-blue { background: #e5ecff; color: #123892; }
.badge-green { background: #e3f5e8; color: #1b5c34; }
.badge-amber { background: #fef3d6; color: #8a4b0b; }
.badge-red { background: #fde4e6; color: #961b26; }
.badge-purple { background: #ece8ff; color: #432896; }

/* Formularios y búsqueda */
.form-label,
.form-field {
  color: var(--v-ink);
}

.form-input,
.form-select,
.form-textarea {
  min-height: 44px;
  border: 1.5px solid #cfd6e8;
  border-radius: 10px;
  background: #ffffff;
  color: var(--v-ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="file"].form-input {
  padding: 6px 10px;
}

.form-textarea {
  min-height: 84px;
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: #a9b5d6;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--v-accent);
  box-shadow: 0 0 0 3px rgba(180, 20, 90, 0.12);
}

.patient-search,
.access-search {
  min-height: 44px;
  border: 1.5px solid #cfd6e8;
  border-radius: 10px;
  background: #ffffff;
  color: var(--v-muted);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.patient-search input,
.access-search input {
  height: 42px;
  color: var(--v-ink);
  font-size: 0.9rem;
  text-overflow: ellipsis;
}

.patient-search [role="status"] {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--v-mint);
  color: var(--v-cobalt);
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.patient-search:focus-within,
.access-search:focus-within {
  border-color: var(--v-cobalt);
  box-shadow: 0 0 0 3px rgba(23, 71, 181, 0.12);
}

/* Barra de filtros unificada */
#portal-screen .admin-filter-bar {
  background: var(--v-surface);
  border: 1px solid var(--v-rule);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 18px;
  box-shadow: var(--v-shadow);
  align-items: end;
}

#portal-screen .card > .admin-filter-bar {
  margin-bottom: 0;
  border: 0;
  border-bottom: 1px solid var(--v-rule);
  border-radius: 14px 14px 0 0;
  box-shadow: none;
  background: #f9fafe;
}

#portal-screen .patient-directory-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
}

#portal-screen .patient-directory-tools .patient-search-field {
  flex: 1 1 280px;
  min-width: 0;
}

#portal-screen .patient-directory-tools .form-field {
  min-width: 0;
}

/* Tablas */
.table-responsive {
  border-radius: 0 0 14px 14px;
}

.table-responsive thead th {
  background: #f1f4fb;
  color: #324074;
  border-bottom: 1px solid var(--v-rule);
  font-size: 0.71rem;
  font-weight: 750;
  letter-spacing: 0.045em;
  white-space: normal;
  padding: 12px 14px;
}

.table-responsive td {
  border-bottom: 1px solid #ebeef7;
  padding: 13px 14px;
  line-height: 1.45;
}

.table-responsive tr:hover td {
  background: #f9fafe;
}

.table-responsive a {
  overflow-wrap: anywhere;
}

.admin-table-empty {
  padding: 24px 18px;
  color: var(--v-muted);
  text-align: start;
  line-height: 1.55;
}

/* Tabular nums en cifras, fechas y horas */
#portal-screen :is(.stat-val, .admin-dashboard-date, input[type="date"], input[type="time"], .role-visit-date, .patient-appointment-time strong, .promo-price-val) {
  font-variant-numeric: tabular-nums;
}

/* ==============================================================================
   1. PANEL DE ADMINISTRACIÓN
   ============================================================================== */

#app-container .admin-brand-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: end;
  gap: 16px;
  margin: 0 0 22px;
  padding: 0 0 18px;
  border: 0;
  border-bottom: 1px solid var(--v-rule);
  border-radius: 0;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--v-ink);
}

#app-container .admin-brand-banner::before,
#app-container .admin-brand-banner::after {
  content: none;
}

.admin-home-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

#portal-screen .admin-brand-banner .admin-home-actions .btn {
  justify-content: center;
  min-height: 46px;
  padding: 9px 15px;
  border-radius: 10px;
  box-shadow: none;
  font-size: 0.88rem;
  font-weight: 700;
}

#portal-screen .admin-brand-banner .admin-home-actions .btn:first-child {
  border-color: var(--v-accent);
  background: var(--v-accent);
  color: #ffffff;
}

#portal-screen .admin-brand-banner .admin-home-actions .btn:first-child:hover {
  background: var(--v-accent-dark);
  border-color: var(--v-accent-dark);
}

#portal-screen .admin-brand-banner .admin-home-actions .btn:not(:first-child) {
  color: var(--v-ink);
  border-color: var(--v-rule-strong);
  background: var(--v-surface);
}

#portal-screen .admin-brand-banner .admin-home-actions .btn:not(:first-child):hover {
  background: var(--v-mint);
  border-color: #b4c2ea;
}

/* Tira de KPIs del panel */
#portal-screen .admin-day-summary {
  gap: 0;
  margin-bottom: 22px;
  overflow: hidden;
  border: 1px solid var(--v-rule);
  border-radius: 14px;
  background: var(--v-surface);
  box-shadow: var(--v-shadow);
}

#portal-screen .admin-day-summary .stat-card {
  gap: 12px;
  min-width: 0;
  min-height: 88px;
  padding: 16px;
  border: 0;
  border-inline-end: 1px solid var(--v-rule);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
  text-align: left;
  width: 100%;
}

#portal-screen .admin-day-summary .stat-card:last-child {
  border-inline-end: 0;
}

#portal-screen .admin-day-summary .admin-stat-action {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

#portal-screen .admin-day-summary .admin-stat-action:hover {
  background: #f5f7fe;
  transform: none;
  box-shadow: none;
}

#portal-screen .admin-day-summary .admin-stat-action:focus-visible {
  outline-offset: -4px;
}

#portal-screen .admin-day-summary .stat-icon,
#portal-screen .admin-payment-summary .stat-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 10px;
}

#portal-screen .admin-day-summary .stat-icon svg,
#portal-screen .admin-payment-summary .stat-icon svg {
  width: 19px;
  height: 19px;
}

#portal-screen .admin-day-summary .stat-val,
#portal-screen .admin-payment-summary .stat-val {
  font-size: 1.42rem;
  font-weight: 800;
  line-height: 1.15;
  color: var(--v-ink);
}

#portal-screen .admin-day-summary .stat-label,
#portal-screen .admin-payment-summary .stat-label {
  margin-top: 3px;
  font-size: 0.77rem;
  font-weight: 550;
  color: var(--v-muted);
  text-transform: none;
  letter-spacing: 0;
}

#portal-screen .admin-payment-summary .stat-card {
  align-items: center;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--v-rule);
  box-shadow: var(--v-shadow);
  transform: none;
}

#portal-screen .admin-payment-summary .stat-card:hover {
  transform: none;
  box-shadow: var(--v-shadow);
}

#portal-screen .admin-payment-summary .stat-card .stat-val,
#portal-screen .admin-payment-summary .stat-card .stat-label {
  display: block;
}

/* Rejilla del panel */
#portal-screen .admin-dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

#portal-screen .dashboard-notices {
  margin-top: 16px;
}

#portal-screen .admin-dashboard-agenda .card-header {
  background: #f1f4fe;
}

#portal-screen .admin-dashboard-payments .card-header {
  background: var(--v-lime-soft);
}

#portal-screen .admin-dashboard-payments .card-title > svg {
  color: var(--v-lime-ink);
}

#portal-screen .dashboard-notices .card-header {
  background: var(--v-blush);
}

#portal-screen .dashboard-notices .card-title > svg {
  color: var(--v-accent);
}

#portal-screen .admin-dashboard-list .admin-dashboard-appointment {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

#portal-screen .admin-dashboard-list .admin-dashboard-payment {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px 14px;
}

#portal-screen .admin-dashboard-date {
  min-width: 6.2rem;
  color: #20398a;
}

#portal-screen .admin-dashboard-row-actions {
  flex-wrap: wrap;
}

#portal-screen .admin-dashboard-row-actions .btn {
  min-width: 42px;
}

.admin-payment-action {
  white-space: nowrap;
}

#portal-screen .admin-agenda-clear:disabled {
  color: var(--v-muted);
  background: #eceff8;
  border-color: var(--v-rule);
  cursor: default;
  opacity: 1;
}

/* Directorio de pacientes (Admin & Profesional) */
#portal-screen .patient-card {
  padding: 18px;
  transition: border-color 0.16s ease;
}

#portal-screen .patient-card-avatar {
  width: 50px;
  height: 50px;
  border: 1.5px solid var(--v-blush-border);
  background: var(--v-blush);
}

#portal-screen .patient-card-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin: 14px 0 12px;
  padding: 12px 0;
  border-top: 1px solid #edf0f7;
  border-bottom: 1px solid #edf0f7;
}

#portal-screen .patient-card-detail-wide {
  grid-column: 1 / -1;
}

#portal-screen .patient-card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

#portal-screen .patient-card-action-wide {
  grid-column: 1 / -1;
}

/* Expedientes y documentos por paciente */
.dossier-picker-wrap {
  min-width: min(100%, 320px);
}

.dossier-picker-field {
  min-width: min(100%, 300px);
}

.dossier-header-card {
  overflow: hidden;
}

.dossier-header-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px 20px;
  padding: 20px;
}

.dossier-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--v-blush-border);
  background: var(--v-blush);
  flex: none;
}

.dossier-identity {
  min-width: 0;
}

.dossier-identity h3 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--v-ink);
  overflow-wrap: anywhere;
}

.dossier-meta {
  margin-top: 4px;
  color: var(--v-muted);
  font-size: 0.84rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.dossier-header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.dossier-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--v-rule);
  background: #f9fafe;
}

.dossier-kpis > div {
  padding: 13px 18px;
  border-inline-end: 1px solid var(--v-rule);
}

.dossier-kpis > div:last-child {
  border-inline-end: 0;
}

.dossier-kpis span {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--v-muted);
}

.dossier-kpis strong {
  display: block;
  margin-top: 2px;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--v-ink);
  font-variant-numeric: tabular-nums;
}

.dossier-form {
  display: grid;
  gap: 12px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--v-rule);
}

.dossier-note-item {
  padding: 14px;
  border: 1px solid var(--v-rule);
  border-radius: 12px;
  background: #fbfcff;
}

@media (max-width: 980px) {
  .dossier-header-main {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .dossier-header-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
  .dossier-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dossier-kpis > div:nth-child(-n+2) {
    border-bottom: 1px solid var(--v-rule);
  }
  .dossier-kpis > div:nth-child(2n) {
    border-inline-end: 0;
  }
}

@media (max-width: 560px) {
  .dossier-header-main {
    grid-template-columns: minmax(0, 1fr);
  }
}

#portal-screen .patient-card-actions .btn {
  min-height: 40px;
  font-size: 0.8rem;
}

#portal-screen .professional-patient-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

#portal-screen .professional-patient-grid .patient-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

#portal-screen .professional-patient-grid .patient-card-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
}

/* Equipo profesional */
#portal-screen .professional-card-footer {
  padding: 13px 20px;
  background: #f9fafe;
  border-top: 1px solid var(--v-rule);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.professional-avatar-ring {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--v-blush-border);
  background: var(--v-mint);
  flex: none;
}

/* Evaluaciones y notas desplegables */
.evaluation-entry {
  margin-bottom: 18px;
}

.evaluation-entry > summary,
.evaluation-details > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 16px;
  cursor: pointer;
  color: var(--v-cobalt);
  font-weight: 750;
  list-style: none;
}

.evaluation-entry > summary::-webkit-details-marker,
.evaluation-details > summary::-webkit-details-marker {
  display: none;
}

.evaluation-entry > summary::before,
.evaluation-details > summary::before {
  content: '+';
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 7px;
  background: var(--v-mint);
  color: var(--v-cobalt);
  font-size: 1.05rem;
  font-weight: 700;
}

.evaluation-entry[open] > summary::before,
.evaluation-details[open] > summary::before {
  content: '−';
}

.evaluation-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 175px), 1fr));
  gap: 12px;
  align-items: end;
  padding: 10px 16px 16px;
  border-top: 1px solid var(--v-rule);
}

.evaluation-form :is(input, select) {
  width: 100%;
  min-width: 0;
}

.evaluation-record {
  display: grid;
  justify-items: start;
  gap: 9px;
  padding: 16px 20px;
}

.evaluation-record + .evaluation-record {
  border-top: 1px solid var(--v-rule);
}

.evaluation-record-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: start;
  gap: 8px;
  width: 100%;
}

.evaluation-record-heading h4 {
  color: var(--v-ink);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.evaluation-record-heading p,
.evaluation-meta {
  color: var(--v-muted);
  font-size: 0.875rem;
}

.evaluation-meta:empty {
  display: none;
}

.evaluation-details {
  width: 100%;
  background: #f5f7fe;
  border: 1px solid var(--v-rule);
  border-radius: 10px;
}

.evaluation-delivery {
  max-width: 100%;
}

.evaluation-delivery .btn {
  white-space: normal;
}

.evaluation-error {
  grid-column: 1 / -1;
  margin-top: 5px;
  color: var(--v-accent-dark);
  font-size: 0.875rem;
}

/* ==============================================================================
   2. VISTAS COMPARTIDAS DE PSICÓLOGO Y PACIENTE
   ============================================================================== */

.role-two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.38fr) minmax(0, 1fr);
  align-items: stretch;
  gap: 16px;
  margin-block: 0 24px;
}

.role-panel {
  min-width: 0;
  padding: 20px;
}

.role-panel-primary {
  background: var(--v-mint);
  border-color: var(--v-mint-border);
}

.role-feature-value {
  margin-block: 8px 4px;
  color: var(--v-cobalt);
  font-size: clamp(1.14rem, 1.9vw, 1.38rem);
  font-weight: 790;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.role-muted,
.role-meta {
  color: var(--v-muted);
  overflow-wrap: anywhere;
}

.role-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 0.85rem;
}

.role-meta > span:has(> svg) {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.role-meta > span > svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.role-section-heading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.role-section-heading :is(h2, h3) {
  color: var(--v-ink);
  font-size: 1.06rem;
  font-weight: 780;
}

.role-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.role-panel > .role-actions {
  margin-top: 14px;
}

.role-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 16px;
  border: 1px dashed var(--v-rule-strong);
  border-radius: 10px;
  color: var(--v-muted);
  background: var(--v-surface-subtle);
  line-height: 1.55;
}

.role-empty svg {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--v-cobalt);
}

/* Accesos rápidos uniformes */
#portal-screen .role-shortcuts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px 14px;
  margin-bottom: 16px;
  padding: 6px 14px;
  border: 1px solid var(--v-rule);
  border-radius: 14px;
  background: var(--v-surface);
  box-shadow: var(--v-shadow);
}

#portal-screen .role-shortcut {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  min-height: 60px;
  min-width: 0;
  padding: 10px 10px;
  border: 0;
  border-bottom: 1px solid #eceff8;
  border-radius: 8px;
  background: transparent;
  color: var(--v-ink);
  font-weight: 680;
  text-align: left;
  transition: background-color 0.15s ease;
}

#portal-screen .role-shortcut:hover {
  background: var(--v-mint);
}

#portal-screen .role-shortcut svg:first-child {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  color: var(--v-accent);
}

#portal-screen .role-shortcut svg:last-child {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  color: var(--v-muted);
}

#portal-screen .role-shortcut > span {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
}

#portal-screen .role-shortcut strong {
  color: var(--v-cobalt);
  font-size: 0.92rem;
  font-weight: 740;
}

#portal-screen .role-shortcut small {
  color: var(--v-muted);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.35;
}

#portal-screen .role-shortcut:last-child,
#portal-screen .role-shortcut:nth-last-child(2):nth-child(odd) {
  border-bottom-color: transparent;
}

#portal-screen [data-portal-view="agenda"] > .role-shortcuts {
  margin-top: 18px;
}

/* Filtros de agenda y notas */
#portal-screen .role-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

#portal-screen .role-filter {
  min-height: 42px;
  padding: 7px 12px;
  border: 1px solid var(--v-rule);
  border-radius: 9px;
  background: #f8f9fd;
  color: var(--v-muted);
  font-weight: 650;
  font-size: 0.86rem;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

#portal-screen .role-filter:hover {
  background: var(--v-mint);
  color: var(--v-ink);
}

#portal-screen .agenda-periods button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

#portal-screen .agenda-periods button span {
  padding: 1px 7px;
  border-radius: 6px;
  background: #e7ecfb;
  color: #213785;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

#portal-screen .agenda-periods button[aria-pressed="true"],
#portal-screen .note-filters button[aria-pressed="true"] {
  background: #fcebf3;
  border-color: #dfaac4;
  color: #870f45;
}

#portal-screen .agenda-periods button[aria-pressed="true"] span {
  background: #f6d3e4;
  color: #7c0d3f;
}

/* Tarjetas de cita en agenda de psicólogo y paciente */
#portal-screen .role-visit-list {
  display: grid;
  gap: 10px;
}

#portal-screen .role-visit {
  display: grid;
  grid-template-columns: minmax(88px, auto) minmax(0, 1fr);
  gap: 10px 16px;
  padding: 15px 16px;
  border: 1px solid var(--v-rule);
  border-radius: 12px;
  background: #fcfdff;
}

#portal-screen .role-visit-date {
  display: grid;
  align-content: start;
  gap: 2px;
  color: var(--v-cobalt);
  font-weight: 740;
}

#portal-screen .role-visit-body {
  display: grid;
  gap: 7px;
  min-width: 0;
}

#portal-screen .role-visit-person {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  overflow-wrap: anywhere;
}

#portal-screen .role-visit-person > div {
  min-width: 0;
}

#portal-screen .role-visit-person h3 {
  font-weight: 760;
  color: var(--v-ink);
}

#portal-screen .role-visit-person p {
  font-size: 0.86rem;
  color: var(--v-muted);
}

.load-more-visits {
  margin-top: 12px;
}

.role-resource-section {
  margin-top: 18px;
}

/* Notas de sesión y evolución clínica */
#portal-screen .note-entry {
  min-width: 0;
  padding: 18px 20px;
}

.note-entry-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 13px;
}

.note-entry-heading > div {
  min-width: 0;
}

.note-entry-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.note-entry-heading h3,
.note-entry-heading h4 {
  overflow-wrap: anywhere;
}

.note-text {
  color: var(--v-ink);
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.note-reply {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--v-mint);
  border: 1px solid var(--v-mint-border);
  color: #21316b;
  font-size: 0.88rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.note-reply-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.note-reply-actions input {
  flex: 1 1 180px;
  min-width: 0;
}

.patient-note-entry {
  max-width: 820px;
}

.clinical-entry {
  max-width: 900px;
}

/* Perfil del profesional */
.profile-avatar-ring {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--v-blush-border);
  background: var(--v-mint);
  box-shadow: var(--v-shadow);
  flex: none;
}

.profile-branch-text {
  color: var(--v-cobalt);
  font-weight: 680;
}

.profile-schedule-box {
  padding: 16px;
  border-radius: 12px;
  background: var(--v-mint);
  border: 1px solid var(--v-mint-border);
}

.profile-schedule-box h4 {
  color: var(--v-ink);
  font-weight: 760;
  margin-bottom: 4px;
}

.profile-schedule-box p {
  color: var(--v-cobalt);
  font-size: 0.84rem;
  font-weight: 550;
}

/* ==============================================================================
   3. PORTAL DEL PACIENTE (INICIO, BIBLIOTECA, TERMÓMETRO)
   ============================================================================== */

#portal-screen .patient-next-appointment {
  background: linear-gradient(145deg, #fff5fa 0%, #ffffff 100%);
  border-color: var(--v-blush-border);
}

#portal-screen .patient-next-appointment .role-section-heading > svg {
  color: var(--v-accent);
}

#portal-screen .patient-next-appointment .role-feature-value {
  color: #7c0e40;
}

.patient-appointment-time {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin: 2px 0 10px;
  color: #6f103c;
  font-size: 1.12rem;
  font-weight: 750;
}

.patient-appointment-time strong {
  font-size: 2rem;
  line-height: 1.1;
}

#portal-screen .patient-next-appointment .role-meta {
  margin-bottom: 8px;
}

.patient-specialist .role-specialist-avatar {
  width: 68px;
  height: 68px;
}

.patient-specialist .role-visit-person + .role-meta {
  margin-top: 12px;
}

.specialist-bio {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--v-rule);
}

.specialist-bio h4 {
  margin-bottom: 5px;
  font-weight: 750;
}

/* Avisos */
.role-bulletins {
  max-width: 820px;
  display: grid;
  gap: 10px;
}

#portal-screen .role-bulletins .announcement-reader-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  padding: 16px 18px;
  border: 1px solid var(--v-rule);
  border-radius: 14px;
  background: var(--v-surface);
}

#portal-screen .role-bulletins [data-latest] {
  border-color: var(--v-mint-border);
  background: #f4f7ff;
}

#portal-screen .announcement-reader-card h3 {
  margin: 0 0 3px;
}

#portal-screen .announcement-reader-card .announcement-date {
  color: var(--v-muted);
}

#portal-screen .announcement-reader-card p {
  margin-top: 5px;
  overflow-wrap: anywhere;
}

/* Biblioteca */
.library-toolbar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-bottom: 16px;
}

.library-toolbar p {
  padding-block: 10px;
  color: var(--v-muted);
  font-size: 0.875rem;
}

.library-reading-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  align-items: stretch;
  gap: 16px;
}

.library-reading {
  --library-wash: #eaefff;
  --library-ink: #1747b5;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  border: 1px solid var(--v-rule);
  border-radius: 14px;
  background: var(--v-surface);
  box-shadow: var(--v-shadow);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.library-reading:hover {
  border-color: var(--v-rule-strong);
  box-shadow: var(--v-shadow-md);
}

.library-reading:nth-child(3n + 2) {
  --library-wash: #fce9f2;
  --library-ink: #8e1048;
}

.library-reading:nth-child(3n + 3) {
  --library-wash: #eef6de;
  --library-ink: #386b15;
}

.library-reading-art {
  display: grid;
  place-items: center;
  min-height: 88px;
  color: var(--library-ink);
  background: var(--library-wash);
}

.library-reading-art svg {
  width: 34px;
  height: 34px;
  stroke-width: 1.75;
}

.library-reading-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 16px 18px 14px;
}

.library-reading-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 7px 12px;
  margin-bottom: 8px;
}

.library-reading-meta > span:last-child {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--v-muted);
  font-size: 0.8rem;
}

.library-reading-meta svg {
  width: 15px;
  height: 15px;
}

.library-reading h3 {
  color: var(--v-ink);
  font-size: 1.06rem;
  font-weight: 780;
  line-height: 1.35;
}

.library-reading p {
  flex: 1;
  margin: 8px 0 14px;
  color: var(--v-muted);
  font-size: 0.9rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.library-reading .library-link {
  color: var(--library-ink);
  padding: 12px 0 2px;
}

.library-reading .library-link:hover {
  color: var(--v-accent);
}

.library-reading .library-link svg {
  width: 18px;
  height: 18px;
}

/* Termómetro emocional */
.mood-btn {
  min-height: 54px;
  border: 1.5px solid var(--v-rule);
  border-radius: 12px;
  background: #ffffff;
  color: var(--v-ink);
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.mood-btn:hover {
  border-color: var(--v-accent);
  background: var(--v-blush);
}

.mood-btn.selected {
  border-color: var(--v-accent);
  background: var(--v-accent);
  color: #ffffff;
}

.mood-chart-panel {
  padding: 18px 20px;
  background: var(--v-surface);
  border: 1px solid var(--v-rule);
  border-radius: 14px;
  box-shadow: var(--v-shadow);
}

.mood-chart-title {
  display: block;
  margin-bottom: 4px;
  color: var(--v-accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Promociones armonizadas */
.promo-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--v-rule);
  border-radius: 14px;
  background: var(--v-surface);
  box-shadow: var(--v-shadow);
}

.promo-card-accent {
  height: 4px;
  width: 100%;
  background: linear-gradient(90deg, var(--v-accent) 0%, var(--v-cobalt) 100%);
}

/* Estados de vista */
.portal-view-state {
  display: grid;
  justify-items: start;
  gap: 10px;
  min-height: 92px;
  padding: 19px 20px;
  border: 1px solid var(--v-rule);
  border-radius: 14px;
  background: var(--v-surface);
  color: var(--v-muted);
  line-height: 1.55;
}

.portal-view-state-error {
  border-color: #e4b5c4;
  background: #fff6f8;
  color: #70183a;
}

/* Modales */
#wa-send-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.modal-backdrop {
  overscroll-behavior: contain;
}

.modal-backdrop .modal-card {
  border-radius: 16px;
  background: var(--v-surface);
  border: 1px solid var(--v-rule);
  box-shadow: 0 22px 54px rgba(20, 29, 70, 0.18);
}

.modal-backdrop .modal-header,
.modal-backdrop .modal-footer {
  background: #f8f9fd;
  border-color: var(--v-rule);
}

.modal-backdrop .modal-header > div {
  min-width: 0;
}

.modal-backdrop .modal-header :is(h2, h3) {
  color: var(--v-ink);
  overflow-wrap: anywhere;
}

.modal-backdrop .modal-close {
  flex: 0 0 auto;
}

.modal-backdrop .modal-close:hover {
  background: var(--v-blush);
  color: var(--v-accent-dark);
}

.modal-backdrop .modal-footer {
  gap: 10px;
}

.modal-backdrop .modal-footer :is(.btn, button) {
  min-height: 44px;
}

.patient-registration-photo {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--v-rule);
  text-align: center;
}

.patient-registration-photo img {
  width: 72px;
  height: 72px;
  margin-bottom: 3px;
  border: 2px solid var(--v-blush-border);
  border-radius: 50%;
  background: var(--v-mint);
  object-fit: cover;
}

.patient-registration-photo .form-label { margin-bottom: 0; }
.patient-registration-photo .form-input { width: min(100%, 320px); min-width: 0; text-align: start; }
.patient-registration-photo small { color: var(--v-muted); font-size: 0.78rem; }
.patient-registration-heading { color: var(--v-ink); font-size: 0.96rem; font-weight: 750; }
#new-client-form .patient-registration-heading + div { margin-top: 10px; }

/* Ficha pública de registro */
#intake-screen {
  background: var(--v-paper);
}

#intake-screen .intake-header {
  border-color: var(--v-rule);
}

#intake-screen .intake-header img {
  width: 65px;
}

#intake-screen .intake-card {
  border: 1px solid var(--v-rule);
  border-radius: 16px;
  box-shadow: var(--v-shadow);
}

#intake-screen .intake-intro h1 {
  color: var(--v-ink);
}

#intake-screen :is(.intake-header span, .intake-intro p, .intake-privacy) {
  color: var(--v-muted);
}

#intake-screen .intake-form-note {
  border-color: var(--v-rule);
  background: var(--v-mint);
  color: var(--v-ink);
}

#intake-screen .intake-form-note svg {
  color: var(--v-cobalt);
}

/* ==============================================================================
   ADAPTACIÓN RESPONSIVA (ESCRITORIO, TABLET, MÓVIL)
   ============================================================================== */

@media (min-width: 1230px) {
  #portal-screen #app-container .admin-brand-banner {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

@media (min-width: 820px) {
  #portal-screen [data-portal-view="agenda"] > .role-shortcuts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  #portal-screen [data-portal-view="agenda"] > .role-shortcuts .role-shortcut {
    border-bottom-color: transparent;
  }
}

@media (max-width: 1023px) {
  :root {
    --v-content-gutter: 22px;
  }
  #portal-screen.portal-layout:not(.hidden) {
    display: block;
  }
  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 292px);
    height: 100dvh;
    overflow-y: auto;
    padding: 15px 13px;
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform 0.24s ease, visibility 0.24s;
  }
  .app-sidebar.is-open {
    transform: translateX(0);
    visibility: visible;
  }
  .sidebar-backdrop:not(.hidden) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    border: 0;
    background: rgba(17, 25, 56, 0.42);
  }
  .sidebar-toggle,
  .sidebar-close {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border-radius: 10px;
  }
  .sidebar-toggle {
    color: var(--v-ink);
    border: 1px solid var(--v-rule);
    background: var(--v-surface);
  }
  .sidebar-close {
    margin-inline-start: auto;
    color: #d4daf9;
    border: 0;
    background: transparent;
  }
  .sidebar-toggle > svg,
  .sidebar-close > svg {
    width: 19px;
    height: 19px;
  }
  :is(.sidebar-toggle, .sidebar-close) > i[data-lucide] {
    display: none;
  }
  .sidebar-toggle:has(> i[data-lucide="menu"])::before {
    content: "";
    width: 17px;
    height: 12px;
    border-block: 2px solid;
    background: linear-gradient(currentColor, currentColor) center / 100% 2px no-repeat;
  }
  .sidebar-close:has(> i[data-lucide="x"])::before {
    content: "×";
    font-size: 1.45rem;
    line-height: 1;
  }

  #portal-screen .header-container {
    min-height: 66px;
  }
  #portal-screen .header-container .brand-logo {
    width: 48px;
    height: 38px;
  }
  #portal-screen #app-container {
    padding-top: 22px;
  }
  #portal-screen .admin-day-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #portal-screen .admin-day-summary .stat-card:nth-child(-n+2) {
    border-bottom: 1px solid var(--v-rule);
  }
  #portal-screen .admin-day-summary .stat-card:nth-child(2n) {
    border-inline-end: 0;
  }
  /* En tablet/móvil evitamos compresión de búsqueda en Pacientes */
  #portal-screen .patient-directory-tools .patient-search-field {
    flex-basis: 100%;
  }
}

@media (max-width: 950px) {
  .role-two-column,
  #portal-screen .admin-dashboard-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (min-width: 710px) and (max-width: 950px) {
  #portal-screen .role-two-column {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  }
}

/* Tablas convertidas a tarjetas compactas en <= 1100px */
@media (max-width: 1100px) {
  .appointment-responsive tbody {
    display: grid;
    gap: 12px;
    padding: 14px;
  }
  .appointment-responsive tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border: 1px solid var(--v-rule);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: var(--v-shadow);
    overflow: hidden;
  }
  .appointment-responsive td {
    display: block;
    position: static;
    width: auto;
    padding: 10px 14px;
    border-bottom: 1px solid #eef1f8;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    max-width: none !important;
  }
  .appointment-responsive td::before {
    content: attr(data-label);
    position: static;
    display: block;
    width: auto;
    margin-bottom: 3px;
    font-size: 0.7rem;
    font-weight: 750;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--v-muted);
  }
  .appointment-responsive td[data-label="Lugar o enlace"],
  .appointment-responsive td[data-label="Acciones"] {
    grid-column: 1 / -1;
  }
  .appointment-responsive td:last-child {
    border-bottom: 0;
    background: #f9fafe;
  }
}

@media (max-width: 650px) {
  :root {
    --v-content-gutter: 14px;
  }
  #portal-screen .header-container {
    gap: 8px;
    padding-inline: 12px;
  }
  #portal-screen .header-container .brand-logo {
    width: 40px;
    height: 34px;
  }
  #portal-screen .brand-title {
    font-size: 0.9rem;
  }
  #portal-screen #app-container {
    padding-top: 18px;
  }
  #portal-screen :is(.view-heading, .role-hero, .admin-brand-banner) h2 {
    font-size: 1.6rem;
  }
  #portal-screen .view-heading,
  #portal-screen .role-hero {
    margin-bottom: 16px;
    padding-bottom: 14px;
  }
  #portal-screen .card .card-header,
  #portal-screen .card .card-body {
    padding-inline: 14px;
  }
  #portal-screen .role-panel {
    padding: 16px;
  }
  #portal-screen .role-two-column {
    gap: 12px;
  }
  #portal-screen .role-visit {
    grid-template-columns: minmax(0, 1fr);
    padding: 13px;
  }
  #portal-screen .role-visit-date {
    display: flex;
    justify-content: space-between;
    gap: 8px;
  }
  #portal-screen .role-shortcuts {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  #portal-screen .role-shortcut:nth-last-child(2):nth-child(odd) {
    border-bottom-color: #eceff8;
  }
  #portal-screen .admin-brand-banner .admin-home-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #portal-screen .admin-home-actions .btn:first-child {
    grid-column: 1 / -1;
  }
  #portal-screen .admin-day-summary .stat-card {
    min-height: 80px;
    gap: 9px;
    padding: 12px;
  }
  #portal-screen .admin-day-summary .stat-icon {
    width: 34px;
    height: 34px;
  }
  #portal-screen .admin-day-summary .stat-icon svg {
    width: 17px;
    height: 17px;
  }
  #portal-screen .admin-day-summary .stat-val {
    font-size: 1.18rem;
  }
  #portal-screen .admin-day-summary .stat-label {
    font-size: 0.72rem;
  }
  #portal-screen .patient-directory-tools {
    align-items: stretch;
  }
  #portal-screen .admin-filter-bar:has(#admin-agenda-query, #admin-payment-query) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #portal-screen .admin-filter-bar > label:has(input[type="search"]) {
    grid-column: 1 / -1;
  }
  #portal-screen .admin-filter-bar :is(input, select) {
    min-width: 0;
    width: 100%;
  }
  #portal-screen .admin-dashboard-list .admin-dashboard-appointment {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px 12px;
    align-items: start;
  }
  #portal-screen .admin-dashboard-list .admin-dashboard-payment {
    grid-template-columns: minmax(0, 1fr);
  }
  #portal-screen .admin-dashboard-appointment .badge {
    justify-self: start;
    align-self: center;
  }
  #portal-screen .admin-dashboard-row-actions {
    justify-content: end;
  }
  #portal-screen .admin-dashboard-date {
    min-width: 0;
  }
  .appointment-responsive tbody {
    padding: 10px;
  }
  .appointment-responsive tr {
    grid-template-columns: minmax(0, 1fr);
  }
  .appointment-responsive td {
    padding: 10px 14px;
  }
  .appointment-responsive td::before {
    position: static;
    width: auto;
  }
  .modal-backdrop .modal-footer {
    flex-wrap: wrap;
  }
  .portal-view-state {
    padding-inline: 15px;
  }
}

@media (max-width: 360px) {
  #portal-screen .header-container .brand-logo { display: none; }
  #portal-screen .user-pill-avatar { display: none; }
  #portal-screen .admin-day-summary .stat-card {
    align-items: flex-start;
    flex-direction: column;
  }
  #portal-screen .admin-home-actions {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-sidebar,
  .btn,
  .library-reading,
  .mood-btn {
    transition: none;
  }
}
