/* ============================================================
   KAISER CLINICAL — Sistema de diseño "Molécula"
   Paleta derivada del logotipo: tinta profunda + azul cielo
   ============================================================ */
:root{
  --ink:        #0E1630;   /* azul tinta del logotipo */
  --ink-soft:   #22304F;
  --sky:        #8FD9EE;   /* punto celeste del logotipo */
  --sky-deep:   #4FB8D8;
  --ice:        #EAF6FA;
  --cloud:      #F5F8FB;
  --white:      #FFFFFF;
  --text:       #1C2740;
  --muted:      #67748F;
  --line:       #E3EAF2;
  --ok:         #23A57C;
  --warn:       #E9A23B;
  --danger:     #DF5570;
  --r-lg: 22px; --r-md: 14px; --r-sm: 9px;
  --shadow: 0 8px 28px rgba(14,22,48,.08);
  --shadow-lift: 0 16px 44px rgba(14,22,48,.14);
  --font-d: 'Sora', system-ui, sans-serif;
  --font-b: 'Inter', system-ui, sans-serif;
}
*{ box-sizing:border-box; margin:0; padding:0; -webkit-tap-highlight-color:transparent; }
html{ scroll-behavior:smooth; }
body{
  font-family:var(--font-b); color:var(--text); background:var(--cloud);
  font-size:15.5px; line-height:1.55; min-height:100dvh;
  -webkit-font-smoothing:antialiased;
}
h1,h2,h3,.display{ font-family:var(--font-d); color:var(--ink); letter-spacing:-.015em; }
a{ color:var(--sky-deep); text-decoration:none; }
img{ max-width:100%; }
button{ font-family:inherit; }
:focus-visible{ outline:3px solid var(--sky); outline-offset:2px; border-radius:6px; }

/* Etiqueta "eyebrow" al estilo C L I N I C A L */
.eyebrow{
  font-family:var(--font-d); font-size:.68rem; font-weight:600;
  letter-spacing:.42em; text-transform:uppercase; color:var(--sky-deep);
}

/* ===== Fondo de puntos (motivo molécula) ===== */
.dotfield{
  background-image:radial-gradient(circle, rgba(143,217,238,.35) 1.5px, transparent 1.6px);
  background-size:26px 26px;
}

/* ============================================================
   LAYOUT — barra lateral en escritorio, barra inferior en móvil
   ============================================================ */
