/* Wara OTA: consola de releases. Todo deriva de los tokens de :root.
   Superficies en capas (página → tarjeta → panel) separadas por tono, sin bordes. */
:root {
  --frame: #efeff1; /* marco: barra lateral y alrededor del contenido */
  --page: #fbfbfc;
  --shell: #eeeef0;
  --inset: #ffffff;
  --raised: #e2e2e5;
  --fg: #141414;
  --fg-2: #606065;
  --brand: #0071e3;
  --neg: #d70015;
  --warn: #9a5b00;
  --backdrop: rgb(20 20 20 / 0.32);

  --line: color-mix(in srgb, var(--fg) 8%, transparent);
  --hover: color-mix(in srgb, var(--fg) 5%, transparent);
  --track: color-mix(in srgb, var(--fg) 9%, transparent);
  --neg-soft: color-mix(in srgb, var(--neg) 10%, transparent);
  --pend: #9cc7f3; /* bajado, falta reiniciar: el azul de datos, más claro */
  --current: var(--page); /* sección actual en la barra y opción elegida */

  --sans: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-card: 22px; /* tarjeta: 16 del panel + 6 de borde tonal, concéntricos (Surface de TuffUI) */
  --r-2xl: 24px;
  --r-pill: 999px;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-press: cubic-bezier(0.2, 0, 0, 1);
  --t-enter: 200ms;
  --t-exit: 140ms;
  --t-move: 300ms;
  color-scheme: light;
}
/* Oscuro: lo pide el sistema (salvo que se eligió claro) o se eligió a mano. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --frame: #070708;
    --page: #0e0e0f;
    --shell: #19191a;
    --inset: #111112;
    --raised: #28282a;
    --fg: #ededed;
    --fg-2: #a1a1a6;
    --brand: #0a84ff;
    --neg: #ff453a;
    --warn: #ffb340;
    --backdrop: rgb(0 0 0 / 0.6);
    --pend: #5f87b3;
    --current: #222224;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --frame: #070708;
  --page: #0e0e0f;
  --shell: #19191a;
  --inset: #111112;
  --raised: #28282a;
  --fg: #ededed;
  --fg-2: #a1a1a6;
  --brand: #0a84ff;
  --neg: #ff453a;
  --warn: #ffb340;
  --backdrop: rgb(0 0 0 / 0.6);
  --pend: #5f87b3;
  --current: #222224;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--frame); color: var(--fg); font: 400 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
body { min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--page), 0 0 0 4px var(--brand); border-radius: var(--r-sm); }
h1, h2, p { margin: 0; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-size: 0.875em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.meta { color: var(--fg-2); font-size: 13px; }
.loading { color: var(--fg-2); padding: 24px 0; }
.empty { padding: 32px; border-radius: var(--r-lg); background: var(--shell); color: var(--fg-2); }
.panel > .empty-inline { padding: 16px 12px; color: var(--fg-2); font-size: 14px; }

/* ── Estructura ──
   El marco lleva la navegación; el contenido va en una superficie propia,
   un tono más arriba, con las tarjetas adentro. */
