/* Pulido de interfaz transversal: jerarquía, consistencia, accesibilidad y sensación de producto. */
:root {
  --primary-soft: #e8f6fa;
  --primary-ring: rgba(23, 107, 135, .22);
  --success: #167353;
  --warning: #8a5b00;
  --danger-soft: #fff1f0;
  --surface-2: #f8fcfe;
  --surface-3: #eef8fb;
  --shadow-sm: 0 8px 22px rgba(31, 72, 95, .08);
  --shadow-md: 0 18px 46px rgba(31, 72, 95, .13);
}

html {
  scroll-behavior: smooth;
}

body {
  letter-spacing: -.01em;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 12% 8%, rgba(57, 166, 163, .16), transparent 28rem),
    radial-gradient(circle at 92% 16%, rgba(23, 107, 135, .11), transparent 30rem);
}

::selection {
  background: #bdeaf0;
  color: #082f3d;
}

a,
.btn,
.panel,
.metric-card,
.module-card,
.appointment-card,
.quick-action,
.quick-chip,
.date-option,
.time-slot {
  transition: color .16s ease, background-color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.app-header {
  box-shadow: 0 10px 28px rgba(16, 37, 63, .05);
}

.navbar {
  padding: .7rem 0;
}

.navbar-brand span {
  letter-spacing: -.025em;
}

.app-menu-toggle {
  position: relative;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid #c6dfe8;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  box-shadow: 0 6px 16px rgba(23, 107, 135, .1);
}

.app-menu-toggle:hover,
.app-menu-toggle:focus-visible {
  border-color: #8fc3d2;
  background: #dff2f7;
  box-shadow: 0 0 0 .23rem var(--primary-ring);
}

.app-menu-toggle:focus {
  box-shadow: 0 0 0 .23rem var(--primary-ring);
}

.app-menu-toggle-lines {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 5px;
}

.app-menu-toggle-lines i {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transition: transform .2s ease, opacity .16s ease;
}

.app-menu-toggle[aria-expanded="true"] .app-menu-toggle-lines i:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.app-menu-toggle[aria-expanded="true"] .app-menu-toggle-lines i:nth-child(2) {
  opacity: 0;
}

.app-menu-toggle[aria-expanded="true"] .app-menu-toggle-lines i:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.nav-link {
  position: relative;
}

.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary-dark);
  box-shadow: inset 0 0 0 1px rgba(23, 107, 135, .09);
}

.nav-link.active::after {
  content: "";
  position: absolute;
  left: .75rem;
  right: .75rem;
  bottom: .22rem;
  height: 2px;
  border-radius: 999px;
  background: var(--primary);
}

.user-menu {
  padding: .35rem .45rem .35rem .8rem;
  border: 1px solid #e0ecf2;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 7px 20px rgba(31, 72, 95, .06);
}

.app-content {
  padding-top: 2.25rem;
}

.page-heading {
  position: relative;
  margin-bottom: 1.6rem;
  padding: 1.05rem 1.15rem;
  border: 1px solid rgba(219, 231, 238, .95);
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(255, 255, 255, .92), rgba(247, 252, 254, .78));
  box-shadow: var(--shadow-sm);
}

