:root {
    --theme-page-bg: #F3FAFF;
    --theme-card-bg: #FFFFFF;
    --theme-card-bg-2: #F8FCFF;
    --theme-inner-bg: #FFFFFF;
    --theme-soft-bg: #EAF5FF;
    --theme-text: #111827;
    --theme-blue-text: #064B91;
    --theme-muted-text: #4B647A;
    --theme-border: #B9DCFF;
    --theme-border-soft: #D8ECFF;
    --theme-accent: #007BFF;
    --theme-accent-dark: #005BBF;
    --theme-shadow: rgba(0, 88, 170, 0.12);
}

* { box-sizing: border-box; }

body {
    background: linear-gradient(135deg, #FFFFFF 0%, var(--theme-page-bg) 55%, #E7F4FF 100%);
    color: var(--theme-text);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    position: relative;
}

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

#fireworksCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 99999;
}

.main-wrapper {
    display: flex;
    width: 100%;
    max-width: 1920px;
    height: 97vh;
    gap: 10px;
}

.promo-sidebar {
    display: flex;
    flex-direction: column;
    width: 260px;
    flex-shrink: 0;
    gap: 10px;
}

.promo-box {
    background: var(--theme-card-bg);
    border: 2px solid var(--theme-border);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    box-shadow: 0 8px 24px var(--theme-shadow);
}

.promo-box img {
    width: 100%;
    height: 100%;
    object-fit: fill;
}

.side-panel {
    flex: 1.2;
    background: linear-gradient(180deg, var(--theme-card-bg) 0%, var(--theme-card-bg-2) 100%);
    border: 1px solid var(--theme-border);
    border-radius: 16px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 24px var(--theme-shadow);
    min-width: 210px;
}

.panel-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-weight: 900;
    color: var(--theme-blue-text);
    font-size: 1rem;
    border-bottom: 1px solid var(--theme-border-soft);
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.panel-header > span:first-child { white-space: nowrap; }

.winner-count-badge {
    background: linear-gradient(135deg, #1EA7FF 0%, var(--theme-accent-dark) 100%);
    color: #fff;
    padding: 3px 12px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 900;
    box-shadow: 0 5px 14px rgba(0, 91, 191, 0.22);
}

.btn-clear {
    color: var(--theme-muted-text);
    cursor: pointer;
    font-size: .8rem;
    text-transform: uppercase;
    transition: .2s;
}
.btn-clear:hover { color: var(--theme-accent-dark); }

#searchBox, textarea {
    background: var(--theme-inner-bg);
    border: 1px solid var(--theme-border-soft);
    border-radius: 8px;
    outline: none;
    color: var(--theme-text);
    box-shadow: 0 4px 12px rgba(0, 88, 170, 0.08);
}

#searchBox {
    padding: 10px;
    margin-bottom: 10px;
    font-size: .9rem;
}

textarea {
    flex: 1;
    padding: 12px;
    resize: none;
    font-size: .95rem;
    margin-bottom: 10px;
}

#searchBox::placeholder, textarea::placeholder { color: rgba(17, 24, 39, .5); }

#btnCapNhat, .btn-main, .btn-close-popup, .time-mini-input, .btn-music-save {
    background: linear-gradient(135deg, #1EA7FF 0%, var(--theme-accent-dark) 100%);
    color: #fff;
    border: 1px solid #1EA7FF;
    box-shadow: 0 5px 14px rgba(0, 91, 191, 0.22);
}

#btnCapNhat {
    border: none;
    padding: 10px;
    border-radius: 6px;
    font-weight: 900;
    width: 100%;
}

.file-action-btn {
    background: #F4FAFF;
    border: 1px dashed var(--theme-border);
    color: var(--theme-blue-text);
    padding: 10px;
    border-radius: 6px;
    font-weight: 900;
    font-size: .85rem;
    cursor: pointer;
    text-align: center;
    margin-top: 10px;
    transition: .2s;
}
.file-action-btn:hover { background: var(--theme-accent-dark); color: #fff; border-style: solid; }

.container {
    flex: 3.5;
    background: linear-gradient(180deg, var(--theme-card-bg) 0%, var(--theme-card-bg-2) 100%);
    border: 2px solid var(--theme-border);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 24px var(--theme-shadow);
    position: relative;
    min-width: 430px;
}

.container::after {
    content: "";
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 20px;
    border: 1px dashed rgba(0, 123, 255, .35);
    pointer-events: none;
    animation: ledBlink 1.5s linear infinite;
}

@keyframes ledBlink {
    0%, 100% { border-color: rgba(0, 123, 255, .45); opacity: .9; }
    50% { border-color: rgba(0, 91, 191, .25); opacity: .65; }
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--theme-border-soft);
    padding-bottom: 12px;
    gap: 12px;
}

.brand-zone {
    display: flex;
    align-items: center;
    gap: 45px;
    min-width: 0;
}

.logo-img {
    max-height: 42px;
    width: auto;
    display: block;
    object-fit: contain;
}

.brand-text h2 {
    margin: 0;
    color: var(--theme-blue-text);
    font-size: 1.3rem;
    font-weight: 900;
    letter-spacing: .5px;
    white-space: nowrap;
}

.total-badge {
    background: var(--theme-inner-bg);
    border: 1px solid var(--theme-border-soft);
    padding: 17px 10px;
    border-radius: 20px;
    font-size: .8rem;
    color: var(--theme-text);
    font-weight: 900;
    box-shadow: 0 4px 12px rgba(0, 88, 170, 0.08);
    white-space: nowrap;
}

.box-container {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 12px;
    margin: 15px 0;
    padding: 20px;
    background: var(--theme-inner-bg);
    border: 1px solid var(--theme-border-soft);
    border-radius: 16px;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 88, 170, 0.08);
}

.user-box {
    width: calc(20% - 12px);
    min-width: 120px;
    max-width: 200px;
    height: 55px;
    background: #fff;
    border: 1px solid var(--theme-border-soft);
    color: var(--theme-text);
    padding: 14px 8px;
    border-radius: 10px;
    font-weight: 900;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 8px rgba(0, 88, 170, 0.08);
}

.user-box.active {
    background: linear-gradient(135deg, #DDF0FF 0%, #A6D8FF 100%);
    color: #003B73;
    border: 2px solid var(--theme-accent);
    transform: scale(1.05);
    box-shadow: 0 0 16px rgba(0, 123, 255, .35), 0 8px 18px rgba(0, 88, 170, .16);
}

.footer-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    width: 100%;
    padding-top: 10px;
}

.time-badge-vip {
    position: absolute;
    left: 0;
    background: var(--theme-inner-bg);
    border: 1px solid var(--theme-border-soft);
    padding: 6px 14px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 88, 170, 0.08);
}

.time-badge-vip span.title-label {
    font-size: .85rem;
    font-weight: 900;
    color: var(--theme-blue-text);
}