.app { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 36px 12px 16px; display: flex; flex-direction: column; gap: 28px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 8px; padding: 0 10px; min-height: 32px; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.brand > span:last-child { color: var(--fg-2); font-weight: 400; margin-left: -2px; }
.mark { display: inline-flex; gap: 2px; margin-right: 4px; }
.mark i { width: 3px; height: 14px; border-radius: 1px; background: var(--brand); }
.mark i:last-child { background: color-mix(in srgb, var(--fg) 24%, transparent); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 32px; padding: 6px 10px; border-radius: var(--r-sm); color: var(--fg-2); font-size: 14px; transition: background-color 120ms ease-out, color 120ms ease-out; }
.nav a:hover { background: var(--hover); color: var(--fg); }
.nav a[aria-current="page"] { background: var(--current); color: var(--fg); font-weight: 500; }
.nav .label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav .count { flex: none; font-size: 12px; font-weight: 400; color: var(--fg-2); }
.nav .count.neg { color: var(--neg); font-weight: 500; }
.nav .group { padding: 22px 10px 4px; font-size: 12px; font-weight: 500; color: var(--fg-2); }
.who { margin-top: auto; display: grid; gap: 12px; padding: 0; font-size: 13px; color: var(--fg-2); }
/* Tema: sistema, claro u oscuro. La píldora se desliza a la opción elegida (--i). */
.theme { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--fg) 6%, transparent); }
.theme::before { content: ""; position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc((100% - 6px) / 3); border-radius: var(--r-pill); background: var(--current); transform: translateX(calc(var(--i, 0) * 100%)); transition: transform 200ms var(--ease-out); }
.theme.instant::before { transition: none; }
.theme button { position: relative; border: 0; background: transparent; min-height: 28px; padding: 0 8px; border-radius: var(--r-pill); color: var(--fg-2); font-size: 12px; font-weight: 400; transition: color 150ms var(--ease-press), scale 150ms var(--ease-press); }
.theme button:hover { color: var(--fg); }
.theme button[aria-checked="true"] { color: var(--fg); font-weight: 500; }
.account { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-left: 10px; }
.account .btn { padding: 0 10px; }
.person { display: grid; min-width: 0; line-height: 1.35; }
.person .name { color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .role { font-size: 12px; }
main { margin: 8px 8px 8px 0; padding: 24px 40px 64px; min-width: 0; border-radius: var(--r-xl); background: var(--page); }
.page { max-width: 1680px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }

.page-head { display: grid; gap: 6px; margin-bottom: 8px; }
.head-row { display: flex; flex-wrap: wrap; align-items: baseline; align-content: center; justify-content: space-between; gap: 8px 16px; min-height: 40px; }
.head-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; font-size: 26px; line-height: 1.2; letter-spacing: -0.02em; }
.crumb { color: var(--fg-2); border-radius: var(--r-sm); transition: color 120ms ease-out; }
.crumb:hover { color: var(--fg); }
.head-title .sep { color: color-mix(in srgb, var(--fg) 24%, transparent); font-weight: 300; }
h1:focus-visible { box-shadow: none; }
h1 { font-size: inherit; line-height: inherit; font-weight: 600; letter-spacing: inherit; min-width: 0; overflow-wrap: anywhere; }
.sub { color: var(--fg-2); font-size: 14px; max-width: 75ch; }
.fresh { flex: none; border: 0; background: transparent; min-height: 32px; padding: 0 12px; margin-right: -12px; border-radius: var(--r-pill); color: var(--fg-2); font-size: 12px; transition: background-color 150ms var(--ease-press), color 150ms var(--ease-press), scale 150ms var(--ease-press), filter 0s linear 300ms; }
.fresh:hover { background: var(--hover); color: var(--fg); }
.fresh[aria-busy] { cursor: progress; }

/* Un número que cambió desde la última actualización entra rodando. */
.counted { display: inline-block; }
.counted.roll-up { animation: roll-up 480ms var(--ease-out); }
.counted.roll-down { animation: roll-down 480ms var(--ease-out); }
@keyframes roll-up { from { opacity: 0; transform: translateY(0.45em); } }
@keyframes roll-down { from { opacity: 0; transform: translateY(-0.45em); } }

/* Carga entre pantallas: barra fina arriba, sólo si tarda. */
.busy-bar { position: fixed; inset: 0 0 auto; height: 2px; z-index: 20; overflow: hidden; opacity: 0; pointer-events: none; transition: opacity var(--t-exit) ease-out; }
.busy-bar::after { content: ""; position: absolute; inset: 0; background: var(--brand); transform: scaleX(0); transform-origin: left; }
body.busy .busy-bar { opacity: 1; transition-duration: var(--t-enter); }
/* Crece una vez y se frena antes del final: avanza mientras carga, sin loop. */
body.busy .busy-bar::after { animation: busy 3s var(--ease-out) forwards; }
@keyframes busy { to { transform: scaleX(0.85); } }
/* Las actualizaciones automáticas redibujan sin animar. */
.quiet .ticks i[class] { animation: none; }
.fresh.stale, .fresh.stale:hover { color: var(--neg); }

