/* =============================================================================
   YoyakuTech — estilos de la aplicación (panel, login y admin)
   Paleta "Lavanda calma": fondo casi blanco con un tono lila muy leve, superficies blancas y un acento
   violeta sereno. Títulos con la misma letra del texto (Figtree, en negritas). Los colores de estado son
   fijos en toda la app.
   ============================================================================= */

:root {
  --bg: #f8f7fb;
  --surface: #ffffff;
  --ink: #2b2738;
  --muted: #6c667e;
  --line: #e6e3ee;
  --line-strong: #d3cee0;
  --accent: #6b5ca5;
  --accent-strong: #564987;
  --accent-ink: #ffffff;
  --accent-soft: #ece9f6;

  --ok: #3d8a5c;
  --ok-soft: #e4f2e9;
  --no: #a3584a;
  --no-soft: #f6e6e2;
  --wait: #a77a22;
  --wait-soft: #f8eed9;
  --idle: #7c8290;
  --idle-soft: #eef0f4;
  --wa: #25d366;
  --wa-ink: #0a3d1f;

  /* Gráficas (validadas para daltonismo: verde/coral difieren en tono y claridad).
     Siempre van acompañadas de números y leyenda escritos. */
  --chart-yes: #1f8a55;
  --chart-no: #ec8a68;
  --chart-track: #e6e9f1;
  --chart-done: #56699c;
  --chart-wait: #a9b6d8;

  --display: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(43, 48, 64, 0.04), 0 8px 24px rgba(43, 48, 64, 0.06);
  --nav-width: 220px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  text-wrap: balance;
}

