/* Estilo del portal FSL: mismo sistema que Sat Zanichelli y Acupuntura (tipografías Archivo + IBM Plex, tarjetas planas con
   borde, pestañas subrayadas, menú lateral para el administrador en el PC). Solo cambia el acento (violeta de FSL). */
:root {
  --bg: #f1f4f7;
  --surface: #ffffff;
  --surface-2: #e8edf2;
  --ink: #14202b;
  --muted: #5a6878;
  --line: #d3dbe4;
  --line-strong: #b8c4d1;
  --accent-strong: #4c446d;
  --accent: #615892;
  --accent-ink: #ffffff;
  --accent-soft: #ebe8f5;
  --ok: #23774a;
  --ok-soft: #ddf0e4;
  --warn: #94600a;
  --warn-soft: #faebcf;
  --bad: #b3261e;
  --bad-soft: #f7dedb;
  --neutral-soft: #e1e7ed;
  --gold: #b8942a;
  --scrim: rgba(8, 14, 22, 0.42);
  --f-display: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --f-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --r: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0e141b;
    --surface: #151d26;
    --surface-2: #1c2631;
    --ink: #e3e9f0;
    --muted: #97a5b5;
    --line: #283442;
    --line-strong: #3a4858;
    --accent-strong: #c3b9f0;
    --accent: #a89be0;
    --accent-ink: #1a1530;
    --accent-soft: #2a2342;
    --ok: #5fc28c;
    --ok-soft: #163525;
    --warn: #e3aa4c;
    --warn-soft: #3a2c12;
    --bad: #ef7366;
    --bad-soft: #3d1c19;
    --neutral-soft: #243040;
    --gold: #d4af37;
    --scrim: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0e141b;
  --surface: #151d26;
  --surface-2: #1c2631;
  --ink: #e3e9f0;
  --muted: #97a5b5;
  --line: #283442;
  --line-strong: #3a4858;
  --accent-strong: #c3b9f0;
  --accent: #a89be0;
  --accent-ink: #1a1530;
  --accent-soft: #2a2342;
  --ok: #5fc28c;
  --ok-soft: #163525;
  --warn: #e3aa4c;
  --warn-soft: #3a2c12;
  --bad: #ef7366;
  --bad-soft: #3d1c19;
  --neutral-soft: #243040;
  --gold: #d4af37;
  --scrim: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 14px; line-height: 1.45; }
