/* ============================================================
   Vintia — sistema de diseño único para landing, login y el
   dashboard clínico. Tokens con propósito: --sage/--fjord son
   acentos semánticos (positivo/informativo); --sand es a la vez
   "atención" y "error" — deliberadamente nunca rojo, para no
   generar alarma visual en un entorno clínico.
   ============================================================ */

@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/fraunces-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Hanken Grotesk';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/hanken-grotesk-variable.woff2') format('woff2');
}

:root {
  --paper: #f5f6f1;
  --paper-raised: #ffffff;
  --paper-sunken: #eff0ea;
  --ink: #1e293b;
  --ink-soft: #47566b;
  --muted: #667085;
  --faint: #97a1ae;
  --line: #e2e0d8;
  --line-strong: #d3d1c6;
  --fjord: #35567d;
  --fjord-ink: #26415f;
  --fjord-bg: #e8edf3;
  --sage: #2f6b4f;
  --sage-deep: #14532d;
  --sage-bg: #e8efe7;
  --sand: #7a5d29;
  --sand-bg: #f2ebdd;
  --panel: #1e293b;
  --panel-fg: #f5f6f1;
  --panel-fg-soft: #b9c2d4;
  --panel-line: rgba(245,246,241,.14);
  --shadow-soft: 0 1px 2px rgba(30,41,59,.04), 0 20px 48px -24px rgba(30,41,59,.24);
  --shadow-modal: 0 24px 64px -20px rgba(30,41,59,.38);
  --radius-s: 10px;
  --radius-m: 14px;
  --radius-l: 20px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14181a; --paper-raised: #1b2023; --paper-sunken: #101315;
    --ink: #edeee9; --ink-soft: #c6cbc3; --muted: #96a09a; --faint: #6d766f;
    --line: #2a2f2d; --line-strong: #383e3b;
    --fjord: #8fb0d6; --fjord-ink: #cfe0f2; --fjord-bg: #1c2833;
    --sage: #6bab84; --sage-deep: #a9d6ba; --sage-bg: #16261c;
    --sand: #d8bb84; --sand-bg: #2b2317;
    --panel: #0e1113; --panel-fg: #edeee9; --panel-fg-soft: #97a19c; --panel-line: rgba(237,238,233,.1);
    --shadow-soft: 0 1px 2px rgba(0,0,0,.3), 0 20px 48px -24px rgba(0,0,0,.5);
    --shadow-modal: 0 24px 64px -20px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --paper: #14181a; --paper-raised: #1b2023; --paper-sunken: #101315;
  --ink: #edeee9; --ink-soft: #c6cbc3; --muted: #96a09a; --faint: #6d766f;
  --line: #2a2f2d; --line-strong: #383e3b;
  --fjord: #8fb0d6; --fjord-ink: #cfe0f2; --fjord-bg: #1c2833;
  --sage: #6bab84; --sage-deep: #a9d6ba; --sage-bg: #16261c;
  --sand: #d8bb84; --sand-bg: #2b2317;
  --panel: #0e1113; --panel-fg: #edeee9; --panel-fg-soft: #97a19c; --panel-line: rgba(237,238,233,.1);
  --shadow-soft: 0 1px 2px rgba(0,0,0,.3), 0 20px 48px -24px rgba(0,0,0,.5);
  --shadow-modal: 0 24px 64px -20px rgba(0,0,0,.6);
}
:root[data-theme="light"] {
  --paper: #f5f6f1; --paper-raised: #ffffff; --paper-sunken: #eff0ea;
  --ink: #1e293b; --ink-soft: #47566b; --muted: #667085; --faint: #97a1ae;
  --line: #e2e0d8; --line-strong: #d3d1c6;
  --fjord: #35567d; --fjord-ink: #26415f; --fjord-bg: #e8edf3;
  --sage: #2f6b4f; --sage-deep: #14532d; --sage-bg: #e8efe7;
  --sand: #7a5d29; --sand-bg: #f2ebdd;
  --panel: #1e293b; --panel-fg: #f5f6f1; --panel-fg-soft: #b9c2d4; --panel-line: rgba(245,246,241,.14);
  --shadow-soft: 0 1px 2px rgba(30,41,59,.04), 0 20px 48px -24px rgba(30,41,59,.24);
  --shadow-modal: 0 24px 64px -20px rgba(30,41,59,.38);
}

