/* ============================================================
   Vintage — shell y componentes
   ============================================================ */

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

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--cream);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 800; text-wrap: balance; }
p { margin: 0; }
svg.ico { filter: url(#rough-ico); }

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

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

/* ---------- utilidades ---------- */
.hand   { font-family: var(--font-hand); font-weight: 700; line-height: 1.05; }
.muted  { color: var(--ink-muted); }
.soft   { color: var(--ink-soft); }
.num    { font-variant-numeric: tabular-nums; }
.eyebrow {
  font-size: 10.5px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-muted);
}
.row    { display: flex; align-items: center; gap: 10px; }
.row-sb { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.col    { display: flex; flex-direction: column; }
.wrapx  { overflow-x: auto; }
.grow   { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.trunc  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* marcador mostaza inclinado detrás de una palabra */
.mark { position: relative; white-space: nowrap; padding: 0 5px; }
.mark::before {
  content: ""; position: absolute; left: 2px; right: 2px; bottom: 4px; top: 38%;
  background: var(--marker); transform: rotate(-1deg);
  border-radius: 3px 8px 4px 9px; z-index: 0;
}
.mark > span { position: relative; z-index: 1; }

/* ============================================================
   SHELL
   ============================================================ */
.shell { display: flex; height: 100%; width: 100%; overflow: hidden; }

/* --- rail --- */
.rail {
  width: var(--rail-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 0 10px; gap: 4px; overflow-y: auto; overflow-x: hidden;
}
.rail-logo {
  width: 42px; height: 42px; border-radius: var(--r-lg); background: var(--green);
  display: grid; place-items: center; margin-bottom: 12px; flex-shrink: 0;
}
.rail-item {
  width: 60px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 2px; border-radius: 11px; transition: background .15s; flex-shrink: 0;
}
.rail-item:hover { background: var(--surface-2); }
.rail-item[aria-current="true"] { background: var(--green-soft); }
.rail-item[aria-current="true"] .rail-label { color: var(--green-ink); }
.rail-label { font-size: 10px; font-weight: 700; color: var(--ink-muted); line-height: 1.1; text-align: center; }
.rail-spacer { flex: 1; min-height: 8px; }

/* El formulario de salir no debe crear caja: con display:contents el botón se
   coloca como un hermano más del rail, y el rail horizontal de móvil sigue
   funcionando sin reglas aparte. */
.rail-form { display: contents; }

.rail-quien {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 6px; color: var(--ink-muted); max-width: 100%;
}
.rail-quien .rail-label { max-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- panel de menú --- */
.menu {
  /* Fluido entre los dos anchos en vez de saltar de 180 a 224 al cruzar los
     1100px. El salto tenia un efecto al reves de lo que parece: la ventana
     crecia un pixel y **el contenido perdia 43**, porque el panel se los
     quedaba de golpe. */
  width: clamp(180px, 17vw, var(--menu-w));
  flex-shrink: 0;
  background: var(--cream-deep); border-right: 1px solid var(--border);
  padding: 18px 14px;

  /* Los dos ejes van juntos a proposito, y conviene no separarlos: en CSS, en
     cuanto un eje deja de ser `visible` el otro tampoco puede serlo. Con solo
     `overflow-y: auto`, cualquier cosa que asome por el lado —el adorno de
     `vintage.css` asomaba 22px— saca **las dos barras** teniendo sitio de
     sobra. Lo vigila `El_panel_del_modulo_no_tiene_barra_si_su_contenido_cabe`. */
  overflow-x: hidden;
  overflow-y: auto;
}
.menu-title { font-size: 14px; font-weight: 800; }
.menu-sub { font-size: 11.5px; color: var(--ink-muted); margin-bottom: 15px; }
.menu-group-label { margin: 4px 0 9px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 11px;
  padding: 11px 7px; display: flex; flex-direction: column; align-items: center;
  gap: 6px; text-align: center; transition: border-color .15s, background .15s;
  min-height: 84px; justify-content: center;
}
.tile:hover { border-color: var(--border-strong); }
.tile[aria-current="true"] { background: var(--green-soft); border-color: var(--green); }
.tile[aria-current="true"] .tile-label { color: var(--green-ink); }
.tile-label { font-family: var(--font-hand); font-size: 16px; font-weight: 700; line-height: 1.05; }
.tile-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.tile-icon-wrap { position: relative; }
.tile-badge {
  position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: var(--r-pill); background: var(--terracotta); color: var(--on-terracotta);
  font-size: 10px; font-weight: 800; display: grid; place-items: center;
}

/* --- área principal --- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: var(--topbar-h); flex-shrink: 0; background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
}
.view { flex: 1; overflow-y: auto; padding: 22px 26px 40px; }
.view-head { margin-bottom: 18px; }
.view-title { font-size: 19px; line-height: 1.15; }
.view-sub { font-size: 12.5px; color: var(--ink-muted); margin-top: 2px; }

/* ============================================================
   CONTROLES
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--r-md); font-size: 13px; font-weight: 700;
  border: 1px solid transparent; transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--green); color: var(--on-green); }
.btn-primary:hover { background: var(--green-hover); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--ink); }
.btn-ghost:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn-quiet { color: var(--ink-soft); padding: 7px 10px; }
.btn-quiet:hover { background: var(--surface-2); }
.btn-danger { background: var(--terracotta); color: var(--on-terracotta); }
.btn-danger:hover { background: var(--terracotta-deep); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn:disabled { opacity: .42; cursor: not-allowed; }

.icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm); display: grid; place-items: center;
  border: 1px solid transparent; transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); }
.icon-btn-bordered { border-color: var(--border); background: var(--surface); }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-muted); }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 11px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  font-size: 13.5px; transition: border-color .15s;
}
.input:hover { border-color: var(--border-strong); }
.input:disabled, .input[readonly] { background: var(--surface-sunk); color: var(--ink-muted); }
textarea.input { resize: vertical; min-height: 68px; line-height: 1.5; }
select.input {
  appearance: none; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 51%, calc(100% - 10px) 51%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}

.seg { display: inline-flex; gap: 3px; background: var(--cream-deep); border-radius: var(--r-md); padding: 3px; }
.seg-item { padding: 7px 14px; font-size: 12.5px; font-weight: 700; border-radius: var(--r-sm); color: var(--ink-muted); transition: background .15s, color .15s; }
.seg-item:hover { color: var(--ink); }
.seg-item[aria-pressed="true"] { background: var(--green); color: var(--on-green); }

.switch-row { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; }

/* ============================================================
   PIEZAS
   ============================================================ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.card-pad { padding: 16px; }
.card-head { padding: 13px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-size: 13.5px; font-weight: 800; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 13px 15px; display: flex; align-items: center; gap: 11px; text-align: left; }
.kpi-label { font-size: 11.5px; color: var(--ink-muted); font-weight: 600; }
.kpi-value { font-size: 20px; font-weight: 800; line-height: 1.1; }
.kpi-foot { font-size: 11px; color: var(--ink-muted); margin-top: 1px; }
.icon-chip { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border-radius: var(--r-sm); font-size: 11px; font-weight: 700; white-space: nowrap;
  border: 1px solid transparent; line-height: 1.5;
}
.badge-neutral   { background: var(--surface-sunk); color: var(--ink-soft); border-color: var(--border); }
.badge-green     { background: var(--green-soft); color: var(--green-ink); border-color: var(--green); }
.badge-mustard   { background: var(--mustard-soft); color: var(--mustard-ink); border-color: var(--mustard-deep); }
.badge-terracotta{ background: var(--terracotta-soft); color: var(--terracotta-ink); border-color: var(--terracotta); }
.badge-slate     { background: var(--slate-soft); color: var(--slate-ink); border-color: var(--slate); }

/* estados de cita */
.st { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: var(--r-sm); font-size: 11px; font-weight: 800; letter-spacing: .02em; border: 1px solid; white-space: nowrap; }
.st-reservada   { background: var(--st-rese-bg); border-color: var(--st-rese-bd); color: var(--st-rese-ink); }
.st-programada  { background: var(--st-prog-bg); border-color: var(--st-prog-bd); color: var(--st-prog-ink); }
.st-atendida    { background: var(--st-aten-bg); border-color: var(--st-aten-bd); color: var(--st-aten-ink); }
.st-cancelada   { background: var(--st-canc-bg); border-color: var(--st-canc-bd); color: var(--st-canc-ink); }
.st-no_asistio  { background: var(--st-noas-bg); border-color: var(--st-noas-bd); color: var(--st-noas-ink); }
.st-disponible  { background: var(--st-disp-bg); border: 1px dashed var(--st-disp-bd); color: var(--st-disp-ink); }

/* Cada estado presta su trazo al resaltador de abajo. */
.st-reservada    { --mk: var(--st-rese-mk); }
.st-programada   { --mk: var(--st-prog-mk); }
.st-atendida     { --mk: var(--st-aten-mk); }
.st-cancelada    { --mk: var(--st-canc-mk); }
.st-no_asistio   { --mk: var(--st-noas-mk); }
.st-reunion      { --mk: var(--st-reun-mk); }

/* ============================================================
   El estado, pintado con resaltador.

   Antes era una pildora con borde, y se leia como un boton que se
   puede pulsar — no lo es. Ahora es una palabra con un brochazo
   detras: el gesto de `.mark`, que estaba en el prototipo y no la
   usaba nadie. Cubre el texto entero y se pasa un poco por los
   cuatro lados, porque un resaltador de verdad se pasa.

   `isolation` encierra el z-index negativo del brochazo en esta
   caja: sin eso se iria detras de la fila y no se veria.
   ============================================================ */
.st-trazo {
  position: relative; isolation: isolate;
  background: none; border-color: transparent; border-radius: 0;
  padding: 1px 7px; font-size: 11.5px;
}
.st-trazo::before {
  content: ""; position: absolute; top: -1px; bottom: -1px; left: -2px; right: -2px;
  background: var(--mk); transform: rotate(-1deg);
  border-radius: 3px 8px 4px 9px; z-index: -1;
}
/* El de «disponible» es la excepcion: su raya discontinua dice «aqui no hay
   nada», y un brochazo encima diria lo contrario. */
.st-trazo.st-disponible { border: 1px dashed var(--st-disp-bd); padding: 2px 8px; }
.st-trazo.st-disponible::before { content: none; }

.avatar { border-radius: 50%; display: grid; place-items: center; color: var(--on-avatar); font-weight: 700; flex-shrink: 0; }
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }
.avatar-md { width: 34px; height: 34px; font-size: 12px; }
.avatar-lg { width: 52px; height: 52px; font-size: 17px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-pill); padding: 4px 12px 4px 4px;
  font-size: 12.5px; font-weight: 600; transition: border-color .15s, background .15s;
}
.chip:hover { border-color: var(--border-strong); }
.chip[aria-pressed="false"] { opacity: .45; }
.chip-plain { padding: 4px 11px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { padding: 10px 15px; font-size: 13px; font-weight: 700; color: var(--ink-muted); border-bottom: 2.5px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--green-ink); border-bottom-color: var(--green); }

/* tablas */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; padding: 9px 12px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase; color: var(--ink-muted);
  border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface);
}
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr.clickable:hover { background: var(--surface-2); cursor: pointer; }
.tbl .r { text-align: right; }

.dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13px; align-items: baseline; }
.dl dt { color: var(--ink-muted); font-size: 12px; font-weight: 600; }
.dl dd { margin: 0; font-weight: 600; }

