:root {
  /* Tema claro fijo: evita que el modo oscuro del sistema/navegador cambie los colores */
  color-scheme: only light;

  /* Paleta "Minimal 01 · Marfil esencial" (marfil, tinta cálida y dorado) */
  --bg-canvas: #F7F5F0;
  --bg-sidebar: #FBFAF7;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F6F3ED;
  --bg-subtle-hover: #EEE9E1;
  --bg-selected: #F5F1E9;

  --gold-primary: #B18B4A;
  --gold-hover: #977538;
  --gold-light: #DFCDA8;
  --gold-soft: #F8F3EA;
  --gold-border: #D6C39D;

  --text-primary: #37332F;
  --text-secondary: #777168;
  --text-muted: #A39A8F;

  /* Status & Pastel Accents from Wireframe 1 */
  --pastel-rose: #E5D4CE;
  --pastel-rose-text: #8A5A4C;
  --pastel-sage: #D6E1D8;
  --pastel-sage-text: #476C4F;
  --pastel-lavender: #DFD8E8;
  --pastel-lavender-text: #65537D;
  --pastel-amber: #F5E8D3;
  --pastel-amber-text: #9C6D27;
  --pastel-blue: #D7E1E8;
  --pastel-blue-text: #49667A;

  --status-success-bg: #EEF3EE;
  --status-success-dot: #739076;
  --status-success-text: #5E7A62;

  --status-warning-bg: #F8F1E4;
  --status-warning-dot: #B58A45;
  --status-warning-text: #8F6A31;

  --status-danger-bg: #F9E9E8;
  --status-danger-dot: #C95B54;
  --status-danger-text: #943B35;

  --border-light: #ECE8E1;
  --border-card: #E9E4DC;

  --shadow-sm: 0 4px 14px rgba(81, 70, 56, 0.05);
  --shadow-md: 0 10px 28px rgba(81, 70, 56, 0.08);
  --shadow-lg: 0 18px 42px rgba(81, 70, 56, 0.13);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Samsung Internet y otros navegadores no aplican su "modo oscuro forzado" cuando la página
   declara su propio tema con prefers-color-scheme. Aquí el tema oscuro reutiliza los mismos
   colores claros, así la app se ve igual con el modo oscuro del teléfono activado. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: only light;
    --bg-canvas: #F7F5F0;
    --bg-sidebar: #FBFAF7;
    --bg-surface: #FFFFFF;
    --text-primary: #37332F;
    --text-secondary: #777168;
  }
  html,
  body {
    background-color: #F7F5F0;
    color: #37332F;
  }
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  color-scheme: only light;
  background-color: #F7F5F0;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  -webkit-tap-highlight-color: transparent;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ==========================================================================
   MAIN LAYOUT (SIDEBAR + TOPBAR + WORKSPACE)
   ========================================================================== */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* Sidebar matching Wireframe 1 */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}

.brand-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 10px 20px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 18px;
  cursor: pointer;
}

.brand-logo {
  width: 185px;
  height: auto;
  display: block;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 16px;
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

a.nav-item {
  text-decoration: none;
}

.nav-item:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-selected);
  color: var(--text-primary);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--gold-primary);
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-primary);
  flex-shrink: 0;
}

.nav-divider {
  height: 1px;
  background: var(--border-light);
  margin: 14px 8px;
}

.nav-item.portal-highlight {
  background: var(--gold-soft);
  border: 1px solid var(--gold-border);
  color: var(--gold-hover);
  font-weight: 600;
}

.nav-item.portal-highlight:hover {
  background: #F2EBDD;
}

.sidebar-profile {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border-light);
}

.avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #EEE5D8;
  color: #5C4C35;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.92rem;
  flex-shrink: 0;
}

