:root {
  --bg: #0f1420;
  --surface: #171d2b;
  --surface-2: #1e2636;
  --border: #2a3348;
  --text: #e7ecf5;
  --muted: #97a3ba;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --warn: #f0b429;
  --radius: 12px;
  --maxw: 920px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 50% -200px, #16203a 0%, var(--bg) 60%);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header { border-bottom: 1px solid var(--border); background: rgba(15, 20, 32, 0.6); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; padding-block: 16px; }
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 30px; color: var(--accent); line-height: 1; }
h1 { font-size: 20px; margin: 0; letter-spacing: 0.2px; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.badge {
  font-size: 12px; color: var(--accent);
  background: var(--accent-soft); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 999px;
}

/* Hero */
.hero { padding: 56px 0 12px; max-width: 640px; }
.hero h2 { font-size: 30px; margin: 0 0 12px; line-height: 1.2; }
.hero p { color: var(--muted); font-size: 16px; }

/* Pipeline */
.pipeline ol {
  list-style: none; margin: 32px 0; padding: 0;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px;
  counter-reset: step;
}
.pipeline li {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 12px; position: relative;
  display: flex; flex-direction: column; gap: 4px;
}
.pipeline li::before {
  counter-increment: step; content: counter(step);
  position: absolute; top: 10px; right: 12px;
  color: var(--accent); font-size: 12px; font-weight: 700; opacity: 0.7;
}
.pipeline strong { font-size: 14px; }
.pipeline span { color: var(--muted); font-size: 12px; }

/* Upload card */
.upload-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin: 8px 0 48px;
}
.upload-head { display: flex; align-items: center; gap: 12px; }
.upload-head h3 { margin: 0; font-size: 18px; }
.chip {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border);
}
.chip-wip { color: var(--warn); background: rgba(240, 180, 41, 0.12); }
.muted { color: var(--muted); font-size: 14px; }