.empty { text-align: center; padding: 34px 20px; color: var(--ink-muted); }
.empty .hand { font-size: 23px; color: var(--ink-muted); }

.bar { height: 7px; border-radius: var(--r-pill); background: var(--surface-sunk); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: var(--r-pill); background: var(--green); }

/* lista de acciones del asistente */
.action-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 13px 15px; border-bottom: 1px solid var(--border-soft); transition: background .15s;
}
.action-item:last-child { border-bottom: none; }
.action-item:hover { background: var(--surface-2); }
.action-count { font-size: 21px; font-weight: 800; min-width: 34px; font-variant-numeric: tabular-nums; }
.action-text { font-size: 13.5px; font-weight: 700; }
.action-hint { font-size: 11.5px; color: var(--ink-muted); margin-top: 1px; }
.action-go { margin-left: auto; color: var(--ink-muted); font-size: 17px; }

/* ============================================================
   MODAL
   ============================================================ */
.scrim {
  position: fixed; inset: 0; background: var(--scrim);
  display: grid; place-items: center; padding: 20px; z-index: 100;
  animation: fade .16s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: var(--sh-modal); width: 100%; max-width: 620px;
  max-height: calc(100dvh - 40px); display: flex; flex-direction: column; overflow: hidden;
}
.modal-lg { max-width: 940px; }
.modal-sm { max-width: 460px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-shrink: 0; }
.modal-title { font-size: 16px; font-weight: 800; }
.modal-sub { font-size: 12px; color: var(--ink-muted); margin-top: 2px; }
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-shrink: 0; background: var(--surface-2); flex-wrap: wrap; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 13px; }
.form-grid .span2 { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span2 { grid-column: auto; } }
/* Los diálogos siguen en dos columnas en el teléfono: hora y duración, importe y
   forma de pago caben de dos en dos, y una sola columna los alargaba hasta
   obligar a desplazarse para llegar al botón. Tres reglas de criterio:
     - `.span2` ya decía «ancho entero» y se respeta.
     - `.span-m` es lo que lleva texto largo (correo, profesional, parentesco):
       en media pantalla se cortaría, así que ocupa el ancho entero aquí.
     - `.form-grid-uno` vuelve a una columna, para los diálogos donde emparejar
       dejaría un campo solo con un hueco al lado.
   `.form-grid-par` queda para los formularios que no están en un diálogo. */
