/* =========================================================
   Interoperabilidad MARN — portal de administración
   Paleta: azul naval, azul acero metalizado, cobalto y blanco
   ========================================================= */

:root {
  /* Superficies */
  --page: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f5f8fb;
  --line: #d6dfea;
  --line-strong: #b9c7d8;

  /* Texto */
  --ink: #0f2340;
  --ink-2: #3a5372;
  --muted: #64809f;

  /* Azules */
  --cobalt: #1f5fd1;
  --cobalt-hover: #184fb3;
  --cobalt-soft: #e3ecfb;
  --steel: #4f6f93;
  --focus: #3b82f6;

  /* Metal: barra lateral y acentos cepillados */
  --metal: linear-gradient(165deg, #2a4b78 0%, #37608f 38%, #23426c 62%, #1a3357 100%);
  --metal-sheen: linear-gradient(100deg, rgba(255,255,255,0) 30%, rgba(255,255,255,.10) 48%, rgba(255,255,255,0) 66%);
  --metal-edge: rgba(255,255,255,.18);
  --steel-btn: linear-gradient(180deg, #e9eff6 0%, #cfdae7 100%);
  --steel-btn-ink: #1b3557;

  /* Estados del dictamen */
  --ok: #0f7a5c;      --ok-soft: #dcf3ea;
  --warn: #9a5b00;    --warn-soft: #fbefd8;
  --closed: #4f6176;  --closed-soft: #e5eaf0;
  --danger: #c0352b;  --danger-soft: #fbe5e3;

  --shadow-1: 0 1px 2px rgba(15,35,64,.06), 0 1px 1px rgba(15,35,64,.04);
  --shadow-2: 0 10px 30px -12px rgba(15,35,64,.35);

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

  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sidebar-w: 252px;

  color-scheme: light;
}

/* Tokens del modo oscuro (sistema o elección manual) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0a1526;
    --surface: #10203a;
    --surface-2: #142744;
    --line: #213a5e;
    --line-strong: #2e4c76;
    --ink: #e7eef8;
    --ink-2: #b4c5db;
    --muted: #8aa1bf;
    --cobalt: #5b9bff;
    --cobalt-hover: #7cb0ff;
    --cobalt-soft: #16305a;
    --steel: #8fb0d6;
    --metal: linear-gradient(165deg, #142a4a 0%, #1d3b64 40%, #132848 64%, #0d1e38 100%);
    --metal-edge: rgba(160,195,240,.14);
    --steel-btn: linear-gradient(180deg, #2a4670 0%, #1d3557 100%);
    --steel-btn-ink: #e3ecf8;
    --ok: #4fd1a5;      --ok-soft: #0f3a33;
    --warn: #f3b453;    --warn-soft: #3d2c10;
    --closed: #a9b8ca;  --closed-soft: #1f324d;
    --danger: #ff7b70;  --danger-soft: #45201f;
    --shadow-1: 0 1px 2px rgba(0,0,0,.35);
    --shadow-2: 0 16px 40px -12px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --page: #0a1526;
  --surface: #10203a;
  --surface-2: #142744;
  --line: #213a5e;
  --line-strong: #2e4c76;
  --ink: #e7eef8;
  --ink-2: #b4c5db;
  --muted: #8aa1bf;
  --cobalt: #5b9bff;
  --cobalt-hover: #7cb0ff;
  --cobalt-soft: #16305a;
  --steel: #8fb0d6;
  --metal: linear-gradient(165deg, #142a4a 0%, #1d3b64 40%, #132848 64%, #0d1e38 100%);
  --metal-edge: rgba(160,195,240,.14);
  --steel-btn: linear-gradient(180deg, #2a4670 0%, #1d3557 100%);
  --steel-btn-ink: #e3ecf8;
  --ok: #4fd1a5;      --ok-soft: #0f3a33;
  --warn: #f3b453;    --warn-soft: #3d2c10;
  --closed: #a9b8ca;  --closed-soft: #1f324d;
  --danger: #ff7b70;  --danger-soft: #45201f;
  --shadow-1: 0 1px 2px rgba(0,0,0,.35);
  --shadow-2: 0 16px 40px -12px rgba(0,0,0,.7);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--cobalt); }
h1, h2, h3 { margin: 0; line-height: 1.15; font-stretch: 82%; font-weight: 650; letter-spacing: -.005em; }
p { margin: 0; }
code, .mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .88em; }
.muted { color: var(--muted); }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 14px;
  border: 1px solid transparent; border-radius: var(--radius-s);
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  background: var(--surface); color: var(--ink);
  transition: background-color .15s, border-color .15s, color .15s;
  white-space: nowrap; text-decoration: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--cobalt); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--cobalt-hover); }
:root[data-theme="dark"] .btn-primary, :root[data-theme="dark"] .btn-danger { color: #06152c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary, :root:not([data-theme="light"]) .btn-danger { color: #06152c; } }
.btn-secondary { border-color: var(--line-strong); background: var(--surface); }
.btn-secondary:hover:not(:disabled) { border-color: var(--steel); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.92); }
.btn-steel {
  background: var(--steel-btn); color: var(--steel-btn-ink);
  border-color: rgba(255,255,255,.35);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 1px 2px rgba(0,0,0,.2);
}
.btn-block { width: 100%; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid transparent; border-radius: var(--radius-s);
  background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.login-brand {
  position: relative; overflow: hidden;
  background: var(--metal); color: #eaf1fa;
  padding: clamp(32px, 6vw, 80px);
  display: flex; flex-direction: column; justify-content: center; gap: 22px;
}
.login-brand::after { content: ""; position: absolute; inset: 0; background: var(--metal-sheen); pointer-events: none; }
.login-title { font-size: clamp(34px, 5vw, 58px); font-stretch: 70%; font-weight: 700; max-width: 12ch; line-height: 1.02; }
.login-lead { font-size: 18px; max-width: 42ch; color: #c7d6ea; }
.login-flow { list-style: none; counter-reset: s; padding: 0; margin: 12px 0 0; display: grid; gap: 0; max-width: 46ch; }
.login-flow li {
  counter-increment: s; position: relative; padding: 12px 0 12px 44px; color: #c7d6ea;
  border-top: 1px solid var(--metal-edge);
}
.login-flow li::before {
  content: counter(s); position: absolute; left: 0; top: 11px;
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #1a3357; background: linear-gradient(180deg, #f2f6fb, #b9cadf);
}
.login-flow strong { color: #fff; font-weight: 600; }
.login-form {
  display: flex; flex-direction: column; justify-content: center; gap: 16px;
  padding: clamp(28px, 6vw, 72px); max-width: 520px; width: 100%; margin: 0 auto;
}
.login-form h2 { font-size: 30px; }
.hint { font-size: 13px; color: var(--muted); }
.theme-toggle-login { align-self: flex-start; }

/* ---------- Estructura ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--metal); color: #dbe6f3;
  border-right: 1px solid var(--metal-edge);
  isolation: isolate;
}
.sidebar::before { content: ""; position: absolute; inset: 0; background: var(--metal-sheen); z-index: -1; pointer-events: none; }
.sidebar-head { display: flex; align-items: center; gap: 12px; padding: 20px 18px 18px; border-bottom: 1px solid var(--metal-edge); }
.brand-mark {
  width: 38px; height: 38px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: linear-gradient(180deg, #f4f7fb 0%, #b8c8dc 100%);
  box-shadow: inset 0 1px 0 #fff, 0 2px 6px rgba(0,0,0,.25);
}
.brand-mark svg { width: 24px; height: 24px; fill: none; stroke: #1d3a62; stroke-width: 2.6; stroke-linecap: round; }
.login-brand .brand-mark { width: 52px; height: 52px; border-radius: 12px; }
.login-brand .brand-mark svg { width: 32px; height: 32px; }
.brand-name { font-weight: 700; font-stretch: 78%; font-size: 19px; color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.25); }
.brand-sub { font-size: 12px; color: #a9bfda; }

.nav { flex: 1; overflow-y: auto; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: 12px; color: #93abc9; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 8px;
  color: #d6e2f1; text-decoration: none; font-weight: 500;
  border: 1px solid transparent;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a[aria-current="page"] {
  color: #10294a; font-weight: 650;
  background: linear-gradient(180deg, #f6f9fc 0%, #ccd9e8 100%);
  box-shadow: inset 0 1px 0 #fff, 0 1px 3px rgba(0,0,0,.25);
}
.nav a .count { margin-left: auto; font-size: 12px; padding: 1px 7px; border-radius: 99px; background: rgba(255,255,255,.12); }
.nav a .ext { margin-left: auto; font-size: 11px; color: #93abc9; }
.nav a[aria-current="page"] .count { background: rgba(16,41,74,.12); }
.sidebar-foot { padding: 14px; border-top: 1px solid var(--metal-edge); display: grid; gap: 12px; }
.session-name { font-weight: 600; color: #fff; font-size: 14px; }
.session-scopes { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.session-scopes span { font-size: 11px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--metal-edge); color: #c4d4e8; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  height: 60px; padding: 0 24px;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.menu-btn { display: none; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); min-width: 0; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
.crumbs .i { width: 14px; height: 14px; }
.crumbs .current { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.health-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 99px; font-size: 13px; color: var(--ink-2); background: var(--surface);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: block; }
  :root:not([data-theme="light"]) .i-moon { display: none; }
}

.content { padding: 28px 24px 64px; width: 100%; max-width: 1320px; outline: none; }

/* ---------- Encabezado de página ---------- */
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 32px; font-stretch: 75%; font-weight: 700; }
.page-head p { color: var(--muted); margin-top: 4px; max-width: 70ch; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Paneles ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); box-shadow: var(--shadow-1); }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 18px; }
.panel-head .sub { color: var(--muted); font-size: 13px; }
.panel-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.panel-body { padding: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; }
.stack { display: grid; gap: 18px; }

