:root {
  --primario: #0e7490;
  --primario-oscuro: #155e75;
  --acento: #0d9488;
  --fondo: #f1f5f9;
  --blanco: #ffffff;
  --texto: #0f172a;
  --gris: #64748b;
  --borde: #e2e8f0;
  --verde: #16a34a;
  --rojo: #dc2626;
  --ambar: #d97706;
  --sombra: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.06);
  --radio: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--primario);
  text-decoration: none;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px;
}

/* ---------- NAVBAR ---------- */
.top-nav {
  background: linear-gradient(135deg, var(--primario), var(--primario-oscuro));
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--sombra);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}

.nav-l {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.9rem;
  min-width: 0;
}

.nav-centro {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  justify-self: center;
  min-width: 0;
}

.nav-brand-logo {
  height: 112px;
  width: auto;
  object-fit: contain;
}

.nav-r {
  justify-self: end;
}

.nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.nav-brand {
  font-weight: 800;
  font-size: 1.55rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.nav-roles {
  font-size: 0.75rem;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.05rem;
  object-fit: cover;
}

/* ---------- TYPOGRAPHY ---------- */
.page-title {
  font-size: 1.6rem;
  margin: 18px 0 14px;
}

.section-title {
  font-size: 1.05rem;
  margin-bottom: 12px;
  color: var(--texto);
}

.subtitle {
  margin-top: 22px;
  font-size: 0.95rem;
  color: var(--gris);
}

.hint {
  color: var(--gris);
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.empty {
  color: var(--gris);
  font-style: italic;
  padding: 8px 0;
}

.subtle {
  color: var(--gris);
  font-size: 0.85rem;
}

/* ---------- CARDS ---------- */
.card {
  background: var(--blanco);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 18px;
  margin-bottom: 16px;
}

/* ---------- BOTONES ---------- */
.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease;
  font-family: inherit;
}

.btn:hover {
  filter: brightness(1.06);
}

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

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

.btn-dark {
  background: rgba(0, 0, 0, 0.18);
  color: #fff;
  padding: 9px 18px;
  font-size: 0.98rem;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--borde);
  color: var(--texto);
}

.btn-success {
  background: var(--verde);
  color: #fff;
}

.btn-danger-outline {
  background: transparent;
  border: 1.5px solid var(--rojo);
  color: var(--rojo);
}

.btn-block {
  display: block;
  width: 100%;
  margin-top: 14px;
}

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

/* ---------- BADGES ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-pendiente {
  background: #fef3c7;
  color: var(--ambar);
}

.badge-confirmado {
  background: #dcfce7;
  color: var(--verde);
}

.badge-rechazado {
  background: #fee2e2;
  color: var(--rojo);
}

.success-msg {
  color: var(--verde);
  font-weight: 600;
  padding: 8px 0;
}

.aviso-turno {
  border: 2px solid var(--ambar);
  background: #fffbeb;
}

.turno-card.urgente {
  border: 2px solid #ef4444;
  background: #fef2f2;
}

.turno-card.urgente .urgencia-aviso {
  display: block;
  margin-top: 8px;
  color: #b91c1c;
  font-weight: 700;
  font-size: 0.85rem;
}

.urgencia-aviso {
  display: none;
}

/* ---------- PAGOS ---------- */
.pago-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--borde);
  flex-wrap: wrap;
}

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

.pago-datos {
  min-width: 180px;
}