@media (max-width: 560px) {
  .scrim .form-grid:not(.form-grid-uno), .form-grid.form-grid-par {
    grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px 10px;
  }
  .scrim .form-grid:not(.form-grid-uno) .span2, .scrim .form-grid:not(.form-grid-uno) .span-m,
  .form-grid-par .span2, .form-grid-par .span-m { grid-column: 1 / -1; }
}

/* panel de validaciones de la cita */
.checks { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: 12.5px; font-weight: 600; }
.check-mark { width: 17px; height: 17px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; flex-shrink: 0; margin-top: 1px; }
.check-ok   .check-mark { background: var(--green); color: var(--on-green); }
.check-bad  .check-mark { background: var(--terracotta); color: var(--on-terracotta); }
.check-bad  { color: var(--terracotta-ink); }
.check-wait .check-mark { background: var(--surface-sunk); color: var(--ink-faint); border: 1px solid var(--border); }
.check-wait { color: var(--ink-muted); }
.check-why { font-weight: 500; font-size: 11.5px; color: var(--ink-muted); display: block; margin-top: 1px; }

/* toast */
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; width: calc(100% - 32px); max-width: 460px; }
.toast {
  background: var(--green); color: var(--on-green); padding: 11px 17px; border-radius: var(--r-md);
  font-size: 13px; font-weight: 700; box-shadow: var(--sh-lg); animation: rise .2s ease-out;
  display: flex; align-items: center; gap: 9px; width: 100%;
}
.toast-warn { background: var(--mustard); color: var(--on-mustard); }
@keyframes rise { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }

/* ============================================================
   AGENDA
   ============================================================ */
.ag-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.ag-date { font-size: 15px; font-weight: 800; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }

/* vista día — lista */
.day-row { display: grid; grid-template-columns: 74px 1fr auto; gap: 14px; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); align-items: center; }
.day-row:last-child { border-bottom: none; }
.day-row:hover { background: var(--surface-2); }
.day-time { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.day-date { font-size: 10.5px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.day-free { display: flex; align-items: center; gap: 12px; }
.day-actions { display: flex; align-items: center; gap: 2px; }
.pt-name { font-size: 13.5px; font-weight: 700; }
.pt-meta { font-size: 11.5px; color: var(--ink-muted); }
.pt-since { font-size: 11px; color: var(--ink-faint); font-style: italic; }

/* vista semana — grilla */
.wk { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.wk-scroll { overflow-x: auto; }
.wk-inner { min-width: 840px; }
.wk-head, .wk-body { display: grid; grid-template-columns: 54px repeat(7, minmax(112px, 1fr)); }
.wk-dow { text-align: center; padding: 9px 4px; font-size: 11.5px; font-weight: 700; color: var(--ink-muted); border-left: 1px solid var(--border); }
.wk-dow-today { background: var(--mustard-soft); color: var(--green-ink); font-weight: 800; }
.wk-body { border-top: 1px solid var(--border); }
.wk-hours > div { height: 62px; text-align: right; padding: 3px 7px 0 0; font-size: 10.5px; color: var(--ink-muted); border-bottom: 1px solid var(--border-soft); font-variant-numeric: tabular-nums; }
.wk-col { border-left: 1px solid var(--border); }
.wk-col-today { background: var(--mustard-soft); }
.wk-cell { height: 62px; border-bottom: 1px solid var(--border-soft); padding: 3px; position: relative; }
.wk-cell-free:hover { background: var(--green-soft); cursor: pointer; }
.appt { border-radius: var(--r-sm); padding: 5px 7px; font-size: 11px; height: 100%; overflow: hidden; border-left: 3px solid; text-align: left; width: 100%; display: block; box-shadow: var(--sh-xs); }
.appt-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appt-meta { font-size: 10px; opacity: .82; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appt-cancel .appt-name { text-decoration: line-through; }

/* vista mes */
.mo { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.mo-dow { padding: 8px 4px; text-align: center; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-muted); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.mo-day { min-height: 94px; border-right: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft); padding: 6px; text-align: left; display: flex; flex-direction: column; gap: 4px; }
.mo-day:hover { background: var(--surface-2); }
.mo-day-out { opacity: .38; }
.mo-day-today .mo-num { background: var(--green); color: var(--on-green); }
.mo-num { font-size: 11.5px; font-weight: 700; width: 21px; height: 21px; border-radius: 50%; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.mo-dots { display: flex; flex-wrap: wrap; gap: 3px; }
.mo-dot { width: 7px; height: 7px; border-radius: 50%; }
.mo-count { font-size: 10.5px; color: var(--ink-muted); font-weight: 700; margin-top: auto; }

/* agenda grupo */
.grp-cell { padding: 4px; border-left: 1px solid var(--border); border-bottom: 1px solid var(--border-soft); min-height: 56px; }
.grp-appt { border-radius: var(--r-sm); padding: 4px 6px; font-size: 10.5px; border-left: 3px solid; margin-bottom: 3px; width: 100%; text-align: left; display: block; }

/* disponibilidad */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.slot { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 9px 8px; text-align: center; font-size: 12px; font-weight: 700; background: var(--surface); }
.slot-free { background: var(--green-soft); border-color: var(--green); color: var(--green-ink); }
.slot-free:hover { background: var(--st-aten-bg); }
.slot-busy { color: var(--ink-faint); background: var(--surface-sunk); cursor: not-allowed; }
.slot-day { font-size: 10px; font-weight: 600; color: var(--ink-muted); display: block; margin-bottom: 2px; }

/* resumen del día */
.mini { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border-soft); align-items: flex-start; width: 100%; text-align: left; }
.mini:last-child { border-bottom: none; }
.mini:hover { background: var(--surface-2); }
.mini-time { font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 50px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  /* El ancho ya lo resuelve el `clamp` de `.menu`, de forma continua. Aqui
     solo cambia la rejilla: a esta anchura dos mosaicos por fila dejan las
     etiquetas en dos palabras cortadas. */
  .tiles { grid-template-columns: 1fr; }
  .tile { flex-direction: row; justify-content: flex-start; text-align: left; min-height: 0; padding: 9px 11px; gap: 9px; }
}

@media (max-width: 860px) {
  body { overflow: auto; }
  .shell { flex-direction: column; height: auto; min-height: 100%; }
  .rail {
    width: 100%; flex-direction: row; border-right: none; border-bottom: 1px solid var(--border);
    padding: 8px 12px; gap: 6px; overflow-x: auto; overflow-y: hidden;
    position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  }
  .rail-logo { margin-bottom: 0; width: 36px; height: 36px; }
  .rail-item { flex-direction: row; width: auto; padding: 8px 12px; gap: 7px; }
  .rail-spacer { display: none; }
  .menu { width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding: 12px 16px; }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .main { overflow: visible; }
  .topbar { height: auto; padding: 10px 16px; flex-wrap: wrap; }
  .view { overflow: visible; padding: 18px 16px 48px; }
  .modal { max-height: calc(100dvh - 24px); }
  .scrim { padding: 12px; }
}

@media (max-width: 520px) {
  .view { padding: 16px 16px 44px; }
  .day-row { grid-template-columns: 1fr; gap: 9px; }
  .day-actions { justify-content: flex-start; }
  .kpi-value { font-size: 18px; }
  .mo-day { min-height: 68px; padding: 4px; }
}

/* ============================================================
   BARRAS DE MAGNITUD
   Una sola serie, un solo tono: la longitud codifica el valor y
   el número va escrito al lado, así el color nunca es el único
   canal de lectura.
   ============================================================ */
.hbar { display: flex; flex-direction: column; gap: 9px; }
.hbar-row { display: grid; grid-template-columns: minmax(96px, 1.1fr) 2fr auto; gap: 11px; align-items: center; }
.hbar-label { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 9px; background: var(--surface-sunk); border-radius: 2px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--green); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-fill-quiet { background: var(--ink-faint); }
.hbar-fill-warn  { background: var(--mustard-deep); }
.hbar-val { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-soft); min-width: 42px; text-align: right; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.cols2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; align-items: start; }
.cols3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; align-items: start; }

.hero { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 20px 22px; }
.hero-hi { font-family: var(--font-hand); font-size: 34px; font-weight: 700; line-height: 1.02; }
.hero-sub { font-size: 13px; color: var(--ink-muted); margin-top: 3px; }

/* ============================================================
   TIRAS QUE SE DESPLAZAN A MANO

   El contenido se difumina por el borde por el que continúa. Con
   máscara y no con una sombra encima: las fichas son opacas y una
   sombra por detrás no se vería, y una por delante taparía justo la
   ficha que hay que pulsar.

   Las clases las pone `tiras.js`, y sólo cuando de verdad sobra
   contenido: un degradado permanente es un adorno, y nadie mira los
   adornos.
   ============================================================ */
.tira-der {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 44px), transparent 100%);
          mask-image: linear-gradient(to right, #000 calc(100% - 44px), transparent 100%);
}

.tira-izq {
  -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 44px), transparent 100%);
          mask-image: linear-gradient(to left, #000 calc(100% - 44px), transparent 100%);
}