.profile-meta {
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.logout-btn {
  flex-shrink: 0;
}

.profile-meta h4 {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-meta p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   TOP HEADER BAR
   ========================================================================== */
.main-wrapper {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-light);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.menu-toggle-btn {
  display: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border-card);
  background: var(--bg-subtle);
  color: var(--text-primary);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-overlay {
  display: none;
}

.topbar-title h1 {
  font-family: var(--font-serif);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.2px;
}

.topbar-title p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

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

.mode-switch {
  display: inline-flex;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-card);
}

.mode-btn {
  border: none;
  background: transparent;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mode-btn.active {
  background: var(--gold-primary);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(177, 139, 74, 0.3);
}

.search-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  width: 240px;
}

.search-pill input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.85rem;
  color: var(--text-primary);
  width: 100%;
  font-family: inherit;
}

.search-pill input::placeholder {
  color: var(--text-muted);
}

.icon-circle-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
}

.icon-circle-btn:hover {
  background: var(--bg-subtle-hover);
}

.notif-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold-primary);
  border: 1.5px solid var(--bg-sidebar);
}

/* ==========================================================================
   CONTENT CANVAS & BUTTONS
   ========================================================================== */
.content-area {
  padding: 26px 32px 48px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}

.btn-gold {
  background: var(--gold-primary);
  color: #FFFFFF;
  border: none;
  border-radius: 12px;
  padding: 11px 22px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(177, 139, 74, 0.25);
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-gold:hover {
  background: var(--gold-hover);
  transform: translateY(-1px);
}

.btn-soft {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-soft:hover {
  background: var(--bg-subtle-hover);
}

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

/* ==========================================================================
   KPI CARDS (3 TOP CARDS IN WIREFRAME 1)
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 138px;
  position: relative;
}

.kpi-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.kpi-label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.kpi-value {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.kpi-icon-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--gold-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-progress-wrap {
  margin-top: 16px;
}

.kpi-progress-track {
  height: 6px;
  background: var(--bg-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.kpi-progress-bar {
  height: 100%;
  background: var(--gold-primary);
  border-radius: var(--radius-pill);
  transition: width 0.4s ease;
}

.kpi-subtext {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   DASHBOARD 2-COLUMN GRID (WIREFRAME 1)
   ========================================================================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.85fr 1fr;
  gap: 22px;
  align-items: start;
}

.surface-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-header h2 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-subhead {
  padding: 10px 24px;
  background: #FCFBF9;
  border-bottom: 1px solid var(--border-light);
  display: grid;
  grid-template-columns: 1.8fr 1.6fr 0.9fr 1.1fr 156px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.list-rows {
  display: flex;
  flex-direction: column;
}

.list-row {
  display: grid;
  grid-template-columns: 1.8fr 1.6fr 0.9fr 1.1fr 156px;
  align-items: center;
  padding: 15px 24px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s ease;
  gap: 10px;
}

.list-row:last-child {
  border-bottom: none;
}

.list-row:hover {
  background: #FCFBF9;
}

.row-entity {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.pastel-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.pastel-rose { background: var(--pastel-rose); color: var(--pastel-rose-text); }
.pastel-sage { background: var(--pastel-sage); color: var(--pastel-sage-text); }
.pastel-lavender { background: var(--pastel-lavender); color: var(--pastel-lavender-text); }
.pastel-amber { background: var(--pastel-amber); color: var(--pastel-amber-text); }
.pastel-blue { background: var(--pastel-blue); color: var(--pastel-blue-text); }

/* Las celdas de las filas deben poder encogerse; si no, el texto largo se monta sobre la columna vecina */
.list-row > *,
.entity-text {
  min-width: 0;
}

.entity-text h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entity-text p {
  overflow-wrap: anywhere;
}

.entity-text p.nowrap {
  white-space: nowrap;
  overflow-wrap: normal;
}

.entity-text p {
  font-size: 0.77rem;
  color: var(--text-secondary);
}

/* Status Pill matching Wireframe 1 */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 600;
  width: fit-content;
}

.status-pill {
  max-width: 100%;
}

.status-pill .dot {
  flex-shrink: 0;
}

.status-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-confirmed, .status-completed {
  background: var(--status-success-bg);
  color: var(--status-success-text);
}
.status-confirmed .dot, .status-completed .dot {
  background: var(--status-success-dot);
}

.status-pending, .status-cabin {
  background: var(--status-warning-bg);
  color: var(--status-warning-text);
}
.status-pending .dot, .status-cabin .dot {
  background: var(--status-warning-dot);
}

.status-danger {
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
}
.status-danger .dot {
  background: var(--status-danger-dot);
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.whatsapp-btn {
  color: #1E8E4F;
}

.whatsapp-btn:hover {
  background: #25D366;
  border-color: #25D366;
  color: #FFFFFF;
}

.danger-btn {
  color: var(--status-danger-text);
}

.danger-btn:hover {
  background: var(--status-danger-dot);
  border-color: var(--status-danger-dot);
  color: #FFFFFF;
}

.whatsapp-soft {
  color: #1E7A45;
  border-color: #BFE3CC;
  background: #EEF8F1;
}

.danger-soft {
  color: var(--status-danger-text);
  border-color: #EBCBC8;
  background: var(--status-danger-bg);
}

.btn-danger {
  background: var(--status-danger-dot);
  color: #FFFFFF;
  border: none;
  border-radius: 12px;
  padding: 11px 22px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-danger:disabled {
  opacity: 0.6;
  cursor: wait;
}

.round-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.round-action-btn:hover {
  background: var(--gold-primary);
  color: #FFFFFF;
  border-color: var(--gold-primary);
}

/* ==========================================================================
   RIGHT COLUMN WIDGETS (CALENDAR + ALERTS IN WIREFRAME 1)
   ========================================================================== */
.right-stack {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.calendar-widget {
  padding: 20px 22px;
}

.cal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.cal-top h3 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
}

.cal-nav {
  display: flex;
  gap: 6px;
}

.cal-arrow {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-card);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
}

.cal-arrow:hover {
  background: var(--gold-soft);
  color: var(--gold-primary);
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.cal-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-day {
  height: 36px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  color: var(--text-primary);
  cursor: pointer;
  position: relative;
  border: none;
  background: transparent;
  font-family: inherit;
  transition: all 0.15s;
}

.cal-day:hover:not(.empty) {
  background: var(--bg-subtle);
}

.cal-day.has-events {
  background: #F6F2EA;
  font-weight: 600;
}

.cal-day.selected {
  background: var(--gold-primary) !important;
  color: #FFFFFF !important;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(177, 139, 74, 0.35);
}

.cal-day.today:not(.selected) {
  box-shadow: inset 0 0 0 1.5px var(--gold-primary);
}

.cal-day.closed:not(.selected) {
  color: var(--text-muted);
  background: repeating-linear-gradient(135deg, transparent 0 4px, rgba(55, 51, 47, 0.04) 4px 6px);
}

.cal-day:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.cal-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold-primary);
  position: absolute;
  bottom: 4px;
}

.cal-day.selected .cal-dot {
  background: #FFFFFF;
}

.mini-feed-card {
  padding: 20px 22px;
}

.mini-feed-card h3 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.mini-feed-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mini-feed-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.mini-feed-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

/* ==========================================================================
   CLINICAL RECORD & BEFORE/AFTER PHOTO SLIDER
   ========================================================================== */
.patients-layout {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 22px;
  align-items: start;
}

.patient-Selector-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.15s;
}