.page-heading::before {
  content: "";
  position: absolute;
  left: 1.15rem;
  top: 1rem;
  width: 44px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.page-heading h1 {
  padding-top: .45rem;
  letter-spacing: -.035em;
}

.page-heading p {
  max-width: 760px;
}

.panel,
.metric-card,
.module-card {
  border-color: rgba(207, 225, 232, .92);
  box-shadow: var(--shadow-sm);
}

.panel {
  position: relative;
}

.panel:hover {
  box-shadow: var(--shadow-md);
}

.metric-grid {
  align-items: stretch;
}

.metric-card {
  min-height: 122px;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: #b9d9e2;
  box-shadow: var(--shadow-md);
}

.metric-card > span {
  letter-spacing: .035em;
  text-transform: uppercase;
}

.metric-card > strong {
  letter-spacing: -.045em;
}

.module-card {
  border-radius: 20px;
}

.module-card .content {
  min-height: 174px;
}

.section-heading h2 {
  letter-spacing: -.025em;
}

.section-heading p {
  line-height: 1.45;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  min-height: 38px;
  border-radius: .8rem;
  box-shadow: none;
}

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

.btn-primary {
  box-shadow: 0 10px 22px rgba(23, 107, 135, .18);
}

.btn-primary:hover,
.btn-primary:focus {
  box-shadow: 0 14px 30px rgba(13, 79, 104, .22);
}

.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-danger,
.btn-outline-warning {
  background: #fff;
}

.btn-outline-primary:hover,
.btn-outline-secondary:hover,
.btn-outline-danger:hover,
.btn-outline-warning:hover {
  box-shadow: 0 10px 22px rgba(31, 72, 95, .09);
}

.form-control,
.form-select {
  background-color: #fff;
}

.form-control:hover,
.form-select:hover {
  border-color: #9fc7d4;
}

.form-control[readonly] {
  background: #f4f8fa;
  color: #536273;
}

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

.form-hint,
.text-muted {
  color: #61758a !important;
}

.booking-summary .form-hint {
  color: #d7eef4 !important;
}

.field-validation-error,
span[data-valmsg-for] {
  display: block;
  margin-top: .35rem;
  color: var(--danger);
  font-size: .82rem;
}

.validation-summary-errors,
.input-validation-error {
  border-color: #efb8b2 !important;
}

.input-validation-error {
  background: #fff8f7;
}

.quick-chip,
.date-option {
  box-shadow: 0 5px 14px rgba(31, 72, 95, .05);
}

.quick-chip:focus-visible,
.date-option:focus-visible,
.time-slot:focus-visible,
.specialist-option:focus-within,
.selectable-treatment:focus-within,
.btn:focus-visible,
.form-control:focus,
.form-select:focus,
.nav-link:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 .23rem var(--primary-ring);
}

.table-responsive {
  border-radius: 16px;
}

.table {
  margin-bottom: 0;
  border-collapse: separate;
  border-spacing: 0 .45rem;
}

.table thead th {
  padding: .55rem .85rem;
  border: 0;
  color: #49677b;
  background: transparent;
}

.table tbody tr {
  background: #fff;
  box-shadow: 0 5px 16px rgba(31, 72, 95, .05);
}

.table tbody tr:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(31, 72, 95, .09);
}

.table tbody td {
  padding: .85rem;
  border-top: 1px solid #e4eef4;
  border-bottom: 1px solid #e4eef4;
}

.table tbody td:first-child {
  border-left: 1px solid #e4eef4;
  border-radius: 14px 0 0 14px;
}

.table tbody td:last-child {
  border-right: 1px solid #e4eef4;
  border-radius: 0 14px 14px 0;
}

.table tfoot th {
  padding: .85rem;
  border-top: 1px solid var(--line);
}

.table-light td {
  background: #f7fafc !important;
  color: #64748b;
}

.state-text,
.status-pill,
.audit-operation,
.role-badge {
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, .55);
}

.status-pill {
  border: 1px solid rgba(22, 115, 83, .16);
}

.status-programada .status-pill,
.status-pill.status-programada {
  background: #edf8fb;
  color: #0e526b;
  border-color: #b8d5df;
}

.status-atendida .status-pill,
.status-pill.status-atendida {
  background: #edf8f3;
  color: #176b4d;
  border-color: #b8ddca;
}

.status-en-atención .status-pill,
.status-en-atencion .status-pill,
.status-pill.attention-open {
  background: #fff8e7;
  color: #73510d;
  border-color: #eed28d;
}

.status-cancelada .status-pill,
.status-pill.status-cancelada {
  background: #fff1f0;
  color: #9b2c25;
  border-color: #efc1bd;
}