.pago-acciones {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.comprobante-preview {
  margin-top: 8px;
}

.comprobante-preview-img {
  max-width: 220px;
  max-height: 220px;
  border-radius: var(--radio);
  border: 1px solid var(--borde);
  display: block;
}

.modal-pago {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}

.modal-pago-caja {
  background: #fff;
  border-radius: var(--radio);
  padding: 12px;
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.modal-pago-caja img {
  max-width: 88vw;
  max-height: 78vh;
  border-radius: var(--radio);
  display: block;
}

/* ---------- BACKUP ---------- */
.backup-wrap {
  position: relative;
  display: inline-block;
}

.backup-nav-btn {
  padding: 9px 18px;
  font-size: 0.98rem;
}

.backup-nav-btn-pulso {
  background: #ef4444 !important;
  border-color: #ef4444 !important;
  font-weight: 800;
  animation: backup-pulso 1.4s ease-in-out infinite;
}

.backup-tooltip {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 260px;
  background: #1f2937;
  color: #f9fafb;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.8rem;
  line-height: 1.4;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  z-index: 50;
  pointer-events: none;
}

.backup-tooltip::before {
  content: "";
  position: absolute;
  bottom: 100%;
  right: 22px;
  border: 6px solid transparent;
  border-bottom-color: #1f2937;
}

.backup-wrap:hover .backup-tooltip,
.backup-wrap:focus-within .backup-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.backup-aviso-vencido {
  color: #fca5a5;
  font-weight: 600;
}

.backup-aviso {
  margin: 0;
  color: var(--texto-claro);
}

@keyframes backup-pulso {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  50% { transform: scale(1.06); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

/* ---------- AUTH PAGE ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #0e7490 0%, #0d9488 100%);
}

.auth-card {
  background: var(--blanco);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 460px;
  padding: 24px;
}

.auth-title {
  text-align: center;
  font-size: 1.4rem;
  color: var(--primario-oscuro);
  margin-bottom: 4px;
}

.auth-logo {
  display: block;
  width: auto;
  height: 140px;
  margin: 0 auto 8px;
  object-fit: contain;
}

.auth-sub {
  text-align: center;
  color: var(--gris);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--borde);
  padding-bottom: 10px;
  flex-wrap: wrap;
}

.tab {
  background: transparent;
  border: none;
  padding: 10px 14px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--gris);
  cursor: pointer;
  border-radius: 8px;
  font-family: inherit;
}

.tab:hover {
  color: var(--primario);
  background: #f0f9ff;
}

.tab.active {
  color: var(--primario);
  background: #e0f2fe;
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--rojo);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  margin-left: 4px;
}

/* ---------- FORMULARIOS ---------- */
.label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--texto);
  margin: 10px 0 4px;
}

.input,
select.input,
textarea.input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--borde);
  border-radius: 8px;
  font-size: 0.92rem;
  font-family: inherit;
  background: #fff;
  color: var(--texto);
}

.input:focus,
textarea.input:focus {
  outline: none;
  border-color: var(--primario);
  box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.15);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0 14px;
}

.campo-form {
  margin-bottom: 8px;
}

.form-error {
  display: none;
  background: #fef2f2;
  color: var(--rojo);
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.87rem;
  margin-top: 12px;
}

.label-grupo {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--borde);
}

fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

fieldset legend {
  font-weight: 700;
  font-size: 0.95rem;
  margin: 14px 0 4px;
  padding-top: 12px;
  border-top: 1px dashed var(--borde);
  width: 100%;
}

/* ---------- CHECKBOXES ---------- */
.checks-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.checks-grid label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  border: 1.5px solid var(--borde);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.87rem;
}

.checks-grid input {
  accent-color: var(--primario);
}

/* ---------- ACCIONES RÁPIDAS ---------- */
.acciones-rapidas {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

/* ---------- TURNOS ---------- */
.turno-card {
  display: flex;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  margin-bottom: 10px;
  background: #fff;
  flex-wrap: wrap;
}

.turno-card-soft {
  background: #fafbfc;
}

.turno-fecha {
  min-width: 120px;
}

.turno-fecha .hora {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primario);
}

.turno-info {
  flex: 1;
  min-width: 180px;
}

.turno-info p {
  color: var(--gris);
  font-size: 0.88rem;
  margin: 4px 0;
}

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

.link {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* ---------- SOLICITUD DE TURNO ---------- */
.prof-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.prof-card {
  border: 1.5px solid var(--borde);
  border-radius: var(--radio);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.prof-card:hover {
  border-color: var(--primario);
  box-shadow: var(--sombra);
}

.prof-av {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  color: #fff;
  font-size: 1.5rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}

.avatar-inicial {
  font-size: 1.15rem;
}

.avatar-sm {
  width: 36px;
  height: 36px;
  font-size: 0.95rem;
}

.avatar-lg {
  width: 68px;
  height: 68px;
  font-size: 1.9rem;
}

.avatar-xl {
  width: 96px;
  height: 96px;
  font-size: 2.3rem;
}

.pac-datos {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.perfil-foto {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.perfil-foto-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 120px;
}

.perfil-foto-editar {
  margin-left: auto;
}

.perfil-logo-wrap {
  text-align: center;
  margin: 16px 0 4px;
}

.perfil-logo {
  height: 140px;
  width: auto;
  object-fit: contain;
}

.av-lg {
  width: 64px;
  height: 64px;
  font-size: 1.8rem;
}

.esp {
  color: var(--gris);
  font-size: 0.82rem;
}

.lista-dias {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dia-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--borde);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 0.92rem;
}

.dia-card:hover {
  border-color: var(--primario);
}

.dia-nombre {
  font-weight: 700;
  min-width: 90px;
}

.dia-fecha {
  color: var(--gris);
  flex: 1;
}

.dia-cant {
  color: var(--primario);
  font-weight: 600;
  font-size: 0.82rem;
}

.slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.slot-btn {
  padding: 10px;
  border: 1.5px solid var(--borde);
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  font-size: 0.9rem;
}

.slot-btn:hover {
  background: var(--primario);
  color: #fff;
  border-color: var(--primario);
}

.resumen-card p {
  margin: 6px 0;
}

.ok-card {
  text-align: center;
  padding: 32px 18px;
}

/* ---------- DATOS / CAMPOS ---------- */
.datos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.campo {
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px 12px;
}

.campo-full {
  grid-column: 1 / -1;
}

.campo-titulo {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gris);
  margin-bottom: 2px;
}

.campo-valor {
  font-weight: 600;
}

.campo-lista {
  list-style: none;
  padding-left: 0;
}

.campo-lista li {
  padding: 2px 0;
}

.campo-lista li:before {
  content: "• ";
  color: var(--primario);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f8fafc;
  border: 1.5px solid var(--borde);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.82rem;
  color: var(--gris);
}

.check.on {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: var(--verde);
  font-weight: 600;
}

/* ---------- CONSULTA ---------- */
.consulta {
  position: relative;
}

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

.consulta-head h3 {
  color: var(--primario-oscuro);
  font-size: 1rem;
}

.signos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
  margin: 12px 0;
  background: #f0fdfa;
  border: 1px solid #ccfbf1;
  border-radius: 10px;
  padding: 12px;
}

