/* ============================================================
   SIPENA GOVERNMENT COMMAND UI — design system v2
   Temas: [data-theme="dark"] COMMAND DARK (por defecto)
          [data-theme="light"] INSTITUTIONAL LIGHT
   Sin dependencias externas: fuentes Inter locales, SVG inline.
   ============================================================ */

/* ── Fuentes locales (Inter, latin + latin-ext) ─────────── */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/inter-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/inter-400-latinext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/fonts/inter-500-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/fonts/inter-500-latinext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/fonts/inter-600-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/fonts/inter-600-latinext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/fonts/inter-700-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/fonts/inter-700-latinext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* ── Design tokens ──────────────────────────────────────── */
:root {
  --font-sans: 'Inter', 'Segoe UI', Calibri, system-ui, sans-serif;
  --font-mono: Consolas, 'Cascadia Mono', monospace;

  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 28px; --space-7: 40px; --space-8: 56px;

  --radius-s: 6px; --radius-m: 10px; --radius-l: 14px; --radius-pill: 999px;

  --shadow-1: 0 1px 2px rgba(2, 8, 20, .25);
  --shadow-2: 0 6px 24px rgba(2, 8, 20, .35);
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 74px;
  --topbar-h: 60px;
}

/* Tema oscuro — COMMAND DARK (defecto) */
[data-theme="dark"] {
  --bg: #0B1526;
  --bg-sidebar: #101D31;
  --surface: #17263D;
  --surface-2: #20334F;
  --border: #2A3D5C;
  --border-soft: #22334E;
  --action: #3B82F6;
  --action-hover: #60A5FA;
  --cyan: #22C1D6;
  --text: #F1F5FA;
  --text-2: #A8B8CC;
  --ok: #34D399;      --ok-bg: rgba(52, 211, 153, .12);
  --warn: #FBBF24;    --warn-bg: rgba(251, 191, 36, .12);
  --danger: #F87171;  --danger-bg: rgba(248, 113, 113, .12);
  --info: #22C1D6;    --info-bg: rgba(34, 193, 214, .12);
  --table-head: #1B2C45;
  --stripe: #13213533;
  --focus-ring: #60A5FA;
}

/* Tema claro — INSTITUTIONAL LIGHT */
[data-theme="light"] {
  --bg: #F4F7FB;
  --bg-sidebar: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F0F4FA;
  --border: #E2E8F0;
  --border-soft: #EAEFF5;
  --action: #1D4ED8;
  --action-hover: #2563EB;
  --cyan: #0E7490;
  --text: #18263A;
  --text-2: #5A6B80;
  --ok: #059669;      --ok-bg: #ECFDF5;
  --warn: #B45309;    --warn-bg: #FFFBEB;
  --danger: #DC2626;  --danger-bg: #FEF2F2;
  --info: #0E7490;    --info-bg: #ECFEFF;
  --table-head: #1D4ED8;
  --stripe: #F6F9FC;
  --focus-ring: #1D4ED8;
}

/* ── Base ───────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--action); }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 4px; }
::placeholder { color: var(--text-2); opacity: .75; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.muted { color: var(--text-2); font-weight: 400; font-size: .86em; }
.small { font-size: 12.5px; }
code {
  font-family: var(--font-mono);
  background: var(--surface-2); color: var(--cyan);
  padding: 1px 6px; border-radius: var(--radius-s); font-size: .88em;
}
.back { font-size: 13.5px; text-decoration: none; display: inline-block; margin-bottom: var(--space-3); color: var(--text-2); }
.back:hover { color: var(--action); }

/* ── App shell ──────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: calc(100vh - var(--topbar-h));
  transition: grid-template-columns .18s ease;
}
body.sidebar-collapsed .shell { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.topbar-inner {
  max-width: 1560px; margin: 0 auto; height: var(--topbar-h);
  padding: 0 var(--space-5); display: flex; align-items: center; gap: var(--space-4);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark {
  height: 34px; width: 34px; padding: 0;
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-1);
  display: block;
  flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.12; font-weight: 700; letter-spacing: 2.5px; font-size: 15px; }
.brand-text small { font-weight: 400; letter-spacing: .2px; font-size: 10px; color: var(--text-2); }
.topbar-divider { width: 1px; height: 26px; background: var(--border); }

/* ── Banda institucional INP (tablero) ──────────────────── */
.inp-band {
  display: flex; align-items: center; gap: var(--space-4);
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-l);
  padding: var(--space-3) var(--space-5);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-1);
}
.inp-band img { height: 64px; width: auto; flex: none; filter: drop-shadow(0 2px 6px rgba(2, 8, 20, .4)); }
.inp-band-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.inp-band-text strong { font-size: 16px; letter-spacing: .4px; }
.inp-band-text span { font-size: 11.5px; color: var(--text-2); letter-spacing: 1px; text-transform: uppercase; }
.inp-band-motto { margin-left: auto; margin-right: 26px; font-size: 11.5px; letter-spacing: 2.5px; text-transform: uppercase; color: var(--warn); font-weight: 600; white-space: nowrap; }
.inp-band .inp-band-crest { height: 84px; width: auto; flex: none; filter: drop-shadow(0 0 14px rgba(34, 193, 214, .35)); }
@media (max-width: 760px) { .inp-band-motto { display: none; } .inp-band img { height: 52px; } .inp-band .inp-band-crest { height: 62px; } }
.topbar-title { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.topbar-title strong { font-size: 14.5px; font-weight: 600; }
.breadcrumb { font-size: 11.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.breadcrumb a { color: var(--text-2); text-decoration: none; }
.breadcrumb a:hover { color: var(--action); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-m);
  background: transparent; border: 1px solid var(--border); color: var(--text-2);
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { width: 17px; height: 17px; }

.theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

.userbox { display: flex; align-items: center; gap: 10px; }
.user-meta { display: flex; flex-direction: column; text-align: right; line-height: 1.18; font-size: 12.5px; }
.user-meta span { color: var(--text-2); font-size: 10.5px; }
.avatar {
  width: 34px; height: 34px; border-radius: var(--radius-pill);
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; color: var(--cyan);
}
.userbox form { margin: 0; }

/* Selector de centro (topbar) */
.centerbar-select {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-m); padding: 6px 10px; font-size: 13px; max-width: 300px;
  font-family: var(--font-sans);
}
.centerbar-label { font-size: 11px; color: var(--text-2); letter-spacing: .5px; text-transform: uppercase; }

.notif-btn { position: relative; }
.notif-badge {
  position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px;
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: var(--radius-pill); display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: var(--space-4) var(--space-3) var(--space-6);
  overflow-y: auto; overflow-x: hidden;
  position: sticky; top: var(--topbar-h);
  max-height: calc(100vh - var(--topbar-h));
}
.menu-group { margin-bottom: var(--space-5); }
.menu-heading {
  font-size: 10px; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--text-2); padding: 0 var(--space-3) var(--space-2); font-weight: 700;
  white-space: nowrap;
}
.menu-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px var(--space-3); border-radius: var(--radius-m);
  text-decoration: none; color: var(--text-2); font-size: 13.2px;
  border-left: 3px solid transparent; white-space: nowrap;
}
.menu-item svg { width: 16.5px; height: 16.5px; flex: 0 0 auto; opacity: .85; }
.menu-item:hover { background: var(--surface-2); color: var(--text); }
.menu-item.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, .16), transparent);
  border-left-color: var(--action); font-weight: 600; color: var(--text);
}
.menu-item.active svg { color: var(--action); opacity: 1; }
.sidebar-foot { margin-top: var(--space-2); border-top: 1px solid var(--border-soft); padding-top: var(--space-4); }

