:root {
  --bg: #120a0b;
  --bg-2: #1a0e10;
  --panel: #1f0f12;
  --panel-2: #2a1216;
  --sidebar: #3a1317;
  --topbar: #401317;
  --line: #4a1d22;
  --red: #d0202e;
  --red-hot: #ef3343;
  --text: #f6eeee;
  --muted: #b9a2a4;
  --green: #3fbf7f;
  --radius: 14px;
  --head: 'Oswald', 'Bebas Neue', Impact, sans-serif;
  --body: 'Inter', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, #2a0d11 0%, var(--bg) 60%) fixed;
  color: var(--text); font: 14px/1.5 var(--body);
}
a { color: var(--red-hot); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { height: 34px; }
.brand img + .wordmark { display: none; }
.wordmark { font-family: var(--head); letter-spacing: .35em; font-size: 20px; font-weight: 500; }
.brand-lg { justify-content: center; margin-bottom: 18px; }
.brand-lg img { height: 56px; }
.brand-lg .wordmark { font-size: 30px; }

/* ---------- Typography ---------- */
.eyebrow { color: var(--red-hot); text-transform: uppercase; letter-spacing: .28em; font-size: 11.5px; font-weight: 700; margin: 0 0 6px; }
.title { font-family: var(--head); text-transform: uppercase; font-size: 44px; line-height: 1; margin: 0 0 22px; letter-spacing: .01em; }
.title .accent { color: var(--red); }
h2 { font-family: var(--head); text-transform: uppercase; font-size: 22px; margin: 0 0 12px; letter-spacing: .02em; }
.label { text-transform: uppercase; letter-spacing: .16em; font-size: 11.5px; color: var(--muted); font-weight: 600; }

/* ---------- Forms ---------- */
label { display: grid; gap: 6px; text-transform: uppercase; letter-spacing: .14em; font-size: 11px; font-weight: 600; color: var(--muted); }
input, select, textarea {
  font: 14px var(--body); color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; width: 100%;
  text-transform: none; letter-spacing: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--red); outline-offset: 0; border-color: transparent; }
input[type="date"] { color-scheme: dark; }
.stack { display: grid; gap: 14px; }
.form-msg { margin: 0; min-height: 1em; color: #ff8b95; font-size: 13px; }
.form-msg.ok { color: var(--green); }

.btn {
  font: 700 13px var(--body); text-transform: uppercase; letter-spacing: .16em; cursor: pointer;
  border-radius: 999px; padding: 12px 22px; border: 1px solid var(--line); color: var(--text); background: var(--panel-2);
}
.btn:hover { border-color: var(--red); }
.btn-primary { background: var(--red); border-color: var(--red); }
.btn-primary:hover { background: var(--red-hot); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 7px 14px; font-size: 11px; letter-spacing: .1em; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { background: none; border: 0; color: var(--text); font-size: 22px; cursor: pointer; }

/* ---------- Auth ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-top: 2px solid var(--red); border-radius: var(--radius); padding: 32px 28px; }
.auth-card .title { font-size: 34px; margin-bottom: 6px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); grid-template-rows: 64px 1fr; min-height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 0 24px; background: var(--topbar); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.role-chip { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; }
.menu-btn { display: none; }
.sidebar { background: var(--sidebar); padding: 28px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 64px; height: calc(100vh - 64px); }
.sidebar a { display: flex; align-items: center; gap: 14px; padding: 13px 16px; border-radius: 10px; color: #e7cfd1; text-decoration: none; font-weight: 700; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; }
.sidebar a .ico { width: 20px; text-align: center; opacity: .85; }
.sidebar a:hover { background: rgba(255,255,255,.04); }
.sidebar a.active { background: rgba(208,32,46,.18); color: #fff; box-shadow: inset 3px 0 0 var(--red); }
.main { padding: 40px 48px 60px; max-width: 1200px; width: 100%; min-width: 0; }

/* ---------- Cards & stats ---------- */
.card { background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%); border: 1px solid var(--line); border-top: 2px solid var(--red); border-radius: var(--radius); padding: 28px 32px; margin-bottom: 22px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: 14px; align-items: end; }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.hero h2 { font-size: 28px; margin: 0; }
.big { font-family: var(--head); font-weight: 700; color: var(--red); line-height: .9; }
.big-xl { font-size: 120px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(130px, 100%), 1fr)); gap: 18px; margin-top: 22px; }
.stat .big { font-size: 58px; }
.stat .label { display: block; margin-top: 6px; }
.note { color: var(--muted); font-size: 13px; margin: -6px 0 26px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 26px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-top: 2px solid var(--red); border-radius: var(--radius); padding: 18px 18px 14px; }
.tile .big { font-size: 40px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 30px 0 12px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tr.me td { background: rgba(208,32,46,.12); }
td select { padding: 7px 8px; font-size: 13px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.pill-green { background: rgba(63,191,127,.15); color: var(--green); }
.pill-red { background: rgba(208,32,46,.18); color: #ff7b86; }
.pill-gray { background: rgba(255,255,255,.07); color: var(--muted); }
.rank { font-family: var(--head); font-size: 20px; color: var(--muted); }
.rank-1 { color: #f5c542; } .rank-2 { color: #cfd6de; } .rank-3 { color: #d08a4a; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { background: none; border: 0; color: var(--muted); padding: 8px 16px; font: 700 11px var(--body); letter-spacing: .12em; text-transform: uppercase; cursor: pointer; }
.seg button.on { background: var(--red); color: #fff; }

/* ---------- Resources ---------- */
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 14px; }
.res { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.res a.res-title { color: var(--text); font-weight: 700; font-size: 15px; text-decoration: none; }
.res a.res-title:hover { color: var(--red-hot); }
.res-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* ---------- Code / copy ---------- */
.copy-row { display: flex; gap: 8px; align-items: center; margin: 6px 0 16px; }
.copy-row code { flex: 1; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; overflow-x: auto; white-space: nowrap; }

/* ---------- Modal & toast ---------- */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-top: 2px solid var(--red); border-radius: var(--radius); padding: 0; width: min(440px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.65); }
.modal-body { padding: 26px; display: grid; gap: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--panel-2); border: 1px solid var(--line); padding: 12px 18px; border-radius: 10px; opacity: 0; transition: .25s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .hero { align-items: flex-end; }
  .menu-btn { display: block; }
  .topbar { padding: 0 16px; }
  .role-chip, #pw-btn { display: none; }
  .sidebar { position: fixed; left: 0; top: 64px; width: 250px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 10px 0 40px rgba(0,0,0,.5); }
  .main { padding: 26px 16px 50px; }
  .card { padding: 22px 18px; }
  .title { font-size: 34px; }
  .big-xl { font-size: 84px; }
  .stat .big { font-size: 44px; }
}