/* Rojo — acotado al indicador de asistencia (el resto del sistema evita el rojo). */
:root { --danger: #b3261e; --danger-bg: #fbe9e7; }
@media (prefers-color-scheme: dark) { :root { --danger: #e28a80; --danger-bg: #2c1613; } }
:root[data-theme="dark"] { --danger: #e28a80; --danger-bg: #2c1613; }
:root[data-theme="light"] { --danger: #b3261e; --danger-bg: #fbe9e7; }

/* ================= RESET / BASE ================= */
* { box-sizing: border-box; }
html { color-scheme: light dark; height: 100%; }
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Hanken Grotesk', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;   /* red de seguridad contra scroll horizontal accidental */
}
body.nav-lock { overflow: hidden; }   /* bloquea el scroll del fondo con el menú móvil abierto */
a { color: inherit; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
p { text-wrap: pretty; }
button { font-family: inherit; }
::selection { background: var(--sage-bg); color: var(--sage-deep); }
*:focus-visible { outline: 2px solid var(--fjord); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.tabular { font-variant-numeric: tabular-nums; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 32px; }
.eyebrow { font-size: 12.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ================= BOTONES (compartidos) ================= */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: inherit; font-size: 14.5px; font-weight: 600; letter-spacing: -.005em;
  padding: 11px 20px; border-radius: 11px; border: 1.5px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: all .3s cubic-bezier(.2,.7,.3,1);
}
.btn-sm { padding: 9px 16px; font-size: 13.5px; border-radius: 9px; }
.btn-primary { background: var(--ink); color: var(--paper); box-shadow: var(--shadow-soft); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 20px 40px -18px rgba(30,41,59,.4); }
.btn-primary svg { transition: transform .3s cubic-bezier(.2,.7,.3,1); }
.btn-primary:hover svg { transform: translateX(3px); }
.btn-outline { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-outline:hover { border-color: var(--ink); background: var(--paper-raised); }
.btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn[aria-disabled="true"]:hover { transform: none; box-shadow: var(--shadow-soft); }

/* ================= LANDING: nav ================= */
.nav {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.1); -webkit-backdrop-filter: blur(14px) saturate(1.1);
  border-bottom: 1px solid transparent; transition: border-color .3s ease;
}
.nav.scrolled { border-bottom-color: var(--line); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 16px 32px; max-width: 1180px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.01em; text-decoration: none; color: var(--ink); flex-shrink: 0; }
.brand svg { flex-shrink: 0; }
.nav-links { display: flex; gap: 8px; list-style: none; margin: 0; padding: 0; }
.nav-links a { display: inline-block; padding: 8px 14px; border-radius: 999px; font-size: 14.5px; font-weight: 500; color: var(--ink-soft); text-decoration: none; transition: background .2s ease, color .2s ease; }
.nav-links a:hover { background: var(--fjord-bg); color: var(--fjord-ink); }
.nav-ctas { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* ================= LANDING: hero ================= */
.hero { position: relative; padding: 88px 32px 64px; overflow: hidden; }
.hero-inner { position: relative; z-index: 2; max-width: 880px; margin: 0 auto; text-align: center; display: flex; flex-direction: column; align-items: center; }
.badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--sage-bg); color: var(--sage-deep);
  font-size: 13px; font-weight: 600; letter-spacing: .01em;
  padding: 7px 16px 7px 12px; border-radius: 999px; margin-bottom: 28px;
  opacity: 0; animation: rise .7s .1s cubic-bezier(.16,1,.3,1) both;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--sage); flex-shrink: 0; animation: pulse 2.4s ease-in-out infinite; }
.hero h1 {
  font-family: 'Fraunces', Georgia, serif; font-weight: 600;
  font-size: clamp(2.4rem, 5.2vw, 4.15rem); line-height: 1.06; letter-spacing: -.02em; color: var(--ink);
  opacity: 0; animation: rise .8s .2s cubic-bezier(.16,1,.3,1) both;
}
.hero h1 em { font-style: italic; color: var(--sage-deep); }
.hero p.lede {
  margin-top: 22px; max-width: 620px; font-size: 18px; line-height: 1.65; color: var(--ink-soft);
  opacity: 0; animation: rise .8s .32s cubic-bezier(.16,1,.3,1) both;
}
.hero-ctas { display: flex; gap: 14px; margin-top: 36px; flex-wrap: wrap; justify-content: center; opacity: 0; animation: rise .8s .44s cubic-bezier(.16,1,.3,1) both; }
.hero-ctas .btn { padding: 14px 24px; font-size: 15px; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

.vintia-line { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.vintia-line svg { width: 100%; height: 100%; }
.vintia-line path { fill: none; stroke-width: 1.4; stroke-linecap: round; }
.vintia-line .p1 { stroke: var(--sage); opacity: .16; }
.vintia-line .p2 { stroke: var(--fjord); opacity: .12; }
.vintia-line .p3 { stroke: var(--sand); opacity: .1; }
.flow-anim { stroke-dasharray: 6 10; animation: flow 26s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -400; } }

.trust { padding: 4px 32px 72px; text-align: center; }
.trust p { font-size: 13px; color: var(--faint); letter-spacing: .02em; }

/* ================= LANDING: features ================= */
.section { padding: 88px 32px; }
.section-head { max-width: 620px; margin: 0 auto 52px; text-align: center; }
.section-head h2 { margin-top: 12px; font-size: clamp(1.7rem, 3vw, 2.35rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.18; }
.section-head p { margin-top: 14px; color: var(--muted); font-size: 16px; line-height: 1.6; }

.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; max-width: 1120px; margin: 0 auto; }
.feature-card { background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 30px 26px; transition: transform .35s cubic-bezier(.2,.7,.3,1), box-shadow .35s ease, border-color .35s ease; }
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-soft); border-color: var(--line-strong); }
.feature-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 20px; }
.feature-card.sage .feature-icon { background: var(--sage-bg); color: var(--sage-deep); }
.feature-card.fjord .feature-icon { background: var(--fjord-bg); color: var(--fjord-ink); }
.feature-card.sand .feature-icon { background: var(--sand-bg); color: var(--sand); }
.feature-card h3 { font-size: 17.5px; font-weight: 700; letter-spacing: -.01em; }
.feature-card p { margin-top: 10px; font-size: 14.5px; line-height: 1.65; color: var(--muted); }

/* ================= LANDING: seguridad legal ================= */
.legal {
  background: var(--ink); border-radius: var(--radius-l); max-width: 1120px; margin: 0 auto; padding: 56px 48px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: center;
  --legal-fg: var(--paper); --legal-fg-soft: #c3cbd6; --legal-eyebrow: #a7b3c4; --legal-check: #8fb0d6;
}
:root[data-theme="dark"] .legal {
  background: var(--paper-raised); border: 1px solid var(--line-strong);
  --legal-fg: var(--ink); --legal-fg-soft: var(--muted); --legal-eyebrow: var(--muted); --legal-check: var(--fjord);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .legal {
    background: var(--paper-raised); border: 1px solid var(--line-strong);
    --legal-fg: var(--ink); --legal-fg-soft: var(--muted); --legal-eyebrow: var(--muted); --legal-check: var(--fjord);
  }
}
.legal-copy .eyebrow { color: var(--legal-eyebrow); }
.legal h2 { margin-top: 10px; font-size: 1.8rem; font-weight: 700; letter-spacing: -.02em; color: var(--legal-fg); }
.legal p { margin-top: 14px; color: var(--legal-fg-soft); font-size: 15px; line-height: 1.7; max-width: 46ch; }
.legal-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.legal-list li { display: flex; align-items: flex-start; gap: 12px; font-size: 14.5px; color: var(--legal-fg-soft); line-height: 1.5; }
.legal-list svg { flex-shrink: 0; margin-top: 2px; color: var(--legal-check); }
.legal-list strong { color: var(--legal-fg); font-weight: 600; }

/* ================= LANDING: precios ================= */
.pricing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; max-width: 880px; margin: 0 auto; }
.price-card { background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 32px 30px; }
.price-card.featured { border-color: var(--sage); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sage) 14%, transparent); }
.price-card h3 { font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.price-card .price { margin-top: 12px; font-size: 2.1rem; font-weight: 700; letter-spacing: -.02em; }
.price-card .price span { font-size: 14px; font-weight: 500; color: var(--muted); }
.price-card ul { list-style: none; margin: 22px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.price-card li { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--ink-soft); }
.price-card li svg { flex-shrink: 0; margin-top: 2px; color: var(--sage); }
.price-card .btn { margin-top: 26px; width: 100%; justify-content: center; }

/* ================= LANDING: cta final + footer ================= */
.cta-final { text-align: center; padding: 96px 32px 110px; }
.cta-final h2 { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: clamp(1.9rem, 3.6vw, 2.7rem); letter-spacing: -.015em; max-width: 640px; margin: 0 auto; }
.cta-final p { margin: 16px auto 0; max-width: 480px; color: var(--muted); font-size: 15.5px; }
.cta-final .hero-ctas { justify-content: center; margin-top: 32px; animation: none; opacity: 1; }

footer { border-top: 1px solid var(--line); padding: 40px 32px; }
.foot-inner { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.foot-links { display: flex; gap: 24px; list-style: none; margin: 0; padding: 0; }
.foot-links a { font-size: 13.5px; color: var(--muted); text-decoration: none; }
.foot-links a:hover { color: var(--ink); }
.foot-copy { font-size: 13px; color: var(--faint); }

@media (max-width: 860px) {
  .nav-links { display: none; }
  .features { grid-template-columns: 1fr; }
  .legal { grid-template-columns: 1fr; padding: 36px 28px; }
  .pricing-grid { grid-template-columns: 1fr; }
  .hero { padding-top: 64px; }
}

/* ================= LOGIN: split-screen ================= */
.screen { display: flex; min-height: 100vh; }
.panel {
  position: relative; flex: 1 1 46%; background: var(--panel); color: var(--panel-fg);
  display: flex; flex-direction: column; justify-content: space-between; padding: 48px; overflow: hidden;
}
.panel-line { position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: .5; }
.panel-line svg { width: 100%; height: 100%; }
.panel-line path { fill: none; stroke-width: 1.2; stroke: var(--panel-fg); opacity: .1; stroke-linecap: round; stroke-dasharray: 5 9; animation: flow 30s linear infinite; }
.panel-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.panel-quote { position: relative; z-index: 1; max-width: 420px; }
.panel-quote blockquote { margin: 0; font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: clamp(1.5rem, 2.4vw, 1.9rem); line-height: 1.32; letter-spacing: -.01em; }
.panel-quote cite { display: block; margin-top: 18px; font-style: normal; font-size: 13.5px; color: var(--panel-fg-soft); }
.pillars { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 18px; }
.pillar { display: flex; align-items: center; gap: 14px; }
.pillar-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--panel-line); display: grid; place-items: center; flex-shrink: 0; }
.pillar-copy p { margin: 0; font-size: 14px; font-weight: 600; }
.pillar-copy span { font-size: 12.5px; color: var(--panel-fg-soft); }

.form-panel { flex: 1 1 54%; display: flex; align-items: center; justify-content: center; padding: 48px 32px; }
.form-card { width: 100%; max-width: 380px; }
.form-brand { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--muted); letter-spacing: -.005em; margin-bottom: 36px; }
.form-card h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.form-card .sub { margin: 8px 0 32px; font-size: 14.5px; color: var(--muted); }

