/* Clinora — sistema visual compartido (reserva pública + panel)
   Layout: reserva = columna de marca + asistente por pasos; panel = riel lateral + espacio de trabajo */
:root {
  --brand: #0F6E68;
  --brand-fg: color-mix(in srgb, var(--brand) 88%, #000);
  --brand-soft: color-mix(in srgb, var(--brand) 10%, var(--surface));
  --brand-line: color-mix(in srgb, var(--brand) 32%, var(--line));
  --on-brand: #FFFFFF;

  --paper: #F3F6F5;
  --surface: #FFFFFF;
  --surface-2: #EDF2F1;
  --line: #DAE3E1;
  --ink: #0F1E1C;
  --ink-2: #475957;
  --ink-3: #7B8C8A;

  --ok: #1D8A57;   --ok-soft: color-mix(in srgb, var(--ok) 12%, var(--surface));
  --warn: #B26B12; --warn-soft: color-mix(in srgb, var(--warn) 13%, var(--surface));
  --bad: #C03A33;  --bad-soft: color-mix(in srgb, var(--bad) 11%, var(--surface));
  --info: #2E69B0; --info-soft: color-mix(in srgb, var(--info) 11%, var(--surface));
  --mute-soft: color-mix(in srgb, var(--ink-3) 14%, var(--surface));

  --shadow-1: 0 1px 2px rgba(15, 30, 28, .06), 0 1px 1px rgba(15, 30, 28, .04);
  --shadow-2: 0 12px 32px -12px rgba(15, 30, 28, .22), 0 2px 6px rgba(15, 30, 28, .06);
  --shadow-3: 0 30px 80px -20px rgba(15, 30, 28, .35);

  --f-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --f-body: "Figtree", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --r-sm: 8px; --r-md: 12px; --r-lg: 18px;
  --t-xs: .75rem; --t-sm: .8125rem; --t-md: .9375rem; --t-lg: 1.125rem; --t-xl: 1.5rem; --t-2xl: 2.25rem; --t-3xl: clamp(2.2rem, 4.2vw, 3.4rem);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand-fg: color-mix(in srgb, var(--brand) 55%, #fff);
    --brand-soft: color-mix(in srgb, var(--brand) 20%, var(--surface));
    --paper: #0B1413; --surface: #111D1B; --surface-2: #172624; --line: #233633;
    --ink: #E5EFED; --ink-2: #A5B7B4; --ink-3: #6F8481;
    --ok: #3DBB82; --warn: #E0A04A; --bad: #EC6A5F; --info: #6AA2E6;
    --shadow-1: 0 1px 2px rgba(0,0,0,.4); --shadow-2: 0 12px 32px -12px rgba(0,0,0,.6); --shadow-3: 0 30px 80px -20px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand-fg: color-mix(in srgb, var(--brand) 55%, #fff);
  --brand-soft: color-mix(in srgb, var(--brand) 20%, var(--surface));
  --paper: #0B1413; --surface: #111D1B; --surface-2: #172624; --line: #233633;
  --ink: #E5EFED; --ink-2: #A5B7B4; --ink-3: #6F8481;
  --ok: #3DBB82; --warn: #E0A04A; --bad: #EC6A5F; --info: #6AA2E6;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4); --shadow-2: 0 12px 32px -12px rgba(0,0,0,.6); --shadow-3: 0 30px 80px -20px rgba(0,0,0,.7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 var(--t-md)/1.55 var(--f-body);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-family: var(--f-display); font-weight: 650; letter-spacing: -.02em; line-height: 1.15; margin: 0; text-wrap: balance; }
p { margin: 0; }
a { color: var(--brand-fg); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.num, .mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.tnum { font-variant-numeric: tabular-nums; }
.eyebrow { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .09em; font-weight: 600; color: var(--ink-3); }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Controles ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 40px; padding: 0 1rem; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: var(--t-sm);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .08s, box-shadow .15s;
}
.btn:hover { border-color: var(--brand-line); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); box-shadow: 0 6px 16px -8px var(--brand); }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn-sm { min-height: 32px; padding: 0 .7rem; font-size: var(--t-xs); border-radius: 8px; }
.btn-lg { min-height: 48px; padding: 0 1.4rem; font-size: var(--t-md); border-radius: 12px; }
.btn-block { width: 100%; }
.icon-btn { width: 36px; min-height: 36px; padding: 0; }

.field { display: grid; gap: .35rem; min-width: 0; }
.field > span, .label { font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.field small { color: var(--ink-3); font-size: var(--t-xs); }
.input, .select, .textarea {
  width: 100%; min-height: 42px; padding: .55rem .8rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 88px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
.input[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 2rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.check { display: flex; gap: .6rem; align-items: flex-start; font-size: var(--t-sm); color: var(--ink-2); cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--brand); flex: none; }
.switch { position: relative; width: 40px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform .2s; }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:focus-visible + i { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Pills de estado */
.pill { display: inline-flex; align-items: center; gap: .35rem; height: 24px; padding: 0 .6rem; border-radius: 99px; font-size: var(--t-xs); font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-pendiente { color: var(--warn); background: var(--warn-soft); }
.st-confirmada { color: var(--info); background: var(--info-soft); }
.st-completada { color: var(--ok); background: var(--ok-soft); }
.st-cancelada { color: var(--ink-3); background: var(--mute-soft); }
.st-no_asistio { color: var(--bad); background: var(--bad-soft); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.chip { display: inline-flex; align-items: center; gap: .4rem; padding: .2rem .6rem; border-radius: 99px; background: var(--surface-2); font-size: var(--t-xs); color: var(--ink-2); font-weight: 600; }

/* Toast */
.toasts { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; gap: .5rem; z-index: 100; }
.toast { display: flex; align-items: center; gap: .6rem; padding: .75rem 1rem; border-radius: 12px; background: var(--ink); color: var(--paper); font-size: var(--t-sm); font-weight: 500; box-shadow: var(--shadow-2); animation: toastIn .25s ease-out; max-width: min(360px, calc(100vw - 32px)); }
.toast.err { background: var(--bad); color: #fff; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

/* Demo banner */
.demo-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .4rem 1rem; padding: .5rem 16px; background: var(--ink); color: var(--paper); font-size: var(--t-xs); text-align: center; }
.demo-bar b { color: color-mix(in srgb, var(--brand) 45%, #fff); letter-spacing: .06em; text-transform: uppercase; }
.demo-bar a { color: inherit; font-weight: 600; }

/* =====================================================================
   RESERVA PÚBLICA
   ===================================================================== */
.bk { min-height: 100%; display: grid; grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); }
.bk-side {
  position: relative; overflow: hidden; color: var(--on-brand);
  background: radial-gradient(120% 80% at 0% 0%, color-mix(in srgb, var(--brand) 70%, #fff 8%) 0%, transparent 60%), linear-gradient(165deg, var(--brand) 0%, color-mix(in srgb, var(--brand) 55%, #041211) 100%);
  padding: 2.5rem 2.25rem; display: flex; flex-direction: column; gap: 2rem;
}
.bk-side::after { /* retícula de agenda */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .09;
  background-image: linear-gradient(rgba(255,255,255,.9) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.9) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: linear-gradient(180deg, transparent, #000 45%, #000 80%, transparent);
}
.bk-side > * { position: relative; z-index: 1; }
.bk-logo { display: flex; align-items: center; gap: .75rem; }
.bk-mark { width: 44px; height: 44px; border-radius: 13px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25); display: grid; place-items: center; font-family: var(--f-display); font-weight: 700; font-size: 1.1rem; backdrop-filter: blur(6px); }
.bk-logo small { display: block; opacity: .7; font-size: var(--t-xs); letter-spacing: .08em; text-transform: uppercase; }
.bk-logo strong { font-family: var(--f-display); font-size: var(--t-lg); font-weight: 650; letter-spacing: -.01em; }
.bk-hero h1 { font-size: var(--t-3xl); font-weight: 700; letter-spacing: -.035em; line-height: 1.02; }
.bk-hero p { margin-top: .9rem; opacity: .82; max-width: 34ch; font-size: var(--t-md); }
.bk-next { display: inline-flex; align-items: center; gap: .6rem; margin-top: 1.4rem; padding: .55rem .9rem .55rem .6rem; border-radius: 99px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22); font-size: var(--t-sm); }
.bk-next i { width: 8px; height: 8px; border-radius: 50%; background: #7CF2C4; box-shadow: 0 0 0 4px rgba(124,242,196,.25); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(124,242,196,0); } }
.bk-facts { display: grid; gap: .9rem; margin-top: auto; font-size: var(--t-sm); }
.bk-facts div { display: grid; grid-template-columns: 20px 1fr; gap: .7rem; align-items: start; opacity: .92; }
.bk-facts svg { width: 18px; height: 18px; opacity: .75; margin-top: 2px; }
.bk-trust { display: flex; gap: 1.5rem; padding-top: 1.25rem; border-top: 1px solid rgba(255,255,255,.18); }
.bk-trust b { display: block; font-family: var(--f-display); font-size: var(--t-xl); letter-spacing: -.02em; }
.bk-trust span { font-size: var(--t-xs); opacity: .72; }

.bk-main { display: flex; flex-direction: column; min-width: 0; padding: 2rem clamp(16px, 4vw, 3.5rem) 2.5rem; }
.bk-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.75rem; }
.stepper { display: flex; gap: .35rem; flex-wrap: wrap; list-style: none; padding: 0; margin: 0; }
.stepper li { display: flex; align-items: center; gap: .45rem; font-size: var(--t-sm); color: var(--ink-3); font-weight: 600; padding: .3rem .7rem .3rem .35rem; border-radius: 99px; }
.stepper li b { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; background: var(--surface-2); color: var(--ink-3); font-family: var(--f-mono); }
.stepper li.on { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-1); }
.stepper li.on b { background: var(--brand); color: var(--on-brand); }
.stepper li.done { color: var(--ink-2); }
.stepper li.done b { background: var(--brand-soft); color: var(--brand-fg); }

.bk-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 2rem; align-items: start; }
.bk-panel { min-width: 0; container-type: inline-size; }
@container (max-width: 760px) { .cal-wrap { grid-template-columns: 1fr; } }
.bk-panel h2 { font-size: var(--t-2xl); letter-spacing: -.03em; }
.bk-panel > p.lead { margin-top: .4rem; color: var(--ink-2); }
.bk-section { margin-top: 1.6rem; }
.bk-section + .bk-section { margin-top: 1.4rem; }
.bk-section > .eyebrow { margin-bottom: .6rem; display: block; }

.opt-list { display: grid; gap: .6rem; }
.opt {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 1rem; align-items: center; text-align: left;
  width: 100%; padding: 1rem 1.1rem; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.opt:hover { border-color: var(--brand-line); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.opt[aria-pressed="true"] { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.opt-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-family: var(--f-display); font-weight: 700; }
.opt h3 { font-size: var(--t-md); font-family: var(--f-body); font-weight: 700; letter-spacing: 0; }
.opt p { font-size: var(--t-sm); color: var(--ink-2); margin-top: .15rem; }
.opt-meta { text-align: right; display: grid; gap: .15rem; }
.opt-meta b { font-family: var(--f-mono); font-size: var(--t-sm); }
.opt-meta span { font-size: var(--t-xs); color: var(--ink-3); }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: var(--t-sm); color: #fff; flex: none; }
.avatar.sm { width: 30px; height: 30px; font-size: 11px; }

/* Calendario mensual */
.cal-wrap { display: grid; grid-template-columns: minmax(0, 330px) minmax(0, 1fr); gap: 1.5rem; margin-top: 1.4rem; align-items: start; }
.cal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1rem; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.cal-head strong { font-family: var(--f-display); font-size: var(--t-lg); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-grid .dow { text-align: center; font-size: 11px; color: var(--ink-3); font-weight: 600; padding: .3rem 0; text-transform: uppercase; }
.cal-day { aspect-ratio: 1; max-width: 100%; border: 0; border-radius: 10px; background: transparent; cursor: pointer; font-family: var(--f-mono); font-size: var(--t-sm); position: relative; color: var(--ink); }
.cal-day:disabled { color: var(--ink-3); opacity: .45; cursor: default; }
.cal-day.avail::after { content: ""; position: absolute; left: 50%; bottom: 6px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--brand); }
.cal-day.avail:hover { background: var(--brand-soft); }
.cal-day.today { box-shadow: inset 0 0 0 1px var(--line); }
.cal-day.sel { background: var(--brand); color: var(--on-brand); }
.cal-day.sel::after { background: var(--on-brand); }
.slots-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .75rem; }
.slots-head strong { font-family: var(--f-display); font-size: var(--t-lg); }
.slot-group + .slot-group { margin-top: 1rem; }
.slot-group .eyebrow { display: block; margin-bottom: .45rem; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .45rem; }
.slot { height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-family: var(--f-mono); font-size: var(--t-sm); cursor: pointer; transition: all .12s; }
.slot:hover { border-color: var(--brand); color: var(--brand-fg); }
.slot[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.empty { padding: 2rem 1rem; text-align: center; color: var(--ink-3); border: 1px dashed var(--line); border-radius: var(--r-md); font-size: var(--t-sm); }

.bk-summary { position: sticky; top: calc(1.5rem + env(safe-area-inset-top, 0px)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.25rem; box-shadow: var(--shadow-1); }
.bk-summary h3 { font-size: var(--t-md); margin-bottom: 1rem; }
.sum-row { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: .7rem; padding: .7rem 0; border-top: 1px solid var(--line); font-size: var(--t-sm); }
.sum-row svg { width: 18px; height: 18px; color: var(--ink-3); margin-top: 1px; }
.sum-row b { display: block; font-weight: 600; }
.sum-row span { color: var(--ink-3); }
.sum-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: .9rem; border-top: 1px solid var(--line); margin-top: .2rem; }
.sum-total b { font-family: var(--f-mono); font-size: var(--t-lg); }
.bk-nav { display: flex; justify-content: space-between; gap: .75rem; margin-top: 2rem; }
.bk-foot { margin-top: auto; padding-top: 2.5rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: var(--t-xs); color: var(--ink-3); }
.bk-foot a { color: inherit; }

.done-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-2); max-width: 620px; }
.done-top { padding: 2rem 2rem 1.5rem; background: linear-gradient(180deg, var(--brand-soft), var(--surface)); }
.done-check { width: 56px; height: 56px; border-radius: 50%; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; margin-bottom: 1.1rem; animation: pop .45s cubic-bezier(.2,1.4,.4,1); }
.done-check svg { width: 28px; height: 28px; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
.done-code { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0 2rem; padding: 1rem 1.2rem; border-radius: var(--r-md); border: 1px dashed var(--brand-line); background: var(--surface); }
.done-code .num { font-size: var(--t-xl); font-weight: 600; letter-spacing: .06em; color: var(--brand-fg); }
.done-list { padding: 1rem 2rem; display: grid; }
.done-actions { display: flex; flex-wrap: wrap; gap: .6rem; padding: 0 2rem 2rem; }

@media (max-width: 1100px) { .bk-body { grid-template-columns: 1fr; } .bk-summary { position: static; } .cal-wrap { grid-template-columns: 1fr; } .cal { max-width: 420px; } }
@media (max-width: 860px) {
  .bk { grid-template-columns: 1fr; }
  .bk-side { padding: 1.5rem 16px 1.75rem; gap: 1.25rem; }
  .bk-facts, .bk-trust { display: none; }
  .bk-hero h1 { font-size: 2rem; }
  .bk-main { padding: 1.5rem 16px 2rem; }
  .stepper li span { display: none; }
  .stepper li { padding: .3rem; }
  .done-top, .done-list { padding-left: 1.25rem; padding-right: 1.25rem; }
  .done-code { margin: 0 1.25rem; } .done-actions { padding: 0 1.25rem 1.5rem; }
}

/* =====================================================================
   MODALES Y CAJONES (compartidos)
   ===================================================================== */
.scrim { position: fixed; inset: 0; background: color-mix(in srgb, #06100F 55%, transparent); backdrop-filter: blur(3px); z-index: 60; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-3); z-index: 61; animation: modalIn .22s ease-out; }
@keyframes modalIn { from { opacity: 0; transform: translate(-50%, -46%); } }
.modal-head, .drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--line); }
.modal-head h3, .drawer-head h3 { font-size: var(--t-lg); }
.modal-body, .drawer-body { padding: 1.4rem; display: grid; gap: 1rem; }
.modal-foot, .drawer-foot { display: flex; justify-content: flex-end; gap: .6rem; padding: 1rem 1.4rem; border-top: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); background: var(--surface); z-index: 61; box-shadow: var(--shadow-3); display: flex; flex-direction: column; animation: drawerIn .25s ease-out; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.drawer-body { overflow: auto; flex: 1; align-content: start; }
@keyframes drawerIn { from { transform: translateX(40px); opacity: 0; } }
.confirm-inline { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .6rem .8rem; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-size: var(--t-sm); font-weight: 600; }

/* =====================================================================
   PANEL ADMINISTRATIVO
   ===================================================================== */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100%; }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 1.25rem; padding: 1.25rem .9rem; background: var(--surface); border-right: 1px solid var(--line); }
.rail-brand { display: flex; align-items: center; gap: .65rem; padding: .25rem .5rem; }
.rail-brand .bk-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--brand); color: var(--on-brand); border: 0; font-size: .95rem; }
.rail-brand strong { font-family: var(--f-display); font-size: var(--t-md); display: block; line-height: 1.2; }
.rail-brand small { color: var(--ink-3); font-size: var(--t-xs); }
.nav { display: grid; gap: 2px; }
.nav .eyebrow { padding: .8rem .75rem .35rem; }
.nav a { display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: var(--t-md); }
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--brand-soft); color: var(--brand-fg); font-weight: 650; }
.nav a .badge { margin-left: auto; font-size: 11px; font-family: var(--f-mono); background: var(--brand); color: var(--on-brand); border-radius: 99px; padding: 0 .45rem; line-height: 18px; }
.rail-foot { margin-top: auto; display: grid; gap: .6rem; }
.user-card { display: flex; align-items: center; gap: .6rem; padding: .6rem; border-radius: 12px; border: 1px solid var(--line); }
.user-card div { min-width: 0; flex: 1; }
.user-card b { display: block; font-size: var(--t-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card span { font-size: var(--t-xs); color: var(--ink-3); }

.work { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; display: flex; align-items: center; gap: 1rem; padding: .9rem clamp(16px, 3vw, 2rem); background: color-mix(in srgb, var(--paper) 86%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: var(--t-xl); }
.topbar .spacer { flex: 1; }
.search { position: relative; width: min(280px, 32vw); }
.search svg { position: absolute; left: .75rem; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--ink-3); }
.search .input { padding-left: 2.2rem; min-height: 38px; }
.menu-btn { display: none; }
.view { padding: 1.5rem clamp(16px, 3vw, 2rem) 3rem; display: grid; gap: 1.25rem; align-content: start; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h2 { font-size: var(--t-md); font-family: var(--f-body); font-weight: 700; letter-spacing: 0; }
.card-body { padding: 1.25rem; }

.hello { display: flex; justify-content: space-between; align-items: end; gap: 1rem; flex-wrap: wrap; }
.hello h2 { font-size: var(--t-2xl); letter-spacing: -.03em; }
.hello p { color: var(--ink-2); margin-top: .25rem; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.kpi { padding: 1.1rem 1.2rem; display: grid; gap: .35rem; }
.kpi .eyebrow { display: flex; justify-content: space-between; }
.kpi b { font-family: var(--f-display); font-size: 2rem; font-weight: 650; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi small { font-size: var(--t-xs); color: var(--ink-3); }
.delta { font-weight: 700; font-family: var(--f-mono); font-size: var(--t-xs); }
.delta.up { color: var(--ok); } .delta.down { color: var(--bad); }
.meter { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: .25rem; }
.meter i { display: block; height: 100%; background: var(--brand); border-radius: inherit; }
.dash { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1.25rem; }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--ink-3); font-family: var(--f-mono); font-size: 10px; }
.chart .grid { stroke: var(--line); stroke-dasharray: 2 4; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: var(--t-xs); color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.agenda-list { display: grid; }
.agenda-item { display: grid; grid-template-columns: 76px 4px minmax(0, 1fr) auto; gap: .9rem; align-items: center; padding: .8rem 1.25rem; border-top: 1px solid var(--line); cursor: pointer; transition: background .12s; }
.agenda-item:first-child { border-top: 0; }
.agenda-item:hover { background: var(--surface-2); }
.agenda-item .t { font-family: var(--f-mono); font-size: var(--t-sm); font-weight: 600; white-space: nowrap; }
.agenda-item .t small { display: block; color: var(--ink-3); font-weight: 400; font-size: var(--t-xs); }
.agenda-item .bar { width: 4px; align-self: stretch; border-radius: 4px; }
.agenda-item b { font-weight: 650; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agenda-item span.sub { color: var(--ink-3); font-size: var(--t-sm); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar { display: grid; gap: .8rem; }
.hbar-row { display: grid; gap: .3rem; }
.hbar-row div:first-child { display: flex; justify-content: space-between; gap: 1rem; font-size: var(--t-sm); }
.hbar-row .meter { height: 8px; }

/* Calendario semanal */
.cal-toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.cal-toolbar h2 { font-size: var(--t-xl); margin-right: auto; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: .35rem .8rem; border-radius: 7px; font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.staff-filter { display: flex; gap: .4rem; flex-wrap: wrap; }
.staff-filter button { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: .25rem .7rem .25rem .35rem; font-size: var(--t-xs); font-weight: 600; cursor: pointer; color: var(--ink-2); }
.staff-filter button[aria-pressed="false"] { opacity: .45; }
.wk { overflow-x: auto; }
.wk-grid { display: grid; min-width: 760px; position: relative; }
.wk-head { position: sticky; top: 0; z-index: 3; background: var(--surface); display: grid; border-bottom: 1px solid var(--line); }
.wk-head div { padding: .6rem .5rem; text-align: center; font-size: var(--t-xs); color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.wk-head div b { display: block; font-family: var(--f-display); font-size: var(--t-xl); color: var(--ink); letter-spacing: -.02em; text-transform: none; }
.wk-head div.today b { color: var(--brand-fg); }
.wk-head div.today b span { background: var(--brand); color: var(--on-brand); border-radius: 10px; padding: 0 .4rem; }
.wk-body { display: grid; position: relative; }
.wk-times div { height: var(--hh); white-space: nowrap; font-family: var(--f-mono); font-size: 10.5px; color: var(--ink-3); text-align: right; padding-right: .5rem; transform: translateY(-.55em); }
.wk-col { position: relative; border-left: 1px solid var(--line); background-image: linear-gradient(var(--line) 1px, transparent 1px); background-size: 100% var(--hh); cursor: copy; }
.wk-col.closed { background-color: var(--surface-2); cursor: not-allowed; }
.wk-col.off { background-color: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.wk-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--bad); z-index: 2; pointer-events: none; }
.wk-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.ev { position: absolute; left: 3px; right: 3px; border-radius: 7px; padding: .25rem .4rem; font-size: 11.5px; line-height: 1.25; overflow: hidden; cursor: pointer; border: 1px solid transparent; transition: transform .1s, box-shadow .1s; z-index: 1; }
.ev:hover { transform: scale(1.015); box-shadow: var(--shadow-2); z-index: 2; }
.ev b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev span { opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.ev .mono { font-size: 10.5px; }
.ev.cancelada { opacity: .45; text-decoration: line-through; }
.ev.pendiente { border-style: dashed; }

/* Tablas */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.tbl th { text-align: left; font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 600; padding: .7rem 1rem; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
.tbl td { padding: .75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; transition: background .12s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .who { display: flex; align-items: center; gap: .6rem; }
.tbl .who b { display: block; font-weight: 650; }
.tbl .who span { color: var(--ink-3); font-size: var(--t-xs); }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.filters .input, .filters .select { width: auto; min-height: 36px; font-size: var(--t-sm); }

.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.svc { padding: 1.1rem 1.2rem; display: grid; gap: .6rem; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.svc:hover { border-color: var(--brand-line); box-shadow: var(--shadow-2); }
.svc-top { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.svc h3 { font-size: var(--t-md); font-family: var(--f-body); font-weight: 700; letter-spacing: 0; }
.svc p { font-size: var(--t-sm); color: var(--ink-2); }
.svc-meta { display: flex; gap: 1rem; font-size: var(--t-sm); color: var(--ink-2); padding-top: .6rem; border-top: 1px solid var(--line); }
.svc-meta b { color: var(--ink); font-family: var(--f-mono); }
.svc.inactive { opacity: .55; }

.sched { display: grid; gap: .5rem; }
.sched-row { display: grid; grid-template-columns: 110px 44px minmax(0, 1fr); gap: .75rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.sched-row .ranges { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.sched-row .ranges .input { width: 96px; min-height: 34px; padding: .3rem .5rem; font-family: var(--f-mono); font-size: var(--t-sm); }
.sched-row .ranges span { color: var(--ink-3); font-size: var(--t-xs); }
.swatches { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.set-grid { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 2rem; padding: 1.5rem 1.25rem; border-top: 1px solid var(--line); }
.set-grid:first-of-type { border-top: 0; }
.set-grid h3 { font-size: var(--t-md); font-family: var(--f-body); font-weight: 700; letter-spacing: 0; }
.set-grid > div:first-child p { font-size: var(--t-sm); color: var(--ink-3); margin-top: .3rem; }
.set-grid > div:last-child { display: grid; gap: 1rem; min-width: 0; }
.codebox { font-family: var(--f-mono); font-size: var(--t-xs); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: .75rem .9rem; overflow-x: auto; white-space: pre; color: var(--ink-2); }
.patient-head { display: flex; gap: 1rem; align-items: center; }
.patient-head .avatar { width: 56px; height: 56px; font-size: var(--t-lg); }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.stat-row div { background: var(--surface-2); border-radius: 10px; padding: .6rem .75rem; }
.stat-row b { display: block; font-family: var(--f-mono); font-size: var(--t-lg); }
.stat-row span { font-size: var(--t-xs); color: var(--ink-3); }
.kv { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: .5rem 1rem; font-size: var(--t-sm); }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.statusbar { display: flex; flex-wrap: wrap; gap: .4rem; }
.statusbar button { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: .3rem .75rem; font-size: var(--t-xs); font-weight: 600; cursor: pointer; color: var(--ink-2); }
.statusbar button[aria-pressed="true"].st-pendiente { border-color: var(--warn); }
.statusbar button[aria-pressed="true"] { box-shadow: 0 0 0 2px currentColor inset; }

/* Login */
.login { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.login-art { position: relative; overflow: hidden; color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; background: linear-gradient(160deg, var(--brand), color-mix(in srgb, var(--brand) 45%, #03100F)); }
.login-art h2 { font-size: var(--t-3xl); max-width: 14ch; letter-spacing: -.035em; line-height: 1.02; }
.login-art p { opacity: .8; max-width: 40ch; margin-top: 1rem; }
.login-preview { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); border-radius: 16px; padding: 1rem; display: grid; gap: .5rem; backdrop-filter: blur(8px); max-width: 380px; }
.login-preview div { display: grid; grid-template-columns: 52px 1fr auto; gap: .75rem; align-items: center; font-size: var(--t-sm); padding: .5rem .6rem; border-radius: 10px; background: rgba(255,255,255,.08); }
.login-preview .mono { opacity: .8; font-size: var(--t-xs); }
.login-preview em { font-style: normal; font-size: 11px; padding: .1rem .5rem; border-radius: 99px; background: rgba(255,255,255,.18); }
.login-form { display: grid; place-items: center; padding: 2rem 16px; }
.login-form form { width: min(380px, 100%); display: grid; gap: 1.1rem; }
.login-form h1 { font-size: var(--t-2xl); }
.hint { font-size: var(--t-sm); padding: .75rem .9rem; border-radius: 10px; background: var(--brand-soft); color: var(--ink-2); }
.err-msg { color: var(--bad); font-size: var(--t-sm); font-weight: 600; }

@media (max-width: 1200px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dash { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; z-index: 70; transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow-3); padding-top: calc(1.25rem + env(safe-area-inset-top, 0px)); }
  .app.nav-open .rail { transform: none; }
  .menu-btn { display: inline-flex; }
  .search { display: none; }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .set-grid { grid-template-columns: 1fr; gap: 1rem; }
  .topbar h1 { font-size: var(--t-lg); }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .kpi { padding: .9rem; } .kpi b { font-size: 1.5rem; }
  .sched-row { grid-template-columns: 1fr auto; }
  .sched-row .ranges { grid-column: 1 / -1; }
  .agenda-item { grid-template-columns: 54px 4px minmax(0, 1fr); }
  .agenda-item .pill { display: none; }
  .topbar .btn-primary span { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
