@font-face {
  font-family: "Archivo";
  src: url("/fonts/archivo.woff2") format("woff2-variations"), url("/fonts/archivo.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --porcelain: #F2F4F3;
  --paper: #FFFFFF;
  --ink: #17212B;
  --ink-2: #26323E;
  --slate: #5A6875;
  --line: #D5DBDF;
  --hazard: #F2B01E;
  --act: #1F4E79;
  --act-hover: #173B5C;
  --stop: #A3271F;
  --safe: #2E6B4F;

  --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  /* escala tipográfica (razón 1,25) */
  --t-sm: 0.8125rem;
  --t-base: 1rem;
  --t-md: 1.25rem;
  --t-lg: 1.5625rem;
  --t-xl: 2.4rem;

  --gap: 1.5rem;
  --radius: 4px;
  --wrap: 72rem;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--porcelain);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--t-base);
  line-height: 1.5;
}
h1, h2, h3 { margin: 0; font-stretch: 82%; letter-spacing: -0.01em; line-height: 1.15; }
h2 { font-size: var(--t-md); font-weight: 650; }
p { margin: 0; }
a { color: var(--act); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--hazard); outline-offset: 2px; }
[hidden] { display: none !important; }

.skip { position: absolute; left: -999px; top: 0; background: var(--paper); padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gap); }
.mono { font-family: var(--mono); font-size: .9em; word-break: break-all; }
.muted { color: var(--slate); }
.small { font-size: var(--t-sm); }

/* ── barra superior ─────────────────────────────── */
.topbar { background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; gap: 2rem; min-height: 3.75rem; flex-wrap: wrap; }
.brand { font-weight: 700; font-stretch: 75%; font-size: var(--t-md); text-decoration: none; color: var(--ink); display: flex; align-items: center; gap: .6rem; }
.brand-mark { width: 1.1rem; height: 1.1rem; border: 3px solid var(--ink); position: relative; }
.brand-mark::after { content: ""; position: absolute; inset: 3px; background: var(--hazard); }
.nav { display: flex; gap: 1.25rem; }
.nav a { color: var(--slate); text-decoration: none; padding: 1.1rem 0; border-bottom: 3px solid transparent; }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.nav a:hover { color: var(--ink); }
.usage { margin-left: auto; display: flex; align-items: center; gap: 1.25rem; font-size: var(--t-sm); color: var(--slate); }
.meter { width: 7rem; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--act); }
.meter.warn > span { background: var(--hazard); }
.meter.full > span { background: var(--stop); }
.account { position: relative; }
.account-btn { background: none; border: 1px solid var(--line); border-radius: var(--radius); padding: .35rem .7rem; cursor: pointer; font-size: var(--t-sm); }
.menu { position: absolute; right: 0; top: calc(100% + .4rem); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); min-width: 13rem; padding: .35rem 0; z-index: 5; box-shadow: 0 8px 24px rgba(23,33,43,.12); }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: .55rem 1rem; cursor: pointer; }
.menu button:hover, .menu button:focus-visible { background: var(--porcelain); }
.menu .who { padding: .55rem 1rem; color: var(--slate); font-size: var(--t-sm); border-bottom: 1px solid var(--line); margin-bottom: .3rem; }