body::before { content: ''; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--surface); }
p { margin: 0; }
h1, h2, h3, h4 { font-family: var(--f-display); margin: 0; text-wrap: balance; }
h1 { font-weight: 700; font-size: 24px; line-height: 1.15; letter-spacing: -0.015em; }
h2 { font-weight: 600; font-size: 15px; }
h3 { font-weight: 600; font-size: 15px; margin-bottom: 10px; }
h4 { font-weight: 600; font-size: 14px; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.text-gradient { color: var(--ink); }

/* Cabecera */
.topbar, .hdr { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1240px; margin: 0 auto; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; }
.brand { display: flex; gap: 10px; align-items: center; color: var(--accent); min-width: 0; }
.brand b { font: 700 18px var(--f-display); letter-spacing: -0.01em; color: var(--ink); white-space: nowrap; }
.brand small { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-logo { width: 30px; height: 30px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font: 700 13px var(--f-display); flex: none; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 22px max(16px, env(safe-area-inset-right, 0px)) 56px max(16px, env(safe-area-inset-left, 0px)); }

/* Menú de la persona (avatar) */
.umenu { position: relative; flex: none; }
.avatar { appearance: none; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--accent-soft); color: var(--accent); font: 600 14px var(--f-body); cursor: pointer; display: grid; place-items: center; }
.avatar:hover, .avatar[aria-expanded='true'] { border-color: var(--accent); }
.menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 35; min-width: 220px; max-width: calc(100vw - 32px); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(10, 16, 24, 0.18); padding: 6px; display: flex; flex-direction: column; }
.menu-who { display: flex; flex-direction: column; gap: 1px; padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-who small { color: var(--muted); font-size: 12.5px; }
.menu button { appearance: none; border: 0; background: none; text-align: left; font: 500 14px var(--f-body); color: var(--ink); padding: 9px 12px; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: var(--surface-2); }

/* Tarjetas, rejillas */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; min-width: 0; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.grid3 { display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center-card { max-width: 440px; margin: 48px auto; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; appearance: none; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: 500 14px/1.2 var(--f-body); border-radius: 6px; padding: 8px 12px; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-outline { background: var(--surface); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: transparent; color: var(--ink); }
.btn-danger { color: var(--bad); border-color: var(--bad); background: transparent; padding: 5px 9px; font-size: 12.5px; }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-sm { padding: 5px 9px; font-size: 12.5px; }
.btn-wa { background: #25d366; border-color: #25d366; color: #fff; }
.btn-wa:hover:not(:disabled) { filter: brightness(.95); border-color: #25d366; }
.btn-block { width: 100%; }
.link { background: none; border: 0; color: var(--accent); font: inherit; font-size: 12.5px; text-decoration: underline; cursor: pointer; padding: 0; }

/* Formularios */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; min-width: 0; max-width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: var(--surface); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
input[type=file] { font-size: 12.5px; max-width: 100%; }
textarea { min-height: 80px; resize: vertical; }
.field + .field { margin-top: 10px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; font-size: 14px; color: var(--ink); cursor: pointer; }
.check input { margin-top: 3px; }

/* Etiquetas (pill) */
.badge { display: inline-flex; align-items: center; font-size: 12px; font-weight: 500; line-height: 1.5; padding: 2px 9px; border-radius: 999px; white-space: nowrap; background: var(--neutral-soft); color: var(--muted); }
.badge-primary { background: var(--accent-soft); color: var(--accent); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-muted { background: var(--neutral-soft); color: var(--muted); }
.badge-gold { background: var(--warn-soft); color: var(--gold); box-shadow: inset 0 0 0 1px currentColor; }

/* Pestañas subrayadas */
.tabs { display: flex; gap: 2px; margin-bottom: 18px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tab { appearance: none; border: 0; border-bottom: 2px solid transparent; background: none; font: 500 14px var(--f-body); color: var(--muted); padding: 10px 12px; cursor: pointer; white-space: nowrap; display: flex; align-items: center; gap: 10px; margin-bottom: -1px; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab svg { display: none; }

/* Menú lateral del administrador (PC): igual que Zanichelli, con iconos y plegable */
.shell { --lat-w: 212px; }
.shell.mini { --lat-w: 60px; }
@media (min-width: 801px) {
  .shell.lateral > .wrap { max-width: none; margin-left: var(--lat-w); padding-left: 24px; padding-right: 24px; }
  .shell.lateral > .tabs { position: fixed; left: 0; top: var(--top-h, 58px); bottom: 0; width: var(--lat-w); z-index: 19; flex-direction: column; gap: 2px; padding: 12px 8px; margin: 0; overflow-x: hidden; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); border-bottom: 0; }
  .shell.lateral > .tabs .tab { width: 100%; text-align: left; padding: 9px 10px; border-bottom: 0; border-radius: 8px; margin: 0; }
  .shell.lateral > .tabs .tab svg { display: block; width: 20px; height: 20px; flex: none; }
  .shell.lateral > .tabs .tab:hover { background: var(--surface-2); }
  .shell.lateral > .tabs .tab.active { background: var(--surface-2); color: var(--ink); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
  .shell.lateral > .tabs .plegar { margin-top: auto; }
  .shell.lateral > .tabs .plegar { color: var(--muted); font-size: 12.5px; }
  .shell.mini > .tabs .tab, .shell.mini > .tabs .plegar { justify-content: center; padding: 10px 0; }
  .shell.mini > .tabs .tab > span, .shell.mini > .tabs .plegar > span { display: none; }
}
@media (max-width: 1000px) and (min-width: 801px) {
  .shell { --lat-w: 60px; }
  .shell.lateral > .tabs .tab, .shell.lateral > .tabs .plegar { justify-content: center; padding: 10px 0; }
  .shell.lateral > .tabs .tab > span, .shell.lateral > .tabs .plegar > span { display: none; }
  .shell.lateral > .tabs .plegar { display: none; }
}
.plegar { display: none; }
@media (min-width: 801px) { .shell.lateral > .tabs .plegar { display: flex; } }

/* Cifras */
.stat { text-align: left; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.stat .v { font: 700 30px/1 var(--f-display); font-variant-numeric: tabular-nums; color: var(--ink); }
.stat .v span { font-size: 14px; font-weight: 500; color: var(--muted); }
.stat .l { font-size: 13px; color: var(--muted); font-weight: 500; order: 2; }
.stat .d { font-size: 12.5px; color: var(--muted); order: 3; }

/* Tablas y listas */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
table.t td { white-space: nowrap; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table-scroll { overflow-x: auto; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.client-row { cursor: pointer; }
.client-row:hover { background: var(--surface-2); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dot-verde { background: var(--ok); } .dot-ambar { background: #e3aa4c; } .dot-rojo { background: var(--bad); } .dot-gris { background: var(--line-strong); }

.locked { background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--r); padding: 14px; text-align: center; color: var(--muted); }
.vigente { background: var(--surface); border: 1px solid var(--accent); border-radius: var(--r); padding: 14px; }

/* Ventanas, avisos y toasts */
.overlay { position: fixed; inset: 0; background: var(--scrim); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px; max-width: 520px; width: 100%; box-shadow: 0 12px 32px rgba(10, 16, 24, 0.25); }
.msg { font-size: 13px; padding: 8px 12px; border-radius: 6px; margin-top: 10px; }
.msg-err { background: var(--bad-soft); color: var(--bad); }
.msg-ok { background: var(--ok-soft); color: var(--ok); }
.msg-info { background: var(--accent-soft); color: var(--accent-strong); }
.notice { background: var(--accent-soft); border-radius: var(--r); padding: 10px 14px; font-size: 13px; color: var(--accent-strong); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-weight: 600; z-index: 90; max-width: calc(100% - 32px); }
.toast.err { background: var(--bad); color: #fff; }

/* Consentimientos y firma */
.consent-text { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; font-size: 13px; max-height: 260px; overflow: auto; }
.firma-lienzo { position: relative; border: 1px dashed var(--line-strong); border-radius: var(--r); background: #fff; height: 170px; touch-action: none; }
.firma-lienzo canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.firma-guia { position: absolute; left: 12px; bottom: 6px; font-size: 12px; color: #6b7885; pointer-events: none; }
.firma-lienzo.con-firma .firma-guia { display: none; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--ink); padding: 8px 16px; font: 500 14px var(--f-body); cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); }
.steps { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.chart-box { position: relative; height: 300px; }

/* Progreso hacia el objetivo y check-in semanal */
.obj { margin: 8px 0 14px; }
.prog { height: 10px; background: var(--neutral-soft); border-radius: 99px; overflow: hidden; margin: 6px 0 4px; }
.prog span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.escala { display: flex; gap: 8px; margin: 6px 0 4px; }
.escala button { flex: 1; min-height: 44px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 6px; font: 600 14px var(--f-body); cursor: pointer; }
.escala button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Panel, agenda y cobros */
.grid4 { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.cols { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 430px), 1fr)); align-items: start; }
.stat.ok .v { color: var(--ok); }
.stat.warn .v { color: var(--warn); }
.stat.bad .v { color: var(--bad); }
.txt-bad { color: var(--bad); }
.fila-btn { appearance: none; width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); font: inherit; color: inherit; text-align: left; cursor: pointer; }
.fila-btn:last-of-type { border-bottom: 0; }
.fila-btn:hover { background: var(--surface-2); }
.prog.mini { height: 8px; margin: 2px 0; min-width: 90px; }
.acciones-fila { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; min-width: 220px; }
