: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: 68px;
  height: 68px;
  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);
}

.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;
}

.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;
}

.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: 42px;
  padding: 10px 16px;
  font: 650 14px / 1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.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;
}

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; gap: 8px; width: 100%; }
.demo-guide-title span, .demo-guide-note { color: #49627d; }
.demo-guide-steps { display: flex; flex-wrap: wrap; 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; }

.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) #settingsBtn,
body.auth-required:not(.authenticated) .layout {
  display: none !important;
}

body.auth-required:not(.authenticated) .topbar > .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;
}

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 {
  margin-bottom: 0;
}

.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);
}

.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: #c8b5f5;
}

.key-dot.doctor-2 {
  background: #d99a86;
}

.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; }

.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;
}

.appointments-grid.week-view {
  display: grid;
  grid-template-columns: repeat(5, minmax(210px, 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-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;
}

.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: 54px 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: 13px;
  line-height: 1.2;
}

.week-copy small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.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;
}

.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-main > div:last-child { min-width: 0; }
.appointment-patient-heading h3 { flex: 0 1 auto; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.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;
}

.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;
}

.patient-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 7px 8px;
  font-size: 13px;
  cursor: pointer;
}

.patient-item strong {
  display: block;
  margin-bottom: 2px;
}

.patient-item small {
  color: var(--muted);
  font-size: 11px;
}

#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;
}

.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));
}

.patient-dialog { width: min(590px, calc(100vw - 28px)); }
.patient-form-dialog { width: min(500px, calc(100vw - 28px)); }
.patient-dialog .dialog-body,
.login-dialog form,
.patient-form-dialog form { padding: 14px; }
.patient-dialog .dialog-header h2,
.login-dialog .dialog-header h2,
.patient-form-dialog .dialog-header h2 { font-size: 18px; }
.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-form-dialog .field { gap: 4px; margin-bottom: 8px; }
.patient-form-dialog input,
.patient-form-dialog textarea { padding: 7px 9px; }
.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;
}

/* 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-dialog .dialog-subtitle {
  margin: 0;
}

.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 .field {
  margin: 0;
}
.appointment-section .field:has(#patientName) { position: relative; }

.appointment-extras {
  background: #fff;
}

.appointment-form-grid {
  gap: 8px 10px;
}
.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(155px, .8fr) minmax(0, 2fr); gap: 10px; align-items: start; width: 100%; }
.patient-contact-row .field { margin: 0; }
.appointment-notes-grid { align-items: start; }
.appointment-notes-grid > .field { align-self: start; }
.appointment-change-field { align-self: end; min-height: 38px; margin: 0 0 12px; }
.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(230px, 1.15fr) minmax(0, 1.85fr); gap: 14px; margin-top: 8px; align-items: start; }
.appointment-details-left { display: grid; gap: 8px; align-content: start; }
.appointment-date-time-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.appointment-details-left .field, .appointment-notes-field { margin: 0; }
.appointment-notes-field textarea { min-height: 76px; height: 76px; }
.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; }

.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;
}

@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 {
  font-size: 18px;
}

#reminderDialog .dialog-subtitle {
  font-size: 13px;
}

#reminderDialog input,
#reminderDialog select,
#reminderDialog textarea {
  padding: 8px 9px;
}

#reminderDialog textarea {
  min-height: 78px;
}

#reminderDialog .btn {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.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 12px;
  padding: 10px 12px;
  border: 1px solid #efbfd3;
  border-radius: 8px;
  background: #fff8fb;
}

.column-header-actions { display: flex; align-items: center; gap: 6px; }
.column-reminder-btn { border: 1px solid #efbfd3; border-radius: 5px; background: #fff3f8; color: #a12d5b; cursor: pointer; padding: 6px 8px; font-size: 11px; font-weight: 700; }
.column-reminder-btn:hover { border-color: #dc91b0; background: #ffe8f1; color: #82234a; }

.internal-reminders-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.internal-reminders-header h3 { margin: 0; font-size: 14px; }
.internal-reminders-header span { color: var(--muted); font-size: 11px; }
.internal-reminders-list { display: grid; gap: 6px; }
.internal-reminder { display: flex; align-items: center; gap: 8px; min-height: 34px; border-bottom: 1px solid #f2d5e1; cursor: pointer; padding: 4px 2px; }
.internal-reminder:last-child { border-bottom: 0; }
.internal-reminder:hover { background: #ffedf4; }
.internal-reminder-text { flex: 1; font-size: 13px; }
.internal-reminder small { color: var(--muted); font-size: 11px; }
.internal-reminder.completed .internal-reminder-text { color: var(--muted); text-decoration: line-through; }
.reminder-complete, .reminder-delete { border: 0; background: transparent; cursor: pointer; }
.reminder-complete { width: 24px; height: 24px; color: #94a3b8; font-size: 18px; font-weight: 800; line-height: 1; padding: 0; }
.reminder-complete.active { color: #16a34a; }
.reminder-complete:hover { color: #15803d; }
.reminder-delete { width: 22px; height: 22px; color: #94a3b8; padding: 3px; }
.reminder-delete svg { width: 14px; height: 14px; 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;
}

.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;
}

.patient-appointments {
  display: grid;
  gap: 16px;
}

.patient-appointment-group h3 {
  margin: 0 0 8px;
  color: #344256;
  font-size: 15px;
}

.patient-appointment {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  padding: 11px;
  text-align: left;
}

.patient-appointment span {
  color: var(--muted);
}

.patient-appointment small {
  color: var(--muted);
}

@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) {
  .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 {
    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; }
.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%; }
.overlap-mode-setting { border: 1px solid #dbe4ef; display: grid; gap: .55rem; background: #fafbff; }
.overlap-mode-setting { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.column-reminder-btn { border: 1px solid #b8c7d9; border-radius: 6px; background: #fff; color: #344256; font-size: 12px; font-weight: 700; padding: 6px 8px; }
.column-reminder-btn:hover { border-color: #8fa3ba; background: #f1f5f9; color: #223044; }

.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: relative;
}

.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 .topbar > .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 { position: relative; }
.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: absolute;
  top: 29px;
  right: -14px;
  margin-left: 0;
}
.official-app .topbar-title h1 { display: inline-block; margin-right: 0; }
.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: none; }
.official-app.settings-view .topbar > .toolbar { display: flex; }
.official-app.settings-view .topbar > .toolbar .view-switch,
.official-app.settings-view .topbar > .toolbar .segmented,
.official-app.settings-view .topbar > .toolbar .toolbar-tool-btn { display: none; }
.official-app.settings-view .settings-page-header { display: none; }
.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 .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) {
  .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 .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 .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 .column-reminder-btn { display: none; }
  .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: 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-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-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;
  }

  #reminderDialog form { padding: 14px; }
  #reminderDialog .dialog-actions { flex-direction: row; }
  #reminderDialog .dialog-actions .btn { min-height: 38px; }

  .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) {
  .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; }
select#appointmentTime option:not(.occupied-time) { color: #111827; background: #fff; }
