/* ===== Clinaudit — design tokens & base ===== */
:root {
  /* clinical-timeline event colours (línea de tiempo) */
  --tl-ingreso: #D97706;
  --tl-eval: #7C3AED;
  --tl-medic: #0D9488;
  --tl-proc: #DB2777;
  --tl-paraclinico: #2563EB;
  --tl-evolucion: #64748B;
  --tl-egreso: #059669;
  /* surfaces */
  --white: #FFFFFF;
  --bg: #F8FAFC;
  --bg-2: #F1F5F9;
  --header-bg: #F1F5F9;

  /* text */
  --ink: #0F172A;
  --body: #475569;
  --muted: #94A3B8;

  /* lines */
  --border: #E6EDF3;
  --border-strong: #D7E0EA;

  /* accent */
  --teal: #0D9488;
  --teal-700: #0F766E;
  --teal-600: #0D9488;
  --cyan: #06B6D4;
  --teal-soft: #ECFDF8;
  --cyan-soft: #ECFEFF;

  /* status */
  --ok: #059669;          --ok-soft: #ECFDF5;
  --bad: #DC2626;         --bad-soft: #FEF2F2;
  --warn: #D97706;        --warn-soft: #FFFBEB;
  --na: #94A3B8;          --na-soft: #F1F5F9;

  /* severity */
  --sev-crit: #DC2626;    --sev-crit-soft: #FEF2F2;
  --sev-high: #D97706;    --sev-high-soft: #FFFBEB;
  --sev-mid:  #64748B;    --sev-mid-soft: #F1F5F9;

  /* radii */
  --r-sm: 9px;
  --r: 14px;
  --r-lg: 16px;
  --r-pill: 999px;

  /* shadow */
  --sh-sm: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.04);
  --sh: 0 1px 2px rgba(15,23,42,.04), 0 6px 18px -10px rgba(15,23,42,.14);
  --sh-lg: 0 1px 2px rgba(15,23,42,.05), 0 18px 40px -18px rgba(15,23,42,.22);
  --sh-teal: 0 10px 24px -10px rgba(13,148,136,.5);

  --maxw: 1160px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv05' 1, 'ss01' 1;
}
#root { min-height: 100vh; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }
::selection { background: rgba(13,148,136,.16); }

/* numerals align in tables/metrics */
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }

/* ---- layout shell ---- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.shell { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 28px; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,.82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-in { height: 66px; display: flex; align-items: center; justify-content: space-between; }
.topbar-nav { display: flex; align-items: center; gap: 26px; }
.topbar-link {
  font-size: 13.5px; font-weight: 500; color: var(--body);
  text-decoration: none; letter-spacing: -.01em; white-space: nowrap;
  padding: 6px 2px; border-bottom: 2px solid transparent; transition: color .15s;
}
.topbar-link:hover { color: var(--ink); }
.topbar-link.active { color: var(--teal-700); }
.topbar-right { display: flex; align-items: center; gap: 14px; }

/* ---- logo ---- */
.logo { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.logo-mark { width: 34px; height: 34px; flex: 0 0 auto; display: block; border-radius: 9px; box-shadow: var(--sh-teal); }
.logo-text { display: flex; flex-direction: column; line-height: 1; gap: 3px; }
.logo-word { font-size: 17px; font-weight: 700; letter-spacing: -.025em; color: var(--ink); }
.logo-word .k { color: var(--teal-700); }
.logo-by { font-size: 9.5px; font-weight: 600; letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  height: 44px; padding: 0 20px; border-radius: var(--r);
  font-size: 14.5px; font-weight: 600; letter-spacing: -.01em;
  border: 1px solid transparent; background: var(--white); color: var(--ink);
  transition: transform .12s ease, box-shadow .15s ease, background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  color: #fff; border: none;
  background: linear-gradient(120deg, var(--teal) 0%, var(--cyan) 130%);
  box-shadow: var(--sh-teal);
}
.btn-primary:hover { box-shadow: 0 14px 30px -10px rgba(13,148,136,.6); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-ghost { background: var(--white); border: 1px solid var(--border-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--muted); background: #fff; }
.btn-quiet { background: transparent; color: var(--body); height: 38px; padding: 0 12px; }
.btn-quiet:hover { color: var(--ink); background: var(--bg-2); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 13px; border-radius: var(--r-sm); }
.btn-lg { height: 52px; padding: 0 28px; font-size: 16px; }

/* ---- card ---- */
.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-sm);
}
.card-hover { transition: transform .16s ease, box-shadow .18s ease, border-color .18s; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--sh); border-color: var(--border-strong); }