body.sidebar-collapsed .menu-item span,
body.sidebar-collapsed .menu-heading,
body.sidebar-collapsed .brand-text { display: none; }
body.sidebar-collapsed .menu-item { justify-content: center; padding: 10px 0; }
body.sidebar-collapsed .brand { justify-content: center; }

/* ── Página ─────────────────────────────────────────────── */
.page { padding: var(--space-6) var(--space-6) var(--space-8); max-width: 1280px; min-width: 0; width: 100%; }
body > main.page { margin: 0 auto; }
.page-title { font-size: 21px; margin: 0 0 var(--space-5); font-weight: 700; letter-spacing: -.01em; }
.footer {
  max-width: 1560px; margin: 0 auto; padding: var(--space-4) var(--space-6) var(--space-7);
  color: var(--text-2); font-size: 11.5px; border-top: 1px solid var(--border-soft);
}

/* ── Botones ────────────────────────────────────────────── */
.btn-primary {
  background: var(--action); color: #fff; border: 0; border-radius: var(--radius-m);
  padding: 10px 20px; font-size: 13.8px; font-weight: 600; cursor: pointer;
  font-family: var(--font-sans); box-shadow: var(--shadow-1);
  transition: background .12s ease;
}
.btn-primary:hover { background: var(--action-hover); }
.btn-primary:disabled { opacity: .65; cursor: progress; }
.btn-ghost {
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border); border-radius: var(--radius-m);
  padding: 7px 14px; font-size: 12.8px; cursor: pointer; font-family: var(--font-sans);
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.page .btn-ghost { color: var(--text-2); }
.btn-mini {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-s); padding: 5px 11px; font-size: 11.8px; cursor: pointer;
  white-space: nowrap; font-family: var(--font-sans);
}
.btn-mini:hover { border-color: var(--action); color: var(--action); }

/* ── KPI / tarjetas de estadísticas ─────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); margin-bottom: var(--space-5); }
.stat-card, .kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-m);
  padding: var(--space-4) var(--space-5);
  display: flex; flex-direction: column; gap: 3px;
  border-top: 3px solid var(--action);
  box-shadow: var(--shadow-1);
}
.stat-card.warn, .kpi-card.warn { border-top-color: var(--warn); }
.stat-card.bad, .kpi-card.bad { border-top-color: var(--danger); background: linear-gradient(var(--surface), var(--surface)) , var(--danger-bg); }
.stat-value, .kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat-card.bad .stat-value { color: var(--danger); }
.stat-label, .kpi-label { color: var(--text-2); font-size: 11.8px; letter-spacing: .3px; }
.kpi-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.kpi-head svg { width: 15px; height: 15px; color: var(--text-2); }
.kpi-card.bad .kpi-head svg { color: var(--danger); }

/* ── Paneles y tablas ───────────────────────────────────── */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-m);
  padding: var(--space-5); margin-bottom: var(--space-5); box-shadow: var(--shadow-1);
}
.panel-title { margin: 0 0 var(--space-3); font-size: 15px; font-weight: 600; }
.panel-link { display: inline-block; margin-top: var(--space-3); font-size: 13px; }
.two-col { display: grid; grid-template-columns: 5fr 7fr; gap: var(--space-5); align-items: start; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  background: var(--table-head); color: #fff; text-align: left; padding: 10px 12px;
  font-size: 11.3px; letter-spacing: .6px; text-transform: uppercase; font-weight: 600;
  position: sticky; top: 0;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); }
