:root {
  color-scheme: light;
  font-family: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --text: #17202a;
  --muted: #617083;
  --line: #d9e0e7;
  --primary: #1769e0;
  --primary-dark: #1155b4;
  --doctor-1: #8b5cf6;
  --doctor-1-soft: #f3ecff;
  --doctor-1-card: #fbf8ff;
  --doctor-1-border: #eadcff;
  --doctor-2: #d99a86;
  --doctor-2-soft: #fff3ee;
  --doctor-2-card: #fffaf7;
  --doctor-2-border: #f0d1c5;
  --danger: #b42318;
  --warning: #8a5a00;
  --ok: #16794f;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #ffffff 0%, #f5f9ff 100%);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

body:not(.official-app) .topbar {
  min-height: 60px;
  height: 60px;
  padding-left: max(20px, calc((100vw - 1120px) / 2));
  padding-right: max(20px, calc((100vw - 1120px) / 2));
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid #d9e0e7;
  backdrop-filter: blur(10px);
  position: sticky;
}

.topbar-actions .btn {
  padding: 7px 10px;
  font-size: 13px;
}

.demo-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 15px;
  font-weight: 750;
  text-decoration: none;
}

.demo-brand-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 6px;
  background: #1769e0;
  color: #fff;
  font-size: 14px;
}

.demo-brand-logo {
  display: block;
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex: 0 0 auto;
}

.official-only { display: none; }

.app-brand {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
}

.app-brand img {
  display: block;
  width: 34px;
  height: 34px;
  object-fit: contain;
}

body.official-app .official-only { display: inline-flex; }

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.panel-subtitle {
  margin: -8px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
}

h2 {
  margin-bottom: 14px;
  font-size: 18px;
}

h3 {
  margin-bottom: 4px;
  font-size: 16px;
}

.topbar-actions,
.dialog-actions,
.dialog-actions-right,
.toolbar,
.segmented,
.view-switch,
.card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dialog-actions-right {
  justify-content: flex-end;
  flex-wrap: nowrap;
}

/* En los pies con un separador vacío, el bloque de acciones queda realmente
   pegado al extremo derecho y no solo alineado dentro de su propio ancho. */
.dialog-actions > span:first-child { flex: 1 1 auto; min-width: 0; }

.feedback-input {
  width: 100%;
  margin: 4px 0 8px;
}

.feedback-dialog .dialog-subtitle {
  white-space: pre-line;
  line-height: 1.45;
}

.demo-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-right: 0 !important;
  font-family: inherit;
}

.demo-nav a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
  text-decoration: none;
  white-space: nowrap;
}

.demo-nav a:hover {
  color: var(--text);
}

.demo-nav .btn {
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 8px;
  color: #fff;
  font-weight: 650;
}

.demo-nav .btn.primary {
  background: #e8f1ff;
  border-color: #b8d0f2;
  color: #0b4f9c;
}

.demo-nav a.btn.primary:hover {
  background: #d7e7ff;
  border-color: #a6c3ee;
  color: #0b4f9c;
}

body:not(.official-app) .demo-nav .btn {
  min-height: 38px;
  padding: 8px 12px;
  font: 650 14px / 20px Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body:not(.official-app) .demo-nav { gap: 14px; }
body:not(.official-app) .demo-nav a { font-size: 13px; }

body:not(.official-app) #loginBtn { display: none !important; }

.demo-banner {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
  padding: 10px 20px;
  background: #eff6ff;
  border-bottom: 1px solid #bfdbfe;
  color: #1e3a8a;
  font-size: 13px;
  justify-content: center;
  text-align: center;
}

body:not(.official-app) .demo-banner {
  padding-left: max(20px, calc((100vw - 1120px) / 2));
  padding-right: max(20px, calc((100vw - 1120px) / 2));
}

.demo-banner strong { font-weight: 750; }

.demo-guide-title { display: flex; align-items: baseline; justify-content: center; gap: 8px; width: 100%; }
.demo-guide-title span, .demo-guide-note { color: #49627d; }
.demo-guide-steps { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: 100%; }
.demo-guide-steps span { display: grid; grid-template-columns: 20px 1fr; column-gap: 7px; align-items: center; min-width: 190px; padding: 7px 10px; border: 1px solid #c8dcf3; border-radius: 9px; background: #fff; color: #23476f; font-size: 12px; font-weight: 650; }
.demo-guide-steps strong, .demo-guide-steps small { grid-column: 2; }
.demo-guide-steps small { color: #617083; font-size: 11px; font-weight: 500; }
.demo-guide-steps b { grid-row: 1 / span 2; }
.demo-guide-steps b { display: inline-grid; width: 20px; height: 20px; place-items: center; border-radius: 50%; background: #1769e0; color: #fff; font-size: 11px; }
.demo-guide-note { width: 100%; font-size: 12px; text-align: center; }

.api-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.api-status.connected {
  color: var(--ok);
}

body .technical-action,
body.local-mode .technical-action[data-local-only] {
  display: none !important;
}

body.api-enabled .technical-action:not([data-local-only]) {
  display: inline-flex !important;
}

[hidden],
body [hidden],
body.api-enabled [hidden] {
  display: none !important;
}

body.auth-required:not(.authenticated) #newAppointmentBtn,
body.auth-required:not(.authenticated) #mobilePatientsBtn,
body.auth-required:not(.authenticated) #settingsBtn,
body.auth-required:not(.authenticated) .layout {
  display: none !important;
}

body.auth-required:not(.authenticated) .agenda-toolbar {
  display: none !important;
}

body:not(.authenticated) #logoutBtn {
  display: none !important;
}

body.authenticated #loginBtn {
  display: none !important;
}

body.authenticated #logoutBtn {
  display: inline-flex !important;
}

body.official-app .demo-only {
  display: none !important;
}

/* La demo comparte la jerarquía visual de la aplicación, pero no expone
   administración, contratos, cuentas ni configuración de una clínica. */
body.showcase-demo #loginBtn,
body.showcase-demo #logoutBtn {
  display: none !important;
}

body.showcase-demo #refreshAgendaBtn,
body.showcase-demo #printDayBtn,
body.showcase-demo #mobileFollowUpsBtn {
  display: none !important;
}

body.showcase-demo #settingsBtn {
  display: inline-flex !important;
}

body.showcase-demo .settings-tab:not([data-settings-tab="basic"]):not([data-settings-tab="treatments"]):not([data-settings-tab="booking"]):not([data-settings-tab="whatsapp"]),
body.showcase-demo .settings-section:not([data-settings-panel="basic"]):not([data-settings-panel="treatments"]):not([data-settings-panel="booking"]):not([data-settings-panel="whatsapp"]) {
  display: none !important;
}

body:not(.official-app) .official-settings > :not(.demo-settings-explanation) {
  display: none !important;
}

body:not(.official-app) .demo-settings-explanation {
  display: block !important;
}

body:not(.official-app) #settingsBtn {
  display: none !important;
}

/* La demo comercial enseña el flujo de recepción, no la administración interna. */
body:not(.official-app) .settings-tab[data-settings-tab="contract"],
body:not(.official-app) .settings-section[data-settings-panel="contract"] {
  display: none !important;
}

body.clinic-la-campana .settings-tab[data-settings-tab="contract"],
body.clinic-la-campana .settings-section[data-settings-panel="contract"] {
  display: none !important;
}

body:not(.official-app) .demo-brand,
body:not(.official-app) .demo-brand:visited {
  color: var(--text);
  text-decoration: none;
}

body:not(.official-app) .topbar-title > #clinicEyebrow,
body:not(.official-app) .topbar-title > #clinicTitle {
  display: none;
}

body:not(.official-app) .topbar-title {
  display: flex;
  align-items: center;
}

body:not(.official-app) .demo-brand {
  display: inline-flex !important;
  margin-bottom: 0;
  gap: 10px;
  font-size: 14px;
  line-height: 21px;
}

/* Mantener la marca de la demo con la misma escala visual que la web pública. */
body:not(.official-app) .demo-brand-logo {
  width: 36px;
  height: 36px;
}

body:not(.official-app) .demo-toolbar {
  width: 100%;
  margin: 0;
}

@media (max-width: 900px) {
  body:not(.official-app) .demo-toolbar {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  body:not(.official-app) .demo-toolbar .view-switch,
  body:not(.official-app) .demo-toolbar .segmented {
    width: 100%;
  }

  body:not(.official-app) .demo-toolbar .view-switch button,
  body:not(.official-app) .demo-toolbar .segmented button {
    flex: 1 1 0;
  }

  body:not(.official-app) .demo-toolbar .toolbar-tool-btn { width: 100%; }
}

.demo-agenda-heading {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px 0;
}

body:not(.official-app) .demo-agenda-heading {
  display: flex !important;
}

body:not(.official-app) #newAppointmentBtn {
  display: none !important;
}


.demo-agenda-heading p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.demo-agenda-heading h1 {
  margin: 0;
  font-size: 24px;
}

body:not(.official-app) .layout {
  width: 100%;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

.demo-settings-explanation h3 { margin: 0 0 10px; }
.demo-settings-explanation p { max-width: 680px; }
.demo-example {
  display: grid;
  gap: 6px;
  max-width: 680px;
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.demo-example code { white-space: normal; color: var(--muted); }

.support-only {
  display: none !important;
}

body.support-user .support-only {
  display: block !important;
}

body.support-user [hidden],
body.support-user .support-only[hidden] {
  display: none !important;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 290px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.sidebar,
.content {
  min-width: 0;
}

.panel,
.content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
  margin-bottom: 14px;
}

.btn.full {
  width: 100%;
}

.content {
  padding: 18px;
  background: #ffffff;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stats div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.stats span {
  display: block;
  font-size: 24px;
  font-weight: 700;
}

.stats small,
.meta,
.notes,
#agendaSubtitle {
  color: var(--muted);
}

.work-list {
  display: grid;
  gap: 8px;
}

.doctor-work-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 0 0 8px;
  color: #64748b;
  font-size: 11px;
}

.doctor-work-legend { display: none; }

.doctor-work-legend span { display: inline-flex; align-items: center; gap: 4px; }

.work-card {
  width: 100%;
  height: 56px;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 9px;
  text-align: left;
}

.work-card:hover {
  border-color: #b8c7d9;
  background: #f8fafc;
}

.reset-work-card {
  background: #fbfcfe;
  color: #526274;
}