.form-error {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--sand-bg); color: var(--sand); border-radius: var(--radius-s);
  padding: 12px 14px; margin-bottom: 22px; font-size: 13.5px; line-height: 1.5;
}
.form-error svg { flex-shrink: 0; margin-top: 1px; }

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.field-shell { position: relative; display: flex; align-items: center; }
.field-icon { position: absolute; left: 14px; color: var(--faint); display: flex; pointer-events: none; }
.field input {
  width: 100%; font-family: inherit; font-size: 15px; color: var(--ink);
  background: var(--paper-raised); border: 1.5px solid var(--line); border-radius: var(--radius-s);
  padding: 12px 14px 12px 42px; transition: border-color .2s ease, box-shadow .2s ease;
}
.field input::placeholder { color: var(--faint); }
.field input:hover { border-color: var(--line-strong); }
.field input:focus { outline: none; border-color: var(--fjord); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fjord) 16%, transparent); }
.toggle-eye {
  position: absolute; right: 6px; width: 32px; height: 32px; display: grid; place-items: center;
  background: none; border: none; border-radius: 8px; color: var(--muted); cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.toggle-eye:hover { background: var(--fjord-bg); color: var(--fjord-ink); }

.row-control { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 26px; font-size: 13.5px; }
.remember { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); cursor: pointer; user-select: none; }
.remember input { width: 16px; height: 16px; accent-color: var(--fjord); cursor: pointer; }
.forgot { color: var(--fjord); text-decoration: none; font-weight: 600; }
.forgot:hover { text-decoration: underline; }

.btn-submit {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 9px;
  font-family: inherit; font-size: 15px; font-weight: 600; color: var(--paper); background: var(--ink);
  border: none; border-radius: var(--radius-s); padding: 13px 20px; cursor: pointer; box-shadow: var(--shadow-soft);
  transition: transform .25s cubic-bezier(.2,.7,.3,1), box-shadow .25s ease, opacity .2s ease;
}
.btn-submit:hover:not(:disabled) { transform: translateY(-1px); }
.btn-submit:disabled { opacity: .55; cursor: not-allowed; }
.btn-submit .spin { width: 15px; height: 15px; border: 2px solid rgba(245,246,241,.35); border-top-color: var(--paper); border-radius: 50%; animation: spin .7s linear infinite; display: none; }
.btn-submit.loading .spin { display: inline-block; }
.btn-submit.loading .label { opacity: .85; }
@keyframes spin { to { transform: rotate(360deg); } }

.form-foot { margin-top: 28px; text-align: center; font-size: 13px; color: var(--faint); }
.form-foot a { color: var(--fjord); font-weight: 600; text-decoration: none; }
.form-foot a:hover { text-decoration: underline; }

@media (max-width: 880px) {
  .panel { display: none; }
  .form-panel { flex: 1 1 100%; }
}

/* ================= DASHBOARD: layout ================= */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 264px; flex-shrink: 0; background: var(--paper-raised); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 60;
}
.sidebar-head { padding: 20px 20px 16px; border-bottom: 1px solid var(--line); }
.sidebar-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16.5px; letter-spacing: -.01em; text-decoration: none; color: var(--ink); }
.sidebar-brand svg { flex-shrink: 0; color: var(--sage); }

.menu-toggle {
  display: none; width: 34px; height: 34px; align-items: center; justify-content: center;
  background: var(--paper-sunken); border: 1px solid var(--line); border-radius: var(--radius-s);
  color: var(--ink-soft); cursor: pointer;
}

.tenant-switch {
  margin-top: 14px; width: 100%; display: flex; align-items: center; gap: 10px;
  background: var(--paper-sunken); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 9px 11px; cursor: pointer; text-align: left; transition: border-color .2s ease, background .2s ease;
}
.tenant-switch:hover { border-color: var(--line-strong); background: var(--paper-raised); }
.tenant-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sage); flex-shrink: 0; }
.tenant-info { flex: 1; min-width: 0; }
.tenant-name { display: block; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tenant-sub { display: block; font-size: 11px; color: var(--faint); margin-top: 1px; }
.tenant-switch svg.chev { color: var(--faint); flex-shrink: 0; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--radius-s);
  font-size: 13.5px; font-weight: 500; color: var(--ink-soft);
  text-decoration: none; background: none; border: none; cursor: pointer; width: 100%; text-align: left;
  transition: background .18s ease, color .18s ease;
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: var(--paper-sunken); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--sage-bg); color: var(--sage-deep); font-weight: 700; }
.nav-item[aria-current="page"] svg { color: var(--sage-deep); }

.sidebar-foot { padding: 16px 20px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 11px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--fjord-bg); color: var(--fjord-ink); display: grid; place-items: center; font-size: 12.5px; font-weight: 700; flex-shrink: 0; }
.who { min-width: 0; }
.who-name { margin: 0; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-cred { margin: 1px 0 0; font-size: 11.5px; color: var(--muted); }

.main { flex: 1; min-width: 0; padding: 32px 40px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.page-head .date { margin: 0; font-size: 12.5px; color: var(--faint); }
.page-head h1 { margin: 5px 0 0; font-size: 24px; font-weight: 700; letter-spacing: -.02em; }

/* auto-fit (y no repeat(3,1fr)) para que quepa un cuarto mosaico sin dejar
   huecos: con 3 elementos sigue dando 3 columnas, porque auto-fit colapsa las
   pistas vacías. La regla móvil de más abajo (1fr) manda igual. */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-top: 26px; }
.qa-btn { display: flex; align-items: center; gap: 13px; border-radius: var(--radius-l); padding: 17px 18px; cursor: pointer; text-align: left; border: 1px solid; text-decoration: none; transition: transform .28s cubic-bezier(.2,.7,.3,1), box-shadow .28s ease; }
.qa-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); }
.qa-btn.new-patient { background: var(--sage-bg); border-color: color-mix(in srgb, var(--sage) 30%, transparent); }
.qa-btn.new-note { background: var(--fjord-bg); border-color: color-mix(in srgb, var(--fjord) 30%, transparent); }
.qa-btn.new-attendance { background: var(--paper-sunken); border-color: var(--line); }
.qa-btn.new-invite { background: var(--sand-bg); border-color: color-mix(in srgb, var(--sand) 30%, transparent); }
.qa-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; color: #fff; }
.new-patient .qa-icon { background: var(--sage); }
.new-note .qa-icon { background: var(--fjord); }
.new-attendance .qa-icon { background: var(--ink-soft); }
.new-invite .qa-icon { background: var(--sand); }
.qa-title { margin: 0; font-size: 14px; font-weight: 700; }
.new-patient .qa-title { color: var(--sage-deep); }
.new-note .qa-title { color: var(--fjord-ink); }
.new-attendance .qa-title { color: var(--ink); }
.new-invite .qa-title { color: var(--sand); }
.qa-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 16px; }
.kpi-card { background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 18px 20px; }
.kpi-label { margin: 0; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.kpi-row { display: flex; align-items: baseline; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.kpi-hint { font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.kpi-hint.fjord { background: var(--fjord-bg); color: var(--fjord-ink); }
.kpi-hint.sand { background: var(--sand-bg); color: var(--sand); }
.kpi-hint.sage { background: var(--sage-bg); color: var(--sage-deep); }

.license-banner { margin-top: 16px; background: var(--sand-bg); color: var(--sand); border-radius: var(--radius-m); padding: 12px 16px; font-size: 13.5px; }
.license-banner p { margin: 0; }
.license-banner p + p { margin-top: 4px; }

/* Panel compacto de notas pendientes de firma */
.unsigned-card { margin-top: 16px; background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 16px 20px; }
.unsigned-card h2 { font-size: 14px; font-weight: 700; }
.unsigned-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.unsigned-row:first-of-type { border-top: none; }
.unsigned-row .info { flex: 1; min-width: 0; }
.unsigned-row .info p { margin: 0; font-size: 13px; font-weight: 700; }
.unsigned-row .info span { font-size: 11.5px; color: var(--faint); }
.sign-btn { font-size: 12.5px; font-weight: 700; color: var(--sage-deep); background: var(--sage-bg); border: none; border-radius: 8px; padding: 7px 13px; cursor: pointer; transition: background .18s ease; flex-shrink: 0; }
.sign-btn:hover { background: color-mix(in srgb, var(--sage-bg) 65%, var(--sage)); }
.sign-btn:disabled { opacity: .6; cursor: default; }

.table-card { margin-top: 28px; background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius-l); overflow: hidden; }
.table-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 22px; flex-wrap: wrap; }
.table-head h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.table-head .count { margin: 3px 0 0; font-size: 12.5px; color: var(--faint); }
.search-shell { position: relative; }
.search-shell svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search-shell input {
  width: 250px; font-family: inherit; font-size: 13.5px; color: var(--ink);
  background: var(--paper-sunken); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 8px 12px 8px 34px; transition: all .2s ease;
}
.search-shell input:focus { outline: none; background: var(--paper-raised); border-color: var(--fjord); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fjord) 14%, transparent); }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
thead th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 10px 22px; border-top: 1px solid var(--line); background: var(--paper-sunken); }
thead th:last-child { text-align: right; }
tbody tr { border-top: 1px solid var(--line); transition: background .18s ease; }
tbody tr:hover { background: var(--paper-sunken); }
tbody td { padding: 13px 22px; vertical-align: middle; }
.cell-folio { color: var(--muted); font-weight: 600; }
.cell-name { display: flex; align-items: center; gap: 11px; }
.cell-avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.cell-name-text { font-weight: 700; }
.cell-visit { color: var(--muted); }
.status-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; line-height: 1.3; white-space: nowrap; padding: 4px 11px; border-radius: 999px; }
.status-badge .sdot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