/* ── Tarjeta (capa tonal) y panel (capa interna) ── */
.card { display: block; background: var(--shell); border-radius: var(--r-card); padding: 6px; }
.card.linked { position: relative; }
.card.linked:hover { background: var(--raised); }
.card.linked { cursor: pointer; }
.card.linked h2 a:hover { text-decoration: underline; text-underline-offset: 3px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 4px 8px 10px; }
.card-head h2 { font-size: 15px; font-weight: 500; }
.card-head .sub { margin-top: 0; font-size: 13px; }
.panel { background: var(--inset); border-radius: var(--r-lg); padding: 4px 8px; overflow-x: auto; }
.board { display: grid; gap: 16px; }
/* Binarios de una app: una columna, o dos cuando entran de al menos 600 px. */
.lane-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 600px), 1fr)); gap: 16px; align-items: start; }

/* ── Binarios en uso ── */
.lanes { padding: 0; overflow: visible; }
.lane-row { display: grid; grid-template-columns: 184px minmax(0, 1fr) 168px; gap: 8px 24px; align-items: start; padding: 16px 20px; }
.lane-row + .lane-row { box-shadow: inset 0 1px 0 var(--line); }
.lane-id { display: grid; gap: 4px; }
.lane-name { font-size: 14px; font-weight: 500; }
.lane-mid { display: grid; gap: 8px; min-width: 0; }
.lane-live { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: 14px; }
.lane-live .msg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane-count { display: grid; justify-items: end; gap: 8px; font-size: 14px; white-space: nowrap; }
.idle { color: var(--fg-2); font-size: 14px; }
.fail { color: var(--neg); font-size: 13px; font-weight: 500; }
.sub .alert { display: block; color: var(--neg); }
.sub .alert a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.idle a { color: var(--fg); }
.idle a:hover { text-decoration: underline; }

.panel.pad { padding: 20px; }
.lane { display: grid; gap: 12px; }
.lane-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.lane-msg { font-size: 17px; font-weight: 500; letter-spacing: -0.01em; }
.lane > .ticks { display: flex; width: 100%; height: 24px; gap: 2px; margin-top: 4px; }
.lane > .ticks i { flex: 1; width: auto; height: 24px; border-radius: 1px; }
.breakdowns { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px 32px; }
.breakdowns:empty { display: none; }
.status { font-size: 13px; font-weight: 500; white-space: nowrap; }
.status.muted { color: var(--fg-2); font-weight: 400; }
.status.brand { color: var(--brand); }
.status.warn { color: var(--warn); }
.status.neg { color: var(--neg); }

/* Barra de 20 ticks: lo corren · falta reiniciar · en otra versión. */
.ticks { display: inline-flex; gap: 2px; height: 16px; }
.ticks i { width: 4px; height: 16px; border-radius: 2px; background: var(--track); }
.ticks i.on, .key.on::before { background: var(--brand); }
.ticks i.pend, .key.pend::before { background: var(--pend); }
.ticks i.behind, .key.behind::before { background: color-mix(in srgb, var(--fg) 24%, transparent); }
/* Fuera del rollout: no les corresponde, así que sólo el contorno. */
.ticks i.out, .key.out::before { background: transparent; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fg) 22%, transparent); }
.ticks i[class] { animation: tick-in 240ms var(--ease-out) both; animation-delay: calc(var(--i) * 12ms); }
@keyframes tick-in { from { background: var(--track); } }