.status-cancelada {
  opacity: 1;
  filter: saturate(.88);
}

.app-alert {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  border: 0;
  border-radius: 16px;
  padding: .95rem 1rem;
  box-shadow: var(--shadow-sm);
}

.app-alert > span {
  display: grid;
  place-items: center;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-weight: 900;
}

.alert-success.app-alert {
  background: #eaf8f2;
  color: #145f45;
}

.alert-success.app-alert > span {
  background: #c8efdc;
}

.alert-danger.app-alert {
  background: var(--danger-soft);
  color: #8f241c;
}

.alert-danger.app-alert > span {
  background: #ffd8d4;
}

.empty-state {
  border: 1px dashed #c6dce5;
  border-radius: 18px;
  background: linear-gradient(145deg, #fbfdfe, #f4fbfd);
}

.empty-state.compact {
  padding: 2rem 1rem;
}

.error-state {
  max-width: 720px;
  margin: 3rem auto;
}

.error-state .empty-icon {
  background: #fff1f0;
  color: #9b2c25;
}

.request-id {
  display: inline-block;
  padding: .65rem .85rem;
  border: 1px solid #dbe7ee;
  border-radius: 12px;
  background: #fff;
  color: #475569;
}

.clinical-note {
  border-left-width: 5px;
  box-shadow: inset 0 0 0 1px rgba(57, 166, 163, .08);
}

.clinical-data dt {
  letter-spacing: .07em;
}

.clinical-data dd {
  padding-bottom: .7rem;
  border-bottom: 1px solid #edf3f6;
}

.clinical-data dd:last-child {
  border-bottom: 0;
}

.timeline article {
  padding: .85rem 0 .85rem .25rem;
}

.timeline article::before {
  box-shadow: 0 0 0 5px #e9f7fa;
}

.auth-card {
  border: 1px solid rgba(255, 255, 255, .62);
}

.auth-brand h1,
.auth-form h2 {
  font-weight: 900;
  letter-spacing: -.04em;
}

.auth-form .form-control {
  min-height: 48px;
}

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

.form-section-title {
  margin: 0 0 .85rem;
  color: #314d63;
  font-size: .82rem;
  font-weight: 900;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.assist-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-top: .5rem;
}

.assist-chip {
  border: 1px solid #cfe1e8;
  border-radius: 999px;
  background: #fff;
  color: #466175;
  padding: .32rem .58rem;
  font-size: .74rem;
  font-weight: 800;
}

.assist-chip:hover,
.assist-chip:focus {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.date-strip,
.quick-filters {
  overscroll-behavior-inline: contain;
  scroll-snap-type: inline proximity;
  -webkit-overflow-scrolling: touch;
}

.date-option,
.quick-chip {
  scroll-snap-align: start;
}

.clinical-history-form textarea {
  min-height: 86px;
}

.clinical-sidebar .panel,
.clinical-form {
  border-radius: 20px;
}

.patient-clinical-card {
  background: linear-gradient(145deg, #fff, #f4fbfd);
}

.treatment-row {
  align-items: center;
  padding: .65rem;
  border: 1px solid #e4eef4;
  border-radius: 14px;
  background: #fff;
}

.treatment-row + .treatment-row {
  margin-top: .55rem;
}

.treatment-row-head {
  margin-bottom: .55rem;
  border: 0;
  background: transparent;
  color: #61758a;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.treatment-row-head:hover {
  box-shadow: none;
  transform: none;
}

.clinical-submit {
  border-radius: 0 0 20px 20px;
}

.patient-basic-profile {
  overflow: hidden;
}

.patient-avatar {
  display: inline-grid;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(145deg, #dff4f7, #eef9fb);
  color: #0e6079;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: .04em;
  box-shadow: inset 0 0 0 1px rgba(23, 107, 135, .08);
}

.profile-data-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 1.25rem 0;
  padding: 1px;
  overflow: hidden;
  border-radius: 16px;
  background: #dce9ef;
}

.profile-data-grid > div {
  min-width: 0;
  padding: 1rem 1.1rem;
  background: #f8fbfc;
}

.profile-data-grid dt {
  margin-bottom: .25rem;
  color: #61758a;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .055em;
  text-transform: uppercase;
}

.profile-data-grid dd {
  margin: 0;
  color: #10253f;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.modal-eyebrow {
  display: block;
  margin-bottom: .2rem;
  color: #61758a;
  font-size: .7rem;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.access-control-modal.fade {
  transition: opacity .24s ease-out;
}

.access-control-modal.fade .modal-dialog {
  transform: translate3d(0, 14px, 0) scale(.985);
  transition: transform .24s cubic-bezier(.2, .75, .25, 1);
}

.access-control-modal.show .modal-dialog {
  transform: none;
}

.access-control-modal .modal-content {
  overflow: hidden;
  border: 0;
  border-radius: 20px;
  box-shadow: 0 28px 80px rgba(16, 37, 63, .28);
}

.access-control-modal .modal-header {
  border-bottom: 1px solid #dce9ee;
  background: linear-gradient(145deg, #f6fbfd, #fff);
}

.access-control-modal .modal-body {
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
}

.access-user-summary {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: 1rem;
  border: 1px solid #f0c4c0;
  border-radius: 15px;
  background: #fff5f4;
}

.access-user-summary > span {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #c9363e;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 900;
}

.access-user-summary strong,
.access-user-summary p {
  display: block;
  margin: 0;
}

.access-user-summary p {
  margin-top: .15rem;
  color: #7f1d1d;
  font-size: .84rem;
}

.access-control-form {
  margin: 0;
}

.access-submit-busy {
  display: none;
}

.access-control-modal.is-submitting .modal-content {
  pointer-events: none;
}

.access-control-modal.is-submitting .access-submit-label {
  display: none;
}

.access-control-modal.is-submitting .access-submit-busy {
  display: inline;
}

body.access-control-modal-open .modal-backdrop.fade {
  transition: opacity .24s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .access-control-modal.fade,
  .access-control-modal.fade .modal-dialog,
  body.access-control-modal-open .modal-backdrop.fade {
    transition: none;
  }
}

@media (max-width: 991px) {
  .navbar > .container-xl {
    align-items: center;
  }

  .app-navigation {
    width: 100%;
    margin-top: .75rem;
    padding: .65rem;
    border: 1px solid #d7e8ef;
    border-radius: 20px;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 18px 42px rgba(16, 37, 63, .14);
  }

  .app-navigation.collapsing {
    transition: height .22s ease;
  }

  .app-navigation .navbar-nav {
    gap: .2rem;
  }

  .app-navigation .nav-link {
    min-height: 46px;
    display: flex;
    align-items: center;
    padding: .75rem .85rem !important;
    border-radius: 13px;
  }

  .app-navigation .nav-link.active::after {
    left: .32rem;
    right: auto;
    top: .72rem;
    bottom: .72rem;
    width: 3px;
    height: auto;
  }

  .user-menu {
    gap: .75rem;
    margin-top: .65rem;
    padding: .65rem;
    border-radius: 16px;
    background: var(--surface-2);
    box-shadow: none;
  }

  .user-menu span {
    min-width: 0;
  }

  .user-menu strong,
  .user-menu small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .user-menu form,
  .user-menu .btn {
    flex: 0 0 auto;
  }

  .user-menu .btn {
    min-height: 42px;
    padding-inline: 1rem;
  }

  .page-heading {
    padding: 1rem;
  }

  .page-heading::before {
    left: 1rem;
  }
}

@media (max-width: 767px) {
  .btn {
    min-height: 44px;
  }

  .btn-close {
    min-width: 44px;
    min-height: 44px;
  }

  .quick-chip,
  .assist-chip,
  .time-slot {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
  }

  .page-heading .btn-lg,
  .page-heading > div:last-child,
  .page-heading > div:last-child .btn {
    width: 100%;
  }

  .page-heading > div:last-child.d-flex {
    flex-direction: column;
  }

  .table {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
    border-spacing: 0 .65rem;
  }

  .table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  .table thead {
    display: none;
  }

  .table tbody tr {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid #e4eef4;
    border-radius: 16px;
  }

  .table tbody td {
    display: flex;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    overflow-wrap: anywhere;
    border: 0;
    border-bottom: 1px solid #edf3f6;
  }

  .table tbody td::before {
    content: attr(data-label);
    flex: 0 0 42%;
    color: #61758a;
    font-size: .72rem;
    font-weight: 900;
    letter-spacing: .05em;
    text-transform: uppercase;
  }

  .table tbody td:not([data-label])::before,
  .table tbody td[data-label=""]::before {
    display: none;
  }

  .table tbody td:first-child,
  .table tbody td:last-child {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .table tbody td:last-child {
    border-bottom: 0;
  }

  .table tbody td.text-end {
    justify-content: flex-start;
    text-align: left !important;
  }

  .table tbody td small,
  .table tbody td strong,
  .table tbody td span:not(.state-text):not(.status-pill):not(.audit-operation) {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .table tbody td .btn {
    width: 100%;
    margin: .1rem 0;
  }

  .professional-form-grid {
    grid-template-columns: 1fr;
  }

  .profile-data-grid {
    grid-template-columns: 1fr;
  }

  .booking-flow {
    order: 1;
    width: 100%;
  }

  .booking-summary {
    position: static;
    order: 2;
    width: 100%;
    margin-top: .15rem;
  }

  .booking-summary dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 .9rem;
  }

  .booking-summary dl div {
    min-width: 0;
  }

  .booking-summary dl div:last-child {
    grid-column: 1 / -1;
  }

  .booking-summary dd {
    overflow-wrap: anywhere;
  }
}

/* iPhone 14 Pro Max y móviles de ancho equivalente (430 px). */
@media (max-width: 430px) {
  .navbar {
    padding: .55rem 0;
  }

  .navbar > .container-xl {
    padding-right: 12px;
    padding-left: 12px;
  }

  .navbar-brand {
    min-width: 0;
    gap: .5rem;
    font-size: 1rem;
  }

  .navbar-brand img {
    width: 38px;
    height: 38px;
  }

  .app-menu-toggle {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
  }

  .app-navigation {
    margin-top: .6rem;
    padding: .55rem;
    border-radius: 18px;
  }

  .app-content {
    padding-top: 1.15rem;
    padding-right: 12px;
    padding-left: 12px;
  }

  .page-heading {
    margin-bottom: 1.1rem;
    border-radius: 18px;
  }

  .page-heading h1 {
    font-size: 1.55rem;
  }

  .booking-layout {
    gap: 1rem;
  }

  .booking-step {
    gap: .7rem;
  }

  .booking-summary {
    padding: 1.1rem;
    border-radius: 18px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-heading .role-badge,
  .section-heading .state-text,
  .section-heading .status-pill {
    align-self: flex-start;
  }

  .modal-footer {
    display: grid;
    grid-template-columns: 1fr;
    gap: .55rem;
  }

  .modal-footer .btn {
    width: 100%;
    margin: 0;
  }

  .patient-profile p,
  .prepare-patient p,
  .invoice-patient p,
  .patient-clinical-card p {
    overflow-wrap: anywhere;
  }

  .user-menu {
    align-items: center;
  }

  .app-footer .container-xl {
    padding-right: 12px;
    padding-left: 12px;
  }
}

@media (max-width: 480px) {
  .treatment-row-head {
    display: none;
  }

  .treatment-row > [data-field-label]::before {
    content: attr(data-field-label);
    display: block;
    margin-bottom: .35rem;
    color: #61758a;
    font-size: .7rem;
    font-weight: 900;
    letter-spacing: .055em;
    text-transform: uppercase;
  }
}