/* ---- chips / pills ---- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; letter-spacing: -.005em; white-space: nowrap;
  border: 1px solid transparent;
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; }
.chip-ok   { background: var(--ok-soft);  color: var(--ok); }
.chip-bad  { background: var(--bad-soft); color: var(--bad); }
.chip-fix  { background: var(--teal-soft); color: var(--teal-700); }
.chip-warn { background: var(--warn-soft);color: #B45309; }
.chip-na   { background: var(--na-soft);  color: #64748B; }
.chip-neutral { background: var(--bg-2); color: var(--body); }

/* severity */
.sev { display:inline-flex; align-items:center; gap:6px; height:22px; padding:0 9px; border-radius: var(--r-pill); font-size:11.5px; font-weight:700; letter-spacing:.02em; text-transform: uppercase; }
.sev-crit { background: var(--sev-crit-soft); color: var(--sev-crit); }
.sev-high { background: var(--sev-high-soft); color: var(--sev-high); }
.sev-mid  { background: var(--sev-mid-soft);  color: var(--sev-mid); }

/* evidence chip */
.ev {
  display:inline-flex; align-items:center; gap:5px; height:22px; padding:0 9px; white-space:nowrap;
  border-radius: var(--r-pill); font-size:11.5px; font-weight:600; letter-spacing:.01em;
  background: var(--cyan-soft); color: #0E7490; border: 1px solid #CFF4FB;
  font-feature-settings:'tnum' 1;
}

/* count badge */
.count-badge {
  display:inline-flex; align-items:center; justify-content:center;
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.count-bad { background: var(--bad-soft); color: var(--bad); }
.count-zero { background: var(--bg-2); color: var(--muted); }

/* ---- progress bar ---- */
.bar { height: 7px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.bar > i { display:block; height:100%; border-radius:99px; transition: width .9s cubic-bezier(.22,.61,.36,1); }

/* ---- privacy lock badge ---- */
.lockbar {
  display:inline-flex; align-items:center; gap:11px; padding: 11px 16px;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--r-pill);
  box-shadow: var(--sh-sm);
}
.lockbar .ic { width: 30px; height: 30px; border-radius: 50%; background: var(--teal-soft); color: var(--teal-700); display:grid; place-items:center; flex:0 0 auto; }
.lockbar b { color: var(--ink); font-weight: 650; }

/* ---- dropzone ---- */
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg);
  background: var(--white); padding: 46px 28px; text-align: center;
  transition: border-color .18s, background .18s, box-shadow .18s; cursor: pointer;
}
.dropzone:hover { border-color: var(--teal); background: #fff; box-shadow: var(--sh); }
.dropzone.drag { border-color: var(--teal); border-style: solid; background: var(--teal-soft); box-shadow: var(--sh-teal); }
.dz-ic { width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 16px;
  background: linear-gradient(140deg, var(--teal-soft), var(--cyan-soft)); color: var(--teal-700);
  display: grid; place-items: center; }

/* file row */
.filerow { display:flex; align-items:center; gap:13px; padding: 12px 14px; border:1px solid var(--border); border-radius: var(--r); background: var(--white); }
.filerow:hover { border-color: var(--border-strong); }
.file-ic { width: 38px; height: 38px; border-radius: 9px; background: var(--bg-2); color: var(--body); display:grid; place-items:center; flex:0 0 auto; }
.file-x { margin-left:auto; width: 30px; height: 30px; border-radius: 8px; border: none; background: transparent; color: var(--muted); display:grid; place-items:center; transition: background .14s, color .14s; }
.file-x:hover { background: var(--bad-soft); color: var(--bad); }

/* ---- table ---- */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl thead th {
  background: var(--header-bg); color: var(--body); font-size: 11.5px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; text-align: left;
  padding: 13px 18px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tbl thead th:first-child { border-top-left-radius: var(--r-lg); }
.tbl thead th:last-child  { border-top-right-radius: var(--r-lg); }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--ink); }
.tbl th .sortarrow { opacity: .4; margin-left: 5px; font-size: 10px; }
.tbl th.sorted .sortarrow { opacity: 1; color: var(--teal-700); }
.tbl tbody td { padding: 16px 18px; border-bottom: 1px solid var(--border); font-size: 14px; color: var(--body); vertical-align: middle; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--bg); }
.tbl tbody tr:last-child td { border-bottom: none; }

