:root {
  --bg: #F4F5F7; --surface: #FFFFFF; --sunken: #F4F5F7; --line: #E1E4E8; --line-strong: #C9CED5;
  --text: #16191D; --muted: #59626E; --soft: #3D4550;
  --accent: #0B5FAA; --accent-ink: #0B4F8C; --accent-soft: #E8F1FB; --accent-row: #F0F6FC;
  --ok: #1E7F4F; --ok-soft: #EAF5EE; --ok-ink: #155C39; --info: #3E6FB0; --warn: #B26A00; --warn-soft: #FBF1E4; --warn-ink: #8A4F00;
  --bad: #B42318; --bad-line: #E5B4AE; --off: #8A929C;
  --head: #16191D; --head-chip: #262B31; --head-ink: #E6E9ED; --head-muted: #C3C9D1;
  --term: #16191D; --term-ink: #D7DCE2;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1215; --surface: #171B20; --sunken: #12161A; --line: #262C33; --line-strong: #39414B;
    --text: #E6E9ED; --muted: #9AA3AE; --soft: #C3C9D1;
    --accent: #4C93D9; --accent-ink: #8CBBEA; --accent-soft: #16283B; --accent-row: #142233;
    --ok: #3DB37A; --ok-soft: #132A1E; --ok-ink: #7FD3A6; --info: #6E9BD6; --warn: #E0A040; --warn-soft: #2D2210; --warn-ink: #F0C27A;
    --bad: #F0786C; --bad-line: #5C2A26; --off: #6B737D;
    --head: #0A0C0F; --head-chip: #1C2127;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
code, pre, .mono { font-family: var(--mono); }
.boot { padding: 40px; color: var(--muted); }
[hidden] { display: none !important; }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.btn { min-height: 40px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface);
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: var(--bad-line); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 500; }
.btn.small { min-height: 34px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 40px; padding: 0; justify-content: center; }
.btn[disabled] { opacity: .55; cursor: default; }
svg.i { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* --- encabezado --- */
header.top { background: var(--head); color: #fff; }
header.top .in { max-width: 1480px; margin: 0 auto; padding: 12px 24px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 32px; height: 32px; border-radius: 8px; background: #0B5FAA; display: grid; place-items: center; }
.brand b { display: block; font-size: 16px; }
.brand span { font: 12px var(--mono); color: var(--head-muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; }
.chip { padding: 6px 10px; border-radius: 6px; background: var(--head-chip); color: var(--head-ink); }
nav.tabs-top { display: flex; gap: 4px; align-items: center; }
nav.tabs-top a, nav.tabs-top button { color: var(--head-muted); text-decoration: none; padding: 8px 12px; border-radius: 6px; background: none; border: 0; cursor: pointer; min-height: 40px; display: inline-flex; align-items: center; }
nav.tabs-top a[aria-current="page"] { background: var(--head-chip); color: #fff; }
nav.tabs-top a:hover, nav.tabs-top button:hover { color: #fff; }

/* --- layout principal --- */
.page { max-width: 1480px; margin: 0 auto; padding: 20px 24px 48px; display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.side { flex: 1 1 210px; padding: 12px; }
.side h3, .label-cap { margin: 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.side h3 { padding: 4px 8px 10px; }
.side input { width: 100%; min-height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); margin-bottom: 8px; }
.stack-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 40px; padding: 8px 10px;
  border: 0; border-radius: 6px; background: transparent; cursor: pointer; text-align: left; }
.stack-btn:hover { background: var(--sunken); }
.stack-btn[aria-current="true"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.stack-btn .n { font-size: 12px; color: var(--muted); font-weight: 400; display: flex; align-items: center; gap: 6px; }
.stack-btn .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.warnbadge { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }

.main { flex: 999 1 540px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.main h1 { margin: 0; font-size: 24px; }
.table-wrap { overflow-x: auto; }
.table { min-width: 680px; }
.tr { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.8fr) minmax(0, 1.25fr) minmax(0, 1.3fr) minmax(0, .8fr); gap: 12px; align-items: center; padding: 10px 16px; }
.thead { border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
button.tr { width: 100%; min-height: 52px; border: 0; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; background: var(--surface); cursor: pointer; text-align: left; }
button.tr:hover { background: var(--sunken); }
button.tr[aria-current="true"] { background: var(--accent-row); border-left-color: var(--accent); }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.status { display: flex; align-items: center; gap: 6px; }

.detail { flex: 1 1 470px; min-width: 0; overflow: hidden; }
.detail .hd { padding: 18px 20px 0; }
.detail h2 { margin: 4px 0 14px; font: 500 20px var(--mono); word-break: break-all; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { min-height: 44px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; cursor: pointer; color: var(--soft); white-space: nowrap; }
.tabs button[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.detail .bd { padding: 18px 20px 22px; display: flex; flex-direction: column; gap: 16px; }
.empty-detail { padding: 40px 20px; text-align: center; color: var(--muted); }

.box { background: var(--sunken); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.box code { word-break: break-all; font-size: 13px; }

.key { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.key.expired { opacity: .7; }
.key .fp { font: 12px var(--mono); color: var(--muted); word-break: break-all; }
.tag { padding: 3px 8px; border-radius: 4px; font-size: 12px; background: var(--sunken); color: var(--soft); border: 1px solid var(--line); }
.tag.shell { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; font-weight: 500; }
.tag.logs { background: var(--ok-soft); color: var(--ok-ink); border-color: transparent; font-weight: 500; }
.tag.sftp { background: var(--warn-soft); color: var(--warn-ink); border-color: transparent; font-weight: 500; }
.tag.bad { color: var(--bad); border-color: var(--bad-line); background: transparent; }
.dashed { border: 1px dashed var(--line-strong); border-radius: 8px; padding: 20px; text-align: center; color: var(--muted); font-size: 13px; }

.form { border: 1px solid var(--accent); border-radius: 8px; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .lbl { font-size: 13px; font-weight: 500; }
.field input[type=text], .field input[type=password], .field textarea { min-height: 40px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); width: 100%; }
.field textarea { font: 12px var(--mono); resize: vertical; }
.opts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.opt { min-height: 60px; padding: 8px 10px; border-radius: 6px; border: 1.5px solid var(--line-strong); background: var(--surface); cursor: pointer; text-align: left; }
.opt b { display: block; font-size: 13px; }
.opt span { font-size: 12px; color: var(--muted); }
.pill { min-height: 36px; padding: 0 12px; border-radius: 18px; border: 1.5px solid var(--line-strong); background: var(--surface); cursor: pointer; font-size: 13px; }
.opt[aria-pressed="true"], .pill[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }

.done { border: 1px solid var(--ok); background: var(--ok-soft); border-radius: 8px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.done h4 { margin: 0; color: var(--ok-ink); }
pre.code { margin: 0; padding: 10px 12px; background: var(--term); color: var(--term-ink); border-radius: 6px; font-size: 12px; overflow-x: auto; white-space: pre; }

.grid2 { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px 14px; font-size: 13px; }
.grid2 > :nth-child(odd) { color: var(--muted); }
.grid2 > :nth-child(even) { word-break: break-all; }
.actions4 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.actions4 .btn { justify-content: center; min-height: 44px; }

.logview { background: var(--term); color: var(--term-ink); border-radius: 8px; padding: 12px; height: 460px; overflow: auto; font: 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-all; }
.logview .ts { color: #7F8A96; }
.term { background: #16191D; border-radius: 8px; padding: 8px; height: 480px; }
.term .xterm { height: 100%; }

/* --- actividad --- */
.wide { flex: 1 1 100%; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.wide section { padding: 16px 20px; }
.wide h2 { margin: 0 0 12px; font-size: 18px; }
.list .li { display: grid; grid-template-columns: 150px 170px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; align-items: start; }
.list .li:last-child { border-bottom: 0; }
.ev { font-weight: 500; }
.ev.bad { color: var(--bad); }
.ev.ok { color: var(--ok); }

/* --- login --- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 420px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.auth h1 { margin: 0; font-size: 22px; }
.auth .err { color: var(--bad); font-size: 13px; min-height: 18px; margin: 0; }
.qr { width: 200px; height: 200px; background: #fff; border-radius: 8px; padding: 6px; align-self: center; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 8px; background: #16191D; color: #fff; z-index: 10; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
#toast.bad { background: var(--bad); }
dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); padding: 20px; max-width: 420px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog p { margin: 0 0 16px; }

@media (max-width: 640px) {
  header.top .in, .page { padding-left: 16px; padding-right: 16px; }
  .opts { grid-template-columns: 1fr; }
  .list .li { grid-template-columns: 1fr; gap: 2px; }
  .grid2 { grid-template-columns: 1fr; }
  .grid2 > :nth-child(odd) { margin-top: 6px; }
}