.patient-Selector-item:hover {
  background: #FAF9F6;
}

.patient-Selector-item.active {
  background: var(--gold-soft);
  border-left: 4px solid var(--gold-primary);
}

.clinical-detail-header {
  padding: 22px 26px;
  background: linear-gradient(135deg, #FAF8F3 0%, #F4F0E8 100%);
  border-bottom: 1px solid var(--border-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.skin-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.skin-tag {
  background: #FFFFFF;
  border: 1px solid var(--gold-border);
  color: var(--text-primary);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
}

.clinical-body {
  padding: 24px 26px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

/* Before & After Interactive Comparison Slider */
.ba-section-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 22px;
  align-items: center;
}

.ba-slider-container {
  position: relative;
  width: 100%;
  height: 310px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid var(--gold-border);
  box-shadow: var(--shadow-md);
  user-select: none;
  background: #F1EDE6;
}

.ba-img-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.ba-img-layer img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ba-before-clip {
  position: absolute;
  inset: 0;
  width: 50%;
  overflow: hidden;
  border-right: 2.5px solid #FFFFFF;
}

.ba-label {
  position: absolute;
  top: 12px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  z-index: 5;
}

.ba-label-before {
  left: 12px;
  background: rgba(55, 51, 47, 0.78);
  color: #FFFFFF;
}

.ba-label-after {
  right: 12px;
  background: rgba(177, 139, 74, 0.92);
  color: #FFFFFF;
}

.ba-range-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: ew-resize;
  z-index: 10;
}

.ba-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--gold-primary);
  border: 3px solid #FFFFFF;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  pointer-events: none;
  z-index: 6;
  font-size: 0.85rem;
}