.btn-time-config {
    background: none;
    border: none;
    color: var(--theme-blue-text);
    cursor: pointer;
    font-size: 1.05rem;
    padding: 0 2px;
}

.time-mini-input {
    width: 38px;
    border: none;
    border-radius: 5px;
    font-weight: 900;
    font-size: .9rem;
    text-align: center;
    padding: 2px 0;
    outline: none;
}

.time-mini-input::-webkit-outer-spin-button,
.time-mini-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.control-btn {
    border: none;
    padding: 12px 40px;
    font-size: .95rem;
    font-weight: 900;
    border-radius: 6px;
    cursor: pointer;
    text-transform: uppercase;
    transition: .2s;
}
.btn-main:hover, #btnCapNhat:hover { background: var(--theme-accent-dark); transform: translateY(-1px); }

.btn-sub {
    position: absolute;
    right: 0;
    background: #F4FAFF;
    color: var(--theme-blue-text);
    border: 1px solid var(--theme-border);
}
.btn-sub:hover { background: var(--theme-accent-dark); color: #fff; }

.winner-history-wrapper { flex: 1; overflow-y: auto; }
#lstWinner { list-style: none; padding: 0; margin: 0; }

#lstWinner li {
    background: #fff;
    color: var(--theme-text);
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 4px solid var(--theme-accent);
    box-shadow: 0 3px 8px rgba(0, 88, 170, 0.08);
    animation: slideInDown .3s cubic-bezier(.175, .885, .32, 1.275);
}