.upload-form { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.file-field {
  flex: 1 1 260px; position: relative; display: flex; align-items: center;
  background: var(--surface-2); border: 1px dashed var(--border);
  border-radius: 10px; padding: 12px 14px; cursor: pointer; color: var(--muted);
}
.file-field input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.btn {
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  font-size: 14px; font-weight: 600; padding: 12px 22px; border-radius: 10px;
  cursor: pointer; transition: filter 0.15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.status { margin: 14px 0 0; min-height: 20px; font-size: 14px; }
.status.err { color: var(--warn); }
.status.ok { color: var(--accent); }

/* Footer */
.site-footer { margin-top: auto; border-top: 1px solid var(--border); }
.site-footer .wrap {
  display: flex; align-items: center; justify-content: space-between;
  padding-block: 18px; color: var(--muted); font-size: 13px;
}
.site-footer a { color: var(--accent); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

@media (max-width: 720px) {
  .pipeline ol { grid-template-columns: repeat(2, 1fr); }
  .hero h2 { font-size: 24px; }
}

/* ---- Phase 1: progress, results, detail page ---- */
.pipeline li.done { border-color: var(--accent); }
.pipeline li.done strong { color: var(--accent); }
.chip-ok { color: var(--accent); background: var(--accent-soft); }

.progress-wrap { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.progress-track {
  flex: 1; height: 8px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; overflow: hidden;
}
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.15s ease; }
.progress-pct { font-size: 12px; color: var(--muted); min-width: 38px; text-align: right; }

.result {
  margin-top: 16px; padding: 14px 16px; border-radius: 10px;
  border: 1px solid var(--border); font-size: 14px; line-height: 1.6;
}
.result a { color: var(--accent); text-decoration: none; }
.result a:hover { text-decoration: underline; }
.result-ok { background: var(--accent-soft); border-color: var(--accent); }
.result-err { background: rgba(240, 180, 41, 0.10); border-color: var(--warn); color: #f4d38a; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12px; }

/* Detail page */
.detail-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; margin: 48px 0;
}
.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.detail-head h2 { margin: 0; font-size: 22px; }
.detail-grid {
  display: grid; grid-template-columns: 160px 1fr; gap: 8px 20px;
  margin: 20px 0; font-size: 14px;
}
.detail-grid dt { color: var(--muted); }
.detail-grid dd { margin: 0; word-break: break-all; }

.status-badge {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border);
}
.status-validated { color: #6ee7a8; background: rgba(110, 231, 168, 0.12); }
.status-rejected  { color: var(--warn); background: rgba(240, 180, 41, 0.12); }
.status-expired   { color: var(--muted); background: rgba(151, 163, 186, 0.12); }
.status-received  { color: var(--accent); background: var(--accent-soft); }

.link-back { display: inline-block; margin-top: 12px; color: var(--accent); text-decoration: none; }
.link-back:hover { text-decoration: underline; }

@media (max-width: 560px) { .detail-grid { grid-template-columns: 1fr; } }

/* BGP session results */
.bgp-results { margin: 0 0 48px; }
.bgp-results h3 { font-size: 18px; margin: 0 0 16px; }
.session-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; margin-bottom: 16px;
}
.session-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.session-head strong { font-size: 15px; }
.session-card h4 { font-size: 14px; margin: 20px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }

.status-session-established { color: #6ee7a8; background: rgba(110, 231, 168, 0.12); }
.status-session-opensent     { color: var(--accent); background: var(--accent-soft); }
.status-session-notified     { color: var(--warn); background: rgba(240, 180, 41, 0.12); }
.status-session-unknown      { color: var(--muted); background: rgba(151, 163, 186, 0.12); }

.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.data-table th, .data-table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.data-table thead th { color: var(--muted); font-weight: 600; background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: none; }

.err-list { margin: 0; padding-left: 18px; font-size: 13px; color: var(--warn); }
.err-list li { margin: 4px 0; }

/* ---- Phase 3: anomaly detection (metrics, findings, timeline) ---- */
.severity-critical { color: #ff6b6b; background: rgba(255, 107, 107, 0.14); }
.severity-high     { color: #ff9166; background: rgba(255, 145, 102, 0.14); }
.severity-medium   { color: var(--warn); background: rgba(240, 180, 41, 0.14); }
.severity-low      { color: #8fd3ff; background: rgba(143, 211, 255, 0.14); }
.severity-info     { color: var(--muted); background: rgba(151, 163, 186, 0.14); }

.confidence-tag {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px;
  padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border);
}
.confidence-confirmed  { color: #6ee7a8; background: rgba(110, 231, 168, 0.10); }
.confidence-possible   { color: var(--accent); background: var(--accent-soft); }
.confidence-suspicious { color: #ff9166; background: rgba(255, 145, 102, 0.12); }

.metrics-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px; margin: 20px 0;
}
.metric-tile {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; text-align: center;
}
.metric-tile .n { display: block; font-size: 22px; font-weight: 700; }
.metric-tile .label { display: block; font-size: 11px; color: var(--muted); margin-top: 2px;
  text-transform: uppercase; letter-spacing: 0.4px; }

.findings-section { margin: 0 0 48px; }
.finding-card {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 12px;
}
.finding-card.severity-critical-border { border-left-color: #ff6b6b; }
.finding-card.severity-high-border     { border-left-color: #ff9166; }
.finding-card.severity-medium-border   { border-left-color: var(--warn); }
.finding-card.severity-low-border      { border-left-color: #8fd3ff; }
.finding-card.severity-info-border     { border-left-color: var(--muted); }
.finding-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.finding-head strong { font-size: 14px; }
.finding-meta { font-size: 12px; color: var(--muted); margin-left: auto; }
.finding-desc { font-size: 13px; color: var(--text); line-height: 1.6; margin: 0 0 8px; }
.finding-evidence {
  font-size: 12px; color: var(--muted); margin: 0; padding: 10px 12px;
  background: var(--surface-2); border-radius: 8px; overflow-x: auto; white-space: pre-wrap;
}
.no-findings {
  padding: 16px 20px; border: 1px solid var(--border); border-radius: var(--radius);
  color: #6ee7a8; background: rgba(110, 231, 168, 0.08); font-size: 14px;
}

.timeline-section { margin: 0 0 48px; }
.timeline-list { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border);
  margin-left: 6px; }
.timeline-item { position: relative; padding: 6px 0 6px 20px; font-size: 13px; }
.timeline-item::before {
  content: ""; position: absolute; left: -5px; top: 12px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--bg);
}
.timeline-item .t-ts { color: var(--muted); font-size: 11px; margin-right: 8px; }
.timeline-item .t-type {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted);
  margin-right: 6px;
}

/* ---- Phase 4: RPKI route origin validation ---- */
.rpki-valid                  { color: #6ee7a8; background: rgba(110, 231, 168, 0.12); }
.rpki-invalid_asn            { color: #ff9166; background: rgba(255, 145, 102, 0.14); }
.rpki-invalid_length         { color: #ff9166; background: rgba(255, 145, 102, 0.14); }
.rpki-invalid_asn_and_length { color: #ff6b6b; background: rgba(255, 107, 107, 0.14); }
.rpki-not_found               { color: var(--muted); background: rgba(151, 163, 186, 0.12); }
.rpki-unavailable             { color: var(--warn); background: rgba(240, 180, 41, 0.12); }

.rpki-summary-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.rpki-source-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px 28px; margin: 24px 0;
}
.rpki-source-card dl.detail-grid { margin: 16px 0 0; }
.freshness-warn {
  display: inline-block; margin-top: 10px; padding: 8px 12px; border-radius: 8px;
  background: rgba(240, 180, 41, 0.10); border: 1px solid var(--warn); color: #f4d38a; font-size: 13px;
}
.reanalyze-btn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: 12px; padding: 6px 14px; border-radius: 8px; cursor: pointer; margin-left: auto;
}
.reanalyze-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Phase 6: incidents, explanations, topology, reports, compare ---- */
.summary-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px 28px; margin: 0 0 32px;
}
.summary-card h2 { margin: 0 0 4px; font-size: 20px; }
.context-pill {
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px; padding: 3px 10px;
  border-radius: 999px; border: 1px solid var(--border); color: var(--accent); background: var(--accent-soft);
}
.report-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 4px; }
.report-links a, .ghost-btn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: 12px; padding: 6px 14px; border-radius: 8px; text-decoration: none; cursor: pointer;
}
.report-links a:hover, .ghost-btn:hover { border-color: var(--accent); color: var(--accent); }

.incident-card {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--border);
  border-radius: var(--radius); padding: 18px 22px; margin-bottom: 14px;
}
.incident-card.severity-critical-border { border-left-color: #ff6b6b; }
.incident-card.severity-high-border { border-left-color: #ff9166; }
.incident-card.severity-medium-border { border-left-color: var(--warn); }
.incident-card.severity-low-border { border-left-color: #8fd3ff; }
.incident-card.severity-info-border { border-left-color: var(--muted); }
.incident-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.incident-head strong { font-size: 15px; }
.incident-resumen { font-size: 13px; color: var(--text); margin: 6px 0; line-height: 1.5; }
.incident-criterion { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.incident-axes { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.axis-chip {
  font-size: 11px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--muted); background: var(--surface-2);
}
.axis-chip strong { color: var(--text); font-weight: 600; }
.rel-alta { border-color: #6ee7a8; color: #6ee7a8; }
.rel-media { border-color: var(--warn); color: #f4d38a; }
.rel-débil, .rel-none { border-color: var(--border); }
.incident-related { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.incident-related li { margin: 2px 0; }
.sev-change { font-size: 12px; color: #f4d38a; margin: 2px 0; }
.coverage-note {
  font-size: 12px; color: #f4d38a; background: rgba(240, 180, 41, 0.08);
  border: 1px solid rgba(240, 180, 41, 0.25); border-radius: 8px; padding: 8px 12px; margin: 10px 0;
}
.expl-block { margin: 8px 0 0; font-size: 13px; }
.expl-block .facts { color: #6ee7a8; }
.expl-block .hyp { color: #ffb38a; }
.expl-block ul { margin: 4px 0 8px; padding-left: 18px; }
details.tech > summary {
  cursor: pointer; color: var(--accent); font-size: 13px; padding: 8px 0; list-style: revert;
}
details.tech[open] > summary { margin-bottom: 8px; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; align-items: flex-end; }
.filter-bar label { display: flex; flex-direction: column; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .4px; gap: 4px; }
.filter-bar select, .filter-bar input {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; min-width: 130px;
}
.tz-note { font-size: 12px; color: var(--muted); }
.timeline-item.hidden { display: none; }

#asn-graph { width: 100%; height: 460px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; touch-action: none; }
#asn-graph text {
  fill: var(--text); font-size: 10.5px; font-family: ui-monospace, Menlo, monospace;
  /* halo so labels stay legible where they cross an edge */
  paint-order: stroke; stroke: var(--surface-2); stroke-width: 3px; stroke-linejoin: round;
}
#asn-graph text.lbl-session { fill: #fff; font-size: 11.5px; font-weight: 600; }
#asn-graph .edge { stroke: var(--muted); stroke-width: 1; }
#asn-graph .edge-observed { stroke: var(--accent); stroke-width: 2.25; }
#asn-graph .edge-inferred { stroke: #b9c4da; stroke-width: 1.1; stroke-dasharray: 4 3; }
#asn-graph .edge-as_set_membership { stroke: #8fd3ff; stroke-width: 1.1; stroke-dasharray: 2 2; }
#asn-graph .edge-confederation_internal { stroke: #ff9166; stroke-width: 1.1; stroke-dasharray: 6 2; }
#asn-graph .node circle { fill: var(--surface); stroke: var(--accent); stroke-width: 1.5; cursor: pointer; }
#asn-graph .node-session circle { fill: var(--accent); stroke: #fff; stroke-width: 1.75; }
#asn-graph .node.dim { opacity: 0.22; }
#asn-graph .edge.dim { opacity: 0.07; }
.graph-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); margin: 10px 0; }
.graph-legend span::before { content: "—"; margin-right: 4px; font-weight: 700; }
.graph-legend .l-observed::before { color: var(--accent); }
.graph-legend .l-inferred::before { color: #b9c4da; }
#graph-detail { font-size: 12px; color: var(--muted); margin-top: 8px; min-height: 18px; }

.cmp-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
@media (max-width: 640px) { .cmp-cols { grid-template-columns: 1fr; } }

/* ---- Phase 9: feedback form + admin inbox ---- */
.fb-link { color: var(--muted); font-size: 13px; text-decoration: none; }
.fb-link:hover { color: var(--accent); text-decoration: underline; }

.fb-form { margin-top: 18px; display: flex; flex-direction: column; gap: 18px; max-width: 620px; }
.fb-fieldset {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 0;
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center;
}
.fb-fieldset legend { color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: .4px; padding: 0 6px; }
.fb-radio { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; cursor: pointer; }
.fb-radio input { accent-color: var(--accent); width: 16px; height: 16px; }

.fb-field { display: flex; flex-direction: column; gap: 6px; }
.fb-field label { font-size: 13px; color: var(--text); font-weight: 600; }
.fb-req { color: var(--muted); font-weight: 400; font-size: 12px; }
.fb-field textarea, .fb-field input[type="email"] {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; font-family: inherit;
  width: 100%; resize: vertical;
}
.fb-field textarea:focus, .fb-field input:focus,
.fb-radio input:focus-visible, .btn:focus-visible, .ghost-btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.fb-count { margin: 0; font-size: 12px; }

/* honeypot: off-screen, not display:none (bots skip display:none) */
.fb-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.fb-actions { display: flex; align-items: center; gap: 16px; }
.fb-actions .link-back { margin-top: 0; }

.fb-admin-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.fb-admin-actions .status { margin: 0; }
.fb-pager { display: flex; gap: 14px; align-items: center; margin: 16px 0; }