.metrics-progress-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.metric-item {
  background: #FBFAF7;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px 14px;
}

.metric-item-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 6px;
}

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

.routine-box {
  background: #FBFAF7;
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 16px 18px;
}

.routine-box h4 {
  font-size: 0.92rem;
  color: var(--gold-hover);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.session-timeline {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.session-card {
  background: #FBFAF7;
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--gold-primary);
  border-radius: 12px;
  padding: 16px 18px;
}

.session-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}

/* ==========================================================================
   MOBILE CLIENT PORTAL ("MI ESPACIO NISKIN" - WIREFRAME 3)
   ========================================================================== */
.client-portal-stage {
  display: grid;
  grid-template-columns: 430px 1fr;
  gap: 32px;
  align-items: start;
}

/* Exact Mobile Frame from Wireframe 3 */
.phone-mockup {
  background: #FBFAF7;
  border-radius: 36px;
  border: 8px solid #F5F1E9;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
}

.phone-topbar {
  padding: 18px 22px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  background: #FFFFFF;
}

.phone-plus-btn {
  font-size: 1.5rem;
  color: var(--gold-primary);
  background: transparent;
  border: none;
  cursor: pointer;
  line-height: 1;
}

.phone-menu-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: none;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.phone-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: #FCFBF9;
}

/* Search/Client Status Pill Bar with Gold Circle from Wireframe 3 */
.phone-user-pill {
  background: var(--bg-subtle);
  border-radius: 14px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.phone-user-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gold-primary);
  flex-shrink: 0;
}

.phone-user-select {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
  width: 100%;
  outline: none;
  cursor: pointer;
}

