:root {
    --bg:          #0e0e10;
    --bg-2:        #14141a;
    --surface:     #16161b;
    --surface-2:   #1c1c22;

    --fg:          #ebe6dc;
    --muted:       #8a857a;
    --dim:         #5a564f;

    --border:        rgba(235, 230, 220, 0.07);
    --border-bright: rgba(235, 230, 220, 0.14);

    --gold:        #d4af37;
    --gold-2:      #f0c75e;
    --gold-soft:   rgba(212, 175, 55, 0.14);
    --silver:      #c0c5cb;
    --silver-2:   #e0e3e7;
    --bronze:      #cd7f32;

    --crimson:     #a8372e;
    --green:       #6fcf6f;
    --amber:       #e0b341;

    --side-w: 232px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--fg);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-feature-settings: 'cv11', 'ss01', 'tnum';
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
}
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-2); }
code { font-family: ui-monospace, 'JetBrains Mono', Menlo, monospace; font-size: 12px; color: var(--muted); }

/* ---------- App shell ---------- */
.app {
    display: grid;
    grid-template-columns: var(--side-w) 1fr;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.side {
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    padding: 18px 14px;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.side-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 10px 18px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
}
.brand-mark {
    width: 28px; height: 28px; border-radius: 7px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--gold-soft); color: var(--gold);
    font-family: ui-monospace, monospace; font-weight: 700; font-size: 12px;
    border: 1px solid rgba(212,175,55,0.3);
}
.brand-text { font-weight: 600; font-size: 14px; letter-spacing: 0.01em; }

.side-section-label {
    font-family: ui-monospace, monospace;
    font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
    color: var(--dim);
    padding: 6px 12px; margin-bottom: 4px;
}
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 8px;
    color: var(--muted); font-size: 13px;
    border: 1px solid transparent;
    transition: background .12s, color .12s, border-color .12s;
}
.nav-item:hover { color: var(--fg); background: rgba(235,230,220,0.03); }
.nav-item.is-active {
    color: var(--gold);
    background: var(--gold-soft);
    border-color: rgba(212,175,55,0.25);
}
.nav-icon { flex-shrink: 0; }
.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.nav-foot { color: var(--muted); }
.nav-foot:hover { color: var(--crimson); }

/* ---------- Top bar ---------- */
.content { min-width: 0; }
.topbar {
    display: flex; align-items: center; gap: 16px;
    padding: 22px 28px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky; top: 0; z-index: 20;
}
.topbar-title h1 {
    margin: 0;
    font-size: 22px; font-weight: 600;
    letter-spacing: -0.01em;
}
.topbar-sub { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.topbar-sub strong { color: var(--gold); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-pill {
    display: inline-flex; align-items: center; gap: 10px;
    padding: 5px 12px 5px 5px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 13px;
}
.user-av { width: 24px; height: 24px; border-radius: 50%; }
.user-name { color: var(--fg); }
.role-tag {
    padding: 2px 7px; border-radius: 999px;
    font-family: ui-monospace, monospace;
    font-size: 9px; letter-spacing: 0.14em;
    color: var(--gold); background: var(--gold-soft);
    border: 1px solid rgba(212,175,55,0.25);
}

/* ---------- Page body ---------- */
.page-body { padding: 22px 28px 80px; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
}
.card-head {
    display: flex; align-items: baseline; justify-content: space-between;
    margin-bottom: 12px;
}
.card-title {
    margin: 0;
    font-size: 14px; font-weight: 600;
    color: var(--fg);
}
.card-sub {
    font-size: 12px; color: var(--muted);
}

/* ---------- Grid ---------- */
.grid { display: grid; gap: 14px; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }

@media (max-width: 1100px) {
    .grid-3, .grid-4, .grid-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
    .app { grid-template-columns: 1fr; }
    .side { position: static; height: auto; flex-direction: row; overflow-x: auto; }
    .side-brand { border-bottom: 0; border-right: 1px solid var(--border); margin: 0 10px 0 0; padding: 0 14px 0 4px; }
    .side-section-label, .side-foot { display: none; }
    .side-nav { flex-direction: row; }
    .grid-3, .grid-4, .grid-6 { grid-template-columns: 1fr; }
    .topbar { padding: 16px; }
    .page-body { padding: 16px; }
}

/* ---------- KPI tile ---------- */
.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    display: flex; flex-direction: column; gap: 6px;
}
.kpi-label {
    font-family: ui-monospace, monospace;
    font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
    color: var(--muted);
}
.kpi-value {
    font-size: 24px; font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--silver-2);
    font-variant-numeric: tabular-nums;
}
.kpi-sub { font-size: 12px; color: var(--dim); }