.table tbody tr:nth-child(even) { background: var(--stripe); }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: center; font-variant-numeric: tabular-nums; }
.bad-text { color: var(--danger); font-weight: 700; }
.code-link { font-family: var(--font-mono); font-weight: 700; text-decoration: none; color: var(--cyan); }
.code-link:hover { text-decoration: underline; }
tr.row-critical { background: var(--danger-bg) !important; }

/* ── Fichas del expediente ──────────────────────────────── */
.facts { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0; }
.facts dt { color: var(--text-2); font-size: 12.3px; }
.facts dd { margin: 0; font-size: 14px; }

/* ── Timeline ───────────────────────────────────────────── */
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 var(--space-4) 14px; }
.timeline li::before {
  content: ""; position: absolute; left: -24px; top: 5px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--cyan); border: 2px solid var(--bg-sidebar);
}
.tl-when { color: var(--text-2); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.tl-what { font-size: 13.8px; }
.tl-src {
  display: inline-block; font-size: 10.5px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius-s); padding: 1px 7px; margin-top: 3px;
}

/* ── Notificaciones ─────────────────────────────────────── */
.notif {
  display: flex; align-items: flex-start; gap: 12px; padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-soft); border-radius: var(--radius-m);
  margin-bottom: var(--space-2); background: var(--surface);
}
.notif.read { opacity: .55; }
.notif.critical { border-left: 4px solid var(--danger); background: var(--danger-bg); }
.notif.high { border-left: 4px solid var(--warn); background: var(--warn-bg); }
.notif.medium { border-left: 4px solid var(--cyan); }
.notif.low { border-left: 4px solid var(--border); }
.notif-body { flex: 1; }
.notif-msg { font-size: 13.8px; }
.notif-meta { color: var(--text-2); font-size: 11.5px; margin-top: 2px; }
.notif form { margin: 0; }

/* ── Chips / estados ────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: var(--radius-pill); padding: 2px 10px;
  font-size: 10.8px; font-weight: 700; letter-spacing: .5px; white-space: nowrap;
  border: 1px solid transparent;
}
.sev-critical { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.sev-high { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.sev-medium { background: var(--warn-bg); color: var(--warn); }
.sev-low, .sev-none { background: var(--surface-2); color: var(--text-2); }
.sev-attention { background: var(--warn-bg); color: var(--warn); }
.sev-urgent { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.sev-open { background: var(--warn-bg); color: var(--warn); }
.st-interned { background: var(--ok-bg); color: var(--ok); }
.st-released { background: var(--surface-2); color: var(--text-2); }
.st-transferred { background: var(--info-bg); color: var(--info); }

.searchbar svg { width: 16px; height: 16px; align-self: center; margin-left: 10px; color: var(--text-2); flex: 0 0 auto; }
.hero-ic { width: 26px !important; height: 26px !important; }
.soon-badge svg { width: 12px; height: 12px; }
.pass-toggle .icon-eye-on { display: none; }
.pass-toggle.showing .icon-eye-on { display: block; }
.pass-toggle.showing .icon-eye-off { display: none; }

/* ── Búsqueda y formularios ─────────────────────────────── */
.searchbar { display: flex; gap: var(--space-3); margin-bottom: var(--space-4); }
.searchbar input[type="search"], .field input, .field select {
  flex: 1; width: 100%; max-width: 540px; padding: 10px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-m); font-size: 14px;
  font-family: var(--font-sans);
}
.searchbar input:focus, .field input:focus, .field select:focus {
  outline: 2px solid var(--focus-ring); outline-offset: 0; border-color: var(--focus-ring);
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text); }

.flash {
  background: var(--ok-bg); border: 1px solid var(--ok); color: var(--ok);
  border-radius: var(--radius-m); padding: 10px 14px; margin-bottom: var(--space-4); font-size: 13.5px;
}
.flash.error { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }

/* ── Login institucional premium ────────────────────────── */
.login-wrap { display: grid; grid-template-columns: minmax(380px, 5fr) 7fr; min-height: calc(100vh - 90px); }
.login-institutional {
  position: relative; overflow: hidden;
  background:
    radial-gradient(ellipse 90% 60% at 85% -10%, rgba(59, 130, 246, .28), transparent 60%),
    radial-gradient(ellipse 70% 55% at -10% 110%, rgba(34, 193, 214, .18), transparent 55%),
    linear-gradient(160deg, #0D1B31 0%, #0B1526 55%, #0A1730 100%);
  color: #F1F5FA;
  padding: var(--space-8) var(--space-7);
  display: flex; flex-direction: column; justify-content: space-between;
}
.login-institutional::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(241, 245, 250, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(241, 245, 250, .045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 75% 65% at 30% 40%, #000 30%, transparent 75%);
}
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-brand .brand-mark { width: 52px; height: 52px; }
.login-hero h1 { font-size: 34px; margin: 0 0 6px; letter-spacing: 3px; font-weight: 700; }
.login-hero .system-name { font-size: 16px; color: #A8B8CC; margin: 0 0 var(--space-4); font-weight: 500; }
.login-hero .institution { font-size: 12px; letter-spacing: 1.2px; text-transform: uppercase; color: #7C92B4; }
.login-message {
  font-size: 15.5px; line-height: 1.65; color: #C9D6E8; max-width: 400px;
  border-left: 3px solid #22C1D6; padding-left: var(--space-4);
}
.login-legal { font-size: 11.5px; color: #7C92B4; line-height: 1.6; max-width: 420px; }
.login-legal strong { color: #A8B8CC; }
.login-form-side {
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-7) var(--space-6); background: var(--bg);
}
.login-card { width: 100%; max-width: 420px; }
.login-card h2 { font-size: 21px; margin: 0 0 4px; font-weight: 700; }
.login-card .login-sub { color: var(--text-2); font-size: 13px; margin: 0 0 var(--space-5); }
.login-card form { display: flex; flex-direction: column; gap: var(--space-4); }
.login-card .btn-primary { width: 100%; padding: 12px; font-size: 14.5px; margin-top: var(--space-2); }
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 46px; }
.pass-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: 0; color: var(--text-2); cursor: pointer;
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-s);
}
.pass-toggle:hover { color: var(--text); background: var(--surface-2); }
.pass-toggle svg { width: 17px; height: 17px; }
.login-version { margin-top: var(--space-5); font-size: 11px; color: var(--text-2); text-align: center; }
.login-error {
  background: var(--danger-bg); border: 1px solid var(--danger); color: var(--danger);
  border-radius: var(--radius-m); padding: 10px 14px; font-size: 13px; margin-bottom: var(--space-4);
}

@media (max-width: 880px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-institutional { padding: var(--space-6); }
  .login-hero h1 { font-size: 26px; }
  .login-institutional .login-message { display: none; }
}

/* ── Secciones (dominios próximos) ──────────────────────── */
.section-hero { padding: var(--space-6) var(--space-7); }
.section-intro { font-size: 15px; line-height: 1.65; margin: 0 0 var(--space-4); }
.section-points { margin: 0 0 var(--space-5); padding-left: 20px; }
.section-points li { margin-bottom: 8px; font-size: 14px; }
.soon-badge {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px dashed var(--border);
  color: var(--text-2); font-size: 11.5px; font-weight: 600; letter-spacing: .8px;
  border-radius: var(--radius-pill); padding: 5px 14px; text-transform: uppercase;
}
.soon-badge svg { width: 13px; height: 13px; }

/* ── Tablero estilo command (KPIs + mapa + ranking) ─────── */
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); flex-wrap: wrap; }
.dash-head-pills { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.dash-head .chip svg { width: 11px; height: 11px; }

.kpi2-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); margin-bottom: var(--space-5); }
.kpi2 {
  position: relative;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-m);
  padding: var(--space-4) var(--space-5) var(--space-5);
  box-shadow: var(--shadow-1); overflow: hidden;
}
.kpi2::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--action);
}
.kpi2.bad::before { background: var(--danger); }
.kpi2-icon {
  position: absolute; top: var(--space-4); right: var(--space-4);
  width: 34px; height: 34px; border-radius: var(--radius-m);
  background: var(--surface-2); border: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: center; color: var(--cyan);
}
.kpi2.bad .kpi2-icon { color: var(--danger); }
.kpi2-icon svg { width: 17px; height: 17px; }
.kpi2-value { font-size: 31px; font-weight: 700; letter-spacing: -.02em; line-height: 1.05; margin-top: var(--space-2); }
.kpi2.bad .kpi2-value { color: var(--danger); }
.kpi2-label { color: var(--text); font-size: 13px; font-weight: 600; margin-top: 2px; }
.kpi2-sub { color: var(--text-2); font-size: 11.5px; margin-top: 3px; }

.dash-main { display: grid; grid-template-columns: 7fr 5fr; gap: var(--space-5); align-items: start; margin-bottom: var(--space-5); }
.dash-side { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.dash-side .panel { margin-bottom: var(--space-4); }

/* Mapa */
.map-card { padding-bottom: var(--space-4); }
.map-wrap {
  position: relative; border-radius: var(--radius-m); overflow: hidden;
  background: #0A1628; border: 1px solid var(--border);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04), var(--shadow-2);
}
.map-wrap img { display: block; width: 100%; height: auto; opacity: .92; }
.map-wrap::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  border-radius: var(--radius-m);
  background: linear-gradient(135deg, rgba(11,21,38,.18) 0%, transparent 40%, transparent 60%, rgba(34,193,214,.06) 100%);
}
.map-dot {
  position: absolute; transform: translate(-50%, -50%);
  border-radius: 50%; background: var(--action);
  border: 1.5px solid rgba(255, 255, 255, .85);
  box-shadow: 0 0 0 1px rgba(11, 21, 38, .25), var(--shadow-1);
  box-sizing: border-box;
}
.map-dot.s { width: 7px; height: 7px; background: var(--text-2); }
.map-dot.m { width: 10px; height: 10px; }
.map-dot.l { width: 14px; height: 14px; }
.map-dot.xl { width: 18px; height: 18px; background: var(--cyan); }
.map-dot.sel { box-shadow: 0 0 0 3px var(--accent), var(--shadow-2); z-index: 2; }
.map-legend {
  display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap;
  padding-top: var(--space-3); font-size: 11.5px; color: var(--text-2);
}
.map-legend .legend-title { font-weight: 700; letter-spacing: .4px; text-transform: uppercase; font-size: 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item .map-dot { position: static; transform: none; }

/* Ranking */
.rank-list {
  list-style: none; margin: 0; padding: 0;
  max-height: 340px; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
  padding-right: 6px;
}
.rank-list::-webkit-scrollbar { width: 6px; }
.rank-list::-webkit-scrollbar-track { background: transparent; }
.rank-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.rank-list::-webkit-scrollbar-thumb:hover { background: var(--cyan); }
.rank-row { display: grid; grid-template-columns: 44px 1fr 42px; gap: 10px; align-items: center; padding: 5px 0; }
.rank-row:hover { background: var(--surface-2); border-radius: var(--radius-s); }
.rank-code { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--cyan); }
.rank-bar-area { background: var(--surface-2); border-radius: var(--radius-s); height: 14px; overflow: hidden; border: 1px solid var(--border-soft); }
.rank-bar { display: block; height: 100%; background: linear-gradient(90deg, var(--action), var(--cyan)); border-radius: var(--radius-s); }
.rank-value { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13px; text-align: right; }