/* Temas semánticos reutilizados por avatares de tabla y badges de estado */
.cell-avatar.theme-blue, .status-badge.theme-blue { background: var(--fjord-bg); color: var(--fjord-ink); }
.cell-avatar.theme-sage, .status-badge.theme-sage { background: var(--sage-bg); color: var(--sage-deep); }
.cell-avatar.theme-sand, .status-badge.theme-sand { background: var(--sand-bg); color: var(--sand); }
.cell-avatar.theme-slate, .status-badge.theme-slate { background: var(--paper-sunken); color: var(--ink-soft); }
.status-badge.theme-blue .sdot { background: var(--fjord-ink); }
.status-badge.theme-sage .sdot { background: var(--sage-deep); }
.status-badge.theme-sand .sdot { background: var(--sand); }
.status-badge.theme-slate .sdot { background: var(--ink-soft); }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.icon-btn {
  width: 30px; height: 30px; display: grid; place-items: center;
  background: var(--paper-sunken); border: none; border-radius: 8px; color: var(--ink-soft); cursor: pointer;
  transition: background .18s ease, color .18s ease;
}
.icon-btn:hover { background: var(--fjord-bg); color: var(--fjord-ink); }
.icon-btn.primary-text { display: inline-flex; align-items: center; justify-content: center; width: auto; padding: 0 12px; gap: 7px; font-size: 12.5px; font-weight: 700; line-height: 1; white-space: nowrap; text-decoration: none; color: var(--fjord-ink); background: var(--fjord-bg); }
.icon-btn.primary-text svg { flex-shrink: 0; }
.icon-btn.primary-text:hover { background: color-mix(in srgb, var(--fjord-bg) 70%, var(--fjord)); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 16px 22px; border-top: 1px solid var(--line); }
.pagination a, .pagination span { font-size: 13px; font-weight: 600; padding: 6px 11px; border-radius: 8px; text-decoration: none; color: var(--ink-soft); }
.pagination a:hover { background: var(--paper-sunken); }
.pagination .current { background: var(--ink); color: var(--paper); }

@media (max-width: 980px) {
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.16,1,.3,1); box-shadow: var(--shadow-modal);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }   /* la X cierra el menú abierto */
  .quick-actions, .kpis { grid-template-columns: 1fr; }

  /* Barra superior fija con hamburguesa: única forma de ABRIR el menú fuera del
     sidebar (que está fuera de pantalla). */
  .app-topbar {
    display: flex; align-items: center; gap: 12px;
    position: fixed; top: 0; left: 0; right: 0; z-index: 55; height: 56px; padding: 0 14px;
    background: var(--paper-raised); border-bottom: 1px solid var(--line);
  }
  .main { padding: 72px 24px 48px; }   /* 56px de la barra + aire */

  /* Fondo oscuro que cierra el menú al tocar fuera. */
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 59;
    background: color-mix(in srgb, var(--ink) 45%, transparent); backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none; transition: opacity .25s ease;
  }
  .sidebar.open ~ .sidebar-backdrop { opacity: 1; pointer-events: auto; }
}

/* ================= DASHBOARD: overlays / modales ================= */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: color-mix(in srgb, var(--ink) 45%, transparent);
  backdrop-filter: blur(3px);
  display: flex; overflow-y: auto;   /* flex + margin:auto en .modal → centrado que sí permite scroll si el modal es más alto que la pantalla */
  animation: fadeIn .18s ease both;
  padding: 24px;
}
.overlay[hidden] { display: none; }
.overlay.side { display: block; overflow: visible; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal { width: 100%; max-width: 440px; margin: auto; background: var(--paper-raised); border-radius: var(--radius-l); box-shadow: var(--shadow-modal); padding: 24px 26px; animation: riseIn .28s cubic-bezier(.16,1,.3,1) both; }
@keyframes riseIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.modal-head p { margin: 3px 0 0; font-size: 12.5px; color: var(--faint); }
.close-btn { width: 30px; height: 30px; display: grid; place-items: center; background: var(--paper-sunken); border: none; border-radius: 8px; color: var(--muted); cursor: pointer; flex-shrink: 0; transition: all .18s ease; }
.close-btn:hover { background: var(--fjord-bg); color: var(--fjord-ink); }

.patient-search { position: relative; }
.patient-search input {
  width: 100%; font-family: inherit; font-size: 14.5px; color: var(--ink);
  background: var(--paper-sunken); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 11px 13px 11px 38px; margin-top: 18px; transition: all .2s ease;
}
.patient-search svg { position: absolute; left: 13px; top: 32px; color: var(--faint); }
.patient-search input:focus { outline: none; border-color: var(--fjord); background: var(--paper-raised); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fjord) 14%, transparent); }
.result-list { margin-top: 10px; display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow-y: auto; }
.result-item { display: flex; align-items: center; gap: 11px; width: 100%; background: none; border: none; border-radius: var(--radius-s); padding: 9px 10px; cursor: pointer; text-align: left; transition: background .18s ease; }
.result-item:hover { background: var(--paper-sunken); }
.result-name { font-size: 13.5px; font-weight: 700; }
.result-sub { font-size: 11.5px; color: var(--faint); }
.result-item svg.chev { margin-left: auto; color: var(--faint); flex-shrink: 0; }
.result-empty { font-size: 13px; color: var(--faint); padding: 14px 4px; }

.selected-patient { display: flex; align-items: center; gap: 12px; background: var(--paper-sunken); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px 13px; margin-top: 18px; }
.selected-patient .info { flex: 1; min-width: 0; }
.selected-patient .name { margin: 0; font-size: 13.5px; font-weight: 700; }
.selected-patient .sub { margin: 1px 0 0; font-size: 11.5px; color: var(--faint); }
.change-link { font-size: 12px; font-weight: 700; color: var(--fjord); background: none; border: none; cursor: pointer; }

.attend-q { margin: 20px 0 10px; font-size: 13.5px; font-weight: 700; }
.attend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.attend-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; border-radius: var(--radius-m); padding: 16px; cursor: pointer; border: 1.5px solid; background: none; transition: all .2s ease; }
.attend-btn.yes { background: var(--sage-bg); border-color: color-mix(in srgb, var(--sage) 35%, transparent); color: var(--sage-deep); }
.attend-btn.no { background: var(--sand-bg); border-color: color-mix(in srgb, var(--sand) 35%, transparent); color: var(--sand); }
.attend-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-soft); }
.attend-btn:disabled { opacity: .5; cursor: not-allowed; }
.attend-btn span { font-size: 13.5px; font-weight: 700; }
.saving-line { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 12.5px; color: var(--muted); }
.saving-line .spin { width: 13px; height: 13px; border: 2px solid var(--line-strong); border-top-color: var(--fjord); border-radius: 50%; animation: spin .7s linear infinite; }

