/* =====================================================================
   Bismuto Agenda — sistema visual
   Manual de marca v1.0: blancos y lilas con morados profundos; tornasol solo como detalle.
   Plus Jakarta Sans para todo lo que se lee; Unbounded solo en títulos y cifras grandes (nunca bajo 14 px).
   ===================================================================== */
@font-face {
  font-family: 'Plus Jakarta Sans'; font-style: normal; font-display: swap; font-weight: 200 800;
  src: url(/fonts/plus-jakarta-sans-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Plus Jakarta Sans'; font-style: normal; font-display: swap; font-weight: 200 800;
  src: url(/fonts/plus-jakarta-sans-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Unbounded'; font-style: normal; font-display: swap; font-weight: 200 900;
  src: url(/fonts/unbounded-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Unbounded'; font-style: normal; font-display: swap; font-weight: 200 900;
  src: url(/fonts/unbounded-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Paleta del manual de marca v1.0 (docs/MARCA.md). Bismuto no usa negro: el oscuro siempre es morado.
   Los nombres de variables se mantienen por compatibilidad; los valores son los de la marca. */
:root {
  --blanco: #ffffff; --niebla: #f6f2fd; --lila: #e6dcfa; --lavanda: #c9b6f2; --violeta: #9b7bea;
  --morado: #6b44c9; --morado-noche: #3b2180; --tinta: #2d1863; --abismo: #1e1038;
  --tornasol: linear-gradient(120deg, #f6e2b0, #f5c9e4 35%, #c9a6ff 68%, #a8e6ee);
  --violet: var(--morado);          /* acento principal, enlaces */
  --violet-600: var(--morado-noche);
  --violet-50: var(--niebla);
  --violet-100: var(--lila);
  --primary: var(--tinta);          /* botón principal */
  --accent: var(--violet);          /* acento: hoy, filtros activos, pasos (la clínica puede elegir otro) */
  --accent-50: var(--violet-50);
  --accent-100: var(--violet-100);
  --primary-hover: var(--morado-noche);
  --teal: #1f7a5c;                  /* solo estados «ok» (confirmada, firmada, pagado); no es color de marca */
  --teal-50: #e6f4ee;
  --ok-text: #17634a;
  --ink: var(--tinta);
  --ink-2: #4a3f6e;
  --muted: #6d6489;
  --line: var(--lila);
  --line-2: #efe9fb;
  --field-line: var(--lavanda);
  --soft-bg: #fbf9fe;
  --canvas: var(--niebla);
  --surface: #ffffff;
  --rose: #c9374f;
  --rose-50: #fdecef;
  --radius: 14px;                   /* tarjetas */
  --radius-sm: 10px;                /* botones y campos */
  --sidebar: 236px;
  --focus: 0 0 0 3px var(--lila);   /* foco: borde Morado + halo Lila */
  --shadow-rgb: 45, 24, 99;         /* sombras teñidas de Tinta, nunca grises */
  --accent-rgb: 107, 68, 201;       /* Morado en rgb, para tramas y selecciones translúcidas */
  --closed-bg: rgba(246, 242, 253, .6);
  --row-hover: #faf7fe;
  --faint: #a99fc6;
  font-family: 'Plus Jakarta Sans', Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
/* iPhone no agranda la letra por su cuenta (cambiaba tamaños entre columnas) */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { background: var(--canvas); color: var(--ink); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--violet); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error-text { color: var(--rose); min-height: 1.2em; margin: 6px 0; }

h2 { font-family: 'Unbounded', Arial, sans-serif; font-size: 21px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; margin: 0 0 16px; }
h3 { font-size: 16px; font-weight: 650; margin: 20px 0 10px; }
h4 { font-size: 14px; font-weight: 650; margin: 14px 0 6px; }

/* ---------- Estructura: barra lateral + contenido ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; overflow-y: auto;
}
/* Logo oficial (archivo del manual, con su aire incorporado): solo se escala, nunca se recorta ni estira */
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 0 2px 14px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-logo { display: block; width: 176px; height: auto; flex: none; }
.crystal { width: 48px; height: 48px; flex: none; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 550;
}
nav a svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
nav a:hover { background: var(--line-2); text-decoration: none; color: var(--ink); }
nav a.active { background: var(--violet-50); color: var(--violet); }
#user-box {
  margin-top: auto; border-top: 1px solid var(--line); padding: 12px 8px 0; display: flex; flex-direction: column; gap: 8px;
}
#user-box:empty { display: none; }
#user-box .who { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600; }
#user-box .who:hover { text-decoration: none; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--violet-100); color: var(--violet-600); font-weight: 700; font-size: 13px;
}
#user-box .role { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
#company { display: block; font-size: 12px; color: var(--muted); font-weight: 500; padding-left: 6px; }

.main { min-width: 0; }
.topbar { display: none; }
main#view { padding: 28px 32px 48px; max-width: 1280px; }
#flash {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm);
  box-shadow: 0 6px 24px rgba(var(--shadow-rgb), .18); font-weight: 550; max-width: calc(100vw - 32px);
}
#flash.error { background: var(--rose); }

/* Móvil: la barra lateral se vuelve un menú desplegable */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(280px, 85vw); z-index: 150; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: 0 0 40px rgba(var(--shadow-rgb), .2);
  }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .main::before { content: ''; position: fixed; inset: 0; z-index: 140; background: rgba(var(--shadow-rgb), .32); }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 100;
    background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 16px;
  }
  .topbar .brand-logo { width: 144px; }
  main#view { padding: 18px 16px 40px; }
}

/* ---------- Controles ---------- */
button, a.button {
  font: inherit; font-weight: 600; color: var(--ink); background: var(--surface); cursor: pointer;
  border: 1px solid var(--lavanda); border-radius: var(--radius-sm); padding: 7px 12px; min-height: 36px;
  transition: background .12s, border-color .12s;
}
button:hover, a.button:hover { background: var(--line-2); border-color: var(--lavanda); }
a.button { display: inline-flex; align-items: center; text-decoration: none; box-sizing: border-box; }
button:disabled { opacity: .5; cursor: default; }
/* Acción principal: botones de envío de formularios y los marcados .primary */
form button:not([type=button]), button.primary {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
form button:not([type=button]):hover, button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
/* Una sola acción destacada por pantalla puede llevar el tornasol */
button.tornasol { background: var(--tornasol); border-color: transparent; color: var(--tinta); }
button.tornasol:hover { background: var(--tornasol); filter: saturate(1.15); border-color: transparent; }
button.danger { color: var(--rose); }
button.danger:hover { background: var(--rose-50); border-color: #f3c3cb; }

label { display: block; margin: 0 0 12px; font-weight: 550; color: var(--ink-2); font-size: 13px; }
label.inline { display: inline-flex; align-items: center; gap: 8px; margin: 4px 16px 8px 0; font-weight: 500; color: var(--ink); font-size: 14px; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  display: block; width: 100%; max-width: 100%; margin-top: 5px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--field-line); border-radius: var(--radius-sm); padding: 8px 10px; min-height: 38px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--violet); box-shadow: var(--focus); }
textarea { resize: vertical; }
input[type=time], input[type=date] { font-variant-numeric: tabular-nums; }
input[type=file] { margin-top: 6px; font: inherit; }

/* Casillas como interruptores (estilo panel de configuración) */
input[type=checkbox] {
  appearance: none; width: 34px; height: 20px; border-radius: 999px; background: var(--lavanda); position: relative;
  margin: 0; flex: none; cursor: pointer; transition: background .15s;
}
input[type=checkbox]::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(var(--shadow-rgb), .25); transition: transform .15s;
}
input[type=checkbox]:checked { background: var(--violet); }
input[type=checkbox]:checked::after { transform: translateX(14px); }
input[type=radio] { accent-color: var(--violet); width: 16px; height: 16px; margin: 0; }
/* Opciones múltiples en fichas: casilla cuadrada, no interruptor */
.check-list input[type=checkbox] { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--violeta); background: #fff; }
.check-list input[type=checkbox]::after { display: none; }
.check-list input[type=checkbox]:checked { background: var(--violet) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' stroke='white' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") center/14px no-repeat; border-color: var(--violet); }

/* Lista de servicios con casillas (profesionales, recursos): buscador, familias y filas compactas */
.svc-tools { display: flex; align-items: center; gap: 12px; }
.svc-tools input[type=search] { flex: 1; width: auto; margin-top: 0; }
.svc-tools label.inline { margin: 0; white-space: nowrap; }
.svc-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 2px 6px; font-size: 12px; }
.svc-count { color: var(--muted); font-weight: 600; }
.svc-bulk { color: var(--muted); white-space: nowrap; }
.svc-bulk .link-btn, .svc-group-head .link-btn { font-size: 12px; }
.svc-list { max-height: 380px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.svc-group + .svc-group { border-top: 1px solid var(--line-2); }
.svc-group-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; background: var(--soft-bg); font-size: 12px; color: var(--ink);
}
.svc-group-head .link-btn { margin-left: auto; }
.svc-group-count { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.svc-group-count.some { color: var(--violet-600); font-weight: 600; }
.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 1px 4px; padding: 4px 6px; }
.svc-row { display: flex; align-items: center; gap: 7px; margin: 0; padding: 4px 6px; border-radius: 5px;
  font-weight: 500; font-size: 12px; color: var(--ink); cursor: pointer; min-width: 0; }