/* Selectable Cards with Avatar & Checkmark from Wireframe 3 */
.phone-selectable-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.phone-select-card {
  background: #FFFFFF;
  border: 1.5px solid var(--border-light);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.phone-select-card.selected {
  border-color: var(--gold-primary);
  background: #FFFDF9;
  box-shadow: 0 6px 18px rgba(177, 139, 74, 0.12);
}

.phone-card-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.phone-avatar-box {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: #EEE5D8;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.phone-check-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--gold-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  flex-shrink: 0;
  transition: all 0.2s;
}

.phone-select-card.selected .phone-check-circle {
  background: var(--gold-primary);
  border-color: var(--gold-primary);
  color: #FFFFFF;
}

/* Time Slot Pills from Wireframe 3 */
.phone-slots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.phone-slot-pill {
  padding: 12px 8px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.phone-slot-pill.selected {
  background: var(--gold-primary);
  color: #FFFFFF;
  border-color: var(--gold-primary);
  box-shadow: 0 4px 12px rgba(177, 139, 74, 0.28);
}

/* Bottom Full-Width Gold CTA Button with Chevron from Wireframe 3 */
.phone-cta-btn {
  width: 100%;
  background: var(--gold-primary);
  color: #FFFFFF;
  border: none;
  border-radius: 14px;
  padding: 15px 22px;
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(177, 139, 74, 0.3);
  font-family: inherit;
  transition: background 0.2s;
}

.phone-cta-btn:hover {
  background: var(--gold-hover);
}

/* ==========================================================================
   MODALS & FORMS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(55, 51, 47, 0.45);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-box {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gold-border);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
}

.modal-body {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  padding: 10px 13px;
  border-radius: 10px;
  border: 1px solid var(--border-card);
  background: #FBFAF7;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text-primary);
  outline: none;
}

select.form-control,
.phone-user-select {
  color-scheme: only light;
}

.form-control:focus {
  border-color: var(--gold-primary);
  background: #FFFFFF;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-gold:disabled {
  opacity: 0.65;
  cursor: wait;
  transform: none;
}

.form-message {
  font-size: 0.84rem;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
}

.form-message.success {
  background: var(--status-success-bg);
  color: var(--status-success-text);
}

/* Pantalla de acceso del panel administrativo */
.admin-gate {
  display: none;
}

.admin-locked .app-layout {
  display: none;
}

.admin-locked .admin-gate {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: radial-gradient(circle at 20% 0%, #FBF8F2 0%, var(--bg-canvas) 55%);
  overflow-y: auto;
}

.admin-gate-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-gate-logo {
  width: 170px;
  margin: 0 auto 4px;
}

.admin-gate-card h1 {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  text-align: center;
  line-height: 1.1;
}

.admin-gate-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
  margin-top: -8px;
}

.admin-gate-link {
  text-align: center;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--gold-hover);
  text-decoration: none;
}

.admin-gate-config {
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.76rem;
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
}

.admin-gate-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: -6px;
}

.profile-avatar {
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.profile-meta {
  cursor: pointer;
}

.team-account-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.team-credentials {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-subtle);
  border-radius: 12px;
  padding: 12px 14px;
}

.team-credentials li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.88rem;
}

.team-credentials li span {
  color: var(--text-secondary);
}

.team-credentials li strong {
  font-family: ui-monospace, Menlo, monospace;
  word-break: break-all;
  text-align: right;
}

.team-role-select {
  padding: 7px 10px;
  font-size: 0.82rem;
  max-width: 170px;
}