/* Referencias: marcador + número + etiqueta. */
.key { display: inline-flex; align-items: center; gap: 8px; }
.key::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 2px; }
.legend { display: inline-flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--fg-2); }
.legend b { font-weight: 500; color: var(--fg); }
.legend-full { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 0; }
.legend-full .key { display: grid; grid-template-columns: 8px auto; column-gap: 8px; align-items: center; justify-content: start; }
.legend-full dt { font-size: 12px; color: var(--fg-2); }
.legend-full dd { grid-column: 1 / -1; margin: 4px 0 0; font-size: 20px; line-height: 1.2; letter-spacing: -0.01em; }
.legend-full .note { font-size: 13px; color: var(--fg-2); letter-spacing: 0; }
.key-out dt { font-size: 12px; color: var(--fg-2); }
.key-out dd { margin: 4px 0 0; font-size: 20px; line-height: 1.2; color: var(--fg-2); }
.legend .outside { color: var(--fg-2); }
.others ul { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.others li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: baseline; }
.others li:has(> .msg:first-child) { grid-template-columns: minmax(0, 1fr) auto; }
.others .msg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding-top: 12px; box-shadow: inset 0 1px 0 var(--line); }
.act-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.act-group .meta { margin-right: 4px; }

/* ── Botones ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--r-pill); border: 0; background: var(--shell); font-size: 14px; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--raised); }
.btn.primary { background: var(--fg); color: var(--page); }
.btn.primary:hover { background: color-mix(in srgb, var(--fg) 82%, var(--page)); }
.btn.danger { color: var(--neg); background: transparent; }
.btn.danger:hover { background: var(--neg-soft); }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn.ghost { background: transparent; color: var(--fg-2); }
.btn.ghost:hover { background: var(--hover); color: var(--fg); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
/* Al presionar se achica apenas. Pendiente: el atenuado espera 150 ms y dura al
   menos 300 ms, así una acción rápida no parpadea (como UI SDK de Vercel). */
.btn { transition: background-color 150ms var(--ease-press), color 150ms var(--ease-press), scale 150ms var(--ease-press), filter 0s linear 300ms; }
.btn[aria-busy="true"], .fresh[aria-busy] { filter: opacity(0.6); cursor: progress; transition: filter 0s linear 150ms; }
.btn, .fresh, .nav a, .crumb, .theme button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
@media (prefers-reduced-motion: no-preference) {
  .btn:active:not(:disabled):not([aria-disabled="true"]), .fresh:active, .theme button:active { scale: 0.97; }
}

/* ── Tablas densas ── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; height: 40px; padding: 0 8px; font-weight: 400; color: var(--fg-2); font-size: 12px; white-space: nowrap; }
.table td { height: 44px; padding: 8px; box-shadow: inset 0 1px 0 var(--line); vertical-align: middle; white-space: nowrap; }
.table th:first-child, .table td:first-child { padding-left: 12px; }
.table th:last-child, .table td:last-child { padding-right: 12px; }
/* El mensaje toma el espacio que sobra y se corta con elipsis. */
.table td.grow { width: 100%; max-width: 0; min-width: 160px; }
.table .msg { display: block; overflow: hidden; text-overflow: ellipsis; }
.table tr.withdrawn td { color: var(--fg-2); }
.table tr.withdrawn .msg { text-decoration: line-through; }
.table .neg { color: var(--neg); font-weight: 500; }
.table td.num, .table th.num { text-align: right; }
.nowrap { white-space: nowrap; }

/* ── Formularios, login y diálogos ── */
.field { display: grid; gap: 8px; }
.field > span { font-size: 13px; color: var(--fg-2); }
.field input, .field select, .field textarea { min-height: 44px; padding: 8px 12px; border-radius: var(--r-md); border: 0; background: var(--shell); }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { box-shadow: 0 0 0 2px var(--brand); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--page); }
.login form { width: min(360px, 100%); display: grid; gap: 16px; }
.login .brand { padding: 0; margin-bottom: 24px; }
.login h1 { margin-bottom: 8px; }
.login .btn { width: 100%; margin-top: 8px; }
.error { color: var(--neg); font-size: 14px; min-height: 20px; }

