/* Paleta y tokens: ver master.css (archivo maestro).
   Este archivo concentra componentes; el responsive base vive en master.css. */
:root {
  /* Tokens duplicados solo como respaldo si master.css no carga */
  --mist: #90afc5;
  --stone: #336b87;
  --shadow: #2a3132;
  --autumn: #763626;

  --mist-soft: #c5d7e4;
  --mist-wash: #e8f0f5;
  --stone-deep: #254d63;
  --autumn-soft: #a45a45;

  --bg: #eef3f6;
  --surface: #fafcfd;
  --surface-elevated: #ffffff;
  --text: var(--shadow);
  --text-muted: #5a6a6d;
  --border: color-mix(in srgb, var(--mist) 55%, white);
  --focus: color-mix(in srgb, var(--stone) 35%, transparent);

  --danger: var(--autumn);
  --success: #2f6b4f;
  --warning: #8a5a2b;

  --radius: 6px;
  --radius-lg: 12px;
  --shadow-soft: 0 10px 30px rgba(42, 49, 50, 0.08);
  --header-h: 4.25rem;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Sora", "Segoe UI", sans-serif;
  --container: 1180px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  min-height: 100vh;
  position: relative;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.container {
  width: min(100% - 2rem, var(--container));
  margin-inline: auto;
}

/* Atmósfera de fondo (niebla / montaña) */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, color-mix(in srgb, var(--mist) 45%, transparent), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 0%, color-mix(in srgb, var(--stone) 22%, transparent), transparent 50%),
    linear-gradient(180deg, #f4f8fa 0%, var(--bg) 40%, #e6eef3 100%);
}

/* Utility bar */
.utility-bar {
  background: var(--shadow);
  color: color-mix(in srgb, var(--mist) 80%, white);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.utility-bar__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 2rem;
  padding-block: 0.35rem;
}

.utility-bar__links {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.utility-bar a {
  color: var(--mist);
  text-decoration: none;
}

.utility-bar a:hover {
  color: #fff;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface-elevated) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: var(--header-h);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.brand__mark {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 8px;
  background:
    linear-gradient(145deg, var(--stone) 0%, var(--stone-deep) 55%, var(--shadow) 100%);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--mist) 40%, transparent);
  position: relative;
}

.brand__mark::after {
  content: "";
  position: absolute;
  inset: 28% 30% 28% 30%;
  border: 2px solid var(--mist);
  border-radius: 3px;
  border-bottom-width: 4px;
}

.brand__name {
  display: block;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  color: var(--shadow);
  line-height: 1.1;
}

.brand__tag {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--stone);
  font-weight: 600;
}

.primary-nav__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  list-style: none;
}

.nav-link,
.sidebar-link {
  appearance: none;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.nav-link:hover,
.sidebar-link:hover {
  color: var(--stone);
  background: var(--mist-wash);
}

.nav-link.active,
.sidebar-link.active {
  color: #fff;
  background: var(--stone);
}

.nav-toggle {
  display: none;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
}

.nav-toggle__bar {
  display: block;
  width: 1.1rem;
  height: 2px;
  background: var(--shadow);
}

/* Page hero */
.page-hero {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(120deg, color-mix(in srgb, var(--shadow) 92%, transparent) 0%, color-mix(in srgb, var(--stone) 88%, transparent) 55%, color-mix(in srgb, var(--stone-deep) 90%, transparent) 100%);
  color: #fff;
}

.page-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 85% 20%, color-mix(in srgb, var(--mist) 35%, transparent), transparent 40%),
    linear-gradient(180deg, transparent 60%, rgba(42, 49, 50, 0.25));
  pointer-events: none;
}

.page-hero__inner {
  position: relative;
  padding: 2.25rem 0 2.5rem;
  animation: rise 0.55s ease both;
}

.page-hero__eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--mist);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.page-hero__title {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3vw, 2.4rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 0.5rem;
}

.page-hero__lead {
  max-width: 36rem;
  color: color-mix(in srgb, var(--mist) 75%, white);
  font-size: 0.98rem;
}

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

/* Layout shell */
.layout {
  padding: 1.75rem 0 3.5rem;
}