/* ---------- Range tabs ---------- */
.range-tabs {
    display: inline-flex; gap: 2px; padding: 3px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    margin-bottom: 14px;
}
.range-tabs button {
    border: 0; background: transparent; color: var(--muted);
    padding: 5px 12px; border-radius: 6px; cursor: pointer;
    font-family: inherit; font-size: 12px;
}
.range-tabs button.is-active { color: var(--gold); background: var(--gold-soft); }

/* ---------- Leaderboard ---------- */
.leader-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.leader-list li {
    display: grid;
    grid-template-columns: 36px 36px 1fr auto auto;
    align-items: center;
    gap: 14px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    font-size: 13px;
}
.leader-list li:last-child { border-bottom: 0; }
.leader-list li:hover { background: rgba(235,230,220,0.025); }
.leader-list .rank {
    font-family: ui-monospace, monospace;
    font-size: 13px; color: var(--dim);
    font-variant-numeric: tabular-nums;
    text-align: center;
}
.leader-list li:nth-child(1) .rank { color: var(--gold); }
.leader-list li:nth-child(2) .rank { color: var(--silver-2); }
.leader-list li:nth-child(3) .rank { color: var(--bronze); }
.leader-list .av {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--bg-2); background-size: cover; background-position: center;
    border: 1px solid var(--border);
}
.leader-list .name { font-weight: 600; color: var(--fg); }
.leader-list .meta { color: var(--muted); font-size: 11px; font-family: ui-monospace, monospace; }
.leader-list .stat {
    color: var(--silver-2); font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.leader-list .stat-sub {
    font-size: 11px; color: var(--muted); text-align: right;
    font-family: ui-monospace, monospace;
}

/* ---------- Generic data list ---------- */
.row-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.row-list li {
    display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center;
    padding: 9px 4px; border-bottom: 1px solid var(--border);
    cursor: pointer; font-size: 13px;
}
.row-list li:last-child { border-bottom: 0; }
.row-list li:hover { background: rgba(235,230,220,0.025); }
.row-list .who { color: var(--muted); }
.row-list .when { color: var(--dim); font-family: ui-monospace, monospace; font-size: 11px; }
.row-list .empty {
    grid-template-columns: 1fr; padding: 20px; color: var(--muted); cursor: default;
    text-align: center; font-style: italic;
}

.review-head-actions {
    display: flex; align-items: center; gap: 10px;
}
.review-list li {
    grid-template-columns: auto minmax(190px, 1.1fr) minmax(180px, 1fr) auto auto auto;
    cursor: default;
}
.review-list .review-main {
    display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.review-list .review-main strong { color: var(--fg); font-weight: 600; }
.review-list .review-main span {
    color: var(--muted); font-family: ui-monospace, monospace; font-size: 11px;
    overflow: hidden; text-overflow: ellipsis;
}
.review-list .review-progress {
    color: var(--muted); font-size: 12px; min-width: 0;
}
.review-list .review-progress strong { color: var(--gold); font-weight: 600; }
.review-list .review-actions {
    display: flex; gap: 8px; justify-content: flex-end;
}
.review-list .review-actions .btn { padding: 6px 10px; }
.review-list .empty { grid-template-columns: 1fr; }

@media (max-width: 1100px) {
    .review-list li {
        grid-template-columns: auto 1fr auto;
    }
    .review-list .review-progress,
    .review-list .when {
        grid-column: 2 / -1;
    }
    .review-list .review-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }
}

/* ---------- Status badges ---------- */
.badge {
    font-family: ui-monospace, monospace; font-size: 10px;
    padding: 2px 7px; border-radius: 4px; letter-spacing: 0.06em;
    border: 1px solid transparent;
}
.badge-open       { color: var(--amber);   background: rgba(224,179,65,0.10); border-color: rgba(224,179,65,0.25); }
.badge-resolved   { color: var(--green);   background: rgba(111,207,111,0.10); border-color: rgba(111,207,111,0.25); }
.badge-disconnect { color: var(--silver);  background: rgba(192,197,203,0.08); border-color: rgba(192,197,203,0.20); }
.badge-force      { color: var(--crimson); background: rgba(168,55,46,0.10); border-color: rgba(168,55,46,0.30); }

/* ---------- Forms ---------- */
.form-row {
    display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px;
}
.form-row input {
    flex: 1; min-width: 220px;
    padding: 9px 12px; border-radius: 8px;
    background: var(--bg-2); color: var(--fg);
    border: 1px solid var(--border);
    font-family: ui-monospace, monospace; font-size: 13px;
}
.form-row input::placeholder { color: var(--dim); }
.form-row input:focus {
    outline: none; border-color: rgba(212,175,55,0.45);
    box-shadow: 0 0 0 3px var(--gold-soft);
}
.btn {
    padding: 9px 14px; border-radius: 8px;
    font-family: inherit; font-size: 13px; cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface); color: var(--fg);
}
.btn:hover { border-color: var(--border-bright); }
.btn-primary {
    color: var(--gold);
    border-color: rgba(212,175,55,0.35);
    background: var(--gold-soft);
}
.btn-primary:hover { background: rgba(212,175,55,0.20); }
.btn-danger {
    color: var(--crimson);
    border-color: rgba(168,55,46,0.35);
    background: rgba(168,55,46,0.08);
}
.btn-danger:hover { background: rgba(168,55,46,0.16); }