.app{ display:flex; min-height:100dvh; }
.sidebar{
  width:236px; background:var(--ink); color:#fff; padding:26px 18px;
  display:flex; flex-direction:column; gap:6px; position:sticky; top:0; height:100dvh;
}
.sidebar .brand{ display:flex; align-items:center; gap:10px; margin-bottom:26px; padding:0 8px; }
.sidebar .brand img{ height:34px; background:#fff; border-radius:10px; padding:5px 8px; }
.sidebar .brand span{ font-family:var(--font-d); font-weight:700; font-size:.95rem; letter-spacing:.02em; }
.nav-link{
  display:flex; align-items:center; gap:12px; color:#C6D2E6; padding:12px 14px;
  border-radius:var(--r-sm); font-weight:500; font-size:.93rem; transition:.18s;
}
.nav-link svg{ width:20px; height:20px; flex:none; }
.nav-link:hover{ background:rgba(143,217,238,.12); color:#fff; }
.nav-link.active{ background:var(--sky); color:var(--ink); font-weight:600; }
.sidebar .spacer{ flex:1; }
.userchip{ display:flex; gap:10px; align-items:center; padding:12px 10px; border-top:1px solid rgba(255,255,255,.12); }
.userchip .avatar{
  width:38px; height:38px; border-radius:50%; background:var(--sky); color:var(--ink);
  display:grid; place-items:center; font-family:var(--font-d); font-weight:700;
}
.userchip small{ display:block; color:#93A3BE; text-transform:capitalize; }
.userchip b{ font-size:.86rem; }

.main{ flex:1; padding:30px clamp(16px, 4vw, 44px) 110px; max-width:1120px; }

/* Barra inferior (móvil / iPad vertical) */
.tabbar{ display:none; }
@media (max-width: 900px){
  .sidebar{ display:none; }
  .main{ padding-top:18px; }
  .tabbar{
    position:fixed; bottom:0; left:0; right:0; z-index:60;
    display:flex; justify-content:space-around; background:var(--ink);
    padding:10px 6px calc(10px + env(safe-area-inset-bottom));
    border-radius:22px 22px 0 0; box-shadow:0 -8px 30px rgba(14,22,48,.25);
  }
  .tabbar a{ color:#C6D2E6; display:flex; flex-direction:column; align-items:center; gap:3px; font-size:.66rem; font-weight:600; }
  .tabbar a svg{ width:23px; height:23px; }
  .tabbar a.active{ color:var(--sky); }
}

/* ============================================================
   COMPONENTES
   ============================================================ */
.topbar{ display:flex; justify-content:space-between; align-items:center; gap:14px; margin-bottom:26px; flex-wrap:wrap; }
.topbar h1{ font-size:clamp(1.35rem, 3vw, 1.8rem); }

.card{ background:var(--white); border:1px solid var(--line); border-radius:var(--r-lg); box-shadow:var(--shadow); padding:22px; }
.grid{ display:grid; gap:16px; }
.grid.cols-3{ grid-template-columns:repeat(3, 1fr); }
@media (max-width:760px){ .grid.cols-3{ grid-template-columns:1fr; } }

.stat{ display:flex; flex-direction:column; gap:2px; }
.stat b{ font-family:var(--font-d); font-size:2rem; color:var(--ink); }
.stat span{ color:var(--muted); font-size:.85rem; }
.stat .dot{ width:10px; height:10px; border-radius:50%; background:var(--sky); margin-bottom:8px; }

.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  background:var(--ink); color:#fff; border:none; border-radius:999px;
  padding:13px 24px; font-weight:600; font-size:.94rem; cursor:pointer;
  transition:.2s; box-shadow:0 6px 18px rgba(14,22,48,.18);
}
.btn:hover{ background:var(--ink-soft); transform:translateY(-1px); }
.btn:active{ transform:translateY(0); }
.btn.sky{ background:var(--sky); color:var(--ink); box-shadow:0 6px 18px rgba(79,184,216,.35); }
.btn.sky:hover{ background:var(--sky-deep); color:#fff; }
.btn.ghost{ background:transparent; color:var(--ink); border:1.5px solid var(--line); box-shadow:none; }
.btn.ghost:hover{ border-color:var(--sky-deep); color:var(--sky-deep); background:var(--ice); }
.btn.sm{ padding:9px 16px; font-size:.85rem; }
.btn:disabled{ opacity:.5; cursor:not-allowed; transform:none; }

.field{ margin-bottom:16px; }
.field label{ display:block; font-weight:600; font-size:.86rem; margin-bottom:7px; color:var(--ink); }
.input, textarea.input, select.input{
  width:100%; border:1.5px solid var(--line); border-radius:var(--r-md);
  padding:13px 15px; font:inherit; background:#fff; color:var(--text); transition:.18s;
  appearance:none; -webkit-appearance:none;
}
.input:focus{ border-color:var(--sky-deep); box-shadow:0 0 0 4px rgba(143,217,238,.28); outline:none; }
textarea.input{ min-height:110px; resize:vertical; }

.badge{ display:inline-flex; align-items:center; gap:6px; background:var(--ice); color:var(--sky-deep);
  border-radius:999px; padding:4px 12px; font-size:.74rem; font-weight:700; letter-spacing:.03em; }
.badge.ink{ background:var(--ink); color:var(--sky); }
.badge.ok{ background:#E4F6EF; color:var(--ok); }
.badge.warn{ background:#FBF1DF; color:#B47B1E; }

/* Lista de pacientes */
.plist{ display:flex; flex-direction:column; gap:10px; }
.prow{
  display:flex; align-items:center; gap:14px; background:#fff; border:1px solid var(--line);
  border-radius:var(--r-md); padding:14px 16px; transition:.18s; cursor:pointer;
}
.prow:hover{ border-color:var(--sky); box-shadow:var(--shadow); transform:translateY(-1px); }
.prow .avatar{
  width:44px; height:44px; border-radius:14px; background:var(--ice); color:var(--sky-deep);
  display:grid; place-items:center; font-family:var(--font-d); font-weight:700; flex:none;
}
.prow .info{ flex:1; min-width:0; }
.prow .info b{ display:block; color:var(--ink); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.prow .info small{ color:var(--muted); }
.prow .meta{ text-align:right; flex:none; }

.searchbar{ position:relative; flex:1; max-width:420px; }
.searchbar svg{ position:absolute; left:14px; top:50%; transform:translateY(-50%); width:18px; height:18px; color:var(--muted); }
.searchbar .input{ padding-left:42px; border-radius:999px; }

/* ============================================================
   TIMELINE DE NOTAS — cadena molecular
   ============================================================ */
.timeline{ position:relative; padding-left:34px; }
.timeline::before{
  content:''; position:absolute; left:10px; top:8px; bottom:8px; width:2px;
  background:linear-gradient(var(--sky), var(--line));
}
.tnode{ position:relative; margin-bottom:18px; }
.tnode::before{
  content:''; position:absolute; left:-31px; top:14px; width:13px; height:13px;
  border-radius:50%; background:var(--sky); border:3px solid #fff;
  box-shadow:0 0 0 2px var(--sky);
}
.tnode.medico::before{ background:var(--ink); box-shadow:0 0 0 2px var(--ink); }
.tnote{ background:#fff; border:1px solid var(--line); border-radius:var(--r-md); padding:16px 18px; box-shadow:var(--shadow); }
.tnote header{ display:flex; justify-content:space-between; gap:10px; flex-wrap:wrap; margin-bottom:8px; align-items:center; }
.tnote header b{ color:var(--ink); font-size:.92rem; }
.tnote header time{ color:var(--muted); font-size:.78rem; }
.tnote .vitals{ display:flex; flex-wrap:wrap; gap:8px; margin:10px 0 4px; }
.tnote .vitals span{ background:var(--ice); border-radius:8px; padding:4px 10px; font-size:.76rem; font-weight:600; color:var(--ink-soft); }
.tnote p{ white-space:pre-wrap; }
.tnote .firma{ margin-top:10px; padding-top:10px; border-top:1px dashed var(--line); font-size:.78rem; color:var(--muted); }

/* ============================================================
   ASISTENTE TIPO TYPEFORM (wizard)
   ============================================================ */
.wizard{ position:fixed; inset:0; background:var(--cloud); z-index:100; display:flex; flex-direction:column; }
.wizard .whead{ display:flex; align-items:center; justify-content:space-between; padding:18px clamp(16px,4vw,40px); }
.wizard .whead img{ height:30px; }

/* progreso: puntos conectados (molécula) */
.molecule{ display:flex; align-items:center; gap:0; }
.molecule i{
  width:11px; height:11px; border-radius:50%; background:var(--line); transition:.3s; flex:none;
}
.molecule s{ width:26px; height:2px; background:var(--line); text-decoration:none; transition:.3s; }
.molecule i.done, .molecule s.done{ background:var(--sky-deep); }
.molecule i.now{ background:var(--ink); transform:scale(1.45); box-shadow:0 0 0 5px rgba(143,217,238,.4); }

.wbody{ flex:1; display:flex; align-items:center; justify-content:center; padding:20px; overflow-y:auto; }
.wstep{ width:min(640px, 100%); animation:rise .45s cubic-bezier(.2,.9,.3,1); }
.wstep .qnum{ font-family:var(--font-d); color:var(--sky-deep); font-weight:700; font-size:.9rem; margin-bottom:8px; display:flex; gap:8px; align-items:center; }
.wstep h2{ font-size:clamp(1.4rem, 4vw, 2rem); margin-bottom:6px; }
.wstep .hint{ color:var(--muted); margin-bottom:22px; }
.wstep .input{ font-size:1.1rem; padding:16px 18px; }
@keyframes rise{ from{ opacity:0; transform:translateY(26px); } to{ opacity:1; transform:none; } }
@media (prefers-reduced-motion: reduce){ .wstep{ animation:none; } *{ transition:none !important; } }

.wfoot{ display:flex; justify-content:space-between; align-items:center; padding:16px clamp(16px,4vw,40px) calc(16px + env(safe-area-inset-bottom)); gap:12px; }
.wfoot .enter-hint{ color:var(--muted); font-size:.8rem; }
@media (max-width:700px){ .wfoot .enter-hint{ display:none; } }

.chips{ display:flex; gap:10px; flex-wrap:wrap; }
.chip{
  border:1.5px solid var(--line); background:#fff; border-radius:999px; padding:12px 22px;
  font-weight:600; cursor:pointer; transition:.18s; font-size:.95rem;
}
.chip:hover{ border-color:var(--sky-deep); }
.chip.sel{ background:var(--ink); color:var(--sky); border-color:var(--ink); }

.vgrid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); gap:12px; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap{ min-height:100dvh; display:grid; grid-template-columns:1.05fr 1fr; }
.login-hero{
  background:var(--ink); color:#fff; display:flex; flex-direction:column;
  justify-content:space-between; padding:clamp(28px,5vw,56px); position:relative; overflow:hidden;
}
.login-hero .glow{
  position:absolute; width:520px; height:520px; border-radius:50%;
  background:radial-gradient(circle, rgba(143,217,238,.35), transparent 65%);
  bottom:-180px; right:-140px; pointer-events:none;
}
.login-hero h1{ color:#fff; font-size:clamp(1.7rem, 3.4vw, 2.5rem); line-height:1.2; max-width:420px; }
.login-hero h1 em{ color:var(--sky); font-style:normal; }
.login-hero p{ color:#AEBCD4; max-width:380px; margin-top:12px; }
.login-form{ display:flex; align-items:center; justify-content:center; padding:26px; }
.login-card{ width:min(400px,100%); }
.login-card img{ height:120px; margin-bottom:22px; }
@media (max-width:860px){
  .login-wrap{ grid-template-columns:1fr; }
  .login-hero{ min-height:34dvh; border-radius:0 0 28px 28px; }
}

/* Tabs, modales, toasts */
.tabs{ display:flex; gap:6px; background:var(--ice); border-radius:999px; padding:5px; width:max-content; max-width:100%; overflow-x:auto; margin-bottom:20px; }
.tabs button{ border:none; background:transparent; padding:9px 18px; border-radius:999px; font-weight:600; color:var(--ink-soft); cursor:pointer; white-space:nowrap; font-size:.88rem; }
.tabs button.active{ background:var(--ink); color:var(--sky); }

.modal-bg{ position:fixed; inset:0; background:rgba(14,22,48,.5); backdrop-filter:blur(4px); z-index:120; display:none; align-items:flex-end; justify-content:center; }
.modal-bg.open{ display:flex; }
.modal{ background:#fff; width:min(560px,100%); border-radius:26px 26px 0 0; padding:26px; max-height:88dvh; overflow-y:auto; animation:rise .3s; }
@media (min-width:700px){ .modal-bg.open{ align-items:center; } .modal{ border-radius:var(--r-lg); } }

.toast{
  position:fixed; left:50%; bottom:calc(90px + env(safe-area-inset-bottom)); transform:translateX(-50%) translateY(20px);
  background:var(--ink); color:#fff; padding:13px 22px; border-radius:999px; font-weight:600;
  box-shadow:var(--shadow-lift); opacity:0; transition:.3s; z-index:200; pointer-events:none; max-width:90vw; text-align:center;
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }
.toast.err{ background:var(--danger); }

.empty{ text-align:center; color:var(--muted); padding:40px 16px; }
.empty .dot-row{ display:flex; gap:8px; justify-content:center; margin-bottom:14px; }
.empty .dot-row i{ width:12px; height:12px; border-radius:50%; background:var(--sky); opacity:.5; }
.empty .dot-row i:nth-child(2){ background:var(--ink); opacity:.8; }

.skeleton{ background:linear-gradient(90deg, #EEF3F8 25%, #F7FAFC 50%, #EEF3F8 75%); background-size:200% 100%; animation:sk 1.2s infinite; border-radius:var(--r-md); }
@keyframes sk{ to{ background-position:-200% 0; } }

.filelist{ display:grid; gap:10px; grid-template-columns:repeat(auto-fill,minmax(210px,1fr)); }
.filecard{ border:1px solid var(--line); border-radius:var(--r-md); padding:14px; background:#fff; display:flex; gap:10px; align-items:center; }
.filecard .fico{ width:38px; height:38px; border-radius:10px; background:var(--ice); display:grid; place-items:center; color:var(--sky-deep); flex:none; }
.filecard b{ font-size:.82rem; display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.filecard small{ color:var(--muted); font-size:.72rem; }

table.tbl{ width:100%; border-collapse:collapse; font-size:.9rem; }
table.tbl th{ text-align:left; color:var(--muted); font-weight:600; font-size:.78rem; text-transform:uppercase; letter-spacing:.06em; padding:10px 12px; border-bottom:1px solid var(--line); }
table.tbl td{ padding:12px; border-bottom:1px solid var(--line); }

.grid.cols-4{ display:grid; grid-template-columns:repeat(4,1fr); gap:16px; }
@media (max-width:900px){ .grid.cols-4{ grid-template-columns:repeat(2,1fr); } }
@media (max-width:520px){ .grid.cols-4{ grid-template-columns:1fr; } }