.layout__grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 1rem);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-soft);
  animation: rise 0.6s ease 0.05s both;
}

.sidebar__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.sidebar__nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 1.25rem;
}

.sidebar-link {
  width: 100%;
  text-align: left;
  border-radius: var(--radius);
}

.sidebar__note {
  background: var(--mist-wash);
  border-left: 3px solid var(--autumn);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.85rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.sidebar__note strong {
  display: block;
  color: var(--shadow);
  margin-bottom: 0.4rem;
  font-size: 0.78rem;
}

.sidebar__note ol {
  margin-left: 1rem;
  display: grid;
  gap: 0.25rem;
}

.content {
  min-width: 0;
  animation: rise 0.65s ease 0.08s both;
}

.panel {
  display: none;
}

.panel.active {
  display: grid;
  gap: 1.25rem;
}

/* Surfaces (no card clutter — clean institutional blocks) */
.surface {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.surface__head {
  padding: 0.9rem 1.15rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fff, var(--mist-wash));
}

.surface__head h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 650;
  color: var(--shadow);
}

.surface__body {
  padding: 1.15rem;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
}

.stat-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--stone);
}

.stat-card.accent::before {
  background: var(--autumn);
}

.stat-card__value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 650;
  color: var(--stone);
  line-height: 1;
}

.stat-card.accent .stat-card__value {
  color: var(--autumn);
}

.stat-card__label {
  margin-top: 0.45rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 0.85rem;
  align-items: end;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

input,
select,
textarea {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--stone);
  box-shadow: 0 0 0 3px var(--focus);
}

.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: end;
}

@media (max-width: 760px) {
  .filters {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .filters .btn {
    width: 100%;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions .btn {
    width: 100%;
  }
}

/* Buttons */
.btn {
  padding: 0.55rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--stone);
  color: #fff;
}

.btn-primary:hover {
  background: var(--stone-deep);
}

.btn-danger {
  background: var(--autumn);
  color: #fff;
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--autumn) 85%, black);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--shadow);
}

.btn-ghost:hover {
  border-color: var(--stone);
  color: var(--stone);
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
}

/* Tables */
.table-wrap,
#doctors-table,
#patients-table,
#schedules-table,
#appointments-table,
#payments-table,
#dashboard-appointments {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead {
  background: var(--mist-wash);
}

th,
td {
  padding: 0.7rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--stone);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--mist) 12%, white);
}

.badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-scheduled { background: color-mix(in srgb, var(--mist) 35%, white); color: var(--stone-deep); }
.badge-completed { background: #d9ebe2; color: var(--success); }
.badge-cancelled { background: color-mix(in srgb, var(--autumn) 18%, white); color: var(--autumn); }
.badge-no_show { background: #f0e6d8; color: var(--warning); }

.badge-pending { background: #f0e6d8; color: var(--warning); }
.badge-paid { background: #d9ebe2; color: var(--success); }
.badge-partial { background: color-mix(in srgb, var(--mist) 35%, white); color: var(--stone-deep); }
.badge-exempt { background: var(--mist-wash); color: var(--shadow); }
.badge-refund_pending { background: color-mix(in srgb, var(--autumn) 18%, white); color: var(--autumn); }

.actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.8rem 1.2rem;
  border-radius: var(--radius);
  color: #fff;
  font-size: 0.875rem;
  z-index: 100;
  animation: slideIn 0.3s ease;
  max-width: 400px;
  box-shadow: var(--shadow-soft);
}

.toast.success { background: var(--success); }
.toast.error { background: var(--autumn); }

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

/* Footer */
.site-footer {
  background: var(--shadow);
  color: color-mix(in srgb, var(--mist) 70%, white);
  margin-top: auto;
}

.site-footer__grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 2rem;
  padding: 2.5rem 0 2rem;
}

.site-footer__brand {
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: #fff;
  margin-bottom: 0.5rem;
}

.site-footer__desc {
  font-size: 0.9rem;
  max-width: 22rem;
}

.site-footer__heading {
  color: var(--mist);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.site-footer ul {
  list-style: none;
  display: grid;
  gap: 0.4rem;
  font-size: 0.875rem;
}

.site-footer a {
  color: #fff;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--mist);
}

.site-footer__base {
  border-top: 1px solid color-mix(in srgb, var(--mist) 25%, transparent);
  padding: 0.9rem 0;
  font-size: 0.78rem;
}

/* Responsive */
@media (max-width: 960px) {
  .layout__grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: none;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .site-footer__grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

@media (max-width: 760px) {
  .nav-toggle {
    display: inline-flex;
  }

  .primary-nav {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: var(--surface-elevated);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem 1rem;
    box-shadow: var(--shadow-soft);
  }

  .primary-nav.is-open {
    display: block;
  }

  .primary-nav__list {
    flex-direction: column;
  }

  .nav-link {
    width: 100%;
    text-align: left;
    border-radius: var(--radius);
  }

  .site-header {
    position: relative;
  }
}

@media (max-width: 520px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .utility-bar__item {
    display: none;
  }
}

/* ========== Login ========== */
.auth-body,
.loading-body,
.error-body {
  min-height: 100vh;
}

.auth-body--video {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
}

.auth-body--video .atmosphere {
  display: none;
}

.auth-video {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  min-width: 100%;
  min-height: 100%;
  object-fit: cover;
  object-position: center center;
  z-index: 0;
  pointer-events: none;
  background: var(--shadow);
}

.auth-video-veil {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: rgba(42, 49, 50, 0.22);
}

.auth-shell {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
}

.auth-shell--overlay {
  display: grid;
  place-items: center;
  grid-template-columns: 1fr;
  padding: 1.5rem;
  width: 100%;
  box-sizing: border-box;
}

.auth-card {
  width: min(100%, 420px);
  padding: 1.6rem 1.45rem 1.4rem;
  border-radius: var(--radius-lg);
  background: rgba(250, 252, 253, 0.78);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(144, 175, 197, 0.45);
  box-shadow: 0 18px 50px rgba(42, 49, 50, 0.28);
  color: var(--shadow);
}

.auth-card--bare {
  background: transparent;
  backdrop-filter: none;
  border: 0;
  box-shadow: none;
  color: #fff;
  text-shadow: 0 1px 10px rgba(42, 49, 50, 0.45);
}

.auth-card--bare .auth-brand__name,
.auth-card--bare .auth-form-title {
  color: #fff;
}

.auth-card--bare .auth-brand__tag,
.auth-card--bare .auth-kicker,
.auth-card--bare .auth-form-lead,
.auth-card--bare label {
  color: rgba(255, 255, 255, 0.9);
}

.auth-card--bare input,
.auth-card--bare select {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
  text-shadow: none;
}

.auth-card--bare input::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

.auth-card--bare input:focus {
  border-color: var(--mist);
  box-shadow: 0 0 0 3px rgba(144, 175, 197, 0.35);
  background: rgba(255, 255, 255, 0.2);
}

.auth-card--bare .btn-primary {
  background: #b42318;
  border-color: #b42318;
  color: #fff;
}

.auth-card--bare .btn-primary:hover {
  background: #912018;
  border-color: #912018;
}

.auth-card--bare .brand__mark {
  background: linear-gradient(145deg, #d92d20 0%, #b42318 55%, #912018 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.auth-card--bare .brand__mark::after {
  border-color: #fff;
}

.auth-password-field {
  position: relative;
  display: block;
}

.auth-password-field input {
  width: 100%;
  padding-right: 2.75rem;
}

.auth-password-toggle {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  width: 2.1rem;
  height: 2.1rem;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  padding: 0;
}

.auth-password-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.auth-password-toggle .eye-icon {
  display: block;
}

.auth-password-toggle .eye-slash {
  opacity: 1;
  transition: opacity 0.15s ease;
}

.auth-password-toggle.is-open .eye-slash {
  opacity: 0;
}

.auth-card .auth-brand {
  margin-bottom: 1.15rem;
}

.auth-card .auth-form {
  max-width: none;
}

.auth-card--bare .auth-brand__name,
.auth-card--bare .auth-brand__tag,
.auth-card--bare .auth-form-title {
  color: #ffffff !important;
}

.auth-card--bare .auth-brand__tag {
  color: #ffffff !important;
  opacity: 0.95;
}

.auth-panel {
  padding: clamp(1.5rem, 4vw, 3.5rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-panel--brand {
  background: transparent;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.auth-panel--brand::after {
  display: none;
}

.auth-body--video .auth-panel--form {
  background: transparent;
  backdrop-filter: none;
  border-left: 0;
  box-shadow: none;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 2rem;
  position: relative;
  z-index: 1;
}

.auth-brand__name {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 650;
}

.auth-brand__tag {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mist);
  font-weight: 600;
}

.auth-panel__title {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  line-height: 1.15;
  max-width: 16ch;
  margin-bottom: 0.85rem;
  position: relative;
  z-index: 1;
}

.auth-panel__lead {
  color: color-mix(in srgb, var(--mist) 80%, white);
  max-width: 34rem;
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 1;
}

.auth-highlights {
  list-style: none;
  display: grid;
  gap: 0.55rem;
  position: relative;
  z-index: 1;
}

.auth-highlights li {
  padding-left: 1rem;
  border-left: 2px solid var(--autumn);
  color: color-mix(in srgb, var(--mist) 75%, white);
  font-size: 0.92rem;
}

.auth-panel--form {
  background: color-mix(in srgb, var(--surface-elevated) 92%, transparent);
  backdrop-filter: blur(8px);
}

.auth-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--stone);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.auth-form-title {
  font-family: var(--font-display);
  font-size: 1.85rem;
  color: var(--shadow);
  margin-bottom: 0.35rem;
}

.auth-form-lead {
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.auth-form {
  display: grid;
  gap: 0.9rem;
  max-width: 24rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
  margin-top: 0.35rem;
}

.auth-alert {
  max-width: 24rem;
  margin-bottom: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--autumn) 14%, white);
  border: 1px solid color-mix(in srgb, var(--autumn) 35%, white);
  color: var(--autumn);
  font-size: 0.88rem;
}

.auth-demo {
  margin-top: 1.5rem;
  max-width: 24rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: var(--mist-wash);
  border: 1px dashed var(--mist);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.auth-demo strong {
  display: block;
  color: var(--shadow);
  margin-bottom: 0.2rem;
}

.auth-footnote {
  margin-top: 1.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.auth-footnote a {
  color: var(--stone);
}

.auth-accounts {
  margin-top: 1.5rem;
  max-width: 28rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  background: var(--mist-wash);
  border: 1px solid var(--border);
  font-size: 0.82rem;
}

.auth-accounts strong {
  display: block;
  margin-bottom: 0.65rem;
  color: var(--shadow);
}

.auth-accounts ul {
  list-style: none;
  display: grid;
  gap: 0.55rem;
}

.auth-accounts li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

.auth-pass {
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
}

.role-pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--stone);
  color: #fff;
}

.role-pill--admin { background: var(--shadow); }
.role-pill--director { background: var(--stone); }
.role-pill--doctor { background: color-mix(in srgb, var(--mist) 20%, var(--stone)); }
.role-pill--patient { background: var(--autumn); }

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.profile-grid dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.profile-grid dd {
  font-weight: 600;
  color: var(--shadow);
}

.utility-user {
  color: var(--mist);
}

/* ========== Profile avatar menu ========== */
.profile-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
  z-index: 50;
}

.profile-avatar {
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--mist) 70%, white);
  background: linear-gradient(145deg, var(--stone), var(--shadow));
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.profile-avatar:hover,
.profile-menu.is-open .profile-avatar {
  transform: scale(1.04);
  border-color: #fff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mist) 35%, transparent);
}

.profile-avatar--lg {
  width: 3.25rem;
  height: 3.25rem;
  font-size: 0.95rem;
  cursor: default;
  pointer-events: none;
}

.profile-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.55rem);
  width: min(18.5rem, calc(100vw - 1.5rem));
  background: var(--surface-elevated);
  color: var(--shadow);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  animation: rise 0.2s ease;
}

.profile-dropdown__head {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.95rem 1rem;
  background: linear-gradient(180deg, #fff, var(--mist-wash));
  border-bottom: 1px solid var(--border);
}

.profile-dropdown__avatar {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--stone), var(--shadow));
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.profile-dropdown__name {
  font-weight: 650;
  font-size: 0.92rem;
  line-height: 1.2;
  color: var(--shadow);
}

.profile-dropdown__meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  word-break: break-all;
}