.field-plain { margin-top: 18px; }
.field-plain label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 7px; }
.field-plain textarea {
  width: 100%; min-height: 110px; resize: vertical; font-family: inherit; font-size: 14px; line-height: 1.6; color: var(--ink);
  background: var(--paper-sunken); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px 14px; transition: all .2s ease;
}
.field-plain textarea:focus { outline: none; background: var(--paper-raised); border-color: var(--fjord); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fjord) 12%, transparent); }
.field-plain input[type="text"] {
  width: 100%; font-family: inherit; font-size: 14px; color: var(--ink);
  background: var(--paper-sunken); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px; transition: all .2s ease;
}
.field-plain input[type="text"]:focus { outline: none; background: var(--paper-raised); border-color: var(--fjord); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fjord) 12%, transparent); }
.modal-submit { width: 100%; margin-top: 18px; }

.dropzone {
  margin-top: 18px; border: 2px dashed var(--line-strong); background: var(--paper-sunken);
  border-radius: var(--radius-m); padding: 30px 20px; display: flex; flex-direction: column; align-items: center;
  gap: 8px; text-align: center; transition: all .2s ease;
}
.dropzone.dragging { border-color: var(--fjord); background: var(--fjord-bg); }
.dropzone-icon { width: 40px; height: 40px; border-radius: 11px; background: var(--fjord-bg); color: var(--fjord-ink); display: grid; place-items: center; }
.dropzone-title { margin: 6px 0 0; font-size: 13.5px; font-weight: 700; }
.dropzone-sub { margin: 0; font-size: 12px; color: var(--faint); }
.dz-actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; justify-content: center; }
.dz-btn { font-size: 12.5px; font-weight: 700; color: var(--fjord-ink); background: var(--fjord-bg); border: none; border-radius: 8px; padding: 7px 13px; cursor: pointer; transition: background .18s ease; }
.dz-btn:hover { background: color-mix(in srgb, var(--fjord-bg) 65%, var(--fjord)); }
.dz-btn.ghost { color: var(--faint); background: none; text-decoration: underline; text-underline-offset: 2px; }
.dz-btn.ghost:hover { color: var(--muted); }
.dz-field { margin-top: 12px; }
.uploaded-file { display: flex; align-items: center; gap: 11px; background: var(--sage-bg); border: 1px solid color-mix(in srgb, var(--sage) 30%, transparent); border-radius: var(--radius-s); padding: 10px 13px; margin-top: 12px; }
.uploaded-file .fname { flex: 1; font-size: 13px; font-weight: 700; color: var(--sage-deep); }
.uploaded-file .fsize { font-size: 11.5px; color: var(--sage); }

/* ================= DASHBOARD: toasts ================= */
.toast-stack { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 360px; }
.toast { display: flex; gap: 12px; align-items: flex-start; background: var(--paper-raised); border: 1px solid; border-radius: var(--radius-m); padding: 13px 15px; box-shadow: var(--shadow-modal); animation: riseIn .25s ease both; }
.toast.success { border-color: color-mix(in srgb, var(--sage) 30%, transparent); }
.toast.caution { border-color: color-mix(in srgb, var(--sand) 30%, transparent); }
.toast-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.toast.success .toast-icon { background: var(--sage-bg); color: var(--sage-deep); }
.toast.caution .toast-icon { background: var(--sand-bg); color: var(--sand); }
.toast-title { margin: 0; font-size: 13.5px; font-weight: 700; }
.toast-msg { margin: 3px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.toast-close { width: 24px; height: 24px; display: grid; place-items: center; background: none; border: none; border-radius: 6px; color: var(--faint); cursor: pointer; flex-shrink: 0; }
.toast-close:hover { background: var(--paper-sunken); color: var(--ink); }

/* ================= DASHBOARD: slide-over expediente ================= */
.slideover {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(620px, 100%);
  background: var(--paper-raised); box-shadow: -20px 0 60px -20px rgba(30,41,59,.3);
  display: flex; flex-direction: column;
  animation: slideIn .3s cubic-bezier(.16,1,.3,1) both;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: translateX(0); } }
.so-head { padding: 22px 26px 0; border-bottom: 1px solid var(--line); }
.so-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.so-patient { display: flex; align-items: center; gap: 13px; }
.so-avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.so-patient h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.so-patient p { margin: 2px 0 0; font-size: 12.5px; color: var(--faint); }

.tablist { display: flex; gap: 2px; margin-top: 18px; }
.tab { font-family: inherit; font-size: 13.5px; font-weight: 700; color: var(--faint); background: none; border: none; border-bottom: 2.5px solid transparent; padding: 9px 13px 12px; cursor: pointer; transition: color .18s ease, border-color .18s ease; }
.tab:hover { color: var(--ink-soft); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }

.so-body { flex: 1; overflow-y: auto; padding: 22px 26px 26px; }
.so-panel[hidden] { display: none; }
.so-panel h3 { margin: 0; font-size: 15px; font-weight: 700; }
.so-panel .help { margin: 5px 0 0; font-size: 12.5px; line-height: 1.55; color: var(--faint); max-width: 52ch; }
.so-panel textarea {
  margin-top: 15px; width: 100%; min-height: 168px; resize: none; overflow: hidden;
  font-family: inherit; font-size: 14px; line-height: 1.7; color: var(--ink);
  background: var(--paper-sunken); border: 1px solid var(--line); border-radius: var(--radius-m);
  padding: 16px 18px; transition: all .2s ease;
}
.so-panel textarea:focus { outline: none; background: var(--paper-raised); border-color: var(--fjord); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fjord) 12%, transparent); }
.so-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; }
.autosave { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; }
.autosave .adot { width: 6px; height: 6px; border-radius: 50%; }
.autosave.saved { color: var(--sage-deep); }
.autosave.saved .adot { background: var(--sage); }
.autosave.saving { color: var(--sand); }
.autosave.saving .adot { background: var(--sand); }
.autosave.error { color: var(--sand); }
.autosave.error .adot { background: var(--sand); }
.charcount { font-size: 12px; color: var(--faint); }

.so-foot { padding: 15px 26px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--paper-sunken); }
.so-foot p { margin: 0; font-size: 12px; color: var(--faint); }
.btn-close-record { font-family: inherit; font-size: 13.5px; font-weight: 700; color: var(--paper); background: var(--ink); border: none; border-radius: var(--radius-s); padding: 10px 18px; cursor: pointer; transition: transform .2s ease; }
.btn-close-record:hover { transform: translateY(-1px); }

/* ================= ESTADO: licencia vencida / bloqueo ================= */
.session-screen { min-height: 100vh; background: var(--paper); display: grid; place-items: center; padding: 24px; }
.session-card { max-width: 420px; text-align: center; }
.session-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--sand-bg); color: var(--sand); display: grid; place-items: center; margin: 0 auto 22px; }
.session-card h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.session-card p { margin: 12px 0 0; font-size: 14px; line-height: 1.6; color: var(--muted); }
.session-btn {
  margin-top: 26px; display: inline-flex; align-items: center; gap: 8px;
  font-family: inherit; font-size: 14px; font-weight: 700; color: var(--paper); background: var(--ink);
  border: none; border-radius: var(--radius-s); padding: 12px 22px; cursor: pointer; text-decoration: none; transition: transform .2s ease;
}
.session-btn:hover { transform: translateY(-1px); }
.session-tenant-tag {
  display: inline-flex; align-items: center; gap: 7px; margin-bottom: 18px;
  font-size: 12px; font-weight: 700; color: var(--faint);
  background: var(--paper-sunken); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px 5px 10px;
}
.session-tenant-tag .sdot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
/* Confirmación del alta autogestionada: mismo card, acento verde en vez de arena. */
.session-icon.done { background: var(--sage-bg); color: var(--sage-deep); }
.done-note { margin-top: 18px !important; font-size: 12.5px !important; color: var(--faint) !important; }

