:root {
    color-scheme: dark;
    --bg: #050a13;
    --panel: #0d1728;
    --panel-2: #121f34;
    --line: #24334b;
    --text: #f7f9fc;
    --muted: #94a3b8;
    --red: #ef3e46;
    --red-dark: #b91c2b;
    --blue: #3b82f6;
    --green: #35c98b;
    --yellow: #f3c969;
    --radius: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-width: 320px;
    background: radial-gradient(circle at 82% -10%, #162c52 0, transparent 38%), var(--bg);
    color: var(--text);
    font: 16px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
a { color: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 28px 22px;
    border-right: 1px solid var(--line);
    background: rgba(5, 10, 19, .94);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; margin-bottom: 42px; }
.brand img { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; }
.brand strong { display: block; letter-spacing: .04em; }
.brand span { color: var(--muted); font-size: .82rem; }
.nav { display: grid; gap: 8px; }
.nav a { padding: 11px 12px; color: #cbd5e1; text-decoration: none; border-radius: 9px; }
.nav a:hover, .nav a:focus-visible { background: var(--panel-2); color: white; outline: none; }
.sidebar-footer { position: absolute; left: 22px; right: 22px; bottom: 24px; }

.main { width: 100%; max-width: 1500px; padding: 32px 38px 70px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.topbar h1 { margin: 0; font-size: clamp(1.65rem, 3vw, 2.25rem); }
.topbar p { margin: 5px 0 0; color: var(--muted); }
.user-chip { border: 1px solid var(--line); background: var(--panel); padding: 9px 13px; border-radius: 999px; color: #cbd5e1; font-size: .88rem; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 28px; }
.metric, .panel { border: 1px solid var(--line); background: linear-gradient(145deg, rgba(18,31,52,.96), rgba(10,20,35,.96)); border-radius: var(--radius); }
.metric { padding: 18px; min-height: 122px; }
.metric-label { color: var(--muted); font-size: .83rem; text-transform: uppercase; letter-spacing: .08em; }
.metric-value { display: block; margin-top: 12px; font-size: 1.65rem; font-weight: 750; }
.metric-note { color: var(--muted); font-size: .82rem; }
.status { display: inline-flex; align-items: center; gap: 7px; }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.status-good::before { background: var(--green); box-shadow: 0 0 14px rgba(53,201,139,.65); }
.status-bad::before { background: var(--red); }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(330px, .75fr); gap: 18px; align-items: start; }
.panel { padding: 22px; margin-bottom: 18px; scroll-margin-top: 20px; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel h2 { margin: 0; font-size: 1.18rem; }
.panel-header p, .panel > p { color: var(--muted); margin: 4px 0 0; }
.eyebrow { margin: 0 0 7px; color: var(--red); text-transform: uppercase; letter-spacing: .12em; font-size: .77rem; font-weight: 750; }
.muted { color: var(--muted); }

.game-list { display: grid; gap: 10px; }
.game-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; padding: 14px; background: rgba(5,10,19,.55); border: 1px solid #1d2a40; border-radius: 10px; }
.team:last-child { text-align: right; }
.team strong { display: block; }
.team span { color: var(--muted); font-size: .82rem; }
.score { min-width: 104px; text-align: center; font-size: 1.25rem; font-weight: 800; }
.score small { display: block; color: var(--yellow); font-size: .7rem; letter-spacing: .05em; text-transform: uppercase; }
.empty-state { padding: 32px 18px; text-align: center; border: 1px dashed #334155; border-radius: 10px; color: var(--muted); }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
label { display: grid; gap: 7px; color: #dbe5f3; font-size: .9rem; font-weight: 650; }
input, select, textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    color: white;
    background: #07111f;
    border: 1px solid #30415c;
    border-radius: 8px;
}
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 2px solid rgba(59,130,246,.22); }
.span-2 { grid-column: span 2; }
.checkbox { display: flex; align-items: center; gap: 9px; min-height: 44px; }
.checkbox input { width: 18px; min-height: 18px; accent-color: var(--red); }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 9px 15px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; text-decoration: none; font-weight: 750; }
.button-primary { background: linear-gradient(135deg, var(--red), var(--red-dark)); color: white; }
.button-secondary { background: #17263d; border-color: #30415c; color: #e2e8f0; }
.button-ghost { background: transparent; border-color: var(--line); color: #cbd5e1; width: 100%; }
.button-small { min-height: 34px; padding: 6px 10px; font-size: .82rem; }
.actions { display: flex; align-items: center; gap: 10px; margin-top: 17px; flex-wrap: wrap; }

.ad-list { display: grid; gap: 10px; margin-top: 18px; }
.ad-row { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid #25354d; border-radius: 10px; }
.ad-type { display: grid; place-items: center; width: 44px; height: 44px; background: #17263d; border-radius: 8px; font-weight: 800; color: var(--blue); }
.ad-row strong { display: block; }
.ad-row span { color: var(--muted); font-size: .79rem; }
.file-picker { position: relative; padding: 18px; border: 1px dashed #405474; border-radius: 10px; background: rgba(7,17,31,.6); }
.file-picker input { padding: 8px; }

.alert { margin: 0 0 16px; padding: 12px 14px; border-radius: 9px; border: 1px solid; }
.alert-success { border-color: rgba(53,201,139,.45); background: rgba(53,201,139,.1); color: #a7f3d0; }
.alert-error { border-color: rgba(239,62,70,.5); background: rgba(239,62,70,.1); color: #fecaca; }
.alert-info { border-color: rgba(59,130,246,.5); background: rgba(59,130,246,.1); color: #bfdbfe; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-shell { width: min(100%, 470px); }
.auth-card { padding: 30px; border: 1px solid var(--line); border-top: 3px solid var(--red); border-radius: 16px; background: rgba(13,23,40,.97); box-shadow: 0 24px 70px rgba(0,0,0,.42); }
.auth-card h1 { margin: 0 0 8px; font-size: 1.55rem; }
.auth-logo { width: 92px; height: 70px; object-fit: cover; border-radius: 10px; margin-bottom: 22px; }
.stack-form { display: grid; gap: 15px; margin-top: 22px; }

@media (max-width: 1050px) {
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { position: static; height: auto; padding: 15px 18px; border-right: 0; border-bottom: 1px solid var(--line); }
    .brand { margin-bottom: 14px; }
    .brand img { width: 42px; height: 42px; }
    .nav { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 3px; }
    .nav a { white-space: nowrap; background: var(--panel); }
    .sidebar-footer { position: static; margin-top: 13px; }
    .main { padding: 24px 16px 50px; }
    .topbar { display: block; }
    .user-chip { display: inline-block; margin-top: 13px; }
    .metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
    .metric { min-height: 104px; padding: 14px; }
    .metric-value { font-size: 1.3rem; }
    .panel { padding: 17px; }
    .settings-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .game-row { grid-template-columns: 1fr auto 1fr; gap: 7px; padding: 11px; }
    .team span { display: none; }
    .score { min-width: 75px; font-size: 1.05rem; }
    .ad-row { grid-template-columns: 42px 1fr; }
    .ad-row form { grid-column: 1 / -1; }
}

@media (max-width: 430px) {
    .metrics { grid-template-columns: 1fr; }
    .panel-header { display: block; }
}