.tira-izq.tira-der {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 44px,
                                      #000 calc(100% - 44px), transparent 100%);
          mask-image: linear-gradient(to right, transparent 0, #000 44px,
                                      #000 calc(100% - 44px), transparent 100%);
}

/* El rail en vertical no se desplaza: la máscara sólo vale tumbado. */
@media (min-width: 861px) {
  .rail.tira-der, .rail.tira-izq {
    -webkit-mask-image: none;
            mask-image: none;
  }
}

/* ============================================================
   Saltar al contenido (WCAG 2.4.1).
   Escondido hasta que recibe el foco, y entonces aparece arriba
   a la izquierda. No se usa `.sr-only` a secas porque entonces
   seguiria invisible al enfocarlo y nadie sabria que lo tiene.
   ============================================================ */
.saltar {
  position: fixed; top: 8px; left: 8px; z-index: 100;
  transform: translateY(-160%);
  padding: 10px 16px; border-radius: var(--r-md);
  background: var(--green); color: var(--on-green);
  font-size: 13px; font-weight: 800; text-decoration: none;
  box-shadow: var(--sh-md);
}
.saltar:focus-visible { transform: none; }

/* ============================================================
   Mientras se esperan los datos (ocupado.js).
   Se apaga el disparador y el cursor lo dice. **Sin rueda que
   gire**, y es deliberado: el prototipo aprobado no tiene
   vocabulario de carga en ninguna pantalla, y meter uno es una
   decision de diseno que se toma alli, no aqui. Lo que esto
   arregla es que no pasara nada y que la segunda pulsacion
   abriera dos dialogos.
   ============================================================ */
.esta-ocupado {
  opacity: .55;
  cursor: progress;
}