/* ===== Alta autogestionada del paciente (página pública con el token) ===== */
.selfreg-screen { min-height: 100vh; background: var(--paper); display: flex; justify-content: center; padding: 48px 24px; }
.selfreg-card { width: 100%; max-width: 620px; }
.selfreg-card h1 { margin: 0; font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.selfreg-card .sub { margin: 8px 0 30px; font-size: 14.5px; line-height: 1.6; color: var(--muted); }
.selfreg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.selfreg-card .form-field { margin-bottom: 16px; }
.selfreg-grid .form-field { margin-bottom: 0; }
.selfreg-wide { margin-bottom: 16px; }
.selfreg-grid + .selfreg-wide { margin-top: 16px; }
.selfreg-guardian[hidden] { display: none; }
.selfreg-hint { margin: 0; font-size: 12px; color: var(--faint); }
.selfreg-card .btn-submit { width: 100%; margin-top: 8px; }
@media (max-width: 560px) { .selfreg-screen { padding: 28px 18px; } }

/* Modal "Invitar paciente": la fila del enlace generado + botón de copiar. */
.invite-intro { margin: 18px 0 0; font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.invite-link-row { display: flex; align-items: center; gap: 10px; background: var(--paper-sunken); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 11px 12px; margin-top: 16px; }
.invite-link-row .invite-url { flex: 1; min-width: 0; font-size: 12.5px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite-expiry { margin: 10px 0 0; font-size: 12px; color: var(--faint); }

/* ================= PÁGINAS DEL TERAPEUTA (lista / expediente / formularios) ================= */
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--faint); margin-bottom: 18px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }

/* Inputs de formulario nativos (PatientForm / FollowUpForm) */
.vintia-input, .vintia-textarea {
  width: 100%; font-family: inherit; font-size: 14px; color: var(--ink);
  background: var(--paper-sunken); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 10px 12px; transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.vintia-textarea { line-height: 1.6; resize: vertical; }
.vintia-input:focus, .vintia-textarea:focus {
  outline: none; background: var(--paper-raised); border-color: var(--fjord);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--fjord) 14%, transparent);
}
select.vintia-input { appearance: none; cursor: pointer; }

.exp-form { display: flex; flex-direction: column; gap: 18px; margin-top: 22px; max-width: 880px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .col-2 { grid-column: 1 / -1; }
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 12px; font-weight: 700; color: var(--muted); }
.field-err { margin: 2px 0 0; font-size: 12px; color: var(--sand); }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }

/* Cabecera del expediente */
.expediente-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.expediente-id { display: flex; align-items: center; gap: 14px; }
.expediente-id h1 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.expediente-meta { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.expediente-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.expediente-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 24px; align-items: start; }
.exp-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.exp-card { background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 20px 22px; }
.exp-card h2 { font-size: 15px; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.exp-card h3 { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 18px; }
.exp-count { font-size: 11.5px; font-weight: 700; color: var(--faint); background: var(--paper-sunken); border-radius: 999px; padding: 2px 9px; }
.exp-text { margin: 8px 0 0; font-size: 13.5px; line-height: 1.6; color: var(--ink-soft); }
.exp-empty { margin: 12px 0 0; font-size: 13px; color: var(--faint); }
.exp-dl { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; margin: 14px 0 0; }
.exp-dl dt { font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; }
.exp-dl dd { margin: 2px 0 0; font-size: 13.5px; color: var(--ink); }
.exp-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.exp-item:first-of-type { border-top: none; }
.exp-item-body { flex: 1; min-width: 0; }
.exp-item-title { margin: 0; font-size: 13.5px; font-weight: 700; }
.exp-item-sub { margin: 1px 0 0; font-size: 12px; color: var(--faint); }
.exp-note-hint { margin: 0 0 16px; font-size: 13px; line-height: 1.55; color: var(--muted); }

/* Línea de tiempo consolidada */
.timeline { list-style: none; margin: 14px 0 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 18px 24px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--paper-raised); background: var(--faint); }
.tl-note .tl-dot { background: var(--fjord); }
.tl-attend .tl-dot { background: var(--sage); }
.tl-title { margin: 0; font-size: 13.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.tl-when { margin: 1px 0 0; font-size: 11.5px; color: var(--faint); }
.tl-text { margin: 5px 0 0; font-size: 13px; line-height: 1.55; color: var(--ink-soft); }
.tl-badge { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.tl-badge.sage { background: var(--sage-bg); color: var(--sage-deep); }
.tl-badge.sand { background: var(--sand-bg); color: var(--sand); }

@media (max-width: 900px) { .expediente-grid { grid-template-columns: 1fr; } }

/* ================= EXPEDIENTE UNIFICADO EN PESTAÑAS ================= */
@keyframes expFadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.exp-tablist {
  margin-top: 22px; gap: 4px; border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.exp-tablist::-webkit-scrollbar { display: none; }
.exp-tablist .tab { white-space: nowrap; }
.tab[aria-disabled="true"] { color: var(--faint); opacity: .55; cursor: not-allowed; border-bottom-color: transparent; }
.tab[aria-disabled="true"]:hover { color: var(--faint); }
.tab-lock { vertical-align: -2px; color: var(--faint); }

.exp-tabpanels { margin-top: 22px; }
.exp-tabpanels .so-panel { animation: expFadeIn .18s ease both; }
.exp-tabpanels .so-panel > * + * { margin-top: 18px; }

/* Fieldset como contenedor de campos: sin estilo nativo de fieldset. */
.doc-fields { border: 0; margin: 0; padding: 0; min-width: 0; }
.doc-fields[disabled] { opacity: .8; }

/* Checkbox en línea (label + casilla) */
.form-check { flex-direction: row; align-items: center; gap: 9px; }
.form-check input[type="checkbox"] { order: -1; width: 16px; height: 16px; accent-color: var(--fjord); }
.form-check label { font-weight: 500; color: var(--ink-soft); }

/* Subida de pruebas embebida en la pestaña */
.upload-inline { margin-top: 6px; display: flex; flex-direction: column; gap: 12px; }

/* Confirmación de guardado por formulario (empuja los botones a la derecha) */
.doc-save-status { font-size: 12px; color: var(--sage-deep); margin-right: auto; }

/* Banner de documento finalizado (positivo, nunca alarma) */
.doc-finalized {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
  background: var(--sage-bg); border: 1px solid color-mix(in srgb, var(--sage) 30%, transparent);
  border-radius: var(--radius-m); padding: 13px 15px;
}
.doc-finalized > svg { color: var(--sage-deep); flex-shrink: 0; }
.df-title { margin: 0; font-size: 13.5px; font-weight: 700; color: var(--sage-deep); }
.df-sub { margin: 2px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.doc-finalized .btn { margin-left: auto; }

/* Estado vacío empático */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 6px; padding: 46px 24px; max-width: 46ch; margin: 8px auto;
}
.empty-state .es-icon {
  width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center;
  margin-bottom: 8px; background: var(--fjord-bg); color: var(--fjord-ink);
}
.empty-state.locked .es-icon { background: var(--sand-bg); color: var(--sand); }
.empty-state h3 { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 18px; letter-spacing: -.01em; color: var(--ink); }
.empty-state p { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.empty-state .btn { margin-top: 14px; }

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

/* ================= FASE 2: modal de notas, confirm, scroll-lock, logout ================= */
/* Bloqueo de scroll mientras hay un overlay abierto (se libera al cerrar el último). */
body.scroll-locked { overflow: hidden; }

/* Confirmación reutilizable (Vintia.confirm) */
.confirm-modal { max-width: 400px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.btn-danger { background: var(--sand); color: var(--paper); box-shadow: var(--shadow-soft); }
.btn-danger:hover { transform: translateY(-1px); box-shadow: 0 20px 40px -18px color-mix(in srgb, var(--sand) 55%, transparent); }

/* Modal de nota de evolución (ver / editar) */
.note-modal { max-width: 560px; }
.note-modal .modal-body { margin-top: 16px; display: flex; flex-direction: column; gap: 14px; }
.note-modal label { font-size: 12px; font-weight: 700; color: var(--muted); display: block; margin-bottom: 6px; }
.note-modal textarea {
  width: 100%; font-family: inherit; font-size: 14px; line-height: 1.6; color: var(--ink);
  background: var(--paper-sunken); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 12px 14px; resize: vertical;
}
.note-modal textarea:focus { outline: none; background: var(--paper-raised); border-color: var(--fjord); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fjord) 14%, transparent); }
.note-modal textarea:disabled { opacity: .85; cursor: default; -webkit-text-fill-color: var(--ink); }
.note-modal .note-meta { font-size: 12px; color: var(--faint); }
.note-modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Acciones (Ver/Editar) en cada item del timeline de seguimientos */
.tl-actions { display: flex; gap: 8px; margin-top: 8px; }

/* Logout en el pie del sidebar */
.logout-form { margin-left: auto; }
.logout-btn { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--faint); cursor: pointer; transition: color .2s ease, background .2s ease; }
.logout-btn:hover { color: var(--ink); background: var(--paper-sunken); }

/* ================= CONMUTADOR DE TEMA (claro/oscuro) ================= */
.sidebar-head-actions { display: flex; align-items: center; gap: 4px; }
.theme-toggle {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  border: 1px solid transparent; background: transparent; color: var(--faint);
  cursor: pointer; transition: color .2s ease, background .2s ease, transform .2s ease;
}
.theme-toggle:hover { color: var(--ink); background: var(--paper-sunken); transform: rotate(-12deg); }
.theme-toggle .ti-sun, .theme-toggle .ti-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .ti-sun { display: block; }
:root[data-theme="light"] .theme-toggle .ti-moon { display: block; }

/* Transición suave al ALTERNAR tema. El tema ya se fija antes del primer paint
   (script no-FOUC del <head>), así que esto no anima la carga; solo el toggle.
   prefers-reduced-motion (arriba) la neutraliza para quien lo pida. */
body, .sidebar, .main, .exp-card, .table-card, .kpi-card, .exp-tablist,
.modal, .slideover, .so-head, .so-body, .so-foot,
.overlay, .doc-finalized, .empty-state, .page-head, .crumbs, .status-badge, .tl-badge, .ant-card {
  transition: background-color .3s ease, border-color .3s ease, color .25s ease, box-shadow .3s ease;
}

/* ================= FICHA GENERAL EN DOS COLUMNAS (sin dead space) ================= */
/* Izquierda: formulario de identificación. Derecha: antecedentes autoguardados.
   Colapsa a 1 columna por debajo de 1024px. */
.general-grid { display: grid; grid-template-columns: 1fr; gap: 22px; align-items: start; }
@media (min-width: 1024px) {
  .general-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; }  /* respiro visual */
}
#panel-general .exp-form { max-width: none; }   /* la ficha ocupa el ancho; la rejilla parte en 2 columnas */
.general-grid > .exp-card { margin-top: 0; }

.general-right { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.general-right .col-head h2 { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.general-right .col-head .exp-note-hint { margin: 4px 0 0; }

/* Cada antecedente = tarjeta sutil (narrativa clínica), distinta de las tarjetas
   blancas de datos estructurados de la izquierda. */
.ant-card {
  background: var(--paper-sunken); border: 1px solid var(--line); border-radius: var(--radius-m);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.ant-card label { font-size: 12px; font-weight: 700; color: var(--muted); }
.ant-card textarea { width: 100%; min-height: 104px; resize: vertical; }   /* w-full + resize-y */
.exp-sign {
  margin-top: 4px; padding-top: 13px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--faint);
}

/* ================= RESPONSIVE: barra superior móvil + backdrop + teléfono ================= */
/* Ocultos en escritorio; el bloque @media(max-width:980px) los activa. */
@media (min-width: 981px) {
  .app-topbar, .sidebar-backdrop { display: none; }
}
.topbar-menu {
  display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0;
  background: var(--paper-sunken); border: 1px solid var(--line); border-radius: var(--radius-s);
  color: var(--ink-soft); cursor: pointer;
}
.topbar-menu:hover { color: var(--ink); }
.topbar-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; text-decoration: none; color: var(--ink); }
.topbar-brand svg { color: var(--sage); flex-shrink: 0; }

/* Teléfonos: menos padding lateral, modales y toasts pegados a los bordes con aire mínimo. */
@media (max-width: 560px) {
  .main { padding-left: 16px; padding-right: 16px; }
  .overlay { padding: 14px; }
  .page-head h1 { font-size: 21px; }
  .expediente-id h1 { font-size: 19px; }
  .toast-stack { left: 14px; right: 14px; bottom: 14px; max-width: none; }
  .expediente-actions { width: 100%; }
  .wrap { padding-left: 20px; padding-right: 20px; }   /* landing / login públicos */
  .hero { padding-left: 20px; padding-right: 20px; }
}

/* ================= ASISTENCIAS: tabla inline (formset) + calendario ================= */
.inline-scroll { overflow-x: auto; margin-top: 14px; -webkit-overflow-scrolling: touch; }
.inline-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 860px; }
.inline-table th { text-align: left; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 0 8px 8px; white-space: nowrap; }
.inline-table td { padding: 5px 6px; vertical-align: top; }
.inline-table .vintia-input, .inline-table .vintia-textarea { padding: 8px 10px; font-size: 13px; }
.inline-table textarea.vintia-textarea { min-height: 38px; }
.inline-table .cell-check, .inline-table .cell-del { text-align: center; vertical-align: middle; }
.inline-table input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--fjord); }
.sr-only-th { width: 34px; }