.profile-dropdown__list {
  list-style: none;
  padding: 0.4rem;
  margin: 0;
}

.profile-dropdown__item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--shadow);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
}

.profile-dropdown__item:hover {
  background: var(--mist-wash);
  color: var(--stone);
}

.profile-dropdown__item--danger {
  color: var(--autumn);
}

.profile-dropdown__item--danger:hover {
  background: color-mix(in srgb, var(--autumn) 12%, white);
  color: var(--autumn);
}

.profile-dropdown__divider {
  height: 1px;
  margin: 0.35rem 0.5rem;
  background: var(--border);
}

.profile-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: calc(100vw - 2rem);
}

.profile-dialog::backdrop {
  background: color-mix(in srgb, var(--shadow) 45%, transparent);
  backdrop-filter: blur(2px);
}

.profile-dialog__card {
  width: min(420px, 100%);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.profile-dialog__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fff, var(--mist-wash));
}

.profile-dialog__head h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--shadow);
}

.profile-dialog__close {
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.15rem 0.4rem;
}

.profile-dialog__body {
  padding: 1.1rem 1rem;
  display: grid;
  gap: 0.85rem;
}

.profile-dialog__preview {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  margin-bottom: 0.25rem;
}

.profile-dialog__hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.profile-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.85rem 1rem 1rem;
  border-top: 1px solid var(--border);
}

