* { box-sizing: border-box; }
:root {
  --bg: #0a0d13;
  --bg-elev: #111621;
  --bg-elev2: #171d2a;
  --border: #212836;
  --border-strong: #2b3444;
  --text: #e8ecf2;
  --text-dim: #8a93a3;
  --text-muted: #5e6676;
  --accent: #4f80ff;
  --accent-2: #7c5cff;
  --accent-grad: linear-gradient(135deg, #4f80ff 0%, #7c5cff 100%);
  --success: #26d07c;
  --danger: #ff5e7a;
  --warn: #ffb547;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 14px;
  --radius-sm: 10px;
}

html, body {
  margin: 0; padding: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #1a2340 0%, transparent 60%),
              radial-gradient(900px 500px at 110% 10%, #2a1b44 0%, transparent 60%),
              var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Text", Roboto, Inter, sans-serif;
  font-size: 15px; line-height: 1.5;
  min-height: 100vh;
}
a { color: #a5c2ff; text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* --- Top bar --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 22px;
  background: rgba(10,13,19,.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .logo {
  font-weight: 800; color: #fff; font-size: 18px; letter-spacing: -0.3px;
  display: inline-flex; align-items: center; gap: 8px;
}
.topbar .logo::before {
  content: ''; width: 26px; height: 26px; border-radius: 8px;
  background: var(--accent-grad);
  box-shadow: 0 4px 14px rgba(79,128,255,.35);
}
.topbar nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.topbar nav a {
  color: var(--text-dim); padding: 8px 12px; border-radius: 8px; font-weight: 500;
  transition: background .15s, color .15s;
}
.topbar nav a:hover { color: var(--text); background: var(--bg-elev); text-decoration: none; }
.topbar nav a.active { color: #fff; background: var(--bg-elev2); }
.topbar .avatar { margin-left: 6px; }
.topbar .logout {
  margin-left: 4px; color: var(--text-muted); font-size: 13px;
}

/* --- Container --- */
main { max-width: 960px; margin: 0 auto; padding: 26px 20px 100px; }

h1 { font-size: 28px; margin: 10px 0 22px; letter-spacing: -0.5px; font-weight: 700; }
h2 { font-size: 18px; margin: 32px 0 14px; font-weight: 600; color: var(--text); }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; font-size: 14px; font-weight: 600;
  border-radius: 11px; border: none; cursor: pointer;
  color: #fff; transition: transform .08s, filter .15s, background .15s;
  line-height: 1;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent-grad); box-shadow: 0 6px 18px rgba(79,128,255,.28); }
.btn.secondary { background: var(--bg-elev2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: #2a1319; color: var(--danger); border: 1px solid #3d1b23; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; transform: none; }

/* --- Feedback --- */
.error { background: #2a1319; color: #ffa6b3; padding: 11px 14px; border-radius: 10px; margin-bottom: 12px; border: 1px solid #3d1b23; }
.ok    { background: #0f2b1e; color: #7fe2b2; padding: 11px 14px; border-radius: 10px; margin-bottom: 12px; border: 1px solid #164530; }
.muted { color: var(--text-dim); font-size: 13px; }
.text-muted { color: var(--text-muted); }

/* --- Hero --- */
.hero { padding: 30px 16px 40px; text-align: center; }
.hero .eyebrow {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  background: rgba(124,92,255,.14); color: #b6a4ff; font-size: 12px;
  margin-bottom: 18px; border: 1px solid rgba(124,92,255,.28);
}
.hero h1 { font-size: 38px; margin: 6px 0 14px; letter-spacing: -0.8px; line-height: 1.15; }
.hero .sub { color: var(--text-dim); max-width: 540px; margin: 0 auto 28px; font-size: 16px; }
.hero .cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* --- Cards --- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 20px 0; }
.card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 6px; min-height: 110px;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--border-strong); }
.card .label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .8px; font-weight: 500; }
.card .value { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; color: #fff; }
.card .value small { font-size: 15px; color: var(--text-dim); font-weight: 500; }
.card .bar {
  height: 6px; background: rgba(255,255,255,.06); border-radius: 3px; overflow: hidden; margin-top: 10px;
}
.card .bar span { display: block; height: 100%; background: var(--accent-grad); border-radius: 3px; transition: width .6s cubic-bezier(.2,.8,.2,1); }

/* --- Panels & lists --- */
.panel {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin: 16px 0;
}
.panel h2:first-child { margin-top: 0; }

.list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 12px;
}
.row.self { background: linear-gradient(180deg, rgba(79,128,255,.08), var(--bg-elev)); border-color: rgba(79,128,255,.35); }
.row .grow { flex: 1; min-width: 0; }
.row .grow b { display: block; font-size: 15px; color: #fff; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .rank {
  width: 32px; text-align: center; font-weight: 700; color: var(--text-dim);
}
.row .rank.top1 { color: #ffd95c; }
.row .rank.top2 { color: #d6d8df; }
.row .rank.top3 { color: #e59a5a; }
.row .value { text-align: right; }
.row .value b { font-size: 18px; color: #fff; }
.row .value span { font-size: 12px; color: var(--text-dim); display: block; }
.row form { margin: 0; display: inline-flex; }

/* --- Avatar --- */
.avatar {
  width: 40px; height: 40px; min-width: 40px;
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.15);
}
.avatar.sm { width: 30px; height: 30px; min-width: 30px; font-size: 13px; }

/* --- Forms --- */
.form-stack label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--text-dim); }
.form-stack input, .inline-form input, .goals-form input {
  display: block; width: 100%; margin-top: 5px; padding: 11px 13px;
  background: var(--bg-elev2); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-size: 14px; transition: border-color .15s, background .15s;
}
.form-stack input:focus, .inline-form input:focus, .goals-form input:focus { outline: none; border-color: var(--accent); background: #131826; }
.form-help { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-form input { flex: 1; min-width: 180px; }

.goals-form { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.goals-form label { flex: 1; min-width: 150px; font-size: 13px; color: var(--text-dim); }

.auth { max-width: 400px; margin: 40px auto; padding: 28px; background: var(--bg-elev); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
.auth h1 { font-size: 24px; margin: 0 0 18px; }

/* --- Tabs --- */
.tabs { display: inline-flex; padding: 4px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 999px; margin: 6px 10px 14px 0; flex-wrap: wrap; }
.tabs .tab {
  display: inline-block; padding: 8px 16px; border-radius: 999px; color: var(--text-dim);
  font-size: 13px; font-weight: 600; text-decoration: none;
}
.tabs .tab.active { background: var(--accent-grad); color: #fff; box-shadow: 0 4px 14px rgba(79,128,255,.3); }
.tabs .tab:hover:not(.active) { color: var(--text); text-decoration: none; }

/* --- Tracker --- */
.tracker-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.selector { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text-dim);
  cursor: pointer; font-size: 13px; font-weight: 600; transition: all .15s;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.active { background: var(--accent-grad); border-color: transparent; color: #fff; box-shadow: 0 4px 14px rgba(79,128,255,.3); }
.chip:disabled { opacity: .45; cursor: not-allowed; }

.goal-row { display: flex; gap: 16px; font-size: 13px; color: var(--text-dim); flex-wrap: wrap; }
.goal-row div { display: inline-flex; align-items: baseline; gap: 4px; }
.goal-row div b { color: #fff; font-size: 15px; font-weight: 700; }

.stage {
  position: relative; width: 100%; aspect-ratio: 4/3;
  background: #000; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.stage video, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.overlay { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; gap: 8px; pointer-events: none; }
.badge {
  background: rgba(8,10,16,.65); backdrop-filter: blur(8px);
  padding: 8px 14px; border-radius: 12px; font-size: 12px; line-height: 1.2; color: #fff;
  border: 1px solid rgba(255,255,255,.08);
}
.badge b { font-size: 20px; display: block; font-weight: 700; margin-top: 2px; }

.controls { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
#status { margin-top: 12px; min-height: 18px; font-size: 13px; }

.hint { color: var(--text-dim); font-size: 13px; line-height: 1.7; padding-left: 18px; margin-top: 14px; }

/* --- Tables --- */
table.t { width: 100%; border-collapse: collapse; margin-top: 8px; }
table.t th, table.t td { padding: 11px 12px; text-align: left; font-size: 14px; border-bottom: 1px solid var(--border); }
table.t tr:last-child td { border-bottom: none; }
table.t th { color: var(--text-muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; }
table.t tbody tr:hover { background: var(--bg-elev); }

/* --- Badge pill --- */
.badge-pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  background: var(--accent-grad); color: #fff; font-size: 11px; font-weight: 700; margin-left: 6px; vertical-align: middle;
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .topbar { padding: 10px 14px; }
  .topbar nav a { padding: 6px 9px; font-size: 13px; }
  main { padding: 18px 14px 80px; }
  .hero h1 { font-size: 28px; }
  h1 { font-size: 22px; }
  .row { padding: 10px 12px; gap: 10px; }
  .row .value b { font-size: 15px; }
  .badge { padding: 6px 10px; font-size: 11px; }
  .badge b { font-size: 16px; }
}