.svc-row > span { min-width: 0; overflow-wrap: break-word; hyphens: auto; line-height: 1.3; }
.svc-row:hover { background: var(--violet-50); }
.svc-row.on { color: var(--violet-600); font-weight: 600; }
.svc-row.inactive { color: var(--muted); }
.svc-list.check-list input[type=checkbox] { width: 14px; height: 14px; border-radius: 4px; border-width: 1.5px; }
.svc-list.check-list input[type=checkbox]:checked { background-size: 11px; }
.svc-tag { margin-left: 5px; font-size: 10.5px; color: var(--muted); }
.svc-empty { margin: 12px; }
@media (max-width: 560px) {
  .svc-tools { flex-wrap: wrap; }
  .svc-tools input[type=search] { flex-basis: 100%; }
  .svc-grid { grid-template-columns: 1fr 1fr; padding: 4px; }
  .svc-row { gap: 6px; padding: 5px 4px; font-size: 12px; }
}

/* ---------- Paneles (fieldset) y disposición ---------- */
fieldset {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px 16px; margin: 0 0 18px; min-width: 0;
}
legend { float: left; width: 100%; padding: 0; margin: 0 0 14px; font-size: 15px; font-weight: 700; color: var(--ink); }
legend + * { clear: both; }
fieldset fieldset { background: var(--soft-bg); border-color: var(--line-2); padding: 14px 16px 10px; }
fieldset fieldset legend { font-size: 14px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin: 0 0 4px; }
.row > label { flex: 1 1 180px; margin-bottom: 12px; }
.row > label.inline { flex: 0 0 auto; }
.row > button { margin-bottom: 12px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 1000px) { .cols { grid-template-columns: 1fr; } }
.hour-row { flex-wrap: nowrap; align-items: center; margin-bottom: 8px; }
.hour-row > * { margin: 0 !important; }
.hour-row select, .hour-row input { width: auto !important; min-width: 0; flex: 1 1 120px; }
.hour-row span { color: var(--muted); }
@media (max-width: 560px) { .hour-row { flex-wrap: wrap; } }

/* ---------- Tablas como listas ---------- */
table {
  width: 100%; border-collapse: separate; border-spacing: 0; margin: 0 0 20px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
th { text-align: left; font-size: 12.5px; font-weight: 650; color: var(--muted); background: var(--soft-bg); padding: 10px 14px; border-bottom: 1px solid var(--line); }
td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: var(--row-hover); }
tr.muted td { color: var(--muted); }
tr.cancelled td { color: var(--muted); text-decoration: line-through; }
/* Celular: cada fila es una tarjeta (sin desplazar de lado). Cada celda muestra su columna (data-label, ver lib.js);
   la primera va como título. Las tablas de vista previa de importación siguen desplazándose. */
@media (max-width: 700px) {
  table:not(.import-table table) { display: block; border: 0; background: none; border-radius: 0; overflow: visible; margin-bottom: 12px; }
  table:not(.import-table table) :is(thead, tbody) { display: block; }
  table:not(.import-table table) tr:has(> th) { display: none; }
  table:not(.import-table table) tr {
    display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 0 0 8px;
  }
  table:not(.import-table table) td {
    display: block; padding: 4px 0; border: 0; text-align: right; white-space: normal; overflow-wrap: anywhere; font-size: 14px;
  }
  table:not(.import-table table) td::after { content: ''; display: block; clear: both; }
  table:not(.import-table table) td[data-label]:not([data-label=''])::before {
    content: attr(data-label); float: left; max-width: 45%; margin-right: 12px; text-align: left; color: var(--muted); font-size: 12.5px; font-weight: 600;
  }
  table:not(.import-table table) td:first-child { display: block; text-align: left; font-weight: 650; font-size: 15px; padding: 0 0 6px; }
  table:not(.import-table table) td:first-child::before { display: none; }
  table:not(.import-table table) td.blank { display: none; }
  table:not(.import-table table) td.num { text-align: right; }
  table:not(.import-table table) tr:hover td { background: none; }
  table:not(.import-table table) tr.clickable:active { background: var(--violet-50); }
  .import-table table { white-space: nowrap; }
}

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 650;
  background: var(--violet-50); color: var(--violet-600); white-space: nowrap;
}
.badge.st-confirmed { background: var(--teal-50); color: var(--ok-text); }
.badge.st-completed { background: var(--lila); color: var(--ink-2); }
.badge.st-cancelled { background: var(--line-2); color: var(--muted); text-decoration: line-through; }
.badge.st-no_show { background: var(--rose-50); color: var(--rose); }
.badge.rec-signed { background: var(--teal-50); color: var(--ok-text); }
.badge.rec-draft { background: #fff4dc; color: #8a5a00; }
.record-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.record-signed { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 8px; }
.addendum { border-left: 3px solid var(--violet-100); padding: 2px 0 2px 10px; margin: 8px 0; }
.addendum p { margin: 2px 0; white-space: pre-wrap; }

dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0 0 16px; }
dt { font-weight: 600; color: var(--muted); }
dd { margin: 0; white-space: pre-wrap; }
dt.section { grid-column: 1 / -1; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--violet); font-size: 13px; }
details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 10px; }
details[open] summary { margin-bottom: 12px; }
summary { cursor: pointer; font-weight: 600; }
h4.form-section { margin: 18px 0 10px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--violet); }
.field-row.is-section fieldset { background: var(--violet-50); border-color: var(--violet-100); }
pre { font: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }

/* Horarios disponibles */
.slots { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.slots button { min-width: 64px; font-variant-numeric: tabular-nums; font-weight: 600; background: var(--surface); }
.slots button:hover { border-color: var(--violet); color: var(--violet); background: var(--violet-50); }
.slots button.selected { background: var(--violet); border-color: var(--violet); color: #fff; }

/* ---------- Calendario ---------- */
.cal-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px 16px; }
.cal-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.cal-toolbar .spacer { flex: 1; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; padding: 0; }
.icon-btn svg, button.primary svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.on { background: var(--accent-50); border-color: var(--accent-100); color: var(--accent); }
.icon-btn.plain { border-color: transparent; background: transparent; width: 32px; }
.icon-btn.plain:hover { background: var(--line-2); }
button.soft { background: var(--violet-50); border-color: var(--violet-50); color: var(--violet-600); }
button.soft:hover { background: var(--violet-100); border-color: var(--violet-100); }
button.primary { display: inline-flex; align-items: center; gap: 6px; }
.cal-arrows { display: inline-flex; }
.cal-title { position: relative; margin: 0 4px; font-size: 17px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; cursor: pointer; }
.cal-title:hover { color: var(--violet); }
.cal-title .cal-date { position: absolute; inset: 0; opacity: 0; pointer-events: none; width: 100%; min-height: 0; margin: 0; padding: 0; }
.cal-toolbar select.cal-view-select { width: auto; margin: 0; min-width: 180px; }
.cal-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px 16px; padding: 12px 14px 0; margin: 0 0 12px; background: var(--soft-bg); border: 1px solid var(--line-2); border-radius: var(--radius); }
.cal-filters > label:not(.inline) { min-width: 240px; }
.cal-zoom { display: inline-flex; align-items: center; }
.cal-zoom .icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.cal-hidden-note { margin: -4px 2px 10px; }
.cal-hint { margin: 10px 2px 0; }
.cal-wrap { overflow: auto; max-height: calc(100vh - 230px); border-top: 1px solid var(--line-2); }
.cal { user-select: none; touch-action: manipulation; --col-min: 130px; }
.cal-head { display: flex; position: sticky; top: 0; z-index: 7; background: var(--surface); border-bottom: 1px solid var(--line); }
.cal-gutter-head, .cal-gutter { width: 56px; flex: none; position: sticky; left: 0; background: var(--surface); }
.cal-gutter-head { z-index: 4; }
.cal-gutter { z-index: 6; }
.cal-colhead {
  flex: 1 1 0; min-width: var(--col-min); padding: 10px 8px; border: 0; border-left: 1px solid var(--line-2); border-radius: 0;
  background: var(--surface); font-weight: 650; color: var(--ink); min-height: 0; text-transform: capitalize;
  display: flex; align-items: center; justify-content: center; gap: 8px; text-align: left;
}
.colhead-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.colhead-text small { font-weight: 500; color: var(--muted); font-size: 11.5px; text-transform: none; }
.avatar.sm { width: 28px; height: 28px; font-size: 11.5px; }
.cal-colhead:hover { background: var(--violet-50); }
.cal-colhead.today { color: var(--accent); }
.cal-body { display: flex; }
.cal-hour { position: absolute; right: 8px; font-size: 11.5px; color: var(--muted); transform: translateY(-7px); font-variant-numeric: tabular-nums; }
.cal-hour:first-child { transform: none; }
.cal-col {
  flex: 1 1 0; min-width: var(--col-min); position: relative; border-left: 1px solid var(--line-2); cursor: cell;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(var(--line-2) 1px, transparent 1px);
  background-size: 100% var(--hour), 100% calc(var(--hour) / 2);
}
.cal-off { position: absolute; left: 0; right: 0; pointer-events: none;
  background: repeating-linear-gradient(135deg, rgba(var(--accent-rgb), .09) 0 1px, transparent 1px 9px), var(--closed-bg); }
