:root {
    --bg: #0f172a;
    --panel: #ffffff;
    --text: #0f172a;
    --muted: #475569;
    --line: #dbe3ef;
    --primary: #0b5fff;
    --primary-dark: #084aca;
    --success: #0f9d58;
    --danger: #cc2f2f;
    --warning: #b56b00;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    background: linear-gradient(145deg, #dbeafe 0%, #f8fafc 45%, #ecfeff 100%);
    min-height: 100vh;
}

main {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 20px 24px;
}

.admin-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.admin-sidebar {
    position: sticky;
    top: 16px;
    margin-bottom: 0;
    padding: 16px;
}

.admin-nav {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.admin-nav a {
    display: block;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    text-decoration: none;
    color: #0f172a;
    font-weight: 600;
    background: #f8fafc;
}

.admin-nav a:hover {
    border-color: #93c5fd;
    background: #eff6ff;
}

.admin-nav a.active {
    border-color: #4f46e5;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #fff;
}

.sidebar-link {
    width: 100%;
}

.admin-content {
    min-width: 0;
}

h1,
h2,
h3 {
    margin-top: 0;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.08);
    padding: 20px;
    margin-bottom: 18px;
}

.panel-compact {
    padding: 16px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

p {
    margin: 0 0 10px;
    color: var(--muted);
}

label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 6px;
}

input,
select,
textarea,
button {
    font: inherit;
}

input[type="text"],
input[type="password"],
input[type="file"],
select,
textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
}

textarea {
    min-height: 72px;
    resize: vertical;
}

.row {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 10px;
}

.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.overview-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    background: linear-gradient(180deg, #f8fafc, #eef2ff);
}

.overview-live-mini {
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    background: linear-gradient(180deg, #f8fafc, #eef6ff);
}

.live-mini-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 8px;
}

.live-mini-item {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 10px;
    background: #fff;
}

.live-mini-title {
    font-weight: 700;
    color: #0f172a;
}

.live-mini-count {
    margin-top: 2px;
    font-weight: 700;
    color: #0b5fff;
}

.live-mini-path {
    margin-top: 4px;
    word-break: break-all;
}

.overview-label {
    font-size: 12px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 8px;
}

.overview-value {
    font-size: clamp(1.4rem, 2.8vw, 2rem);
    line-height: 1.1;
    margin-bottom: 6px;
    font-weight: 800;
    color: #0f172a;
}

.view-section {
    display: none;
}

main.view-overview .view-overview,
main.view-games .view-games,
main.view-music .view-music,
main.view-live .view-live,
main.view-system .view-system,
main.view-admin .view-admin {
    display: block;
}

.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

@media (max-width: 860px) {
    .admin-layout {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: static;
    }

    .overview-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .row {
        grid-template-columns: 1fr;
    }

    .col-2,
    .col-3,
    .col-4,
    .col-5,
    .col-6,
    .col-8,
    .col-12 {
        grid-column: span 1;
    }

    .inline-form-row {
        flex-direction: column;
        align-items: stretch;
    }

    .inline-form-row input[type="text"] {
        min-width: 0;
    }
}

@media (max-width: 520px) {
    .overview-grid {
        grid-template-columns: 1fr;
    }
}

.btn {
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 700;
    color: #fff;
    background: var(--primary);
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn:hover {
    background: var(--primary-dark);
}

.btn-sm {
    padding: 7px 11px;
    font-size: 13px;
    border-radius: 9px;
}

.btn-secondary {
    background: #475569;
}

.btn-secondary:hover {
    background: #334155;
}

.btn-danger {
    background: var(--danger);
}

.btn-danger:hover {
    background: #9f2020;
}

.btn-danger-outline {
    background: #fff;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.btn-danger-outline:hover {
    background: #fee2e2;
    color: #7f1d1d;
    border-color: #dc2626;
}

.btn-success {
    background: var(--success);
}

.btn-success:hover {
    background: #0b7f47;
}

.inline-form {
    display: inline;
}

.inline-form-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.inline-form-row input[type="text"] {
    min-width: 220px;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.game-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.btn-table {
    padding: 6px 10px;
    font-size: 13px;
    line-height: 1.1;
    border-radius: 8px;
}

.confirm-dialog {
    border: 0;
    padding: 0;
    background: transparent;
}

.confirm-dialog::backdrop {
    background: rgba(15, 23, 42, 0.58);
}

.confirm-dialog-card {
    width: min(460px, calc(100vw - 28px));
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
    padding: 16px;
}

.confirm-dialog-card p {
    margin-bottom: 8px;
}

.confirm-dialog-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.hidden-remove-form {
    display: none !important;
}

.shortcut-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.table-wrap {
    overflow-x: auto;
}

.table-wrap.table-scroll-y {
    max-height: 380px;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 #e2e8f0;
}

.table-wrap.table-scroll-y table {
    margin: 0;
}

.table-wrap.table-scroll-y thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f8fafc;
    box-shadow: 0 1px 0 var(--line);
}

.table-wrap.table-scroll-y tbody tr:last-child td {
    border-bottom: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid var(--line);
    text-align: left;
    padding: 9px;
    vertical-align: top;
}

.view-games td {
    vertical-align: middle;
}

th {
    font-size: 13px;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.status-pill {
    display: inline-block;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 700;
}

.status-on {
    background: #dcfce7;
    color: #166534;
}

.status-off {
    background: #fee2e2;
    color: #991b1b;
}

.status-warn {
    background: #ffedd5;
    color: #9a3412;
}

.flash {
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 10px;
    border: 1px solid transparent;
}

.flash-success {
    color: #14532d;
    background: #dcfce7;
    border-color: #86efac;
}

.flash-error {
    color: #7f1d1d;
    background: #fee2e2;
    border-color: #fecaca;
}

.flash-warning {
    color: #7c2d12;
    background: #ffedd5;
    border-color: #fdba74;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 18px;
}

.login-card {
    width: min(450px, 100%);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 22px;
    box-shadow: 0 14px 48px rgba(15, 23, 42, 0.12);
}

.text-right {
    text-align: right;
}

.small {
    font-size: 12px;
    color: #64748b;
}

.topbar {
    background: #0f172a;
    color: #e2e8f0;
    padding: 12px 24px;
}

.topbar-inner {
    max-width: none;
    margin: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.topbar a {
    color: #bfdbfe;
    text-decoration: none;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.question-row {
    margin-top: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f8fafc;
}

.question-answer-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 110px;
    gap: 8px;
    margin-bottom: 8px;
}

@media (max-width: 700px) {
    .question-answer-grid {
        grid-template-columns: 1fr;
    }
}