/* ---------- Flujo de interoperabilidad (pieza central) ---------- */
.flow {
  position: relative; overflow: hidden;
  border-radius: var(--radius-l);
  background: var(--metal); color: #e6eef8;
  padding: 26px 26px 22px;
  border: 1px solid var(--metal-edge);
  isolation: isolate;
}
.flow::before { content: ""; position: absolute; inset: 0; background: var(--metal-sheen); z-index: -1; }
.flow-top { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; margin-bottom: 22px; }
.flow-total { font-size: 64px; line-height: .9; font-weight: 700; font-stretch: 62%; color: #fff; }
.flow-total-label { color: #b9cbe2; max-width: 30ch; }
.flow-top .btn { margin-left: auto; }
.flow-track { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: stretch; gap: 0; }
.flow-node {
  background: rgba(255,255,255,.06); border: 1px solid var(--metal-edge); border-radius: 12px;
  padding: 14px 14px 12px; min-width: 0;
}
.flow-node h3 { font-size: 16px; color: #fff; display: flex; align-items: center; gap: 8px; }
.flow-node .port { font-size: 12px; color: #9fb6d3; margin-top: 2px; }
.flow-node ul { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; font-size: 13px; color: #c7d6ea; }
.flow-node li { display: flex; justify-content: space-between; gap: 8px; }
.flow-node li b { color: #fff; font-weight: 600; }
.flow .dot.ok { box-shadow: 0 0 0 3px rgba(79,209,165,.28); background: #4fd1a5; }
.flow-link { display: grid; place-items: center; width: 70px; position: relative; color: #9fb6d3; font-size: 11px; text-align: center; }
.flow-link::before {
  content: ""; position: absolute; left: 4px; right: 4px; top: 50%; height: 2px;
  background: repeating-linear-gradient(90deg, #9fb6d3 0 6px, transparent 6px 11px);
  opacity: .6;
}
.flow-link.live::before { animation: flowdash 1.2s linear infinite; background: repeating-linear-gradient(90deg, #d8e6f7 0 6px, transparent 6px 11px); opacity: .9; }
.flow-link span { position: relative; background: #24456f; padding: 2px 4px; border-radius: 4px; }
:root[data-theme="dark"] .flow-link span { background: #183356; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .flow-link span { background: #183356; } }
@keyframes flowdash { to { background-position: 11px 0; } }

/* ---------- Barras de distribución ---------- */
.dist { display: grid; gap: 14px; }
.segbar { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.segbar > span { height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend b { color: var(--ink); }
.bars { display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 28px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .lbl { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--steel), var(--cobalt)); }
.bar-row .val { text-align: right; font-weight: 600; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-VIGENTE { color: var(--ok); background: var(--ok-soft); }
.b-EN_ANALISIS { color: var(--warn); background: var(--warn-soft); }
.b-CERRADO { color: var(--closed); background: var(--closed-soft); }
.cat {
  display: inline-grid; place-items: center; min-width: 30px; height: 24px; padding: 0 6px;
  border-radius: 5px; font-weight: 700; font-size: 12.5px;
  color: var(--steel-btn-ink); background: var(--steel-btn);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 0 0 1px var(--line-strong);
}
.chip { display: inline-flex; padding: 1px 8px; border-radius: 99px; font-size: 12px; border: 1px solid var(--line-strong); color: var(--ink-2); background: var(--surface-2); }
.status-code { display: inline-flex; padding: 1px 8px; border-radius: 5px; font-weight: 700; font-size: 12.5px; }
.s2 { color: var(--ok); background: var(--ok-soft); }
.s3 { color: var(--cobalt); background: var(--cobalt-soft); }
.s4 { color: var(--warn); background: var(--warn-soft); }
.s5 { color: var(--danger); background: var(--danger-soft); }

/* ---------- Barra de herramientas ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.search { position: relative; flex: 1 1 260px; max-width: 380px; }
.search .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 36px; }
.toolbar select { width: auto; min-width: 150px; }
.toolbar .spacer { flex: 1; }

/* ---------- Formularios ---------- */
input, select, textarea {
  width: 100%; font: inherit; font-size: 14.5px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  padding: 8px 11px; min-height: 38px;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--cobalt); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cobalt) 22%, transparent); }
.field { display: grid; gap: 6px; font-size: 13.5px; }
.field > span { font-weight: 600; color: var(--ink-2); }
.field .help { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field .err { font-size: 12.5px; color: var(--danger); }
.form-error { color: var(--danger); background: var(--danger-soft); padding: 9px 12px; border-radius: var(--radius-s); font-size: 14px; }
fieldset { border: 0; margin: 0; padding: 0; }
.form-section { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 18px; padding: 18px 0; border-top: 1px solid var(--line); }
.form-section:first-of-type { border-top: 0; padding-top: 4px; }
.form-section legend { float: left; padding: 0; }
.form-section h3 { font-size: 15px; }
.form-section .desc { font-size: 13px; color: var(--muted); margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.checks { display: grid; gap: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; margin: 2px 0 0; accent-color: var(--cobalt); }
.check b { display: block; font-size: 14px; }
.check small { color: var(--muted); }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { appearance: none; width: 40px; height: 22px; min-height: 0; padding: 0; border-radius: 99px; background: var(--line-strong); position: relative; cursor: pointer; border: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked { background: var(--cobalt); }
.switch input:checked::after { transform: translateX(18px); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
th button:focus-visible { outline: 2px solid var(--focus); }
th button .i { width: 13px; height: 13px; opacity: .5; }
th[aria-sort] button .i { opacity: 1; color: var(--cobalt); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; width: 1%; }
.cell-title { font-weight: 600; color: var(--ink); }
.cell-sub { font-size: 12.5px; color: var(--muted); }
.instr { white-space: nowrap; font-weight: 650; font-stretch: 85%; letter-spacing: .01em; color: var(--ink); text-decoration: none; }
.instr:hover { color: var(--cobalt); text-decoration: underline; }
.table-foot { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.pager { margin-left: auto; display: flex; gap: 4px; }
.pager button { min-width: 34px; }
.pager button[aria-current="page"] { background: var(--cobalt); color: #fff; border-color: var(--cobalt); }

.empty { padding: 48px 20px; text-align: center; display: grid; gap: 10px; justify-items: center; }
.empty h3 { font-size: 18px; }
.empty p { color: var(--muted); max-width: 46ch; }

/* ---------- Modal y panel lateral ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(8,20,40,.5); backdrop-filter: blur(2px);
  animation: fade .15s ease-out;
}
.modal {
  width: min(100%, 560px); max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); box-shadow: var(--shadow-2);
  animation: rise .18s ease-out;
}
.modal.wide { width: min(100%, 920px); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 21px; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius-l) var(--radius-l); }
.modal-foot .left { margin-right: auto; }

.overlay.drawer-overlay { place-items: stretch end; padding: 0; }
.drawer {
  width: min(100vw, 520px); height: 100vh; overflow-y: auto;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-2);
  animation: slidein .2s ease-out; display: flex; flex-direction: column;
}
.drawer-hero { position: relative; background: var(--metal); color: #e6eef8; padding: 18px 22px 22px; isolation: isolate; }
.drawer-hero::before { content: ""; position: absolute; inset: 0; background: var(--metal-sheen); z-index: -1; }
.drawer-hero .top { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.drawer-hero .top .icon-btn { color: #d6e2f1; margin-left: auto; }
.drawer-hero .top .icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.instr-big { font-size: 46px; font-weight: 700; font-stretch: 62%; line-height: .95; color: #fff; letter-spacing: .005em; }
.drawer-hero h2 { font-size: 20px; margin-top: 10px; color: #fff; font-stretch: 90%; }
.drawer-hero .loc { color: #b9cbe2; margin-top: 4px; display: flex; gap: 6px; align-items: center; }
.drawer-hero .loc .i { width: 15px; height: 15px; }
.drawer-hero .tags { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.drawer-body { padding: 8px 22px 22px; flex: 1; }
.dl { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 0; margin: 0; }
.dl dt, .dl dd { padding: 10px 0; border-bottom: 1px solid var(--line); margin: 0; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { color: var(--ink); }
.drawer-section { font-size: 15px; margin: 20px 0 4px; }
.drawer-foot { display: flex; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }
.drawer-foot { flex-wrap: wrap; }
.drawer-foot .btn-danger { margin-left: auto; }
.mini-map { height: 180px; border-radius: var(--radius-m); border: 1px solid var(--line); margin-top: 14px; overflow: hidden; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px;
  background: var(--ink); color: var(--page); border-radius: var(--radius-m); box-shadow: var(--shadow-2);
  font-size: 14px; animation: rise .18s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }
.toast .dot { margin-top: 6px; background: currentColor; }

/* ---------- Mapa ---------- */
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 0; height: calc(100vh - 60px - 28px - 64px - 80px); min-height: 460px; overflow: hidden; }
#map { height: 100%; background: var(--surface-2); }
.map-side { border-left: 1px solid var(--line); overflow-y: auto; }
.map-item { display: block; width: 100%; text-align: left; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--line); background: none; color: inherit; font: inherit; cursor: pointer; }
.map-item:hover, .map-item.active { background: var(--surface-2); }
.map-item .row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.leaflet-container { font-family: var(--font) !important; }
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(185deg) brightness(.85) contrast(.9) saturate(.6); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(1) hue-rotate(185deg) brightness(.85) contrast(.9) saturate(.6); } }
.pin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45); }
.map-fallback { display: grid; place-items: center; height: 100%; padding: 24px; text-align: center; color: var(--muted); }

/* ---------- Consola ---------- */
.console-grid { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 18px; align-items: start; }
.clause { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px; gap: 6px; align-items: center; }
.clauses { display: grid; gap: 8px; }
.and { font-size: 12px; color: var(--muted); padding-left: 4px; }
.fields-pick { display: flex; flex-wrap: wrap; gap: 6px; max-height: 180px; overflow-y: auto; }
.fields-pick label { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 99px; cursor: pointer; }
.fields-pick input { width: 13px; height: 13px; min-height: 0; margin: 0; accent-color: var(--cobalt); }
.req-line { display: block; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-s); word-break: break-all; font-size: 12.5px; color: var(--ink-2); }
.resp-meta { display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 14px 18px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.resp-meta b { color: var(--ink); font-weight: 600; }
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.tabs button { all: unset; cursor: pointer; padding: 11px 12px; font-size: 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--cobalt); border-bottom-color: var(--cobalt); }
.tabs button:focus-visible { outline: 2px solid var(--focus); }
pre.json { margin: 0; padding: 16px 18px; max-height: 520px; overflow: auto; font-size: 12.5px; line-height: 1.55; background: var(--surface-2); color: var(--ink-2); border-radius: 0 0 var(--radius-l) var(--radius-l); }
.json .k { color: var(--cobalt); } .json .s { color: var(--ok); } .json .n { color: var(--warn); }

/* ---------- Comparación fuente vs. FeatureSet ---------- */
.compare { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0; }
.compare-col { padding: 16px 18px; min-width: 0; display: grid; gap: 10px; align-content: start; }
.compare-col + .compare-col { border-left: 1px solid var(--line); }
.compare-col h3 { font-size: 16px; display: flex; align-items: center; gap: 8px; }
.compare-col pre.json { border-radius: var(--radius-s); max-height: 460px; }
.step-n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--cobalt); color: #fff; font-size: 13px; font-weight: 700; flex: none; }
@media (max-width: 1100px) { .compare { grid-template-columns: minmax(0, 1fr); } .compare-col + .compare-col { border-left: 0; border-top: 1px solid var(--line); } }

/* ---------- Estado ---------- */
.kv { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.endpoint { display: flex; gap: 10px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; flex-wrap: wrap; }
.endpoint:last-child { border-bottom: 0; }
.verb { font-weight: 700; font-size: 11.5px; min-width: 54px; color: var(--steel); }
.endpoint .scope { margin-left: auto; }

/* ---------- Secreto ---------- */
.secret-box { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border: 1px dashed var(--cobalt); border-radius: var(--radius-s); background: var(--cobalt-soft); margin: 12px 0; }
.secret-box code { flex: 1; word-break: break-all; font-size: 14px; color: var(--ink); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-main, .console-grid { grid-template-columns: minmax(0, 1fr); }
  .map-layout { grid-template-columns: minmax(0, 1fr); height: auto; }
  #map { height: 420px; }
  .map-side { border-left: 0; border-top: 1px solid var(--line); max-height: 360px; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; width: min(86vw, 290px); transform: translateX(-100%); transition: transform .2s ease-out; }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 55; background: rgba(8,20,40,.45); }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px 56px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .flow-track { grid-template-columns: minmax(0, 1fr); }
  .flow-link { width: auto; height: 34px; }
  .flow-link::before { left: 50%; right: auto; top: 2px; bottom: 2px; width: 2px; height: auto; background: repeating-linear-gradient(180deg, #9fb6d3 0 6px, transparent 6px 11px); }
  .flow-link.live::before { background: repeating-linear-gradient(180deg, #d8e6f7 0 6px, transparent 6px 11px); animation: none; }
  .login { grid-template-columns: minmax(0, 1fr); }
  .login-brand { padding: 32px 20px; }
  .login-flow { display: none; }
  .form-section { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .health-pill .txt { display: none; }
}
@media (max-width: 600px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .page-head h1 { font-size: 27px; }
  .flow-total { font-size: 52px; }
  .dl { grid-template-columns: minmax(0, 1fr); }
  .dl dt { border-bottom: 0; padding-bottom: 0; }
  .toolbar select { flex: 1 1 140px; min-width: 0; }
  .search { max-width: none; }
  .hide-sm { display: none; }
  th, td { padding: 10px; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .left { width: 100%; }
}
