:root {
  --bg: #0d1210;
  --surface: #151c19;
  --surface-2: #1d2622;
  --line: #2a3530;
  --text: #e8efe9;
  --muted: #8a998f;
  --accent: #7bd35b;      /* verd Hulk */
  --accent-ink: #0d1a08;
  --purple: #a77bf0;      /* pantalons del Hulk */
  --warn: #f0b14a;
  --danger: #ef6b5e;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px;
  align-items: center; text-align: center;
}
.login-card h1 { font-size: 28px; }
.login-card p { margin: 0 0 8px; }
.login-card input, .login-card .btn { width: 100%; }

input, select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text); padding: 11px 16px; border-radius: 10px; cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .5; }

/* ---------- layout */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--safe-t)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 20px; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  background: none; border: 0; color: var(--text); width: 40px; height: 40px;
  border-radius: 10px; display: grid; place-items: center; cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.view {
  padding: 16px 16px calc(88px + var(--safe-b));
  max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px;
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + var(--safe-b));
}
.tabbar button {
  background: none; border: 0; color: var(--muted); display: flex; flex-direction: column;
  align-items: center; gap: 3px; font: 600 10.5px/1 system-ui, sans-serif; padding: 6px 0; cursor: pointer;
}
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button.active { color: var(--accent); }

/* ---------- cards */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h2 { font-size: 15px; }
.card.link { cursor: pointer; }
.card.link:active { background: var(--surface-2); }
.card.err { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.stat b { display: block; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat span { color: var(--muted); font-size: 12px; }
.stat.accent b { color: var(--accent); }
.stat.purple b { color: var(--purple); }
.stat.warn b { color: var(--warn); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; flex: none; }
.dot.off { background: var(--danger); }
.dot.idle { background: var(--muted); }
.pill {
  font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.pill.green { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.pill.purple { background: color-mix(in srgb, var(--purple) 18%, transparent); color: var(--purple); }
.pill.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pill.red { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }

/* ---------- lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 11px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.list li:first-child { border-top: 0; padding-top: 2px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.row .meta { color: var(--muted); font-size: 12.5px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { color: var(--muted); font-size: 14px; padding: 4px 0; }

.bar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.bar.purple > i { background: var(--purple); }

.speeds { display: flex; gap: 18px; align-items: baseline; }
.speeds b { font-size: 24px; font-variant-numeric: tabular-nums; }
.speeds .down b { color: var(--accent); }
.speeds .up b { color: var(--purple); }

.segmented { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.segmented button {
  flex: 1; background: none; border: 0; color: var(--muted); font: 600 13px system-ui, sans-serif;
  padding: 8px 4px; border-radius: 8px; cursor: pointer;
}
.segmented button.active { background: var(--surface); color: var(--text); }

.alert { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.alert.red { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }

/* ---------- skeleton */
.skeleton { height: 92px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- dialog */
dialog {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 18px; padding: 20px; width: min(420px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { font-size: 18px; margin-bottom: 14px; }
dialog form { display: flex; flex-direction: column; gap: 12px; }
dialog label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
dialog label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: 14px; }
dialog label.check input { width: 20px; height: 20px; accent-color: var(--accent); }
dialog .btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.invite-url {
  font: 13px ui-monospace, monospace; background: var(--surface-2); padding: 12px; border-radius: 10px;
  word-break: break-all; user-select: all;
}

.toast {
  position: fixed; left: 50%; bottom: calc(86px + var(--safe-b)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 20; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); color: #fff; }

@media (min-width: 720px) {
  .tabbar { max-width: 720px; margin: 0 auto; border-radius: 16px 16px 0 0; border: 1px solid var(--line); border-bottom: 0; }
}
