:root {
    --bg-top: #0a1638;
    --bg-mid: #0b1c49;
    --bg-bottom: #0a132b;
    --panel: rgba(19, 36, 84, 0.62);
    --panel-strong: rgba(17, 31, 70, 0.84);
    --line: rgba(166, 196, 255, 0.22);
    --line-soft: rgba(166, 196, 255, 0.12);
    --text: #eef4ff;
    --muted: #b5c5eb;
    --accent: #84c4ff;
    --success: #57d38c;
    --warn: #ffc857;
    --danger: #ff7e8a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--text);
    font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
    background:
        radial-gradient(1200px 500px at 20% -120px, rgba(95, 161, 255, 0.24), transparent 60%),
        radial-gradient(1000px 420px at 82% -130px, rgba(132, 196, 255, 0.2), transparent 62%),
        linear-gradient(180deg, var(--bg-top), var(--bg-mid) 42%, var(--bg-bottom));
    min-height: 100vh;
}

.app-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at 50% -30%, rgba(255, 255, 255, 0.08), transparent 48%);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.glass {
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    background: var(--panel);
    border: 1px solid var(--line-soft);
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.28);
}

.topbar {
    position: sticky;
    top: 10px;
    z-index: 10;
    margin: 10px auto 0;
    width: min(1320px, calc(100vw - 20px));
    border-radius: 18px;
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-weight: 900;
    letter-spacing: 0.04em;
    color: #fff;
    background: linear-gradient(135deg, #5fa1ff, #84c4ff);
}
.brand strong { display: block; line-height: 1.1; font-size: 13px; }
.brand small { display: block; color: var(--muted); font-size: 11px; }

.nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.nav a {
    border: 1px solid transparent;
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    padding: 7px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
}
.nav a:hover {
    text-decoration: none;
    border-color: var(--line);
    background: rgba(95, 161, 255, 0.2);
}

.container {
    width: min(1320px, calc(100vw - 20px));
    margin: 14px auto 24px;
    display: grid;
    gap: 14px;
}

.page-header,
.card {
    border-radius: 16px;
    border: 1px solid var(--line-soft);
    background: linear-gradient(180deg, var(--panel-strong), rgba(15, 29, 66, 0.85));
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.24);
}

.page-header {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.page-header h1 { margin: 0; font-size: 21px; }
.page-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.card { padding: 14px; }
.card h2 { margin: 0 0 10px; font-size: 15px; }
.card > p { margin: 0 0 8px; color: var(--muted); }
.narrow { max-width: 460px; margin: 4vh auto 0; }

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.stat {
    padding: 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line-soft);
}
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { margin-top: 6px; font-size: 24px; font-weight: 800; }

.grid-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.section-grid { display: grid; gap: 12px; }

.table-wrap {
    overflow: auto;
    border-radius: 12px;
    border: 1px solid var(--line-soft);
    background: rgba(6, 13, 33, 0.45);
}

.table-wrap table { width: 100%; border-collapse: collapse; min-width: 620px; }
th, td {
    padding: 10px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-align: left;
    vertical-align: top;
    font-size: 13px;
}
th {
    color: #c7d6f5;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 800;
}
tr:last-child td { border-bottom: none; }

.form-grid { display: grid; gap: 7px; }
.form-grid.compact { grid-template-columns: 1fr 1fr; gap: 8px; }
.form-grid.compact textarea,
.form-grid.compact button,
.form-grid.compact .full { grid-column: 1 / -1; }

label { color: var(--muted); font-size: 12px; font-weight: 600; }

input, textarea, select, button {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--line-soft);
    background: rgba(7, 15, 36, 0.8);
    color: var(--text);
    padding: 9px 10px;
    font-size: 13px;
}

textarea { resize: vertical; }

button {
    cursor: pointer;
    background: linear-gradient(180deg, rgba(95, 161, 255, 0.36), rgba(95, 161, 255, 0.23));
    border-color: rgba(132, 196, 255, 0.48);
    color: #f4f8ff;
    font-weight: 800;
}

button:hover { filter: brightness(1.08); }

button.ghost,
.ghost {
    width: auto;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
    color: var(--text);
}

