/* Centro de mando — the /app visual system (ink + one accent + zinc
   surfaces, Inter, tracking-tight titles, tabular figures), at the density
   of a control room. Mobile first: the sidebar becomes a bottom bar under
   720 px; every table becomes cards; every command box scrolls sideways. */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("./fonts/inter-latin-var.woff2") format("woff2-variations"), url("./fonts/inter-latin-var.woff2") format("woff2"); }

:root {
  --accent: #0b0b0c; --on-accent: #fff;
  --ink: #0b0b0c; --bg: #fafafa; --surface: #fff; --surface-2: #f4f4f5; --surface-3: #e4e4e7;
  --border: rgba(228,228,231,.9); --border-strong: #d4d4d8;
  --text: #0b0b0c; --text-2: #3f3f46; --muted: #71717a; --faint: #a1a1aa;
  --danger: #dc2626; --danger-bg: #fef2f2; --danger-border: #fecaca;
  --ok: #047857; --ok-bg: #ecfdf5; --ok-border: #a7f3d0;
  --info: #0369a1; --info-bg: #f0f9ff; --info-border: #bae6fd;
  --warn: #b45309; --warn-bg: #fffbeb; --warn-border: #fde68a;
  --radius-lg: 1.1rem; --radius: .8rem; --radius-sm: .5rem;
  --shadow: 0 1px 2px rgba(11,11,12,.04), 0 12px 32px -12px rgba(11,11,12,.14);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --nav-w: 15rem; --nav-bg: var(--ink); --nav-text: rgba(255,255,255,.72); --nav-strong: #fff; --nav-active: rgba(255,255,255,.1);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0f0f11; --surface: #18181b; --surface-2: #202024; --surface-3: #2a2a30; --border: rgba(63,63,70,.7); --border-strong: #3f3f46;
  --text: #f4f4f5; --text-2: #d4d4d8; --muted: #a1a1aa; --faint: #71717a;
  --danger: #f87171; --danger-bg: #2a1616; --danger-border: #4c1d1d; --ok: #34d399; --ok-bg: #0f2a20; --ok-border: #14532d;
  --info: #7dd3fc; --info-bg: #0f2233; --info-border: #1e3a56; --warn: #fbbf24; --warn-bg: #2a2011; --warn-border: #713f12;
  --accent: #f4f4f5; --on-accent: #0b0b0c; --nav-bg: #0b0b0c; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); font-feature-settings: "tnum" 1, "cv11" 1; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.02em; line-height: 1.2; }
h1 { font-size: 1.5rem; font-weight: 750; } h2 { font-size: 1.15rem; font-weight: 700; } h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
code, pre, .mono { font-family: var(--mono); font-size: .86em; }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .tiny { font-size: .78rem; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── shell ─────────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; min-height: 100dvh; }
.nav { background: var(--nav-bg); color: var(--nav-text); padding: 1.1rem .9rem; position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: .2rem; }
.nav .brand { color: var(--nav-strong); font-weight: 800; letter-spacing: -.03em; font-size: 1.05rem; padding: .3rem .6rem 1rem; display: flex; align-items: center; gap: .5rem; }
.nav .brand .dot { width: .55rem; height: .55rem; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 4px rgba(52,211,153,.18); }
.nav a { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-radius: var(--radius-sm); text-decoration: none; font-weight: 550; }
.nav a:hover { background: rgba(255,255,255,.06); }
.nav a.active { background: var(--nav-active); color: var(--nav-strong); }
.nav a .ic { width: 1.1rem; text-align: center; opacity: .8; }
.nav .spacer { flex: 1; }
.nav .who { padding: .6rem .7rem; font-size: .8rem; opacity: .75; border-top: 1px solid rgba(255,255,255,.1); }
.nav .who button { background: none; border: 0; color: inherit; text-decoration: underline; padding: 0; cursor: pointer; }
main { padding: 1.4rem 1.6rem 4rem; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.page-head .ctx { color: var(--muted); margin-top: .25rem; max-width: 62ch; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ── cards & grid ──────────────────────────────────────────────────────── */
.grid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card h3 { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.card .kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .8rem; margin-top: .7rem; font-size: .9rem; }
.card .kv dt { color: var(--muted); } .card .kv dd { margin: 0; overflow-wrap: anywhere; }
.section { margin-top: 1.8rem; }
.section > h2 { margin-bottom: .2rem; }
.section > .ctx { color: var(--muted); margin-bottom: .8rem; max-width: 70ch; }
.fresh { font-size: .78rem; color: var(--muted); } .fresh.stale { color: var(--warn); } .fresh.bad { color: var(--danger); }

/* ── chips ─────────────────────────────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 650; border: 1px solid transparent; white-space: nowrap; }
.chip::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.chip.ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.chip.warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.chip.bad { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.chip.info { color: var(--info); background: var(--info-bg); border-color: var(--info-border); }
.chip.dim { color: var(--muted); background: var(--surface-2); border-color: var(--border); }

/* ── buttons ───────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .85rem; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-weight: 600; font-size: .9rem; line-height: 1.2; transition: transform .15s, background .15s; text-decoration: none; }
.btn:hover { background: var(--surface-2); } .btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.danger { color: var(--danger); border-color: var(--danger-border); background: var(--danger-bg); }
.btn.sm { padding: .3rem .6rem; font-size: .82rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.link { border: 0; background: none; padding: .2rem .3rem; text-decoration: underline; font-weight: 500; }

/* ── the three forms ───────────────────────────────────────────────────── */
.forma { border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; background: var(--surface); margin-top: .8rem; }
.forma .tag { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 750; color: var(--muted); margin-bottom: .35rem; }
.forma.hago { border-left: 4px solid var(--ok); } .forma.hago .tag { color: var(--ok); }
.forma.haces { border-left: 4px solid var(--info); } .forma.haces .tag { color: var(--info); }
.forma.bloqueado { border-left: 4px solid var(--warn); background: var(--warn-bg); } .forma.bloqueado .tag { color: var(--warn); }
.forma h4 { font-size: .98rem; margin-bottom: .3rem; }
.forma .porque { color: var(--text-2); font-size: .88rem; margin-top: .4rem; }
.cmd { position: relative; margin-top: .6rem; background: var(--ink); color: #e4e4e7; border-radius: var(--radius-sm); padding: .7rem 4.6rem .7rem .8rem; overflow-x: auto; font-family: var(--mono); font-size: .8rem; line-height: 1.5; white-space: pre; }
.cmd .copy { position: absolute; right: .5rem; top: .5rem; background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: .35rem; padding: .25rem .5rem; font-size: .72rem; cursor: pointer; font-family: var(--font); }
.cmd .copy:hover { background: rgba(255,255,255,.22); }
.verif { display: flex; align-items: center; gap: .6rem; margin-top: .6rem; flex-wrap: wrap; }
.verif .res { font-size: .86rem; } .verif .res.ok { color: var(--ok); } .verif .res.bad { color: var(--danger); }

/* ── failure block ─────────────────────────────────────────────────────── */
.fallo { border: 1px solid var(--danger-border); background: var(--danger-bg); border-radius: var(--radius); padding: .9rem 1rem; margin-top: .8rem; display: grid; gap: .5rem; }
.fallo h4 { color: var(--danger); }
.fallo .item b { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .1rem; }
.fallo .item pre { font-family: var(--mono); font-size: .8rem; background: rgba(0,0,0,.06); padding: .5rem .6rem; border-radius: .4rem; overflow-x: auto; white-space: pre-wrap; }
.aviso { border: 1px solid var(--warn-border); background: var(--warn-bg); border-radius: var(--radius); padding: .8rem 1rem; margin-top: .8rem; }
.nota { border: 1px solid var(--info-border); background: var(--info-bg); border-radius: var(--radius); padding: .8rem 1rem; margin-top: .8rem; }

/* ── steps & log ───────────────────────────────────────────────────────── */
.pasos { list-style: none; margin: .8rem 0 0; padding: 0; display: grid; gap: .35rem; }
.pasos li { display: grid; grid-template-columns: 1.6rem 1fr auto; gap: .5rem; align-items: start; padding: .45rem .6rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.pasos li .n { font-weight: 700; color: var(--muted); font-size: .85rem; }
.pasos li .st { font-size: .78rem; font-weight: 650; }
.pasos li.ok .st { color: var(--ok); } .pasos li.fallo .st { color: var(--danger); } .pasos li.corriendo .st { color: var(--info); } .pasos li.esperando .st { color: var(--warn); }
.pasos li .cmdline { color: var(--muted); font-family: var(--mono); font-size: .76rem; overflow-wrap: anywhere; }
.log { margin-top: .8rem; background: var(--ink); color: #d4d4d8; border-radius: var(--radius); padding: .8rem .9rem; max-height: 60vh; overflow: auto; font-family: var(--mono); font-size: .78rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.log .l-ok { color: #6ee7b7; } .log .l-bad { color: #fca5a5; } .log .l-hdr { color: #fcd34d; font-weight: 600; }

/* ── tables / lists ────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; } .table tr.click:hover td { background: var(--surface-2); }
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a { padding: .4rem .75rem; border-radius: 999px; text-decoration: none; font-weight: 600; font-size: .88rem; border: 1px solid var(--border); background: var(--surface); }
.tabs a.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.list li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .9rem; }
.list li .t { font-weight: 650; } .list li .d { color: var(--text-2); font-size: .88rem; margin-top: .2rem; }
.audit li { display: grid; grid-template-columns: 1.4rem 1fr; gap: .5rem; }
.audit .ok { color: var(--ok); } .audit .falta { color: var(--danger); } .audit .aviso { color: var(--warn); }

/* ── forms ─────────────────────────────────────────────────────────────── */
.form { display: grid; gap: .8rem; }
.field label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-2); margin-bottom: .25rem; }
.field input, .field select, .field textarea { width: 100%; padding: .55rem .7rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.field textarea { min-height: 5rem; resize: vertical; }
.field .help { font-size: .78rem; color: var(--muted); margin-top: .2rem; }
.field .err { font-size: .8rem; color: var(--danger); margin-top: .2rem; }
.field.bad input, .field.bad select, .field.bad textarea { border-color: var(--danger); }
.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.check input { width: 1.1rem; height: 1.1rem; }

/* ── modal / sheet ─────────────────────────────────────────────────────── */
.modal-bg { position: fixed; inset: 0; background: rgba(11,11,12,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem; }
.modal { background: var(--surface); border-radius: var(--radius-lg); max-width: 760px; width: 100%; max-height: 90vh; overflow: auto; padding: 1.2rem 1.3rem; box-shadow: 0 30px 80px -20px rgba(0,0,0,.5); }
.modal h2 { margin-bottom: .6rem; }
.modal .foot { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.plan { background: var(--surface-2); border-radius: var(--radius); padding: .8rem .9rem; white-space: pre-wrap; font-size: .9rem; line-height: 1.5; }

/* ── login ─────────────────────────────────────────────────────────────── */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1rem; background: var(--ink); }
.login .card { width: 100%; max-width: 380px; }
.login h1 { margin-bottom: .2rem; } .login .ctx { color: var(--muted); margin-bottom: 1rem; font-size: .9rem; }

/* ── toasts ────────────────────────────────────────────────────────────── */
.toasts { position: fixed; bottom: 4.6rem; left: 50%; transform: translateX(-50%); display: grid; gap: .4rem; z-index: 60; width: min(92vw, 420px); }
.toast { background: var(--ink); color: #fff; padding: .6rem .9rem; border-radius: var(--radius-sm); font-size: .88rem; box-shadow: var(--shadow); }
.toast.bad { background: var(--danger); }

/* stat tiles */
.tiles { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .9rem; }
.tile .v { font-size: 1.4rem; font-weight: 750; letter-spacing: -.02em; } .tile .l { font-size: .78rem; color: var(--muted); }
.tile.bad .v { color: var(--danger); } .tile.warn .v { color: var(--warn); } .tile.ok .v { color: var(--ok); }

/* ── mobile ────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto; flex-direction: row; padding: .35rem .3rem calc(.35rem + env(safe-area-inset-bottom)); justify-content: space-around; z-index: 40; }
  .nav .brand, .nav .spacer, .nav .who, .nav a.secondary { display: none; }
  .nav a { flex-direction: column; gap: .1rem; padding: .35rem .4rem; font-size: .68rem; font-weight: 600; }
  .nav a .ic { font-size: 1.1rem; }
  main { padding: 1rem .9rem 5.5rem; }
  h1 { font-size: 1.3rem; }
  .grid { grid-template-columns: 1fr; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--border); padding: .4rem 0; }
  .table td { border: 0; padding: .2rem .7rem; }
  .table td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: .78rem; }
  .modal { padding: 1rem; border-radius: var(--radius); max-height: 94vh; }
  .card .kv { grid-template-columns: 1fr; gap: .1rem; } .card .kv dt { margin-top: .35rem; }
  .pasos li { grid-template-columns: 1.4rem 1fr; } .pasos li .st { grid-column: 2; }
}