.cal-block {
  position: absolute; left: 2px; right: 2px; z-index: 1; font-size: 11.5px; padding: 4px 6px; overflow: hidden; cursor: pointer; color: var(--ink-2);
  background: var(--line-2); border-radius: 6px; display: flex; gap: 5px; align-items: flex-start; font-weight: 600;
}
.cal-block svg, .month-block svg { width: 14px; height: 14px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.cal-event {
  --ev: var(--violet);
  position: absolute; z-index: 2; font-size: 12px; line-height: 1.3; padding: 5px 8px; overflow: hidden; cursor: grab;
  border: 1px solid color-mix(in srgb, var(--ev) 40%, white); border-radius: 7px;
  background: color-mix(in srgb, var(--ev) 16%, white); color: var(--ink);
}
.cal-event.compact { padding: 0 6px; font-size: 11px; line-height: 1.25; white-space: nowrap; text-overflow: ellipsis; }
.cal-event:hover { box-shadow: 0 3px 12px rgba(var(--shadow-rgb), .14); z-index: 5; }
.cal-ev-title { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev-time { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.cal-event.dragging { opacity: .9; z-index: 10; cursor: grabbing; pointer-events: none; box-shadow: 0 8px 24px rgba(var(--shadow-rgb), .25); }
.cal-event.st-completed { filter: saturate(.35); opacity: .85; }
.cal-event.st-cancelled { background: var(--soft-bg); border-style: dashed; color: var(--muted); text-decoration: line-through; }
.cal-event.st-no_show { background: var(--rose-50); border-color: #f1b3bd; }
.cal-selection { position: absolute; left: 3px; right: 3px; z-index: 4; background: rgba(var(--accent-rgb), .12); border: 1.5px dashed var(--violet); border-radius: 6px; font-size: 12px; padding: 3px 6px; color: var(--violet-600); font-weight: 600; pointer-events: none; }
.quick-menu {
  position: fixed; z-index: 160; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(var(--shadow-rgb), .16); display: flex; flex-direction: column; padding: 4px; min-width: 190px;
}
.quick-menu button { border: 0; background: none; text-align: left; padding: 9px 12px; font-weight: 550; }
.quick-menu button:hover { background: var(--violet-50); color: var(--violet); }

.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line-2); }
.month-head { padding: 8px 10px; font-weight: 650; color: var(--muted); font-size: 12.5px; text-align: center; }
.month-cell { min-height: 116px; padding: 6px 6px 4px; border-left: 1px solid var(--line-2); border-top: 1px solid var(--line-2); cursor: cell; overflow: hidden; background: var(--soft-bg); }
.month-cell:nth-child(7n + 1) { border-left: 0; }
.month-cell.closed { background: repeating-linear-gradient(135deg, rgba(var(--accent-rgb), .07) 0 1px, transparent 1px 9px), var(--soft-bg); }
.month-cell.other .month-day { color: var(--faint); }
.month-day { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 4px; border-radius: 6px; font-weight: 650; font-size: 12.5px; color: var(--ink); margin-bottom: 4px; }
.month-day:hover { background: var(--violet-50); text-decoration: none; }
.month-cell.today .month-day { background: var(--accent); color: #fff; }
.month-event, .month-block {
  display: flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 4px; margin-bottom: 1px; border-radius: 5px;
  cursor: pointer; white-space: nowrap; overflow: hidden;
}
.month-event:hover, .month-block:hover { background: var(--surface); box-shadow: 0 1px 4px rgba(var(--shadow-rgb), .1); }
.month-event .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.month-event b, .month-block b { font-weight: 700; font-variant-numeric: tabular-nums; }
.month-event.st-cancelled { color: var(--muted); text-decoration: line-through; }
.month-block { color: var(--ink-2); }
@media (max-width: 700px) { .month-cell { min-height: 72px; } .month-event, .month-block { font-size: 10.5px; } .month-event .dot { display: none; } }

/* ---------- Panel lateral (detalle de cita, formularios rápidos) ---------- */
dialog.modal {
  position: fixed; inset: 0 0 0 auto; margin: 0; height: 100vh; max-height: 100vh; width: min(480px, 100vw); max-width: 100vw;
  border: 0; border-left: 1px solid var(--line); padding: 20px 24px 28px; overflow: auto; background: var(--surface); color: var(--ink);
  box-shadow: -12px 0 40px rgba(var(--shadow-rgb), .14);
}
dialog.modal[open] { animation: drawer-in .22s ease-out; }
dialog.modal::backdrop { background: rgba(var(--shadow-rgb), .28); }
@keyframes drawer-in { from { transform: translateX(32px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin: 0 0 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.modal-head strong { font-size: 18px; }
.modal-head button { border: 0; min-height: 32px; width: 32px; padding: 0; font-size: 16px; color: var(--muted); }
dialog.modal fieldset { background: var(--soft-bg); }
.status-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.status-buttons button:disabled { opacity: 1; background: var(--violet); border-color: var(--violet); color: #fff; }

/* ---------- Acceso ---------- */
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-box { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px 28px 22px; }
.auth-box .crystal { width: 60px; height: 60px; margin: -8px 0 6px -8px; }
.auth-box h2 { margin-bottom: 6px; }
.auth-box > p { color: var(--ink-2); margin: 0 0 18px; }
.auth-box button { width: 100%; min-height: 42px; margin-top: 4px; }
.auth-box.wide-box { width: min(460px, 100%); }
.demo-users { display: grid; gap: 8px; margin-bottom: 14px; }
.auth-box .demo-user { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; min-height: 0; margin: 0;
  padding: 10px 14px; text-align: left; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; }
.auth-box .demo-user:hover { border-color: var(--violet); background: var(--violet-50); }
.demo-user span { font-size: 0.85em; color: var(--ink-2); font-weight: 400; }
/* Verificación en dos pasos */
.code-input { font-size: 22px; letter-spacing: .25em; text-align: center; font-variant-numeric: tabular-nums; }
.qr { display: flex; justify-content: center; margin: 8px 0 12px; }
.qr svg { width: 200px; height: 200px; max-width: 100%; border-radius: 8px; }
ol.steps { padding-left: 20px; margin: 0 0 8px; color: var(--ink-2); }
ol.steps li { margin-bottom: 6px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; letter-spacing: .05em; word-break: break-all; }
.recovery-codes { list-style: none; padding: 12px; margin: 8px 0 12px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 16px;
  background: var(--canvas); border: 1px solid var(--line); border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.auth-box .row-actions button { width: auto; flex: 1; }
.twofa-setup { max-width: 420px; }

/* ---------- Portal de reservas ---------- */
body.portal { min-height: 100vh; background: var(--niebla) linear-gradient(180deg, var(--lila) 0, var(--niebla) 260px) no-repeat; }
.portal-top { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 22px 16px 6px; }
.portal-top img { max-height: 52px; }
.portal-top img:not(.crystal) { width: 200px; max-width: 80vw; height: auto; max-height: 90px; object-fit: contain; }
.portal-top strong { font-family: 'Unbounded', Arial, sans-serif; font-size: 18px; font-weight: 600; }
body.portal main#view { max-width: 760px; margin: 0 auto; padding: 12px 16px 48px; }
.portal-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
.portal-step { padding: 18px 0; border-top: 1px solid var(--line-2); }
.portal-step:first-of-type { border-top: 0; padding-top: 4px; }
.portal-step h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.step-num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 4px; background: var(--accent-50); color: var(--accent); font-size: 13px; font-weight: 700; }
.choice-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.choice { text-align: left; padding: 12px 14px; min-height: 0; font-weight: 500; line-height: 1.35; }
.choice strong { font-weight: 650; }
.choice:hover { border-color: var(--violet); background: var(--violet-50); }
.choice.selected { border-color: var(--violet); background: var(--violet-50); box-shadow: inset 0 0 0 1px var(--violet); }
.portal-ok { border: 1px solid #b9dfcd; background: var(--teal-50); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px; }
.portal-calendar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 14px; }
.portal-ok h2 { color: var(--ok-text); margin-bottom: 6px; }
.portal-foot { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 18px; }

/* Movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Sin sesión: solo la pantalla de acceso */
body.logged-out .sidebar, body.logged-out .topbar { display: none; }
body.logged-out .app { grid-template-columns: 1fr; }
body.logged-out main#view { padding: 0; max-width: none; }
.topbar button { border: 0; min-height: 34px; width: 34px; padding: 0; font-size: 18px; }

/* Páginas de formularios: ancho de lectura */
.narrow { max-width: 880px; }
.logo-row { align-items: center; }
.logo-preview {
  width: 88px; height: 88px; flex: none; display: grid; place-items: center; text-align: center;
  border: 1px dashed var(--lavanda); border-radius: var(--radius); background: var(--soft-bg); overflow: hidden; margin-bottom: 12px;
}
.logo-preview img { max-width: 80px !important; max-height: 80px !important; }
.logo-row > label { flex: 0 1 auto; }
.brand-row { align-items: flex-end; }
.brand-row > label { flex: 0 1 auto; }
.color-field { display: flex; gap: 8px; align-items: center; }
/* Mismo peso que la regla general de input (va después, así gana) */
.color-field input.color-pick:not([type=file]) { width: 46px; height: 38px; padding: 3px; margin: 0; cursor: pointer; flex: none; }
.color-field input.hex-input:not([type=file]) { width: 130px; margin: 0; font-variant-numeric: tabular-nums; }
.color-field { margin-top: 5px; }
.brand-preview { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.brand-sample { display: inline-block; background: var(--sample, var(--primary)); color: #fff; font-weight: 600; padding: 8px 14px; border-radius: var(--radius-sm); }

/* Logo de la clínica en la barra lateral: se escala sin recortar; «con Bismuto» queda pequeño abajo */
.brand-logo.pending { visibility: hidden; }
.brand-logo.clinic { width: 180px; max-width: 100%; height: auto; max-height: 80px; object-fit: contain; object-position: left center; }
.topbar .brand-logo.clinic { width: 120px; max-height: 44px; }
.powered { display: flex; align-items: center; gap: 5px; margin: 10px 8px 0; font-size: 11px; color: var(--muted); }
.powered img { width: 14px; height: 14px; }

/* Listas en tarjeta (pacientes) */
.list-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px 6px; }
.list-card table { border: 0; border-radius: 0; margin: 0 0 8px; }
.list-card th { background: transparent; }
.list-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.list-toolbar .spacer { flex: 1; }
.audit-filters select, .audit-filters input { width: auto; margin: 0; }
.audit-filters label.inline { margin: 0; }
.search-box { position: relative; margin: 0; flex: 0 1 360px; }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; stroke: var(--muted); fill: none; stroke-width: 2; stroke-linecap: round; }
.search-box input[type=search] { margin: 0; padding-left: 36px !important; }
tr.clickable { cursor: pointer; }
.name-cell { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; }
.name-cell a { color: var(--ink); }
.empty { padding: 28px 8px; text-align: center; color: var(--muted); }

/* Formularios dentro del panel lateral: sin el marco del panel principal */
dialog.modal form > fieldset:first-child { border: 0; padding: 0; background: none; margin: 0; }
dialog.modal form > fieldset:first-child > legend { display: none; }
dialog.modal.wide { width: min(820px, 100vw); }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.form-actions .push { margin-left: auto; }
.page-intro { margin: -8px 0 16px; max-width: 70ch; }
.sub { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.switch-list { display: flex; flex-direction: column; gap: 2px; margin: 4px 0 4px; }

/* ---------- Encabezados, pestañas y filtros ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head h2 { margin: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 16px; overflow-x: auto; }
.tabs button { border: 0; border-radius: 0; background: none; padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--violet); border-bottom-color: var(--violet); }
.tabs button:hover { background: none; color: var(--ink); }
.filter-row { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: flex-end; margin: 0 0 6px; }
.filter-row > label { flex: 0 1 190px; }
.filter-total { margin: 0 0 12px auto; }
.list-toolbar button svg, button:not(.primary):not(.icon-btn) > svg:not(.chart) { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; margin-right: 5px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.no-margin { margin: 0; }
.debt { color: var(--rose); font-weight: 650; }
.paid { color: var(--ok-text); font-weight: 650; }
.ok-text { color: var(--ok-text); }
.link-btn { border: 0; background: none; padding: 0; min-height: 0; color: var(--violet); font-weight: 600; }
.link-btn:hover { background: none; text-decoration: underline; }
.link-btn.danger { color: var(--rose); }
.small-btn { min-height: 30px; padding: 4px 10px; }

/* ---------- Panel (indicadores y gráficos) ---------- */
.dash-filters { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 0 0 16px; }
.dash-filters label.inline input { width: auto; margin: 0; }
.cal-views { display: inline-flex; background: var(--line-2); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.cal-views button { border: 0; background: transparent; min-height: 30px; padding: 4px 12px; color: var(--ink-2); }
.cal-views button.active { background: var(--surface); color: var(--violet); box-shadow: 0 1px 3px rgba(var(--shadow-rgb), .12); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 0 0 18px; }
.kpis.compact { margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.list-card .kpi { background: var(--soft-bg); }
.kpi.warn { border-color: var(--warn, #e0a100); }
.kpi.warn .kpi-value { color: var(--warn-ink, #8a5a00); }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi-value { font-family: 'Unbounded', Arial, sans-serif; font-size: 22px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--muted); font-size: 12px; }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.dash-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; min-width: 0; }
.dash-card.wide { grid-column: 1 / -1; }
.dash-card h3 { margin: 0 0 10px; font-size: 14.5px; }
.dash-card table { border: 0; margin: 0; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: var(--line-2); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font-size: 11px; font-family: inherit; }
svg.chart .bar { fill: var(--violet); }
svg.chart .hit { fill: transparent; }
svg.chart .col:hover .bar { fill: var(--violet-600); }
.bar-list { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.bar-track { height: 10px; background: var(--line-2); border-radius: 0 4px 4px 0; overflow: hidden; }
.bar-fill { display: block; height: 100%; max-width: 100%; background: var(--violet); border-radius: 0 4px 4px 0; }
.bar-value { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 48px; text-align: right; }
.chart-tip { position: fixed; z-index: 300; pointer-events: none; background: var(--ink); color: #fff; padding: 7px 10px; border-radius: 7px; font-size: 12.5px; line-height: 1.35; box-shadow: 0 6px 18px rgba(var(--shadow-rgb), .25); }

/* ---------- Facturación ---------- */
.pay-box { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; background: var(--soft-bg); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 16px; }
.pay-box > div { display: flex; flex-direction: column; }
.pay-box button { margin-left: auto; }
.pay-target { background: var(--violet-50); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 14px; line-height: 1.5; }

/* ---------- Integraciones ---------- */
.sim-note { background: var(--amber-50, #fff7e0); border: 1px solid #f0d78c; border-radius: var(--radius); padding: 10px 14px; max-width: 90ch; }
.int-group h3 { margin: 22px 0 10px; }
.int-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.int-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.int-card.on { border-color: var(--accent-100); box-shadow: inset 3px 0 0 var(--accent); }
.int-card p { margin: 0; color: var(--ink-2); font-size: 13px; flex: 1; }
.int-head { display: flex; gap: 10px; align-items: center; }
.int-logo { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: var(--violet-50); color: var(--violet-600); font-weight: 750; font-size: 13px; flex: none; }
.int-card.on .int-logo { background: var(--accent); color: #fff; }
.int-foot { display: flex; justify-content: space-between; align-items: center; }
.int-activity { margin-top: 16px; }
.change-history { margin-top: 16px; }
.change-timeline { margin: 8px 0 0; padding-left: 18px; font-size: 13px; }
.change-timeline > li { margin: 0 0 10px; }
.change-timeline ul { margin: 2px 0 0; padding-left: 16px; }
.badge.origin-staff { background: var(--line-2); color: var(--ink-2); }
.badge.origin-claude { background: var(--lila); color: var(--morado-noche); }
.badge.origin-api { background: var(--lila); color: var(--ink-2); }
.badge.origin-agent { background: var(--lila); color: var(--morado); }
.badge.origin-portal { background: var(--teal-50); color: var(--ok-text); }
.badge.origin-system { background: var(--line-2); color: var(--muted); }
.int-activity ul { margin: 0; padding-left: 18px; font-size: 13px; }
.int-activity li { margin: 4px 0; }

/* ---------- Importación ---------- */
.import-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 12px 0; }
.import-summary > div { background: var(--soft-bg); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 10px 12px; }
.import-summary strong { font-family: 'Unbounded', Arial, sans-serif; font-size: 18px; font-weight: 600; display: block; }
.import-table { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.import-table table { border: 0; margin: 0; }

/* Bonos de sesiones */
.contents { display: contents; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.section-head h3 { margin: 12px 0; }
.pkg-meter { display: block; width: 110px; height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; margin: 4px 0 2px; }
.pkg-meter > span { display: block; height: 100%; background: var(--violet); }

/* Paginación de listados */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 12px 2px 2px; border-top: 1px solid var(--line-2); margin-top: 6px; }
.pager-size { display: inline-flex; align-items: center; gap: 8px; }
.pager-pages { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
.pager-pages button { min-width: 34px; min-height: 32px; padding: 4px 8px; font-variant-numeric: tabular-nums; }
.pager-pages button.active { background: var(--violet); border-color: var(--violet); color: #fff; }
.pager-gap { color: var(--muted); padding: 0 2px; }
@media (max-width: 640px) { .pager-pages { margin-left: 0; } }

/* Panel: pacientes nuevos vs frecuentes */
.mix-legend { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 2px 0 12px; font-size: 13px; }
.mix-legend strong { font-variant-numeric: tabular-nums; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
.swatch.new, svg.chart .bar.new { background: var(--violeta); fill: var(--violeta); }
.swatch.ret, svg.chart .bar.ret { background: var(--violet); fill: var(--violet); }
.mix-split { display: flex; gap: 2px; height: 14px; margin-bottom: 14px; }
.mix-split span { display: block; height: 100%; margin: 0; border-radius: 0; }
.mix-split span:first-child { border-radius: 4px 0 0 4px; }
.mix-split span:last-child { border-radius: 0 4px 4px 0; }
.mix-split span:only-child { border-radius: 4px; }
svg.chart .col:hover .bar.new { fill: var(--morado); }
svg.chart .col:hover .bar.ret { fill: var(--violet-600); }

/* Panel estilo «Resumen» de AgendaPro */
.dash { max-width: 1180px; }
.dash-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 20px; margin-bottom: 16px; }
.dash-head h2 { margin-bottom: 2px; }
.dash-head p { margin: 0; text-transform: capitalize; }
.dash-period { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dash-period select { margin: 0; width: auto; min-width: 170px; }
.dash-custom { display: inline-flex; flex-wrap: wrap; gap: 8px 12px; }
.dash-custom[hidden] { display: none; }
.dash-custom input { width: auto; margin: 0; }
.kpis-ap { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 12px; }
.kpi-ap { align-items: center; text-align: center; padding: 16px 14px; gap: 4px; border-radius: var(--radius); }
.kpi-ap .kpi-value { font-size: 26px; order: 0; }
.kpi-ap .kpi-label { text-transform: uppercase; letter-spacing: .04em; font-size: 11.5px; display: inline-flex; align-items: center; gap: 6px; }
.kpi-dark { background: var(--tinta); border-color: var(--tinta); color: #fff; }
.kpi-dark .kpi-label { color: var(--lavanda); }
.kpi-dark .kpi-value { color: #fff; font-size: 30px; }
.kpi-dark a { color: #fff; font-weight: 650; font-size: 13px; text-decoration: underline; margin-top: 2px; }
.kpi-dark .kpi-delta.up { color: #8fe0bf; } .kpi-dark .kpi-delta.down { color: #ffb3c0; } .kpi-dark .kpi-delta.flat { color: var(--lavanda); }
.kpi-delta { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 4px; }
.kpi-delta.up { color: var(--ok-text); } .kpi-delta.down { color: var(--rose); } .kpi-delta.flat { color: var(--muted); font-weight: 600; }
.kpi-arrow { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.delta-word { font-weight: 600; font-size: 11.5px; opacity: .85; }
.help-dot { display: inline-grid; place-items: center; width: 16px; height: 16px; min-height: 0; padding: 0; margin: 0; border-radius: 50%; border: 1.5px solid currentColor; background: transparent; color: inherit; font-size: 10px; font-weight: 700; line-height: 1; cursor: help; opacity: .7; text-transform: none; letter-spacing: 0; vertical-align: middle; }
.help-dot:hover, .help-dot:focus-visible { opacity: 1; background: transparent; color: var(--morado); }
.kpi-dark .help-dot:hover, .kpi-dark .help-dot:focus-visible { color: #fff; }
.help-pop { position: fixed; z-index: 400; background: var(--ink); color: #fff; padding: 9px 12px; border-radius: 8px; font-size: 12.5px; line-height: 1.45; font-weight: 500; text-transform: none; letter-spacing: 0; box-shadow: 0 8px 22px rgba(var(--shadow-rgb), .28); pointer-events: none; }
.dash-card h3 .help-dot { margin-left: 6px; vertical-align: 1px; color: var(--muted); }
.dash-today { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.dash-today summary { display: flex; align-items: center; gap: 10px; padding: 13px 16px; font-weight: 700; cursor: pointer; list-style: none; }
.dash-today summary::-webkit-details-marker { display: none; }
.dash-today summary::after { content: ''; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg); transition: transform .15s; }
.dash-today[open] summary::after { transform: rotate(-135deg); }
.count-pill { background: var(--lila); color: var(--morado-noche); border-radius: 999px; padding: 1px 9px; font-size: 12px; font-variant-numeric: tabular-nums; }
.dash-today-body { padding: 0 16px 12px; margin: 0; }
.dash-today table { border: 0; margin: 0; }
.dash-grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.dash-grid3 .dash-card { display: flex; flex-direction: column; min-height: 230px; }
.dash-grid3 .dash-card.wide { grid-column: 1 / -1; min-height: 0; }
.dash-card-body { flex: 1; }
.dash-foot { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line-2); font-size: 12.5px; color: var(--muted); }
.dash-empty { height: 100%; min-height: 140px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; color: var(--muted); font-size: 13px; }
.dash-empty p { margin: 0; max-width: 260px; }
.dash-empty-icon { width: 34px; height: 34px; border-radius: 50%; border: 3px dashed var(--lavanda); font-size: 0; }
.dash-grid3 .bar-row { grid-template-columns: minmax(40px, 34%) 1fr auto; }
.origin { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: center; }
.origin-legend { display: flex; flex-direction: column; gap: 10px; }
.origin-legend > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.origin-legend .muted { flex-basis: 100%; }
.origin-pct { font-family: 'Unbounded', Arial, sans-serif; font-size: 20px; font-variant-numeric: tabular-nums; }
.origin-pct.online { color: var(--violeta); } .origin-pct.staff { color: var(--morado); }
.origin-detail { grid-column: 1 / -1; margin: 0; }
svg.donut { width: 120px; height: 120px; display: block; }
svg.donut circle { fill: none; stroke-width: 14; }
svg.donut .donut-track { stroke: var(--line-2); }
svg.donut .donut-seg.online { stroke: var(--violeta); }
svg.donut .donut-seg.staff { stroke: var(--morado); }
.progress-list { display: flex; flex-direction: column; gap: 16px; padding-top: 4px; }
.progress-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.progress-row .bar-track { display: block; height: 10px; border-radius: 5px; }
.progress-row .bar-fill { border-radius: 5px; }
.bday-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow: auto; }
.bday-list li { display: flex; flex-direction: column; gap: 1px; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.bday-list li:last-child { border-bottom: 0; }
.bday-list a { font-weight: 650; }
@media (max-width: 1100px) { .dash-grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .kpis-ap { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .dash-grid3 { grid-template-columns: 1fr; }
  .dash-grid3 .dash-card { min-height: 0; }
  .dash-empty { min-height: 90px; }
  .kpi-ap .kpi-value, .kpi-dark .kpi-value { font-size: 19px; white-space: nowrap; }
  .kpi-ap { padding: 14px 8px; }
}

/* Panel: gráficos de líneas */
svg.line-chart .line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
svg.line-chart .line.dashed { stroke-width: 2; stroke-dasharray: 6 5; }
svg.line-chart .line.cur, svg.line-chart .line.ret { stroke: var(--morado); }
svg.line-chart .line.new { stroke: var(--violeta); }
svg.line-chart .line.prev { stroke: var(--lavanda); }
svg.line-chart .area.cur { fill: var(--morado); opacity: .08; }
svg.line-chart .dot { stroke: var(--surface); stroke-width: 2; }
svg.line-chart .dot.cur, svg.line-chart .dot.ret { fill: var(--morado); }
svg.line-chart .dot.new { fill: var(--violeta); }
svg.line-chart .dot.hover-only { opacity: 0; }
svg.line-chart .guide { stroke: var(--lavanda); stroke-width: 1; opacity: 0; }
svg.line-chart .col:hover .guide, svg.line-chart .col:hover .dot { opacity: 1; }
svg.line-chart .col:hover .dot { r: 5.5; }
.swatch.cur { background: var(--morado); }
.swatch.prev { background: var(--lavanda); }
.swatch.line-swatch { width: 18px; height: 3px; border-radius: 2px; vertical-align: 3px; }
.swatch.dashed { background: repeating-linear-gradient(90deg, var(--lavanda) 0 5px, transparent 5px 8px); }

/* Panel: pestañas Resumen / Reservas / Ventas y exportación */
.dash-tabs { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.dash-tabs .tabs { border-bottom: 0; margin: 0; }
.dash-tabs .tabs button { font-weight: 650; font-size: 14.5px; padding: 10px 16px; }
.dash-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; padding-bottom: 8px; margin-left: auto; }
.kpis-ap.kpis-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.dash-grid3 .dash-card.span2 { grid-column: span 2; }
.table-scroll { overflow-x: auto; }
.report-table { width: 100%; border: 0; margin: 0; font-size: 13px; }
.report-table th.num, .report-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.big-stat { height: 100%; min-height: 120px; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.big-stat strong { font-family: 'Unbounded', Arial, sans-serif; font-size: 26px; font-variant-numeric: tabular-nums; }
.col-bars { display: flex; align-items: stretch; gap: 6px; height: 170px; padding-top: 6px; }
.col-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.col-bar-track { flex: 1; width: 100%; max-width: 28px; display: flex; align-items: flex-end; }
.col-bar-fill { display: block; width: 100%; background: var(--violet); border-radius: 4px 4px 0 0; min-height: 2px; }
.col-bar:hover .col-bar-fill { background: var(--violet-600); }
.col-bar-label { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 1100px) { .kpis-ap.kpis-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) { .kpis-ap.kpis-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .dash-grid3 .dash-card.span2 { grid-column: auto; }
  .dash-actions { width: 100%; }
  .dash-actions > * { flex: 1 1 auto; }
  .dash-period select { width: 100%; }
  .col-bar-label { font-size: 9.5px; }
}

/* Panel: pestaña Análisis */
.analysis-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; }
.analysis-bar select { margin: 0; width: auto; min-width: 230px; }
.findings { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.finding { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border-radius: var(--radius-sm); background: var(--soft-bg); font-size: 13.5px; line-height: 1.4; }
.finding-icon { flex: none; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: 12px; font-weight: 800; color: #fff; background: var(--violeta); margin-top: 1px; }
.finding.good { background: var(--teal-50); } .finding.good .finding-icon { background: var(--teal); }
.finding.bad { background: var(--rose-50); } .finding.bad .finding-icon { background: var(--rose); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.card-head h3 { margin: 0; }
.card-head select { margin: 0; width: auto; }
.report-table td .kpi-delta { justify-content: flex-end; }
.heatmap { display: grid; gap: 3px; font-size: 11.5px; min-width: 380px; }
.heat-head { text-align: center; font-weight: 700; color: var(--ink-2); padding-bottom: 2px; }
.heat-hour { color: var(--muted); text-align: right; padding-right: 6px; align-self: center; font-variant-numeric: tabular-nums; }
.heat-cell { height: 26px; border-radius: 5px; display: grid; place-items: center; color: var(--ink-2); font-variant-numeric: tabular-nums; font-weight: 600; cursor: default; }
.heat-cell.dark { color: #fff; }
.heat-cell.off { background: repeating-linear-gradient(45deg, transparent 0 4px, var(--line-2) 4px 6px); }
@media (max-width: 640px) { .analysis-bar select { min-width: 0; width: 100%; } }
.delta-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0 0 10px; }
.delta-legend .kpi-arrow { color: var(--muted); }
.rose-text { color: var(--rose); }
.metric-groups { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.metric-group h3 { margin-bottom: 4px; }
.metric-tile { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-top: 1px solid var(--line-2); }
.metric-group h3 + .metric-tile { border-top: 0; }
.metric-label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.less-better { font-size: 10.5px; font-weight: 600; color: var(--muted); background: var(--line-2); border-radius: 999px; padding: 0 7px; }
.metric-main { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 10px; }
.metric-value { font-family: 'Unbounded', Arial, sans-serif; font-size: 19px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metric-before { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 1150px) { .metric-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .metric-groups { grid-template-columns: 1fr; } }


/* Panel: pestaña Análisis Gerencial */
.data-tag { display: inline-flex; align-items: center; font-size: 10.5px; font-weight: 700; border-radius: 999px; padding: 1px 8px; white-space: nowrap; vertical-align: 1px; }
.data-tag.real { background: var(--teal-50); color: var(--ok-text); }
.data-tag.est { background: var(--lila); color: var(--morado-noche); }
.data-tag.missing { background: #fff4dc; color: #8a5a00; }
.formula p { margin: 0 0 8px; font-size: 13.5px; }
.formula .big-stat { min-height: 0; margin-bottom: 6px; }
.ibc-scale { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin-top: 6px; }
.ibc-scale span { display: flex; flex-direction: column; gap: 1px; padding: 6px 4px; border-radius: 8px; background: var(--soft-bg); font-size: 11px; color: var(--muted); text-align: center; }
.ibc-scale span strong { font-size: 11.5px; color: var(--ink-2); }
.ibc-scale span.active { background: var(--tinta); color: var(--lavanda); }
.ibc-scale span.active strong { color: #fff; }
.value-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 18px; margin: 8px 0 10px; }
.value-grid > div { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--soft-bg); }
.value-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 10px 0; }
.value-group { border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.value-group-title { margin: 0 0 8px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.value-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.value-field { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--soft-bg); }
.value-field .metric-label .help-dot, .value-foot .help-dot, .card-head h3 .help-dot { margin-left: 6px; color: var(--muted); }
.value-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; margin: 0; }
.value-note { flex-basis: 100%; }
@media (max-width: 900px) { .value-groups { grid-template-columns: 1fr; } }
@media (max-width: 480px) { .value-pair { grid-template-columns: 1fr; } }
.missing-list { margin: 4px 0 0; padding-left: 18px; font-size: 13.5px; display: flex; flex-direction: column; gap: 4px; }
.heat-cell.limit-boxes { box-shadow: inset 0 0 0 2px var(--tinta); }
@media (max-width: 1100px) { .value-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .value-grid { grid-template-columns: 1fr; } }

/* Miniaturas de imágenes en fichas */
a.thumb { display: inline-flex; flex-direction: column; gap: 4px; max-width: 180px; text-decoration: none; }
a.thumb img { display: block; width: 160px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--line-2); }
a.thumb:hover img { border-color: var(--violet); }
a.thumb span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }

/* Nueva cita: tratamientos con sesiones por agendar */
.pending-sessions { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 4px; padding: 10px 12px; border: 1px solid #b9dfcd; background: var(--teal-50); border-radius: var(--radius); font-size: 13px; }
.pending-item { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.pending-item > button:first-child { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 10px; text-align: left; background: var(--surface); }
.pending-item.selected > button:first-child { border-color: var(--teal); box-shadow: 0 0 0 2px var(--teal-50), 0 0 0 3px var(--teal); }
.pending-item .sub { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.pending-count { font-weight: 700; color: var(--ok-text); white-space: nowrap; }

/* Celular: buscador a lo ancho y botones parejos en una fila; filtros de a dos; campos de 16 px (iPhone no hace zoom) */
@media (max-width: 700px) {
  .list-card { padding: 12px 12px 4px; }
  .list-toolbar { gap: 8px; }
  .list-toolbar .search-box { flex: 1 1 100%; }
  .list-toolbar .spacer { display: none; }
  .list-toolbar > button, .list-toolbar > a.button, .list-toolbar > span:not(.spacer) > button { flex: 1 1 0; justify-content: center; white-space: nowrap; }
  .list-toolbar > span:not(.spacer) { display: flex; gap: 8px; flex: 1 1 100%; }
  .filter-row > label { flex: 1 1 calc(50% - 12px); min-width: 0; }
  .audit-filters > select { flex: 1 1 100%; width: 100%; }
  .audit-filters > label.inline { flex: 1 1 calc(50% - 8px); min-width: 0; display: flex; flex-direction: column; align-items: stretch; gap: 4px; margin: 0; color: var(--ink-2); }
  .audit-filters > label.inline input { width: 100%; min-width: 0; }
  .page-head > * { flex: 1 1 auto; }
}
@media (max-width: 860px) {
  input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea { font-size: 16px; }
  input[type=date], input[type=time], input[type=datetime-local] { -webkit-appearance: none; appearance: none; text-align: left; min-height: 42px; }
  input::-webkit-date-and-time-value { text-align: left; }
  button, a.button { min-height: 40px; }
}

/* ---------- Inventario ---------- */
.inv-alert { background: var(--rose-50); color: var(--rose); border-radius: 10px; padding: 10px 14px; margin: 0 0 12px; font-weight: 600; }
.badge.inv-low { margin-left: 8px; }
.inv-lines { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.inv-line { align-items: flex-end; }
.inv-line > .link-btn { margin-bottom: 22px; }
.inv-qty { display: flex; align-items: center; gap: 8px; }
.inv-qty input { flex: 1; min-width: 0; }
.inv-count { max-width: 140px; }
td.inv-neg { color: var(--rose); font-weight: 600; }
.inv-scroll { overflow-x: auto; }
.tabs button { white-space: nowrap; flex: 0 0 auto; }
.inv-line { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.inv-line > label { margin-bottom: 12px; min-width: 0; }
.inv-line select, .inv-line input { width: 100%; }
.inv-lines:empty { display: none; }
.inv-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.inv-create { border: 1px dashed var(--violeta); border-radius: var(--radius-sm); padding: 12px 14px 4px; margin: 8px 0 12px; background: var(--violet-50); }
.inv-create .form-actions { margin-top: 0; }
@media (max-width: 420px) { .inv-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .inv-line > .link-btn { grid-column: 1 / -1; justify-self: start; margin: -6px 0 8px; } }