/* ── botones y campos ──────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; border-radius: var(--radius); border: 1px solid transparent; padding: .6rem 1.1rem; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--act); color: #fff; }
.btn-primary:hover { background: var(--act-hover); }
.btn-hazard { background: var(--hazard); color: var(--ink); }
.btn-hazard:hover { background: #DD9E10; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--slate); }
.btn-stop { background: transparent; border-color: var(--stop); color: var(--stop); }
.btn-stop:hover { background: var(--stop); color: #fff; }
.btn[disabled] { opacity: .55; cursor: progress; }
.field { display: grid; gap: .35rem; }
.field label { font-size: var(--t-sm); font-weight: 600; }
.input, .select { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .75rem; background: var(--paper); }
.input:focus, .select:focus { border-color: var(--act); outline: none; box-shadow: 0 0 0 3px rgba(31,78,121,.2); }
.error { color: var(--stop); font-size: var(--t-sm); }

/* ── login ─────────────────────────────────────── */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 28rem); }
.login-side { background: var(--ink); color: #E8ECEF; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.login-side h1 { font-size: clamp(2rem, 4vw, 3.4rem); font-stretch: 68%; font-weight: 700; max-width: 14ch; color: #fff; }
.login-side p { max-width: 38ch; color: #B9C3CC; margin-top: 1rem; }
.login-side .brand { color: #fff; }
.login-side .brand-mark { border-color: #fff; }
.login-form { background: var(--paper); padding: 3rem; display: flex; flex-direction: column; justify-content: center; gap: 1.1rem; }
.login-form h2 { font-size: var(--t-lg); }

/* ── banco de ingreso de la muestra ─────────────── */
.intake { background: var(--ink); color: #E8ECEF; padding: 2.5rem 0 2.75rem; }
.intake h1 { font-size: var(--t-xl); font-stretch: 68%; font-weight: 700; color: #fff; }
.intake .lede { color: #B9C3CC; margin-top: .5rem; max-width: 60ch; }
.intake form { margin-top: 1.5rem; display: grid; gap: 1rem; }
.url-row { display: flex; gap: .75rem; }
.url-input { flex: 1; font-family: var(--mono); font-size: 1.05rem; padding: .9rem 1rem; border-radius: var(--radius); border: 2px solid var(--ink-2); background: #fff; color: var(--ink); min-width: 0; }
.url-input:focus { outline: none; border-color: var(--hazard); }
.options { display: flex; flex-wrap: wrap; gap: 1rem 1.75rem; align-items: end; }
.options .field label { color: #B9C3CC; font-weight: 500; }
.options .select { background: var(--ink-2); border-color: #3A4754; color: #fff; min-width: 9rem; }
.seg { display: inline-flex; border: 1px solid #3A4754; border-radius: var(--radius); overflow: hidden; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { padding: .55rem .9rem; cursor: pointer; color: #C9D1D8; border-right: 1px solid #3A4754; font-size: .95rem; }
.seg label:last-of-type { border-right: 0; }
.seg input:checked + label { background: #fff; color: var(--ink); font-weight: 600; }
.seg input:focus-visible + label { outline: 3px solid var(--hazard); outline-offset: -3px; }
.seg-group-label { font-size: var(--t-sm); color: #B9C3CC; display: block; margin-bottom: .35rem; }
.seg .sep { width: 1px; background: #5A6875; }
.intake .error { color: #FFB4A9; }

/* ── secciones y listas ─────────────────────────── */
.section { padding: 2.25rem 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.rows { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.row { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr) auto auto; gap: 1.25rem; align-items: center; padding: .9rem 1.1rem; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .os { font-weight: 600; }
.row .os small { display: block; font-weight: 400; color: var(--slate); }
.countdown { font-variant-numeric: tabular-nums; color: var(--slate); white-space: nowrap; }
.countdown.low { color: var(--stop); font-weight: 600; }
.live { display: inline-flex; align-items: center; gap: .4rem; font-size: var(--t-sm); color: var(--ink); }
.live::before { content: ""; width: .55rem; height: .55rem; border-radius: 50%; background: var(--hazard); box-shadow: 0 0 0 3px rgba(242,176,30,.3); }
.empty { padding: 2rem 1.1rem; color: var(--slate); }
.actions { display: flex; gap: .5rem; }

table.history { width: 100%; border-collapse: collapse; background: var(--paper); border: 1px solid var(--line); }
.history th { text-align: left; font-size: var(--t-sm); font-weight: 600; color: var(--slate); padding: .7rem 1rem; border-bottom: 1px solid var(--line); background: var(--porcelain); }
.history td { padding: .75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.history td.url { max-width: 32rem; }
.history tr:last-child td { border-bottom: 0; }

/* ── visor: el área de contención ───────────────── */
.viewer-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; padding: 1rem 0; }
.viewer-bar .target { flex: 1; min-width: 14rem; }
.viewer-bar .target .mono { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.containment {
  padding: 10px;
  background: repeating-linear-gradient(-45deg, var(--hazard) 0 14px, var(--ink) 14px 28px);
  border-radius: 2px;
}
.containment.ended { background: var(--line); }
.screen { position: relative; aspect-ratio: 16 / 9; background: var(--ink); }
.screen iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--ink); }
.screen .state { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: #E8ECEF; gap: .75rem; padding: 2rem; }
.screen .state h2 { color: #fff; font-size: var(--t-lg); }
.containment:fullscreen { padding: 6px; display: grid; place-content: center; }
.containment:fullscreen .screen { width: min(100vw - 12px, (100vh - 12px) * 16 / 9); }
.viewer-note { margin: .9rem 0 2rem; color: var(--slate); font-size: var(--t-sm); max-width: 75ch; }
.scan { width: 3rem; height: 3px; background: var(--hazard); margin: 0 auto; animation: scan 1.4s ease-in-out infinite alternate; }
@keyframes scan { from { transform: translateX(-1.5rem); } to { transform: translateX(1.5rem); } }

/* ── evidencia ─────────────────────────────────── */
.ev-head { padding: 2rem 0 1.25rem; border-bottom: 1px solid var(--line); }
.ev-head h1 { font-size: var(--t-lg); font-stretch: 80%; margin-top: .5rem; }
.ev-head .mono { font-size: 1rem; }
.ev-meta { display: flex; flex-wrap: wrap; gap: .5rem 2rem; margin-top: .75rem; color: var(--slate); font-size: var(--t-sm); }
.ev-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 2.5rem; padding: 2rem 0 3rem; }
.ev-block + .ev-block { margin-top: 2.25rem; }
.ev-block h2 { margin-bottom: .85rem; }
.trail { list-style: none; margin: 0; padding: 0; counter-reset: hop; }
.trail li { counter-increment: hop; position: relative; padding: 0 0 1rem 2.4rem; }
.trail li::before { content: counter(hop); position: absolute; left: 0; top: 0; width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 2px solid var(--ink); display: grid; place-content: center; font-size: var(--t-sm); font-weight: 700; background: var(--paper); }
.trail li:not(:last-child)::after { content: ""; position: absolute; left: calc(.8rem - 1px); top: 1.7rem; bottom: .1rem; width: 2px; background: var(--line); }
.trail .kind { font-size: var(--t-sm); color: var(--slate); }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .75rem; }
.shots button { padding: 0; border: 1px solid var(--line); background: var(--paper); cursor: zoom-in; border-radius: var(--radius); overflow: hidden; }
.shots img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; }
.shots figcaption { font-size: var(--t-sm); color: var(--slate); padding: .3rem .5rem; text-align: left; }
.file { background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--stop); border-radius: var(--radius); padding: .9rem 1rem; display: grid; gap: .4rem; }
.file + .file { margin-top: .6rem; }
.file .name { font-weight: 600; word-break: break-all; }
.file .hash { font-family: var(--mono); font-size: .8rem; color: var(--slate); word-break: break-all; }
.file .actions { flex-wrap: wrap; }
.fp { width: 100%; border-collapse: collapse; }
.fp th { text-align: left; font-weight: 500; color: var(--slate); padding: .45rem 1rem .45rem 0; vertical-align: top; width: 9rem; font-size: var(--t-sm); }
.fp td { padding: .45rem 0; border-bottom: 1px solid var(--line); }
.callout { background: var(--paper); border: 1px solid var(--line); padding: 1rem; border-radius: var(--radius); }
.back { display: inline-block; margin-top: 1.25rem; color: var(--slate); text-decoration: none; font-size: var(--t-sm); }
.back:hover { color: var(--ink); }

/* ── diálogo y aviso ───────────────────────────── */
.dialog { border: 0; border-radius: var(--radius); padding: 0; max-width: min(34rem, calc(100vw - 2rem)); box-shadow: 0 20px 60px rgba(23,33,43,.3); }
.dialog::backdrop { background: rgba(23,33,43,.55); }
.dialog .body { padding: 1.5rem; display: grid; gap: 1rem; }
.dialog .foot { display: flex; justify-content: flex-end; gap: .5rem; padding: 1rem 1.5rem; background: var(--porcelain); }
.dialog.shot { max-width: min(90rem, calc(100vw - 2rem)); }
.dialog.shot img { display: block; max-width: 100%; max-height: 80vh; }
.toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .75rem 1.1rem; border-radius: var(--radius); z-index: 20; max-width: calc(100vw - 2rem); }
.toast.bad { background: var(--stop); }

/* ── responsive ────────────────────────────────── */
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-side { padding: 2rem; min-height: 14rem; }
  .login-form { padding: 2rem; }
  .ev-grid { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr; gap: .5rem; }
  .usage { margin-left: 0; width: 100%; padding-bottom: .6rem; }
  .url-row { flex-direction: column; }
  .history thead { display: none; }
  .history tr { display: grid; padding: .5rem 0; border-bottom: 1px solid var(--line); }
  .history td { border: 0; padding: .2rem 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  .scan { animation: none; }
}

/* utilidades (sin estilos inline: la CSP los bloquea) */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.on-dark { color: #fff; }
.page-title { font-size: var(--t-lg); }
.run-select { max-width: 16rem; }
figure.shot { margin: 0; }
.spaced-top { margin-top: .6rem; }
.spaced-bottom { margin-bottom: .75rem; }