p {
  margin: 0;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small-text {
  font-size: 0.85rem;
}

.display {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* -----------------------------------------------------------------------------
   Formularios
   ----------------------------------------------------------------------------- */

form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label {
  font-weight: 600;
  font-size: 0.88rem;
  margin-top: 8px;
}

input,
select,
textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  width: 100%;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

/* Los radios y casillas nunca toman el 100% de ancho: si además están ocultos con
   position:absolute, ese 100% sería el de la página y provocaría scroll horizontal. */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  accent-color: var(--accent);
}

fieldset {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 0;
  padding: 12px 14px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

legend {
  font-weight: 700;
  color: var(--accent-strong);
  padding: 0 4px;
}

.form-error,
.field-error {
  color: var(--no);
  margin: 2px 0 0;
}

.field-error {
  font-size: 0.82rem;
}

.success {
  color: var(--ok);
  font-weight: 600;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-weight: 500;
  white-space: nowrap;
}

/* -----------------------------------------------------------------------------
   Botones: primario por defecto; .secondary = contorno; .whatsapp; .danger; .small; .link
   ----------------------------------------------------------------------------- */

button {
  font: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

button.secondary {
  background: var(--surface);
  color: var(--accent-strong);
  border-color: var(--line-strong);
}

button.secondary:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

button.whatsapp {
  background: var(--wa);
  border-color: var(--wa);
  color: var(--wa-ink);
}

button.whatsapp:hover {
  background: #1fbf5b;
  border-color: #1fbf5b;
}

button.danger {
  background: var(--surface);
  color: var(--no);
  border-color: #e7c9c2;
}

button.danger:hover {
  background: var(--no-soft);
}

button.small {
  padding: 6px 12px;
  font-size: 0.84rem;
}

button.link {
  background: none;
  border: 0;
  padding: 4px 0;
  color: var(--accent-strong);
  border-radius: 4px;
}

button.link:hover {
  text-decoration: underline;
  background: none;
}

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

/* -----------------------------------------------------------------------------
   Tarjetas, insignias y estados
   ----------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
}

.card h3 {
  font-size: 1.05rem;
}

.badge,
.status,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.badge-on,
.pill-yes,
.s-done {
  color: var(--ok);
  background: var(--ok-soft);
}

.badge-off,
.pill-no {
  color: var(--no);
  background: var(--no-soft);
}

.badge-neutral,
.pill-wait,
.s-idle {
  color: var(--idle);
  background: var(--idle-soft);
}

.s-sent {
  color: var(--wait);
  background: var(--wait-soft);
}

.s-open {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

/* -----------------------------------------------------------------------------
   Pantalla de acceso (login y creación de contraseña) con anuncios a un lado
   ----------------------------------------------------------------------------- */

.login-page {
  background: radial-gradient(120% 80% at 30% 0%, var(--accent-soft) 0%, var(--bg) 60%);
}

.login-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
}

.login-layout > .auth {
  align-self: center;
  justify-self: center;
  padding: 32px 16px;
}

.auth {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth a.brand {
  text-decoration: none;
}

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

button.forgot {
  align-self: center;
  font-size: 0.88rem;
  font-weight: 500;
}

/* Contraseña con botón de "ojo" para ver lo escrito */
.password-field {
  position: relative;
}

.password-field input {
  padding-right: 46px;
}

.password-field .reveal {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.password-field .reveal:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.password-field .reveal::before {
  content: "";
  width: 20px;
  height: 20px;
  background: currentColor;
  -webkit-mask: var(--eye) center / contain no-repeat;
  mask: var(--eye) center / contain no-repeat;
  --eye: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
}

.password-field .reveal[aria-pressed="true"]::before {
  --eye: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 3l18 18M10.6 5.1A10 10 0 0 1 12 5c6.4 0 10 7 10 7a17 17 0 0 1-3.2 4.1M6.6 6.6A17 17 0 0 0 2 12s3.6 7 10 7a9.7 9.7 0 0 0 5.4-1.6M9.9 9.9a3 3 0 0 0 4.2 4.2'/%3E%3C/svg%3E");
}

/* Requisitos de la contraseña: se marcan con ✓ al cumplirse */
.password-rules {
  list-style: none;
  margin: 2px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 12px;
  font-size: 0.82rem;
  color: var(--muted);
}

.password-rules li {
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s ease;
}

.password-rules li::before {
  content: "";
  flex: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.password-rules li.ok {
  color: var(--ok);
  font-weight: 600;
}

.password-rules li.ok::before {
  border-color: var(--ok);
  background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5'/%3E%3C/svg%3E") center / 11px no-repeat;
}

/* Anuncios de paquetes */
.promo {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  padding: 48px clamp(28px, 5vw, 72px);
  background: linear-gradient(150deg, #6b5ca5 0%, #564987 55%, #3b3163 100%);
  color: #fff;
}

.promo > :not(.promo-glow) {
  width: 100%;
  max-width: 540px;
}

.auth a:not(.brand) {
  color: var(--accent-strong);
  font-weight: 600;
}

.promo-glow,
.promo-glow::before,
.promo-glow::after {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.promo-glow {
  inset: -20% auto auto -15%;
  width: 60%;
  aspect-ratio: 1;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.22), transparent 70%);
  animation: promo-float 14s ease-in-out infinite alternate;
}

.promo-glow::before {
  content: "";
  width: 90%;
  aspect-ratio: 1;
  left: 140%;
  top: 120%;
  background: radial-gradient(circle, rgba(236, 196, 160, 0.3), transparent 70%);
  animation: promo-float 18s ease-in-out infinite alternate-reverse;
}

.promo-glow::after {
  content: "";
  width: 50%;
  aspect-ratio: 1;
  left: 190%;
  top: -10%;
  background: radial-gradient(circle, rgba(200, 210, 255, 0.25), transparent 70%);
  animation: promo-float 11s ease-in-out infinite alternate;
}

@keyframes promo-float {
  to {
    transform: translate(12%, 10%) scale(1.15);
  }
}

/* Todas las diapositivas en la misma celda: el alto es el de la más larga y no "brinca". */
.promo-slides {
  position: relative;
  display: grid;
}

.promo-slide {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(18px);
  transition: opacity 0.6s ease, transform 0.6s ease, visibility 0.6s;
}

.promo-slide.active {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.promo-tag {
  align-self: flex-start;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.promo-slide h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.7rem, 2.8vw, 2.4rem);
  letter-spacing: -0.015em;
  line-height: 1.1;
  max-width: 16ch;
}

.promo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 1rem;
}

.promo-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.promo-list li::before {
  content: "";
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5'/%3E%3C/svg%3E") center / 12px no-repeat;
}

.promo-price {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.promo-price b {
  font-family: var(--display);
  font-weight: 700;
  font-size: 2.6rem;
  line-height: 1;
}

.promo-price s {
  opacity: 0.65;
  font-size: 1.1rem;
}

.promo-price span {
  font-size: 0.9rem;
  opacity: 0.85;
}

.promo-footer {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.promo-dots {
  display: flex;
  gap: 8px;
}

.promo-dot {
  width: 10px;
  height: 10px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.4);
  transition: width 0.3s ease, background-color 0.3s ease;
}

.promo-dot:hover {
  background: rgba(255, 255, 255, 0.7);
}

.promo-dot[aria-pressed="true"] {
  width: 28px;
  background: #fff;
}

.promo-cta {
  padding: 10px 20px;
  border-radius: 999px;
  background: #fff;
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(20, 28, 60, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.promo-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(20, 28, 60, 0.3);
}

.promo :focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

@media (max-width: 899px) {
  .login-layout {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
  }

  .login-layout > .auth {
    padding: 40px 16px 28px;
  }

  .promo {
    margin: 0 16px 24px;
    padding: 28px 22px;
    border-radius: var(--radius-lg);
    gap: 20px;
  }

  .promo-slide h2 {
    font-size: 1.8rem;
  }

  .promo-price b {
    font-size: 2.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .promo-glow,
  .promo-glow::before,
  .promo-glow::after {
    animation: none;
  }

  .promo-slide {
    transition: none;
  }
}

.brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.9rem;
  letter-spacing: -0.015em;
  line-height: 1;
  color: var(--ink);
  text-align: center;
}

/* Logo (opción 5, barras en orden): img/logo.svg + "Yoyaku" en tinta y "Tech" en lavanda.
   Todo en em: toma el tamaño del .brand donde va. */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.34em;
  vertical-align: middle;
}

.logo-mark {
  flex: none;
  width: 1.15em;
  height: 1.15em;
}

.logo-word {
  font-family: var(--body);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--ink);
}

.logo-word span {
  color: var(--accent);
}

/* "Agenda con YoyakuTech" al pie de las páginas de cita y reservas */
.footer-mark {
  width: 16px;
  height: 16px;
  margin: 0 4px 0 2px;
  vertical-align: -3px;
}

.brand small {
  display: block;
  margin-top: 6px;
  font-family: var(--body);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.auth .card {
  box-shadow: var(--shadow);
}

.auth form button[type="submit"] {
  margin-top: 12px;
}

/* -----------------------------------------------------------------------------
   Estructura: barra lateral (escritorio) / barra inferior (celular)
   ----------------------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: var(--nav-width) minmax(0, 1fr);
  min-height: 100vh;
}

.nav {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 22px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.nav .brand {
  font-size: 1.45rem;
  text-align: left;
  padding: 0 10px 18px;
}

/* Nombre del consultorio debajo de la marca (en lugar de repetirlo en cada página). */
.nav .brand small {
  margin-top: 4px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.3;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}

.nav-item:hover {
  background: var(--bg);
  color: var(--ink);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.nav-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 10px 0;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
}

.nav-footer .link {
  align-self: flex-start;
}

.nav-footer strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content {
  min-width: 0;
  padding: 28px 32px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 20px;
}

.page-header .titles {
  flex: 1 1 260px;
  min-width: 0;
}

.page-header h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.5rem, 2.4vw, 1.9rem);
  letter-spacing: -0.015em;
  line-height: 1.15;
}

.page-header p {
  color: var(--muted);
  margin-top: 6px;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.view-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.view-header h2 {
  font-size: 1.15rem;
}


/* -----------------------------------------------------------------------------
   Diálogos (formularios de citas, pacientes, configuración)
   ----------------------------------------------------------------------------- */

dialog {
  width: min(580px, calc(100% - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 64px rgba(43, 48, 64, 0.22);
}

dialog::backdrop {
  background: rgba(43, 48, 64, 0.35);
}

dialog form {
  padding: 24px;
}

/* ---------- Avisos (js/avisos.js): reemplazan alert, confirm y prompt del navegador ---------- */
dialog.app-dialog {
  width: min(440px, calc(100% - 32px));
}

dialog.app-dialog[open] {
  animation: app-dialog-in 0.18s ease-out;
}

@keyframes app-dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

.app-dialog-box {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.app-dialog-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-dialog-head h3 {
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.2;
}

.app-dialog-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.app-dialog-icon svg {
  width: 22px;
  height: 22px;
}

.tone-info {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.tone-success {
  color: var(--ok);
  background: var(--ok-soft);
}

.tone-warning {
  color: var(--wait);
  background: var(--wait-soft);
}

.tone-danger {
  color: var(--no);
  background: var(--no-soft);
}

.app-dialog-message {
  color: var(--ink);
  line-height: 1.55;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.app-dialog-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.app-dialog-copy {
  width: 100%;
  resize: vertical;
  font-size: 0.86rem;
  color: var(--muted);
}

.app-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

button.danger-solid {
  background: var(--no);
  border-color: var(--no);
  color: #fff;
}

button.danger-solid:hover {
  background: #8a4537;
  border-color: #8a4537;
}

@media (max-width: 480px) {
  .app-dialog-actions {
    flex-direction: column-reverse;
  }

  .app-dialog-actions button {
    width: 100%;
  }
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 100;
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 10px 28px rgba(20, 24, 40, 0.25);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.app-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.app-toast.tone-danger {
  background: var(--no);
}

@media (max-width: 860px) {
  /* Encima de la barra inferior del panel en celular. */
  .app-toast {
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  dialog.app-dialog[open] {
    animation: none;
  }
}


.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.dialog-head h3 {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.1;
}

.dialog-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.member-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.rsvp-row {
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}

.rsvp-row select {
  width: auto;
}

.export-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.export-option {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.export-option h4 {
  font-size: 1rem;
}

.export-option button {
  margin-top: auto;
}

fieldset .checkbox {
  white-space: normal;
  margin: 0;
}

.danger-zone {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px dashed var(--line-strong);
}

/* -----------------------------------------------------------------------------
   Admin: cuentas
   ----------------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--bg);
}

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

td .badge + button {
  display: flex;
  margin-top: 6px;
}

td.actions {
  flex-wrap: nowrap;
}

.notice {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

pre {
  white-space: pre-wrap;
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 12px 14px;
  border-radius: 10px;
  font-family: var(--body);
  font-size: 0.88rem;
  margin: 8px 0;
}


/* Acciones por fila con botones de ícono, e interruptor (switch) */
.row-actions-cell {
  width: 1%;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.icon-button {
  position: relative;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--accent-strong);
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.icon-button:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.icon-button.icon-danger:hover {
  background: var(--no-soft);
  border-color: var(--no);
  color: var(--no);
}

/* Etiqueta al pasar el mouse o al enfocar con teclado (aparece al instante, a diferencia de title). */
.icon-button[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  z-index: 5;
  padding: 5px 9px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.icon-button:hover::after,
.icon-button:focus-visible::after {
  opacity: 1;
  transform: none;
}

.switch {
  gap: 8px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.84rem;
}

.switch:hover {
  background: none;
  color: var(--ink);
}

.switch-track {
  position: relative;
  flex: none;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background-color 0.15s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(43, 48, 64, 0.25);
  transition: transform 0.15s ease;
}

.switch[aria-checked="true"] {
  color: var(--ok);
}

.switch[aria-checked="true"] .switch-track {
  background: var(--ok);
}

.switch[aria-checked="true"] .switch-track::after {
  transform: translateX(16px);
}


/* -----------------------------------------------------------------------------
   Celular
   ----------------------------------------------------------------------------- */

@media (max-width: 860px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  /* La barra lateral se vuelve barra inferior fija. */
  .nav {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 20;
    height: auto;
    flex-direction: row;
    justify-content: space-around;
    gap: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    border-right: 0;
    border-top: 1px solid var(--line);
  }

  .nav .brand,
  .nav-footer {
    display: none;
  }

  .nav-item {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    font-size: 0.72rem;
    padding: 6px 4px;
  }

  .nav-item.active {
    background: transparent;
  }

  .content {
    padding: 20px 16px 96px;
  }

  .split,
  .summary-grid {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .kpi-value {
    font-size: 2.1rem;
  }

  /* El detalle se abre como pantalla completa sobre la lista. */
  .detail {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 30;
    border-radius: 0;
    border: 0;
    overflow-y: auto;
    padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  }

  .detail.open {
    display: flex;
  }

  .detail-back {
    display: inline-flex;
    align-self: flex-start;
  }

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

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

  .rsvp-row span {
    grid-column: 1 / -1;
    font-weight: 600;
  }

  dialog {
    width: 100%;
    max-width: none;
    max-height: 100%;
    height: 100%;
    margin: 0;
    border-radius: 0;
  }

  /* Los avisos (js/avisos.js) son cortos: van centrados como tarjeta, no a pantalla completa. */
  dialog.app-dialog {
    width: calc(100% - 32px);
    height: fit-content; /* "auto" lo estiraría a toda la pantalla (el diálogo modal va de arriba a abajo) */
    max-height: calc(100% - 48px);
    margin: auto;
    border-radius: var(--radius-lg);
  }
}

.mobile-only {
  display: none !important;
}

@media (max-width: 860px) {
  .mobile-only {
    display: inline-flex !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}


/* -----------------------------------------------------------------------------
   Página temporal (fase 2): estado de la API
   ----------------------------------------------------------------------------- */

.center-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.center-page .card {
  width: min(440px, 100%);
  text-align: center;
}

.health {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  font-size: 0.92rem;
}

.health.ok {
  color: var(--ok);
}

.health.error {
  color: var(--no);
}

/* -----------------------------------------------------------------------------
   Utilidades de vistas y formularios
   ----------------------------------------------------------------------------- */

.narrow {
  max-width: 720px;
}

.empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
}

.list-footer {
  display: flex;
  justify-content: center;
  padding: 12px;
}

/* Dos campos lado a lado (en celular, uno debajo del otro). */
.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 12px;
}

.form-row > div {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inline-number {
  width: 72px;
  padding: 4px 8px;
}

@media (max-width: 560px) {
  .form-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* -----------------------------------------------------------------------------
   Admin: indicadores, estado de la suscripción y pagos
   ----------------------------------------------------------------------------- */

#admin-stats {
  margin-bottom: 8px;
}

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

.kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.kpi-value {
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: lining-nums tabular-nums;
}

.kpi.primary {
  background: var(--accent-soft);
  border-color: transparent;
}

.kpi.primary .kpi-value {
  color: var(--accent-strong);
}

.kpi-sub {
  font-size: 0.84rem;
  color: var(--muted);
}

/* Semáforo de la suscripción */
.sub-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.sub-al_corriente {
  color: var(--ok);
  background: var(--ok-soft);
}

.sub-prueba {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.sub-por_vencer {
  color: var(--wait);
  background: var(--wait-soft);
}

.sub-en_gracia,
.sub-solo_lectura {
  color: var(--no);
  background: var(--no-soft);
}

.sub-sin_pago,
.sub-suspendida {
  color: var(--idle);
  background: var(--idle-soft);
}

.payment-preview {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.9rem;
}

.payment-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.86rem;
}

.payment-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  padding: 8px 0;
}

.payment-list li + li {
  border-top: 1px solid var(--line);
}

.payment-list b {
  font-variant-numeric: tabular-nums;
}

/* -----------------------------------------------------------------------------
   Aviso del plan (fase 11): vence pronto, en días de gracia o en solo lectura
   (los colores salen de .tone-info / .tone-warning / .tone-danger de los avisos)
   ----------------------------------------------------------------------------- */

.plan-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 18px;
  padding: 14px 18px;
  border-radius: var(--radius);
}

.plan-banner > div {
  flex: 1 1 320px;
  min-width: 0;
}

.plan-banner strong {
  display: block;
  font-size: 0.98rem;
}

.plan-banner p {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 0.9rem;
}

.plan-banner a {
  flex: none;
}

/* Solo lectura: se ocultan los botones de crear (la API además rechaza cualquier cambio). */
body.read-only #today-new,
body.read-only #appointment-new,
body.read-only #client-new,
body.read-only #pet-new,
body.read-only #service-new,
body.read-only #status-new {
  display: none;
}

/* -----------------------------------------------------------------------------
   Configuración del profesionista
   ----------------------------------------------------------------------------- */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.tab {
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
}

.tab:hover {
  background: var(--accent-soft);
  border-color: var(--line-strong);
  color: var(--ink);
}

.tab[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.info-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 20px;
  margin: 12px 0 0;
  font-size: 0.92rem;
}

.info-list dt {
  color: var(--muted);
}

.info-list dd {
  margin: 0;
  font-weight: 600;
}

/* Horario: un renglón por día con sus rangos */
.schedule-days {
  display: flex;
  flex-direction: column;
  margin: 8px 0;
}

.day-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px 0;
}

.day-row + .day-row {
  border-top: 1px solid var(--line);
}

.day-name {
  margin-top: 6px;
  font-weight: 600;
}

.day-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.day-closed {
  margin-top: 8px;
}

.day-ranges {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Los campos de hora se encogen en pantallas angostas para que "Quitar" no se salga. */
.range-row input[type="time"] {
  flex: 1 1 0;
  min-width: 0;
  max-width: 150px;
  padding: 6px 8px;
}

.range-remove {
  flex: none;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
}

.range-remove:hover {
  background: var(--no-soft);
  border-color: var(--no);
  color: var(--no);
}

.range-row.invalid input {
  border-color: var(--no);
  background: var(--no-soft);
}

/* Listas de servicios, estatus y bloqueos */
.simple-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.simple-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
}

.simple-list li + li {
  border-top: 1px solid var(--line);
}

.simple-list li.inactive {
  opacity: 0.6;
}

.item-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.color-dot {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

/* Selector de color */
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.swatch {
  position: relative;
  margin: 0;
  cursor: pointer;
}

.swatch input {
  position: absolute;
  opacity: 0;
}

.swatch-dot {
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px transparent;
  transition: box-shadow 0.15s ease;
}

.swatch input:checked + .swatch-dot {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink);
}

.swatch input:focus-visible + .swatch-dot {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.dialog-foot #service-delete,
.dialog-foot #status-delete {
  margin-right: auto;
}

@media (max-width: 560px) {
  .day-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }
}

/* -----------------------------------------------------------------------------
   Pacientes / clientes: lista, ficha y mascotas
   ----------------------------------------------------------------------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.toolbar input[type="search"] {
  flex: 1 1 260px;
  width: auto;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 7px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  font-size: 0.86rem;
}

.chip:hover {
  background: var(--accent-soft);
  border-color: var(--line-strong);
}

.chip b {
  font-variant-numeric: tabular-nums;
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.list-card {
  padding: 6px 0;
}

.client-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.client-list li + li {
  border-top: 1px solid var(--line);
}

.client-row {
  width: 100%;
  justify-content: flex-start;
  gap: 14px;
  padding: 12px 22px;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--ink);
  font-weight: 400;
  text-align: left;
}

.client-row:hover {
  background: var(--bg);
}

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
}

.client-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pet-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.pet-tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--idle-soft);
  color: var(--idle);
  font-size: 0.76rem;
  font-weight: 600;
}

#client-back {
  align-self: flex-start;
}

.profile-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.profile-head h2 {
  font-size: 1.5rem;
}

.prewrap {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* Enlace con aspecto de botón (WhatsApp abre en otra pestaña) */
a.button-like {
  display: inline-flex;
  align-items: center;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
}

a.button-like.whatsapp {
  background: var(--wa);
  color: var(--wa-ink);
}

a.button-like.whatsapp:hover {
  background: #1fbf5b;
}

.duplicate-note {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--wait-soft);
  color: var(--wait);
  font-weight: 600;
  font-size: 0.9rem;
}

/* -----------------------------------------------------------------------------
   Agenda: barra de navegación, rejilla de día/semana y citas
   ----------------------------------------------------------------------------- */

.agenda-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.agenda-nav,
.agenda-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.agenda-nav h2 {
  margin-left: 6px;
  font-size: 1.15rem;
}

.agenda-nav .icon-button {
  font-size: 1.3rem;
  line-height: 1;
}

.agenda-hint {
  margin: 8px 0 12px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.segmented button {
  padding: 6px 14px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.86rem;
}

.segmented button:hover {
  background: var(--bg);
  color: var(--ink);
}

.segmented button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

.agenda-grid {
  --cols: 7;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.agenda-head,
.agenda-body {
  display: grid;
  grid-template-columns: 56px repeat(var(--cols), minmax(0, 1fr));
}

.agenda-head {
  border-bottom: 1px solid var(--line);
}

.day-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.day-head b {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--ink);
  font-size: 1.05rem;
}

.day-head.today b {
  background: var(--accent);
  color: var(--accent-ink);
}

.agenda-scroll {
  max-height: calc(100vh - 280px);
  min-height: 360px;
  overflow-y: auto;
}

.agenda-body {
  position: relative;
}

.time-gutter {
  position: relative;
}

.time-gutter span {
  position: absolute;
  right: 8px;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.time-gutter span:first-child {
  transform: none;
}

/* Fuera de horario: sombreado. Líneas cada hora (sólidas) y media hora (punteadas). */
.day-col {
  position: relative;
  border-left: 1px solid var(--line);
  background-color: #f3f2f7;
  background-image:
    linear-gradient(to bottom, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, transparent calc(var(--hour) / 2), #ece9f2 calc(var(--hour) / 2), #ece9f2 calc(var(--hour) / 2 + 1px), transparent calc(var(--hour) / 2 + 1px));
  background-size: 100% var(--hour);
  cursor: pointer;
}

.day-col.today {
  background-color: #f1eef9;
}

.open-range {
  position: absolute;
  left: 0;
  right: 0;
  background-color: var(--surface);
  background-image: inherit;
  background-size: 100% var(--hour);
  pointer-events: none;
}

.blocked-range {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 1;
  padding: 4px 6px;
  background: repeating-linear-gradient(135deg, #eceff1 0 6px, #e0e4e7 6px 12px);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  overflow: hidden;
  pointer-events: none;
}

.appt {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 1px;
  padding: 4px 6px;
  border: 1px solid color-mix(in srgb, var(--status) 35%, white);
  border-left: 4px solid;
  border-radius: 8px;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 500;
  line-height: 1.25;
  text-align: left;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(35, 49, 47, 0.08);
}

.appt:hover {
  border-color: var(--status);
  box-shadow: 0 4px 12px rgba(35, 49, 47, 0.15);
}

.appt-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.appt-who {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.appt-service,
.appt-status {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.appt-status {
  color: color-mix(in srgb, var(--status) 80%, black);
  font-weight: 700;
}

/* Citas cortas: hora y nombre en un renglón. */
.appt.compact {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.appt.compact .appt-time {
  flex: none;
}

.appt.compact .appt-status {
  display: none;
}

.appt.cancelled {
  opacity: 0.55;
}

.appt.cancelled .appt-who {
  text-decoration: line-through;
}

.now-line {
  position: absolute;
  left: -1px;
  right: 0;
  z-index: 3;
  height: 2px;
  background: var(--no);
  pointer-events: none;
}

.now-line::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--no);
}

/* Diálogo de cita: buscador de paciente, alta rápida, avisos e historial */
.form-row.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.picker {
  position: relative;
}

.picker-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 5;
  list-style: none;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.picker-results button {
  width: 100%;
  justify-content: space-between;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font-weight: 500;
}

.picker-results button:hover {
  background: var(--accent-soft);
}

.picker-results .picker-new {
  justify-content: flex-start;
  color: var(--accent-strong);
  font-weight: 700;
}

.picker-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent-soft);
  font-weight: 600;
}

.quick-client {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
}

.warning-box {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--wait-soft);
  color: var(--wait);
  font-weight: 600;
  font-size: 0.9rem;
}

.warning-box ul {
  margin: 0;
  padding-left: 18px;
}

.history ul {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

#ap-delete {
  margin-right: auto;
}

@media (max-width: 760px) {
  .agenda-scroll {
    max-height: none;
  }

  .agenda-nav h2 {
    font-size: 1rem;
  }

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

/* -----------------------------------------------------------------------------
   Hoy: indicadores, citas del día y recordatorios de mañana
   ----------------------------------------------------------------------------- */

#home-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.today-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.today-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 10px;
  cursor: pointer;
}

.today-item + .today-item {
  border-top: 1px solid var(--line);
}

.today-item:hover {
  background: var(--bg);
}

.today-item.now {
  background: var(--accent-soft);
}

.today-item.cancelled {
  opacity: 0.55;
}

.today-item.cancelled strong {
  text-decoration: line-through;
}

.today-time {
  display: flex;
  flex-direction: column;
  font-variant-numeric: tabular-nums;
}

.today-who {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.today-who strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.today-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-select {
  width: auto;
  max-width: 150px;
  padding: 6px 10px;
  border-color: var(--status);
  background: color-mix(in srgb, var(--status) 12%, white);
  font-size: 0.84rem;
  font-weight: 600;
}

.empty-row {
  padding: 18px 8px;
  cursor: default;
}

.sent-mark {
  color: var(--ok);
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
}

a.button-like.small {
  padding: 6px 12px;
  font-size: 0.84rem;
}

/* Variante tenue del botón de WhatsApp (mensajes secundarios). */
a.button-like.whatsapp.soft {
  background: #e3f8eb;
  color: var(--wa-ink);
}

a.button-like.whatsapp.soft:hover {
  background: #c9f0d8;
}

.send-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

/* Mensajes de WhatsApp en Configuración */
.messages-editor {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 12px;
}

.message-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.message-block + .message-block {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.message-block textarea[readonly] {
  background: var(--bg);
  color: var(--muted);
}

/* Vista previa con aspecto de burbuja de WhatsApp */
.message-preview {
  align-self: flex-start;
  max-width: 460px;
  padding: 8px 12px;
  border-radius: 10px 10px 10px 2px;
  background: #e7f6dc;
  font-size: 0.88rem;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

@media (max-width: 860px) {
  .today-item {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .today-actions {
    grid-column: 2;
  }
}

/* -----------------------------------------------------------------------------
   Página pública de la cita (paciente)
   ----------------------------------------------------------------------------- */

.public-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px;
  background: radial-gradient(120% 70% at 50% 0%, var(--accent-soft) 0%, var(--bg) 60%);
}

.public-card {
  width: min(480px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
}

.public-card h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.7rem;
  letter-spacing: -0.015em;
}

.public-business {
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.public-when {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--bg);
  font-size: 1.05rem;
}

.public-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.public-notice {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--ok-soft);
  color: var(--ok);
  font-weight: 600;
}

a.button-like.soft-link {
  border: 1px solid var(--line-strong);
  color: var(--accent-strong);
}

a.button-like.soft-link:hover {
  background: var(--accent-soft);
}

.public-footer {
  margin-top: 16px;
}

/* -----------------------------------------------------------------------------
   Reservas en línea: página pública, configuración y marcas en el panel
   ----------------------------------------------------------------------------- */

.booking {
  gap: 18px;
}

.booking-step {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.booking-step h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
}

.step-badge {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.85rem;
}

.booking-message {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.9rem;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  text-align: left;
}

.option:hover,
.option.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.day-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.day-option {
  flex: none;
  flex-direction: column;
  gap: 0;
  width: 58px;
  padding: 8px 4px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 500;
  text-transform: capitalize;
}

.day-option b {
  font-size: 1.15rem;
}

.day-option:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.day-option[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.day-option:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--bg);
}

.time-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 6px;
}

.time-option {
  padding: 9px 6px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--surface);
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
}

.time-option:hover {
  background: var(--accent);
  color: var(--accent-ink);
}

.chosen-summary {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
}

/* Configuración: enlace para compartir */
.link-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

.link-box code {
  overflow-wrap: anywhere;
  font-size: 0.86rem;
}

.link-box.disabled {
  opacity: 0.55;
}

.upsell {
  border-style: dashed;
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--surface), var(--accent-soft));
}

.upsell h3 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 6px;
}

.online-card {
  border-color: var(--accent);
}

.appt-online {
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.66rem;
  font-weight: 700;
}

/* Formas de pago (Mi negocio y página de la cita) */
.checkbox-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.payment-box {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.transfer-info {
  margin: 4px 0;
  white-space: pre-line;
  font-variant-numeric: tabular-nums;
}

.place-link {
  align-self: flex-start;
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

/* -----------------------------------------------------------------------------
   Cobros, expediente, vista de mes y reportes
   ----------------------------------------------------------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* En el celular caben 6 secciones en la barra inferior. */
@media (max-width: 860px) {
  .nav-item {
    min-width: 0;
    padding: 6px 2px;
    font-size: 0.68rem;
    white-space: nowrap;
  }
}

/* Cobro dentro del diálogo de cita */
.payment-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

.payment-row select {
  width: auto;
  min-width: 180px;
}

.paid-mark {
  color: var(--ok);
  font-weight: 600;
}

/* Expediente */
.note-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.note-form-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.note-form-foot select {
  width: auto;
  max-width: 100%;
  flex: 1 1 220px;
}

.upsell-inline {
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px dashed var(--accent);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--surface), var(--accent-soft));
}

.notes-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}

.note {
  padding: 12px 0;
}

.note + .note {
  border-top: 1px solid var(--line);
}

.note-text {
  margin-top: 4px;
}

.note-actions {
  display: flex;
  gap: 14px;
  margin-top: 4px;
}

.note-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

button.link.danger-link {
  color: var(--no);
}

/* Agenda: vista de mes */
.month-head,
.month-body {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.month-head {
  border-bottom: 1px solid var(--line);
}

.month-head div {
  padding: 8px 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
}

.month-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 112px;
  padding: 6px;
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
  cursor: pointer;
  overflow: hidden;
}

.month-cell:nth-child(7n + 1) {
  border-left: 0;
}

.month-cell:nth-child(-n + 7) {
  border-top: 0;
}

.month-cell:hover {
  background: var(--bg);
}

.month-cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.month-cell.closed {
  background: #f6f5f9;
}

.month-cell.blocked {
  background: repeating-linear-gradient(135deg, #f1f3f4 0 6px, #e8ebed 6px 12px);
}

.month-cell.other-month .month-day b {
  color: var(--line-strong);
}

.month-day {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.month-day b {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 0.86rem;
}

.month-cell.today .month-day b {
  background: var(--accent);
  color: var(--accent-ink);
}

.month-flag {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
}

.month-appt {
  display: flex;
  justify-content: flex-start;
  gap: 4px;
  width: 100%;
  padding: 2px 6px;
  border: 0;
  border-left: 3px solid var(--status);
  border-radius: 4px;
  background: color-mix(in srgb, var(--status) 14%, white);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
}

.month-appt:hover {
  background: color-mix(in srgb, var(--status) 26%, white);
  border-color: var(--status);
}

.month-appt-time {
  flex: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.month-appt-who {
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.month-appt.cancelled {
  opacity: 0.55;
}

.month-appt.cancelled .month-appt-who {
  text-decoration: line-through;
}

.month-more {
  padding-left: 6px;
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 700;
}

.month-count {
  display: none;
}

@media (max-width: 760px) {
  .month-cell {
    min-height: 58px;
    align-items: center;
    padding: 4px 2px;
  }

  .month-day {
    justify-content: center;
  }

  .month-appt,
  .month-more,
  .month-flag {
    display: none;
  }

  .month-count {
    display: grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 0.72rem;
    font-weight: 700;
  }
}

/* Reportes */
#reports-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.reports-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.reports-period {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.reports-period select {
  width: auto;
  min-width: 170px;
}

.reports-stepper {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.reports-stepper strong {
  min-width: 150px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.reports-stepper .icon-button {
  width: 32px;
  height: 32px;
  border-color: transparent;
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
}

.reports-stepper .icon-button:not(:disabled):hover {
  background: var(--accent-soft);
}

.reports-stepper .icon-button:disabled {
  opacity: 0.35;
  cursor: default;
}

/* En celular: periodo y flechas a todo lo ancho, exportar abajo */
@media (max-width: 640px) {
  .reports-toolbar,
  .reports-period {
    flex-direction: column;
    align-items: stretch;
  }

  .reports-period select {
    width: 100%;
  }

  .reports-stepper {
    justify-content: space-between;
  }

  .reports-stepper strong {
    min-width: 0;
  }
}

.reports-custom {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.reports-custom label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
}

.reports-custom .form-error {
  flex-basis: 100%;
}

#reports-range {
  margin-top: -8px;
}

#reports-kpis {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 860px) {
  #reports-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.reports-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.reports-grid .card h3 {
  margin-bottom: 14px;
}

/* -----------------------------------------------------------------------------
   Inicio (panel): indicadores, agenda de hoy, pendientes, semana y actividad
   ----------------------------------------------------------------------------- */

.home-tiles {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.home-tiles .kpi {
  padding: 14px 16px;
}

.home-tiles .kpi-value {
  font-size: 1.7rem;
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr);
  gap: 16px;
  align-items: start;
}

.home-main,
.home-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.pending-card h3 {
  margin-bottom: 4px;
}

/* Esta semana: barras por día; hoy en el color de acento, los demás en su tono suave */
.week-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.week-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.week-count {
  min-height: 1.2em;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.week-track {
  display: flex;
  align-items: flex-end;
  width: 100%;
  height: 84px;
  border-bottom: 1px solid var(--line-strong);
}

.week-bar {
  display: block;
  width: 100%;
  max-width: 34px;
  margin: 0 auto;
  border-radius: 4px 4px 0 0;
  background: color-mix(in srgb, var(--accent) 35%, white);
}

.week-day.future .week-bar {
  background: var(--accent-soft);
}

.week-day.today .week-bar {
  background: var(--accent);
}

.week-label {
  color: var(--muted);
  font-size: 0.74rem;
}

.week-day.today .week-label,
.week-day.today .week-count {
  color: var(--accent-strong);
  font-weight: 700;
}

/* Actividad reciente */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.activity-item {
  display: grid;
  grid-template-columns: 52px 22px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  padding: 6px;
  margin: 0 -6px;
  border-radius: 8px;
  font-size: 0.88rem;
}

.activity-item.clickable {
  cursor: pointer;
}

.activity-item.clickable:hover {
  background: var(--bg);
}

.activity-time {
  padding-top: 1px;
  color: var(--muted);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.activity-dot {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 800;
}

.d-patient { background: var(--accent-soft); color: var(--accent-strong); }
.d-money { background: var(--ok-soft); color: var(--ok); }
.d-warn { background: var(--no-soft); color: var(--no); }
.d-idle { background: var(--idle-soft); color: var(--idle); }

.activity-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.activity-text b {
  font-weight: 600;
}

.activity-more {
  padding-top: 4px;
}

.pending-group + .pending-group {
  margin-top: 6px;
  border-top: 1px solid var(--line);
}

.pending-group h4 {
  margin: 12px 0 2px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pending-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pending-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 6px;
  margin: 0 -6px;
  border-radius: 8px;
  cursor: pointer;
}

.pending-item:hover {
  background: var(--bg);
}

.pending-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pending-text strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.today-item.past {
  opacity: 0.7;
}

.now-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
  color: var(--no);
  font-size: 0.74rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.now-divider::before,
.now-divider::after {
  content: "";
  flex: 1;
  height: 2px;
  background: var(--no);
  opacity: 0.6;
}

.now-divider::before {
  flex: 0 0 12px;
}

/* Próximos 7 días (debajo de la agenda de hoy) */
.upcoming {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line-strong);
}

.upcoming-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
}

.upcoming-head h4 {
  font-size: 0.95rem;
  font-weight: 700;
}

.upcoming-alert {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--wait-soft);
  color: var(--wait);
  font-weight: 700;
}

.upcoming-date {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.upcoming-list {
  list-style: none;
  margin: 2px 0 0;
  padding: 0;
}

.upcoming-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 7px 8px;
  border-radius: 10px;
  cursor: pointer;
}

.upcoming-item:hover {
  background: var(--bg);
}

.upcoming-time {
  font-variant-numeric: tabular-nums;
}

.upcoming-who {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.upcoming-who strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upcoming-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  white-space: nowrap;
}

.upcoming-status .color-dot {
  width: 10px;
  height: 10px;
}

.upcoming > .link {
  align-self: flex-start;
}

@media (max-width: 520px) {
  .upcoming-item {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .upcoming-status {
    grid-column: 2;
  }
}

.today-item + .now-divider + .today-item,
.now-divider + .today-item {
  border-top: 0;
}

@media (max-width: 1100px) {
  .home-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .home-tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* -----------------------------------------------------------------------------
   Pacientes: lista a la izquierda y ficha a la derecha (en celular, una a la vez)
   ----------------------------------------------------------------------------- */

.clients-layout {
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.clients-list-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.clients-tools {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.clients-tools-row {
  display: flex;
  gap: 8px;
}

.clients-tools-row input {
  flex: 1;
  min-width: 0;
}

.clients-list-panel .client-row {
  padding: 10px 14px;
  gap: 10px;
}

.clients-list-panel .avatar {
  width: 32px;
  height: 32px;
  font-size: 0.8rem;
}

.client-list li.selected .client-row {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* En computadora la lista se queda visible mientras se recorre la ficha. */
@media (min-width: 861px) {
  .clients-list-panel {
    position: sticky;
    top: 16px;
  }

  .clients-list-panel .list-card {
    max-height: calc(100vh - 190px);
    overflow-y: auto;
  }
}

.client-profile {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.profile-empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  color: var(--muted);
  text-align: center;
}

.profile-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#client-back {
  display: none;
}

.profile-who {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.avatar.large {
  width: 46px;
  height: 46px;
  font-size: 1rem;
}

.profile-head h2 {
  font-size: 1.3rem;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.profile-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
}

.profile-stat b {
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.profile-stat.alert b {
  color: var(--no);
}

.profile-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
}

.profile-tab {
  padding: 8px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--muted);
  font-weight: 600;
}

.profile-tab:hover {
  background: none;
  color: var(--ink);
}

.profile-tab[aria-selected="true"] {
  border-bottom-color: var(--accent);
  color: var(--accent-strong);
}

.profile-grid [data-ptab] {
  display: none;
}

.profile-grid[data-active="appointments"] [data-ptab="appointments"],
.profile-grid[data-active="notes"] [data-ptab="notes"],
.profile-grid[data-active="pets"] [data-ptab="pets"],
.profile-grid[data-active="info"] [data-ptab="info"] {
  display: block;
}

@media (max-width: 1100px) {
  .profile-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .clients-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Una cosa a la vez: la lista, o la ficha con "Volver". */
  #clients-view:not(.has-profile) .client-profile,
  #clients-view.has-profile .clients-list-panel {
    display: none;
  }

  #client-back {
    display: inline-flex;
  }
}

/* -----------------------------------------------------------------------------
   Agenda: mini calendario y leyenda | rejilla | panel de la cita
   ----------------------------------------------------------------------------- */

.agenda-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.agenda-layout.with-panel {
  grid-template-columns: 210px minmax(0, 1fr) 290px;
}

.agenda-aside {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mini-cal-card,
.legend-card {
  padding: 14px;
}

.mini-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.icon-button.small-icon {
  width: 28px;
  height: 28px;
  font-size: 1.1rem;
}

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

.mini-dow {
  padding-bottom: 2px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
}

.mini-day {
  position: relative;
  padding: 5px 0;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.mini-day:hover {
  background: var(--bg);
}

.mini-day.out {
  color: var(--line-strong);
}

.mini-day.in-range {
  background: var(--accent-soft);
}

.mini-day.has {
  font-weight: 800;
}

.mini-day.has::after {
  content: "";
  position: absolute;
  bottom: 2px;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateX(-50%);
}

.mini-day.today {
  background: var(--accent);
  color: var(--accent-ink);
}

.mini-day.today::after {
  background: var(--accent-ink);
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.84rem;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.appt.selected,
.month-appt.selected {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  z-index: 3;
}

.appt-panel {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-name {
  justify-content: flex-start;
  padding: 0;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 700;
  text-align: left;
}

.appt-panel .status-select {
  align-self: flex-start;
  max-width: 100%;
}

.panel-info {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 12px;
  margin: 0;
  font-size: 0.88rem;
}

.panel-info dt {
  color: var(--muted);
}

.panel-info dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.panel-notes {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg);
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

/* Cobro de la cita: recuadro propio (verde cobrada, ámbar por cobrar, gris sin precio) */
.panel-pay {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--bg);
}

.panel-pay.paid {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.panel-pay.due {
  border-color: var(--wait);
  background: var(--wait-soft);
}

.panel-pay-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.panel-pay-amount {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.panel-pay-status {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
}

.panel-pay.paid .panel-pay-status {
  color: var(--ok);
}

.panel-pay.due .panel-pay-status {
  color: var(--wait);
}

/* Contactar al paciente: número + llamar */
.panel-contact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-phone {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.panel-history {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
}

.panel-history li {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* En laptops, con el panel abierto se oculta el mini calendario para que la semana no quede angosta. */
@media (max-width: 1499px) {
  .agenda-layout.with-panel {
    grid-template-columns: minmax(0, 1fr) 290px;
  }

  .agenda-layout.with-panel .agenda-aside {
    display: none;
  }
}

/* Sin espacio para tres columnas: primero se oculta el mini calendario. */
@media (max-width: 1279px) {
  .agenda-layout,
  .agenda-layout.with-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .agenda-layout.with-panel {
    grid-template-columns: minmax(0, 1fr) 280px;
  }

  .agenda-aside {
    display: none;
  }
}

@media (max-width: 999px) {
  .agenda-layout.with-panel {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* -----------------------------------------------------------------------------
   Configuración: menú lateral agrupado por tema
   ----------------------------------------------------------------------------- */

.settings-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.settings-menu {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.settings-group {
  margin-top: 10px;
  padding: 0 10px 4px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.settings-group:first-child {
  margin-top: 0;
}

.settings-item {
  justify-content: flex-start;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font-weight: 500;
  text-align: left;
}

.settings-item:hover {
  background: var(--bg);
}

.settings-item[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
}

.settings-panels {
  min-width: 0;
}

@media (max-width: 860px) {
  .settings-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  /* En celular el menú se vuelve una fila de botones arriba del formulario. */
  .settings-menu {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0;
    border: 0;
    background: none;
  }

  .settings-group {
    display: none;
  }

  .settings-item {
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    font-size: 0.84rem;
  }
}

/* Barras verticales: una sola serie en el color de acento; escala (máximo y cero) a la izquierda. */
.bar-chart {
  --bars: 7;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: 160px auto;
  column-gap: 8px;
}

.bar-scale {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.bar-plot {
  display: grid;
  grid-template-columns: repeat(var(--bars), minmax(0, 1fr));
  align-items: end;
  gap: 2px;
  border-bottom: 1px solid var(--line-strong);
  background-image: linear-gradient(to bottom, var(--line) 1px, transparent 1px);
}

.bar {
  display: flex;
  align-items: flex-end;
  height: 100%;
  border-radius: 4px 4px 0 0;
  cursor: default;
}

.bar:hover,
.bar:focus-visible {
  background: var(--bg);
  outline: none;
}

.bar-fill {
  width: 70%;
  max-width: 36px;
  margin: 0 auto;
  border-radius: 4px 4px 0 0;
  background: var(--accent);
}

.bar:hover .bar-fill,
.bar:focus-visible .bar-fill {
  background: var(--accent-strong);
}

.bar-axis {
  grid-column: 2;
  display: grid;
  grid-template-columns: repeat(var(--bars), minmax(0, 1fr));
  gap: 2px;
  padding-top: 4px;
  color: var(--muted);
  font-size: 0.7rem;
  text-align: center;
  white-space: nowrap;
}

.chart-empty {
  padding: 24px 0;
}

.chart-tip {
  position: fixed;
  z-index: 40;
  max-width: 260px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  pointer-events: none;
}

/* Barras horizontales: formas de pago */
.hbar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hbar-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.9rem;
}

.hbar-track {
  height: 8px;
  margin: 4px 0 2px;
  border-radius: 4px;
  background: var(--chart-track);
  overflow: hidden;
}

.hbar-fill {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
}

.table-wrap.plain {
  border: 0;
  border-radius: 0;
}

.table-wrap.plain table {
  min-width: 0;
}

th.num,
td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.reports-note {
  max-width: 760px;
}

@media (max-width: 860px) {
  .reports-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