.profile-account-list {
  list-style: none;
  display: grid;
  gap: 0.55rem;
}

.profile-account-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.88rem;
  padding: 0.55rem 0.65rem;
  background: var(--mist-wash);
  border-radius: var(--radius);
}

.profile-account-list code {
  font-size: 0.8rem;
  color: var(--stone-deep);
}

.utility-bar__links {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

/* Media library */
.media-upload-form .media-file-label input[type="file"] {
  padding: 0.45rem;
}

.media-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.media-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
}

.media-card__preview {
  aspect-ratio: 16 / 10;
  background: var(--mist-wash);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.media-card__preview img,
.media-card__preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-card__meta {
  padding: 0.75rem 0.85rem 0.35rem;
  display: grid;
  gap: 0.2rem;
}

.media-card__meta strong {
  font-size: 0.9rem;
  color: var(--shadow);
}

.media-card__meta span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.media-card__who {
  word-break: break-all;
}

.media-card__actions {
  padding: 0.55rem 0.85rem 0.85rem;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* ========== Loading page + overlay ========== */
.loading-shell,
.error-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.loading-card,
.error-card {
  width: min(100%, 420px);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 2rem 1.75rem;
  text-align: center;
}

.loading-brand {
  justify-content: center;
  margin-bottom: 1.5rem;
}

.loader {
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 1.25rem;
  position: relative;
}

.loader__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--mist) 45%, transparent);
  border-top-color: var(--stone);
  animation: spin 0.9s linear infinite;
}

.loader__ring--delay {
  inset: 8px;
  border-top-color: var(--autumn);
  animation-duration: 1.25s;
  animation-direction: reverse;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--shadow);
  margin-bottom: 0.4rem;
}

.loading-lead {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.loading-steps {
  display: flex;
  justify-content: center;
  gap: 0.45rem;
  margin-bottom: 1.1rem;
}

.loading-step {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: var(--mist-wash);
  color: var(--text-muted);
  font-weight: 600;
}

.loading-step.is-active {
  background: var(--stone);
  color: #fff;
}

.loading-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--mist-wash);
  overflow: hidden;
  margin-bottom: 1rem;
}

.loading-bar span {
  display: block;
  height: 100%;
  width: 35%;
  background: linear-gradient(90deg, var(--stone), var(--mist));
  animation: loadbar 1.4s ease-in-out infinite;
}

@keyframes loadbar {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.loading-skip {
  font-size: 0.8rem;
  color: var(--stone);
}

.app-loader {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--shadow) 35%, transparent);
  backdrop-filter: blur(2px);
}

.app-loader[hidden] {
  display: none !important;
}

