:root {
    color-scheme: dark;
    --bg: #090b0f;
    --panel: #131821;
    --panel2: #181f2a;
    --line: #2b3442;
    --gold: #d0a84b;
    --gold2: #f1d68b;
    --text: #eef2f6;
    --muted: #98a3b3;
    --red: #ff6b6b;
    --green: #54d68c;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background: radial-gradient(circle at 20% 0, #28240d 0, transparent 34%), var(--bg);
    color: var(--text);
}

body { font-size: 14px; }

.topbar {
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 max(24px, 4vw);
    border-bottom: 1px solid var(--line);
    background: rgba(9, 11, 15, .9);
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar > div { display: flex; align-items: center; gap: 14px; }

.topbar strong, .brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--gold);
    border-radius: 50%;
    color: var(--gold2);
    font-family: Georgia, serif;
}

.container { width: min(1500px, 94vw); margin: 28px auto 60px; }
.diagnostics-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.diagnostics-toolbar h1 { margin: 0 0 5px; font-size: 22px; }
.diagnostics-toolbar span { color: var(--muted); }
.diagnostics-toolbar form { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }

.stats article, .panel, .login-card {
    background: linear-gradient(145deg, rgba(25, 31, 42, .97), rgba(14, 18, 25, .97));
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}

.stats article { padding: 20px; }
.stats span { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.stats strong { display: block; font-size: 32px; color: var(--gold2); margin-top: 8px; }
.panel { padding: 18px; margin-bottom: 20px; }
.filters form { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)) minmax(260px, 2fr) auto auto; gap: 12px; align-items: end; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; }

input, select {
    width: 100%;
    background: #0c1016;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    padding: 11px 12px;
    outline: none;
}

input:focus, select:focus { border-color: var(--gold); }

button, .button {
    border: 1px solid #aa8434;
    background: linear-gradient(#d2ad55, #927026);
    color: #111;
    font-weight: 700;
    border-radius: 8px;
    padding: 10px 14px;
    text-decoration: none;
    cursor: pointer;
    text-align: center;
}

.secondary { background: #171d26; color: var(--text); border-color: var(--line); }
.danger { background: rgba(255, 107, 107, .12); color: #ffadad; border-color: rgba(255, 107, 107, .55); }
.danger:hover { background: rgba(255, 107, 107, .2); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title h2 { margin: 0; font-size: 18px; }
.section-title span { color: var(--muted); }

.panel-message { margin-bottom: 18px; }
.success {
    border: 1px solid rgba(84, 214, 140, .5);
    background: rgba(84, 214, 140, .1);
    color: #8cebb4;
    border-radius: 8px;
    padding: 11px;
}

.update-manager .section-title > div { display: grid; gap: 5px; }
.update-manager .section-title > div > span { font-size: 13px; }
.update-state { padding: 6px 10px; border-radius: 999px; font-weight: 700; font-size: 12px; }
.update-state.enabled { color: #77e7a6; background: rgba(84, 214, 140, .14); }
.update-state.disabled { color: #ffb0b0; background: rgba(255, 107, 107, .12); }
.update-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.update-summary > div { border: 1px solid var(--line); border-radius: 9px; padding: 12px; background: #0d1219; }
.update-summary span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.update-summary strong { font-size: 15px; }
.update-form { display: grid; grid-template-columns: minmax(150px, .65fr) minmax(280px, 1.5fr) minmax(220px, 1fr) auto; gap: 12px; align-items: end; }
.play-update-form { display: grid; grid-template-columns: minmax(190px, .7fr) minmax(360px, 1.6fr) minmax(270px, 1fr) auto; gap: 12px; align-items: end; }
.update-form input[type="file"] { padding: 8px; }
.toggle-row { display: flex; align-items: center; gap: 9px; min-height: 40px; font-size: 14px; color: var(--text); }
.toggle-row input { width: 18px; height: 18px; accent-color: var(--gold); }
.form-note { color: var(--muted); margin: 12px 0 0; font-size: 12px; }
.form-note code { color: var(--gold2); }
.store-url { display: block; overflow-wrap: anywhere; font-size: 13px !important; }

.table-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.logs-table {
    width: 100%;
    min-width: 1160px;
    border-collapse: collapse;
    table-layout: fixed;
}

.logs-table col.col-date { width: 14%; }
.logs-table col.col-type { width: 8%; }
.logs-table col.col-platform { width: 11%; }
.logs-table col.col-device { width: 22%; }
.logs-table col.col-player { width: 13%; }
.logs-table col.col-reason { width: 12%; }
.logs-table col.col-status { width: 8%; }
.logs-table col.col-actions { width: 12%; }

.logs-table th, .logs-table td {
    text-align: left;
    padding: 11px 9px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    overflow-wrap: anywhere;
}

.logs-table thead th {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    background: #111721;
}

.logs-table tbody tr:last-child td { border-bottom: 0; }
.logs-table tbody tr:hover td { background: rgba(255, 255, 255, .018); }
.logs-table td:first-child, .status-cell { white-space: nowrap; }
.logs-table td small, .muted { color: var(--muted); }
.reason { white-space: normal; }

.badge, .resolved, .open { display: inline-block; padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge { background: #28354a; }
.badge.crash, .open { background: rgba(255, 107, 107, .14); color: #ff9595; }
.badge.session_start { background: rgba(84, 214, 140, .14); color: #77e7a6; }
.resolved { background: rgba(84, 214, 140, .14); color: #77e7a6; }

.actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; min-height: 28px; }
.actions a { color: var(--gold2); white-space: nowrap; }
.actions form { margin: 0; }
.actions button { padding: 5px 8px; font-size: 11px; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 34px; }

.log-view pre {
    background: #090d12;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    max-height: 520px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    color: #c9d3df;
}

.login-page { display: grid; place-items: center; padding: 24px; }
.login-card { width: min(430px, 94vw); padding: 34px; }
.login-card .brand-mark { margin: 0 auto 18px; width: 64px; height: 64px; font-size: 22px; }
.login-card h1 { text-align: center; margin: 0 0 8px; }
.login-card > p { text-align: center; margin: 0 0 24px; }
.login-card form { display: grid; gap: 16px; }
.login-card button { margin-top: 5px; padding: 13px; }
.alert { border: 1px solid rgba(255, 107, 107, .5); background: rgba(255, 107, 107, .1); color: #ffadad; border-radius: 8px; padding: 11px; margin-bottom: 16px; }

@media (max-width: 1100px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .filters form { grid-template-columns: repeat(2, 1fr); }
    .filters .search { grid-column: span 2; }
    .update-form { grid-template-columns: repeat(2, 1fr); }
    .play-update-form { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .stats, .filters form { grid-template-columns: 1fr; }
    .filters .search { grid-column: auto; }
    .section-title, .diagnostics-toolbar { align-items: flex-start; flex-direction: column; }
    .topbar { padding: 0 16px; }
    .container { width: 94vw; }
    .update-summary, .update-form, .play-update-form { grid-template-columns: 1fr; }
}