.campo-sv {
  text-align: center;
}

.campo-sv strong {
  display: block;
  font-size: 1.05rem;
  color: var(--acento);
}

.evolucion {
  margin-top: 10px;
  background: #fffbf1;
  border-left: 3px solid var(--ambar);
  border-radius: 6px;
  padding: 10px 12px;
}

.evolucion p {
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ---------- CALENDARIO ---------- */
.calendario-card {
  padding: 16px;
  max-width: 560px;
  margin: 0 auto;
}

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

.cal-nav-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.cal-titulo {
  text-transform: capitalize;
  letter-spacing: 0.04em;
  font-size: 0.95rem;
}

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

.cal-dow {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--gris);
  padding: 4px 0;
}

.cal-dia {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.85rem;
  border: 1.5px solid transparent;
  background: #fff;
  color: var(--texto);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.cal-dia.disponible {
  background: #f0fdfa;
  border-color: #a7f3d0;
  font-weight: 600;
  cursor: pointer;
}

.cal-dia.disponible:hover {
  background: var(--primario);
  border-color: var(--primario);
  color: #fff;
}

.cal-dia.sin-turnos {
  background: #f8fafc;
  color: #cbd5e1;
  cursor: default;
}

.cal-dia.pasado,
.cal-dia.vacio {
  background: #f8fafc;
  color: #e2e8f0;
  cursor: default;
}

.cal-dia.hoy {
  border-color: var(--primario);
  font-weight: 800;
}

.cal-dia.sel {
  background: var(--primario);
  border-color: var(--primario);
  color: #fff;
  font-weight: 800;
}

.cal-leyenda {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--gris);
}

.leyenda-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.leyenda-caja {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid var(--borde);
  display: inline-block;
}

.leyenda-caja.av-disp {
  background: #f0fdfa;
  border-color: #a7f3d0;
}

.leyenda-caja.av-sin {
  background: #f8fafc;
}

.leyenda-caja.av-hoy {
  border-color: var(--primario);
  background: #fff;
}

/* ---------- EJERCICIOS ---------- */
.ej-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.ej-card {
  background: #f8fafc;
  border: 1px solid var(--borde);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.85rem;
}

.ej-form-row {
  display: grid;
  grid-template-columns: 2fr 0.6fr 0.8fr 1.2fr 1.5fr auto;
  gap: 6px;
  margin-bottom: 8px;
  align-items: center;
}

/* ---------- PROFESIONAL ---------- */
.lista-pacientes {
  margin-top: 12px;
}

.pac-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--borde);
  border-radius: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  background: #fff;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 600px) {
  .container {
    padding: 12px;
  }

  .page-title {
    font-size: 1.3rem;
  }

  .turno-fecha {
    min-width: 100%;
  }

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

  .ej-form-row .ej-obs {
    grid-column: 1 / -1;
  }

  .nav-user strong {
    display: none;
  }

  .top-nav {
    grid-template-columns: 1fr auto;
    padding: 0 10px;
  }

  .nav-centro {
    grid-column: 1 / -1;
    order: -1;
  }

  .nav-l {
    min-width: 0;
    overflow: hidden;
  }

  .nav-l .nav-roles,
  .nav-l strong {
    display: none;
  }

  .nav-brand {
    font-size: 1.15rem;
    white-space: normal;
  }

  .nav-brand-logo {
    height: 76px;
  }

  .prof-grid {
    grid-template-columns: 1fr;
  }

  .dia-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .dia-cant {
    align-self: flex-end;
  }
}

@media (min-width: 1200px) {
  body {
    font-size: 0.98rem;
  }
}