/* =====================================================================
   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 */
  --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 */
  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; }
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;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-name { display: block; font-family: 'Unbounded', Arial, sans-serif; font-weight: 700; font-size: 18px; letter-spacing: -.01em; line-height: 1.1; color: var(--tinta); }
.crystal { width: 34px; height: 34px; 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; }

.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 .crystal { width: 26px; height: 26px; }
  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); }

/* ---------- 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: #faf7fe; }
tr.muted td { color: var(--muted); }
tr.cancelled td { color: var(--muted); text-decoration: line-through; }
@media (max-width: 700px) {
  table { display: block; overflow-x: auto; 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(--violet-50); border-color: var(--violet-100); color: var(--violet); }
.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-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; }
.cal-head { display: flex; position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--line); }
.cal-gutter-head, .cal-gutter { width: 56px; flex: none; }
.cal-colhead {
  flex: 1 1 0; min-width: 130px; 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(--violet); }
.cal-body { display: flex; }
.cal-gutter { position: relative; }
.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: 120px; 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(107, 68, 201, .09) 0 1px, transparent 1px 9px), rgba(246, 242, 253, .6); }
.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: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(107, 68, 201, .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(107, 68, 201, .07) 0 1px, transparent 1px 9px), var(--soft-bg); }
.month-cell.other .month-day { color: #a99fc6; }
.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(--violet); 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: 44px; height: 44px; margin-bottom: 14px; }
.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%); }
/* 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 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(--violet-50); color: var(--violet); 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; }

/* 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-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(--violet-100); box-shadow: inset 3px 0 0 var(--violet); }
.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(--violet); 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-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); }

/* 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; }