.reset-work-card strong { color: #344256; font-weight: 650; }
.work-card.reset-work-card b { background: #f1f5f9; color: #526274; }

.work-card.review-card {
  border-color: var(--line);
  background: #fff;
}

.work-card.review-card.has-review-items { border-color: #f0c36a; background: #fff9e8; }

.work-card span {
  display: grid;
  gap: 2px;
}

.work-card strong {
  font-size: 14px;
}

.work-card small {
  color: var(--muted);
  font-size: 12px;
  display: none;
}

.work-card b {
  min-width: 30px;
  border-radius: 999px;
  background: var(--surface-2);
  color: #223044;
  font-size: 14px;
  padding: 5px 8px;
  text-align: center;
}

.work-count-breakdown {
  display: flex !important;
  align-items: center;
  gap: 6px !important;
  margin-left: auto;
  white-space: nowrap;
}

.work-count-breakdown span {
  display: inline-flex !important;
  align-items: center;
  gap: 2px;
  color: #526174;
  font-size: 11px;
}

.work-count-breakdown .key-dot {
  width: 9px;
  height: 9px;
}

.doctor-count {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  color: #26364a;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
}

.doctor-count.doctor-1 { background: var(--doctor-1-soft); border: 1px solid var(--doctor-1-border); }
.doctor-count.doctor-2 { background: var(--doctor-2-soft); border: 1px solid var(--doctor-2-border); }
.doctor-count.doctor-3 { background: #eefaf8; border: 1px solid #c9ebe7; }
.doctor-count.doctor-4 { background: #fff7e8; border: 1px solid #f5dfb5; }

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.doctor-key {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: #344256;
  font-size: 14px;
}

.doctor-key.compact-key {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  margin: 2px 0 14px;
  padding: 7px 9px;
}

.agenda-tabs {
  display: grid;
  gap: 7px;
}

.agenda-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #344256;
  cursor: pointer;
  font-weight: 700;
  padding: 7px 9px;
  text-align: left;
}

.agenda-tab-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  margin-left: auto;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #fff;
  color: transparent;
  font-size: 12px;
  font-style: normal;
  line-height: 1;
}

.agenda-tab.active .agenda-tab-check {
  border-color: currentColor;
  background: rgba(255, 255, 255, .58);
  color: currentColor;
  font-weight: 800;
}

.agenda-tab:hover {
  border-color: #b8c7d9;
  background: #f8fafc;
}

.agenda-tab.active {
  border-color: var(--primary);
  background: #edf5ff;
  color: var(--primary-dark);
  box-shadow: inset 0 0 0 1px rgba(23, 105, 224, 0.2);
}

.agenda-tab.doctor-1.active {
  border-color: var(--doctor-1);
  background: var(--doctor-1-soft);
  color: #4c1d95;
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.22);
}

.agenda-tab.doctor-2.active {
  border-color: var(--doctor-2);
  background: var(--doctor-2-soft);
  color: #0f766e;
  box-shadow: inset 0 0 0 1px rgba(20, 184, 166, 0.22);
}

/* La selección se comunica con el check y el borde; evitamos fondos multicolor. */
.official-app .agenda-tab,
.official-app .agenda-tab.active,
.official-app .agenda-tab.doctor-1.active,
.official-app .agenda-tab.doctor-2.active,
.official-app .agenda-tab.doctor-3.active,
.official-app .agenda-tab.doctor-4.active,
.official-app .agenda-tab.doctor-5.active,
.official-app .agenda-tab.doctor-6.active,
.official-app .agenda-tab.doctor-7.active,
.official-app .agenda-tab.doctor-8.active {
  background: #fff;
  color: #344256;
  box-shadow: none;
}
.official-app .agenda-tab.active { border-color: #8eb7e6; box-shadow: inset 0 0 0 1px rgba(23, 105, 224, .16); }

/* Pastel palette for additional agendas. */
.doctor-3 { --doctor-color: #78c9c0; --doctor-soft: #eefaf8; --doctor-card: #f7fdfc; --doctor-border: #c9ebe7; }
.doctor-4 { --doctor-color: #f0b45b; --doctor-soft: #fff7e8; --doctor-card: #fffaf2; --doctor-border: #f5dfb5; }
.doctor-5 { --doctor-color: #79b9e8; --doctor-soft: #eef7ff; --doctor-card: #f7fbff; --doctor-border: #cfe7f8; }
.doctor-6 { --doctor-color: #9bcf8b; --doctor-soft: #f0faed; --doctor-card: #f8fdf6; --doctor-border: #d4ebcb; }
.doctor-7 { --doctor-color: #c19be8; --doctor-soft: #f7f0ff; --doctor-card: #fbf8ff; --doctor-border: #e5d4f5; }
.doctor-8 { --doctor-color: #e5a879; --doctor-soft: #fff4eb; --doctor-card: #fffaf5; --doctor-border: #f2d8c1; }
.agenda-tab.doctor-3.active, .agenda-tab.doctor-4.active, .agenda-tab.doctor-5.active,
.agenda-tab.doctor-6.active, .agenda-tab.doctor-7.active, .agenda-tab.doctor-8.active {
  border-color: var(--doctor-color); background: var(--doctor-soft);
}
.key-dot.doctor-3, .key-dot.doctor-4, .key-dot.doctor-5, .key-dot.doctor-6, .key-dot.doctor-7, .key-dot.doctor-8 { background: var(--doctor-color); }
.week-appointment.doctor-3, .week-appointment.doctor-4, .week-appointment.doctor-5, .week-appointment.doctor-6, .week-appointment.doctor-7, .week-appointment.doctor-8,
.appointment-card.doctor-3, .appointment-card.doctor-4, .appointment-card.doctor-5, .appointment-card.doctor-6, .appointment-card.doctor-7, .appointment-card.doctor-8 { background: var(--doctor-card); border-color: var(--doctor-border); }
.doctor-column.doctor-3, .doctor-column.doctor-4, .doctor-column.doctor-5, .doctor-column.doctor-6, .doctor-column.doctor-7, .doctor-column.doctor-8 { border-top: 4px solid var(--doctor-color); }
.doctor-column.doctor-3 .day-column-header, .doctor-column.doctor-4 .day-column-header, .doctor-column.doctor-5 .day-column-header,
.doctor-column.doctor-6 .day-column-header, .doctor-column.doctor-7 .day-column-header, .doctor-column.doctor-8 .day-column-header { background: var(--doctor-soft); }

/* Ultima regla para que ninguna paleta de agenda vuelva a colorear el selector. */
.official-app .agenda-tabs .agenda-tab.active {
  background: #fff;
  color: #344256;
  box-shadow: inset 0 0 0 1px rgba(23, 105, 224, .16);
}

/* El punto del selector debe coincidir exactamente con la línea de su agenda. */
.official-app .agenda-tabs .key-dot.doctor-1,
.official-app .doctor-key .key-dot.doctor-1,
.official-app .doctor-work-legend .key-dot.doctor-1 {
  background: #b9a9df !important;
}
.official-app .agenda-tabs .key-dot.doctor-2,
.official-app .doctor-key .key-dot.doctor-2,
.official-app .doctor-work-legend .key-dot.doctor-2 {
  background: #d9b6a8 !important;
}

.official-app .agenda-tabs .agenda-tab .key-dot.doctor-1,
.official-app .doctor-key .key-dot.doctor-1,
.official-app .doctor-work-legend .key-dot.doctor-1 {
  background-color: #b9a9df !important;
  border-color: #b9a9df !important;
}
.official-app .agenda-tabs .agenda-tab .key-dot.doctor-2,
.official-app .doctor-key .key-dot.doctor-2,
.official-app .doctor-work-legend .key-dot.doctor-2 {
  background-color: #d9b6a8 !important;
  border-color: #d9b6a8 !important;
}

.doctor-key span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  flex: 0 0 15px;
  display: inline-block;
}

.key-dot.doctor-1 {
  background: #b9a9df;
}

.key-dot.doctor-2 {
  background: #d9b6a8;
}

.field span {
  color: #3d4a5c;
  font-size: 13px;
  font-weight: 700;
}

.panel-section-title {
  border-top: 1px solid var(--line);
  color: #344256;
  font-size: 14px;
  margin: 14px 0 10px;
  padding-top: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: #8bb8e8;
  box-shadow: 0 0 0 3px rgba(79, 143, 202, .14);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: #f8fafc;
  color: #617083;
  cursor: not-allowed;
}

textarea {
  resize: vertical;
}

.search {
  margin-bottom: 10px;
}

#newPatientBtn {
  margin-bottom: 10px;
}

.patient-identity-conflict {
  border: 1px solid #e6c878;
  border-radius: 8px;
  background: #fff9e8;
  color: #684c00;
  padding: 10px;
}

.patient-identity-conflict p {
  margin: 5px 0 9px;
  font-size: 13px;
}

.patient-identity-conflict-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.link-btn {
  justify-self: start;
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  padding: 0;
}

.btn.danger {
  background: #fff;
  border-color: #f0b8b3;
  color: var(--danger);
}

.btn.small {
  padding: 7px 9px;
  font-size: 13px;
}

.file-btn {
  display: inline-block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #dbe7f5;
  border-radius: 12px;
  background: linear-gradient(135deg, #f8fbff 0%, #eef6ff 100%);
  box-shadow: 0 4px 14px rgba(32, 74, 125, .06);
}

.toolbar h2 { margin-bottom: 2px; color: #183b66; }
.toolbar .view-switch,
.toolbar .segmented { box-shadow: 0 2px 6px rgba(32, 74, 125, .08); border-radius: 7px; }
.toolbar .view-switch button,
.toolbar .segmented button { padding: 7px 10px; font-size: 13px; color: #315274; }
.toolbar .view-switch button.active { background: #4f8fca; border-color: #4f8fca; }
.toolbar .segmented button:hover,
.toolbar .view-switch button:hover { background: #e3f0ff; }
.toolbar #todayBtn { background: #dcecff; color: #1f5f9c; font-weight: 700; }

.toolbar .toolbar-tool-btn {
  min-height: 32px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #dcecff;
  border-color: #c5ddf7;
  color: #1f5f9c;
  font-weight: 700;
  cursor: pointer;
  font-size: 12px;
  box-shadow: 0 2px 6px rgba(32, 74, 125, .08);
}

.toolbar .toolbar-tool-btn:hover { background: #cfe5fb; }
.toolbar-actions { display: flex; align-items: center; gap: 6px; }

.patient-whatsapp-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #dbe4ef;
  border-radius: 7px;
  background: #fbfdff;
  color: #344256;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.3;
}
.patient-whatsapp-consent input[type="checkbox"] {
  width: 16px;
  min-width: 16px;
  height: 16px;
  min-height: 16px;
  flex: 0 0 16px;
  margin: 1px 0 0;
  padding: 0;
  accent-color: var(--primary);
}
.patient-whatsapp-consent strong,
.patient-whatsapp-consent small { display: block; }
.patient-whatsapp-consent strong { font-size: 12px; }
.patient-whatsapp-consent small { margin-top: 3px; color: #64748b; font-size: 11px; line-height: 1.35; }

.segmented {
  gap: 0;
}

.segmented button,
.view-switch button {
  border: 1px solid var(--line);
  background: #fff;
  padding: 9px 12px;
  cursor: pointer;
}

.segmented button:first-child,
.view-switch button:first-child {
  border-radius: 6px 0 0 6px;
}

.segmented button:last-child,
.view-switch button:last-child {
  border-radius: 0 6px 6px 0;
}

.view-switch {
  gap: 0;
}

.view-switch button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.appointments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 12px;
}

.content { container-type: inline-size; }

.appointments-grid.week-view {
  display: grid;
  grid-template-columns: repeat(7, minmax(258px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.week-summary-column {
  min-width: 210px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.week-summary-column.non-working-day,
.day-column.non-working-day {
  background: #f3f5f7;
  border-color: #cbd5df;
}

.week-summary-column.non-working-day .week-summary-header,
.day-column.non-working-day .day-column-header {
  background: #e9edf1;
  border-bottom-color: #cbd5df;
}

.calendar-non-working-label {
  color: #617083;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.week-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.week-summary-header div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.week-summary-header strong {
  font-size: 13px;
  line-height: 1.2;
}

.week-summary-header span {
  color: var(--muted);
  font-size: 12px;
}

.week-summary-body {
  display: grid;
  gap: 7px;
  padding: 8px;
}

/* La semana es una lectura rápida, no otra agenda diaria. Los huecos y
   recordatorios se consultan desde el día completo para no hacer ilegible
   la comparación entre días. */
.appointments-grid.week-view .week-reminders {
  display: none;
}

.week-reminders {
  display: grid;
  gap: 2px;
  padding: 5px 6px;
  border: 1px solid #cfe0f4;
  border-radius: 6px;
  background: #f8fbff;
}

.week-reminder,
.week-reminders-more {
  width: 100%;
  border: 0;
  background: transparent;
  color: #304d68;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.week-reminder {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
}

.week-reminder-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.week-reminder-text { color: #304d68; font-size: 11px; }
.week-reminder.completed { opacity: .58; }
.week-reminder.completed .week-reminder-text { text-decoration: line-through; }
.week-reminders-more { padding: 2px 0 0; color: #24527c; font-size: 11px; font-weight: 700; }

.week-gap {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 6px;
  width: 100%;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #526274;
  cursor: pointer;
  font-size: 11px;
  padding: 6px;
  text-align: left;
}

.week-gap strong { color: #344256; font-size: 11px; }
.week-gap-professionals { display: flex; flex-wrap: wrap; gap: 2px 7px; white-space: normal !important; }
.week-gap-professional { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; color: #435368; font-size: 10px; font-weight: 650; }
.week-gap-professional .key-dot { flex: 0 0 8px; width: 8px; height: 8px; margin: 0; }
.week-gap span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.week-gap:hover { border-color: #9eb9d4; background: #f1f6fb; }

.week-open-day {
  width: calc(100% - 16px);
  margin: 0 8px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--primary-dark);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  padding: 8px;
}

.week-appointment {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-left: 4px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  padding: 7px;
  text-align: left;
  min-height: 62px;
}

.whatsapp-action {
  border-color: #bfe8d0;
  background: #e9f8f0;
  color: #16794f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 9px;
  min-width: 42px;
  min-height: 42px;
}

.whatsapp-icon {
  width: 22px;
  height: 22px;
  display: block;
  fill: #1fa855;
}

.whatsapp-action:hover {
  border-color: #94d8b0;
  background: #dff4e8;
  color: #126541;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--text);
  font-size: 13px;
}

.checkbox-field input {
  width: auto;
  margin: 0;
}

#whatsappTemplate[readonly] {
  background: #f8fafc;
  color: #475569;
}

.week-appointment:hover {
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.1);
}

.week-appointment.doctor-1 {
  background: var(--doctor-1-card);
  border-color: var(--doctor-1-border);
}

.week-appointment.doctor-2 {
  background: var(--doctor-2-card);
  border-color: var(--doctor-2-border);
}

.week-appointment.status-confirmed {
  border-left-color: var(--ok);
}

.week-appointment.status-pending {
  border-left-color: var(--primary);
}

.week-appointment.status-change {
  border-left-color: var(--warning);
}

.week-appointment.status-no_response {
  border-left-color: #64748b;
}

.week-appointment.status-cancelled {
  border-left-color: var(--danger);
  opacity: 0.78;
}

.week-time {
  align-self: stretch;
  display: grid;
  align-content: center;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 5px;
  text-align: center;
}

.week-time small {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 700;
}

.week-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.week-copy strong,
.week-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.week-copy strong {
  font-size: 14px;
  line-height: 1.2;
}

.week-copy small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.week-appointment .status-pill {
  min-width: 82px;
}

.week-open-day:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.day-column {
  min-height: 180px;
  border: 1px solid #d8e0e8;
  border-radius: var(--radius);
  background: #ffffff;
  overflow: hidden;
}

.doctor-column.doctor-1 {
  border-top: 4px solid var(--doctor-1);
}

.doctor-column.doctor-2 {
  border-top: 4px solid var(--doctor-2);
}

.doctor-column.doctor-1 .day-column-header {
  background: var(--doctor-1-soft);
}

.doctor-column.doctor-2 .day-column-header {
  background: var(--doctor-2-soft);
}

.day-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.column-header-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.column-header-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.column-header-title .doctor-count {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  font-size: 11px;
}

.doctor-work-legend .total-count {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  background: #cbd5e1;
  border: 1px solid #94a3b8;
}

.column-header-main span {
  color: var(--muted);
  font-size: 12px;
}

.column-appointment-total { color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }

.day-column-header strong {
  font-size: 15px;
}

.column-add-btn {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #223044;
  cursor: pointer;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 8px;
}

.column-add-btn:hover {
  border-color: #aeb9c6;
  background: #f7f9fb;
  color: #223044;
}

.column-reminder-btn {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #344256;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 8px;
}

.column-reminder-btn:hover { border-color: #aeb9c6; background: #f7f9fb; color: #223044; }

.day-column-body {
  display: grid;
  gap: 7px;
  padding: 10px;
}

.empty {
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

.empty.compact {
  padding: 10px;
}

.appointment-card {
  border: 1px solid var(--line);
  border-left: 5px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  display: grid;
  grid-template-rows: auto minmax(18px, auto) minmax(20px, auto) auto;
  min-height: 158px;
  padding: 8px 9px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  cursor: pointer;
}

.appointment-card:hover {
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.1);
  transform: translateY(-1px);
}

.appointment-card.status-confirmed {
  border-left-color: var(--ok);
}

.appointment-card.status-pending {
  border-left-color: var(--primary);
}

.appointment-card.status-change {
  border-left-color: var(--warning);
}

.appointment-card.status-no_response {
  border-left-color: #64748b;
}

.appointment-card.status-cancelled {
  border-left-color: var(--danger);
  opacity: 0.78;
}

.appointment-card.needs-review {
  border-color: #e8b85b;
  background: #fffaf0;
}

.appointment-card.doctor-1 {
  background: var(--doctor-1-card);
  border-color: var(--doctor-1-border);
}

.appointment-card.doctor-2 {
  background: var(--doctor-2-card);
  border-color: var(--doctor-2-border);
}

.appointment-card.doctor-1.status-confirmed,
.week-appointment.doctor-1.status-confirmed,
.appointment-card.doctor-2.status-confirmed,
.week-appointment.doctor-2.status-confirmed {
  border-left-color: var(--ok);
}

.appointment-card.doctor-1.status-pending,
.week-appointment.doctor-1.status-pending,
.appointment-card.doctor-2.status-pending,
.week-appointment.doctor-2.status-pending {
  border-left-color: var(--primary);
}

.appointment-card.doctor-1.status-change,
.week-appointment.doctor-1.status-change,
.appointment-card.doctor-2.status-change,
.week-appointment.doctor-2.status-change {
  border-left-color: var(--warning);
}

.appointment-card.doctor-1.status-no_response,
.week-appointment.doctor-1.status-no_response,
.appointment-card.doctor-2.status-no_response,
.week-appointment.doctor-2.status-no_response {
  border-left-color: #64748b;
}

.appointment-card.doctor-1.status-cancelled,
.week-appointment.doctor-1.status-cancelled,
.appointment-card.doctor-2.status-cancelled,
.week-appointment.doctor-2.status-cancelled {
  border-left-color: var(--danger);
}

/* La vista diaria prioriza lectura y acciones; la vista semanal identifica agendas. */
.appointments-grid.day-view .appointment-card.doctor-1,
.appointments-grid.day-view .appointment-card.doctor-2 {
  background: #fff;
  border-top-color: var(--line);
  border-right-color: var(--line);
  border-bottom-color: var(--line);
}

.appointments-grid.day-view .appointment-card.status-pending { background: #f8fbff; }
.appointments-grid.day-view .appointment-card.status-confirmed { background: #f8fcfa; }
.appointments-grid.day-view .appointment-card.status-change { background: #fffdf7; }
.appointments-grid.day-view .appointment-card.status-no_response { background: #fafbfc; }
.appointments-grid.day-view .appointment-card.status-cancelled { background: #fffafa; }

/* El estado se identifica por texto y borde; el selector no rellena toda la tarjeta. */
.status-select.status-tone-pending,
.status-select.status-tone-confirmed,
.status-select.status-tone-change,
.status-select.status-tone-no_response,
.status-select.status-tone-cancelled,
#appointmentStatus.status-tone-pending,
#appointmentStatus.status-tone-confirmed,
#appointmentStatus.status-tone-change,
#appointmentStatus.status-tone-no_response,
#appointmentStatus.status-tone-cancelled {
  background: #fff;
}

.appointments-grid.week-view .week-appointment.doctor-1 {
  border-left-color: var(--doctor-1);
}

.appointments-grid.week-view .week-appointment.doctor-2 {
  border-left-color: var(--doctor-2);
}

/* Overrides finales: prevalecen sobre la paleta histórica de los selectores. */
.appointments-grid.day-view .appointment-card.status-pending,
.appointments-grid.day-view .appointment-card.status-confirmed,
.appointments-grid.day-view .appointment-card.status-change,
.appointments-grid.day-view .appointment-card.status-no_response,
.appointments-grid.day-view .appointment-card.status-cancelled {
  background: transparent;
}

.appointment-card .status-select.status-tone-pending,
.appointment-card .status-select.status-tone-confirmed,
.appointment-card .status-select.status-tone-change,
.appointment-card .status-select.status-tone-no_response,
.appointment-card .status-select.status-tone-cancelled,
.appointment-dialog #appointmentStatus.status-tone-pending,
.appointment-dialog #appointmentStatus.status-tone-confirmed,
.appointment-dialog #appointmentStatus.status-tone-change,
.appointment-dialog #appointmentStatus.status-tone-no_response,
.appointment-dialog #appointmentStatus.status-tone-cancelled {
  background: #fff !important;
}

.status-select option.status-option-pending,
.status-select option.status-option-confirmed,
.status-select option.status-option-change,
.status-select option.status-option-no_response,
.status-select option.status-option-cancelled,
#appointmentStatus option.status-option-pending,
#appointmentStatus option.status-option-confirmed,
#appointmentStatus option.status-option-change,
#appointmentStatus option.status-option-no_response,
#appointmentStatus option.status-option-cancelled {
  background: #fff !important;
}

/* El tratamiento aprovecha el espacio libre sin desplazar las acciones. */
.appointments-grid.day-view .appointment-card .meta span:nth-child(3) {
  flex: 1 1 auto;
  min-width: 56px;
  width: auto;
  max-width: none !important;
}

.appointments-grid.day-view .appointment-card .meta span:first-child {
  display: none;
}

.appointments-grid.day-view .appointment-card .meta .daily-note {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 18px;
  width: 18px;
  color: #64748b;
  line-height: 1;
  cursor: pointer;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}
.appointments-grid.day-view .appointment-card .meta .daily-note svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.appointments-grid.day-view .appointment-card .meta span:nth-child(3) {
  flex: 1 1 auto;
  min-width: 80px;
}

.appointments-grid.day-view .appointment-card .meta:has(.daily-note) span:nth-child(3) {
  flex: 0 1 220px;
  min-width: 0;
  max-width: 220px !important;
}

.appointment-main {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 8px;
}

.time {
  align-self: start;
  min-height: 46px;
  padding: 7px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  font-weight: 700;
  font-size: 13px;
  text-align: center;
}

.time small {
  display: block;
  margin-top: 2px;
  color: inherit;
  font-size: 10px;
  font-weight: 700;
}

.appointment-card.doctor-1 .time {
  background: var(--surface-2);
  color: var(--text);
}

.appointment-card.doctor-2 .time {
  background: var(--surface-2);
  color: var(--text);
}

.appointment-card h3 {
  margin-bottom: 2px;
  font-size: 14px;
}

.appointment-card .meta {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 5px;
  font-size: 12px;
  min-width: 0;
  overflow: hidden;
}
.appointment-patient-heading { display: flex; align-items: center; gap: 6px; min-width: 0; }
.appointment-patient-heading { flex-wrap: nowrap; overflow: hidden; }
.appointment-main > div:last-child { min-width: 0; }
.appointment-patient-heading h3 { flex: 1 1 auto; min-width: 0; max-width: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.booking-source-badge { display: inline-flex; align-items: center; flex: 0 0 auto; min-height: 18px; padding: 1px 6px; border: 1px solid #cbd5e1; border-radius: 999px; background: #f8fafc; color: #526274; font-size: 9px; font-weight: 800; line-height: 1; letter-spacing: .02em; }
.booking-source-badge[data-source="online"] { border-color: #b9d4ff; background: #eef5ff; color: #1556ad; }
.booking-source-badge[data-source="whatsapp"] { border-color: #bde6d1; background: #effaf4; color: #137447; }
.booking-source-badge[data-source="phone_bot"] { border-color: #c4e5d2; background: #edf9f3; color: #126441; }
.daily-note-heading { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 18px; width: 18px; color: #64748b; cursor: pointer; }
.daily-note-heading svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.change-preference-badge { display: inline-flex; align-items: center; justify-content: center; width: 25px; height: 25px; color: #94a3b8; background: transparent; border: 0; border-radius: 0; padding: 0; font-size: 19px; line-height: 1; flex: 0 0 25px; cursor: pointer; user-select: none; transition: color .15s ease, opacity .15s ease; }
.change-preference-badge.active { color: #c2410c; background: transparent; border: 0; }
.change-preference-badge:hover { opacity: .75; }
.change-preference-badge.saving { opacity: .55; pointer-events: none; }
.appointment-card.accepts-change .change-preference-badge { display: inline-flex; }
.daily-gap { display: flex; align-items: center; gap: 8px; margin: 2px 0; padding: 5px 8px; border: 1px dashed #cbd5e1; border-radius: 7px; background: #f8fafc; color: #64748b; font-size: 11px; cursor: pointer; }
.daily-gap::before, .daily-gap::after { content: ""; height: 1px; flex: 1; background: #dbe4ef; }

.appointment-card .meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.appointment-card .meta span:first-child {
  max-width: 120px;
}

.appointment-card .meta span:nth-child(2) {
  max-width: 80px;
}

.appointment-card .meta span:nth-child(3) {
  max-width: 96px;
}

.notes {
  margin: 7px 0 2px 64px;
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  line-height: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* En columnas estrechas se reserva siempre el espacio del nombre antes que el de los iconos. */
.appointments-grid.day-view:has(> .doctor-column:nth-child(5)) .daily-note-heading {
  display: none;
}

.appointments-grid.day-view:has(> .doctor-column:nth-child(4)) .change-preference-badge {
  display: none;
}

/* Las tarjetas se adaptan al ancho real de cada columna, también cuando el
   panel lateral o un filtro cambia el espacio sin cambiar el viewport. */
@container (max-width: 520px) {
  .appointments-grid.day-view .booking-source-badge { display: inline-flex; }
}

@container (max-width: 450px) {
  .appointments-grid.day-view .daily-note-heading { display: none; }
  .appointments-grid.day-view .appointment-patient-heading { gap: 4px; }
}

@container (max-width: 390px) {
  .appointments-grid.day-view .change-preference-badge { display: none; }
  .appointments-grid.day-view .appointment-card .status-select { width: 104px; max-width: 104px; }
}

@container (max-width: 340px) {
  .appointments-grid.day-view .appointment-card {
    align-items: stretch;
    flex-wrap: wrap;
  }
  .appointments-grid.day-view .appointment-main { flex: 1 1 100%; }
  .appointments-grid.day-view .appointment-card .card-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

@container (max-width: 700px) {
  .appointments-grid.day-view {
    grid-template-columns: 1fr;
  }
  .appointments-grid.day-view .doctor-column {
    min-width: 0;
  }
}

.next-action {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 7px 64px;
  overflow: hidden;
  color: #344256;
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-badges {
  display: inline-flex;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.review-badges em {
  border: 1px solid #e8b85b;
  border-radius: 999px;
  background: #fff4cf;
  color: #6b4500;
  flex: 0 0 auto;
  font-style: normal;
  font-weight: 700;
  padding: 1px 6px;
}

.status-pill {
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  justify-self: start;
  min-width: 76px;
  padding: 5px 8px;
  white-space: nowrap;
  justify-content: center;
}

.status-pill.status-pending {
  background: var(--primary);
}

.status-pill.status-confirmed {
  background: var(--ok);
}

.status-pill.status-change {
  background: var(--warning);
  min-width: 92px;
}

.status-pill.status-no_response {
  background: #64748b;
  min-width: 98px;
}

.status-pill.status-cancelled {
  background: var(--danger);
}

.appointment-card .card-actions {
  align-self: end;
  justify-content: flex-end;
}

.appointment-card .status-select {
  max-width: 132px;
  padding: 6px 8px;
  font-size: 12px;
}

/* Misma paleta que las tarjetas, aplicada con un tono suave al estado seleccionado. */
.status-select.status-tone-pending,
#appointmentStatus.status-tone-pending {
  background: #eef5ff;
  border-color: #b9d4ff;
  color: #1556ad;
}

.status-select.status-tone-confirmed,
#appointmentStatus.status-tone-confirmed {
  background: #edf9f3;
  border-color: #b7e2ca;
  color: #126441;
}

.status-select.status-tone-change,
#appointmentStatus.status-tone-change {
  background: #fff8e8;
  border-color: #ecd59a;
  color: #765000;
}

.status-select.status-tone-no_response,
#appointmentStatus.status-tone-no_response {
  background: #f1f4f7;
  border-color: #cbd5e1;
  color: #526274;
}

.status-select.status-tone-cancelled,
#appointmentStatus.status-tone-cancelled {
  background: #fff1f0;
  border-color: #efc1bc;
  color: #9e2118;
}

/* El desplegable usa la misma señal visual, con tonos todavía discretos. */
.status-select option.status-option-pending,
#appointmentStatus option.status-option-pending {
  background: #eef5ff;
  color: #1556ad;
}

.status-select option.status-option-confirmed,
#appointmentStatus option.status-option-confirmed {
  background: #edf9f3;
  color: #126441;
}

.status-select option.status-option-change,
#appointmentStatus option.status-option-change {
  background: #fff8e8;
  color: #765000;
}

.status-select option.status-option-no_response,
#appointmentStatus option.status-option-no_response {
  background: #f1f4f7;
  color: #526274;
}

.status-select option.status-option-cancelled,
#appointmentStatus option.status-option-cancelled {
  background: #fff1f0;
  color: #9e2118;
}

.patient-list {
  display: grid;
  gap: 5px;
  max-height: 280px;
  overflow: auto;
}

.mobile-patients-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mobile-patients-heading h2 { margin: 0 0 10px; }
.mobile-patients-heading button { display: none; }

.patient-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 7px 8px;
  font-size: 13px;
  cursor: pointer;
}

.patient-item strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.patient-item small {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.patient-dialog-context { margin: 4px 0 0; color: #35536f; font-size: 12px; font-weight: 700; }
.patient-history-loading { margin: 0 0 8px; color: var(--muted); font-size: 12px; }

#newPatientBtn { margin-bottom: 8px; padding: 6px 9px; font-size: 12px; }

.patient-matches {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% - 1px);
  display: grid;
  gap: 6px;
  margin-top: 0;
  max-height: 190px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .16);
}

.patient-matches button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 9px 10px;
  text-align: left;
  cursor: pointer;
}
.patient-matches .new-patient-match { color: var(--primary); font-weight: 700; border-top: 1px solid var(--line); }

.patient-matches small {
  color: var(--muted);
  white-space: nowrap;
}

.patient-match-status {
  margin: 4px 0 0;
  color: #48627b;
  font-size: 11px;
  line-height: 1.3;
  font-weight: 600;
}
.patient-match-status.new { color: #28714f; }
.patient-match-status.existing { color: #355d87; }

.dialog {
  width: min(760px, calc(100vw - 28px));
  border: 0;
  border-radius: var(--radius);
  box-shadow: 0 24px 72px rgba(15, 23, 42, 0.24);
  padding: 0;
}

.dialog.small-dialog {
  width: min(440px, calc(100vw - 28px));
}

/* Todas las modales pequeñas comparten la misma escala y no crecen fuera de
   la pantalla cuando aparece un error o contenido adicional. */
.dialog.small-dialog .dialog-header h2 { margin: 0; font-size: 16px; line-height: 1.25; }
.dialog.small-dialog .dialog-subtitle { margin-top: 4px; font-size: 13px; line-height: 1.3; }
.dialog.small-dialog .field { gap: 4px; }
.dialog.small-dialog .field > span { font-size: 12px; }
.dialog.small-dialog input,
.dialog.small-dialog select,
.dialog.small-dialog textarea { font-size: 13px; line-height: 1.25; }
.dialog.small-dialog .dialog-actions .btn { min-height: 32px; padding: 6px 10px; font-size: 12px; }
.dialog.small-dialog form { max-height: calc(100dvh - 28px); overflow-y: auto; box-sizing: border-box; }
.feedback-dialog form { min-height: 132px; }
.feedback-dialog {
  border: 1px solid #dbe3ee;
  border-top: 3px solid #4b83c5;
  border-radius: 14px;
  overflow: hidden;
}
.feedback-dialog .dialog-header {
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.feedback-heading { min-width: 0; flex: 1; }
.feedback-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eaf3fc;
  color: #2c6ba7;
  font-size: 15px;
  font-weight: 800;
}
.feedback-dialog.feedback-warning { border-top-color: #d28a27; }
.feedback-dialog.feedback-warning .feedback-icon { background: #fff4df; color: #9a5d09; }
.feedback-dialog.feedback-error { border-top-color: #d35d5d; }
.feedback-dialog.feedback-error .feedback-icon { background: #fff0f0; color: #b43f3f; }
.feedback-dialog.feedback-success { border-top-color: #3d9b70; }
.feedback-dialog.feedback-success .feedback-icon { background: #eaf8f0; color: #24734f; }
.feedback-dialog .dialog-actions { margin-top: 14px; }
.feedback-dialog #feedbackMessage {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #40536b;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.toast-container {
  position: fixed;
  z-index: 1000;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  width: min(340px, calc(100vw - 36px));
  pointer-events: none;
}
.ui-toast {
  border: 1px solid #b7dfc6;
  border-radius: 8px;
  background: #f1fbf4;
  color: #21633a;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .14);
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  animation: toast-in .18s ease-out;
}
.ui-toast.error { border-color: #efb5b5; background: #fff5f5; color: #a42323; }
.ui-toast.is-leaving { opacity: 0; transform: translateY(4px); transition: opacity .18s, transform .18s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.patient-dialog {
  width: min(590px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
}
.patient-form-dialog { width: min(650px, calc(100vw - 28px)); background: #f8fbff; }
.patient-dialog .dialog-body,
.login-dialog form,
.patient-form-dialog form { padding: 14px; }
.patient-dialog #patientAppointments {
  max-height: min(440px, calc(100vh - 250px));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 3px;
}
.patient-dialog .dialog-header h2,
.patient-form-dialog .dialog-header h2 { font-size: 18px; }
.login-dialog .dialog-header h2 { margin: 0; font-size: 16px; line-height: 1.25; }
.login-dialog .dialog-subtitle { margin-top: 4px; font-size: 13px; line-height: 1.3; }
.login-dialog .field { gap: 4px; margin-bottom: 10px; }
.login-dialog .field > span { font-size: 12px; }
.login-dialog input,
.login-dialog select { padding: 8px 9px; font-size: 13px; line-height: 1.25; }
.login-dialog .link-btn { font-size: 12px; }
.patient-dialog .dialog-actions { gap: 6px; }
.patient-dialog .dialog-actions .btn,
.login-dialog .dialog-actions .btn,
.patient-form-dialog .dialog-actions .btn { min-height: 32px; padding: 6px 10px; font-size: 12px; }
.patient-header-actions,
.patient-footer-actions { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.patient-header-actions .btn,
.patient-footer-actions .btn { min-height: 32px; padding: 6px 9px; font-size: 12px; white-space: nowrap; }
.patient-form-dialog .dialog-header {
  align-items: flex-start;
  margin: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #ffffff, #f1f7ff);
}
.patient-form-title-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px 10px; }
.patient-form-title-context { color: var(--muted); font-size: 12px; font-weight: 600; line-height: 1.3; }
.patient-form-content { display: grid; gap: 10px; margin-top: 10px; }
.patient-form-section {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 3px 12px rgba(32, 74, 125, .05);
}
.patient-form-section h3 { margin: 0 0 7px; color: #344256; font-size: 13px; letter-spacing: .01em; }
.patient-form-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(120px, .85fr) minmax(120px, .85fr) minmax(105px, .8fr); gap: 8px 10px; }
.patient-form-grid .field { margin: 0; gap: 4px; }
.patient-name-field { grid-column: auto; }
.patient-email-field { grid-column: span 1; }
.patient-address-field { grid-column: span 2; }
.patient-notes-section .field { gap: 4px; margin: 0; }
.patient-form-dialog input,
.patient-form-dialog textarea,
.appointment-dialog input,
.appointment-dialog select,
.appointment-dialog textarea { padding: 8px 9px; font-size: 13px; }
.patient-form-dialog .field,
.appointment-dialog .field { gap: 4px; }
.patient-form-dialog textarea { min-height: 70px; resize: vertical; }
.patient-form-dialog .dialog-actions { margin-top: 12px; }
.danger-secondary { border-color: #efb5b5; background: #fff8f8; color: #b42318; }
.danger-secondary:hover { border-color: #dc8d8d; background: #fff0f0; }

.dialog.wide-dialog {
  width: min(1180px, calc(100vw - 28px));
}

.appointment-dialog {
  width: min(860px, calc(100vw - 28px));
  height: min(760px, calc(100vh - 16px));
  max-height: calc(100vh - 16px);
  overflow: hidden;
  background: #f8fbff;
}

.dialog.appointment-dialog form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 16px;
  font-size: 13px;
  height: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.appointment-dialog-content {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

.appointment-review-notice {
  border: 1px solid #e8b85b;
  border-radius: 7px;
  background: #fff7e6;
  color: #704d12;
  padding: 9px 11px;
  font-size: 13px;
  line-height: 1.45;
}

/* Chromium puede enfocar automáticamente un contenedor con scroll al abrir
   una modal. No es un control editable y no debe dibujar un marco de foco. */
.appointment-dialog-content:focus,
.appointment-dialog-content:focus-visible {
  outline: none;
}

.appointment-dialog .dialog-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  margin: 0;
  padding-bottom: 10px;
  background: linear-gradient(135deg, #ffffff, #f1f7ff);
}

.appointment-dialog .dialog-header h2 {
  margin-bottom: 3px;
  font-size: 20px;
}

.appointment-title-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px 10px;
}

.appointment-title-context {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}

.appointment-dialog .dialog-header > .btn { flex: 0 0 auto; min-height: 32px; padding: 6px 9px; font-size: 12px; white-space: nowrap; }

.appointment-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 3px 12px rgba(32, 74, 125, .05);
  padding: 10px;
}

.appointment-section h3 {
  margin: 0 0 7px;
  color: #344256;
  font-size: 13px;
  letter-spacing: 0.01em;
}

.appointment-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.appointment-section-heading h3 { margin: 0; }
.appointment-section-heading .appointment-patient-record-btn {
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f7fbff;
  border-color: #a9c5df;
  color: #24527c;
  box-shadow: none;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}
.appointment-section-heading .appointment-patient-record-btn:hover,
.appointment-section-heading .appointment-patient-record-btn:focus-visible {
  border-color: #6f9fc9;
  background: #edf6ff;
  outline: none;
}

.appointment-section .field {
  margin: 0;
}
.appointment-section .field:has(#patientName) { position: relative; }

.appointment-extras {
  background: #fff;
}

.appointment-form-grid {
  gap: 8px 10px;
}

.appointment-source-field {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 5px 10px;
  min-width: 0;
  margin: 0;
  font-size: 12px;
}

.appointment-source-label {
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.appointment-source-options { display: flex; flex-wrap: nowrap; align-items: center; gap: 5px 9px; }

.appointment-details-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
.patient-fields-grid { grid-template-columns: minmax(0, 2fr) minmax(90px, .75fr) minmax(130px, 1fr); }
.patient-fields-grid { column-gap: 6px; align-items: start; grid-auto-rows: max-content; }
.patient-fields-grid .field { align-self: start; }
.patient-contact-row { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(175px, .8fr) minmax(0, 2fr); gap: 10px; align-items: start; width: 100%; }
.patient-contact-row .field { margin: 0; }
.patient-contact-row .patient-email-field,
.patient-contact-row .patient-address-field { grid-column: auto; }
.appointment-notes-grid { align-items: start; }
.appointment-notes-grid > .field { align-self: start; }
.appointment-change-field { align-self: start; justify-self: start; min-height: 30px; margin: 0; white-space: nowrap; }
.appointment-dialog .patient-fields-grid { grid-template-columns: minmax(0, 2fr) minmax(90px, .75fr) minmax(130px, 1fr); }
.appointment-dialog .appointment-details-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.appointment-details-grid .field:has(#appointmentDate) { grid-column: 1; }
.appointment-details-lower { display: grid; grid-template-columns: minmax(250px, 1fr) minmax(0, 1fr); gap: 18px; margin-top: 10px; align-items: stretch; }
.appointment-details-left,
.appointment-details-right { display: grid; gap: 8px; align-content: start; }
.appointment-details-right { grid-column: 2; padding-left: 18px; border-left: 1px solid var(--line); }
.appointment-details-left .appointment-details-checks { min-height: 26px; }
.appointment-date-time-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.appointment-slot-tools { display: flex; align-items: center; gap: 12px; min-height: 30px; }
.find-slot-btn { min-height: 30px; padding: 5px 9px; font-size: 12px; }
.find-slot-btn,
.patient-footer-actions #patientFollowUpBtn { border-color: #91b9dc; background: #f1f8ff; color: #1d5d94; font-weight: 700; box-shadow: 0 1px 2px rgba(36, 82, 124, .08); }
.find-slot-btn:hover, .find-slot-btn:focus-visible,
.patient-footer-actions #patientFollowUpBtn:hover, .patient-footer-actions #patientFollowUpBtn:focus-visible { border-color: #5e94c2; background: #e5f2ff; color: #174f86; outline: none; }

.appointment-details-left .field, .appointment-notes-field { margin: 0; }
.appointment-notes-field textarea { width: 100%; min-height: 76px; height: 76px; }
.appointment-details-checks { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 12px; min-height: 30px; }
.appointment-details-checks .appointment-source-options { gap: 5px 8px; }
.patient-form-contact-row { grid-column: 1 / -1; }
.appointment-communication-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(220px, 1fr); gap: 10px; align-items: start; }
.appointment-communication-layout .field { margin: 0; }
.communication-checks-field { padding-top: 20px; }

.appointment-dialog input,
.appointment-dialog select,
.appointment-dialog textarea { padding: 8px 9px; }
.appointment-dialog textarea { min-height: 58px; }
.appointment-dialog .field { gap: 4px; }
.optional-label { font-style: normal; font-weight: 400; color: var(--muted); }
.whatsapp-message-field textarea { min-height: 104px; height: 104px; }
.appointment-dialog .btn { padding: 8px 11px; font-size: 13px; }

/* Compact action controls in the agenda. */
.topbar-actions .btn,
.toolbar > .btn,
.toolbar .segmented button,
.toolbar .view-switch button { min-height: 32px; padding: 5px 9px; font-size: 12px; }
.appointment-dialog .dialog-actions .btn,
.appointment-dialog .dialog-actions-right .btn { min-height: 32px; padding: 6px 10px; font-size: 12px; }
.appointment-dialog .icon-btn { width: 30px; height: 30px; }

.slot-suggestions-dialog { width: min(480px, calc(100vw - 28px)); max-height: calc(100dvh - 32px); overflow: hidden; }
.slot-suggestions-dialog .dialog-body { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 9px; max-height: calc(100dvh - 32px); padding: 14px; }
.slot-suggestions-dialog .dialog-header { margin: 0; }
.slot-suggestions-list { display: grid; align-content: start; gap: 7px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 1px 3px 2px 1px; }
.slot-suggestion-group { display: grid; gap: 5px; padding: 8px; border: 1px solid #d8e5f2; border-radius: 9px; background: #fbfdff; }
.slot-suggestion-group.is-day-hidden, .slot-suggestion.is-slot-hidden { display: none; }
.slot-suggestion-group h3 { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0; color: #173f67; font-size: 13px; line-height: 1.3; text-transform: capitalize; }
.slot-suggestion-group h3 span { color: #71859a; font-size: 11px; font-weight: 600; }
.slot-suggestion-period { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.slot-suggestion-more { justify-self: start; border: 0; padding: 3px 2px; background: transparent; color: #1768a9; font: inherit; font-size: 11px; font-weight: 650; cursor: pointer; }
.slot-suggestion-more:hover, .slot-suggestion-more:focus-visible { color: #104a7c; text-decoration: underline; outline: none; }
.slot-suggestion-more-days { justify-self: center; padding: 7px 12px; border: 1px solid #d8e5f2; border-radius: 7px; background: #fff; }
.slot-suggestion {
  display: grid;
  min-width: 0;
  width: 100%;
  padding: 7px 8px;
  border: 1px solid #cfddeb;
  border-radius: 7px;
  background: #fff;
  color: #284969;
  text-align: center;
  cursor: pointer;
}
.slot-suggestion:hover, .slot-suggestion:focus-visible { border-color: #5d96d0; background: #f4f9ff; outline: none; }
.slot-suggestion-main { display: grid; gap: 2px; min-width: 0; color: #183f65; font-size: 10px; line-height: 1.25; }
.slot-suggestion-main strong { font-size: 13px; }
.slot-suggestion-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-suggestions-empty { margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: #f8fafc; color: var(--muted); font-size: 12px; line-height: 1.4; }

.appointment-time-help {
  grid-column: 1 / -1;
  margin: -1px 0 0;
  border-left: 3px solid var(--primary);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  padding: 5px 8px;
}

.appointment-dialog .dialog-actions {
  border-top: 1px solid var(--line);
  margin: 0;
  padding: 12px 0 0;
  background: #fff;
  z-index: 1;
  justify-content: flex-end;
}

/* Todas las salidas de la cita quedan juntas a la derecha, igual que en el
   resto de modales. "Cancelar cita" sigue siendo la acción destructiva, pero
   no rompe la lectura del pie dejando un botón aislado a la izquierda. */
.appointment-dialog #deleteAppointmentBtn { margin-left: 2px; }

@media (max-height: 780px) {
  .appointment-dialog form { gap: 6px; padding: 10px; }
  .appointment-section { padding: 7px; }
  .appointment-form-grid { gap: 5px 8px; }
  .appointment-dialog input, .appointment-dialog select, .appointment-dialog textarea { padding: 6px 8px; }
  .appointment-dialog textarea { min-height: 45px; }
  .appointment-dialog .dialog-actions { padding: 8px 14px 10px; }
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.dialog form,
.dialog-body {
  padding: 18px;
}

#reminderDialog form {
  padding: 14px;
}

#reminderDialog .dialog-header h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
}

#reminderDialog .dialog-subtitle {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.3;
}

#reminderDialog .field > span { font-size: 12px; }

#reminderDialog input,
#reminderDialog select,
#reminderDialog textarea {
  padding: 8px 9px;
  font-size: 13px;
  line-height: 1.25;
}

#reminderDialog textarea {
  min-height: 78px;
}

#reminderDialog .btn {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.settings-page {
  padding: 22px 24px 32px;
}

.settings-shell {
  max-width: 1240px;
  min-height: calc(100vh - 112px);
  margin: 0 auto;
}

.settings-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.settings-page-header #closeSettingsBtn { display: none; }

.settings-context-bar {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #dbe7f5;
  border-radius: 12px;
  background: #f7faff;
  box-shadow: none;
}
.settings-context-bar h2 { margin: 0 0 2px; color: #183b66; font-size: 17px; }
.settings-context-bar .dialog-subtitle { margin: 0; font-size: 12px; }

.settings-page-header h2 {
  margin-bottom: 4px;
  font-size: 22px;
}

.settings-feedback {
  margin: -8px 0 16px;
  padding: 10px 12px;
  border: 1px solid #b7d7c2;
  border-radius: 6px;
  background: #f0fbf4;
}

.section-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.settings-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  align-items: start;
  gap: 18px;
}

.settings-tabs {
  position: sticky;
  top: 86px;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.settings-tab {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #344256;
  cursor: pointer;
  padding: 11px 12px;
  text-align: left;
}

.settings-tab strong {
  font-size: 14px;
}

.settings-tab span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.settings-tab.active {
  border-color: #bcd7ff;
  background: #f0f7ff;
  color: var(--primary-dark);
}

.settings-tab.active span {
  color: #365f8c;
}

.settings-panels {
  min-height: 620px;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.dialog-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
}

.form-error {
  margin: 4px 0 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.field-help {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.settings-card .dialog-subtitle,
.settings-help {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: 10px 0 14px;
  padding: 10px 12px;
}

.privacy-note {
  border-color: var(--line);
  background: #f8fafc;
  color: var(--muted);
}

.support-tools {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.support-tools h4 {
  margin: 0 0 4px;
  font-size: 15px;
}

.support-overview {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.support-admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.support-admin-box {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 12px;
}

.support-admin-box h4 {
  margin: 0 0 10px;
  font-size: 15px;
}

.support-user-admin {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.compact-toggle {
  margin-top: 10px;
}

.support-summary-grid,
.support-status-grid {
  display: grid;
  gap: 10px;
}

.support-summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.support-status-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.support-metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 10px;
}

.support-metric span,
.support-metric small,
.support-metric strong {
  display: block;
}

.support-metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.support-metric strong {
  overflow-wrap: anywhere;
  margin-top: 4px;
  color: #1f2937;
  font-size: 18px;
  line-height: 1.2;
}

.support-metric small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.support-section {
  display: grid;
  gap: 8px;
}

.support-section h4 {
  margin: 4px 0 0;
  font-size: 15px;
}

.support-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.support-table th,
.support-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 6px;
  text-align: left;
  vertical-align: top;
}

.support-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.contract-readonly {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0 14px;
}

.contract-readonly div {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 10px;
}

.contract-readonly span,
.contract-readonly strong {
  display: block;
}

.contract-client-readonly {
  display: none;
}

.whatsapp-btn {
  position: relative;
}

.whatsapp-sent-toggle {
  position: absolute;
  right: -6px;
  top: -7px;
  z-index: 2;
  display: block;
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #94a3b8;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  line-height: 14px;
  text-align: center;
}

.whatsapp-sent-toggle.active {
  background: #16a34a;
}

.whatsapp-sent-toggle.saving {
  opacity: .55;
  pointer-events: none;
}

.whatsapp-sent-toggle {
  user-select: none;
}


.contract-readonly span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.contract-readonly strong {
  color: #344256;
  font-size: 13px;
  line-height: 1.35;
}

.support-contract-fields {
  display: none !important;
}

body.contract-support-edit .support-contract-fields {
  display: grid !important;
}

body.contract-support-edit label.support-contract-fields {
  display: grid !important;
}

body.contract-support-edit .contract-readonly {
  display: none;
}

.excel-template {
  display: grid;
  gap: 6px;
  margin: 10px 0 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
}

.excel-template code {
  display: block;
  overflow: auto;
  padding: 8px;
  border-radius: 4px;
  background: #eef2f6;
  white-space: nowrap;
}

.form-error.success {
  color: var(--ok);
}

#bulkImportData {
  width: 100%;
  min-height: 150px;
  resize: vertical;
}

.settings-section {
  margin: 0;
}

.internal-reminders-panel {
  margin: 0 0 7px;
  padding: 5px 7px;
  border: 1px solid #d8e4f0;
  border-radius: 6px;
  background: #f8fbff;
}

.column-header-actions { display: flex; align-items: center; gap: 6px; }

.internal-reminders-list { display: grid; gap: 2px; }
.internal-reminder { display: flex; align-items: center; gap: 5px; min-height: 28px; border-bottom: 1px solid #e6eef6; cursor: pointer; padding: 2px 0; }
.internal-reminder:last-child { border-bottom: 0; }
.internal-reminder:hover { background: #f0f7ff; }
.internal-reminder-text { flex: 1; min-width: 0; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.internal-reminder small { color: var(--muted); font-size: 11px; }
.internal-reminder.completed .internal-reminder-text { color: var(--muted); text-decoration: line-through; }
.reminder-kind { display: inline-flex; flex: 0 0 auto; align-items: center; border-radius: 4px; background: #eaf2fc; color: #355d87; font-size: 10px; font-weight: 700; line-height: 1; padding: 3px 4px; }
.reminder-overflow { display: none; }
[data-reminder-group].is-expanded .reminder-overflow,
[data-reminder-list].is-expanded .reminder-overflow { display: flex; }
.week-reminder.reminder-overflow { display: none; }
.week-reminder-group.is-expanded .week-reminder.reminder-overflow,
.week-reminder-list.is-expanded .week-reminder.reminder-overflow { display: flex; }
.reminder-expand { margin-top: 2px; border: 0; background: transparent; color: #24527c; cursor: pointer; font: inherit; font-size: 11px; font-weight: 700; padding: 1px 0; text-align: left; }
.reminder-complete, .reminder-delete { border: 0; background: transparent; cursor: pointer; }
.reminder-complete { width: 20px; height: 20px; color: #94a3b8; font-size: 16px; font-weight: 800; line-height: 1; padding: 0; }
.reminder-complete.active { color: #16a34a; }
.reminder-complete:hover { color: #15803d; }
.reminder-delete { width: 20px; height: 20px; color: #94a3b8; padding: 3px; }
.reminder-delete svg { width: 13px; height: 13px; fill: currentColor; }
.reminder-delete:hover { color: #b91c1c; background: #fee2e2; }

.settings-section h3 {
  margin-bottom: 6px;
  font-size: 19px;
}

.settings-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-height: 620px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.settings-card h3 {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.settings-section-divider {
  border-top: 1px solid var(--line);
  margin-top: 26px;
  padding-top: 22px;
}

.settings-section-divider h3 {
  border: 0;
  margin: 0 0 4px;
  padding: 0;
}

.settings-subtitle {
  margin: 18px 0 10px;
  color: #344256;
  font-size: 14px;
}

.treatment-settings {
  display: grid;
  gap: 10px;
  margin: 8px 0 14px;
}

.treatment-list-head {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 170px 42px;
  gap: 12px;
  margin: 18px 0 8px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.public-booking-list-head,
.public-booking-setting {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(140px, 1fr) 92px minmax(150px, 1fr) 70px 112px;
  gap: 8px;
  align-items: center;
}

.public-booking-list-head {
  margin: 16px 0 8px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.public-booking-settings { display: grid; gap: 10px; margin-bottom: 12px; }

.public-booking-link-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 12px 0 16px;
  padding: 14px 16px;
  border: 1px solid #cfe3df;
  border-radius: 12px;
  background: linear-gradient(120deg, #f0faf8, #fff);
}

.public-booking-link-card > div { display: grid; min-width: 0; gap: 4px; }
.public-booking-link-card strong { color: var(--ink); font-size: 13px; }
.public-booking-link-card p,
.public-booking-link-card span { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.public-booking-link-card a { overflow-wrap: anywhere; color: var(--primary-dark); font-size: 13px; font-weight: 700; }
.public-booking-link-card .btn { flex: 0 0 auto; min-height: 38px; padding: 8px 12px; font-size: 12px; }

.public-booking-setting {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 7px 9px;
}

.public-booking-setting input,
.public-booking-setting select { padding: 7px 8px; }

.public-booking-active {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  white-space: nowrap;
}

.public-booking-row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
}

[data-settings-panel="whatsapp"] .wa-block-intro { margin: 4px 0 12px; color: var(--muted); font-size: 13px; line-height: 1.5; }
[data-settings-panel="whatsapp"] .wa-block-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.wa-onboarding-actions { margin-top: 20px !important; }
.wa-block-actions > span { flex: 1 1 240px; color: var(--muted); font-size: 12px; line-height: 1.5; }
[data-settings-panel="whatsapp"] .wa-block-actions .section-actions { margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.whatsapp-opening-setting > .wa-block-actions { grid-column: 1 / -1; }
#waCredentialsPanel { background: var(--surface); }
#waCredentialsPanel .wa-connection-status { margin: 0 0 14px; padding: 10px 12px; border-left: 3px solid #90abc5; border-radius: 4px; background: #f2f6fa; color: #415d77; font-size: 13px; line-height: 1.5; }
#waCredentialsPanel .wa-connection-status.is-connected { border-left-color: #16804a; background: #edf8f1; color: #17663d; font-weight: 600; }
.wa-inbox-list { display: grid; gap: 8px; margin-top: 10px; }
.wa-inbox-item { display: flex; align-items: start; justify-content: space-between; gap: 12px; padding: 10px; border: 1px solid #d8e3ee; border-radius: 8px; background: #fff; }
.wa-inbox-item strong, .wa-inbox-item small { display: block; }
.wa-inbox-item strong { color: #173f67; font-size: 13px; }
.wa-inbox-item small { margin-top: 2px; color: #617083; font-size: 12px; }
.wa-inbox-item p { margin: 6px 0 0; color: #26394d; font-size: 13px; white-space: pre-wrap; }
.wa-simulator-block { border-color: #b8d8c8; background: #fbfffc; }
.wa-simulator-block > summary { cursor: pointer; color: var(--text); font-size: 14px; font-weight: 600; }
.wa-simulator-block > summary small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; font-weight: 400; }
.wa-simulator-patient { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.wa-simulator-transcript { display: grid; gap: 8px; min-height: 96px; max-height: 240px; overflow: auto; margin: 12px 0; padding: 12px; border: 1px solid #d9e4dc; border-radius: 9px; background: #f2f8f4; }
.wa-simulator-message { width: fit-content; max-width: 86%; margin: 0; padding: 8px 10px; border-radius: 10px; background: #fff; color: var(--text); font-size: 13px; line-height: 1.4; box-shadow: 0 1px 2px rgba(22, 72, 42, .08); }
.wa-simulator-message.patient { justify-self: end; background: #d9fdd3; }
.wa-simulator-choices { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.wa-simulator-composer { display: flex; gap: 8px; align-items: end; }
.wa-simulator-composer input { max-width: 180px; }
@media (max-width: 640px) { .wa-simulator-patient { grid-template-columns: 1fr; } .wa-simulator-composer { align-items: stretch; flex-direction: column; } .wa-simulator-composer input { max-width: none; } }
.wa-technical-details { border: 1px solid var(--line); border-radius: 8px; }
.wa-technical-details > summary { padding: 12px 14px; cursor: pointer; color: var(--text); font-size: 13px; font-weight: 600; }
.wa-technical-details > summary small { display: block; margin: 4px 0 0 16px; color: var(--muted); font-size: 12px; font-weight: 400; }
.wa-technical-content { padding: 2px 14px 14px; }
.wa-credentials-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.wa-credentials-grid .wa-credential-token { grid-column: 1 / -1; }
.wa-credentials-grid .field small { color: var(--muted); font-size: 12px; }
.wa-credential-consents { display: grid; gap: 12px; margin: 12px 0; padding: 12px; border-radius: 8px; background: #f8fafc; }
#waCredentialsPanel .wa-consent { display: flex; align-items: flex-start; gap: 10px; margin: 0; font-size: 13px; line-height: 1.5; }
#waCredentialsPanel .wa-consent input { flex: 0 0 16px; width: 16px; height: 16px; min-height: 0; padding: 0; margin: 2px 0 0; }
#waCredentialsPanel .wa-consent span { min-width: 0; }
.wa-consent small { display: block; color: var(--muted); font-size: 12px; }
@media (max-width: 640px) {
  .wa-credentials-grid { grid-template-columns: minmax(0, 1fr); }
  .wa-block-actions > span { flex-basis: 100%; }
  [data-settings-panel="whatsapp"] .wa-block-actions .section-actions { width: 100%; }
  [data-settings-panel="whatsapp"] .wa-block-actions button { flex: 1 1 180px; }
}

.wa-options-guide {
  margin: 12px 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}
.wa-options-guide > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}
.wa-options-guide > summary::-webkit-details-marker { display: none; }
.wa-options-guide > summary small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}
.wa-options-guide > summary:hover { background: #f7faff; }
.wa-options-guide > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: -3px; }
.wa-options-chevron { font-size: 20px; color: var(--muted); transition: transform .15s; }
.wa-options-guide[open] .wa-options-chevron { transform: rotate(180deg); }
.wa-options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 16px 16px;
}
.wa-option-card { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 10px; }
.wa-option-label { display: inline-block; padding: 4px 8px; border-radius: 6px; color: #245486; background: #eef5fc; font-size: 11px; font-weight: 600; }
#whatsappOnboarding .wa-option-card h4 { margin: 10px 0 8px; color: var(--text); font-size: 15px; }
.wa-option-card p, .wa-options-handoff p { margin: 0; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.wa-option-card .wa-option-caveat { margin-top: 12px; color: var(--muted); }
.wa-option-card .wa-option-note { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); }
.wa-options-handoff { display: grid; gap: 8px; padding: 14px 16px; border-top: 1px solid var(--line); background: #f7f9fc; color: var(--muted); }
.wa-options-handoff strong { color: var(--text); }
@media (max-width: 640px) {
  .wa-options-grid { grid-template-columns: minmax(0, 1fr); padding: 0 12px 12px; }
  .wa-options-guide > summary, .wa-options-handoff { padding: 12px; }
  .wa-option-card { padding: 14px; }
}

.onboarding-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}

.manual-table-wrap {
  margin-top: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.manual-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  font-size: 13px;
}

.manual-table th,
.manual-table td {
  border-bottom: 1px solid var(--line);
  padding: 6px;
  text-align: left;
}

.manual-table th {
  background: #f8fafc;
  color: #344256;
  font-weight: 700;
}

.manual-table input,
.manual-table select {
  width: 100%;
  min-width: 90px;
  padding: 7px 8px;
}

.manual-table [data-field="patientName"] {
  min-width: 180px;
}

.manual-table [data-field="notes"] {
  min-width: 170px;
}

.manual-paste {
  min-height: 74px;
}

.compact-actions {
  justify-content: flex-start;
  margin: 10px 0 0;
}

.duration-setting,
.treatment-setting {
  display: grid;
  grid-template-columns: 1fr 110px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 9px 10px;
}

.treatment-setting {
  grid-template-columns: minmax(220px, 1fr) 170px 42px;
  gap: 8px;
  padding: 7px 9px;
}

.duration-setting span,
.treatment-setting input {
  color: #344256;
  font-size: 13px;
  font-weight: 700;
}

.duration-setting select,
.treatment-setting select {
  padding: 7px 8px;
}

.clinic-settings .field input,
.clinic-settings .field select,
.clinic-settings .field textarea {
  padding: 8px 9px;
}

.toggle-setting {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 10px;
  margin: 4px 0 14px;
}

.toggle-setting input {
  margin-top: 2px;
}

.toggle-setting strong,
.toggle-setting small {
  display: block;
}

.toggle-setting small {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.doctor-settings-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 12px;
  grid-column: 1 / -1;
  margin-bottom: 18px;
}

/* These onboarding defaults are managed centrally for now. */
.onboarding-in-basic .onboarding-grid .field:nth-child(n+4) { display: none; }

.doctor-setting-row {
  position: relative;
  min-width: 0;
  margin: 0;
}

.doctor-setting-row input {
  width: 100%;
  padding-right: 44px;
}

.doctor-setting-row .remove-doctor-setting {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 30px;
  height: 30px;
  border: 0;
  background: #f1f5f9;
  color: #64748b;
  font-size: 20px;
  line-height: 1;
}

.doctor-setting-row .remove-doctor-setting:hover {
  background: #fee2e2;
  color: #b91c1c;
}

.add-doctor-setting {
  grid-column: 1 / -1;
  justify-self: start;
  min-width: 190px;
}

.dialog-actions {
  justify-content: space-between;
  margin-top: 18px;
}

/* El aviso de sesión mantiene siempre la misma escala compacta que el login. */
.dialog.session-expiry-dialog { width: min(380px, calc(100vw - 32px)); max-width: min(380px, calc(100vw - 32px)); }
.session-expiry-dialog form { padding: 14px; }
.session-expiry-dialog .dialog-header h2 { font-size: 16px; line-height: 1.25; }
.session-expiry-dialog .dialog-actions { justify-content: flex-end; gap: 6px; margin-top: 14px; }

.patient-appointments {
  display: grid;
  gap: 8px;
}

.patient-appointment-group {
  display: grid;
  gap: 6px;
  padding: 9px;
  border: 1px solid #dce5ef;
  border-radius: 9px;
  background: #fff;
}

.patient-appointment-group.is-next { border-color: #a8c9ed; background: #f7fbff; }
.patient-appointment-group.is-upcoming { background: #fbfdff; }
.patient-appointment-group.is-history { background: #fafbfc; }
.patient-appointment-group.patient-followups { border-color: #efd9a7; background: #fffdf7; }
.patient-appointment-group.patient-followups h3 { color: #865c0a; }

.patient-appointment-group h3 {
  margin: 0;
  color: #344256;
  font-size: 12px;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.patient-appointment {
  display: grid;
  gap: 2px;
  width: 100%;
  border: 1px solid #d3deea;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  padding: 8px 9px;
  text-align: left;
}

.patient-appointment:hover { border-color: #a9c5e5; background: #f8fbff; }
.patient-appointment-date { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.patient-appointment-date strong { font-size: 13px; line-height: 1.25; }
.patient-appointment-date b { color: #24527c; font-size: 12px; white-space: nowrap; }

.patient-dialog .dialog-header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding-bottom: 8px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.patient-dialog .dialog-header .icon-btn {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: #44566c;
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
}

.patient-history-details {
  border: 1px solid #d7e2ed;
  border-radius: 9px;
  background: #f8fafc;
  overflow: hidden;
}

.patient-history-details.is-attached {
  margin: 0 -9px -9px;
  border: 0;
  border-top: 1px solid #d7e2ed;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

.patient-history-details summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
  padding: 9px 10px;
  color: #24527c;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  list-style: none;
}

.patient-history-details summary::-webkit-details-marker { display: none; }
.patient-history-details:not(.is-attached) summary { display: flex; align-items: center; gap: 8px; }
.patient-history-details:not(.is-attached) summary > .patient-history-summary-more { display: inline; }
.patient-history-details:not(.is-attached) summary > .patient-history-summary-less { display: none; }
.patient-history-details:not(.is-attached)[open] summary > .patient-history-summary-more { display: none; }
.patient-history-details:not(.is-attached)[open] summary > .patient-history-summary-less { display: inline; }
.patient-history-details:not(.is-attached) summary > small { margin-left: auto; }
.patient-history-details.is-attached summary { display: flex; align-items: center; gap: 8px; padding: 8px 9px; border: 0; background: transparent; color: #24527c; font-size: 12px; }
.patient-history-details summary::before { content: "›"; display: inline-flex; flex: 0 0 8px; width: 8px; height: 12px; align-items: center; justify-content: center; color: #6a89a7; font-family: inherit; font-size: 14px; font-weight: 400; line-height: 12px; }
.patient-history-details[open] summary::before { content: "⌄"; }
.patient-history-details.is-attached summary::before { display: inline-flex; }
.patient-history-details summary > span { grid-column: 2; grid-row: 1; justify-self: start; }
.patient-history-summary-less { display: none; }
.patient-history-details[open] .patient-history-summary-more,
.patient-followup-history[open] .patient-history-summary-more { display: none; }
.patient-history-details[open] .patient-history-summary-less,
.patient-followup-history[open] .patient-history-summary-less { display: inline; }
.patient-history-details summary > small { grid-column: 2 / -1; grid-row: 2; color: var(--muted); font-size: 10px; font-weight: 600; }
.patient-history-details.is-attached:not([open]) summary .patient-history-summary-more { display: inline; }
.patient-history-details.is-attached:not([open]) summary .patient-history-summary-less { display: none; }
.patient-history-details.is-attached[open] summary .patient-history-summary-more { display: none; }
.patient-history-details.is-attached[open] summary .patient-history-summary-less { display: inline; }
.patient-history-details.is-attached summary > small { margin-left: auto; }
.patient-history-details > .patient-appointment-group { margin: 0 8px 8px; }

.patient-history-details .patient-appointment-group { margin-top: 0; }

.patient-followup-history summary { display: flex; align-items: center; gap: 8px; padding: 8px 0; list-style: none; }
.patient-followup-history summary::-webkit-details-marker { display: none; }
.patient-followup-history summary::before { content: "›"; display: inline-flex; flex: 0 0 8px; width: 8px; height: 12px; align-items: center; justify-content: center; color: #6a89a7; font-family: inherit; font-size: 14px; font-weight: 400; line-height: 12px; transform: none; transition: transform .15s ease; }
.patient-followup-history[open] summary::before { content: "⌄"; transform: none; }
.patient-followup-history summary .patient-history-summary-more,
.patient-followup-history summary .patient-history-summary-less { color: #526b85; font: inherit; font-size: 12px; font-weight: 700; }

.patient-appointment span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.patient-appointment .patient-appointment-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 7px; }
.patient-appointment-meta > span { color: #5c7188; }
.patient-appointment-meta > span + span { padding-left: 7px; border-left: 1px solid #dbe4ee; }
.patient-appointment-meta em { padding: 2px 6px; border-radius: 999px; background: #eef2f6; color: #526274; font-size: 10px; font-style: normal; font-weight: 800; }
.patient-appointment-meta em[data-status="confirmed"] { background: #e9f8ee; color: #18723a; }
.patient-appointment-meta em[data-status="pending"] { background: #fff5d9; color: #8a5a00; }
.patient-appointment-meta em[data-status="no_response"] { background: #f1edff; color: #5b3ca1; }
.patient-appointment-meta em[data-status="cancelled"] { background: #fff0f0; color: #a12929; }

.patient-appointment small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.patient-appointment:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 1px;
}

.patient-followup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border: 1px solid #efd9a7;
  border-left: 3px solid #e4ad45;
  border-radius: 7px;
  background: #fff;
}

.patient-followup small { color: var(--muted); }

.patient-followup-summary {
  display: grid;
  min-width: 0;
  gap: 2px;
  cursor: pointer;
}

.patient-followup-summary.inbox-followup-open {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

.patient-followup-summary:focus-visible { outline: 2px solid #1768d2; outline-offset: 2px; border-radius: 3px; }

.patient-followup-summary strong { font-size: 12px; line-height: 1.25; }

.patient-followup-date { display: flex; align-items: center; gap: 7px; min-width: 0; }
.patient-followup-date > span { color: #2f6798; font-size: 10px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; }

.patient-followup-summary span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.patient-followup-summary .patient-followup-note { color: #5c7188; font-size: 12px; }

.patient-followup-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }

.patient-followup-actions button {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: #24527c;
  padding: 4px 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.patient-followup.completed {
  border-color: #b8dec5;
  background: #f4fcf6;
}

.patient-followup.completed .patient-followup-summary {
  opacity: .58;
  text-decoration: line-through;
}

.patient-followup-actions button.done {
  border-color: #98c9a8;
  background: #e9f8ee;
  color: #18723a;
}

.patient-followup-actions button:disabled { cursor: default; }

.patient-followup-list,
.patient-followup-overflow {
  display: grid;
  gap: 8px;
}

.patient-followup-expand {
  margin: 6px 0;
  border: 0;
  background: transparent;
  color: #24527c;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 0;
}
.patient-followup-expand::before {
  content: "›";
  display: inline-block;
  width: 10px;
  color: #6a89a7;
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
}
.patient-followups.is-expanded .patient-followup-expand::before { content: "⌄"; }

.patient-followup-overflow { display: none; }
.patient-followups.is-expanded .patient-followup-overflow { display: grid; }

.patient-followup-history {
  margin-top: 1px;
  padding: 0;
  border-top: 1px solid #dce9f7;
}

.patient-followup-history summary {
  color: #526b85;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.patient-followup-history .patient-followup-list { margin-top: 7px; }

.patient-dialog .dialog-actions {
  position: sticky;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  justify-content: space-between;
  bottom: 0;
  z-index: 2;
  margin: 12px -14px -14px;
  padding: 9px 14px;
  background: #fff;
  border-top: 1px solid var(--line);
}

.patient-dialog .dialog-actions .danger-secondary { flex: 0 0 auto; white-space: nowrap; }
.patient-footer-actions { justify-content: flex-end; min-width: 0; }

.patient-form-dialog .dialog-actions-right { gap: 6px; }

/* El seguimiento mantiene la misma escala compacta del resto de acciones. */
#followUpDialog form { padding: 14px; }
#followUpDialog .dialog-header { margin-bottom: 12px; }
#followUpDialog .dialog-header h2 { margin: 0; font-size: 16px; line-height: 1.25; }
#followUpDialog .dialog-subtitle { margin-top: 4px; font-size: 13px; line-height: 1.3; }
#followUpDialog .field > span { font-size: 12px; }
#followUpDialog input,
#followUpDialog textarea { font-size: 13px; line-height: 1.25; }
#followUpDialog .dialog-actions { margin-top: 12px; }
#followUpDialog .dialog-actions-right { gap: 6px; }
#followUpDialog .dialog-actions .btn {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

@media (max-width: 560px) {
  .patient-form-grid { grid-template-columns: 1fr; }
  .patient-name-field,
  .patient-email-field,
  .patient-address-field { grid-column: auto; }
  .patient-followup { grid-template-columns: 1fr; }
  .patient-followup-actions { justify-content: flex-start; }
  .patient-dialog .dialog-actions { align-items: center; flex-wrap: nowrap; gap: 4px; }
  .patient-dialog .dialog-actions .btn { min-height: 30px; padding: 5px 6px; font-size: 11px; }
  .patient-header-actions { gap: 4px; }
  .patient-header-actions .btn { min-height: 30px; padding: 5px 6px; font-size: 11px; }
  .patient-footer-actions { gap: 4px; }
}

.follow-up-quick-dates {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.follow-up-quick-dates button {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: #24527c;
  padding: 4px 7px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.follow-up-quick-dates button.is-selected {
  border-color: #8bb8e8;
  background: #eaf3ff;
  color: #174f86;
  box-shadow: inset 0 0 0 1px rgba(23, 105, 224, .14);
}

.follow-up-non-working-notice {
  display: grid;
  gap: 7px;
  margin: -4px 0 10px;
  padding: 10px 12px;
  border: 1px solid #f0d39a;
  border-radius: 8px;
  background: #fff9eb;
  color: #76520a;
  font-size: 13px;
  line-height: 1.4;
}

.follow-up-non-working-notice[hidden] { display: none; }
.follow-up-non-working-notice button { justify-self: start; }

@media (max-width: 900px) {
  .topbar,
  .toolbar,
  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .layout {
    display: flex;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .content {
    order: -1;
  }

  .sidebar {
    order: 2;
  }

  .topbar-actions,
  .demo-nav,
  .dialog-actions-right {
    flex-wrap: wrap;
  }

  .settings-page {
    padding: 14px;
  }

  .settings-page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-layout {
    display: flex;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .settings-tabs {
    position: relative;
    top: auto;
    z-index: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 4px;
    box-shadow: none;
  }

  .settings-panels,
  .settings-card {
    min-height: 0;
    width: 100%;
  }

  .support-admin-grid,
  .support-summary-grid,
  .support-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .dialog.session-expiry-dialog { width: calc(100vw - 32px); max-width: calc(100vw - 32px); }
  .session-expiry-dialog .dialog-actions { flex-direction: column-reverse; }
  .session-expiry-dialog .dialog-actions .btn { width: 100%; }
}

@media (max-width: 560px) {
  .layout {
    padding: 10px;
  }

  .topbar {
    gap: 10px;
    padding: 14px;
  }

.topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .topbar-actions .api-status {
    grid-column: 1 / -1;
    white-space: normal;
  }

  .topbar-actions .btn {
    padding: 7px 9px;
    font-size: 12px;
  }

  .form-grid,
  .doctor-settings-list,
  .appointments-grid,
  .duration-settings,
  .support-admin-grid,
  .support-summary-grid,
  .support-status-grid,
  .onboarding-grid {
    grid-template-columns: 1fr;
  }

  .settings-tabs {
    grid-template-columns: 1fr;
  }

  .settings-card {
    padding: 16px;
  }

  .duration-setting {
    grid-template-columns: 1fr;
  }

  .treatment-list-head,
  .treatment-setting,
  .public-booking-list-head,
  .public-booking-setting {
    grid-template-columns: 1fr;
  }

  .card-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
/* Daily view is the reception workbench: keep each appointment dense on laptops
   while preserving the full card layout on tablets and mobiles. */
@media (min-width: 901px) {
  .appointments-grid.day-view .day-column-body {
    gap: 4px;
    padding: 6px;
  }

  .appointments-grid.day-view .appointment-card {
    align-items: center;
    display: flex;
    gap: 8px;
    min-height: 55px;
    padding: 4px 7px;
  }

  .appointments-grid.day-view .appointment-main {
    display: grid;
    flex: 1 1 auto;
    grid-template-columns: 48px minmax(0, 1fr);
    min-width: 0;
  }

  .appointments-grid.day-view .time {
    min-height: 38px;
    padding: 4px 3px;
  }

  .appointments-grid.day-view .appointment-main > div:last-child {
    min-width: 0;
  }

  .appointments-grid.day-view .appointment-card h3 {
    margin: 0 0 1px;
  }

  .appointments-grid.day-view .notes,
  .appointments-grid.day-view .next-action {
    display: none;
  }

  .appointments-grid.day-view .appointment-card .card-actions {
    align-self: center;
    flex: 0 0 auto;
    margin: 0;
  }

  .appointments-grid.day-view .appointment-card .status-select {
    width: 116px;
    max-width: 116px;
    padding: 5px 6px;
  }

  .appointments-grid.day-view .appointment-card .meta span:first-child {
    max-width: 80px;
  }

  .appointments-grid.day-view .appointment-card .meta span:nth-child(2) {
    max-width: 64px;
  }

  .appointments-grid.day-view .appointment-card .meta span:nth-child(3) {
    max-width: 74px;
  }
}
select#appointmentTime option.occupied-time { color: #777; background: #e5e7eb; }
select#appointmentTime.occupied-time-selected,
select#appointmentTime.occupied-time-selected:focus { color: #6b7280 !important; background-color: #e5e7eb !important; border-color: #b8c0ca !important; box-shadow: none !important; }

/* La demo pública comparte la distribución móvil de la agenda oficial.
   El encabezado comercial se mantiene, pero las tarjetas y sus acciones
   deben conservar el mismo tamaño y posición en ambos modos. */
@media (max-width: 900px) {
  body.showcase-demo .appointments-grid.day-view .appointment-card {
    min-height: 0;
    padding: 7px;
  }

  body.showcase-demo .appointments-grid.day-view .notes,
  body.showcase-demo .appointments-grid.day-view .next-action {
    display: none;
  }

  body.showcase-demo .appointments-grid.day-view .card-actions {
    flex-direction: row;
    align-items: center;
    gap: 6px;
  }

  body.showcase-demo .appointments-grid.day-view .status-select {
    width: 118px;
    max-width: 118px;
    min-height: 32px;
  }

  body.showcase-demo .appointments-grid.day-view .change-preference-badge {
    display: none;
  }

  body.showcase-demo .appointments-grid.day-view .daily-note-heading {
    display: none;
  }

  body.showcase-demo .appointments-grid.day-view .whatsapp-btn {
    width: auto;
    min-width: 42px;
    min-height: 42px;
    flex: 0 0 42px;
  }

  body.showcase-demo .appointments-grid.day-view .day-column-body {
    padding: 7px;
    gap: 6px;
  }
}
.settings-basic-block { border: 1px solid #dbe4ef; border-radius: 10px; padding: 11px 12px; margin: 0 0 10px; background: #fbfdff; box-shadow: 0 2px 8px rgba(32, 74, 125, .04); }
.settings-general-block { background: #f8fbff; }
.settings-general-block > legend { grid-column: 1 / -1; font-weight: 700; }
.settings-basic-block .settings-subtitle { margin-top: 0; }
.settings-general-block { display: grid; grid-template-columns: 1fr; gap: 7px 16px; align-items: start; }
.settings-general-block > .settings-subtitle, .settings-general-block > .field, .settings-general-block > #settingsDoctorsList { grid-column: 1; }
.settings-general-block > .field { max-width: 560px; }
.settings-general-block #settingsDoctorsList { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px 12px; align-items: end; }
.settings-general-block #settingsDoctorsList .add-doctor-setting { width: fit-content; }
.schedule-setting { display: block; background: #fcfcfa; }
.schedule-setting legend { font-weight: 700; margin-bottom: 7px; }
.schedule-setting .settings-inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.schedule-setting input { max-width: 100%; }
.schedule-mode-choice { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.schedule-mode-choice label { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: #344256; font-size: 12px; font-weight: 700; cursor: pointer; }
.schedule-mode-choice input { width: auto; min-height: 0; accent-color: var(--primary); }
.schedule-setting .settings-calendar-toggle { display: grid; gap: 4px; }
.schedule-setting .settings-calendar-toggle > span { display: flex; align-items: center; gap: 6px; }
.schedule-setting .settings-calendar-toggle input[type="checkbox"] { width: 16px !important; min-width: 16px !important; height: 16px !important; min-height: 16px !important; padding: 0 !important; margin: 0; accent-color: var(--primary); }
.cancelled-appointments-setting { background: #fcfcfa; }
.cancelled-appointments-toggle { display: inline-flex; align-items: center; gap: 7px; margin: 0; color: #344256; font-size: 12px; font-weight: 700; cursor: pointer; }
.cancelled-appointments-toggle input[type="checkbox"] { width: 16px !important; min-width: 16px !important; height: 16px !important; min-height: 16px !important; padding: 0 !important; margin: 0; accent-color: var(--primary); flex: 0 0 16px; }
.cancelled-appointments-help { display: block; margin-top: 5px; color: #64748b; font-size: 11px; line-height: 1.35; }
.overlap-mode-setting { border: 1px solid #dbe4ef; display: grid; gap: .55rem; background: #fafbff; }
.overlap-mode-setting { grid-template-columns: repeat(3, minmax(0, 1fr)); }


.doctor-column.doctor-1 .day-column-header { background: #faf8ff; }
.doctor-column.doctor-2 .day-column-header { background: #fffaf8; }
.column-appointment-total { display: inline-flex; align-items: center; gap: 5px; }
.column-appointment-total .doctor-count { width: 22px; height: 22px; font-size: 11px; }
.appointments-grid.day-view .appointment-card { border-top-color: #e5eaf0; border-right-color: #e5eaf0; border-bottom-color: #e5eaf0; }

.doctor-column.doctor-1 { border-top-color: #b9a9df; }
.doctor-column.doctor-2 { border-top-color: #d9b6a8; }

.official-app .topbar {
  padding: 8px 18px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.official-app .topbar > .toolbar {
  position: absolute;
  top: 50%;
  left: 50%;
  width: max-content;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  transform: translate(-50%, -50%);
  z-index: 1;
}

.official-app.settings-view .agenda-toolbar { display: none; }
.official-app .topbar > .toolbar h2 { color: #183b66; }
.official-app .topbar > .toolbar .view-switch button,
.official-app .topbar > .toolbar .segmented button { min-height: 30px; padding: 4px 8px; }

@media (max-width: 1100px) {
  .official-app .topbar > .toolbar { position: static; transform: none; margin-left: auto; }
}

.official-app .topbar-actions { gap: 8px; }
.official-app .api-status { font-size: 12px; font-weight: 600; }
.official-app .topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  min-width: 0;
}
.official-app .topbar-title #clinicEyebrow { display: none; }
.official-app .api-status { display: none; }
.official-app.authenticated .api-status.connected {
  display: inline-flex;
  position: static;
  width: 9px;
  height: 9px;
  margin-left: 7px;
  vertical-align: middle;
  border-radius: 50%;
  background: var(--ok);
  font-size: 0;
  box-shadow: 0 0 0 2px #fff;
}
.official-app.authenticated .topbar-title .api-status.connected {
  position: static;
  flex: 0 0 9px;
  margin-left: -5px;
  transform: translateY(-3px);
}
.official-app .topbar-title h1 {
  display: block;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 1101px) {
  /* Reserve the space occupied by the centred agenda controls. Long business
     names stay inside the title area without moving the existing toolbar. */
  .official-app:not(.settings-view) .topbar-title { max-width: calc(50% - 400px); }
}

.official-app #logoutBtn { border-color: transparent; background: transparent; color: #64748b; padding-left: 4px; padding-right: 4px; }
.official-app #logoutBtn { margin-left: 8px; opacity: .72; font-weight: 600; }
.official-app #logoutBtn { border-color: #efb5b5; background: #fff8f8; color: #b42318; padding: 6px 9px; opacity: 1; }
.official-app #logoutBtn:hover { border-color: #dc8d8d; background: #fff0f0; color: #991b1b; }
.official-app #logoutBtn.icon-logout { width: 34px; height: 34px; padding: 7px; }
.official-app #logoutBtn.icon-logout svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.official-app #loginBtn { border-color: #1769e0; background: #1769e0; color: #fff; font-weight: 700; }
.official-app #loginBtn:hover { background: #1258bd; border-color: #1258bd; }
.official-app .topbar-actions #newAppointmentBtn { order: 1; }
.official-app .topbar-actions #settingsBtn { order: 2; }
.official-app .topbar-actions #logoutBtn,
.official-app .topbar-actions #loginBtn { order: 3; }
.official-app .topbar-actions #settingsBtn { min-width: 96px; }
.official-app .topbar-actions #settingsBtn.icon-settings { width: 36px; min-width: 36px; height: 36px; padding: 8px; border: 1px solid #d8e0e8; border-radius: 8px; background: #fff; color: #344054; box-shadow: none; }
.official-app .topbar-actions #settingsBtn.icon-settings,
.official-app .topbar-actions #logoutBtn.icon-logout { border-color: transparent; background: transparent; box-shadow: none; }
.official-app .topbar-actions #settingsBtn.icon-settings:hover,
.official-app .topbar-actions #logoutBtn.icon-logout:hover { border-color: transparent; background: #f5f7fa; }
.official-app .topbar-actions #settingsBtn.icon-settings { border-color: #d8e0e8; background: #fff; }
.official-app .topbar-actions #settingsBtn.icon-settings:hover { border-color: #b9c4d0; background: #f5f7fa; }
.official-app .topbar-actions #logoutBtn.icon-logout { border-color: #efb5b5; background: #fff8f8; }
.official-app .topbar-actions #logoutBtn.icon-logout:hover { border-color: #dc8d8d; background: #fff0f0; }
.official-app.settings-view .topbar-actions #settingsBtn:not(.icon-settings) { min-width: 96px; padding: 6px 10px; }
.official-app #settingsBtn.icon-settings svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.official-app #settingsBtn.icon-settings { font-family: "Segoe UI Symbol", "Noto Sans Symbols", sans-serif; font-size: 19px; line-height: 1; }
.official-app.settings-view .topbar-actions #settingsBtn {
  border-color: #cbd8e6;
  background: #fff;
  color: #344256;
  font-weight: 600;
}
.official-app.settings-view .topbar-actions #newAppointmentBtn { display: inline-flex; }
.official-app.settings-view .agenda-toolbar { display: none; }
.official-app.settings-view .settings-page-header { display: flex; }
.official-app:not(.settings-view) .topbar-actions #settingsBtn {
  background: #fff;
  color: #344256;
}
.official-app.settings-view .topbar-actions #settingsBtn.icon-settings { border-color: #cbd8e6; background: #fff; color: #344256; }
.official-app .layout { padding-top: 10px; }
.official-app.settings-view .settings-page { padding-top: 10px; }
.official-app .toolbar { margin-bottom: 7px; padding: 7px 10px; }
.official-app .toolbar { min-height: 66px; padding: 10px 18px; border-color: #dbe4ee; background: #f7faff; box-shadow: none; }
.official-app .toolbar h2 { margin: 0; font-size: 19px; }
.official-app .toolbar #agendaSubtitle { margin: 2px 0 0; font-size: 13px; color: #64748b; }
.official-app .toolbar .toolbar-tool-btn {
  background: #fff;
  border-color: #cbd8e6;
  color: #526274;
  box-shadow: none;
  font-weight: 600;
}
.official-app .toolbar #todayBtn { background: #e5f0ff; color: #1f5f9c; border-color: #c7ddf6; }
.official-app .toolbar .toolbar-tool-btn:hover { background: #f8fafc; border-color: #aebfd1; }
.official-app .toolbar #printDayBtn { margin-left: 34px; }
.official-app .mobile-follow-up-btn { display: none; }
.official-app .mobile-patients-btn { display: none; }
.official-app .mobile-follow-up-btn b { min-width: 22px; padding: 2px 6px; border-radius: 999px; background: #e8f3f1; color: #426a68; text-align: center; }
.official-app .mobile-follow-up-btn.has-review-items b { background: #fff0d1; color: #7a5100; }
.official-app .agenda-toolbar {
  margin: 0;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
}
.official-app .workday-panel { display: block; }
.official-app .sidebar .field:has(#viewMode) { display: none; }
.appointment-filters { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.appointment-filters summary { cursor: pointer; color: #344256; font-size: 13px; font-weight: 700; margin-bottom: 10px; }
.appointment-filters[open] summary { margin-bottom: 10px; }

@media (min-width: 901px) {
  .official-app .toolbar > div:first-child { display: block; }
  .official-app .toolbar > div:first-child h2,
  .official-app .toolbar > div:first-child #agendaSubtitle { margin: 0; }
}

/* En escritorio separamos los grupos de control para que la cabecera respire
   sin aumentar innecesariamente la altura de la agenda. */
@media (min-width: 1101px) {
  .official-app .topbar > .toolbar { column-gap: 18px; }
  .official-app .topbar > .toolbar > div:first-child { margin-right: 12px; }
  .official-app .topbar > .toolbar .view-switch { margin-right: 8px; }
  .official-app .topbar > .toolbar .segmented { margin-left: 4px; margin-right: 8px; }
  .official-app .layout { padding-top: 16px; }
}

.appointments-grid.day-view .appointment-card {
  min-height: 0;
  padding: 6px 8px;
}

#reminderDialog .field { margin-bottom: 8px; gap: 4px; }
#reminderDialog textarea { min-height: 60px; height: 60px; }
#reminderDialog .dialog-actions { margin-top: 4px; }
.overlap-mode-setting legend { grid-column: 1 / -1; font-weight: 700; margin-bottom: .15rem; }

/* Filtros compactos del lateral; los formularios de las modales conservan su tamaño. */
.sidebar .field {
  gap: 4px;
  margin-bottom: 8px;
}

.sidebar .field > span {
  font-size: 12px;
}

.sidebar #selectedDate,
.sidebar #viewMode,
.sidebar #statusFilter,
.sidebar #typeFilter,
.sidebar #appointmentSearch,
.sidebar #patientSearch {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 13px;
}

/* Configuracion compacta, alineada con los filtros y las modales. */
.clinic-settings .field {
  gap: 4px;
  margin-bottom: 8px;
}

.clinic-settings .field > span,
.clinic-settings .settings-subtitle {
  font-size: 12px;
}

.clinic-settings .field input,
.clinic-settings .field select,
.clinic-settings .field textarea,
.clinic-settings .doctor-setting-row input {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 13px;
}

.clinic-settings .settings-basic-block {
  padding: 9px 10px;
  margin-bottom: 8px;
}

.clinic-settings .settings-general-block {
  gap: 5px 12px;
}

.clinic-settings .settings-general-block #settingsDoctorsList {
  gap: 6px 10px;
}

.clinic-settings .doctor-setting-row .remove-doctor-setting {
  right: 6px;
  bottom: 5px;
  width: 26px;
  height: 26px;
  font-size: 17px;
}

.clinic-settings .add-doctor-setting {
  min-width: 170px;
  padding: 7px 10px;
  font-size: 13px;
}

.clinic-settings .schedule-setting .settings-inline-fields {
  gap: 10px;
}

.clinic-settings .schedule-setting legend {
  margin-bottom: 5px;
}

.clinic-settings .overlap-mode-setting {
  gap: .4rem;
}

.clinic-settings .overlap-mode-setting > label {
  gap: .5rem;
  padding: .45rem .55rem;
}

.clinic-settings .overlap-mode-setting label span {
  font-size: 13px;
}

.clinic-settings .overlap-mode-setting small {
  font-size: 11px;
}

.clinic-settings .section-actions .btn {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
}

/* Todas las secciones de configuracion comparten la misma escala visual. */
.settings-tabs {
  gap: 6px;
  padding: 9px;
}

.settings-tab {
  gap: 2px;
  padding: 8px 10px;
}

.settings-tab strong {
  font-size: 13px;
}

.settings-tab span {
  font-size: 11px;
}

.official-settings .field,
.settings-section .field {
  gap: 4px;
  margin-bottom: 8px;
}

.official-settings .field > span,
.settings-section .field > span {
  font-size: 12px;
}

.official-settings input:not([type="radio"]):not([type="checkbox"]),
.official-settings select,
.official-settings textarea,
.settings-section input:not([type="radio"]):not([type="checkbox"]),
.settings-section select,
.settings-section textarea {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 13px;
}

.settings-section textarea {
  min-height: 64px;
}

.settings-section .section-actions .btn {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
}

/* Importacion de citas con la misma escala compacta que el resto de configuracion. */
.official-settings[data-settings-panel="manual"] {
  padding: 16px;
}

.official-settings[data-settings-panel="manual"] h3 {
  font-size: 17px;
  padding-bottom: 9px;
  margin-bottom: 10px;
}

.official-settings[data-settings-panel="manual"] .dialog-subtitle,
.official-settings[data-settings-panel="manual"] .settings-help {
  font-size: 12px;
}

.official-settings[data-settings-panel="manual"] .excel-template {
  padding: 8px 9px;
  margin: 8px 0;
  font-size: 12px;
}

.official-settings[data-settings-panel="manual"] .manual-paste {
  min-height: 60px;
  height: 60px;
  padding: 7px 8px;
  font-size: 13px;
}

.official-settings[data-settings-panel="manual"] .compact-actions,
.official-settings[data-settings-panel="manual"] .dialog-actions {
  gap: 7px;
  margin-top: 8px;
}

.official-settings[data-settings-panel="manual"] .btn {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 12px;
}

.official-settings[data-settings-panel="manual"] .manual-table th,
.official-settings[data-settings-panel="manual"] .manual-table td {
  padding: 4px;
}

.official-settings[data-settings-panel="manual"] .manual-table input,
.official-settings[data-settings-panel="manual"] .manual-table select {
  min-height: 32px;
  padding: 5px 6px;
  font-size: 12px;
}

/* En movil la agenda es la pantalla principal; la configuracion y los filtros quedan fuera del flujo. */
@media (max-width: 900px) {
  /* El punto de sesión queda dentro del nombre de la clínica también en móvil. */
  .official-app.authenticated .topbar-title .api-status.connected {
    display: inline-flex;
    position: static;
    flex: 0 0 9px;
    margin-left: -5px;
    transform: translateY(-3px);
  }
  .official-app .topbar-title #clinicEyebrow,
  .official-app .topbar-title #clinicEyebrow {
    display: none;
  }

  .official-app .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 10px;
    align-items: center;
    padding: 10px 12px;
  }

  .official-app .topbar-title h1 { font-size: 25px; }
  .official-app .topbar-title .eyebrow { font-size: 12px; }
  .official-app .topbar-actions {
    display: flex;
    width: auto;
    justify-content: flex-end;
    gap: 5px;
  }
  .official-app .topbar-actions .api-status { display: none; }
  .official-app .topbar-actions #logoutBtn { display: none; }
  .official-app .topbar-actions .btn { padding: 6px 8px; font-size: 12px; }

  .official-app .topbar > .toolbar {
    position: static;
    grid-column: 1 / -1;
    display: flex;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    transform: none;
    margin: 2px 0 0;
  }
  .official-app .topbar > .toolbar > div:first-child { flex: 1 0 100%; }
  .official-app .topbar > .toolbar .segmented,
  .official-app .topbar > .toolbar .view-switch { flex: 1 1 auto; }
  .official-app .topbar > .toolbar .toolbar-tool-btn { display: none; }
  .official-app .topbar > .toolbar .mobile-follow-up-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; width: 100%; min-height: 42px; }
  .official-app .topbar > .toolbar .mobile-patients-btn { display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 42px; }
  .official-app .topbar > .toolbar .view-switch { display: none; }

  .official-app .layout { display: block; padding: 8px; }
  .official-app .sidebar { display: block; }
  .official-app .sidebar > .workday-panel,
  .official-app .sidebar > section:not(:has(#selectedDate)) { display: none; }
  .official-app .sidebar > section:has(#selectedDate) {
    display: block;
    margin: 0 0 8px;
    padding: 8px;
  }
  .official-app .sidebar > section:has(#selectedDate) > * { display: none; }
  .official-app .sidebar > section:has(#selectedDate) > label:has(#selectedDate) { display: grid; margin: 0; }
  .official-app .sidebar > section:has(#selectedDate) > label:has(#selectedDate) > span { font-size: 12px; }
  .official-app .sidebar > section:has(#selectedDate) > label:has(#selectedDate) > input { min-height: 34px; padding: 6px 8px; font-size: 13px; }
  .official-app.mobile-patients-open .content,
  .official-app.mobile-patients-open .sidebar > section:has(#selectedDate) { display: none; }
  .official-app.mobile-patients-open .sidebar > #patientsPanel { display: block; margin: 0 0 8px; }
  .official-app.mobile-patients-open .mobile-patients-heading button { display: inline-flex; min-height: 36px; margin-bottom: 10px; }
  .official-app .content { width: 100%; }
  .official-app .appointments-grid { grid-template-columns: 1fr; gap: 8px; }
  .official-app .doctor-column { min-width: 0; }
  .official-app .appointments-grid.day-view {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .official-app .appointments-grid.day-view .doctor-column {
    display: block;
    width: 100%;
    border-top-width: 4px;
    border-radius: 8px;
    overflow: hidden;
  }
  .official-app .appointments-grid.day-view .doctor-column + .doctor-column {
    margin-top: 2px;
  }
  .official-app .day-column-header { padding: 8px 10px; }
  .official-app .day-column-body { padding: 7px; gap: 6px; }

  .official-app .appointments-grid.day-view .appointment-card {
    min-height: 0;
    padding: 7px;
  }
  .official-app .appointments-grid.day-view .notes,
  .official-app .appointments-grid.day-view .next-action { display: none; }
  .official-app .appointments-grid.day-view .card-actions {
    flex-direction: row;
    align-items: center;
    gap: 6px;
  }
  .official-app .appointments-grid.day-view .status-select {
    width: 118px;
    max-width: 118px;
    min-height: 32px;
  }
}

@media (max-width: 900px) {
  .appointment-dialog .appointment-source-field { display: none; }

  .official-app .agenda-toolbar {
    display: flex;
    align-items: stretch;
    flex-direction: column;
  }
  .official-app .agenda-toolbar .view-switch,
  .official-app .agenda-toolbar .segmented {
    display: flex;
    width: 100%;
  }
  .official-app .agenda-toolbar .view-switch button,
  .official-app .agenda-toolbar .segmented button { flex: 1 1 0; }
}

@media (max-width: 560px) {
  .official-app .topbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }

  .official-app .topbar-title h1 { font-size: 24px; line-height: 1.12; }
  .official-app .topbar-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 7px;
  }
  .official-app .topbar-actions .api-status { flex: 1 0 100%; }
  .official-app .topbar-actions .api-status { display: none; }
  .official-app .topbar-actions .btn { min-height: 34px; }

  .official-app .topbar > .toolbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 3px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }
  .official-app .topbar > .toolbar > div:first-child { display: block; }
  .official-app .topbar > .toolbar h2 { font-size: 17px; line-height: 1.2; }
  .official-app .topbar > .toolbar #agendaSubtitle { display: block; margin-top: 2px; }
  .official-app .topbar > .toolbar .view-switch,
  .official-app .topbar > .toolbar .segmented { width: 100%; justify-content: stretch; }
  .official-app .topbar > .toolbar .view-switch button,
  .official-app .topbar > .toolbar .segmented button { flex: 1 1 0; }
}

@media (max-width: 900px) {
  .dialog,
  .dialog.small-dialog,
  .dialog.wide-dialog,
  .appointment-dialog {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 12px;
  }

  .appointment-dialog {
    height: calc(100dvh - 16px);
  }

  .official-app .daily-note-heading,
  .official-app .change-preference-badge {
    display: none !important;
  }

  .dialog form,
  .dialog-body,
  .appointment-dialog form {
    padding: 9px;
  }

  .appointment-dialog .dialog-header {
    padding: 0 0 7px;
  }

  .appointment-dialog .dialog-header h2,
  .dialog-header h2 { font-size: 16px; }

  .appointment-dialog-content {
    gap: 6px;
    padding-right: 2px;
  }

  .appointment-section {
    padding: 7px;
    border-radius: 8px;
  }

  .appointment-form-grid,
  .patient-fields-grid,
  .appointment-details-grid,
  .appointment-details-lower,
  .appointment-communication-layout,
  .appointment-date-time-row,
  .patient-contact-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .appointment-details-right { padding-left: 0; border-left: 0; }
  .appointment-notes-field textarea { min-height: 76px; height: 76px; }

  .appointment-dialog .field,
  .appointment-dialog .field input,
  .appointment-dialog .field select,
  .appointment-dialog .field textarea {
    width: 100%;
  }

  .appointment-dialog input,
  .appointment-dialog select,
  .appointment-dialog textarea {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 13px;
  }

  .appointment-dialog .checkbox-field {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
    margin: 6px 0;
    font-size: 13px;
    line-height: 1.3;
  }

  .appointment-source-field,
  .appointment-source-options { flex-wrap: wrap; }

  .appointment-dialog .checkbox-field input[type="checkbox"] {
    width: 19px;
    min-width: 19px;
    height: 19px;
    min-height: 19px;
    flex: 0 0 19px;
    margin: 1px 0 0;
    padding: 0;
  }

  .appointment-dialog .communication-checks-field small {
    display: block;
    margin: 2px 0 7px 27px;
    font-size: 11px;
    line-height: 1.3;
  }

  .appointment-dialog textarea,
  .appointment-notes-field textarea,
  .whatsapp-message-field textarea {
    min-height: 54px;
    height: 54px;
  }

  .communication-checks-field {
    padding-top: 0;
  }

  .appointment-dialog .dialog-actions {
    align-items: stretch;
    flex-direction: row;
    gap: 8px;
    padding: 7px 0 0;
  }

  .appointment-dialog .dialog-actions .btn,
  .appointment-dialog .dialog-actions-right .btn {
    flex: 1 1 0;
    min-height: 34px;
    padding: 6px 9px;
    font-size: 12px;
  }

  /* La cancelación de la cita es una acción secundaria/destructiva; no debe
     ocupar media pantalla ni partirse en dos líneas en un móvil estrecho. */
  .appointment-dialog .dialog-actions > #deleteAppointmentBtn {
    flex: 0 0 auto;
    width: auto;
    min-width: 92px;
    height: 36px;
    min-height: 36px;
    align-self: center;
    line-height: 1.1;
    white-space: nowrap;
    padding-inline: 10px;
  }

  #reminderDialog form { padding: 14px; }
  #reminderDialog .dialog-actions { flex-direction: row; }
  #reminderDialog .dialog-actions .btn { min-height: 32px; padding: 6px 10px; font-size: 12px; }

  .settings-dialog,
  .settings-page {
    width: 100%;
    max-width: none;
    min-height: 100dvh;
    border-radius: 0;
  }
}
.overlap-mode-setting > label { display: flex; gap: .6rem; align-items: center; padding: .55rem .7rem; border: 1px solid #d1d5db; border-radius: .55rem; cursor: pointer; background: #fff; transition: border-color .15s, background .15s, box-shadow .15s; }
.overlap-mode-setting label:hover { border-color: #9ca3af; background: #f9fafb; }
.overlap-mode-setting label:has(input:checked) { border-color: #2563eb; background: #eff6ff; box-shadow: 0 0 0 2px #bfdbfe; }
.overlap-mode-setting input { width: 1.1rem; height: 1.1rem; accent-color: #2563eb; flex: 0 0 auto; }
.overlap-mode-setting label span { line-height: 1.25; }
.overlap-mode-setting > small { display: none; }
.overlap-mode-setting .settings-help { display: block; }
@media (max-width: 700px) {
  .public-booking-link-card { align-items: stretch; flex-direction: column; gap: 10px; padding: 12px; }
  .public-booking-link-card .btn { width: 100%; }
  .settings-general-block { grid-template-columns: 1fr; }
  .overlap-mode-setting { grid-template-columns: 1fr; }
  .overlap-mode-setting legend { grid-column: auto; }
}
.overlap-mode-setting small { display: block; color: #6b7280; font-weight: 400; }

/* Login y aviso de caducidad comparten siempre el mismo modal compacto. */
.dialog.login-dialog,
.dialog.session-expiry-dialog {
  width: min(380px, calc(100vw - 32px));
  max-width: min(380px, calc(100vw - 32px));
}
.login-dialog form,
.session-expiry-dialog form { padding: 14px; }
.login-dialog .dialog-actions,
.session-expiry-dialog .dialog-actions {
  align-items: center;
  justify-content: flex-end;
  flex-direction: row;
  gap: 6px;
  margin-top: 14px;
}
.login-dialog .dialog-actions .btn,
.session-expiry-dialog .dialog-actions .btn {
  width: auto;
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

@media (max-width: 900px) {
  .dialog.login-dialog,
  .dialog.session-expiry-dialog {
    width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
  }
  .login-dialog form,
  .session-expiry-dialog form { padding: 14px; }
  .login-dialog .dialog-actions,
  .session-expiry-dialog .dialog-actions { flex-direction: row; }
  .login-dialog .dialog-actions .btn,
  .session-expiry-dialog .dialog-actions .btn { width: auto; }
}
select#appointmentTime option:not(.occupied-time) { color: #111827; background: #fff; }

/* Selector visual de apertura de WhatsApp. Mantiene radios accesibles, pero
   presenta cada opción como una tarjeta clara y fácil de pulsar. */
.whatsapp-opening-setting {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

/* Opciones de automatización: controles visibles, alineados y fáciles de pulsar. */
.whatsapp-automation-setting {
  display: grid;
  gap: 10px;
  background: #fbfdff;
}
.whatsapp-automation-setting legend,
.whatsapp-automation-setting > .settings-help,
.whatsapp-automation-section-label {
  grid-column: 1 / -1;
}
.whatsapp-automation-setting > .settings-help {
  margin: 0 0 2px;
}
.whatsapp-automation-section-label {
  margin: 2px 0 -2px;
  color: #53677f;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.whatsapp-automation-toggle,
.whatsapp-automation-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: #344256;
  cursor: pointer;
}
.whatsapp-automation-toggle {
  min-height: 58px;
  padding: 12px 13px;
  border: 1px solid #c9dced;
  border-radius: 10px;
  background: linear-gradient(100deg, #f1f7ff, #f8fbff);
  box-shadow: 0 2px 5px rgba(32, 74, 125, .04);
}
.whatsapp-automation-toggle input,
.whatsapp-automation-option input {
  flex: 0 0 16px;
  width: 16px !important;
  min-width: 16px !important;
  height: 16px;
  min-height: 16px !important;
  margin: 1px 0 0;
  padding: 0 !important;
  accent-color: var(--primary);
}
.whatsapp-automation-toggle span,
.whatsapp-automation-option span {
  display: block;
  min-width: 0;
  line-height: 1.35;
}
.whatsapp-automation-toggle strong {
  display: block;
  margin-bottom: 3px;
  color: #16263d;
  font-size: 14px;
}
.whatsapp-automation-toggle small {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.35;
}
.whatsapp-automation-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  grid-auto-rows: 88px;
}
.whatsapp-automation-option {
  align-items: flex-start;
  min-height: 0;
  height: 100%;
  padding: 12px;
  border: 1px solid #d5deea;
  border-radius: 10px;
  background: #fff;
  font-size: 12px;
  box-shadow: 0 2px 5px rgba(32, 74, 125, .025);
}
.whatsapp-automation-option:hover {
  border-color: #9bb5d2;
  background: #f8fbff;
}
.whatsapp-automation-option:has(input:checked) {
  border-color: #8ab4df;
  background: #f2f8ff;
  box-shadow: 0 0 0 2px #dbeafe;
}
.whatsapp-automation-option strong {
  display: block;
  margin-bottom: 3px;
  color: #253b55;
  font-size: 13px;
}
.whatsapp-automation-option small {
  display: block;
  color: #718096;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.35;
}
.whatsapp-automation-reminder-option {
  display: grid;
  gap: 0;
  min-height: 0;
  height: 100%;
  border: 1px solid #d5deea;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 5px rgba(32, 74, 125, .025);
}
.whatsapp-automation-reminder-option .whatsapp-automation-option {
  min-height: 0;
  height: auto;
  border: 0;
  border-radius: 10px 10px 0 0;
  box-shadow: none;
}
.whatsapp-reminder-hours {
  display: grid;
  grid-template-columns: auto minmax(70px, 100px);
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 0 12px 8px 38px;
}
.whatsapp-reminder-hours span {
  color: #64748b;
  font-size: 11px;
  font-weight: 400;
}
.whatsapp-reminder-hours input {
  min-height: 30px !important;
  padding: 5px 7px !important;
  font-size: 12px;
}
.whatsapp-automation-setting .section-actions {
  margin-top: 3px;
}
.whatsapp-outbox-summary {
  grid-column: 1 / -1;
  margin-top: 2px;
  padding: 10px 12px;
  border: 1px solid #d8e3ee;
  border-radius: 9px;
  background: #fff;
}
.whatsapp-outbox-summary > strong {
  display: block;
  color: #173f67;
  font-size: 13px;
}
.whatsapp-outbox-summary > .settings-help {
  margin: 3px 0 0;
}
.wa-outbox-list {
  display: grid;
  gap: 7px;
  margin-top: 9px;
}
.wa-outbox-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 7px;
  border-top: 1px solid #edf1f5;
}
.wa-outbox-item strong,
.wa-outbox-item small {
  display: block;
}
.wa-outbox-item strong {
  color: #253b55;
  font-size: 12px;
}
.wa-outbox-item small {
  margin-top: 2px;
  color: #617083;
  font-size: 11px;
}
.wa-outbox-state {
  flex: 0 0 auto;
  color: #396888;
  font-size: 11px;
  text-align: right;
}
.wa-outbox-state.is-review {
  color: #a7461f;
  font-weight: 600;
}

/* Las cuatro decisiones operativas son simples: se presentan como una lista
   compacta, sin reservar espacio vacío para textos largos. */
.whatsapp-automation-options {
  grid-auto-rows: unset;
  align-items: start;
}
.whatsapp-automation-options > .whatsapp-automation-option {
  min-height: 48px;
  height: auto;
  align-items: center;
  padding: 9px 10px;
}
.whatsapp-automation-options > .whatsapp-automation-option > span {
  font-size: 12px;
  font-weight: 600;
}
.whatsapp-automation-options > .whatsapp-automation-reminder-option {
  display: flex;
  min-height: 48px;
  height: auto;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid #d5deea;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 5px rgba(32, 74, 125, .025);
}
.whatsapp-automation-options > .whatsapp-automation-reminder-option:hover {
  border-color: #9bb5d2;
  background: #f8fbff;
}
.whatsapp-automation-options > .whatsapp-automation-reminder-option:has(input:checked) {
  border-color: #8ab4df;
  background: #f2f8ff;
  box-shadow: 0 0 0 2px #dbeafe;
}
.whatsapp-reminder-inline-label {
  margin-left: auto;
  color: #718096;
  font-size: 11px !important;
  font-weight: 400 !important;
  white-space: nowrap;
}
.whatsapp-automation-options > .whatsapp-automation-reminder-option .whatsapp-reminder-hours-input {
  flex: 0 0 58px;
  width: 58px !important;
  min-width: 58px !important;
  min-height: 30px !important;
  height: 30px;
  padding: 5px 7px !important;
  font-size: 12px;
}
.whatsapp-opening-setting legend,
.whatsapp-opening-setting > .settings-help {
  grid-column: 1 / -1;
}
.whatsapp-opening-setting > label {
  position: relative;
  display: block;
  min-height: 68px;
  padding: 9px 10px;
  border: 1px solid #d5deea;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease, transform .15s ease;
}
.whatsapp-opening-setting > label:hover {
  border-color: #9bb5d2;
  background: #f8fbff;
  transform: translateY(-1px);
}
.whatsapp-opening-setting > label:has(input:checked) {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 2px #bfdbfe;
}
.whatsapp-opening-setting > label input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.whatsapp-opening-setting > label span {
  display: block;
  padding-right: 4px;
  line-height: 1.3;
}
.whatsapp-opening-setting > label strong {
  display: block;
  margin-bottom: 4px;
  color: #16263d;
  font-size: 12px;
}
.whatsapp-opening-setting > label small {
  display: block;
  color: #64748b;
  font-size: 10px;
  font-weight: 400;
  line-height: 1.35;
}
.whatsapp-desktop-check {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 2px;
}
.whatsapp-desktop-check .btn {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}
.whatsapp-desktop-check small {
  color: #64748b;
  font-size: 11px;
  line-height: 1.35;
}
@media (max-width: 700px) {
  .whatsapp-automation-options { grid-template-columns: 1fr; }
  .wa-outbox-item { align-items: flex-start; flex-direction: column; }
  .wa-outbox-state { text-align: left; }
  .whatsapp-opening-setting { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .whatsapp-opening-setting legend,
  .whatsapp-opening-setting > .settings-help { grid-column: auto; }
  .whatsapp-desktop-check { grid-column: 1 / -1; }
}
@media (max-width: 460px) {
  .whatsapp-opening-setting { grid-template-columns: 1fr; }
  .whatsapp-desktop-check { align-items: flex-start; flex-direction: column; }
}

/* Demo comercial: en móvil la agenda debe poder probarse sin navegar una
   cabecera alta ni repetir los paneles de escritorio bajo las citas. */
@media (max-width: 560px) {
  body:not(.official-app) .topbar {
    height: auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    justify-content: stretch;
    gap: 7px;
    padding: 10px 12px;
  }

  body:not(.official-app) .topbar-title,
  body:not(.official-app) .topbar-actions {
    width: 100%;
  }

  body:not(.official-app) .topbar-title {
    justify-content: center;
  }

  body:not(.official-app) .demo-brand {
    gap: 6px;
    font-size: 12px;
  }

  body:not(.official-app) .demo-brand-logo {
    width: 26px;
    height: 26px;
  }

  body:not(.official-app) .demo-nav {
    display: flex;
    align-items: center;
    gap: 0;
  }

  body:not(.official-app) .demo-nav a:not(.btn.primary) {
    display: none;
  }

  body:not(.official-app) .demo-nav .btn.primary {
    display: inline-flex;
    min-height: 36px;
    padding: 7px 10px;
    font-size: 12px;
  }

  body:not(.official-app) .demo-banner {
    display: block;
    padding: 8px;
    background: #f5f9ff;
  }

  body:not(.official-app) .demo-guide-title,
  body:not(.official-app) .demo-guide-steps,
  body:not(.official-app) .demo-guide-note {
    display: none;
  }

  body:not(.official-app) .demo-toolbar {
    gap: 6px;
    padding: 9px;
    margin: 0;
    border-color: #d8e5f3;
    box-shadow: none;
  }

  body:not(.official-app) .demo-toolbar h2 {
    font-size: 16px;
  }

  body:not(.official-app) .demo-toolbar #agendaSubtitle {
    font-size: 11px;
  }

  body:not(.official-app) .demo-toolbar .toolbar-tool-btn {
    display: none;
  }

  body:not(.official-app) .layout {
    display: block;
    padding: 8px;
  }

  body:not(.official-app) .sidebar {
    display: none;
  }

  body:not(.official-app) .content {
    width: 100%;
  }

  body:not(.official-app) .appointments-grid {
    gap: 8px;
  }
}

/* Última capa de unificación para que las reglas específicas de cada modal
   no vuelvan a convertir estas acciones en botones planos. */
.consistent-action-btn,
.appointment-dialog .consistent-action-btn,
.patient-dialog .consistent-action-btn {
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid #a9c5df;
  border-radius: 6px;
  background: #f7fbff;
  color: #24527c;
  box-shadow: 0 1px 2px rgba(36, 82, 124, .08);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}
.consistent-action-btn:hover,
.consistent-action-btn:focus-visible,
.appointment-dialog .consistent-action-btn:hover,
.appointment-dialog .consistent-action-btn:focus-visible,
.patient-dialog .consistent-action-btn:hover,
.patient-dialog .consistent-action-btn:focus-visible {
  border-color: #6f9fc9;
  background: #edf6ff;
  color: #174f86;
  outline: none;
}

/* Pulido visual de la agenda: superficie neutra, tarjetas limpias y el color
   reservado para identificar profesional/estado, como en una agenda de
   recepción profesional. */
.appointments-grid { gap: 16px; }

.doctor-column,
.week-summary-column {
  border-color: #dbe3ec;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(31, 55, 81, .045);
}

.day-column-header,
.week-summary-header {
  padding: 13px 15px;
  background: #fbfcfe;
}

.column-header-main strong,
.week-summary-header strong {
  color: #1e2b3d;
  letter-spacing: -.01em;
}

.column-header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.column-add-btn,
.column-reminder-btn,
.week-open-day {
  border-color: #cfd9e5;
  color: #34516f;
  background: #fff;
  font-weight: 700;
}

.day-column-body,
.week-summary-body {
  padding: 10px;
  background: #fff;
}

.appointment-card {
  border-color: #e1e7ee;
  border-radius: 9px;
  background: #fff !important;
  box-shadow: 0 1px 3px rgba(31, 55, 81, .035);
}

.appointment-card:hover,
.week-appointment:hover {
  border-color: #b9c9da;
  box-shadow: 0 7px 18px rgba(31, 55, 81, .09);
}

.appointment-card.doctor-1,
.appointment-card.doctor-2 {
  border-top-color: #e1e7ee;
  border-right-color: #e1e7ee;
  border-bottom-color: #e1e7ee;
}

.appointment-card.status-pending { border-left-color: #3178d8; }
.appointment-card.status-confirmed { border-left-color: #2f9465; }
.appointment-card.status-change { border-left-color: #d59a2d; }
.appointment-card.status-no_response { border-left-color: #8898aa; }
.appointment-card.status-cancelled { border-left-color: #c35b5b; }

.appointment-card h3,
.week-copy strong { color: #1d2a3a; }

.appointment-card .meta,
.week-copy small { color: #64758a; }

.time,
.week-time {
  background: #f1f4f8;
  color: #27384d;
}

.status-select { border-radius: 7px; font-weight: 700; }

.week-appointment {
  border-color: #e1e7ee;
  border-radius: 8px;
  background: #fff;
}

.week-summary-header span {
  color: #718197;
  font-size: 11px;
}

/* En tabletas y móviles la tarjeta no debe crecer por conservar la
   composición vertical de escritorio: acciones y cita comparten fila. */
@media (max-width: 900px) {
  .appointments-grid.day-view .appointment-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto;
    align-items: center;
    min-height: 0;
    padding: 7px;
  }

  .appointments-grid.day-view .appointment-main {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  .appointments-grid.day-view .notes,
  .appointments-grid.day-view .next-action {
    display: none;
  }

  .appointments-grid.day-view .appointment-card .card-actions {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    margin: 0;
    gap: 5px;
  }

  .appointments-grid.day-view .appointment-card .status-select {
    width: 112px;
    max-width: 112px;
    min-height: 32px;
  }

  .appointments-grid.day-view .whatsapp-btn {
    width: 42px;
    min-width: 42px;
    min-height: 42px;
    flex: 0 0 42px;
  }
}

@media (max-width: 420px) {
  .appointments-grid.day-view .appointment-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .appointments-grid.day-view .appointment-card .card-actions {
    grid-column: 1;
    grid-row: 2;
    justify-self: end;
    margin-top: 4px;
  }
}

/* Agenda visual layer: pastel, compact and intentionally size-neutral. */
:root {
  --agenda-pastel-primary: #5fb8ae;
  --agenda-pastel-primary-dark: #4aa69c;
  --agenda-pastel-mint: #edf7f5;
  --agenda-pastel-mint-border: #cfe5e2;
  --agenda-pastel-text: #426a68;
  --agenda-pastel-danger: #bd776d;
  --agenda-pastel-danger-bg: #fff7f5;
  --agenda-pastel-warning: #c49a56;
}

.btn {
  border-radius: 10px;
  font-weight: 700;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}

.btn.primary {
  background: var(--agenda-pastel-primary);
  border-color: var(--agenda-pastel-primary);
  color: #fff;
  box-shadow: 0 5px 12px rgba(84, 170, 161, .14);
}

.btn.primary:hover,
.btn.primary:focus-visible {
  background: var(--agenda-pastel-primary-dark);
  border-color: var(--agenda-pastel-primary-dark);
}

.btn.secondary,
.btn.danger-secondary {
  background: var(--agenda-pastel-mint);
  border-color: var(--agenda-pastel-mint-border);
  color: var(--agenda-pastel-text);
}

.btn.secondary:hover,
.btn.secondary:focus-visible,
.btn.danger-secondary:hover,
.btn.danger-secondary:focus-visible {
  background: #e3f2f0;
  border-color: #b7d9d5;
}

.btn.danger {
  background: var(--agenda-pastel-danger-bg);
  border-color: #ecc4be;
  color: var(--agenda-pastel-danger);
}

.btn.danger:hover,
.btn.danger:focus-visible {
  background: #ffefec;
  border-color: #dda49b;
}

.appointment-card,
.week-appointment {
  border-radius: 12px;
  border-color: #dbe7e6;
}

.appointment-card.status-pending {
  background: #f4fbfa;
  border-left-color: #78bfb7;
}

.appointment-card.status-confirmed {
  background: #f2faf6;
  border-left-color: #72aa91;
}

.appointment-card.status-change {
  background: #fffaf1;
  border-left-color: #d7b16d;
}

.appointment-card.status-no_response {
  background: #f7f9fa;
  border-left-color: #a8b5bd;
}

.appointment-card.status-cancelled {
  background: #fff8f7;
  border-left-color: #d59a91;
}

.status-select,
.appointment-dialog select,
.appointment-dialog input,
.appointment-dialog textarea,
.settings-shell select,
.settings-shell input,
.settings-shell textarea {
  border-color: #d2e5e3;
  border-radius: 10px;
}

.status-select:focus,
.appointment-dialog select:focus,
.appointment-dialog input:focus,
.appointment-dialog textarea:focus,
.settings-shell select:focus,
.settings-shell input:focus,
.settings-shell textarea:focus {
  border-color: var(--agenda-pastel-primary);
  box-shadow: 0 0 0 3px rgba(95, 184, 174, .14);
}

.work-card,
.settings-card,
.settings-section,
.settings-tab {
  border-color: #dbe7e6;
  border-radius: 12px;
}

.work-card:hover,
.settings-tab:hover {
  border-color: #b7d9d5;
  background: #f7fbfa;
}

.settings-tab.active {
  background: var(--agenda-pastel-mint);
  border-color: var(--agenda-pastel-mint-border);
  color: var(--agenda-pastel-text);
}

.toolbar .view-switch button.active,
.toolbar .view-switch button.active:hover,
.toolbar .view-switch button.active:focus-visible {
  background: var(--agenda-pastel-primary);
  border-color: var(--agenda-pastel-primary);
  color: #fff;
}

.toolbar .view-switch button:not(.active):hover,
.toolbar .view-switch button:not(.active):focus-visible {
  background: var(--agenda-pastel-mint);
  border-color: var(--agenda-pastel-mint-border);
  color: var(--agenda-pastel-text);
  outline: none;
}

/* Ajuste fino: controles compactos, sobrios y consistentes */
.booking-source-badge {
  min-height: 17px;
  padding: 1px 4px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #74859a;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.15;
}

.booking-source-badge[data-source="online"],
.booking-source-badge[data-source="whatsapp"],
.booking-source-badge[data-source="phone_bot"] {
  border-color: transparent;
  background: transparent;
  color: #74859a;
}

.daily-note-heading {
  color: #8292a5;
}

.daily-note-heading svg {
  width: 15px;
  height: 15px;
  stroke-width: 1.45;
}

.change-preference-badge {
  width: 20px;
  height: 20px;
  flex-basis: 20px;
  color: #8292a5;
  font-size: 16px;
}

.change-preference-badge.active {
  color: #9b6a22;
}

.status-select,
.appointment-card .status-select {
  border-radius: 7px;
  border-color: #d3dde8;
  background: #fff !important;
  color: #4c6076;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
}

.status-select.status-tone-pending,
#appointmentStatus.status-tone-pending {
  background: #f8fbff !important;
  border-color: #cbdced;
  color: #41678f;
}

.status-select.status-tone-confirmed,
#appointmentStatus.status-tone-confirmed {
  background: #f7fbf8 !important;
  border-color: #cfe4d6;
  color: #467258;
}

.status-select.status-tone-change,
#appointmentStatus.status-tone-change {
  background: #fffbf3 !important;
  border-color: #ead9b0;
  color: #806b38;
}

.status-select.status-tone-no_response,
#appointmentStatus.status-tone-no_response {
  background: #f7f9fb !important;
  border-color: #d7e0e8;
  color: #68798b;
}

.status-select.status-tone-cancelled,
#appointmentStatus.status-tone-cancelled {
  background: #fff8f7 !important;
  border-color: #e8cbc7;
  color: #9a5d58;
}

.status-select option,
.status-select option.status-tone-pending,
.status-select option.status-tone-confirmed,
.status-select option.status-tone-change,
.status-select option.status-tone-no_response,
.status-select option.status-tone-cancelled {
  background: #fff !important;
  color: #43566c !important;
  font-weight: 400;
}

.whatsapp-sent-toggle {
  width: 15px;
  height: 15px;
  top: -5px;
  right: -4px;
  border-width: 1.5px;
  background: #b7c2cd;
  font-size: 10px;
  line-height: 12px;
}

.whatsapp-sent-toggle.active {
  background: #58a878;
}

/* Sistema visual común para acceso, configuración y diálogos */
.topbar,
.settings-page-header,
.settings-tabs,
.settings-section,
.dialog,
.work-card,
.settings-card {
  border-color: #dbe7e6;
  box-shadow: 0 6px 18px rgba(46, 77, 84, .06);
}

.topbar {
  background: rgba(255, 255, 255, .96);
}

.topbar-title h1,
.settings-page-header h2,
.dialog-header h2,
.settings-section h3,
.settings-section h4 {
  color: #263c4b;
  font-weight: 650;
}

.topbar-title h1 {
  letter-spacing: -.01em;
}

.dialog,
.dialog form,
.dialog-body {
  background: #fff;
}

.dialog.small-dialog,
.login-dialog,
.session-expiry-dialog {
  border: 1px solid #dbe7e6;
  border-top: 3px solid var(--agenda-pastel-primary);
  border-radius: 12px;
  overflow: hidden;
}

.login-dialog form,
.session-expiry-dialog form {
  padding: 18px;
}

.login-dialog .dialog-header,
.session-expiry-dialog .dialog-header {
  margin-bottom: 15px;
}

.dialog-subtitle,
.settings-help,
.field-help {
  color: #718394;
  font-weight: 400;
}

.field > span,
.settings-section > h3,
.settings-section > h4,
.settings-subtitle {
  color: #526877;
  font-weight: 600;
}

.login-dialog input,
.login-dialog select,
.dialog input,
.dialog select,
.dialog textarea,
.settings-shell input,
.settings-shell select,
.settings-shell textarea {
  border-color: #d2e1e3;
  border-radius: 8px;
  background: #fff;
  color: #344d5c;
  box-shadow: none;
}

.login-dialog input:focus,
.login-dialog select:focus,
.dialog input:focus,
.dialog select:focus,
.dialog textarea:focus,
.settings-shell input:focus,
.settings-shell select:focus,
.settings-shell textarea:focus {
  border-color: #8cc9c1;
  box-shadow: 0 0 0 3px rgba(95, 184, 174, .12);
  outline: none;
}

.login-dialog .btn.primary,
.settings-shell .btn.primary,
.dialog .btn.primary {
  background: var(--agenda-pastel-primary);
  border-color: var(--agenda-pastel-primary);
  box-shadow: none;
  font-weight: 600;
}

.login-dialog .btn.primary:hover,
.settings-shell .btn.primary:hover,
.dialog .btn.primary:hover {
  background: var(--agenda-pastel-primary-dark);
  border-color: var(--agenda-pastel-primary-dark);
}

.link-btn {
  color: #4e817d;
  font-weight: 500;
}

.settings-context-bar {
  border-color: #dbe7e6;
  background: #f7fbfa;
}

.settings-context-bar h2 {
  color: #426a68;
  font-weight: 650;
}

.settings-tab {
  border-radius: 8px;
  color: #647886;
  font-weight: 500;
}

.settings-tab.active {
  background: #edf7f5;
  border-color: #cfe5e2;
  color: #426a68;
  font-weight: 600;
}

.settings-basic-block,
.settings-card .settings-basic-block {
  border-color: #e0ebe9;
  border-radius: 9px;
}

.form-error {
  font-weight: 500;
}

/* Última capa del sistema visual: también cubre la cabecera oficial */
:root {
  --primary: #5fb8ae;
  --primary-dark: #4aa69c;
}

.official-app .topbar {
  background: rgba(255, 255, 255, .97);
  border-bottom-color: #dbe7e6;
}

.official-app #loginBtn,
.official-app #loginBtn:hover,
.official-app #loginBtn:focus-visible {
  border-color: var(--agenda-pastel-primary);
  background: var(--agenda-pastel-primary);
  color: #fff;
  font-weight: 600;
  box-shadow: none;
}

.official-app .topbar-actions #settingsBtn.icon-settings,
.official-app .topbar-actions #logoutBtn.icon-logout {
  border-color: #dbe7e6;
  background: #fff;
  color: #58707b;
  box-shadow: none;
}

.official-app .topbar-actions #settingsBtn.icon-settings:hover,
.official-app .topbar-actions #logoutBtn.icon-logout:hover {
  border-color: #b7d9d5;
  background: #f7fbfa;
  color: #426a68;
}

.official-app .topbar > .toolbar h2,
.official-app .toolbar h2,
.toolbar h2 {
  color: #426a68;
  font-weight: 600;
}

.toolbar,
.agenda-toolbar {
  border-color: #dbe7e6;
  background: #fff;
  box-shadow: 0 5px 16px rgba(46, 77, 84, .05);
}

.toolbar #todayBtn,
.toolbar .view-switch button.active,
.toolbar .view-switch button.active:hover,
.toolbar .view-switch button.active:focus-visible {
  background: #edf7f5;
  border-color: #cfe5e2;
  color: #426a68;
  font-weight: 600;
  box-shadow: none;
}

/* Los estados recuperan su código de color, con una intensidad contenida. */
.status-select.status-tone-pending,
#appointmentStatus.status-tone-pending {
  background: #eef5ff !important;
  border-color: #c7dcfa;
  color: #356ca8;
}

.status-select.status-tone-confirmed,
#appointmentStatus.status-tone-confirmed {
  background: #edf9f3 !important;
  border-color: #c2e5d0;
  color: #287653;
}

.status-select.status-tone-change,
#appointmentStatus.status-tone-change {
  background: #fff8e8 !important;
  border-color: #ead9ae;
  color: #8a691f;
}

.status-select.status-tone-no_response,
#appointmentStatus.status-tone-no_response {
  background: #f3f6f8 !important;
  border-color: #d7e0e8;
  color: #68798b;
}

.status-select.status-tone-cancelled,
#appointmentStatus.status-tone-cancelled {
  background: #fff1ef !important;
  border-color: #edc7c1;
  color: #a3534d;
}

/* Chromium respeta estos tonos en el menú nativo de opciones. */
.status-select option.status-tone-pending { background: #eef5ff !important; color: #356ca8 !important; }
.status-select option.status-tone-confirmed { background: #edf9f3 !important; color: #287653 !important; }
.status-select option.status-tone-change { background: #fff8e8 !important; color: #8a691f !important; }
.status-select option.status-tone-no_response { background: #f3f6f8 !important; color: #68798b !important; }
.status-select option.status-tone-cancelled { background: #fff1ef !important; color: #a3534d !important; }
.status-select option.status-option-pending { background: #eef5ff !important; color: #356ca8 !important; }
.status-select option.status-option-confirmed { background: #edf9f3 !important; color: #287653 !important; }
.status-select option.status-option-change { background: #fff8e8 !important; color: #8a691f !important; }
.status-select option.status-option-no_response { background: #f3f6f8 !important; color: #68798b !important; }
.status-select option.status-option-cancelled { background: #fff1ef !important; color: #a3534d !important; }

/* Código de estado de la tarjeta: contraste suficiente sin colorear todo el bloque. */
.appointments-grid .appointment-card.status-pending,
.appointments-grid .week-appointment.status-pending {
  background: #f7fbff !important;
  border-left-color: #2f75d6 !important;
}

.appointments-grid .appointment-card.status-confirmed,
.appointments-grid .week-appointment.status-confirmed {
  background: #f7fcf9 !important;
  border-left-color: #16865b !important;
}

.appointments-grid .appointment-card.status-change,
.appointments-grid .week-appointment.status-change {
  background: #fffaf0 !important;
  border-left-color: #c48719 !important;
}

.appointments-grid .appointment-card.status-no_response,
.appointments-grid .week-appointment.status-no_response {
  background: #fafbfc !important;
  border-left-color: #7a8795 !important;
}

.appointments-grid .appointment-card.status-cancelled,
.appointments-grid .week-appointment.status-cancelled {
  background: #fff8f7 !important;
  border-left-color: #c4514c !important;
}

/* In weekly view, appointment fill identifies the professional; left border and pill identify status. */
.appointments-grid.week-view .week-appointment.doctor-1 { background: var(--doctor-1-card) !important; }
.appointments-grid.week-view .week-appointment.doctor-2 { background: var(--doctor-2-card) !important; }
.appointments-grid.week-view .week-appointment.doctor-3,
.appointments-grid.week-view .week-appointment.doctor-4,
.appointments-grid.week-view .week-appointment.doctor-5,
.appointments-grid.week-view .week-appointment.doctor-6,
.appointments-grid.week-view .week-appointment.doctor-7,
.appointments-grid.week-view .week-appointment.doctor-8 { background: var(--doctor-card) !important; }

.status-pill.status-pending { background: #e8f1ff !important; color: #245fae !important; }
.status-pill.status-confirmed { background: #e5f6ed !important; color: #116c49 !important; }
.status-pill.status-change { background: #fff1cc !important; color: #805800 !important; }
.status-pill.status-no_response { background: #edf1f4 !important; color: #5f6e7b !important; }
.status-pill.status-cancelled { background: #ffe5e2 !important; color: #9d3e3a !important; }

/* Jerarquía de negocio: paciente para recepción, tratamiento para preparar el trabajo. */
.appointment-card .meta {
  gap: 6px;
}

.appointment-card .appointment-treatment {
  display: block;
  max-width: 100% !important;
  overflow: hidden;
  color: #405d6d;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.appointment-treatment-line {
  display: block;
  max-width: 100%;
  margin-top: 3px;
  overflow: hidden;
  color: #405d6d;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.appointment-card .meta:has(.appointment-treatment) {
  display: none;
}

.work-count-breakdown {
  display: none !important;
}

.work-card {
  height: 48px;
  min-height: 48px;
}

.work-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.work-card {
  min-width: 0;
  padding: 7px 8px;
  gap: 6px;
}

.work-card span:first-child {
  min-width: 0;
}

.work-card strong {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.15;
  text-overflow: clip;
  white-space: normal;
}

.work-card b {
  flex: 0 0 auto;
  min-width: 25px;
  padding: 4px 6px;
  font-size: 12px;
}

@media (max-width: 760px) {
  .work-list {
    grid-template-columns: 1fr;
  }
}

/* El panel de trabajo reutiliza exactamente el código de color de las citas. */
.work-card#pendingConfirmBtn {
  border-left: 3px solid #2f75d6;
  background: #f7fbff;
}

.work-card#noResponseBtn {
  border-left: 3px solid #7a8795;
  background: #fafbfc;
}

.work-card#changeRequestsBtn {
  border-left: 3px solid #c48719;
  background: #fffaf0;
}

.work-card#confirmedTodayBtn {
  border-left: 3px solid #16865b;
  background: #f7fcf9;
}

.work-card#reviewDataBtn,
.work-card#reviewDataBtn.has-review-items {
  border-left: 3px solid #c48719;
  background: #fffaf0;
}

.work-card#followUpWorkBtn {
  border-left: 3px solid #5fb8ae;
  background: #f7fbfa;
}

.work-card#resetWorkFiltersBtn strong,
.work-card#followUpWorkBtn strong {
  font-size: 12px;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-card#resetWorkFiltersBtn strong {
  white-space: normal;
}

.work-card#reviewDataBtn strong {
  font-size: 11px;
  white-space: normal;
}

.work-card#followUpWorkBtn small { display: none; }

/* Profesionales en un selector compacto: todas arriba y agendas juntas debajo. */
.agenda-tabs {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.agenda-tab {
  min-width: 0;
  padding: 5px 7px;
  gap: 5px;
  font-size: 11px;
  line-height: 1.15;
}

.agenda-tab:first-child {
  grid-column: 1 / -1;
}

.agenda-tab span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agenda-tab-check {
  width: 15px;
  height: 15px;
  font-size: 10px;
}

.agenda-tabs.few-doctors {
  grid-template-columns: 1fr;
}

.agenda-tabs.few-doctors .agenda-tab:first-child {
  grid-column: auto;
}

.agenda-tabs.few-doctors .agenda-tab span {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.appointment-card .appointment-doctor {
  order: 2;
  color: #81909c;
}

.appointment-card .appointment-phone {
  display: none;
}

.wa-inbox-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 5px;
  align-items: center;
}

.wa-inbox-item {
  display: grid;
  gap: 8px;
}

.wa-inbox-item > div:first-child {
  min-width: 0;
}

.wa-inbox-actions .btn {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 11px;
  white-space: nowrap;
}

.week-copy .week-treatment {
  color: #405d6d;
  font-size: 13px;
  font-weight: 650;
}

.week-copy .week-patient {
  color: #718394;
  font-size: 11px;
  font-weight: 500;
}

.week-time {
  display: grid;
  align-content: center;
  justify-items: center;
  row-gap: 4px;
  line-height: 1.05;
}

.week-time small {
  margin-top: 0;
  line-height: 1.1;
  white-space: nowrap;
}

/* En pantallas estrechas los campos conservan anchura para leer sus valores. */
@media (max-width: 900px) {
  .appointment-dialog .patient-fields-grid,
  .appointment-dialog .appointment-details-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .appointment-dialog .patient-fields-grid > .field:first-child {
    grid-column: 1 / -1;
  }
  .appointment-dialog .appointment-details-right {
    grid-column: auto;
  }
}
.wa-connection-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px 24px; margin: 16px 0; }
.wa-connection-summary dt { font-size: 13px; color: var(--muted, #64748b); }
.wa-connection-summary dd { margin: 4px 0 0; font-weight: 600; overflow-wrap: anywhere; }

/* Acceso directo a una fecha desde la cabecera. */
.agenda-toolbar .agenda-date-jump {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 0;
  margin: 0;
  color: #526274;
  font-size: 14px;
  font-weight: 500;
}
.agenda-date-jump > span { white-space: nowrap; }
.agenda-toolbar .agenda-date-jump input {
  width: 154px;
  min-width: 0;
  min-height: 36px;
  margin: 0;
  padding: 6px 8px;
  border: 1px solid #dbe7e6;
  border-radius: 8px;
  background: #f7fbfa;
  color: inherit;
  font: inherit;
  font-size: 14px;
  color-scheme: light;
}
.agenda-toolbar .agenda-date-jump input:hover { border-color: #b7d9d5; }
.agenda-toolbar .agenda-date-jump input:focus-visible {
  outline: 2px solid #426a68;
  outline-offset: 2px;
}
@media (max-width: 900px) {
  .agenda-toolbar .agenda-date-jump { justify-content: space-between; width: 100%; }
  .agenda-toolbar .agenda-date-jump input { flex: 1; max-width: 240px; min-height: 44px; }
}

@media (min-width: 901px) {
  .official-app:not(.settings-view) .topbar-title { max-width: none; }
  .official-app .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 16px;
  }
  .official-app .topbar > .toolbar {
    position: static;
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    min-height: 0;
    transform: none;
    margin: 0;
    padding: 8px 0 0;
    border-top: 1px solid #dbe7e6;
    gap: 10px 14px;
    flex-wrap: wrap;
  }
  .official-app .topbar > .toolbar > div:first-child {
    flex: 1 1 230px;
    min-width: 0;
    margin-right: 0;
  }
  .official-app .topbar > .toolbar .view-switch,
  .official-app .topbar > .toolbar .segmented { flex: 0 0 auto; margin: 0; }
  .official-app .toolbar #printDayBtn { margin-left: 0; }
}

/* La fecha orienta la vista; el selector permite saltar a otro dia. */
.agenda-toolbar .agenda-current-date {
  flex: 0 0 auto;
  color: #526274;
  font-size: 14px;
  font-weight: 500;
  text-transform: capitalize;
  white-space: nowrap;
}
@media (max-width: 900px) {
  .agenda-toolbar .agenda-date-jump input { max-width: none; }
}
/* El nombre del centro puede desplazar los controles sin superponerse a ellos. */
@media (min-width: 1200px) {
  .official-app .topbar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 16px;
  }
  .official-app .topbar-title { order: 0; flex: 0 1 auto; }
  .official-app .topbar-actions { order: 2; flex: 0 0 auto; justify-content: flex-end; }
  .official-app .topbar > .toolbar {
    order: 1;
    flex: 1 0 auto;
    width: auto;
    padding: 0;
    border: 0;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 10px;
  }
}

/* A compact, grouped editor for online booking options on desktop and mobile. */
.public-booking-editor {
  margin-top: 26px;
  padding: 20px;
  border: 1px solid #e1e8ef;
  border-radius: 16px;
  background: #f8fafc;
}
.public-booking-editor-heading { margin-bottom: 14px; }
.public-booking-editor-heading .settings-subtitle { margin: 0 0 5px; font-size: 17px; }
.public-booking-editor-heading .dialog-subtitle { max-width: 760px; line-height: 1.5; }
.public-booking-editor .public-booking-link-card { margin-top: 0; background: #fff; }
.public-booking-setting {
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.public-booking-setting:focus-within { border-color: #8fb6df; box-shadow: 0 0 0 3px rgba(65, 132, 193, .1); }
.public-booking-row-actions { gap: 6px; }
.public-booking-row-actions .icon-btn,
.public-booking-row-actions [data-public-booking-remove] { min-height: 38px; }
.public-booking-row-actions [data-public-booking-remove] { padding: 6px 10px; font-size: 12px; }
.treatment-setting { border-radius: 10px; }

@media (max-width: 900px) {
  .official-app.settings-view .topbar > .agenda-toolbar { display: none !important; }
  .official-app.settings-view .topbar { background: #fff; }
  .official-app.settings-view .settings-page { padding: 12px 10px 28px; }
  .official-app.settings-view .settings-layout { gap: 12px; }
  .official-app.settings-view .settings-tabs {
    position: static;
    display: flex;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    flex-wrap: nowrap;
    gap: 8px;
    margin: 0 -2px 2px;
    padding: 5px 2px 9px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  .official-app.settings-view .settings-tab {
    flex: 0 0 auto;
    width: auto;
    min-height: 42px;
    padding: 9px 13px;
    border: 1px solid #dbe4ee;
    border-radius: 999px;
    background: #fff;
    text-align: center;
  }
  .official-app.settings-view .settings-tab strong { white-space: nowrap; }
  .official-app.settings-view .settings-tab span { display: none; }
  .official-app.settings-view .settings-panels { min-height: 0; }
  .official-app.settings-view .settings-card { min-height: 0; padding: 16px; border-radius: 14px; }
  .official-app.settings-view .treatment-list-head,
  .official-app.settings-view .public-booking-list-head { display: none; }
  .official-app.settings-view .treatment-setting {
    grid-template-columns: minmax(0, 1fr) 112px 40px;
    gap: 8px;
    padding: 10px;
  }
  .official-app.settings-view .public-booking-editor { margin-top: 22px; padding: 14px; border-radius: 14px; }
  .official-app.settings-view .public-booking-editor-heading .settings-subtitle { font-size: 16px; }
  .official-app.settings-view .public-booking-setting {
    grid-template-columns: minmax(0, 1fr) minmax(152px, .8fr);
    gap: 9px;
    padding: 12px;
  }
  .official-app.settings-view .public-booking-setting [data-public-booking-name],
  .official-app.settings-view .public-booking-setting [data-public-booking-note] { grid-column: 1 / -1; min-width: 0; }
  .official-app.settings-view .public-booking-active { grid-column: 1; min-height: 40px; }
  .official-app.settings-view .public-booking-row-actions { grid-column: 2; justify-content: flex-end; gap: 5px; }
  .official-app.settings-view .public-booking-row-actions .icon-btn { width: 40px; min-width: 40px; height: 40px; }
  .official-app.settings-view .public-booking-row-actions [data-public-booking-remove] { min-height: 40px; padding: 6px 9px; }
  .official-app.settings-view .section-actions { flex-wrap: wrap; gap: 8px; }
  .official-app.settings-view .section-actions .btn { min-height: 42px; }
}

@media (max-width: 560px) {
  .official-app.settings-view .topbar { position: sticky; top: 0; z-index: 30; }
  .official-app.settings-view .settings-page { padding: 8px 8px 24px; }
  .official-app.settings-view .settings-tabs { padding-right: 4px; padding-left: 4px; }
  .official-app.settings-view .settings-tab { min-height: 40px; padding: 8px 12px; font-size: 13px; }
  .official-app.settings-view .settings-card { padding: 14px 12px; }
  .official-app.settings-view [data-settings-panel="treatments"] > .dialog-subtitle { line-height: 1.45; }
  .official-app.settings-view .treatment-setting { grid-template-columns: minmax(0, 1fr) 98px 38px; gap: 6px; padding: 8px; }
  .official-app.settings-view .treatment-setting input,
  .official-app.settings-view .treatment-setting select { min-width: 0; padding: 8px 7px; }
  .official-app.settings-view .treatment-setting .icon-btn { width: 36px; min-width: 36px; height: 38px; }
  .official-app.settings-view .public-booking-editor { margin-right: -2px; margin-left: -2px; padding: 12px 10px; }
  .official-app.settings-view .public-booking-link-card { align-items: stretch; gap: 10px; padding: 12px; }
  .official-app.settings-view .public-booking-link-card .btn { width: 100%; min-height: 42px; }
  .official-app.settings-view .public-booking-setting { gap: 8px; padding: 10px; }
  .official-app.settings-view .public-booking-setting [data-public-booking-name],
  .official-app.settings-view .public-booking-setting [data-public-booking-type],
  .official-app.settings-view .public-booking-setting [data-public-booking-duration],
  .official-app.settings-view .public-booking-setting [data-public-booking-note] { min-height: 42px; }
  .official-app.settings-view .public-booking-row-actions .icon-btn { width: 38px; min-width: 38px; height: 40px; }
  .official-app.settings-view .public-booking-row-actions [data-public-booking-remove] { min-height: 40px; padding: 6px 8px; font-size: 11px; }
  .official-app.settings-view .public-booking-active { font-size: 13px; }
  .official-app.settings-view [data-settings-panel="treatments"] > .section-actions,
  .official-app.settings-view .public-booking-editor .section-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .official-app.settings-view [data-settings-panel="treatments"] > .section-actions .btn { width: 100%; padding: 8px; font-size: 12px; }
  .official-app.settings-view .public-booking-editor .section-actions .btn { width: 100%; padding: 8px; font-size: 12px; }
}

@media (max-width: 380px) {
  .official-app.settings-view .public-booking-setting { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .official-app.settings-view .public-booking-setting [data-public-booking-type] { grid-column: 1 / -1; }
  .official-app.settings-view .public-booking-row-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* Keep mobile navigation actions together and recognizable. */
.official-app:not(.authenticated) #mobilePatientsBtn { display: none; }
.official-app .topbar-actions #mobilePatientsBtn { display: inline-flex; order: 2; }
.official-app .mobile-patients-btn {
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid #d8e2eb;
  border-radius: 9px;
  background: #fff;
  color: #344256;
  box-shadow: none;
  font-size: 13px;
  font-weight: 650;
}
.official-app .mobile-patients-btn:hover { border-color: #b8c9d8; background: #f7fafc; }
.official-app .mobile-patients-btn svg { width: 19px; height: 19px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.official-app .topbar-actions #logoutBtn.icon-logout { border-color: transparent; background: transparent; color: #b85c5c; opacity: .82; box-shadow: none; }
.official-app .topbar-actions #logoutBtn.icon-logout:hover { border-color: #f0dada; background: #fff8f8; color: #a33f3f; opacity: 1; }
.official-app .topbar-actions #logoutBtn.icon-logout { border: 1px solid #f0dada; border-radius: 999px; background: #fff8f8; }

@media (max-width: 900px) {
  .official-app .topbar-actions #mobilePatientsBtn { display: inline-flex; order: 3; }
  .official-app .topbar-actions #settingsBtn { order: 2; }
  .official-app .topbar-actions #logoutBtn { order: 4; }
  .official-app.authenticated .topbar-actions #logoutBtn.icon-logout { display: grid; }
  .official-app .topbar-actions #settingsBtn.icon-settings { width: auto; min-width: 0; min-height: 38px; height: 38px; padding: 7px 10px; gap: 7px; border-radius: 10px; font-size: 12px; font-weight: 600; }
  .official-app .topbar-actions #settingsBtn [data-settings-label],
  .official-app .topbar-actions #mobilePatientsBtn [data-mobile-patients-label] { display: inline; }
  .official-app .topbar-actions #mobilePatientsBtn { min-height: 38px; height: 38px; padding: 7px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; }
  .official-app .topbar-actions #logoutBtn.icon-logout { border-color: #f0dada; background: #fff8f8; border-radius: 999px; }
}

@media (max-width: 560px) {
  .official-app .topbar-actions #mobilePatientsBtn { min-height: 36px; height: 36px; padding: 6px 9px; }
  .official-app .topbar-actions #settingsBtn.icon-settings { width: auto; min-width: 0; min-height: 36px; height: 36px; padding: 6px 9px; }
  .official-app .topbar-actions #logoutBtn.icon-logout { width: 36px; min-width: 36px; height: 36px; padding: 7px; }
}

@media (min-width: 901px) {
  .official-app .topbar-actions #settingsBtn [data-settings-label] { display: inline-flex; }
  .official-app .topbar-actions #settingsBtn { order: 2; }
  .official-app .topbar-actions #mobilePatientsBtn { order: 3; }
  .official-app .topbar-actions #logoutBtn,
  .official-app .topbar-actions #loginBtn { order: 4; }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .official-app .topbar-actions #mobilePatientsBtn [data-mobile-patients-label] { display: inline-flex; }
}

@media (max-width: 380px) {
  .official-app .topbar-actions { grid-column: 1 / -1; justify-content: flex-end; gap: 4px; }
  .official-app .topbar-actions > .btn { padding-right: 6px; padding-left: 6px; font-size: 11px; }
}

@media (max-width: 900px) {
  .official-app .topbar-actions > .btn {
    box-sizing: border-box;
    height: 38px;
    min-height: 38px;
    line-height: 1;
  }

  .official-app.settings-view .topbar-actions #newAppointmentBtn { display: inline-flex; order: 1; }

  .official-app .topbar-actions #settingsBtn.icon-settings,
  .official-app .topbar-actions #mobilePatientsBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    gap: 7px;
    height: 38px;
    min-height: 38px;
    padding: 0 10px;
    border: 1px solid #d9e3ec;
    border-radius: 12px;
    background: linear-gradient(180deg, #fff 0%, #f6f9fc 100%);
    color: #344b63;
    box-shadow: 0 1px 2px rgba(35, 58, 82, .08), inset 0 1px 0 rgba(255, 255, 255, .9);
    font-family: inherit;
    font-size: 12px;
    font-weight: 650;
    line-height: 1;
    white-space: nowrap;
    transition: border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .16s ease;
  }

  .official-app .topbar-actions #settingsBtn.icon-settings:hover,
  .official-app .topbar-actions #mobilePatientsBtn:hover {
    border-color: #bfd0df;
    background: #fff;
    box-shadow: 0 2px 5px rgba(35, 58, 82, .1);
  }

  .official-app .topbar-actions #settingsBtn.icon-settings:active,
  .official-app .topbar-actions #mobilePatientsBtn:active { transform: translateY(1px); }

  .official-app .topbar-actions #settingsBtn [data-settings-label],
  .official-app .topbar-actions #mobilePatientsBtn [data-mobile-patients-label] {
    display: inline-flex;
    align-items: center;
    font: inherit;
    line-height: 1;
  }

  .official-app .topbar-actions #settingsBtn svg,
  .official-app .topbar-actions #mobilePatientsBtn svg {
    display: block;
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
  }

  .official-app .topbar-actions #logoutBtn.icon-logout {
    display: grid;
    place-items: center;
    width: 38px;
    min-width: 38px;
    height: 38px;
    margin-left: 0;
    padding: 8px;
    border: 1px solid #f0dddd;
    border-radius: 50%;
    background: #fff9f8;
    color: #ad5d5d;
    box-shadow: 0 1px 2px rgba(35, 58, 82, .06);
  }

  .official-app .topbar-actions #logoutBtn.icon-logout:hover {
    border-color: #e8c9c9;
    background: #fff3f2;
    color: #984b4b;
  }

  .official-app .day-column-header { gap: 8px; }
  .official-app .column-header-main { flex: 1 1 auto; width: 0; min-width: 0; }
  .official-app .column-header-title { display: block; min-width: 0; }
  .official-app .column-header-title > strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.25;
  }
  .official-app .column-header-actions { flex: 0 0 auto; flex-wrap: nowrap; gap: 5px; }
  .official-app .column-header-actions .column-add-btn,
  .official-app .column-header-actions .column-reminder-btn {
    min-height: 32px;
    padding: 6px 7px;
    font-size: 11px;
    line-height: 1;
    white-space: nowrap;
  }
}

@media (max-width: 560px) {
  .official-app .topbar-actions > .btn { height: 38px; min-height: 38px; }
  .official-app .topbar-actions #mobilePatientsBtn,
  .official-app .topbar-actions #settingsBtn.icon-settings { height: 38px; min-height: 38px; padding: 0 9px; }
  .official-app .topbar-actions #logoutBtn.icon-logout { width: 38px; min-width: 38px; height: 38px; }
}

@media (max-width: 380px) {
  .official-app .topbar-actions { grid-column: 1 / -1; gap: 4px; }
  .official-app .topbar-actions > .btn { padding: 0 6px; font-size: 11px; }
}

@media (min-width: 901px) {
  .official-app .topbar-actions #settingsBtn.icon-settings {
    width: auto;
    min-width: 0;
    height: 36px;
    min-height: 36px;
    padding: 6px 10px;
    gap: 7px;
    white-space: nowrap;
  }
  .official-app .topbar-actions #settingsBtn [data-settings-label] { display: inline-flex; line-height: 1; }
  .official-app .topbar-actions #mobilePatientsBtn { min-height: 36px; padding: 6px 10px; white-space: nowrap; }
}

@media (min-width: 1200px) {
  .official-app .topbar > .toolbar { flex: 1 1 560px; min-width: 0; flex-wrap: wrap; row-gap: 6px; }
  .official-app .topbar-actions { gap: 6px; }
}

/* Match every header action in height, type scale and vertical alignment. */
.official-app .topbar-actions > .btn {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  min-height: 36px;
  line-height: 1;
}

.official-app .topbar-actions #settingsBtn.icon-settings,
.official-app .topbar-actions #mobilePatientsBtn {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  gap: 7px;
  width: auto;
  min-width: 0;
  height: 36px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid #d9e3ec;
  border-radius: 10px;
  background: linear-gradient(180deg, #fff 0%, #f6f9fc 100%);
  color: #344b63;
  box-shadow: 0 1px 2px rgba(35, 58, 82, .08), inset 0 1px 0 rgba(255, 255, 255, .9);
  font-family: inherit;
  font-size: 13px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
}

.official-app .topbar-actions #settingsBtn [data-settings-label],
.official-app .topbar-actions #mobilePatientsBtn [data-mobile-patients-label] {
  display: inline-flex;
  align-items: center;
  font: inherit;
  line-height: 1;
}

.official-app .topbar-actions #settingsBtn svg,
.official-app .topbar-actions #mobilePatientsBtn svg {
  display: block;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
}

.official-app .topbar-actions #logoutBtn.icon-logout {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 8px;
  border-radius: 50%;
}

@media (min-width: 901px) {
  .official-app .topbar-actions #newAppointmentBtn { font-family: inherit; font-size: 13px; }
}

@media (max-width: 900px) {
  .official-app .topbar-actions > .btn { height: 38px; min-height: 38px; }
  .official-app .topbar-actions #settingsBtn.icon-settings,
  .official-app .topbar-actions #mobilePatientsBtn {
    height: 38px;
    min-height: 38px;
    padding: 0 10px;
    border-radius: 12px;
    font-size: 12px;
  }
  .official-app .topbar-actions #logoutBtn.icon-logout { width: 38px; min-width: 38px; height: 38px; }
}

@media (max-width: 560px) {
  .official-app .topbar-actions #settingsBtn.icon-settings,
  .official-app .topbar-actions #mobilePatientsBtn { padding-right: 9px; padding-left: 9px; }
}

.field-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.field-heading > label { color: var(--muted); font-size: 13px; font-weight: 600; }
.field-text-action { border: 0; background: transparent; padding: 4px 0; color: #236c70; font: inherit; font-size: 12px; font-weight: 650; cursor: pointer; }
.quick-treatment-editor { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 10px; padding: 14px; border: 1px solid #bcdcd7; border-radius: 12px; background: #f5fbf9; }
.quick-treatment-editor > p, .quick-treatment-editor > .section-actions { grid-column: 1 / -1; margin: 0; font-size: 12px; line-height: 1.5; }
.quick-treatment-editor .field { margin: 0; }
.quick-treatment-editor .section-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.official-app.settings-view .settings-page-header { align-items: center; margin-bottom: 16px; }
.official-app.settings-view .settings-page-header h2 { margin: 0; font-size: 23px; }
.official-app.settings-view .settings-page-header p { margin: 5px 0 0; font-size: 13px; }
.official-app.settings-view .settings-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.official-app.settings-view .settings-tab strong { width: 100%; line-height: 1.3; white-space: normal; }
.official-app.settings-view .section-actions .btn,
.quick-treatment-editor .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; line-height: 1.25; text-align: center; }
.official-app.settings-view .treatment-list-head,
.official-app.settings-view .public-booking-list-head { display: none; }
.official-app.settings-view .public-booking-editor { margin: 0; padding: 0; border: 0; background: transparent; box-shadow: none; }
.official-app.settings-view details.treatment-setting,
.official-app.settings-view details.public-booking-setting { display: block; min-width: 0; padding: 0; border: 1px solid #dce6eb; border-radius: 12px; background: #fff; overflow: hidden; }
.catalog-row-summary { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; min-height: 58px; padding: 12px 14px; cursor: pointer; list-style: none; }
.catalog-row-summary::-webkit-details-marker { display: none; }
.catalog-row-summary strong { min-width: 0; overflow-wrap: anywhere; font-size: 14px; line-height: 1.4; color: #28414e; }
.catalog-row-summary [data-catalog-duration] { font-size: 12px; color: #607480; white-space: nowrap; }
.catalog-row-toggle { display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid #d7e6e3; border-radius: 50%; background: #f5faf9; color: #28736c; font-size: 18px; font-weight: 500; line-height: 1; }
.catalog-row-summary:hover .catalog-row-toggle { border-color: #a9d2ca; background: #eaf6f2; }
.catalog-row-summary:focus-visible { outline: 3px solid rgba(52, 148, 137, .25); outline-offset: -3px; }
details[open] > .catalog-row-summary { border-bottom: 1px solid #e4ecef; background: #f6faf9; }
.catalog-row-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(100px, .5fr); gap: 12px; padding: 14px; }
.catalog-row-fields .field { min-width: 0; margin: 0; gap: 5px; }
.catalog-row-fields .field > span { color: #536a77; font-size: 12px; font-weight: 600; }
.catalog-row-fields .catalog-name-field, .catalog-row-fields .catalog-optional-note { grid-column: 1 / -1; }
.catalog-row-fields input, .catalog-row-fields select, .catalog-row-fields textarea { width: 100%; min-width: 0; min-height: 40px; font-size: 14px; }
.catalog-row-fields textarea { resize: vertical; }
.official-app.settings-view [data-settings-panel="treatments"] > .catalog-actions,
.official-app.settings-view .public-booking-editor > .catalog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin: 16px 0 12px; }
.official-app.settings-view .catalog-actions > .btn { width: auto; min-height: 34px; padding: 7px 10px; border-radius: 9px; font-size: 13px; line-height: 1.25; }
.official-app.settings-view .catalog-row-fields [data-public-booking-note] { height: 42px; min-height: 42px; resize: none; overflow-y: auto; padding: 8px 10px; font-size: 13px; line-height: 1.4; }
.official-app.settings-view .catalog-optional-note > summary { width: fit-content; color: #28736c; font-size: 12px; font-weight: 600; cursor: pointer; }
.official-app.settings-view .catalog-optional-note[open] > .field { margin-top: 8px; }
.official-app.settings-view .catalog-row-fields .btn,
.official-app.settings-view .catalog-row-fields .icon-btn { height: 34px; min-height: 34px; padding: 6px 10px; border-radius: 8px; font-size: 13px; line-height: 1.25; }
.official-app.settings-view .catalog-row-fields .public-booking-row-actions .icon-btn { width: 34px; min-width: 34px; }
.catalog-row-fields .catalog-delete-btn { justify-self: end; align-self: end; min-height: 40px; }
.catalog-row-fields .public-booking-active { display: inline-flex; align-items: center; gap: 5px; grid-column: auto; min-height: 34px; padding: 0 3px; font-size: 12px; }
.catalog-row-fields .public-booking-active input { width: 18px; min-height: 18px; height: 18px; margin: 0; }
.catalog-row-fields .public-booking-row-actions { width: 100%; grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: nowrap; }
.official-app.settings-view #patientsPanel { scroll-margin-top: 100px; }
@media (max-width: 900px) {
  .official-app.settings-view .settings-page { padding: 14px 10px 24px; }
  .official-app.settings-view .settings-page-header { display: block; margin-bottom: 14px; }
  .official-app.settings-view .settings-page-header #closeSettingsBtn { display: none; }
  .official-app.settings-view .settings-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; margin: 0 0 4px; padding: 0; gap: 8px; overflow: visible; }
  .official-app.settings-view .settings-tab { width: 100%; min-width: 0; min-height: 46px; padding: 10px 8px; border-radius: 10px; font-size: 13px; text-align: center; }
  .official-app.settings-view .settings-tab strong { font-size: 13px; white-space: normal; }
  .official-app.settings-view .settings-tab.active { border-color: #69b7ad; background: #eaf6f2; color: #235f5b; box-shadow: inset 0 0 0 1px #69b7ad; }
  .official-app.settings-view .settings-card { padding: 16px 12px; }
  .official-app.settings-view .catalog-row-summary { padding: 11px 10px; gap: 8px; }
  .official-app.settings-view .catalog-row-fields { padding: 12px 10px; }
  .official-app.settings-view .public-booking-link-card { margin: 12px 0; padding: 12px; }
  .official-app.settings-view .public-booking-link-card a { overflow-wrap: anywhere; }
  .official-app.settings-view .section-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .official-app.settings-view .section-actions > .btn { flex: 1 1 140px; min-height: 42px; }
}

@media (max-width: 380px) {
  .official-app .topbar-actions { grid-column: 1 / -1; flex-wrap: nowrap; justify-content: flex-start; gap: 4px; }
  .official-app .topbar-actions > .btn { height: 36px; min-height: 36px; padding: 0 6px; font-size: 11px; }
  .official-app .topbar-actions #settingsBtn.icon-settings,
  .official-app .topbar-actions #mobilePatientsBtn { height: 36px; min-height: 36px; padding: 0 6px; gap: 5px; font-size: 11px; }
  .official-app .topbar-actions #settingsBtn svg,
  .official-app .topbar-actions #mobilePatientsBtn svg { width: 16px; height: 16px; flex-basis: 16px; }
  .official-app .topbar-actions #logoutBtn.icon-logout { width: 36px; min-width: 36px; height: 36px; padding: 8px; }
  .quick-treatment-editor { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .official-app.settings-view [data-settings-panel="treatments"] > .catalog-actions,
  .official-app.settings-view .public-booking-editor > .catalog-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 16px 0 12px; }
  .official-app.settings-view .catalog-actions > .btn { width: 100%; min-height: 38px; padding: 7px 8px; font-size: 12px; }
}

/* Fill the existing desktop notes column without increasing the appointment panel. */
@media (min-width: 901px) {
  .appointment-details-right { grid-template-rows: minmax(0, 1fr); align-content: stretch; }
  .appointment-details-right .appointment-notes-field { grid-template-rows: auto minmax(0, 1fr); }
  .appointment-notes-field textarea { height: 100%; min-height: 76px; resize: none; }
}