button.small,
.ghost.small { padding: 6px 9px; font-size: 12px; }
button.danger {
    background: linear-gradient(180deg, rgba(255, 126, 138, 0.4), rgba(255, 126, 138, 0.24));
    border-color: rgba(255, 126, 138, 0.62);
}

.inline-form { display: inline-flex; align-items: center; gap: 6px; }
.inline-form input,
.inline-form select,
.inline-form button { width: auto; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.wrap { flex-wrap: wrap; }

.request-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

code {
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: rgba(7, 15, 36, 0.7);
    padding: 2px 6px;
    color: var(--accent);
}

.alert {
    margin-bottom: 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 126, 138, 0.5);
    background: rgba(255, 126, 138, 0.14);
    padding: 10px 12px;
    color: #ffe8ec;
}
.alert-success {
    border-color: rgba(87, 211, 140, 0.5);
    background: rgba(87, 211, 140, 0.18);
    color: #e8fff2;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.08);
    white-space: nowrap;
}

.chip-success { border-color: rgba(87, 211, 140, 0.5); background: rgba(87, 211, 140, 0.2); }
.chip-warn { border-color: rgba(255, 200, 87, 0.5); background: rgba(255, 200, 87, 0.2); }
.chip-danger { border-color: rgba(255, 126, 138, 0.5); background: rgba(255, 126, 138, 0.2); }
.chip-info { border-color: rgba(132, 196, 255, 0.5); background: rgba(132, 196, 255, 0.2); }

.muted { color: var(--muted); font-size: 12px; }
.mt-8 { margin-top: 8px; }
.card-subtle {
    background: linear-gradient(180deg, rgba(20, 36, 78, 0.72), rgba(10, 24, 58, 0.86));
    border-color: rgba(166, 196, 255, 0.2);
    box-shadow: none;
}
.card-title {
    margin: 0 0 6px;
    font-size: 14px;
}
.match-edit-layout {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(260px, 1.1fr) minmax(300px, 1fr);
    grid-template-areas:
        "rules result"
        "rules special";
}
.match-edit-layout section:nth-child(1) { grid-area: rules; }
.match-edit-layout section:nth-child(2) { grid-area: result; }
.match-edit-layout section:nth-child(3) { grid-area: special; }
.kv-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
}
.kv-grid > div {
    display: grid;
    gap: 2px;
    padding: 8px;
    border-radius: 10px;
    border: 1px solid var(--line-soft);
    background: rgba(255, 255, 255, 0.03);
}
.kv-grid strong {
    font-size: 13px;
    color: var(--text);
}
.admin-hint {
    border-radius: 10px;
    border: 1px solid var(--line-soft);
    background: rgba(132, 196, 255, 0.08);
    padding: 8px 10px;
    color: #dbe8ff;
    font-size: 12px;
}
.admin-hint.warn {
    border-color: rgba(255, 200, 87, 0.5);
    background: rgba(255, 200, 87, 0.15);
    color: #fff3d1;
}
.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.action-row button {
    width: auto;
}

.jobs-table-wrap table { min-width: 1500px; }
.status-stack {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.actions-col {
    display: grid;
    gap: 6px;
}
.actions-col details {
    border: 1px solid var(--line-soft);
    border-radius: 10px;
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.03);
}
.actions-col summary {
    cursor: pointer;
    font-size: 12px;
    color: var(--muted);
}
.actions-col pre {
    margin: 6px 0 0;
    max-width: 360px;
    max-height: 200px;
    overflow: auto;
    padding: 6px;
    border-radius: 8px;
    border: 1px solid var(--line-soft);
    background: rgba(7, 15, 36, 0.8);
    font-size: 11px;
    color: #d9e6ff;
}

@media (max-width: 1050px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-two { grid-template-columns: 1fr; }
    .topbar { top: 6px; border-radius: 14px; }
    .match-edit-layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "rules"
            "result"
            "special";
    }
}

@media (max-width: 680px) {
    .stats { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .nav { width: 100%; justify-content: flex-start; }
    .kv-grid { grid-template-columns: 1fr; }
}
