@import url('assets/ds-tokens.css');

/* ============================================================
   DALCA — Pantalla de Diagnóstico Radiológico con IA
   Tema clínico oscuro. Layout de 3 columnas.
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg-app);
  font-family: var(--font-primary);
  color: var(--fg-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#root { height: 100vh; }

/* ── Nous (IA) brand layer ── */
:root {
  --nous: #EF5907;
  --nous-bright: #FF6A12;
  --nous-soft-12: rgba(239,89,7,0.12);
  --nous-soft-20: rgba(239,89,7,0.20);
  --nous-soft-32: rgba(239,89,7,0.34);
  --nous-tint: rgba(239,89,7,0.07);
}
.nous-mark { display: inline-block; vertical-align: middle; object-fit: contain; flex-shrink: 0; }

button { font-family: inherit; cursor: pointer; }
::selection { background: rgba(0,174,231,0.3); }

/* scrollbars */
.scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.scroll::-webkit-scrollbar-track { background: transparent; }
.scroll::-webkit-scrollbar-thumb { background: var(--gray-600); border-radius: 3px; }
.scroll::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

/* ─── APP SHELL ─── */
.app { display: flex; flex-direction: column; height: 100vh; }

/* ─── NAV (40px, igual al worklist) ─── */
.nav {
  height: 40px; background: var(--bg-surface);
  display: flex; align-items: center; padding: 0 16px; gap: 0;
  border-bottom: 1px solid var(--border); flex-shrink: 0; z-index: 30;
}
.nav-logo img { display: block; height: 18px; }
.nav-context {
  height: 100%; display: flex; align-items: center; padding: 0 12px; margin-left: 14px;
  background: var(--bg-app); gap: 6px; font-size: 11px; font-weight: 700; color: var(--fg-primary);
}
.nav-context svg { width: 12px; height: 12px; color: var(--fg-muted); }
.nav-breadcrumb { display: flex; align-items: center; gap: 7px; padding-left: 16px; font-size: 11px; font-weight: 700; }
.nav-breadcrumb .bc-muted { color: var(--fg-muted); }
.nav-breadcrumb .bc-active { color: var(--action); }
.nav-breadcrumb svg { width: 11px; height: 11px; color: var(--gray-500); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.nav-icon-btn { width: 32px; height: 40px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.nav-icon-btn:hover { background: var(--bg-surface-2); }
.nav-icon-btn svg { width: 14px; height: 14px; color: var(--fg-secondary); }
.nav-alert-btn { width: 32px; height: 40px; background: var(--red); display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; }
.nav-alert-btn svg { width: 14px; height: 14px; color: #fff; }
.nav-user { padding: 0 10px; font-size: 11px; font-weight: 700; color: var(--fg-secondary); display: flex; align-items: center; gap: 7px; }
.nav-user .avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--gray-600); display: flex; align-items: center; justify-content: center; font-size: 9px; color: var(--fg-primary); }

/* ─── BODY GRID ─── */
.workspace { flex: 1; display: flex; min-height: 0; min-width: 0; overflow-x: hidden; }

/* generic column */
.col { display: flex; flex-direction: column; min-height: 0; }
.col-scroll { flex: 1; overflow-y: auto; }

/* ===========================================================
   COLUMN 1 — TASK RAIL
   =========================================================== */
.rail { width: 280px; background: var(--bg-surface); border-right: 1px solid var(--border); flex-shrink: 0; transition: width .22s cubic-bezier(.4,0,.2,1); }
.rail.collapsed { width: 52px; }
.rail-head { height: 46px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.rail-head .title { font-size: 12px; font-weight: 700; color: var(--fg-primary); white-space: nowrap; flex: 1; overflow: hidden; }
.rail-head .count { background: var(--gray-600); color: var(--fg-primary); font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: var(--radius-pill); }
.rail-toggle { width: 26px; height: 26px; border: none; background: transparent; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; color: var(--fg-muted); flex-shrink: 0; }
.rail-toggle:hover { background: var(--bg-surface-2); color: var(--fg-secondary); }
.rail-toggle svg { width: 15px; height: 15px; }

.rail-filter { display: flex; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.rail-chip { flex: 1; text-align: center; font-size: 10px; font-weight: 700; padding: 4px 0; border-radius: var(--radius-md); background: var(--bg-app); color: var(--fg-muted); border: 1px solid transparent; }
.rail-chip.active { background: var(--bg-surface-2); color: var(--fg-primary); border-color: var(--border-strong); }
.rail-chip:hover { color: var(--fg-secondary); }

.task-list { padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.task {
  display: grid; grid-template-columns: 4px 1fr; gap: 8px; align-items: stretch;
  background: var(--bg-app); border: 1px solid transparent; border-radius: var(--radius-md);
  padding: 0; cursor: pointer; overflow: hidden; transition: background .12s, border-color .12s;
}
.task:hover { background: var(--bg-surface-2); }
.task.active { background: var(--bg-surface-2); border-color: var(--action); }
.task .accent { background: var(--gray-500); }
.task.over .accent { background: var(--red); }
.task.warn .accent { background: var(--orange); }
.task.ok .accent { background: var(--green); }
.task-body { padding: 8px 8px 8px 0; min-width: 0; }
.task-top { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.task-mod { font-size: 9px; font-weight: 700; border-radius: var(--radius-sm); padding: 1px 4px; color: var(--gray-900); flex-shrink: 0; }
.task-study { font-size: 10px; font-weight: 700; color: var(--fg-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.task-timer { font-size: 11px; font-weight: 700; margin-left: auto; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.task-timer.ok { color: var(--green); } .task-timer.warn { color: var(--orange); } .task-timer.over { color: var(--red); }
.task-patient { font-size: 11px; font-weight: 700; color: var(--fg-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-meta { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.task-demo { font-size: 9px; font-weight: 700; color: var(--fg-muted); }
.task-ai { margin-left: auto; display: inline-flex; align-items: center; gap: 3px; font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: var(--radius-pill); }
.task-ai svg { width: 9px; height: 9px; }
.task-ai.normal { background: rgba(15,193,104,0.14); color: var(--green); }
.task-ai.review { background: rgba(244,134,68,0.15); color: var(--orange); }
.task-ai.crit { background: rgba(255,74,50,0.16); color: var(--red); }
.task.done .task-body { opacity: .45; }
.task .done-check { color: var(--green); width: 12px; height: 12px; }

/* collapsed rail mini items */
.rail.collapsed .rail-head .title,
.rail.collapsed .rail-head .count,
.rail.collapsed .rail-filter,
.rail.collapsed .task-body { display: none; }
.rail.collapsed .task { grid-template-columns: 1fr; padding: 0; min-height: 38px; }
.rail.collapsed .task .accent { display: none; }
.rail.collapsed .task::after { content: attr(data-mod); display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; color: var(--fg-secondary); min-height: 38px; }

/* ===========================================================
   COLUMN 2 — PATIENT CONTEXT
   =========================================================== */
.context { width: 348px; background: var(--bg-app); border-right: 1px solid var(--border); flex-shrink: 0; }
.ctx-scroll { padding: 12px; display: flex; flex-direction: column; gap: 10px; }

.patient-card { background: var(--bg-surface); border-radius: var(--radius-md); padding: 12px; box-shadow: var(--shadow-card); }
.patient-name { font-size: 15px; font-weight: 700; color: var(--fg-primary); line-height: 1.15; }
.patient-demo { display: flex; align-items: center; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.patient-demo .chip { font-size: 10px; font-weight: 700; color: var(--fg-secondary); }
.patient-demo .dot { color: var(--gray-500); }
.pedi { background: var(--gray-600); border-radius: var(--radius-sm); padding: 0 4px; color: var(--fg-primary); }
.patient-rut { font-size: 11px; font-weight: 700; color: var(--fg-muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.patient-tags { display: flex; gap: 5px; margin-top: 8px; flex-wrap: wrap; }
.ptag { font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: var(--radius-sm); }
.ptag.urg { background: var(--bg-red); color: var(--red); }
.ptag.hosp { background: var(--bg-surface-2); color: var(--red); border: 1px solid var(--red); }
.ptag.amb { background: var(--gray-600); color: var(--fg-primary); }

/* section card */
.card { background: var(--bg-surface); border-radius: var(--radius-md); box-shadow: var(--shadow-card); overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 7px; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.card-head .ico { width: 14px; height: 14px; color: var(--fg-muted); flex-shrink: 0; }
.card-head .lbl { font-size: 10px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--fg-secondary); }
.card-head .right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.card-body { padding: 11px 12px; }
.card-body p { font-size: 12px; font-weight: 500; line-height: 1.5; color: var(--fg-secondary); font-family: var(--font-secondary); }
.card-body .kv { display: grid; grid-template-columns: 96px 1fr; gap: 4px 8px; }
.card-body .kv dt { font-size: 11px; font-weight: 700; color: var(--fg-muted); }
.card-body .kv dd { font-size: 11px; font-weight: 700; color: var(--fg-primary); }

/* prior studies list */
.prior { display: flex; flex-direction: column; }
.prior-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.prior-item:last-child { border-bottom: none; }
.prior-item:hover { background: var(--bg-surface-2); }
.prior-mod { font-size: 9px; font-weight: 700; border-radius: var(--radius-sm); padding: 1px 4px; color: var(--gray-900); flex-shrink: 0; min-width: 22px; text-align: center; }
.prior-info { min-width: 0; flex: 1; }
.prior-name { font-size: 11px; font-weight: 700; color: var(--fg-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prior-date { font-size: 9px; font-weight: 700; color: var(--fg-muted); }
.prior-item .open { width: 22px; height: 22px; border-radius: var(--radius-sm); background: var(--bg-surface-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.prior-item .open svg { width: 11px; height: 11px; color: var(--fg-muted); }

/* ===========================================================
   AI SUMMARY CARD (copiloto)
   =========================================================== */
.ai-card { border: 1px solid var(--border); background: var(--bg-surface); }
.ai-card .card-head { border-bottom-color: var(--border); }
.ai-card .card-head .ico { color: var(--fg-muted); }
.ai-card .card-head .lbl { color: var(--fg-secondary); }
.ai-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 9px; font-weight: 700; color: var(--fg-muted); }
.ai-badge svg { width: 11px; height: 11px; }
.ai-summary-text { font-size: 12px; font-weight: 500; line-height: 1.55; color: var(--fg-primary); font-family: var(--font-secondary); }
.ai-summary-text mark { background: rgba(255,150,2,0.18); color: var(--yellow); padding: 0 2px; border-radius: 2px; font-weight: 600; }
.ai-summary-text mark.crit { background: rgba(255,74,50,0.18); color: var(--red); }
.ai-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--border); }
.ai-foot .src { font-size: 9px; font-weight: 700; color: var(--fg-muted); display: flex; align-items: center; gap: 4px; }
.ai-foot .src svg { width: 10px; height: 10px; }

/* generic small ghost button */
.gbtn { background: var(--bg-surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-md); color: var(--fg-secondary); font-weight: 700; font-size: 11px; padding: 5px 9px; display: inline-flex; align-items: center; gap: 5px; transition: .12s; }
.gbtn:hover { border-color: var(--action); color: var(--fg-primary); }
.gbtn svg { width: 12px; height: 12px; }
.gbtn.sm { padding: 3px 7px; font-size: 10px; }
.gbtn:disabled { opacity: .45; cursor: not-allowed; }

.ai-btn { background: var(--bg-surface-2); border: 1px solid var(--border-strong); color: var(--fg-secondary); border-radius: var(--radius-md); font-weight: 700; font-size: 11px; padding: 5px 9px; display: inline-flex; align-items: center; gap: 5px; transition: .12s; }
.ai-btn:hover { border-color: var(--nous); color: var(--fg-primary); }
.ai-btn svg { width: 12px; height: 12px; }
.ai-btn.sm { padding: 3px 7px; font-size: 10px; }
.ai-btn:disabled { opacity: .4; cursor: not-allowed; }
.ai-btn.busy { color: var(--fg-muted); border-color: var(--border-strong); background: var(--bg-surface-2); }

/* ===========================================================
   COLUMN 3 — REPORT EDITOR
   =========================================================== */
.editor { flex: 1; min-width: 0; background: var(--bg-app); }
.editor-scroll { padding: 0 0 120px; }

/* image-AI banner */
.ai-read-banner { margin: 12px 16px 0; border-radius: var(--radius-md); padding: 10px 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ai-read-banner.normal { background: linear-gradient(180deg, rgba(15,193,104,0.14), rgba(15,193,104,0.04)); border: 1px solid rgba(15,193,104,0.4); }
.ai-read-banner.review { background: linear-gradient(180deg, rgba(244,134,68,0.13), rgba(244,134,68,0.03)); border: 1px solid rgba(244,134,68,0.42); }
.ai-read-banner.crit  { background: linear-gradient(180deg, rgba(255,74,50,0.15), rgba(255,74,50,0.04)); border: 1px solid rgba(255,74,50,0.5); }
.ai-read-icon { width: 32px; height: 32px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ai-read-banner.normal .ai-read-icon { background: rgba(15,193,104,0.2); color: var(--green); }
.ai-read-banner.review .ai-read-icon { background: rgba(244,134,68,0.2); color: var(--orange); }
.ai-read-banner.crit .ai-read-icon { background: rgba(255,74,50,0.22); color: var(--red); }
.ai-read-icon svg { width: 17px; height: 17px; }
.ai-read-text { flex: 1 1 240px; min-width: 200px; }
.ai-read-text .t { font-size: 12px; font-weight: 700; color: var(--fg-primary); display: flex; align-items: center; gap: 6px; }
.ai-read-text .t .tag { font-size: 8px; font-weight: 700; letter-spacing: .5px; padding: 1px 5px; border-radius: var(--radius-pill); background: rgba(255,255,255,0.08); color: var(--fg-secondary); }
.ai-read-text .s { font-size: 11px; font-weight: 500; color: var(--fg-secondary); font-family: var(--font-secondary); margin-top: 2px; }
.ai-read-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-normal { background: linear-gradient(180deg, #14d97a, var(--green)); border: none; color: #06381f; font-weight: 700; font-size: 11px; padding: 6px 11px; border-radius: var(--radius-md); display: inline-flex; align-items: center; gap: 5px; }
.btn-normal svg { width: 13px; height: 13px; }
.btn-abnormal { background: var(--bg-surface-2); border: 1px solid var(--border-strong); color: var(--fg-secondary); font-weight: 700; font-size: 11px; padding: 6px 11px; border-radius: var(--radius-md); display: inline-flex; align-items: center; gap: 5px; }
.btn-abnormal:hover { border-color: var(--orange); color: var(--orange); }
.btn-abnormal svg { width: 13px; height: 13px; }

/* report sheet */
.sheet { margin: 14px 16px 0; max-width: none; }
.report-section { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 10px; overflow: hidden; transition: border-color .15s; }
.report-section:focus-within { border-color: var(--action); }
.rs-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg-surface); border-bottom: 1px solid var(--border); }
.rs-head .num { width: 18px; height: 18px; border-radius: var(--radius-sm); background: var(--bg-surface-2); color: var(--fg-muted); font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rs-head .name { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--fg-secondary); }
.rs-head .req { color: var(--red); font-size: 11px; }
.rs-tools { margin-left: auto; display: flex; align-items: center; gap: 5px; }
.rs-body { position: relative; }

/* textarea / contenteditable field */
.field {
  width: 100%; min-height: 54px; resize: none;
  background: transparent; border: none; outline: none;
  color: var(--fg-primary); font-family: var(--font-secondary);
  font-size: 13px; font-weight: 500; line-height: 1.6;
  padding: 11px 12px;
}
.field::placeholder { color: var(--gray-500); font-style: italic; }
.field.title-field { font-family: var(--font-primary); font-weight: 700; font-size: 15px; color: var(--action); min-height: 0; padding: 10px 12px; }
.field.ghost { color: var(--fg-muted); }

/* typing cursor for AI streaming */
.streaming::after { content: '▍'; color: var(--action); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* mic button */
.mic-btn { width: 26px; height: 26px; border-radius: var(--radius-md); border: 1px solid var(--border-strong); background: var(--bg-surface-2); display: flex; align-items: center; justify-content: center; color: var(--fg-muted); flex-shrink: 0; transition: .12s; }
.mic-btn:hover { color: var(--fg-secondary); border-color: var(--fg-muted); }
.mic-btn svg { width: 13px; height: 13px; }
.mic-btn.live { background: var(--red); border-color: var(--red); color: #fff; animation: micpulse 1.4s ease-in-out infinite; }
@keyframes micpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,74,50,0.5); } 50% { box-shadow: 0 0 0 5px rgba(255,74,50,0); } }

/* listening waveform strip inside a field */
.listening-strip { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px dashed var(--red); background: rgba(255,74,50,0.05); }
.wave { display: flex; align-items: center; gap: 2px; height: 16px; }
.wave span { width: 2px; background: var(--red); border-radius: 1px; animation: wave 0.9s ease-in-out infinite; }
@keyframes wave { 0%,100% { height: 4px; } 50% { height: 16px; } }
.listening-strip .lbl { font-size: 10px; font-weight: 700; color: var(--red); }

/* critical pathology selector */
.crit-section { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 10px; overflow: hidden; }
.crit-section.flagged { border-color: var(--red); box-shadow: 0 0 0 1px rgba(255,74,50,0.3); }
.crit-grid { padding: 11px 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.crit-pill {
  font-size: 11px; font-weight: 700; padding: 5px 10px; border-radius: var(--radius-pill);
  background: var(--bg-app); border: 1px solid var(--border-strong); color: var(--fg-secondary);
  display: inline-flex; align-items: center; gap: 6px; transition: .12s;
}
.crit-pill:hover { border-color: var(--fg-muted); color: var(--fg-primary); }
.crit-pill.on { background: rgba(255,74,50,0.16); border-color: var(--red); color: var(--red); }
.crit-pill.suggested { border-color: var(--nous); border-style: dashed; color: var(--fg-secondary); }
.crit-pill svg { width: 11px; height: 11px; }
.crit-none { font-size: 11px; font-weight: 700; padding: 5px 10px; border-radius: var(--radius-pill); background: var(--bg-app); border: 1px solid var(--border-strong); color: var(--fg-muted); display: inline-flex; align-items: center; gap: 6px; }
.crit-none.on { background: rgba(15,193,104,0.14); border-color: var(--green); color: var(--green); }
.crit-none svg { width: 11px; height: 11px; }
.ai-suggest-note { display: flex; align-items: center; gap: 6px; padding: 7px 12px; background: var(--bg-surface-2); border-top: 1px solid var(--border); font-size: 10px; font-weight: 700; color: var(--fg-secondary); }
.ai-suggest-note svg { width: 12px; height: 12px; flex-shrink: 0; }
.ai-suggest-note .accept { margin-left: auto; }

/* ===========================================================
   ACTION BAR (footer del editor)
   =========================================================== */
.action-bar {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--bg-surface); border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; z-index: 20;
}
.coherence { display: flex; align-items: center; gap: 8px; }
.coherence-status { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; }
.coherence-status svg { width: 14px; height: 14px; }
.coherence-status.ok { color: var(--green); }
.coherence-status.warn { color: var(--orange); }
.coherence-status.idle { color: var(--fg-muted); }
.action-bar .spacer { flex: 1; }
.btn-secondary { background: var(--bg-surface-2); border: 1px solid var(--border-strong); color: var(--fg-secondary); font-weight: 700; font-size: 12px; padding: 8px 14px; border-radius: var(--radius-md); display: inline-flex; align-items: center; gap: 6px; }
.btn-secondary:hover { color: var(--fg-primary); border-color: var(--fg-muted); }
.btn-secondary svg { width: 14px; height: 14px; }
.btn-sign {
  background: linear-gradient(180deg, var(--blue-light), var(--blue-primary));
  border: none; color: #fff; font-weight: 700; font-size: 12px; padding: 8px 18px;
  border-radius: var(--radius-md); display: inline-flex; align-items: center; gap: 7px;
  box-shadow: 0 0 12px rgba(255,255,255,0.18);
}
.btn-sign:hover { filter: brightness(1.05); }
.btn-sign svg { width: 14px; height: 14px; }
.btn-sign:disabled { opacity: .5; filter: none; cursor: not-allowed; }

/* coherence findings popover */
.coh-list { display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }
.coh-row { display: flex; align-items: flex-start; gap: 8px; font-size: 11px; font-weight: 500; font-family: var(--font-secondary); color: var(--fg-secondary); line-height: 1.4; }
.coh-row svg { width: 13px; height: 13px; flex-shrink: 0; margin-top: 1px; }
.coh-row.warn svg { color: var(--orange); }
.coh-row.ok svg { color: var(--green); }

/* ===========================================================
   EDITOR HEADER (sticky)
   =========================================================== */
.editor-head { height: 46px; display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--bg-app); flex-shrink: 0; position: sticky; top: 0; z-index: 10; }
.editor-head .e-title { font-size: 13px; font-weight: 700; color: var(--fg-primary); }
.editor-head .e-sub { font-size: 10px; font-weight: 700; color: var(--fg-muted); display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.editor-head > div:first-child { min-width: 0; }
.editor-head .e-title { white-space: nowrap; }
.editor-head .e-sub .sep { color: var(--gray-500); }
.editor-head .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.template-select { height: 28px; background: var(--bg-surface); border: 1px solid var(--border-strong); border-radius: var(--radius-md); color: var(--fg-secondary); font-family: var(--font-primary); font-weight: 700; font-size: 11px; padding: 0 26px 0 9px; outline: none; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%235A7E91' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; }

/* progress dots */
.prog { display: flex; align-items: center; gap: 4px; }
.prog .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gray-600); }
.prog .dot.done { background: var(--green); }

/* ===========================================================
   TOAST
   =========================================================== */
.toast-wrap { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--bg-surface); border: 1px solid var(--border-strong); border-radius: var(--radius-md); padding: 10px 14px; display: flex; align-items: center; gap: 9px; box-shadow: 0 8px 30px rgba(0,0,0,0.5); font-size: 12px; font-weight: 700; color: var(--fg-primary); animation: toastin .25s cubic-bezier(.4,0,.2,1); }
.toast svg { width: 15px; height: 15px; flex-shrink: 0; }
.toast.ok { border-left: 3px solid var(--green); } .toast.ok svg { color: var(--green); }
.toast.ai { border-left: 3px solid var(--action); } .toast.ai svg { color: var(--action); }
.toast.warn { border-left: 3px solid var(--orange); } .toast.warn svg { color: var(--orange); }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* signing overlay flash */
.advance-flash { position: fixed; inset: 0; background: var(--bg-app); display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px; z-index: 150; animation: fadeout .9s ease forwards; animation-delay: .5s; pointer-events: none; }
.advance-flash .ring { width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--bg-surface-2); border-top-color: var(--green); animation: spin .7s linear infinite; }
.advance-flash .msg { font-size: 13px; font-weight: 700; color: var(--fg-secondary); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeout { to { opacity: 0; } }

/* misc helpers */
.muted { color: var(--fg-muted); }
.divv { width: 1px; height: 22px; background: var(--border-strong); }
.kbd { font-family: var(--font-secondary); font-size: 9px; font-weight: 700; color: var(--fg-muted); background: var(--bg-app); border: 1px solid var(--border-strong); border-radius: 3px; padding: 1px 4px; }

/* ===========================================================
   RESPONSIVE
   =========================================================== */

/* Pane switcher (visible solo en modo angosto) */
.pane-switcher { display: flex; gap: 4px; padding: 6px 10px; background: var(--bg-surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.pane-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 6px; border: 1px solid transparent; border-radius: var(--radius-md); background: var(--bg-app); color: var(--fg-muted); font-weight: 700; font-size: 11px; }
.pane-btn svg { width: 14px; height: 14px; }
.pane-btn.active { background: var(--bg-surface-2); color: var(--fg-primary); border-color: var(--border-strong); }
.pane-count { background: var(--gray-600); color: var(--fg-primary); font-size: 9px; padding: 0 5px; border-radius: var(--radius-pill); }

/* Modo angosto: una sola columna a la vez */
.workspace.narrow .rail,
.workspace.narrow .context,
.workspace.narrow .editor { display: none; width: 100% !important; flex: 1 1 auto; border-right: none; }
.workspace.narrow[data-pane="tareas"] .rail { display: flex; }
.workspace.narrow[data-pane="paciente"] .context { display: flex; }
.workspace.narrow[data-pane="informe"] .editor { display: flex; }
.workspace.narrow .rail.collapsed { width: 100% !important; }
.workspace.narrow .rail.collapsed .rail-head .title,
.workspace.narrow .rail.collapsed .rail-head .count,
.workspace.narrow .rail.collapsed .rail-filter,
.workspace.narrow .rail.collapsed .task-body { display: revert; }
.workspace.narrow .rail.collapsed .task { grid-template-columns: 4px 1fr; }
.workspace.narrow .rail.collapsed .task .accent { display: block; }
.workspace.narrow .rail.collapsed .task::after { content: none; }
.workspace.narrow .rail-toggle { display: none; }

/* Medium: comprimir columnas antes de colapsar */
@media (max-width: 1240px) {
  .rail { width: 244px; }
  .context { width: 312px; }
}
@media (max-width: 1080px) {
  .context { width: 288px; }
  .toolbar { gap: 8px; }
}

/* Tablet / móvil */
@media (max-width: 900px) {
  .nav-breadcrumb { display: none; }
  .nav-context { margin-left: 8px; }
  .editor-head .right .divv,
  .editor-head .template-select { display: none; }
  .sheet { margin: 12px 12px 0; }
  .ai-read-banner { margin: 12px 12px 0; flex-wrap: wrap; }
  .ai-read-actions { width: 100%; }
  .action-bar { flex-wrap: wrap; gap: 8px; }
  .coherence-status { display: none !important; }
}

@media (max-width: 560px) {
  .nav { padding: 0 10px; }
  .nav-user span.avatar { margin: 0; }
  .nav-user { font-size: 0; gap: 0; padding: 0 4px; }
  .nav-user .avatar { font-size: 9px; }
  .editor-head { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 6px; }
  .editor-head .e-sub { white-space: normal; }
  .ai-read-banner { flex-direction: column; align-items: flex-start; }
  .ai-read-actions { flex-direction: column; }
  .ai-read-actions button { width: 100%; justify-content: center; }
  .action-bar { padding: 8px 12px; }
  .action-bar .btn-sign,
  .action-bar .btn-secondary { flex: 1; justify-content: center; }
  .crit-grid { gap: 5px; }
  .toast { max-width: 92vw; }
}