/* Expedientes: ficha y seguimiento */
.patient-head {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.patient-name {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.patient-name span {
  font-size: 1.05rem;
  color: var(--text-secondary);
}

.patient-contact {
  font-size: 0.84rem;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

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

.patient-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.patient-stats > div {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 0;
}

.patient-stats span {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.patient-stats strong {
  font-size: 0.92rem;
  color: var(--text-primary);
}

.allergy-alert {
  font-size: 0.84rem;
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
  border-radius: 12px;
  padding: 10px 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.section-head h3 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
}

.subsection-title {
  font-size: 0.86rem;
  margin: 18px 0 10px;
  color: var(--text-secondary);
}

.progress-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.progress-metric {
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-metric-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
}

.progress-delta {
  font-size: 0.74rem;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  white-space: nowrap;
}

.progress-delta.up {
  background: var(--status-success-bg);
  color: var(--status-success-text);
}

.progress-delta.down {
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
}

.progress-metric-values {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.progress-metric-values strong {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  line-height: 1;
}

.progress-metric-values span {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.sparkline {
  width: 100%;
  height: 34px;
}

.progress-empty {
  border: 1px dashed var(--gold-border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  font-size: 0.86rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

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

.eval-item {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 10px 12px;
}

.eval-date {
  font-size: 0.82rem;
  font-weight: 700;
}

.eval-body {
  min-width: 0;
}

.eval-values {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.eval-body p {
  font-size: 0.8rem;
  color: var(--text-primary);
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.eval-body .eval-by {
  color: var(--text-muted);
  font-size: 0.74rem;
}

.eval-actions {
  display: flex;
  gap: 6px;
}

.eval-slider label {
  display: flex;
  justify-content: space-between;
}

.eval-slider output {
  font-weight: 700;
  color: var(--gold-hover);
}

.eval-slider input[type="range"] {
  width: 100%;
  accent-color: var(--gold-primary);
}

.session-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.session-date {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gold-hover);
  white-space: nowrap;
}

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

.patient-appt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 10px 12px;
}

.patient-appt strong {
  font-size: 0.86rem;
}

.patient-appt p {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* Catálogo de tratamientos */
.treatment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 20px;
}

.treatment-card {
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.treatment-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.treatment-duration {
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.treatment-card h3 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  line-height: 1.2;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.treatment-desc {
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.treatment-supplies {
  margin-top: 8px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.treatment-card-foot {
  border-top: 1px solid var(--border-light);
  padding-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.treatment-price {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.treatment-deposit {
  font-size: 0.76rem;
  color: var(--gold-hover);
}

.treatment-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Insumos por sesión (formulario de tratamiento) */
.supply-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 8px;
}

.supply-row {
  display: grid;
  grid-template-columns: 20px 1fr 76px auto;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  cursor: pointer;
}

.supply-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--gold-primary);
}

.supply-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.supply-row .form-control {
  padding: 6px 8px;
}

.supply-row .form-control:disabled {
  opacity: 0.45;
}

.supply-unit {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Hoja de citas del día (calendario) */
.day-sheet-meta {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.day-appt-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.day-appt {
  display: flex;
  gap: 12px;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px;
  background: var(--bg-surface);
}

.day-appt-time {
  flex-shrink: 0;
  width: 72px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  padding-top: 2px;
}

.day-appt-body {
  flex: 1;
  min-width: 0;
}

.day-appt-body h4 {
  font-size: 0.92rem;
}

.day-appt-body p {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.day-appt-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.day-appt-actions {
  display: inline-flex;
  gap: 6px;
}

.day-empty,
.slot-empty {
  font-size: 0.86rem;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
}

/* Horarios ocupados: visibles pero deshabilitados */
.phone-slot-pill.taken,
.phone-slot-pill:disabled {
  background: repeating-linear-gradient(135deg, var(--bg-subtle) 0 6px, #EFEBE4 6px 8px);
  color: var(--text-muted);
  border-style: dashed;
  text-decoration: line-through;
  cursor: not-allowed;
  box-shadow: none;
}

.phone-slot-pill small {
  display: block;
  font-size: 0.66rem;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.3px;
}

/* Confirmar cita: con o sin depósito */
.confirm-option {
  border: 1px solid var(--border-card);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #FCFAF6;
}

.confirm-option h4 {
  font-size: 0.95rem;
}

/* Configuración del negocio */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.settings-card {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-card h2 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
}

.settings-help {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: -6px;
  word-break: break-word;
}

.settings-help a {
  color: var(--gold-hover);
}

textarea.form-control {
  resize: vertical;
  line-height: 1.45;
}

.settings-switch {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.86rem;
  cursor: pointer;
}

.settings-switch input,
.settings-day input {
  width: 18px;
  height: 18px;
  accent-color: var(--gold-primary);
  flex-shrink: 0;
}

.settings-days {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.settings-day {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--border-card);
  border-radius: 10px;
  background: var(--bg-subtle);
  font-size: 0.82rem;
  cursor: pointer;
}

.settings-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.settings-slot {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 6px 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--gold-soft);
  border: 1px solid var(--gold-border);
  font-size: 0.82rem;
  font-weight: 600;
}

.settings-slot button {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(177, 139, 74, 0.18);
  color: var(--gold-hover);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}

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

.settings-weekday {
  display: grid;
  grid-template-columns: 130px 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: var(--bg-surface);
}

.settings-weekday-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.settings-weekday-name input {
  width: 18px;
  height: 18px;
  accent-color: var(--gold-primary);
}

.settings-weekday-hours {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.settings-weekday-hours .form-control {
  padding: 7px 6px;
  min-width: 0;
  width: 100%;
  flex: 1 1 0;
}

.settings-weekday-hours span {
  flex-shrink: 0;
}

.settings-weekday-closed {
  display: none;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.settings-weekday.is-closed {
  background: var(--bg-subtle);
}

.settings-weekday.is-closed .settings-weekday-hours {
  display: none;
}

.settings-weekday.is-closed .settings-weekday-closed {
  display: block;
}

.settings-deposit-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-preview {
  font-size: 0.8rem;
  color: var(--gold-hover);
  background: var(--gold-soft);
  border-radius: 10px;
  padding: 10px 12px;
}

.settings-preview:empty {
  display: none;
}

.settings-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Aviso para activar notificaciones */
.push-prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #FBF8F2 0%, #F3ECDF 100%);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 18px;
}

.push-prompt strong {
  font-size: 0.95rem;
}

.push-prompt p {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.push-prompt-actions {
  display: flex;
  gap: 8px;
}

.push-account-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  background: var(--bg-subtle);
  border-radius: 12px;
  padding: 12px 14px;
}

/* Aviso de modo oscuro forzado (Samsung Internet) */
.dark-notice {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 300;
  max-width: 460px;
  margin: 0 auto;
  background: #FFFFFF;
  color: #37332F;
  border: 1px solid #D6C39D;
  border-radius: 18px;
  box-shadow: 0 18px 42px rgba(81, 70, 56, 0.25);
  padding: 16px 18px;
  font-size: 0.86rem;
  line-height: 1.45;
}

.dark-notice strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 4px;
}

.dark-notice ol {
  margin: 8px 0 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dark-notice button {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 12px;
  background: #B18B4A;
  color: #FFFFFF;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #37332F;
  color: #FFFFFF;
  padding: 13px 20px;
  border-radius: 12px;
  border-left: 4px solid var(--gold-primary);
  box-shadow: var(--shadow-md);
  font-size: 0.86rem;
  font-weight: 500;
  animation: fadeInUp 0.25s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   RESPONSIVE — TABLET
   ========================================================================== */
@media (max-width: 1120px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .settings-weekday {
    grid-template-columns: 1fr;
  }
  .patient-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .progress-metrics {
    grid-template-columns: 1fr;
  }
  .eval-item {
    grid-template-columns: 1fr auto;
  }
  .eval-date {
    grid-column: 1 / -1;
  }
  .settings-card {
    padding: 18px 14px;
  }
  .settings-weekday {
    padding: 8px;
  }
  .settings-weekday-hours {
    gap: 6px;
  }
  .settings-weekday-hours .form-control {
    font-size: 14px;
    padding: 7px 4px;
  }
  .settings-weekday-hours .form-control::-webkit-calendar-picker-indicator {
    margin-left: 0;
    padding: 0;
  }
  .dashboard-grid,
  .patients-layout,
  .client-portal-stage,
  .ba-section-grid {
    grid-template-columns: 1fr;
  }
  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
  .topbar {
    padding: 14px 22px;
    flex-wrap: wrap;
  }
  .content-area {
    padding: 22px 22px 40px;
  }
}

/* ==========================================================================
   RESPONSIVE — MÓVIL (menú lateral deslizable + filas en tarjeta)
   ========================================================================== */
@media (max-width: 820px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  /* Sidebar convertida en cajón lateral */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(290px, 84vw);
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: calc(18px + env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));
    transform: translateX(-100%);
    transition: transform 0.28s ease, box-shadow 0.28s ease;
    z-index: 90;
    gap: 16px;
  }
  .menu-open .sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(55, 51, 47, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
    z-index: 80;
  }
  .menu-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }
  body.menu-open {
    overflow: hidden;
  }
  .brand-logo {
    width: 150px;
  }
  .nav-item {
    padding: 13px 14px;
    font-size: 0.95rem;
  }
  .menu-toggle-btn {
    display: inline-flex;
  }

  /* Barra superior compacta */
  .topbar {
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    gap: 10px;
  }
  .topbar-left {
    gap: 12px;
    flex: 1 1 100%;
  }
  .topbar-title {
    min-width: 0;
  }
  .topbar-title h1 {
    font-size: 1.3rem;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-title p {
    font-size: 0.74rem;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .topbar-right {
    width: 100%;
    gap: 8px;
  }
  .mode-switch,
  .topbar-avatar {
    display: none;
  }
  .search-pill {
    flex: 1;
    width: auto;
    min-width: 0;
    padding: 9px 14px;
  }
  .topbar .btn-soft.btn-sm {
    height: 40px;
    padding: 0 12px;
    flex-shrink: 0;
  }
  .icon-circle-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }

  .content-area {
    padding: 16px 16px calc(36px + env(safe-area-inset-bottom));
  }
  .action-bar {
    margin-bottom: 16px;
  }
  .action-bar > div {
    max-width: 100%;
  }

  /* Tarjetas y encabezados */
  .kpi-grid {
    gap: 12px;
    margin-bottom: 16px;
  }
  .kpi-card {
    padding: 18px;
    min-height: 0;
  }
  .kpi-value {
    font-size: 1.75rem;
  }
  .kpi-subtext {
    flex-wrap: wrap;
    gap: 4px 10px;
  }
  .dashboard-grid,
  .right-stack,
  .patients-layout {
    gap: 16px;
  }
  .card-header {
    padding: 16px 18px;
  }
  .card-header h2 {
    font-size: 1.2rem;
  }

  /* Filas tipo tabla → tarjetas apiladas (anula el grid inline de app.js) */
  .card-subhead {
    display: none !important;
  }
  .list-row {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px 12px;
    padding: 14px 18px;
    align-items: start;
  }
  .list-row > .row-entity,
  .list-row > .row-actions {
    grid-column: 1 / -1;
  }
  .list-row > .row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .list-row > [style*="text-align:right"] {
    text-align: left !important;
  }
  .entity-text h4 {
    white-space: normal;
  }

  /* Objetivos táctiles más cómodos */
  .round-action-btn {
    width: 40px;
    height: 40px;
  }
  .btn-sm {
    min-height: 36px;
  }
  .cal-day {
    height: 40px;
  }
  .cal-arrow {
    width: 34px;
    height: 34px;
  }

  /* Expedientes */
  .clinical-detail-header,
  .clinical-body {
    padding: 18px;
  }
  .clinical-body {
    gap: 20px;
  }
  .ba-slider-container {
    height: 260px;
  }
  .routine-grid {
    grid-template-columns: 1fr;
  }

  /* Portal del cliente */
  .client-portal-stage {
    gap: 18px;
  }
  .phone-mockup {
    border-width: 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
  }
  .phone-body {
    padding: 16px;
  }
  .phone-avatar-box {
    width: 52px;
    height: 52px;
  }

  /* Formularios: 16px evita el zoom automático de iOS al enfocar */
  .form-row {
    grid-template-columns: 1fr;
  }
  .form-control,
  .search-pill input,
  .phone-user-select,
  select,
  textarea,
  input {
    font-size: 16px;
  }

  /* Modal como hoja inferior */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .modal-box {
    max-width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-width: 1px 0 0;
    animation: sheetUp 0.25s ease;
  }
  .modal-header {
    padding: 16px 18px;
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    z-index: 2;
  }
  .modal-body {
    padding: 18px;
  }
  .modal-footer {
    padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
    position: sticky;
    bottom: 0;
    background: var(--bg-surface);
    flex-wrap: wrap;
  }
  .modal-footer > button {
    flex: 1 1 auto;
    justify-content: center;
  }

  /* Notificaciones */
  .toast-container {
    left: 16px;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 480px) {
  .topbar .btn-label {
    display: none;
  }
  .topbar-title p {
    display: none;
  }
  .action-bar > div:last-child {
    width: 100%;
  }
  .action-bar > div:last-child > .btn-gold,
  .action-bar > div:last-child > .btn-soft {
    flex: 1 1 auto;
    justify-content: center;
  }
  .phone-slots-grid {
    gap: 8px;
  }
  .phone-slot-pill {
    padding: 11px 4px;
  }
}

@keyframes sheetUp {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar-overlay,
  .modal-box,
  .toast {
    transition: none;
    animation: none;
  }
}