/* ---- stepper ---- */
.steps { display:flex; align-items:center; gap: 0; }
.step { display:flex; align-items:center; gap:9px; }
.step-dot { width: 26px; height: 26px; border-radius: 50%; display:grid; place-items:center; flex:0 0 auto;
  font-size: 12px; font-weight: 700; border: 2px solid var(--border-strong); color: var(--muted); background: var(--white); transition: all .3s; }
.step.active .step-dot { border-color: var(--teal); color: #fff; background: var(--teal); box-shadow: 0 0 0 4px var(--teal-soft); }
.step.done .step-dot { border-color: var(--ok); background: var(--ok); color: #fff; }
.step-label { font-size: 13px; font-weight: 600; color: var(--muted); transition: color .3s; }
.step.active .step-label { color: var(--teal-700); }
.step.done .step-label { color: var(--ink); }
.step-line { width: 30px; height: 2px; background: var(--border-strong); margin: 0 10px; border-radius: 2px; transition: background .3s; }
.step-line.fill { background: var(--ok); }

/* ---- accordion ---- */
.acc { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; background: var(--white); }
.acc + .acc { margin-top: 10px; }
.acc-head { width: 100%; display:flex; align-items:center; gap: 14px; padding: 16px 18px; background: var(--white); border: none; text-align: left; transition: background .14s; }
.acc-head:hover { background: var(--bg); }
.acc-chev { margin-left: auto; color: var(--muted); transition: transform .22s ease; flex:0 0 auto; }
.acc.open .acc-chev { transform: rotate(90deg); }
.acc-title { font-size: 15px; font-weight: 650; color: var(--ink); letter-spacing: -.01em; }
.acc-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.acc-body { border-top: 1px solid var(--border); }

/* mini status pills inline in domain summary */
.minipills { display:flex; align-items:center; gap: 7px; }
.minipill { display:inline-flex; align-items:center; gap:5px; font-size:12px; font-weight:600; color: var(--body); font-variant-numeric: tabular-nums; }
.minipill .dot { width:8px; height:8px; border-radius:50%; }

/* ---- finding card ---- */
.finding { display:flex; gap: 16px; padding: 18px 20px; border:1px solid var(--border); border-radius: var(--r); background: var(--white); transition: border-color .16s, box-shadow .16s; }
.finding:hover { border-color: var(--border-strong); box-shadow: var(--sh-sm); }
.finding + .finding { margin-top: 12px; }
.finding-rail { width: 4px; border-radius: 99px; flex: 0 0 auto; align-self: stretch; }
.rail-crit { background: var(--sev-crit); }
.rail-high { background: var(--sev-high); }
.rail-mid  { background: var(--sev-mid); }
.rail-review { background: var(--cyan); }
.finding-id { font-size: 12.5px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.finding-name { font-size: 15.5px; font-weight: 650; color: var(--ink); letter-spacing: -.01em; }
.eval-line { font-size: 13px; color: var(--muted); }
.eval-line b { color: var(--body); font-weight: 600; }
.justif { font-size: 14px; color: var(--body); line-height: 1.5; }
.justif .q { color: var(--ink); font-weight: 600; }

/* ---- scorecard ring ---- */
.scorecards { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 16px; }
.scorecard { padding: 20px; }
.score-num { font-size: 30px; font-weight: 750; color: var(--ink); letter-spacing: -.03em; line-height: 1; }
.score-label { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-top: 7px; letter-spacing: .01em; }
.ringwrap { display:flex; align-items:center; gap: 18px; }
.ring-center { display:flex; flex-direction:column; }
.ring-pct { font-size: 26px; font-weight: 750; color: var(--ink); letter-spacing: -.03em; line-height: 1; }

/* ---- detail banner ---- */
.banner {
  position: relative; overflow: hidden; border-radius: var(--r-lg);
  background: linear-gradient(118deg, var(--teal-700) 0%, var(--teal) 46%, var(--cyan) 116%);
  color: #fff; padding: 26px 28px;
}
.banner::after { content:''; position:absolute; inset:0; background:
  radial-gradient(420px 180px at 88% -30%, rgba(255,255,255,.22), transparent 60%); pointer-events:none; }
.banner b { font-weight: 750; }

/* segmented tabs */
.seg { display:inline-flex; padding: 4px; background: var(--bg-2); border-radius: var(--r); gap: 3px; }
.seg button { height: 34px; padding: 0 16px; border:none; background: transparent; border-radius: var(--r-sm); font-size: 13.5px; font-weight: 600; color: var(--body); transition: all .15s; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--white); color: var(--ink); box-shadow: var(--sh-sm); }

/* anonymized text view */
.anon { font-family: 'Inter', monospace; font-size: 14px; line-height: 1.85; color: var(--body); white-space: pre-wrap; }
.ph { display:inline-block; padding: 1px 7px; margin: 0 1px; border-radius: 6px; background: var(--cyan-soft); color: #0E7490; font-size: 12.5px; font-weight: 600; font-feature-settings:'tnum' 1; border: 1px solid #CFF4FB; }
/* PHI review: canary = redacted by the local validator; manual = masked by the auditor */
.ph-canary { background: var(--warn-soft); color: #B45309; border-color: #FDE0B8; }
.ph-manual { background: var(--bad-soft); color: var(--bad); border-color: #F7CDCD; }

/* section headings */
.sec-title { font-size: 19px; font-weight: 700; color: var(--ink); letter-spacing: -.02em; }
.sec-desc { font-size: 14px; color: var(--body); margin-top: 4px; }
.eyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--teal-700); }

/* empty state */
.empty { text-align:center; padding: 40px 24px; color: var(--muted); }

/* footer note */
.footnote { font-size: 12.5px; color: var(--muted); line-height: 1.6; }

/* misc */
.divider { height:1px; background: var(--border); border: none; margin: 0; }
.kbd-trace { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.backlink { display:inline-flex; align-items:center; gap:7px; font-size: 13.5px; font-weight: 600; color: var(--body); text-decoration: none; transition: color .14s; background:none; border:none; padding:0; }
.backlink:hover { color: var(--teal-700); }

/* Always-visible base. No opacity gating — robust for capture, print & PDF.
   A subtle, capture-safe slide-up plays only when motion is allowed. */
.fade-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: no-preference) {
  .fade-in { animation: rise .42s ease both; }
}
@keyframes rise { from { transform: translateY(9px);} to { transform: none;} }

@media (max-width: 920px) {
  .scorecards { grid-template-columns: 1fr 1fr; }
  .shell { padding: 0 18px; }
}
@media (max-width: 620px) {
  .scorecards { grid-template-columns: 1fr; }
  .topbar-nav { display: none; }
}

/* ---- audit-profile config screen ---- */
.inp {
  height: 34px; padding: 0 10px; font: inherit; font-size: 13.5px; color: var(--ink);
  background: var(--white); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.inp:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.nivel-select {
  height: 32px; padding: 0 8px; font: inherit; font-size: 12.5px; font-weight: 650;
  color: var(--ink); background: var(--white); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); cursor: pointer; outline: none;
}
.nivel-select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
/* Priority cue on the per-attribute select. */
.nivel-select[data-nivel="critica"] { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.nivel-select[data-nivel="alta"]    { border-color: var(--warn); color: #B45309; background: var(--warn-soft); }
.nivel-select[data-nivel="ignorar"] { color: var(--muted); background: var(--bg-2); }
.cat-pill {
  display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px;
  font-weight: 700; text-transform: capitalize; letter-spacing: .01em;
}
.cat-asistencial  { background: var(--teal-soft); color: var(--teal-700); }
.cat-institucional{ background: #EEF2FF; color: #4338CA; }
.cat-transversal  { background: var(--bg-2); color: var(--body); }
.cfg-savebar {
  position: sticky; bottom: 0; margin-top: 18px; padding: 12px 0;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
