/* CILIO: sistema visual. Ver DESIGN.md y docs/identidad/.
   Claro por defecto, papel calido, tinta casi negra, un solo acento (el azul
   CILIO #246FDB). Lineas finas en vez de sombras, radios minimos, etiquetas en mono.
   Deliberadamente distinto a NECTO (oscuro terracota) y SOMA (navy magenta). */

:root {
  --paper: #F6F6F2;
  --surface: #FFFFFF;
  --surface-2: #EFEFEA;
  --ink: #15171C;
  --ink-2: #4B5060;
  --ink-3: #7D8291;
  --line: #DCDDE2;
  --line-strong: #B5B8C2;

  /* Identidad CILIO (ficha de handoff, ATL · TT): accent, mid, light, dark, bg, border. */
  --cilio-accent: #246FDB;
  --cilio-mid: #4285F4;
  --cilio-light: #8AB4F8;
  --cilio-dark: #0B2A5B;
  --cilio-bg: #E8F0FE;
  --cilio-border: #C6DAFC;
  --signal: var(--cilio-accent);
  --signal-ink: var(--cilio-dark);
  --signal-soft: var(--cilio-bg);

  --ok: #15803D;      --ok-soft: #E4F3E8;
  --warn: #B45309;    --warn-soft: #FBEEDC;
  --crit: #B91C1C;    --crit-soft: #FBE5E5;
  --idle: #7D8291;    --idle-soft: #EDEEF1;

  --font: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 3px;
  --topbar-h: 52px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* Etiquetas tecnicas: mono, mayusculas, tracking abierto. */
.eyebrow, .mono {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.mono-data { font-family: var(--mono); font-size: 12.5px; letter-spacing: 0; text-transform: none; color: var(--ink); }

/* Barra superior: identidad y navegacion. Sin sidebar a proposito. */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 28px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 24px; height: 24px; display: block; }
.brand .word { font-weight: 700; letter-spacing: .12em; font-size: 14px; white-space: nowrap; }
.brand .sub { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); letter-spacing: .04em; margin-left: 2px; white-space: nowrap; }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a {
  padding: 6px 10px; border-radius: var(--radius);
  color: var(--ink-2); font-weight: 500; font-size: 13.5px;
  border-bottom: 2px solid transparent;
}
.nav a:hover { background: var(--surface-2); }
.nav a.active { color: var(--ink); border-bottom-color: var(--signal); border-radius: var(--radius) var(--radius) 0 0; }
.topbar .spacer { flex: 1; }
.user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); }
.user img { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); }
.user button { background: none; border: none; color: var(--ink-3); cursor: pointer; font-size: 12.5px; }
.user button:hover { color: var(--ink); text-decoration: underline; }

/* Contenedor de pagina */
.page { max-width: 1240px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.page-head .meta { margin-top: 4px; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface);
  font-weight: 500; font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--signal); border-color: var(--signal); color: #fff; }
.btn.primary:hover { background: var(--signal-ink); border-color: var(--signal-ink); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--crit); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }

/* Paneles: una linea, nada de sombra. */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 14px; font-weight: 600; }
.panel-body { padding: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* Tabla de datos */
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left; padding: 10px 14px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 500; border-bottom: 1px solid var(--line);
  background: var(--surface);
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr.row-link { cursor: pointer; }
table.data tr.row-link:hover td { background: #FAFAF7; }
td .muted, .muted { color: var(--ink-3); }
.dim { color: var(--ink-2); }

/* Pills de estado: el color es informacion, no decoracion. */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px; border-radius: 999px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .03em;
  border: 1px solid transparent;
}
.pill { white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
table.data td.mono-data, table.data td .mono-data { white-space: nowrap; }
.pill.ok   { color: var(--ok);   background: var(--ok-soft); }
.pill.warn { color: var(--warn); background: var(--warn-soft); }
.pill.crit { color: var(--crit); background: var(--crit-soft); }
.pill.idle { color: var(--idle); background: var(--idle-soft); }
.pill.signal { color: var(--signal-ink); background: var(--signal-soft); }

/* Chips de scopes */
.chip { display: inline-block; padding: 2px 7px; border: 1px solid var(--line); border-radius: var(--radius); font-family: var(--mono); font-size: 11px; color: var(--ink-2); background: var(--surface-2); margin: 2px 4px 2px 0; }
.chip.on { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
.chip.off { border-color: var(--line); color: var(--ink-3); text-decoration: line-through; }

/* Avisos: dato faltante explicito */
.notice { display: flex; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-left: 3px solid var(--idle); border-radius: var(--radius); background: var(--surface); font-size: 13px; color: var(--ink-2); }
.notice.warn { border-left-color: var(--warn); }
.notice.crit { border-left-color: var(--crit); }
.notice.ok { border-left-color: var(--ok); }
.notice + .notice { margin-top: 8px; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.field input, .field select, .field textarea {
  padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface);
  font-size: 13.5px;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--signal-soft); border-color: var(--signal); }
.field .hint { font-size: 12px; color: var(--ink-3); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* Drawer lateral */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(21,23,28,.28); z-index: 30; display: none; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--surface); border-left: 1px solid var(--line); z-index: 31; transform: translateX(100%); transition: transform .18s ease; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-backdrop.open { display: block; }
.drawer-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.drawer-head h2 { font-size: 15px; font-weight: 600; }
.drawer-body { padding: 20px; overflow: auto; flex: 1; }

/* Lista de candidatos (resolver accesos) */
.cand { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.cand + .cand { margin-top: 8px; }
.cand:hover { border-color: var(--line-strong); }
.cand.sel { border-color: var(--signal); background: var(--signal-soft); }
.cand input { margin-top: 3px; }
.cand .t { font-weight: 500; }
.cand .s { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.cand .score { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--ink-3); white-space: nowrap; }

/* Riel de pipeline: la columna vertebral de la vista de cliente. */
.rail { display: grid; grid-template-columns: repeat(6, 1fr); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; margin: 18px 0 20px; }
.rail a { padding: 12px 14px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; color: var(--ink-2); position: relative; }
.rail a:last-child { border-right: none; }
.rail a .n { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.rail a .t { font-weight: 600; color: var(--ink); font-size: 13.5px; }
.rail a .st { font-size: 12px; }
.rail a.active { background: var(--signal-soft); }
.rail a.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--signal); }
.rail a.locked { opacity: .6; cursor: default; }
@media (max-width: 1000px) { .rail { grid-template-columns: repeat(3, 1fr); } .rail a { border-bottom: 1px solid var(--line); } }

/* Definiciones clave-valor */
.kv { display: grid; grid-template-columns: minmax(160px, max-content) 1fr; gap: 8px 16px; font-size: 13.5px; }
.kv dt { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); padding-top: 3px; word-break: break-all; max-width: 320px; }
.kv dd { word-break: break-word; }

.empty { padding: 36px 20px; text-align: center; color: var(--ink-3); font-size: 13.5px; }
.empty .eyebrow { display: block; margin-bottom: 8px; }

/* Toast */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius); font-size: 13px; z-index: 50; opacity: 0; transition: opacity .15s; pointer-events: none; }
.toast.show { opacity: 1; }
.toast.crit { background: var(--crit); }

/* Anchos angostos: la tabla se desplaza dentro de su panel, nunca la pagina. */
.panel:has(> table.data) { overflow-x: auto; }
@media (max-width: 760px) {
  .brand .sub { display: none; }
  .topbar { gap: 16px; padding: 0 16px; }
  .page { padding: 20px 16px 48px; }
}

/* Auditoria: resumen por severidad, hallazgos e inventario. */
.sev-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.sev { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); display: flex; flex-direction: column; gap: 4px; }
.sev .n { font-family: var(--mono); font-size: 22px; font-weight: 500; line-height: 1; }
.sev.p1 .n { color: var(--crit); } .sev.p2 .n { color: var(--warn); } .sev.p3 .n { color: var(--ink-3); }
.finding { padding: 12px 14px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 48px 1fr; gap: 12px; }
.finding:first-child { border-top: none; }
.finding .sev-tag { font-family: var(--mono); font-size: 11px; font-weight: 500; padding-top: 2px; }
.finding.p1 .sev-tag { color: var(--crit); } .finding.p2 .sev-tag { color: var(--warn); } .finding.p3 .sev-tag { color: var(--ink-3); }
.finding .t { font-weight: 600; }
.finding .d { color: var(--ink-2); font-size: 13px; margin-top: 3px; }
.finding .cat { font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin-left: 8px; }
.finding details { margin-top: 6px; }
.finding summary { cursor: pointer; font-family: var(--mono); font-size: 11px; color: var(--signal-ink); letter-spacing: .04em; }
.finding pre { margin-top: 6px; font-family: var(--mono); font-size: 11.5px; background: var(--surface-2); padding: 8px 10px; border-radius: var(--radius); white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; }
.quota { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.quota .bar { flex: 1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.quota .bar i { display: block; height: 100%; background: var(--signal); }
.quota .bar i.warn { background: var(--warn); }
.quota + .quota { margin-top: 8px; }
table.data.compact td, table.data.compact th { padding: 7px 12px; font-size: 12.5px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { background: none; border: none; padding: 8px 12px; cursor: pointer; color: var(--ink-2); font-size: 13px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--ink); border-bottom-color: var(--signal); }
