:root {
  --bg: #0b1220;
  --card: #131c2e;
  --card-2: #1b2740;
  --text: #e8edf6;
  --muted: #8a97ad;
  --accent: #4f8cff;
  --accent-2: #2a6adf;
  --ok: #35c26b;
  --warn: #f0b429;
  --danger: #ff5a5a;
  --border: #22304a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

button { font: inherit; cursor: pointer; }
h1 { font-size: 1.4rem; margin: 0 0 6px; }
h2 {
  font-size: 0.8rem; margin: 0 0 14px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.muted { color: var(--muted); }
.err { color: var(--danger); font-size: 0.9rem; min-height: 1.2em; margin: 8px 0 0; }
code { background: #0c1424; padding: 2px 6px; border-radius: 6px; font-size: 0.85em; }

/* ---------- LOGIN ---------- */
.login {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg); padding: 24px; z-index: 50;
}
.login-box {
  width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 24px;
}
.login-box input {
  background: #0c1424; border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); padding: 12px 14px; font-size: 1rem;
}
.login-box input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.login-box button {
  background: var(--accent); color: #fff; border: 0; border-radius: 10px;
  padding: 13px; font-weight: 700; font-size: 1rem;
}

/* ---------- TOP BAR + TABS ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 10;
}
.brand { font-weight: 700; }
.link-btn { background: none; border: 0; color: var(--muted); font-size: 0.9rem; }
.link-btn:hover { color: var(--text); }

.tabs {
  display: flex; gap: 4px; padding: 8px 12px; overflow-x: auto;
  position: sticky; top: 49px; background: var(--bg); z-index: 9;
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1; min-width: max-content; background: none; border: 0;
  color: var(--muted); padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 0.9rem;
}
.tab.active { color: var(--text); background: var(--card-2); }

main { max-width: 640px; margin: 0 auto; padding: 16px; }

/* ---------- CARDS ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px; margin-bottom: 14px;
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field span { font-size: 0.85rem; color: var(--muted); }
.field select, .field input {
  background: #0c1424; border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); padding: 11px 12px; font-size: 1rem; width: 100%;
}
.field select:focus, .field input:focus { outline: 2px solid var(--accent); border-color: transparent; }

.buttons { display: flex; flex-wrap: wrap; gap: 10px; }
button.secondary, button.ghost, #btn-enable, #btn-add-team {
  border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 600; font-size: 0.95rem; color: #fff;
}
#btn-enable, #btn-add-team { background: var(--accent); }
#btn-enable:hover, #btn-add-team:hover { background: var(--accent-2); }
button.secondary { background: #26324a; }
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.state { font-weight: 600; margin: 0 0 14px; }
.state.on { color: var(--ok); }
.state.off { color: var(--muted); }
.state.err { color: var(--danger); }

.hint { color: var(--muted); font-size: 0.85rem; margin: 12px 0 0; }

/* ---------- LISTS ---------- */
.list { list-style: none; padding: 0; margin: 0; }
.list li {
  padding: 11px 0; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.list li:last-child { border-bottom: 0; }
.list .muted { justify-content: flex-start; }
.list .col { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.list .col .sub { font-size: 0.8rem; color: var(--muted); }
.badge { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.badge.live { color: var(--warn); }
.badge.losing { color: var(--danger); }
.x-btn {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; width: 30px; height: 30px; flex: none; font-size: 1rem;
}
.x-btn:hover { color: var(--danger); border-color: var(--danger); }

footer { max-width: 640px; margin: 8px auto 24px; padding: 0 16px; color: var(--muted); font-size: 0.8rem; text-align: center; }