.winner-rank {
    background: linear-gradient(135deg, #EAF5FF 0%, #CBE7FF 100%);
    color: var(--theme-blue-text);
    border: 1px solid var(--theme-border-soft);
    font-size: .8rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 900;
}
.winner-name { flex: 1; text-align: left; }
@keyframes slideInDown { from { opacity: 0; transform: translateY(-15px); } to { opacity: 1; transform: translateY(0); } }

.popup-overlay, .music-popup-overlay, .game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.popup-overlay {
    background: rgba(0, 40, 90, .45);
    z-index: 999999;
    opacity: 0;
    pointer-events: none;
    transition: .3s ease;
    backdrop-filter: blur(4px);
}
.popup-overlay.active { opacity: 1; pointer-events: auto; }

.popup-content {
    background: linear-gradient(180deg, var(--theme-card-bg) 0%, var(--theme-card-bg-2) 100%);
    border: 4px solid var(--theme-border);
    border-radius: 20px;
    padding: 30px 20px;
    width: 90%;
    max-width: 550px;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0, 0, 0, .35);
    transform: scale(.7);
    transition: .4s cubic-bezier(.175, .885, .32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
}
.popup-overlay.active .popup-content { transform: scale(1); }
.popup-title-text { font-size: 1.8rem; color: var(--theme-blue-text); font-weight: 900; }

.popup-body {
    background: linear-gradient(180deg, #FFFFFF 0%, #F1F9FF 100%);
    border: 2px dashed var(--theme-border);
    border-radius: 12px;
    padding: 20px 15px;
    margin-bottom: 20px;
    width: 100%;
}

#popupWinnerName {
    font-size: clamp(2.5rem, 7vw, 4.5rem);
    color: #003B73;
    font-weight: 900;
    margin: 0;
}

.popup-logo-wrapper {
    background: #fff;
    padding: 8px 30px;
    border-radius: 10px;
    display: inline-flex;
    margin-bottom: 20px;
    border: 1px solid var(--theme-border-soft);
}
.popup-logo-img { max-height: 45px; width: auto; object-fit: contain; }

.btn-close-popup {
    border: none;
    padding: 12px 50px;
    font-size: 1.05rem;
    font-weight: 900;
    border-radius: 6px;
    text-transform: uppercase;
}

.bg-music-trigger {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    background: #fff;
    border: 2px solid var(--theme-border-soft);
    padding: 10px 15px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0,0,0,.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 900;
    color: var(--theme-blue-text);
    font-size: .85rem;
}
.music-icon-spin { font-size: 1.2rem; animation: spinMusic 3s linear infinite; display: inline-block; }
@keyframes spinMusic { 100% { transform: rotate(360deg); } }

.music-popup-overlay {
    background: rgba(0,0,0,.4);
    z-index: 100000;
    opacity: 0;
    pointer-events: none;
    transition: .2s;
}
.music-popup-overlay.active { opacity: 1; pointer-events: auto; }

.music-card {
    background: linear-gradient(180deg, var(--theme-card-bg) 0%, var(--theme-card-bg-2) 100%);
    border: 2px solid var(--theme-border);
    border-radius: 12px;
    width: 420px;
    padding: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,.25);
    color: var(--theme-text);
    position: relative;
}
.music-card-header { font-size: 1.2rem; font-weight: 900; text-align: center; color: var(--theme-blue-text); margin-bottom: 25px; border-bottom: 1px solid var(--theme-border-soft); padding-bottom: 10px; }
.music-close-x { position: absolute; top: 12px; right: 15px; font-size: 1.2rem; color: var(--theme-blue-text); cursor: pointer; }
.music-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; font-size: 1.05rem; }
.music-row label { color: var(--theme-muted-text); font-weight: 700; }
.switch-container { display: flex; align-items: center; gap: 10px; }
.switch-label-status { font-size: .9rem; font-weight: 900; color: var(--theme-blue-text); }
.music-switch { position: relative; display: inline-block; width: 60px; height: 30px; }
.music-switch input { opacity: 0; width: 0; height: 0; }
.slider-round { position: absolute; cursor: pointer; inset: 0; background-color: #BFDFFF; transition: .3s; border-radius: 34px; border: 1px solid var(--theme-border); }
.slider-round:before { position: absolute; content: ""; height: 22px; width: 22px; left: 3px; bottom: 3px; background-color: #fff; transition: .3s; border-radius: 50%; }
input:checked + .slider-round { background-color: var(--theme-accent); }
input:checked + .slider-round:before { transform: translateX(30px); }
.music-select { width: 100%; background: #fff; border: 1px solid var(--theme-border); color: var(--theme-text); padding: 10px; border-radius: 6px; outline: none; }
.music-actions { display: flex; justify-content: center; gap: 15px; margin-top: 25px; }
.music-btn { padding: 8px 25px; border-radius: 4px; font-weight: 900; cursor: pointer; border: none; }
.btn-music-cancel { background: #fff; color: var(--theme-text); border: 1px solid var(--theme-border); }

.game-overlay {
    inset: 0;
    background: rgba(0,0,0,.6);
    display: none;
    z-index: 9999;
}
.game-overlay.active { display: flex; }

#spinCenterBox {
    width: 360px;
    height: 140px;
    background: linear-gradient(135deg, #fff 0%, #EAF5FF 100%);
    border: 3px solid var(--theme-accent);
    border-radius: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0,0,0,.35);
}

#spinBox {
    font-size: 28px;
    font-weight: 900;
    color: #003B73;
    text-align: center;
    padding: 0 16px;
    word-break: break-word;
}

body.running-game .promo-sidebar,
body.running-game .side-panel,
body.running-game .footer-controls,
body.running-game .box-container {
    filter: blur(6px);
    opacity: .25;
    pointer-events: none;
}

/* Admin */
body[data-page="admin"] {
    padding: 0;
    display: block;
    overflow: auto;
    align-items: initial;
    justify-content: initial;
}
body[data-page="admin"] { align-items: stretch; overflow: auto; background: #f6fbff; }
.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); width: 100%; color: var(--theme-text); }
.admin-sidebar { background: #fff; border-right: 1px solid var(--theme-border-soft); padding: 18px; position: sticky; top: 0; height: 100vh; box-shadow: 0 8px 24px var(--theme-shadow); overflow: auto; }
.admin-sidebar img { width: 100%; max-height: 72px; object-fit: contain; margin-bottom: 18px; }
.admin-sidebar nav { display: grid; gap: 7px; }
.admin-sidebar button { text-align: left; min-height: 40px; padding: 0 12px; border-radius: 6px; background: transparent; color: var(--theme-text); border: 0; font-weight: 800; transition: background .18s ease, color .18s ease, transform .18s ease; }
.admin-sidebar button.active, .admin-sidebar button:hover { background: #e0f2fe; color: var(--theme-blue-text); transform: translateX(2px); }
.admin-sidebar button[hidden] { display: none; }
.admin-main { min-width: 0; }
.admin-header { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 24px; background: rgba(255,255,255,.9); border-bottom: 1px solid var(--theme-border-soft); position: sticky; top: 0; z-index: 5; backdrop-filter: blur(12px); }
.admin-header p { margin: 0; color: var(--theme-muted-text); font-weight: 800; }
.admin-header h1 { margin: 2px 0 0; line-height: 1.15; }
.admin-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.admin-content { padding: 24px; display: grid; gap: 18px; animation: adminFade .22s ease; }
.admin-content > * { min-width: 0; }
@keyframes adminFade { from { opacity: .35; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.admin-content.is-loading { opacity: .72; transition: opacity .12s ease; }
.admin-content.view-ready { animation: adminFade .18s ease; opacity: 1; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-grid article, .admin-panel, .table-wrap, .empty-state, .toast, .login-dialog form { background: #fff; border: 1px solid var(--theme-border-soft); border-radius: 8px; box-shadow: 0 8px 24px var(--theme-shadow); }
.stat-grid article { padding: 16px; transition: transform .18s ease, box-shadow .18s ease; }
.stat-grid article:hover { transform: translateY(-2px); box-shadow: 0 12px 28px var(--theme-shadow); }
.stat-grid span { display: block; color: var(--theme-muted-text); font-weight: 800; }
.stat-grid b { display: block; font-size: 1.75rem; margin-top: 6px; color: var(--theme-blue-text); overflow-wrap: anywhere; }
.admin-panel { padding: 18px; }
.admin-panel h2 { margin: 0 0 14px; color: var(--theme-blue-text); line-height: 1.2; }
.bar-chart { display: flex; align-items: end; gap: 12px; min-height: 170px; }
.bar-chart div { flex: 1; display: grid; align-items: end; gap: 7px; text-align: center; }
.bar-chart b { display: block; height: var(--h); min-height: 8px; border-radius: 6px 6px 0 0; background: linear-gradient(180deg, #38bdf8, #075985); }
.editor-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
.editor-form.inline { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.editor-form.account-form { grid-template-columns: minmax(260px, 2fr) minmax(150px, 1fr) minmax(150px, 1fr) auto; align-items: end; }
.editor-form.account-form .row-actions { min-width: 190px; }
.editor-form.account-form .row-actions button { min-width: 86px; }
.editor-form label { display: grid; gap: 6px; }
.editor-form span { font-weight: 800; color: var(--theme-muted-text); font-size: .9rem; }
.editor-form input, .editor-form select, .editor-form textarea, .login-dialog input { min-height: 42px; border: 1px solid var(--theme-border-soft); border-radius: 6px; padding: 0 12px; background: #fff; color: var(--theme-text); outline: none; transition: border-color .16s ease, box-shadow .16s ease; }
.editor-form input:focus, .editor-form select:focus, .editor-form textarea:focus, .admin-toolbar input:focus, .admin-toolbar select:focus, .login-dialog input:focus { border-color: #0ea5e9; box-shadow: 0 0 0 3px rgba(14,165,233,.14); }
.editor-form textarea { min-height: 132px; padding: 10px 12px; resize: vertical; }
.editor-form .wide-field { grid-column: span 2; }
.row-actions { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; }
.editor-form button, .admin-actions button, .toolbar button, .table-wrap button, .login-dialog button { min-height: 38px; padding: 0 12px; border-radius: 6px; color: #fff; background: linear-gradient(135deg, #0ea5e9, #075985); border: 0; font-weight: 800; transition: transform .16s ease, filter .16s ease, opacity .16s ease; }
.editor-form button:hover, .admin-actions button:hover, .toolbar button:hover, .table-wrap button:hover, .login-dialog button:hover { transform: translateY(-1px); filter: brightness(1.04); }
.editor-form button:disabled, .admin-actions button:disabled, .toolbar button:disabled, .table-wrap button:disabled { opacity: .45; cursor: not-allowed; }
.table-wrap { overflow: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { border-bottom: 1px solid var(--theme-border-soft); padding: 11px 12px; text-align: left; vertical-align: top; }
th { color: var(--theme-blue-text); background: #f0f9ff; position: sticky; top: 0; }
tbody tr { transition: background .16s ease; }
tbody tr:hover { background: #f8fcff; }
td button { min-height: 30px; margin: 0 6px 6px 0; padding: 0 10px; }
.table-wrap button[data-user-delete], .table-wrap button[data-ip-delete], .table-wrap button[data-account-delete], .table-wrap button[data-history-delete], .table-wrap button[data-delete], #deleteSelectedHistory, #deleteAllHistory { background: linear-gradient(135deg, #ef4444, #991b1b); }
.table-wrap button[data-user-toggle], .table-wrap button[data-ip-toggle], .table-wrap button[data-account-toggle], #clearNextWinner, #stopManual { background: linear-gradient(135deg, #64748b, #334155); }
.toolbar { display: flex; justify-content: flex-end; }
.admin-toolbar { align-items: center; flex-wrap: wrap; gap: 10px; }
.admin-toolbar input, .admin-toolbar select { min-height: 40px; border: 1px solid var(--theme-border-soft); border-radius: 6px; padding: 0 12px; background: #fff; color: var(--theme-text); }
.admin-toolbar input { min-width: min(320px, 100%); }
.admin-toolbar span { color: var(--theme-muted-text); font-weight: 800; margin-right: auto; }
.empty-state, .toast { padding: 16px; color: var(--theme-muted-text); }
.toast { position: fixed; right: 20px; top: 20px; z-index: 30; max-width: min(420px, calc(100vw - 40px)); color: #14532d; background: #dcfce7; border-color: #bbf7d0; animation: toastIn .18s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.login-dialog { border: 0; border-radius: 8px; padding: 0; background: transparent; }
.login-dialog::backdrop { background: rgba(3,7,18,.58); backdrop-filter: blur(5px); }
.login-dialog form { width: min(92vw, 420px); padding: 24px; display: grid; gap: 12px; }
.login-dialog h2 { margin: 0; }
.login-dialog p, .login-dialog small { color: var(--theme-muted-text); }
.access-denied {
    min-height: 100vh;
    display: grid;
    place-content: center;
    text-align: center;
    padding: 24px;
}
.access-denied h1 {
    margin: 0 0 8px;
    color: #b91c1c;
    font-size: clamp(2.2rem, 6vw, 4rem);
}
.access-denied p {
    margin: 0;
    color: var(--theme-muted-text);
    font-size: 1.2rem;
    font-weight: 800;
}

body.dark { --theme-page-bg: #09111f; --theme-card-bg: #0f172a; --theme-card-bg-2: #111c31; --theme-inner-bg: #111c31; --theme-text: #e5eefb; --theme-muted-text: #99aac1; --theme-border: #1e3a5f; --theme-border-soft: #1e3a5f; background: #09111f; }
body.dark[data-page="admin"] { background: #09111f; }
body.dark .admin-sidebar, body.dark .admin-header, body.dark .admin-panel, body.dark .stat-grid article, body.dark .table-wrap, body.dark .empty-state, body.dark .login-dialog form { background: var(--theme-card-bg); }
body.dark input, body.dark select, body.dark textarea, body.dark th { background: var(--theme-inner-bg); color: var(--theme-text); }
body.dark tbody tr:hover { background: rgba(14,165,233,.08); }
body.dark .admin-sidebar button.active, body.dark .admin-sidebar button:hover { background: rgba(14,165,233,.14); color: #7dd3fc; }
body.dark .admin-toolbar input, body.dark .admin-toolbar select { background: var(--theme-inner-bg); color: var(--theme-text); }

@media (max-width: 1500px) {
    .promo-sidebar { width: 200px; }
    .brand-zone { gap: 18px; }
    .brand-text h2 { font-size: 1.05rem; }
    .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1200px) {
    body { overflow: auto; align-items: flex-start; }
    .main-wrapper { height: auto; min-height: 100vh; flex-wrap: wrap; }
    .promo-sidebar { display: none; }
    .container { order: 1; flex: 1 1 100%; min-height: 58vh; }
    .side-panel { order: 2; flex: 1 1 calc(50% - 10px); min-height: 340px; }
    .user-box { width: calc(25% - 12px); }
    .admin-shell { grid-template-columns: 220px minmax(0, 1fr); }
    .admin-sidebar { padding: 14px; }
    .admin-content { padding: 18px; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .editor-form, .editor-form.account-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .user-box { width: calc(33.33% - 12px); }
    .footer-controls { flex-direction: column; gap: 10px; }
    .time-badge-vip, .btn-sub { position: static; }
    .admin-shell { display: block; padding: 12px; }
    .admin-sidebar { position: static; height: auto; border-radius: 8px; margin-bottom: 12px; }
    .admin-sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-header { position: static; height: auto; padding: 14px; border-radius: 8px; flex-direction: column; align-items: stretch; }
    .admin-content { padding: 14px 0; }
    .stat-grid, .editor-form, .editor-form.inline { grid-template-columns: 1fr; }
    .editor-form .wide-field { grid-column: auto; }
    .admin-toolbar { justify-content: stretch; }
    .admin-toolbar input, .admin-toolbar select, .admin-toolbar button { flex: 1 1 180px; }
}
@media (max-width: 600px) {
    .side-panel { flex-basis: 100%; }
    .main-header { flex-direction: column; align-items: flex-start; }
    .brand-zone { flex-direction: column; align-items: flex-start; gap: 10px; }
    .brand-text h2 { white-space: normal; }
    .user-box { width: calc(50% - 12px); }
    #spinCenterBox { width: min(92vw, 360px); }
    .admin-sidebar nav { grid-template-columns: 1fr; }
    .admin-header h1 { font-size: 1.45rem; }
    .admin-actions button, .toolbar button { flex: 1 1 auto; }
}
@media (max-width: 420px) {
    .user-box { width: 100%; }
}

/* Admin UI refinement */
body[data-page="admin"] {
    --admin-sidebar-width: 264px;
    --admin-gap: 16px;
    --admin-control-height: 40px;
    --admin-radius: 8px;
    --admin-surface: #fff;
    --admin-surface-soft: #f8fbff;
    --admin-line: #d9e8f7;
    --admin-primary: #0b83c5;
    --admin-primary-dark: #075985;
    --admin-danger: #dc2626;
    --admin-muted: #60748c;
    background: #f4f9ff;
    color: var(--theme-text);
    font-size: 15px;
}

body[data-page="admin"] .admin-shell {
    grid-template-columns: var(--admin-sidebar-width) minmax(0, 1fr);
    background: #f4f9ff;
}

body[data-page="admin"] .admin-sidebar {
    padding: 16px;
    background: var(--admin-surface);
    border-right: 1px solid var(--admin-line);
    box-shadow: 8px 0 24px rgba(11, 131, 197, .06);
}

body[data-page="admin"] .admin-sidebar img {
    width: 100%;
    max-height: 64px;
    margin: 0 0 18px;
    object-fit: contain;
}

body[data-page="admin"] .admin-sidebar nav {
    gap: 6px;
}

body[data-page="admin"] .admin-sidebar button {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border-radius: var(--admin-radius);
    line-height: 1.25;
    white-space: normal;
    display: flex;
    align-items: center;
    color: #19324d;
}

body[data-page="admin"] .admin-sidebar button.active,
body[data-page="admin"] .admin-sidebar button:hover {
    background: #e6f4ff;
    color: #074b78;
    transform: translateX(2px);
}

body[data-page="admin"] .admin-header {
    min-height: 76px;
    padding: 14px 24px;
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--admin-line);
    box-shadow: 0 8px 20px rgba(11, 131, 197, .05);
}

body[data-page="admin"] .admin-header h1 {
    font-size: clamp(1.45rem, 2.2vw, 2rem);
    letter-spacing: 0;
    color: #111827;
}

body[data-page="admin"] .admin-header p,
body[data-page="admin"] .editor-form span,
body[data-page="admin"] .admin-toolbar span,
body[data-page="admin"] .stat-grid span {
    color: var(--admin-muted);
}

body[data-page="admin"] .admin-actions,
body[data-page="admin"] .row-actions,
body[data-page="admin"] .admin-toolbar {
    gap: 10px;
}

body[data-page="admin"].auth-locked .admin-shell {
    grid-template-columns: 1fr;
}

body[data-page="admin"].auth-session-pending .auth-gate {
    display: none;
}

body[data-page="admin"].auth-locked .admin-sidebar,
body[data-page="admin"].auth-locked .admin-content {
    display: none;
}

body[data-page="admin"] .auth-gate {
    min-height: calc(100vh - 76px);
    padding: 24px;
    display: none;
    place-items: center;
}

body[data-page="admin"].auth-locked .auth-gate {
    display: grid;
}

body[data-page="admin"] .auth-gate > div {
    width: min(460px, 100%);
    padding: 26px;
    border: 1px solid var(--admin-line);
    border-radius: var(--admin-radius);
    background: var(--admin-surface);
    box-shadow: 0 14px 34px rgba(11, 131, 197, .12);
    text-align: center;
}

body[data-page="admin"] .auth-gate h2 {
    margin: 0 0 8px;
    color: #074b78;
}

body[data-page="admin"] .auth-gate p {
    margin: 0 0 18px;
    color: var(--admin-muted);
    font-weight: 800;
}

body[data-page="admin"] .auth-gate button {
    min-height: var(--admin-control-height);
    padding: 0 18px;
    border-radius: var(--admin-radius);
    color: #fff;
    border: 0;
    font-weight: 900;
    background: linear-gradient(135deg, var(--admin-primary), var(--admin-primary-dark));
    box-shadow: 0 6px 14px rgba(11, 131, 197, .14);
}

body[data-page="admin"] .admin-content {
    padding: 22px;
    gap: var(--admin-gap);
    align-content: start;
}

body[data-page="admin"] .stat-grid {
    gap: var(--admin-gap);
}

body[data-page="admin"] .stat-grid article,
body[data-page="admin"] .admin-panel,
body[data-page="admin"] .table-wrap,
body[data-page="admin"] .empty-state,
body[data-page="admin"] .toast,
body[data-page="admin"] .login-dialog form {
    border: 1px solid var(--admin-line);
    border-radius: var(--admin-radius);
    background: var(--admin-surface);
    box-shadow: 0 8px 22px rgba(11, 131, 197, .07);
}

body[data-page="admin"] .stat-grid article,
body[data-page="admin"] .admin-panel {
    padding: 18px;
}

body[data-page="admin"] .stat-grid b {
    font-size: 1.55rem;
    line-height: 1.2;
    color: #074b78;
}

body[data-page="admin"] .admin-panel h2 {
    margin-bottom: 16px;
    font-size: 1.25rem;
    color: #074b78;
}

body[data-page="admin"] .editor-form {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 14px;
    align-items: end;
}

body[data-page="admin"] .editor-form.inline {
    grid-template-columns: repeat(4, minmax(160px, 1fr));
}

body[data-page="admin"] .editor-form.account-form {
    grid-template-columns: minmax(240px, 1.6fr) minmax(150px, .8fr) minmax(150px, .8fr) auto;
}

body[data-page="admin"] .editor-form label {
    gap: 7px;
    min-width: 0;
}

body[data-page="admin"] .editor-form input,
body[data-page="admin"] .editor-form select,
body[data-page="admin"] .editor-form textarea,
body[data-page="admin"] .admin-toolbar input,
body[data-page="admin"] .admin-toolbar select,
body[data-page="admin"] .login-dialog input {
    width: 100%;
    min-height: var(--admin-control-height);
    border: 1px solid var(--admin-line);
    border-radius: var(--admin-radius);
    padding: 0 12px;
    background: #fff;
    box-sizing: border-box;
    font: inherit;
}

body[data-page="admin"] .editor-form textarea {
    min-height: 112px;
    padding: 10px 12px;
    line-height: 1.45;
}

body[data-page="admin"] .editor-form input:focus,
body[data-page="admin"] .editor-form select:focus,
body[data-page="admin"] .editor-form textarea:focus,
body[data-page="admin"] .admin-toolbar input:focus,
body[data-page="admin"] .admin-toolbar select:focus,
body[data-page="admin"] .login-dialog input:focus {
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, .16);
}

body[data-page="admin"] button {
    cursor: pointer;
}

body[data-page="admin"] .editor-form button,
body[data-page="admin"] .admin-actions button,
body[data-page="admin"] .toolbar button,
body[data-page="admin"] .table-wrap button,
body[data-page="admin"] .login-dialog button {
    min-height: var(--admin-control-height);
    padding: 0 14px;
    border-radius: var(--admin-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 1;
    white-space: nowrap;
    background: linear-gradient(135deg, var(--admin-primary), var(--admin-primary-dark));
    box-shadow: 0 6px 14px rgba(11, 131, 197, .14);
}

body[data-page="admin"] .table-wrap button {
    min-height: 34px;
    padding: 0 11px;
    margin: 0 6px 6px 0;
}

body[data-page="admin"] .editor-form button:disabled,
body[data-page="admin"] .admin-actions button:disabled,
body[data-page="admin"] .toolbar button:disabled,
body[data-page="admin"] .table-wrap button:disabled {
    opacity: .5;
    transform: none;
    cursor: not-allowed;
}

body[data-page="admin"] .table-wrap button[data-user-delete],
body[data-page="admin"] .table-wrap button[data-ip-delete],
body[data-page="admin"] .table-wrap button[data-account-delete],
body[data-page="admin"] .table-wrap button[data-history-delete],
body[data-page="admin"] .table-wrap button[data-next-delete],
body[data-page="admin"] .table-wrap button[data-delete],
body[data-page="admin"] #deleteSelectedHistory,
body[data-page="admin"] #deleteAllHistory {
    background: linear-gradient(135deg, #ef4444, #991b1b);
}

body[data-page="admin"] .table-wrap button[data-user-toggle],
body[data-page="admin"] .table-wrap button[data-ip-toggle],
body[data-page="admin"] .table-wrap button[data-account-toggle],
body[data-page="admin"] #clearNextWinner,
body[data-page="admin"] #stopManual {
    background: linear-gradient(135deg, #64748b, #334155);
}

body[data-page="admin"] .table-wrap button[data-user-auth] {
    background: linear-gradient(135deg, #14b8a6, #0f766e);
}

body[data-page="admin"] #deleteSelectedNext {
    background: linear-gradient(135deg, #ef4444, #991b1b);
}

body[data-page="admin"] .queue-panel {
    display: grid;
    gap: 14px;
}

body[data-page="admin"] .queue-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

body[data-page="admin"] .queue-toolbar h2 {
    margin: 0 0 4px;
}

body[data-page="admin"] .queue-toolbar p {
    margin: 0;
    color: var(--admin-muted);
    font-weight: 800;
}

body[data-page="admin"] .queue-scroll {
    max-height: min(58vh, 560px);
    overflow: auto;
    border: 1px solid var(--admin-line);
    border-radius: var(--admin-radius);
    background: var(--admin-surface);
    scroll-behavior: smooth;
}

body[data-page="admin"] .queue-table {
    min-width: 820px;
}

body[data-page="admin"] .queue-table th {
    position: sticky;
    top: 0;
    z-index: 1;
}

body[data-page="admin"] .queue-table tbody tr {
    cursor: grab;
    transition: background .16s ease, box-shadow .16s ease, transform .16s ease;
}

body[data-page="admin"] .queue-table tbody tr:hover {
    background: #f4fbff;
    box-shadow: inset 3px 0 0 var(--admin-primary);
}

body[data-page="admin"] .queue-table tbody tr.dragging {
    opacity: .55;
    cursor: grabbing;
    background: #e0f2fe;
    transform: scale(.995);
}

body[data-page="admin"] .queue-rank {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #e0f2fe;
    color: #075985;
    font-weight: 900;
}

body[data-page="admin"] .queue-status {
    min-height: 28px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    font-weight: 900;
    white-space: nowrap;
}

body[data-page="admin"] .queue-status.is-next {
    background: #dcfce7;
    color: #166534;
}

body[data-page="admin"] .queue-table input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--admin-primary);
}

body[data-page="admin"] .twofa-dialog form {
    text-align: center;
}

body[data-page="admin"] .twofa-dialog img {
    width: 180px;
    height: 180px;
    margin: 8px auto;
    display: block;
    border-radius: var(--admin-radius);
    border: 1px solid var(--admin-line);
}

body[data-page="admin"] .permission-grid {
    grid-column: 1 / -1;
    margin: 0;
    padding: 14px;
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 12px;
    border: 1px solid var(--admin-line);
    border-radius: var(--admin-radius);
    background: var(--admin-surface-soft);
}

body[data-page="admin"] .permission-grid legend {
    padding: 0 8px;
    color: #074b78;
    font-weight: 900;
}

body[data-page="admin"] .permission-group {
    display: grid;
    gap: 8px;
    align-content: start;
}

body[data-page="admin"] .permission-group strong {
    color: #074b78;
}

body[data-page="admin"] .permission-group label {
    min-height: 30px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

body[data-page="admin"] .permission-group input {
    width: 16px;
    height: 16px;
    accent-color: var(--admin-primary);
}

body[data-page="admin"] .toolbar,
body[data-page="admin"] .admin-toolbar {
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
}

body[data-page="admin"] .admin-toolbar input,
body[data-page="admin"] .admin-toolbar select {
    flex: 0 1 240px;
    min-width: 180px;
}

body[data-page="admin"] .admin-toolbar input {
    flex-basis: 320px;
}

body[data-page="admin"] .table-wrap {
    overflow: auto;
}

body[data-page="admin"] table {
    width: 100%;
    min-width: 820px;
    border-collapse: separate;
    border-spacing: 0;
}

body[data-page="admin"] th,
body[data-page="admin"] td {
    padding: 12px 14px;
    vertical-align: middle;
    border-bottom: 1px solid var(--admin-line);
    line-height: 1.35;
}

body[data-page="admin"] th {
    height: 44px;
    color: #074b78;
    background: #edf7ff;
    font-weight: 900;
}

body[data-page="admin"] tbody tr:last-child td {
    border-bottom: 0;
}

body[data-page="admin"] tbody tr:hover {
    background: var(--admin-surface-soft);
}

body[data-page="admin"] .empty-state {
    padding: 18px;
}

body[data-page="admin"] .toast {
    padding: 14px 16px;
    right: 18px;
    top: 18px;
}

body.dark[data-page="admin"] {
    --admin-surface: #0f172a;
    --admin-surface-soft: #111c31;
    --admin-line: #1e3a5f;
    --admin-muted: #99aac1;
    background: #09111f;
}

body.dark[data-page="admin"] .admin-shell,
body.dark[data-page="admin"] .admin-sidebar,
body.dark[data-page="admin"] .admin-header,
body.dark[data-page="admin"] .admin-panel,
body.dark[data-page="admin"] .stat-grid article,
body.dark[data-page="admin"] .table-wrap,
body.dark[data-page="admin"] .empty-state,
body.dark[data-page="admin"] .auth-gate > div,
body.dark[data-page="admin"] .login-dialog form {
    background: var(--admin-surface);
}

body.dark[data-page="admin"] .admin-header h1,
body.dark[data-page="admin"] .admin-sidebar button {
    color: var(--theme-text);
}

body.dark[data-page="admin"] input,
body.dark[data-page="admin"] select,
body.dark[data-page="admin"] textarea,
body.dark[data-page="admin"] th {
    background: var(--admin-surface-soft);
    color: var(--theme-text);
    border-color: var(--admin-line);
}

@media (max-width: 1200px) {
    body[data-page="admin"] .admin-shell { grid-template-columns: 224px minmax(0, 1fr); }
    body[data-page="admin"] .admin-content { padding: 18px; }
    body[data-page="admin"] .editor-form,
    body[data-page="admin"] .editor-form.inline,
    body[data-page="admin"] .editor-form.account-form { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
}

@media (max-width: 900px) {
    body[data-page="admin"] .admin-shell { display: block; padding: 12px; }
    body[data-page="admin"] .admin-sidebar {
        position: static;
        height: auto;
        border: 1px solid var(--admin-line);
        border-radius: var(--admin-radius);
        margin-bottom: 12px;
    }
    body[data-page="admin"] .admin-sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    body[data-page="admin"] .admin-header {
        position: static;
        border: 1px solid var(--admin-line);
        border-radius: var(--admin-radius);
        flex-direction: column;
        align-items: stretch;
    }
    body[data-page="admin"] .admin-content { padding: 12px 0 0; }
    body[data-page="admin"] .stat-grid,
    body[data-page="admin"] .editor-form,
    body[data-page="admin"] .editor-form.inline,
    body[data-page="admin"] .editor-form.account-form { grid-template-columns: 1fr; }
    body[data-page="admin"] .permission-grid { grid-template-columns: 1fr; }
    body[data-page="admin"] .editor-form .wide-field { grid-column: auto; }
    body[data-page="admin"] .admin-toolbar { justify-content: stretch; }
    body[data-page="admin"] .admin-toolbar input,
    body[data-page="admin"] .admin-toolbar select,
    body[data-page="admin"] .admin-toolbar button,
    body[data-page="admin"] .admin-actions button,
    body[data-page="admin"] .row-actions button { flex: 1 1 180px; }
}

@media (max-width: 600px) {
    body[data-page="admin"] .admin-sidebar nav { grid-template-columns: 1fr; }
    body[data-page="admin"] .admin-header h1 { font-size: 1.35rem; }
    body[data-page="admin"] .admin-content { gap: 12px; }
    body[data-page="admin"] .stat-grid article,
    body[data-page="admin"] .admin-panel { padding: 14px; }
    body[data-page="admin"] table { min-width: 720px; }
}

/* CMS visual refresh — giao diện mới, không thay đổi DOM hoặc nghiệp vụ */
body[data-page="admin"] {
    --admin-sidebar-width: 280px;
    --admin-gap: 20px;
    --admin-control-height: 44px;
    --admin-radius: 16px;
    --admin-surface: #ffffff;
    --admin-surface-soft: #f6f8fc;
    --admin-line: #e4e9f2;
    --admin-primary: #4f46e5;
    --admin-primary-dark: #3730a3;
    --admin-danger: #e11d48;
    --admin-muted: #7b8499;
    background: #f4f6fa;
    color: #172033;
    font-family: "Be Vietnam Pro", Inter, system-ui, sans-serif;
}

body[data-page="admin"] .admin-shell {
    min-height: 100vh;
    background:
        radial-gradient(circle at 82% 0, rgba(99,102,241,.08), transparent 28%),
        #f4f6fa;
}

body[data-page="admin"] .admin-sidebar {
    padding: 22px 16px 18px;
    background: linear-gradient(180deg, #11182b 0%, #161f38 100%);
    border-right: 0;
    box-shadow: 16px 0 50px rgba(17,24,39,.12);
}

body[data-page="admin"] .admin-sidebar img {
    width: calc(100% - 24px);
    max-height: 66px;
    margin: 0 12px 24px;
    padding: 9px 12px;
    border-radius: 14px;
    background: rgba(255,255,255,.96);
    object-fit: contain;
}

body[data-page="admin"] .admin-sidebar nav {
    display: grid;
    gap: 5px;
}

body[data-page="admin"] .admin-sidebar button {
    min-height: 47px;
    padding: 10px 14px;
    border-radius: 12px;
    color: #aeb8cf;
    font-size: .88rem;
    font-weight: 700;
    transition: color .18s ease, background .18s ease, transform .18s ease;
}

body[data-page="admin"] .admin-sidebar button::before {
    content: "";
    width: 7px;
    height: 7px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: #5e6a85;
    box-shadow: 0 0 0 4px rgba(255,255,255,.03);
}

body[data-page="admin"] .admin-sidebar button.active,
body[data-page="admin"] .admin-sidebar button:hover {
    color: #fff;
    background: linear-gradient(135deg, rgba(99,102,241,.95), rgba(79,70,229,.72));
    box-shadow: 0 9px 22px rgba(37,31,127,.3);
    transform: translateX(3px);
}

body[data-page="admin"] .admin-sidebar button.active::before,
body[data-page="admin"] .admin-sidebar button:hover::before {
    background: #fff;
}

body[data-page="admin"] .admin-main {
    min-width: 0;
}

body[data-page="admin"] .admin-header {
    min-height: 88px;
    padding: 16px 30px;
    background: rgba(255,255,255,.9);
    border-bottom: 1px solid rgba(228,233,242,.9);
    box-shadow: 0 8px 30px rgba(31,42,68,.045);
    backdrop-filter: blur(18px);
}

body[data-page="admin"] .admin-header p {
    color: #8b95aa;
    font-size: .72rem;
    letter-spacing: .1em;
    text-transform: uppercase;
}

body[data-page="admin"] .admin-header h1 {
    margin-top: 5px;
    color: #172033;
    font-size: clamp(1.45rem, 2vw, 1.9rem);
    font-weight: 800;
    letter-spacing: -.035em;
}

body[data-page="admin"] .admin-actions button,
body[data-page="admin"] .editor-form button,
body[data-page="admin"] .toolbar button,
body[data-page="admin"] .table-wrap button,
body[data-page="admin"] .login-dialog button,
body[data-page="admin"] .auth-gate button {
    min-height: 42px;
    padding: 0 16px;
    border-radius: 11px;
    background: linear-gradient(135deg, #6157ee, #4338ca);
    box-shadow: 0 8px 18px rgba(79,70,229,.18);
    font-size: .82rem;
    font-weight: 800;
}

body[data-page="admin"] .admin-actions button:first-child {
    color: #344056;
    background: #f2f4f8;
    box-shadow: none;
    border: 1px solid #e1e6ef;
}

body[data-page="admin"] .admin-content {
    max-width: 1560px;
    width: 100%;
    margin: 0 auto;
    padding: 28px 30px 48px;
}

body[data-page="admin"] .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

body[data-page="admin"] .stat-grid article,
body[data-page="admin"] .admin-panel,
body[data-page="admin"] .table-wrap,
body[data-page="admin"] .empty-state,
body[data-page="admin"] .login-dialog form,
body[data-page="admin"] .auth-gate > div {
    border: 1px solid #e7ebf2;
    border-radius: 18px;
    background: rgba(255,255,255,.97);
    box-shadow: 0 12px 35px rgba(31,42,68,.065);
}

body[data-page="admin"] .stat-grid article {
    min-height: 128px;
    padding: 22px;
    position: relative;
    overflow: hidden;
}

body[data-page="admin"] .stat-grid article::after {
    content: "";
    position: absolute;
    width: 76px;
    height: 76px;
    right: -24px;
    top: -24px;
    border-radius: 50%;
    background: rgba(99,102,241,.08);
}

body[data-page="admin"] .stat-grid span {
    font-size: .78rem;
    font-weight: 700;
}

body[data-page="admin"] .stat-grid b {
    margin-top: 15px;
    color: #172033;
    font-size: 1.85rem;
    letter-spacing: -.04em;
}

body[data-page="admin"] .admin-panel {
    padding: 22px;
}

body[data-page="admin"] .admin-panel h2 {
    margin-bottom: 18px;
    color: #202a40;
    font-size: 1.12rem;
    letter-spacing: -.02em;
}

body[data-page="admin"] .admin-toolbar {
    padding: 13px;
    border: 1px solid #e8ecf3;
    border-radius: 14px;
    background: #f8f9fc;
}

body[data-page="admin"] .editor-form input,
body[data-page="admin"] .editor-form select,
body[data-page="admin"] .editor-form textarea,
body[data-page="admin"] .admin-toolbar input,
body[data-page="admin"] .admin-toolbar select,
body[data-page="admin"] .login-dialog input {
    min-height: 44px;
    border: 1px solid #dfe4ed;
    border-radius: 11px;
    color: #253049;
    background: #fff;
    box-shadow: 0 1px 2px rgba(31,42,68,.03);
}

body[data-page="admin"] .editor-form input:focus,
body[data-page="admin"] .editor-form select:focus,
body[data-page="admin"] .editor-form textarea:focus,
body[data-page="admin"] .admin-toolbar input:focus,
body[data-page="admin"] .admin-toolbar select:focus,
body[data-page="admin"] .login-dialog input:focus {
    border-color: #7770ed;
    box-shadow: 0 0 0 4px rgba(99,102,241,.11);
}

body[data-page="admin"] .table-wrap {
    overflow: hidden;
}

body[data-page="admin"] .table-wrap > div {
    overflow-x: auto;
}

body[data-page="admin"] table {
    border-spacing: 0;
}

body[data-page="admin"] th {
    padding: 13px 15px;
    color: #79849a;
    background: #f7f8fb;
    border-bottom: 1px solid #e5e9f1;
    font-size: .7rem;
    letter-spacing: .06em;
    text-transform: uppercase;
}

body[data-page="admin"] td {
    padding: 14px 15px;
    border-bottom: 1px solid #edf0f5;
    color: #344056;
    font-size: .84rem;
}

body[data-page="admin"] tbody tr {
    transition: background .16s ease, box-shadow .16s ease;
}

body[data-page="admin"] tbody tr:hover {
    background: #f8f8ff;
    box-shadow: inset 3px 0 #6366f1;
}

body[data-page="admin"] .table-wrap button {
    min-height: 33px;
    padding: 0 11px;
    border-radius: 9px;
    font-size: .72rem;
}

body[data-page="admin"] .bar-chart {
    min-height: 260px;
    padding-top: 22px;
}

body[data-page="admin"] .bar-chart i {
    border-radius: 8px 8px 3px 3px;
    background: linear-gradient(180deg, #818cf8, #4f46e5);
    box-shadow: 0 9px 18px rgba(79,70,229,.13);
}

body[data-page="admin"] .queue-scroll,
body[data-page="admin"] .permission-grid {
    border-color: #e4e8f0;
    border-radius: 14px;
    background: #f8f9fc;
}

body[data-page="admin"] .queue-rank {
    background: #ebe9ff;
    color: #4338ca;
}

body[data-page="admin"] .queue-status {
    background: #eef0ff;
    color: #4338ca;
}

body[data-page="admin"] .queue-status.is-next {
    background: #dcfce7;
    color: #15803d;
}

body[data-page="admin"] .login-dialog::backdrop {
    background: rgba(12,18,32,.72);
    backdrop-filter: blur(10px);
}

body[data-page="admin"] .login-dialog form,
body[data-page="admin"] .auth-gate > div {
    padding: 30px;
}

body[data-page="admin"] .login-dialog h2,
body[data-page="admin"] .auth-gate h2 {
    color: #202a40;
    letter-spacing: -.03em;
}

/* Luôn hiện cổng đăng nhập khi chưa xác nhận được phiên quản trị.
   Điều này tránh màn hình trống nếu token cũ còn trong trình duyệt
   hoặc backend local cần vài giây để khởi động. */
body[data-page="admin"].auth-session-pending .admin-sidebar,
body[data-page="admin"].auth-session-pending .admin-content {
    display: none;
}

body[data-page="admin"].auth-session-pending .admin-shell {
    grid-template-columns: 1fr;
}

body[data-page="admin"].auth-session-pending .auth-gate {
    display: grid;
}

body[data-page="admin"].auth-locked .admin-header,
body[data-page="admin"].auth-session-pending .admin-header {
    width: 100%;
}

body[data-page="admin"] .auth-gate {
    background:
        radial-gradient(circle at 72% 18%, rgba(99,102,241,.13), transparent 32%),
        #f4f6fa;
}

body[data-page="admin"] .auth-gate > div::before {
    content: "88CLB CMS";
    display: inline-flex;
    margin-bottom: 16px;
    padding: 7px 11px;
    border-radius: 999px;
    color: #4338ca;
    background: #eeecff;
    font-size: .72rem;
    font-weight: 900;
    letter-spacing: .08em;
}

body[data-page="admin"].dark,
body[data-page="admin"].dark .admin-shell {
    background: #0e1422;
}

body[data-page="admin"].dark .admin-header,
body[data-page="admin"].dark .admin-panel,
body[data-page="admin"].dark .stat-grid article,
body[data-page="admin"].dark .table-wrap,
body[data-page="admin"].dark .empty-state,
body[data-page="admin"].dark .login-dialog form {
    color: #dce3f1;
    background: #171f31;
    border-color: #28344b;
}

body[data-page="admin"].dark .admin-header h1,
body[data-page="admin"].dark .admin-panel h2,
body[data-page="admin"].dark .stat-grid b {
    color: #f4f7fc;
}

body[data-page="admin"].dark th,
body[data-page="admin"].dark .admin-toolbar {
    background: #111827;
    border-color: #28344b;
}

body[data-page="admin"].dark td {
    color: #cbd5e1;
    border-color: #28344b;
}

body[data-page="admin"].dark tbody tr:hover {
    background: #1d2740;
}

@media (max-width: 1100px) {
    body[data-page="admin"] { --admin-sidebar-width: 238px; }
    body[data-page="admin"] .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    body[data-page="admin"] .admin-content { padding: 22px; }
}

@media (max-width: 760px) {
    body[data-page="admin"] .admin-shell { display: block; padding: 0; }
    body[data-page="admin"] .admin-sidebar {
        position: static;
        height: auto;
        margin: 0;
        border-radius: 0 0 18px 18px;
    }
    body[data-page="admin"] .admin-sidebar img {
        width: 170px;
        margin: 0 auto 16px;
        display: block;
    }
    body[data-page="admin"] .admin-sidebar nav { grid-template-columns: repeat(2, minmax(0,1fr)); }
    body[data-page="admin"] .admin-sidebar button { min-height: 44px; font-size: .78rem; }
    body[data-page="admin"] .admin-header { position: sticky; top: 0; border-radius: 0; padding: 13px 16px; }
    body[data-page="admin"] .admin-content { padding: 16px 12px 34px; }
    body[data-page="admin"] .editor-form,
    body[data-page="admin"] .editor-form.inline,
    body[data-page="admin"] .editor-form.account-form { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
    body[data-page="admin"] .admin-sidebar nav { grid-template-columns: 1fr; }
    body[data-page="admin"] .stat-grid { grid-template-columns: 1fr; }
    body[data-page="admin"] .admin-header { align-items: stretch; }
    body[data-page="admin"] .admin-actions { display: grid; grid-template-columns: 1fr 1fr; }
    body[data-page="admin"] .admin-toolbar { align-items: stretch; }
    body[data-page="admin"] .admin-toolbar > * { flex: 1 1 100%; width: 100%; }
}
