:root {
  --bg: #0d1117; --bg2: #161b22; --bg3: #1f2630; --line: #2a3340; --text: #e6edf3; --muted: #8b98a8;
  --accent: #4ea1ff; --ok: #3fb950; --warn: #d29922; --bad: #f85149; --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f5f7fa; --bg2: #ffffff; --bg3: #eef1f5; --line: #d8dee6; --text: #1b2430; --muted: #5d6b7c; --accent: #0b6bcb; color-scheme: light; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- layout */
header.top {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top) + 8px) 14px 0;
}
.top-row { display: flex; align-items: center; gap: 10px; max-width: 1280px; margin: 0 auto; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; }
.brand img { width: 26px; height: 26px; }
.spacer { flex: 1; }
.seg { display: inline-flex; background: var(--bg3); border-radius: 10px; padding: 3px; gap: 2px; }
.seg a { padding: 6px 14px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.seg a.on { background: var(--bg2); color: var(--text); box-shadow: 0 1px 2px #0004; }
.icon-btn { background: none; border: 0; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--muted); display: inline-flex; }
.icon-btn:hover, .icon-btn.on { background: var(--bg3); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; max-width: 1280px; margin: 8px auto 0; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 8px 12px 10px; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; font-weight: 500; }
.tabs a.on { color: var(--text); border-color: var(--accent); }
main { max-width: 1280px; margin: 0 auto; padding: 14px 14px calc(env(safe-area-inset-bottom) + 80px); }
h1 { font-size: 20px; margin: 4px 0 12px; }
h2 { font-size: 16px; margin: 18px 0 10px; }
h3 { font-size: 14px; margin: 12px 0 6px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

/* bottom nav (celular) */
nav.bottom { display: none; }
@media (max-width: 720px) {
  .top-row .seg, .top-row .desk { display: none; }
  nav.bottom {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--bg2);
    border-top: 1px solid var(--line); padding: 6px 0 calc(env(safe-area-inset-bottom) + 6px);
  }
  nav.bottom a { flex: 1; text-align: center; color: var(--muted); font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
  nav.bottom a.on { color: var(--accent); }
  nav.bottom svg { width: 22px; height: 22px; }
}

/* ---------- componentes */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.chip { border: 1px solid var(--line); background: var(--bg2); border-radius: 999px; padding: 5px 12px; white-space: nowrap; cursor: pointer; color: var(--muted); }
.chip.on { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 16%, var(--bg2)); }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card.link { cursor: pointer; transition: border-color .15s, transform .15s; }
.card.link:hover { border-color: var(--accent); }
.card-h { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.card-h .t { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; background: var(--muted); }
.dot.ok { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--bg3); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--ok); } .badge.bad { color: var(--bad); } .badge.warn { color: var(--warn); }
.bar { height: 6px; background: var(--bg3); border-radius: 4px; overflow: hidden; margin: 3px 0 8px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar > i.warn { background: var(--warn); } .bar > i.bad { background: var(--bad); }
.metric { font-size: 12px; display: flex; justify-content: space-between; color: var(--muted); }
.error { background: color-mix(in srgb, var(--bad) 12%, var(--bg2)); border: 1px solid color-mix(in srgb, var(--bad) 40%, var(--line)); color: var(--text); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.note { background: var(--bg3); padding: 10px 12px; border-radius: 10px; font-size: 14px; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--bg3); padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 500; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn:disabled { opacity: .5; cursor: wait; }
input[type=text], input[type=search], input[type=number], select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-color: var(--accent); }
label.f { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label.f > span { display: block; margin-bottom: 4px; }
.form-grid { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
pre.out { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; overflow: auto; max-height: 60vh; font: 12.5px/1.4 var(--mono); white-space: pre-wrap; word-break: break-all; margin: 8px 0 0; }
.loading { color: var(--muted); padding: 24px 0; text-align: center; }
.loading::before { content: ""; display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; margin-right: 8px; vertical-align: -2px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); margin-bottom: 8px; }

/* tablas */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg2); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--bg2); }
tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--bg3); }
tr.off td { opacity: .5; }
td.wrap { white-space: normal; min-width: 220px; }
.tbl-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.tbl-tools input { max-width: 320px; }

/* puertos del switch */
.ports { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.port { background: var(--bg2); border: 1px solid var(--line); border-left: 4px solid var(--muted); border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.port.up { border-left-color: var(--ok); }
.port.slow { border-left-color: var(--warn); }
.port .n { font-weight: 600; font-size: 13px; }
.port .l { font-size: 13px; min-height: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.port .m { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: #0009; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--bg2); border: 1px solid var(--line); border-radius: 16px 16px 0 0; width: 100%; max-width: 760px; max-height: 92vh; overflow: auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px); }
@media (min-width: 721px) { .modal-bg { align-items: center; } .modal { border-radius: 16px; } }
.modal-h { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.modal-h .t { font-weight: 700; font-size: 16px; flex: 1; }
.qr { background: #fff; border-radius: 12px; padding: 8px; display: inline-block; }
.qr svg { display: block; width: 260px; height: 260px; }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translateX(-50%); background: var(--bg3); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 60; box-shadow: 0 6px 24px #0006; }
.list { display: flex; flex-direction: column; gap: 6px; }
.list-item { display: flex; align-items: center; gap: 10px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.list-item .grow { flex: 1; min-width: 0; }
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.stat { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; min-width: 130px; flex: 1; }
.stat .v { font-size: 22px; font-weight: 700; }
.stat .k { font-size: 12px; color: var(--muted); }

/* login */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { text-align: center; max-width: 320px; width: 100%; }
.login-box h1 { font-size: 28px; margin: 12px 0 0; letter-spacing: 1px; }
.login-box .btn.google { display: inline-flex; align-items: center; gap: 10px; justify-content: center; width: 100%; padding: 12px; margin-top: 24px; background: #fff; color: #1f1f1f; border-color: #dadce0; }
.login-box .error { margin-top: 16px; }
