/* iDMARC — identidad visual "correo aéreo": tinta azul profundo, papel frío, franja par avion */
@font-face {
  font-family: "Archivo"; font-style: normal; font-display: swap; font-weight: 100 900; font-stretch: 62% 125%;
  src: url(../fonts/archivo-latin-ext-wdth-normal.woff2) format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2020, U+20A0-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Archivo"; font-style: normal; font-display: swap; font-weight: 100 900; font-stretch: 62% 125%;
  src: url(../fonts/archivo-latin-wdth-normal.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --ink: #16233f;
  --ink-2: #24365c;
  --paper: #eef1f5;
  --surface: #ffffff;
  --line: #d5dbe5;
  --line-soft: #e6eaf0;
  --muted: #5b6782;
  --text: #1a2338;
  --blue: #2445a6;
  --blue-soft: #e3e9f8;
  --red: #be3a34;
  --red-soft: #fbe5e3;
  --green: #1e8a5a;
  --green-soft: #ddf3e8;
  --amber: #a86d12;
  --amber-soft: #fbefd6;
  --violet: #6a4bb0;
  --radius-s: 4px;
  --radius-m: 8px;
  --font: "Archivo", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --stripe: repeating-linear-gradient(-45deg, var(--red) 0 9px, #fff 9px 14px, var(--blue) 14px 23px, #fff 23px 28px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--paper);
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h1, h2, h3, h4 { font-stretch: 112%; color: var(--ink); margin: 0; line-height: 1.2; }
h1 { font-size: 24px; font-weight: 680; letter-spacing: -0.01em; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 620; }
h4 { font-size: 13px; font-weight: 620; }
p { margin: 0 0 8px; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
small, .muted { color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---------------------------------------------------------------- layout */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--ink); color: #c9d2e6; padding: 0 0 24px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .stripe { height: 6px; background: var(--stripe); }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px 14px; color: #fff; }
.brand svg { flex: none; }
.brand b { font-size: 19px; font-stretch: 120%; font-weight: 720; letter-spacing: 0.01em; }
.brand span { display: block; font-size: 11.5px; color: #9aa8c7; font-stretch: 100%; font-weight: 400; }
.nav-group { padding: 10px 12px 2px; }
.nav-group > div { font-size: 12px; color: #8492b3; padding: 6px 8px 4px; font-weight: 500; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-s); color: #d3dbec;
  font-size: 13.5px; text-decoration: none; position: relative;
}
.nav a:hover { background: var(--ink-2); color: #fff; }
.nav a.active { background: #2b3f69; color: #fff; }
.nav a.active::before { content: ""; position: absolute; left: -12px; top: 6px; bottom: 6px; width: 3px; background: var(--stripe); }
.nav a svg { width: 16px; height: 16px; opacity: .85; flex: none; }
.nav .count { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; border-radius: 9px; padding: 0 6px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 500; flex-wrap: wrap;
}
.topbar .filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar .spacer { flex: 1; }
.topbar .user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.menu-btn { display: none; }
.content { padding: 24px 28px 48px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .lead { color: var(--muted); max-width: 72ch; margin-top: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- panels & grid */
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-side { grid-template-columns: 320px minmax(0, 1fr); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 18px 20px; min-width: 0; }
.panel > header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.panel > header p { margin: 0; color: var(--muted); font-size: 13px; width: 100%; }
.panel > header .tools { margin-left: auto; display: flex; gap: 6px; }
.panel.flush { padding: 0; }
.panel.flush > header { padding: 16px 20px 0; }
.panel.tint { background: #f7f9fc; }
.mt { margin-top: 16px; }
.mt-s { margin-top: 8px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }

/* KPI strip: una sola fila con divisores, no tarjetas idénticas */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-m); }
.kpi { padding: 14px 18px; border-right: 1px solid var(--line-soft); }
.kpi:last-child { border-right: 0; }
.kpi .v { font-size: 24px; font-weight: 650; font-stretch: 108%; color: var(--ink); line-height: 1.15; }
.kpi .l { font-size: 12.5px; color: var(--muted); }
.kpi .d { font-size: 12px; margin-top: 2px; }
.up { color: var(--green); } .down { color: var(--red); }

/* Sello postal de cumplimiento (elemento distintivo) */
.postmark { display: grid; grid-template-columns: 1fr; gap: 18px; justify-items: center; }
.postmark .facts { width: 100%; }
.postmark svg text { font-family: var(--font); }
.postmark .facts { display: grid; gap: 10px; }
.facts .fact { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.bar { height: 6px; background: var(--line-soft); border-radius: 3px; overflow: hidden; grid-column: 1 / -1; }
.bar > i { display: block; height: 100%; background: var(--blue); }
.bar.g > i { background: var(--green); } .bar.r > i { background: var(--red); } .bar.a > i { background: var(--amber); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 8px 10px;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
table.t th.sort { cursor: pointer; user-select: none; }
table.t th.sort:hover { color: var(--ink); }
table.t th.asc::after { content: " ▲"; font-size: 9px; } table.t th.desc::after { content: " ▼"; font-size: 9px; }
table.t td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.t tr:hover td { background: #f6f8fc; }
table.t td.num, table.t th.num { text-align: right; }
table.t tr.click { cursor: pointer; }
.t-empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- badges & chips */
.b { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 520; white-space: nowrap; }
.b-ok { background: var(--green-soft); color: #13603e; }
.b-bad { background: var(--red-soft); color: #8d2420; }
.b-warn { background: var(--amber-soft); color: #7a4f0c; }
.b-info { background: var(--blue-soft); color: #1e3a8a; }
.b-mute { background: #eceff4; color: #4a556e; }
.b-vio { background: #ece6f8; color: #4d3393; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.pr { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.pr .bar { flex: 1; grid-column: auto; }

/* ---------------------------------------------------------------- forms */
input, select, textarea, button { font: inherit; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  border: 1px solid var(--line); border-radius: var(--radius-s); padding: 7px 10px; background: #fff; color: var(--text); min-width: 0;
}
textarea { width: 100%; min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-soft); }
label.f { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.f > input, label.f > select, label.f > textarea { color: var(--text); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 7px 14px; border-radius: var(--radius-s); cursor: pointer; font-weight: 520; font-size: 13.5px; white-space: nowrap;
}
.btn:hover { border-color: #b8c2d4; background: #f6f8fb; text-decoration: none; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #1d3a8f; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 3px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 11px; cursor: pointer; font-size: 13px; color: var(--muted); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: #fff; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--blue); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* ---------------------------------------------------------------- findings / records */
.record { background: #f4f6fa; border: 1px solid var(--line); border-left: 3px solid var(--blue); padding: 10px 12px;
  border-radius: var(--radius-s); word-break: break-all; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; position: relative; }
.record .copy { position: absolute; top: 6px; right: 6px; }
.record:has(.copy) { padding-right: 78px; }
.findings { list-style: none; margin: 0; padding: 0; }
.findings li { display: grid; grid-template-columns: 22px 1fr; gap: 6px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.findings li:last-child { border-bottom: 0; }
.findings .fix { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.lvl { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; margin-top: 1px; }
.lvl.critical { background: var(--red); } .lvl.error { background: #d9663c; } .lvl.warning { background: var(--amber); }
.lvl.info { background: var(--blue); } .lvl.ok { background: var(--green); }
.score { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; font-weight: 700; font-size: 17px;
  font-stretch: 110%; border: 3px solid currentColor; }
.tree { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.tree ul { list-style: none; margin: 0; padding-left: 18px; border-left: 1px dashed var(--line); }
.tree li { padding: 2px 0; }

/* Ruta a p=reject: vía con paradas */
.track { display: grid; grid-template-columns: repeat(6, 1fr); position: relative; margin: 8px 0 4px; }
.track::before { content: ""; position: absolute; left: 8%; right: 8%; top: 15px; height: 4px; background: var(--line); border-radius: 2px; }
.track .fill { position: absolute; left: 8%; top: 15px; height: 4px; background: var(--stripe); border-radius: 2px; }
.stop { position: relative; text-align: center; padding: 0 4px; }
.stop .pin { width: 34px; height: 34px; border-radius: 50%; margin: 0 auto 8px; display: grid; place-items: center; background: #fff;
  border: 3px solid var(--line); font-weight: 700; color: var(--muted); position: relative; z-index: 1; }
.stop.done .pin { border-color: var(--green); background: var(--green); color: #fff; }
.stop.cur .pin { border-color: var(--blue); color: var(--blue); box-shadow: 0 0 0 5px var(--blue-soft); }
.stop .nm { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.stop .ds { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* matriz de riesgo */
.matrix { display: grid; grid-template-columns: 120px 1fr 1fr; gap: 6px; }
.matrix .hd { font-size: 12px; color: var(--muted); display: flex; align-items: center; justify-content: center; text-align: center; padding: 4px; }
.matrix .cell { border-radius: var(--radius-m); padding: 16px; min-height: 108px; display: flex; flex-direction: column; justify-content: space-between; }
.matrix .cell .n { font-size: 26px; font-weight: 680; font-stretch: 110%; }
.matrix .cell .p { font-size: 13px; }
.matrix .cell small { color: inherit; opacity: .8; }
.c-both { background: var(--green-soft); color: #11583a; }
.c-one { background: var(--amber-soft); color: #6d470c; }
.c-none { background: var(--red-soft); color: #87221d; }

/* alertas */
.alert-row { display: grid; grid-template-columns: 6px 1fr auto; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.alert-row .sev { border-radius: 3px; }
.sev-critical { background: var(--red); } .sev-high { background: #d9663c; } .sev-medium { background: var(--amber); }
.sev-low { background: var(--blue); } .sev-info { background: #93a0bb; }
.alert-row.ack { opacity: .6; }

/* map */
#map, .map { height: 420px; border-radius: var(--radius-m); border: 1px solid var(--line); z-index: 1; }

/* modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(22, 35, 63, .45); display: grid; place-items: center; z-index: 2000; padding: 16px; }
.modal { background: #fff; border-radius: var(--radius-m); max-width: 760px; width: 100%; max-height: 90vh; overflow: auto; padding: 22px 24px; }
.modal.wide { max-width: 1100px; }
.modal header { display: flex; align-items: center; margin-bottom: 14px; gap: 10px; }
.modal header .x { margin-left: auto; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius-s);
  z-index: 3000; max-width: 420px; }
.toast.err { background: var(--red); }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.empty { padding: 32px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.dropzone { display: block; border: 2px dashed var(--line); border-radius: var(--radius-m); padding: 32px; text-align: center; color: var(--muted); background: #fafbfd; cursor: pointer; }
.dropzone.over { border-color: var(--blue); background: var(--blue-soft); }
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 200px; }
.chart-box.lg { height: 320px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }

/* login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login .art { background: var(--ink); color: #dfe5f2; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login .art::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 10px; background: var(--stripe); }
.login .art h1 { color: #fff; font-size: 40px; font-stretch: 118%; max-width: 15ch; line-height: 1.08; }
.login .art p { max-width: 46ch; color: #b5c0d8; font-size: 15px; }
.login .form { display: grid; place-items: center; padding: 32px; }
.login form { width: 100%; max-width: 360px; display: grid; gap: 14px; }

@media (max-width: 1100px) {
  .g-main, .g-3, .g-side { grid-template-columns: 1fr; }
  .postmark { grid-template-columns: 1fr; justify-items: center; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 1500; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .g-2 { grid-template-columns: 1fr; }
  .track { grid-template-columns: repeat(3, 1fr); row-gap: 16px; }
  .track::before, .track .fill { display: none; }
  .login { grid-template-columns: 1fr; }
  .login .art { padding: 32px 24px; }
  .login .art h1 { font-size: 30px; }
  .matrix { grid-template-columns: 70px 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .app { display: block; } .content { padding: 0; }
}