/* Tabla plegable */
.details-card summary {
  cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--text-2);
  padding-bottom: var(--space-2); user-select: none;
}
.details-card summary:hover { color: var(--text); }
.details-card[open] summary { color: var(--text); margin-bottom: var(--space-3); }
.table-wrap { overflow-x: auto; }

@media (max-width: 1280px) { .kpi2-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 1100px) { .dash-main { grid-template-columns: 1fr; } }

/* ── Varios ─────────────────────────────────────────────── */
.quick { list-style: none; margin: 0; padding: 0; }
.quick li { padding: 9px 0; border-bottom: 1px solid var(--border-soft); display: flex; flex-direction: column; }
.quick li:last-child { border-bottom: 0; }
.quick a { font-weight: 600; text-decoration: none; }
.quick span { color: var(--text-2); font-size: 12.3px; }
.empty-state {
  text-align: center; padding: var(--space-7) var(--space-4); color: var(--text-2);
}
.empty-state svg { width: 34px; height: 34px; opacity: .5; margin-bottom: var(--space-2); }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1280px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1100px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; display: none; }
  body.sidebar-open .sidebar { display: block; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .page { padding: var(--space-5) var(--space-4) var(--space-7); }
  .topbar-inner { padding: 0 var(--space-4); gap: var(--space-2); }
  .user-meta { display: none; }
  .table { font-size: 12.5px; }
  .table th, .table td { padding: 8px 8px; }
  .centerbar-label { display: none; }
}

/* Formularios operativos (consultas, signos vitales) */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 12px; margin-top: 10px; }
.form-grid .field.wide { grid-column: 1 / -1; }
.form-grid textarea { font: inherit; font-size: 12.5px; padding: 7px 10px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 6px; min-height: 54px; resize: vertical; }