.app-loader__panel {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  min-width: 200px;
  text-align: center;
  box-shadow: var(--shadow-soft);
}

.app-loader__panel .loader {
  margin-bottom: 0.75rem;
}

.app-loader__panel p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ========== Error ========== */
.error-card {
  width: min(100%, 480px);
  text-align: left;
}

.error-code {
  font-family: var(--font-display);
  font-size: 3.5rem;
  line-height: 1;
  color: var(--autumn);
  margin-bottom: 0.5rem;
}

.error-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--shadow);
  margin-bottom: 0.5rem;
}

.error-message {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.error-detail {
  margin-bottom: 1.25rem;
}

.error-detail code {
  display: inline-block;
  padding: 0.35rem 0.55rem;
  background: var(--mist-wash);
  border-radius: var(--radius);
  font-size: 0.8rem;
  color: var(--stone-deep);
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

@media (max-width: 900px) {
  .auth-shell:not(.auth-shell--overlay) {
    grid-template-columns: 1fr;
  }

  .auth-panel--brand {
    min-height: auto;
    padding-bottom: 1.25rem;
  }

  .auth-panel__title {
    max-width: none;
  }

  .auth-shell--overlay {
    padding: 1rem;
    align-items: end;
    padding-bottom: 1.5rem;
  }

  .auth-card {
    width: min(100%, 440px);
  }
}

/* ========== Documentación ========== */
.docs-body {
  min-height: 100vh;
  color: var(--shadow);
}

.docs-top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, #fff 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.docs-top__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 4rem;
}

.docs-top__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  font-size: 0.88rem;
}

.docs-top__nav a {
  color: var(--stone);
  text-decoration: none;
  font-weight: 600;
}

.docs-top__nav a:hover {
  color: var(--shadow);
}

.docs-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 1.5rem;
  padding: 1.5rem 0 3rem;
  align-items: start;
}

.docs-toc {
  position: sticky;
  top: 5rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-soft);
}

.docs-toc__title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 0.6rem;
}

.docs-toc ol {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.35rem;
  font-size: 0.82rem;
}

.docs-toc a {
  color: var(--stone);
  text-decoration: none;
}

.docs-toc a:hover {
  color: var(--autumn);
}

.docs-main {
  min-width: 0;
}

.docs-hero {
  margin-bottom: 1.75rem;
}

.docs-kicker {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--stone);
  font-weight: 700;
}

.docs-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  margin: 0.35rem 0 0.6rem;
}

.docs-lead {
  max-width: 52rem;
  color: var(--text-muted);
}

.docs-meta {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--stone);
}

.docs-section {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem 1.4rem;
  margin-bottom: 1.15rem;
  box-shadow: var(--shadow-soft);
}

.docs-section h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  color: var(--shadow);
}

.docs-section h3 {
  font-size: 1rem;
  margin: 1rem 0 0.45rem;
  color: var(--stone-deep);
}

.docs-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.docs-card {
  background: var(--mist-wash);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}

.docs-card--tight {
  margin-bottom: 0.85rem;
}

.docs-card ul {
  margin-left: 1rem;
}

.docs-code {
  background: #1e2728;
  color: #e8f0f5;
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.45;
  margin: 0.5rem 0 0.75rem;
}

.docs-table-wrap {
  overflow-x: auto;
}

.docs-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.docs-table-wrap th,
.docs-table-wrap td {
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0.45rem;
  text-align: left;
  vertical-align: top;
}

.docs-note {
  margin-top: 0.85rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.docs-steps {
  margin-left: 1.15rem;
  display: grid;
  gap: 0.55rem;
}

.docs-footer {
  margin-top: 1.5rem;
  padding: 1rem 0 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.method {
  display: inline-block;
  min-width: 3.4rem;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: #fff;
  background: var(--stone);
}

.method--get { background: #2f6b4f; }
.method--post { background: var(--stone); }
.method--put, .method--patch { background: #8a5a2b; }
.method--delete { background: var(--autumn); }

@media (max-width: 900px) {
  .docs-layout {
    grid-template-columns: 1fr;
  }

  .docs-toc {
    position: static;
  }

  .docs-grid-2 {
    grid-template-columns: 1fr;
  }
}