.attn-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.btn-add-row {
  display: inline-flex; align-items: center; gap: 6px; font-family: inherit; font-size: 13.5px; font-weight: 700;
  color: var(--sage-deep); background: var(--sage-bg); border: 1px dashed color-mix(in srgb, var(--sage) 45%, transparent);
  border-radius: var(--radius-s); padding: 9px 15px; cursor: pointer; transition: background .2s ease, border-color .2s ease;
}
.btn-add-row:hover { border-color: var(--sage); background: color-mix(in srgb, var(--sage-bg) 70%, var(--sage)); }

/* Calendario mensual vanilla */
.cal-head { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 14px; }
.cal-title { font-weight: 700; font-size: 15px; letter-spacing: -.01em; text-transform: capitalize; min-width: 11ch; text-align: center; }
.cal-nav { width: 32px; height: 32px; display: grid; place-items: center; font-size: 17px; line-height: 1; color: var(--ink-soft); background: var(--paper-sunken); border: 1px solid var(--line); border-radius: var(--radius-s); cursor: pointer; }
.cal-nav:hover { color: var(--ink); background: var(--paper-raised); }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 16px; }
.cal-weekdays span { text-align: center; font-size: 10.5px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 6px; }
.cal-cell { aspect-ratio: 1 / 1; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 5px 6px; display: flex; flex-direction: column; justify-content: space-between; min-width: 0; }
.cal-empty { border-color: transparent; background: none; }
.cal-num { font-size: 12px; color: var(--ink-soft); }
.cal-dots { display: flex; flex-wrap: wrap; gap: 3px; align-content: flex-end; }
.cal-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.cal-dot.att-yes { background: var(--sage); }
.cal-dot.att-no { background: var(--sand); }
.cal-dot.cita { background: var(--fjord); }
.cal-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 14px; font-size: 12px; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend .cal-dot { width: 9px; height: 9px; }
/* Muestra de leyenda: replica el borde acento del bloque */
.cal-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex-shrink: 0; background: var(--paper-sunken); border: 1px solid var(--line); border-left: 3px solid var(--fjord); }
.cal-swatch.att-yes { border-left-color: var(--sage); }
.cal-swatch.att-no  { border-left-color: var(--danger); }
.cal-swatch.cita    { border-left-color: var(--fjord); }

@media (max-width: 560px) {
  .cal-cell { padding: 3px; }
  .cal-num { font-size: 11px; }
  .cal-dot { width: 6px; height: 6px; }
}

/* ================= CALENDARIO GENERAL + CITAS + VERDE/ROJO ================= */
/* Verde/rojo del select de asistencia (formset) */
.att-yes { background: var(--sage-bg); border-color: color-mix(in srgb, var(--sage) 45%, transparent); color: var(--sage-deep); font-weight: 700; }
.att-no  { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); font-weight: 700; }
.cal-dot.att-no { background: var(--danger); }   /* falta = rojo (antes ámbar) */