/* Odontograma (FDI) */
.odontogram { background: var(--bg-inset, #0A1628); border: 1px solid var(--border); border-radius: 10px; padding: 14px 10px; margin-top: 10px; }
.od-arch { display: flex; flex-direction: column; gap: 6px; }
.od-arch + .od-arch { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 10px; }
.od-arch-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.od-arch-teeth { display: flex; justify-content: center; gap: 26px; }
.od-half { display: flex; gap: 3px; }
.tooth-btn { position: relative; min-width: 34px; height: 34px; border-radius: 7px 7px 10px 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 11px; font-weight: 600; cursor: pointer; }
.tooth-btn:hover { border-color: var(--cyan); }
.tooth-btn.t-caries { background: #7f1d1d; color: #fecaca; }
.tooth-btn.t-rest { background: #1e3a8a; color: #bfdbfe; }
.tooth-btn.t-endo { background: #4c1d95; color: #ddd6fe; }
.tooth-btn.t-crown { background: #78350f; color: #fde68a; }
.tooth-btn.t-impl { background: #134e4a; color: #99f6e4; }
.tooth-btn.t-frac { background: #7c2d12; color: #fed7aa; }
.tooth-btn.t-exind { border: 2px dashed #f87171; color: #f87171; }
.tooth-btn.t-prost { background: #155e75; color: #a5f3fc; }
.tooth-btn.t-missing { background: #2a2f3a; color: #6b7280; text-decoration: line-through; }
.tooth-btn.t-obs { border-color: var(--cyan); }
.tooth-btn .t-badge { position: absolute; top: -6px; right: -6px; background: var(--cyan); color: #06202c; border-radius: 8px; font-size: 9px; padding: 0 4px; }
.tooth-btn.mini { min-width: 18px; height: 18px; font-size: 0; vertical-align: middle; margin-right: 2px; cursor: default; }
.od-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: 11px; }
.od-legend span { display: inline-flex; align-items: center; }
.odonto-toolbar { display: flex; gap: 12px; align-items: center; }

/* Mapa interactivo (zoom + arrastre + emergente de centro) */
.map-viewport { position: relative; overflow: hidden; border-radius: 10px; background: #0A1628; border: 1px solid var(--border); cursor: grab; touch-action: none; user-select: none; width: 100%; aspect-ratio: 1090 / 676; }
.map-viewport:active { cursor: grabbing; }
.map-canvas { position: absolute; inset: 0; transform-origin: 0 0; }
.map-canvas img { width: 100%; height: 100%; object-fit: cover; opacity: .92; pointer-events: none; }
.map-canvas .map-dot { transform: translate(-50%, -50%) scale(var(--iz, 1)); position: absolute; }
.map-canvas .map-label { display: none; position: absolute; transform: translate(8px, -50%) scale(var(--iz, 1)); font-size: 10px; font-weight: 700; color: var(--cyan); text-shadow: 0 1px 2px #000; pointer-events: none; }
.map-canvas.zoomed .map-label { display: block; }
.map-controls { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 5px; z-index: 5; }
.map-controls button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 16px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow-2, 0 2px 8px rgba(0,0,0,.4)); }
.map-controls button:hover { border-color: var(--cyan); color: var(--cyan); }
.map-popup { position: absolute; z-index: 6; display: flex; gap: 10px; width: 300px; padding: 10px; background: var(--elevated, #20334F); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.map-popup[hidden] { display: none; }
.map-popup-photo { flex: 0 0 110px; height: 84px; border-radius: 8px; overflow: hidden; background: var(--surface); }
.map-popup-photo img { width: 100%; height: 100%; object-fit: cover; }
.map-photo-pending { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 10px; color: var(--muted); border: 1px dashed var(--border); border-radius: 8px; padding: 4px; }
.map-popup-body { flex: 1; font-size: 12.5px; }
.map-popup-body strong { display: block; margin-bottom: 2px; }
.map-popup-close { position: absolute; top: 4px; right: 6px; background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer; }

/* ── Ficha de ingreso: pestañas por departamento ─────────────────────── */
.ficha { display: flex; flex-direction: column; gap: 0; }
.ficha-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); background: var(--surface-2); border-radius: var(--radius-m) var(--radius-m) 0 0; }
.ficha-head .field { min-width: 170px; flex: 1; }
.ficha-tabs { display: flex; gap: 4px; overflow-x: auto; padding: 8px 10px 0; border-bottom: 1px solid var(--border-soft); scrollbar-width: thin; }
.ficha-tab { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; padding: 8px 13px 9px; border: 1px solid transparent; border-bottom: none; border-radius: 9px 9px 0 0; background: transparent; color: var(--text-2); font: inherit; font-size: 12.3px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.ficha-tab:hover { color: var(--text); background: var(--surface-2); }
.ficha-tab.active { background: var(--surface); border-color: var(--border-soft); color: var(--text); position: relative; }
.ficha-tab.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--cyan); border-radius: 2px; }
.ficha-tab .tab-dept { font-size: 10px; font-weight: 500; color: var(--muted); letter-spacing: .3px; text-transform: uppercase; }
.ficha-tab .tab-num { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; margin-right: 5px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); font-size: 10px; color: var(--text-2); vertical-align: 1px; }
.ficha-tab.active .tab-num { background: var(--cyan); border-color: var(--cyan); color: #06202c; }
.ficha-tab .tab-dot { display: none; width: 7px; height: 7px; border-radius: 50%; background: #34d399; }
.ficha-tab.done .tab-dot { display: inline-block; }
.tab-pane { padding: 14px; }
.tab-pane[hidden] { display: none; }
.tab-pane .pane-hint { margin: 0 0 4px; font-size: 11.8px; color: var(--text-2); }
.tab-actions { display: flex; gap: 8px; justify-content: space-between; align-items: center; padding: 12px 14px; border-top: 1px solid var(--border-soft); background: var(--surface-2); border-radius: 0 0 var(--radius-m) var(--radius-m); }

/* Fotos de la ficha: ranuras con vista previa */
.photo-slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 10px; }
.photo-slot { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px dashed var(--border); border-radius: 10px; text-align: center; }
.photo-slot.has-photo { border-style: solid; border-color: var(--cyan); }
.photo-slot .slot-label { font-size: 11px; font-weight: 700; color: var(--text); letter-spacing: .3px; }
.photo-slot img.preview { width: 100%; height: 120px; object-fit: cover; border-radius: 7px; border: 1px solid var(--border); }
.photo-slot .slot-empty { height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 1px dashed var(--border); border-radius: 7px; color: var(--muted); font-size: 10.5px; }
.photo-slot input[type="file"] { display: none; }
.photo-slot .slot-btns { display: flex; gap: 6px; justify-content: center; }
.photo-slot .slot-btns button { font-size: 11px; padding: 3px 9px; }

/* Rejilla dactilar (10 dedos, AFIS) */
.fp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin-top: 10px; }
.fp-hand { grid-column: 1 / -1; font-size: 10.5px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.fp-slot { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; transition: border-color .15s; }
.fp-slot:hover { border-color: var(--cyan); }
.fp-slot.captured { border-color: #34d399; }
.fp-finger { width: 34px; height: 42px; color: var(--text-2); }
.fp-slot.captured .fp-finger { color: #34d399; }
.fp-name { font-size: 10.5px; color: var(--text-2); text-align: center; line-height: 1.15; }
.fp-state { font-size: 9.5px; font-weight: 700; letter-spacing: .4px; color: var(--muted); text-transform: uppercase; }
.fp-slot.captured .fp-state { color: #34d399; }
.fp-grid input[type="file"] { display: none; }

/* Lienzo de firmas del acta */
.sig-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
@media (max-width: 720px) { .sig-row { grid-template-columns: 1fr; } }
.sig-box { display: flex; flex-direction: column; gap: 5px; }
.sig-box label { font-size: 12.5px; font-weight: 600; }
.sig-pad { width: 100%; height: 110px; background: #fff; border: 1px solid var(--border); border-radius: 8px; cursor: crosshair; touch-action: none; }
.sig-box .sig-btns { display: flex; gap: 6px; }
.sig-box .sig-btns button { font-size: 11px; padding: 3px 9px; }

/* Selección de delitos del catálogo */
.crime-picker { border: 1px solid var(--border); border-radius: 10px; margin-top: 8px; overflow: hidden; }
.crime-search { width: 100%; padding: 8px 12px; border: none; border-bottom: 1px solid var(--border-soft); background: var(--surface); color: var(--text); font: inherit; font-size: 12.5px; }
.crime-list { max-height: 240px; overflow-y: auto; padding: 8px 12px; }
.crime-cat { font-size: 10.5px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--cyan); margin: 10px 0 4px; }
.crime-cat:first-child { margin-top: 0; }
.crime-opt { display: flex; align-items: center; gap: 7px; padding: 3px 2px; font-size: 12.3px; color: var(--text); }
.crime-opt input { accent-color: var(--cyan); }
.crime-opt .ref { color: var(--muted); font-size: 10.5px; }
.chip-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chip-item { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 11.5px; }
.chip-item button { background: none; border: none; color: var(--text-2); cursor: pointer; font-size: 13px; line-height: 1; padding: 0; }
.chip-item button:hover { color: #e11d48; }

/* Filas dinámicas (señas, pertenencias, fotos extra) */
.dyn-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.dyn-row { display: grid; grid-template-columns: minmax(110px, 170px) minmax(140px, 1fr) 74px minmax(120px, 170fr) 30px; gap: 6px; align-items: center; }
.dyn-row input, .dyn-row select { font: inherit; font-size: 12.3px; padding: 6px 9px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 6px; min-width: 0; }
.dyn-row .dyn-del { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; font-size: 14px; }
.dyn-row .dyn-del:hover { color: #e11d48; border-color: #e11d48; }
.dyn-add { align-self: flex-start; margin-top: 2px; }
.dyn-row.mark-row { grid-template-columns: minmax(130px, 170px) minmax(200px, 1fr) 150px 30px; }
.dyn-row.photo-row { grid-template-columns: minmax(130px, 160px) minmax(180px, 1fr) minmax(120px, 1fr) 30px; }
.dyn-row input[type="file"] { font-size: 11px; }

/* Ficha de ingreso (vista) */
.ficha-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.ficha-photo-hero { width: 132px; height: 160px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); }
.ficha-gallery { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ficha-gallery figure { margin: 0; text-align: center; }
.ficha-gallery img { width: 118px; height: 118px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.ficha-gallery figcaption { font-size: 10px; color: var(--text-2); margin-top: 3px; max-width: 118px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ficha-gallery img.sig { background: #fff; width: 150px; height: 70px; object-fit: contain; }
.fp-mini { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin-top: 8px; }
.fp-mini span { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 8.6px; color: var(--text-2); text-align: center; }
.fp-mini .ok { width: 100%; padding: 4px 0; border-radius: 6px; border: 1px solid #34d399; color: #34d399; }
.fp-mini .miss { width: 100%; padding: 4px 0; border-radius: 6px; border: 1px dashed var(--border); color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 18px; margin-top: 8px; }
.detail-grid > div { font-size: 12.6px; }
.detail-grid dt { font-size: 10.6px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.detail-grid dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.module-title { display: flex; align-items: center; gap: 8px; margin: 16px 0 2px; font-size: 13px; }
.module-title:first-child { margin-top: 4px; }
.module-title .dept-chip { font-size: 9.8px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--cyan) 40%, var(--border)); color: var(--cyan); }

/* ── Detalle de centro (vista de decisión) ──────────────────────────── */
.center-hero { display: flex; gap: 22px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.occ-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.occ-label { font-size: 10.5px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); }
.occ-figure { font-size: 22px; font-weight: 800; letter-spacing: .3px; }
.occ-ok { color: #34d399; } .occ-warn { color: #fbbf24; } .occ-high, .occ-crit { color: #f87171; } .occ-na { color: var(--text); }
.gauge { position: relative; height: 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border-soft); overflow: hidden; }
.gauge-fill { display: block; height: 100%; border-radius: 999px; transition: width .4s; }
.g-ok { background: linear-gradient(90deg, #059669, #34d399); }
.g-warn { background: linear-gradient(90deg, #b45309, #fbbf24); }
.g-high { background: linear-gradient(90deg, #b91c1c, #f97316); }
.g-crit { background: linear-gradient(90deg, #7f1d1d, #ef4444); }
.g-na { background: var(--border); }
.statbars { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.statbar { display: grid; grid-template-columns: minmax(130px, 220px) 1fr 64px; gap: 10px; align-items: center; font-size: 12.6px; }
.sb-label { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-track { height: 10px; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 999px; overflow: hidden; }
.sb-fill { display: block; height: 100%; border-radius: 999px; }
.sb-ok { background: linear-gradient(90deg, #059669, #34d399); }
.sb-info { background: linear-gradient(90deg, #0e7490, #22c1d6); }
.sb-crit { background: linear-gradient(90deg, #9f1239, #fb7185); }
.sb-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.minichart { display: flex; gap: 10px; align-items: flex-end; margin-top: 12px; min-height: 110px; }
.mini-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; height: 100%; }
.mini-bar { width: 70%; max-width: 46px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, #22c1d6, #0e7490); }
.mini-val { font-size: 10.5px; font-weight: 700; color: var(--text); }
.mini-lab { font-size: 9.5px; color: var(--muted); }

/* Tarjetas y filas de ranking cliclables */
a.kpi2 { text-decoration: none; color: inherit; transition: transform .12s, border-color .12s; cursor: pointer; }
a.kpi2:hover { transform: translateY(-2px); border-color: var(--cyan); }
a.rank-row { text-decoration: none; color: inherit; cursor: pointer; }
a.rank-row:hover .rank-code { color: var(--action); }
a.statbar { text-decoration: none; color: inherit; cursor: pointer; border-radius: 8px; padding: 3px 5px; margin: 0 -5px; transition: background .12s; }
a.statbar:hover { background: var(--surface-2); }
a.statbar:hover .sb-label { color: var(--cyan); }
a.statbar:hover .sb-track { border-color: var(--cyan); }
.drill-panel { border: 1px solid color-mix(in srgb, var(--cyan) 35%, var(--border)); background: color-mix(in srgb, var(--cyan) 4%, var(--surface)); }

/* ── Ficha de ingreso v2: riel de módulos + cuadrícula ──────────────── */
.ficha-panel { padding: 0; overflow: hidden; }
.ficha-head { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border-soft); background: var(--surface-2); }
.ficha-head .field.wide { grid-column: 1 / -1; }
.ficha-body { display: grid; grid-template-columns: 256px minmax(0, 1fr); }
.module-rail { border-right: 1px solid var(--border-soft); background: var(--surface-2); padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; }
.module-step { display: flex; gap: 10px; align-items: center; width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text-2); font: inherit; cursor: pointer; text-align: left; position: relative; }
.module-step:hover { background: var(--surface); color: var(--text); }
.module-step.active { background: var(--surface); border-color: var(--border-soft); color: var(--text); box-shadow: 0 1px 6px rgba(0,0,0,.12); }
.module-step.active::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--cyan); }
.module-step .step-num { flex: 0 0 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; font-weight: 700; color: var(--text-2); }
.module-step.active .step-num { background: var(--cyan); border-color: var(--cyan); color: #06202c; }
.module-step .step-txt strong { display: block; font-size: 12.9px; line-height: 1.25; }
.module-step .step-txt small { display: block; font-size: 9.8px; color: var(--muted); letter-spacing: .3px; text-transform: uppercase; margin-top: 2px; }
.module-step .step-dot { display: none; width: 8px; height: 8px; border-radius: 50%; background: #34d399; margin-left: auto; flex: 0 0 8px; }
.module-step.done .step-dot { display: block; }
.module-panes { display: flex; flex-direction: column; min-width: 0; }
.module-panes .tab-pane { padding: 16px 18px 6px; flex: 1; }
.module-panes .tab-actions { margin-top: auto; }
.pane-grid { grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px 14px; }
.orders-details { margin-top: 12px; }
.orders-details summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text-2); padding: 4px 0; }
.orders-details[open] summary { margin-bottom: 6px; }
.edit-banner { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.amend-card { border: 1px solid var(--border-soft); border-radius: 10px; padding: 12px 14px; margin-top: 10px; background: var(--surface); }
.amend-card.amend-pending { border-color: color-mix(in srgb, #f59e0b 45%, var(--border)); background: color-mix(in srgb, #f59e0b 6%, var(--surface)); }
@media (max-width: 920px) {
  .ficha-body { grid-template-columns: 1fr; }
  .module-rail { flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border-soft); }
  .module-step { width: auto; white-space: nowrap; padding: 9px 12px; }
  .module-step .step-txt small { display: none; }
  .module-step.active::before { top: auto; bottom: 0; left: 9px; right: 9px; width: auto; height: 3px; }
}

/* Bitácora de accesos */
.section-title { font-size: 15px; font-weight: 700; margin: 22px 0 10px; letter-spacing: .02em; }
.nowrap { white-space: nowrap; }
.clip-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip-cell.ua { max-width: 260px; font-size: 11.5px; color: var(--text-2); }
.filter-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.small-note { font-size: 11.5px; margin-top: 14px; line-height: 1.5; }

/* Desconexión remota (P2-4): formulario en línea dentro de la fila. */
.inline-form {
    display: inline;
    margin-inline-start: 6px;
}

.ledger-alert {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    align-items: baseline;
    padding: 12px 16px;
    margin-bottom: 14px;
}

.ledger-alert code {
    background: var(--surface-2);
    padding: 1px 6px;
    border-radius: 4px;
}

/* ===== Identificación física del expediente (juego fotográfico + fisonomía + croquis) ===== */
.id-section { display: grid; grid-template-columns: minmax(300px, 380px) minmax(300px, 1fr) minmax(320px, 460px); gap: 22px; align-items: start; }
@media (max-width: 1280px) { .id-section { grid-template-columns: 1fr 1fr; } }
@media (max-width: 900px) { .id-section { grid-template-columns: 1fr; } }
.id-sub { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent, #3B82F6); margin: 2px 0 10px; }
.id-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.id-slot { border: 1px solid var(--border, #26364F); border-radius: 10px; padding: 8px; background: var(--surface, #17263D); }
.id-slot img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; display: block; }
.id-slot-empty { aspect-ratio: 3 / 4; border: 1.5px dashed var(--border, #26364F); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 10.5px; text-align: center; padding: 6px; }
.id-slot-label { font-size: 11px; margin-top: 6px; font-weight: 600; }
.id-slot-form { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
.id-file { font-size: 10.5px; max-width: 150px; }
.btn-mini { background: var(--accent, #3B82F6); border: none; color: #fff; border-radius: 6px; padding: 4px 10px; font-size: 11px; cursor: pointer; white-space: nowrap; }
.fisio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px 14px; margin: 0; }
.fisio-cell dt { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.fisio-cell dd { margin: 2px 0 0; font-weight: 600; font-size: 13px; }
.id-details { margin-top: 12px; border: 1px solid var(--border, #26364F); border-radius: 10px; padding: 10px 12px; background: var(--surface-2, #20334F); }
.id-details summary { cursor: pointer; font-weight: 600; font-size: 12.5px; }
.id-marks-wrap { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.croquis { display: flex; gap: 14px; }
.croquis-fig { text-align: center; }
.croquis-label { font-size: 10.5px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: .05em; }
.mark-list { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 8px; }
.mark-row { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border, #26364F); border-radius: 10px; padding: 8px 10px; background: var(--surface, #17263D); }
.mark-num { background: #EF4444; color: #fff; border-radius: 50%; min-width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.mark-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
