/* Paleta SilSalud: violeta y rosa del logo, neutros con leve tinte violeta */
:root {
  --bg: #faf7fb; --surface: #ffffff; --surface-2: #f7f2f8; --border: #ebe2ee; --text: #2b2230; --muted: #6e6276;
  --primary: #7e5a96; --primary-2: #664479; --primary-soft: #f1e9f5; --on-primary: #ffffff;
  --accent: #d9738f; --accent-2: #c25a78; --accent-soft: #fcecf1;
  --danger: #b42318; --danger-soft: #fdecea; --warn: #b54708; --warn-soft: #fef3e2;
  --ok: #067647; --ok-soft: #e7f6ee; --info: #664479; --info-soft: #f1e9f5;
  --radius: 10px; --shadow: 0 1px 2px rgba(43,34,48,.05), 0 1px 3px rgba(43,34,48,.07);
  --logo-filter: none;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151118; --surface: #1d1822; --surface-2: #241e2a; --border: #352c3d; --text: #f2ecf5; --muted: #a797b0;
    --primary: #b894d2; --primary-2: #cfb2e4; --primary-soft: #33263f; --on-primary: #1d1822;
    --accent: #f08fab; --accent-2: #f5a9bf; --accent-soft: #3c2230;
    --danger: #f97066; --danger-soft: #3a1a18; --warn: #fdb022; --warn-soft: #3a2a10;
    --ok: #47cd89; --ok-soft: #0f3222; --info: #cfb2e4; --info-soft: #2c2238;
    --logo-filter: brightness(1.3) saturate(1.1);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151118; --surface: #1d1822; --surface-2: #241e2a; --border: #352c3d; --text: #f2ecf5; --muted: #a797b0;
  --primary: #b894d2; --primary-2: #cfb2e4; --primary-soft: #33263f; --on-primary: #1d1822;
  --accent: #f08fab; --accent-2: #f5a9bf; --accent-soft: #3c2230;
  --danger: #f97066; --danger-soft: #3a1a18; --warn: #fdb022; --warn-soft: #3a2a10;
  --ok: #47cd89; --ok-soft: #0f3222; --info: #cfb2e4; --info-soft: #2c2238;
  --logo-filter: brightness(1.3) saturate(1.1);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* Layout */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 10px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { font-weight: 700; font-size: 16px; padding: 4px 10px 16px; display: flex; gap: 8px; align-items: center; }
.brand .dot { width: 26px; height: 26px; border-radius: 7px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-size: 15px; }
.logo { display: block; filter: var(--logo-filter); }
.brand .logo { height: 36px; width: auto; }
.topbar .logo { height: 28px; width: auto; }
.logo-auth { width: 200px; max-width: 70%; height: auto; margin: 0 auto 18px; }
.pub header .logo { height: 46px; width: auto; }
.nav a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; margin-bottom: 2px; }
.nav a:hover { background: var(--accent-soft); }
.nav a.active { background: var(--primary-soft); color: var(--primary-2); font-weight: 600; }
.userbox { margin-top: auto; padding: 10px; border-top: 1px solid var(--border); font-size: 13px; }
.main { padding: 24px 28px; min-width: 0; }
.topbar { display: none; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; left: 0; top: 0; width: 240px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 30px rgba(0,0,0,.25); }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
  .main { padding: 16px; }
}