.hint { font-size: 12px; color: var(--muted); min-height: 1.4em; margin: 4px 0 0; }
.hint.is-ok    { color: var(--green); }
.hint.is-error { color: var(--crimson); }

/* ---------- Charts ---------- */
.chart-tall   { position: relative; height: 260px; }
.chart-square { position: relative; aspect-ratio: 1; max-width: 320px; margin: 0 auto; }

/* ---------- Heatmap ---------- */
.heatmap-grid {
    display: grid;
    grid-template-columns: 32px repeat(24, 1fr);
    gap: 2px;
    font-family: ui-monospace, monospace; font-size: 9px;
}
.heatmap-grid .axis,
.heatmap-grid .hr-axis {
    color: var(--muted); padding: 2px;
    text-align: center;
}
.heatmap-grid .axis { text-align: right; }
.heatmap-grid .cell {
    aspect-ratio: 1;
    background: rgba(240, 199, 94, var(--intensity, 0));
    border: 1px solid var(--border);
    border-radius: 2px;
    transition: transform .12s;
}
.heatmap-grid .cell:hover { transform: scale(1.15); border-color: var(--gold); }

/* ---------- Subheading inside cards ---------- */
.subheading {
    font-family: ui-monospace, monospace;
    font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
    color: var(--muted); margin: 18px 0 8px;
}

/* ---------- Admin allowlist ---------- */
.admin-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.admin-list li {
    display: grid; grid-template-columns: auto auto auto 1fr auto auto; gap: 12px; align-items: center;
    padding: 9px 4px; border-bottom: 1px solid var(--border); font-size: 13px;
}
.admin-list .badge { justify-self: start; }
.admin-list .actions { display: flex; gap: 8px; justify-self: end; }
.admin-list li:last-child { border-bottom: 0; }
.admin-list .av {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--bg-2); background-size: cover; background-position: center;
    border: 1px solid var(--border);
}
.admin-list .who-block { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.admin-list .name { font-weight: 600; color: var(--fg); }
.admin-list .sid { font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted); }
.admin-list .note { color: var(--fg); }
.admin-list .when { color: var(--dim); font-family: ui-monospace, monospace; font-size: 11px; }