/* Con un diálogo abierto, la página de atrás no se desplaza. */
html:has(dialog[open]) { overflow: hidden; }
dialog { border: 0; border-radius: var(--r-2xl); background: var(--inset); color: var(--fg); padding: 32px; width: min(480px, calc(100vw - 32px)); }
dialog[open] { animation: dlg-in var(--t-enter) var(--ease-out); }
dialog[open]::backdrop { background: var(--backdrop); animation: fade-in var(--t-enter) ease-out; }
dialog.leaving { animation: dlg-out var(--t-exit) var(--ease-out) forwards; }
dialog.leaving::backdrop { animation: fade-out var(--t-exit) ease-out forwards; }
dialog form { display: grid; gap: 16px; }
dialog h2 { font-size: 24px; font-weight: 500; letter-spacing: -0.015em; }
dialog p { color: var(--fg-2); font-size: 14px; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(0.97); } }
@keyframes dlg-out { to { opacity: 0; transform: scale(0.97); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.secret { font-family: var(--mono); font-size: 13px; padding: 12px; border-radius: var(--r-md); background: var(--shell); word-break: break-all; }

/* Tooltip: texto de apoyo invertido, chico, sin flecha. Crece desde el lado del control. */
.tip { position: fixed; z-index: 40; max-width: min(360px, calc(100vw - 16px)); padding: 6px 10px; border-radius: var(--r-sm); background: var(--fg); color: var(--page); font-size: 12px; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; pointer-events: none; transform-origin: 50% 100%; animation: tip-in 150ms var(--ease-out); }
.tip[data-side="bottom"] { transform-origin: 50% 0; }
.tip.instant { animation: none; }
.tip.mono { font-family: var(--mono); font-size: 11px; }
@keyframes tip-in { from { opacity: 0; scale: 0.96; } }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; padding: 12px 16px; border-radius: var(--r-md); background: var(--fg); color: var(--page); font-size: 14px; max-width: calc(100vw - 48px); animation: toast-in var(--t-enter) var(--ease-out); }
.toast.error { background: var(--neg); color: var(--page); font-weight: 500; }
.toast.leaving { animation: toast-out var(--t-exit) var(--ease-out) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(4px); } }

/* ── Responsive ── */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 12px 12px 8px; gap: 8px; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
  .brand { padding: 0 4px; }
  .nav { order: 3; width: 100%; flex-direction: row; overflow-x: auto; padding-bottom: 4px; mask-image: linear-gradient(to right, black calc(100% - 32px), transparent); }
  .nav a { flex: none; min-height: 44px; }
  .nav .group { display: none; }
  .who { margin-top: 0; padding: 0; display: flex; align-items: center; gap: 8px; }
  .person { display: none; }
  .account { padding: 0; }
  main { margin: 0; padding: 20px 16px 48px; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .head-title { font-size: 22px; }
  .lane-row { grid-template-columns: minmax(0, 1fr) auto; padding: 16px; }
  .lane-mid { grid-column: 1 / -1; grid-row: 2; }
  .panel.pad { padding: 16px; }
  .legend-full dd { font-size: 18px; }
  .card-head { padding: 8px 8px 12px; }
  .btn.small { min-height: 44px; }
  .lane-count { grid-column: 2; grid-row: 1; }
  .lane > .ticks { gap: 1px; }
  .lane-head { flex-direction: column; gap: 4px; }
}

/* En pantallas táctiles, iOS agranda la página si el campo tiene menos de 16 px. */
@media (pointer: coarse) {
  .field input, .field select, .field textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::backdrop { animation: none !important; transition: none !important; }
}