/* Programar cita */
.cita-form { margin-top: 14px; }
.cita-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; align-items: end; }
.cita-submit { display: flex; align-items: end; }
.cita-submit .btn { width: 100%; justify-content: center; }
.overlap-banner { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; background: var(--sand-bg); border: 1px solid color-mix(in srgb, var(--sand) 35%, transparent); border-radius: var(--radius-m); padding: 12px 14px; color: var(--sand); }
.overlap-banner > svg { flex-shrink: 0; margin-top: 1px; }
.overlap-banner[hidden] { display: none; }
.ob-title { margin: 0; font-size: 13px; font-weight: 700; }
.ob-list { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; }
.ob-note { margin: 6px 0 0; font-size: 12px; opacity: .85; }
.cita-list-head { margin: 20px 0 8px; font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; gap: 8px; }
.cita-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cita-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; background: var(--paper-sunken); border: 1px solid var(--line); border-radius: var(--radius-s); font-size: 13px; }
.cita-when { font-weight: 700; }
.cita-dur { color: var(--faint); font-size: 12px; }
.cita-status { margin-left: auto; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--fjord-bg); color: var(--fjord-ink); }
.cita-status.s2 { background: var(--sage-bg); color: var(--sage-deep); }
.cita-status.s3 { background: var(--danger-bg); color: var(--danger); }
.cita-status.s4 { background: var(--sand-bg); color: var(--sand); }

/* Barra de herramientas del calendario general */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; flex-wrap: wrap; }
.cal-nav-group { display: flex; align-items: center; gap: 8px; }
.cal-range { font-weight: 700; font-size: 15px; letter-spacing: -.01em; text-transform: capitalize; margin-left: 6px; }
.seg-control { display: inline-flex; background: var(--paper-sunken); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg { font-family: inherit; font-size: 13px; font-weight: 700; color: var(--muted); background: none; border: none; border-radius: 999px; padding: 7px 16px; cursor: pointer; transition: color .18s ease, background .18s ease; }
.seg:hover { color: var(--ink); }
.seg[aria-selected="true"] { background: var(--ink); color: var(--paper); }

.cal-shell { margin-top: 18px; }

/* Mes: celdas altas que apilan bloques de cita */
.cal-grid.month .cal-cell { aspect-ratio: auto; min-height: 92px; justify-content: flex-start; gap: 2px; }
.cal-chips { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; max-height: 96px; overflow-y: auto; }

/* ===== Bloque de cita estilo MS Teams (mes + semana/día, ambos calendarios) ===== */
.cal-block {
  display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: left;
  font: inherit; font-size: 11.5px; line-height: 1.25; cursor: pointer; overflow: hidden;
  padding: 4px 8px; border: 1px solid var(--line); border-left: 3px solid var(--fjord);
  border-radius: 8px; background: var(--paper-sunken); color: var(--ink);
  transition: background .15s ease, box-shadow .15s ease;
}
.cal-block:hover { background: color-mix(in srgb, var(--paper-sunken) 82%, var(--fjord)); box-shadow: var(--shadow-soft); }
.cal-block .cb-time { font-weight: 700; }
.cal-block .cb-name { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-block.status-2 { border-left-color: var(--sage); }      /* atendida */
.cal-block.status-4 { border-left-color: var(--danger); }    /* no asistió */
.cal-block.att-yes  { border-left-color: var(--sage); }
.cal-block.att-no   { border-left-color: var(--danger); }

/* Semana / Día: rejilla horas × días */
.cal-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.time-grid { display: flex; min-width: 640px; margin-top: 8px; }
.time-grid.day { min-width: 320px; }
.tg-hourcol { flex: 0 0 56px; }
.tg-hourhead { height: 34px; }
.tg-hours { position: relative; }
.tg-hour { display: flex; align-items: flex-start; justify-content: flex-end; padding-right: 8px; }
.tg-hour span { font-size: 10.5px; color: var(--faint); transform: translateY(-6px); }
.tg-cols { display: flex; flex: 1; min-width: 0; }
.tg-day { flex: 1; min-width: 90px; border-left: 1px solid var(--line); }
.tg-colhead-wrap { height: 34px; display: flex; align-items: center; justify-content: center; }
.tg-colhead { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.tg-body { position: relative; }
.tg-line { border-top: 1px solid var(--line); }
/* Bloque posicionado en la franja horaria (semana/día): mismo look Teams */
.cal-block.abs { position: absolute; left: 3px; right: 3px; box-shadow: var(--shadow-soft); }

/* ===== Popover de detalle de la cita ===== */
.ev-modal { max-width: 380px; }
.ev-details { margin: 16px 0 0; }
.ev-row { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.ev-row:first-child { border-top: none; }
.ev-row dt { margin: 0; color: var(--muted); font-weight: 600; }
.ev-row dd { margin: 0; color: var(--ink); font-weight: 600; text-align: right; }
.ev-actions { margin-top: 18px; }
.ev-actions .btn { width: 100%; justify-content: center; }
/* Popover con acciones de gestión (solo el Calendario General, que sí trae id de
   cita): apila los botones, que son width:100%. La clase la añade
   calendar-common.js únicamente cuando hay acciones extra, así el popover del
   expediente nunca la ve. */
.ev-actions.ev-actions-stack { display: flex; flex-direction: column; gap: 8px; }
/* Modal de agendar/reprogramar: separa la rejilla de campos de la ficha del
   paciente (en el expediente ese espacio lo da .cita-form). */
#newCitaForm .cita-fields { margin-top: 18px; }

@media (max-width: 560px) { .cal-toolbar { gap: 10px; } .cal-range { font-size: 14px; } }

/* ================= MARCA VINTIA (logos claro/oscuro) ================= */
.brand-logo { height: 40px; width: auto; display: block; }
.sidebar-brand { min-width: 0; }
.sidebar-brand .brand-logo { max-width: 158px; }
/* Conmutación por tema: el script no-FOUC fija data-theme antes del paint. */
.brand-dark { display: none; }
:root[data-theme="dark"] .brand-light { display: none; }
:root[data-theme="dark"] .brand-dark  { display: block; }
.topbar-isotype { height: 26px; width: auto; display: block; flex-shrink: 0; }
.brand-mark { height: 26px; width: auto; flex-shrink: 0; }


/* ================= TABLAS EN MÓVIL: vista de tarjetas (.table-cards) ================= */
@media (max-width: 640px) {
  .table-head { padding: 16px; }
  .table-head > div:first-child { min-width: 0; flex: 1 1 100%; }
  .search-shell { flex: 1 1 100%; }
  .search-shell input { width: 100%; }

  .table-cards { min-width: 0; font-size: 13.5px; }
  .table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }  /* visible solo para lectores de pantalla */
  .table-cards, .table-cards tbody { display: block; }
  .table-cards tbody tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
    column-gap: 12px; row-gap: 10px; padding: 14px 16px;
  }
  .table-cards tbody td { display: block; padding: 0; min-width: 0; }
  .table-cards td.cell-name-td { grid-column: 1; grid-row: 1; }
  .table-cards td.cell-status-td { grid-column: 2; grid-row: 1; justify-self: end; }
  .table-cards td.cell-folio { grid-column: 1; grid-row: 2; }
  .table-cards td.cell-visit { grid-column: 2; grid-row: 2; justify-self: end; text-align: right; }
  .table-cards td.cell-actions-td { grid-column: 1 / -1; grid-row: 3; padding-top: 10px; border-top: 1px dashed var(--line); }
  .table-cards .row-actions { flex-wrap: wrap; }
  .table-cards td[data-label]::before {
    content: attr(data-label) ": "; font-size: 11.5px; font-weight: 600; color: var(--faint);
  }
  .table-cards .cell-name { min-width: 0; }
  .table-cards .cell-name-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .table-cards td[colspan] { grid-column: 1 / -1; grid-row: auto; }
  .table-cards td[colspan]::before { content: none; }
}