/* ---------- Gate (landing / forbidden) ---------- */
body.gate {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background:
        radial-gradient(900px 500px at 50% -10%, rgba(212,175,55,0.06), transparent 60%),
        radial-gradient(800px 500px at 50% 110%, rgba(212,175,55,0.03), transparent 60%),
        var(--bg);
    padding: 32px 18px;
}
.gate-card {
    width: min(440px, 100%);
    background: var(--surface);
    border: 1px solid var(--border-bright);
    border-radius: 14px;
    padding: 36px 32px 28px;
    text-align: center;
    box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
.gate-brand {
    display: inline-flex; align-items: center; gap: 10px;
    margin-bottom: 22px;
}
.gate-title {
    font-size: 22px; font-weight: 600; letter-spacing: -0.01em;
    margin: 0 0 10px;
}
.gate-lead {
    font-size: 14px; color: var(--muted); line-height: 1.6;
    margin: 0 0 12px;
}
.gate-lead strong { color: var(--gold); font-weight: 600; }
.gate-meta {
    display: inline-flex; align-items: center; gap: 8px;
    margin: 14px 0 18px; padding: 6px 12px;
    background: var(--bg-2); border: 1px solid var(--border);
    border-radius: 999px;
    font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted);
}
.gate-av { width: 22px; height: 22px; border-radius: 50%; }
.gate-foot {
    margin: 22px 0 0;
    font-family: ui-monospace, monospace;
    font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
    color: var(--dim);
}
.btn-steam {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 11px 18px;
    font-size: 14px; font-weight: 500;
    text-decoration: none;
    margin: 6px 0 4px;
}
.btn-steam svg { color: var(--gold); }

/* ---------- Ticket modal ---------- */
.ticket-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(5,5,7,0.78);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    backdrop-filter: blur(3px);
}
.ticket-modal {
    width: min(560px, 92vw);
    max-height: min(80vh, 760px);
    background: var(--surface);
    border: 1px solid var(--border-bright);
    border-radius: 10px;
    display: flex; flex-direction: column;
    box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
.tm-header {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.tm-header .tm-title {
    color: var(--fg); font-weight: 600; font-size: 14px;
}
.tm-header .tm-sub {
    color: var(--muted); font-size: 11px;
    font-family: ui-monospace, monospace;
    margin-left: auto;
}
.tm-header .tm-close {
    background: transparent; color: var(--muted); border: 0;
    font-size: 20px; cursor: pointer; line-height: 1; padding: 2px 6px;
}
.tm-header .tm-close:hover { color: var(--gold); }

.tm-meta {
    display: flex; flex-wrap: wrap; gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    color: var(--muted);
}
.tm-meta .pill {
    padding: 2px 8px; border-radius: 4px;
    font-family: ui-monospace, monospace; font-size: 10px;
    background: var(--gold-soft); color: var(--gold);
    border: 1px solid rgba(212,175,55,0.25);
}
.tm-meta .pill-resolve { background: rgba(111,207,111,0.10); color: var(--green); border-color: rgba(111,207,111,0.25); }
.tm-meta .pill-disconnect { background: rgba(192,197,203,0.08); color: var(--silver); border-color: rgba(192,197,203,0.20); }
.tm-meta .pill-force { background: rgba(168,55,46,0.10); color: var(--crimson); border-color: rgba(168,55,46,0.30); }
.tm-meta strong { color: var(--fg); font-weight: 600; }

.tm-body {
    flex: 1; overflow-y: auto;
    padding: 12px 16px;
    background: var(--bg);
}
.tm-body::-webkit-scrollbar { width: 6px; }
.tm-body::-webkit-scrollbar-thumb {
    background: rgba(212,175,55,0.4); border-radius: 999px;
}

.tm-line { padding: 5px 0; line-height: 1.5; font-size: 13px; display: grid; grid-template-columns: 60px auto 1fr; gap: 8px; align-items: baseline; }
.tm-line .ts {
    font-family: ui-monospace, monospace; font-size: 10px;
    color: var(--dim);
}
.tm-line .who { font-weight: 600; }
.tm-line .who.role-staff  { color: var(--gold); }
.tm-line .who.role-player { color: var(--silver-2); }
.tm-line .text { color: var(--fg); white-space: pre-wrap; word-wrap: break-word; }

.tm-event {
    padding: 6px 0; font-size: 10px;
    color: var(--muted);
    font-family: ui-monospace, monospace;
    text-align: center;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-top: 1px dashed var(--border);
    border-bottom: 1px dashed var(--border);
    margin: 6px 0;
}
.tm-event .actor { color: var(--gold); }