/* Components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 700px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; min-width: 0; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
label.chk { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }

.btn { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }

table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.t th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.badge.reservado { background: var(--accent-soft); color: var(--accent-2); }
.badge.confirmado { background: var(--primary-soft); color: var(--primary-2); }
.badge.atendido, .badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.ausente { background: var(--warn-soft); color: var(--warn); }
.badge.cancelado, .badge.pendiente { background: var(--danger-soft); color: var(--danger); }
.badge.pagada { background: var(--ok-soft); color: var(--ok); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; color: var(--muted); }

/* Bar chart */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bars .b .col { width: 100%; max-width: 44px; background: linear-gradient(180deg, var(--accent), var(--primary)); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .b .x { font-size: 11px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.bars .b .y { font-size: 10px; color: var(--muted); margin-bottom: 2px; white-space: nowrap; }

/* Agenda */
.agendas { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.agcol { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.agcol .hd { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; font-weight: 600; }
.agcol .hd .sw { width: 10px; height: 10px; border-radius: 50%; }
.slot { display: grid; grid-template-columns: 56px 1fr; border-bottom: 1px solid var(--border); min-height: 44px; }
.slot:last-child { border-bottom: 0; }
.slot .h { padding: 10px; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; border-right: 1px solid var(--border); }
.slot .c { padding: 6px 8px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.slot.libre .c { color: var(--muted); }
.slot.off { background: repeating-linear-gradient(135deg, var(--surface-2), var(--surface-2) 6px, var(--surface) 6px, var(--surface) 12px); }
.slot.off .c { color: var(--muted); font-size: 12px; }
.turno { flex: 1; min-width: 0; border-left: 3px solid var(--primary); background: var(--surface-2); padding: 4px 8px; border-radius: 6px; cursor: pointer; }
.turno:hover { filter: brightness(.97); }
.turno .n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.turno .s { font-size: 12px; color: var(--muted); }
.slot.edit { cursor: pointer; }
.slot.edit:hover .c { text-decoration: underline; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 16px; }
.week .d { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; cursor: pointer; text-align: center; }
.week .d.sel { border-color: var(--primary); background: var(--primary-soft); }
.week .d .w { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.week .d .n { font-weight: 700; font-size: 16px; }
.week .d .o { font-size: 11px; color: var(--muted); }
.meter { height: 4px; border-radius: 2px; background: var(--border); margin-top: 4px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--primary); }

/* Evoluciones */
.evo { border-left: 3px solid var(--primary); padding: 8px 12px; margin-bottom: 12px; background: var(--surface-2); border-radius: 0 8px 8px 0; }
.evo.aclara { border-left-color: var(--warn); margin-left: 24px; }
.evo .meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.evo dl { margin: 0; display: grid; grid-template-columns: 110px 1fr; gap: 2px 10px; }
.evo dt { color: var(--muted); font-size: 12px; }
.evo dd { margin: 0; white-space: pre-wrap; }

/* Modal & toast */
.overlay { position: fixed; inset: 0; background: rgba(15, 20, 25, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 12px; width: min(620px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal .mh { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal .mh h2 { margin: 0; }
.modal .mb { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal .mf { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 60; box-shadow: var(--shadow); max-width: 90vw; }
.toast.err { background: var(--danger); color: var(--surface); }
.alert { padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.list-pick { max-height: 220px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.list-pick div { padding: 8px 10px; border-bottom: 1px solid var(--border); cursor: pointer; }
.list-pick div:hover, .list-pick div.sel { background: var(--primary-soft); }

/* Auth / público */
.center { min-height: 100vh; display: grid; place-items: center; align-content: center; padding: 16px; }
.authbox { width: min(420px, 100%); }
.pub { max-width: 760px; margin: 0 auto; padding: 24px 16px 60px; }
.pub header { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); background: var(--surface); padding: 6px 10px; border-radius: 8px; cursor: pointer; font: inherit; color: var(--text); font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--primary); }
.chip.sel { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.chip:hover { background: var(--accent-soft); }
.day { padding: 12px 0; border-bottom: 1px solid var(--border); }
.day:last-child { border-bottom: 0; }
.day .dt { font-weight: 600; margin-bottom: 8px; }
.pick-medico { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.pick-medico button { text-align: left; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; cursor: pointer; }
.pick-medico button:hover, .pick-medico button.sel { border-color: var(--primary); background: var(--primary-soft); }

/* WhatsApp */
:root { --wa: #1f9e55; --wa-2: #178a49; }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn.wa:hover { background: var(--wa-2); }
.wa-float { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 40; display: inline-flex; align-items: center; gap: 8px;
  background: var(--wa); color: #fff; text-decoration: none; font-weight: 600; padding: 12px 16px 12px 14px; border-radius: 999px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.wa-float:hover { background: var(--wa-2); }
.wa-float:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
@media (max-width: 480px) { .wa-float span { display: none; } .wa-float { padding: 14px; } }
.contacto-pub { margin: 20px 0 80px; padding: 14px 16px; border-top: 1px solid var(--border); display: grid; gap: 4px; font-size: 13px; }
.contacto-pub .contacto-titulo { font-weight: 600; color: var(--primary-2); margin-bottom: 4px; }

@media print {
  .sidebar, .topbar, .noprint, .btn { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; }
  .card { box-shadow: none; border: 0; }
  body { background: #fff; color: #000; }
}

/* Llamar pacientes */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
tr.apagado td { opacity: .55; }
.t.llamador select { min-width: 150px; }
.llamar-box { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); flex-wrap: wrap; }
.linkbox { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); word-break: break-all; flex: 1; min-width: 220px; }

/* ---------------------------------------------------------------- Pantalla de la sala de espera */
.body-pantalla { background: #f6f1f8; overflow: hidden; }
.pantalla {
  --pt-violeta: #7e5a96; --pt-violeta-2: #5d3f73; --pt-rosa: #d9738f; --pt-tinta: #2c2233; --pt-gris: #6f6476;
  min-height: 100vh; display: flex; flex-direction: column; gap: 2.2vh; padding: 3vh 3vw;
  background: radial-gradient(circle at 85% 0%, #fbe9ef 0, transparent 45%), #f6f1f8; color: var(--pt-tinta);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; position: relative; box-sizing: border-box;
}
.pantalla.sin-puntero, .pantalla.sin-puntero * { cursor: none; }
.pt-head { display: flex; align-items: center; justify-content: space-between; gap: 2vw; }
.pt-logo { height: clamp(44px, 8vh, 110px); width: auto; }
.pt-hora { text-align: right; }
.pt-reloj { font-size: clamp(34px, 6vh, 84px); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; color: var(--pt-violeta-2); }
.pt-fecha { font-size: clamp(14px, 2.2vh, 28px); color: var(--pt-gris); margin-top: .4vh; }
.pt-cuerpo { flex: 1; display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 2.2vw; min-height: 0; }
.pt-principal {
  border-radius: 28px; padding: 5vh 3.5vw; color: #fff; display: flex; flex-direction: column; justify-content: center; gap: 2.2vh;
  background: linear-gradient(140deg, var(--pt-violeta) 0%, var(--pt-violeta-2) 100%);
  box-shadow: 0 20px 50px -20px rgba(93, 63, 115, .55); min-width: 0;
}
.pt-principal.nuevo { animation: pt-llamado 1.1s ease-in-out 4; }
@keyframes pt-llamado {
  0%, 100% { box-shadow: 0 20px 50px -20px rgba(93, 63, 115, .55), 0 0 0 0 rgba(217, 115, 143, 0); transform: scale(1); }
  50% { box-shadow: 0 20px 60px -15px rgba(93, 63, 115, .7), 0 0 0 14px rgba(217, 115, 143, .55); transform: scale(1.012); }
}
.pt-etq { font-size: clamp(18px, 3.4vh, 44px); text-transform: uppercase; letter-spacing: .14em; font-weight: 600; opacity: .85; }
.pt-nombre { font-size: clamp(40px, 11vh, 150px); font-weight: 800; line-height: 1.04; letter-spacing: -.01em; overflow-wrap: anywhere; }
.pt-destino { display: flex; align-items: center; gap: 1.4vw; flex-wrap: wrap; }
.pt-flecha { font-size: clamp(32px, 8vh, 110px); font-weight: 700; line-height: 1; }
.pt-cons {
  font-size: clamp(32px, 8.5vh, 120px); font-weight: 800; line-height: 1.05; background: var(--pt-rosa); color: #fff;
  padding: .12em .45em; border-radius: .28em; box-shadow: 0 10px 25px -10px rgba(0, 0, 0, .35);
}
.pt-sub { font-size: clamp(18px, 3.6vh, 48px); opacity: .9; }
.pt-principal.vacio { background: linear-gradient(140deg, #8d6aa5 0%, var(--pt-violeta) 100%); }
.pt-principal.vacio .pt-nombre { font-size: clamp(40px, 10vh, 130px); }
.pt-lado { background: #fff; border-radius: 28px; padding: 3.5vh 2vw; display: flex; flex-direction: column; min-height: 0; overflow: hidden; box-shadow: 0 12px 35px -22px rgba(44, 34, 51, .45); }
.pt-lado h2 { margin: 0 0 1.6vh; font-size: clamp(16px, 2.8vh, 36px); text-transform: uppercase; letter-spacing: .12em; color: var(--pt-gris); font-weight: 700; }
.pt-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.pt-lista li { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "n h" "c h"; column-gap: 1vw; padding: 1.7vh 0; border-bottom: 1px solid #ece3f0; }
.pt-lista li:last-child { border-bottom: 0; }
.pt-l-nombre { grid-area: n; font-size: clamp(18px, 3.4vh, 44px); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-l-cons { grid-area: c; font-size: clamp(15px, 2.7vh, 34px); color: var(--pt-violeta); font-weight: 600; }
.pt-l-hora { grid-area: h; align-self: center; font-size: clamp(15px, 2.6vh, 32px); color: var(--pt-gris); font-variant-numeric: tabular-nums; }
.pt-lista li.pt-l-vacio { display: block; color: var(--pt-gris); font-size: clamp(15px, 2.6vh, 30px); border: 0; }
.pt-pie { display: flex; justify-content: space-between; gap: 2vw; font-size: clamp(13px, 2.1vh, 26px); color: var(--pt-gris); }
.pt-estado.error { color: #b3261e; font-weight: 600; }
.pt-aviso {
  position: absolute; left: 50%; bottom: 7vh; transform: translateX(-50%); font: inherit; font-size: clamp(14px, 2.3vh, 26px); font-weight: 600;
  background: var(--pt-tinta); color: #fff; border: 0; border-radius: 999px; padding: .8em 1.6em; cursor: pointer; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .5);
}
.pt-aviso[hidden] { display: none; }
@media (max-width: 760px), (orientation: portrait) {
  .body-pantalla { overflow: auto; }
  .pt-cuerpo { grid-template-columns: 1fr; }
  .pt-nombre { font-size: clamp(34px, 9vw, 90px); }
  .pt-cons, .pt-flecha { font-size: clamp(28px, 8vw, 80px); }
  .pt-pie { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) { .pt-principal.nuevo { animation: none; outline: 6px solid #d9738f; } }
a.btn { text-decoration: none; }

/* Historia compartida por derivación */
.card.compartida { border-left: 4px solid var(--accent, #d9738f); }
details.comp { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-top: 10px; background: var(--surface-2); }
details.comp > summary { cursor: pointer; list-style-position: outside; padding: 2px 0; }
details.comp .comp-body { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
details.comp h3 { margin: 10px 0 4px; }
@media print { details.comp { break-inside: avoid; } details.comp:not([open]) { display: none; } }
details.comp .comp-body > dl { margin: 0; display: grid; grid-template-columns: 170px 1fr; gap: 4px 10px; }
details.comp .comp-body > dl dt { color: var(--muted); font-size: 12px; }
details.comp .comp-body > dl dd { margin: 0; }
details.comp .evo { background: var(--surface); }

/* ---------------------------------------------------------------- Recetas y documentos imprimibles */
.doc { background: #fff; color: #222; width: 100%; max-width: 640px; margin: 0 auto; padding: 28px 32px; box-sizing: border-box; border: 1px solid #e5dcea; border-radius: 10px; font-size: 14px; line-height: 1.45; display: flex; flex-direction: column; gap: 14px; min-height: 760px; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-bottom: 2px solid #7e5a96; padding-bottom: 12px; }
.doc-logo { height: 46px; width: auto; }
.doc-cons { text-align: right; font-size: 12px; color: #555; }
.doc-tipo { font-size: 20px; font-weight: 700; color: #5d3f73; text-transform: uppercase; letter-spacing: .06em; }
.doc-pac { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; padding: 10px 12px; background: #f7f2f9; border-radius: 8px; font-size: 13px; }
.doc-pac span, .doc-dx span { color: #6f6476; }
.doc-cuerpo { flex: 1; }
.doc-rp { font-size: 22px; font-weight: 700; font-style: italic; color: #5d3f73; margin-bottom: 6px; }
.doc-cuerpo ol { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; font-size: 15px; }
.doc-texto { white-space: pre-wrap; font-size: 15px; }
.doc-dx { margin-top: 18px; font-size: 13px; }
.doc-firma { align-self: flex-end; text-align: center; min-width: 220px; font-size: 13px; margin-top: 30px; }
.doc-linea { border-top: 1px solid #333; margin-bottom: 6px; }
.doc-pie { font-size: 11px; color: #8a8090; text-align: center; border-top: 1px solid #eee; padding-top: 6px; }
.doc-pagina { padding: 16px; }
.doc-acciones { max-width: 640px; margin: 0 auto 12px; display: flex; justify-content: flex-end; }
.body-doc { background: #f3eef6; }
#print-area { display: none; }
@media print {
  body.imprimiendo > *:not(#print-area) { display: none !important; }
  body.imprimiendo #print-area { display: block !important; }
  body.imprimiendo { background: #fff !important; }
  #print-area .doc, #print-area .resumen { border: 0; max-width: none; min-height: 0; padding: 0; }
  #print-area .doc { min-height: 95vh; }
  .body-doc .noprint { display: none !important; }
  body.body-doc { background: #fff !important; }
  .body-doc .doc-pagina { padding: 0; }
  .body-doc .doc, #print-area .doc { border: 0; border-radius: 0; max-width: none; padding: 0; min-height: 255mm; }
  @page { margin: 14mm; }
}
@media (max-width: 560px) { .doc { padding: 18px; } .doc-pac { grid-template-columns: 1fr; } }

/* Campos estructurados de la evolución */
.campos-evo { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 12px; background: var(--surface-2); border-radius: 10px; }
.campo-evo input { width: 100%; }
.chips-evo { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 8px; }
.chip-evo { font-size: 12.5px; padding: 2px 9px; border-radius: 999px; background: var(--primary-soft, #efe7f4); color: var(--text); }
.doc-preview { background: var(--surface-2); padding: 12px; border-radius: 10px; max-height: 60vh; overflow: auto; }
.doc-preview .doc { min-height: 0; }
.badge.sala { background: var(--info-soft); color: var(--info); margin-left: 4px; }
.badge.sala.demora { background: var(--warn-soft); color: var(--warn); }
.campos-config { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px dashed var(--border); border-radius: 10px; }
.chks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 12px; }
details.restaurar { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
details.restaurar > summary { cursor: pointer; }

/* ---------------------------------------------------------------- Estadísticas (gráficos simples en HTML) */
:root { --serie-1: #7b4fa0; --serie-2: #d9738f; --pista: #f1ebf4; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --serie-1: #a07ed4; --serie-2: #c4506f; --pista: #2a2330; } }
:root[data-theme="dark"] { --serie-1: #a07ed4; --serie-2: #c4506f; --pista: #2a2330; }
.grid-est { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.grid-est .card { margin-bottom: 0; }
.barras-h { display: flex; flex-direction: column; gap: 8px; }
.bh-fila { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.bh-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.bh-pista { height: 12px; background: var(--pista); border-radius: 4px; overflow: hidden; }
.bh-barra { display: block; height: 100%; background: var(--serie-1); border-radius: 0 4px 4px 0; }
.bh-fila:hover .bh-barra { filter: brightness(1.12); }
.bh-v { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.leyenda { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.leyenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.leyenda i.s1, .seg.s1 { background: var(--serie-1); }
.leyenda i.s2, .seg.s2 { background: var(--serie-2); }
.cols { display: flex; align-items: flex-end; gap: 8px; height: 190px; padding-top: 18px; border-bottom: 1px solid var(--border); }
.col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.col-pila { width: min(42px, 100%); display: flex; flex-direction: column; gap: 2px; min-height: 2px; }
.col-pila .seg { display: block; min-height: 2px; }
.col-pila .seg:first-child { border-radius: 4px 4px 0 0; }
.col-v { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; margin-bottom: 3px; }
.col-l { position: absolute; bottom: -20px; font-size: 11.5px; color: var(--muted); }
.col:hover .seg { filter: brightness(1.12); }
.tabla-datos { margin-top: 30px; font-size: 13px; }
.tabla-datos > summary { cursor: pointer; color: var(--muted); }
.seg-ctrl { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-ctrl button { font: inherit; font-size: 13px; background: var(--surface); color: var(--text); border: 0; padding: 6px 10px; cursor: pointer; }
.seg-ctrl button + button { border-left: 1px solid var(--border); }
.seg-ctrl button.on { background: var(--primary); color: var(--on-primary); }
.resumen h3 { margin: 6px 0 0; font-size: 14px; color: #5d3f73; }
.resumen-t { width: 100%; font-size: 13px; }
.resumen-t td, .resumen-t th { padding: 5px 8px; color: #222; }
.resumen-t.detalle { font-size: 12px; }
.doc.resumen { min-height: 0; }

/* Logo visible en ambos temas y espacio antes del menú. */
.sidebar .brand{min-height:144px;padding:12px;margin:0 0 10px;background:#fff;border-radius:12px;justify-content:center;flex-shrink:0;box-sizing:border-box}
.sidebar .brand .logo{height:116px;width:100%;max-width:100%;object-fit:contain;filter:none}
.topbar .logo{height:54px;max-width:230px;object-fit:contain;background:#fff;padding:6px;border-radius:8px;filter:none}
.logo-auth{width:300px;max-width:85%;background:#fff;padding:16px;border-radius:12px;box-sizing:border-box;filter:none}

/* Logo ampliado y fondo lavanda acorde con SilSalud. */
.sidebar .brand{height:144px;min-height:144px;padding:4px;align-items:center;justify-content:center;background:#eee3f4;border:1px solid #d8c6e4;overflow:hidden}
.sidebar .brand .logo{height:100%;width:100%;max-height:100%;max-width:100%;object-fit:contain;filter:none}
