: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;
}

.public-shell .admin-sidebar nav {
    display: grid;
    gap: 10px;
}

.admin-link {
    display: block;
    text-decoration: none;
    color: #fff;
    font-weight: 900;
    padding: 12px 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, #1EA7FF, #005BBF);
    text-align: center;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stats-grid article {
    background: linear-gradient(180deg, var(--theme-card-bg), var(--theme-card-bg-2));
    border: 1px solid var(--theme-border-soft);
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 12px 28px var(--theme-shadow);
}

.stats-grid span {
    color: var(--theme-muted-text);
    font-weight: 800;
}

.stats-grid strong {
    display: block;
    color: var(--theme-blue-text);
    font-size: 2rem;
    margin-top: 8px;
}

.panel-card {
    background: var(--theme-card-bg);
    border: 1px solid var(--theme-border-soft);
    border-radius: 18px;
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: 0 12px 28px var(--theme-shadow);
}

.panel-card h2 {
    margin: 0 0 14px;
    color: var(--theme-blue-text);
    text-transform: uppercase;
}

.admin-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 12px;
    align-items: end;
}

.admin-form-grid label,
#settingForm label {
    display: grid;
    gap: 7px;
    color: var(--theme-muted-text);
    font-weight: 800;
}

.admin-form-grid input,
.admin-form-grid select,
#settingForm input {
    width: 100%;
    border: 1px solid var(--theme-border);
    border-radius: 12px;
    padding: 12px 14px;
    background: var(--theme-inner-bg);
    color: var(--theme-text);
}

.admin-form-grid button,
#settingForm button,
td button {
    border: 0;
    border-radius: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #1EA7FF, #005BBF);
    color: #fff;
    font-weight: 900;
}

button.danger,
td button.danger {
    background: linear-gradient(135deg, #ff4d4d, #bd1f1f);
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--theme-border-soft);
    border-radius: 16px;
}

.table-wrap table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
    background: var(--theme-card-bg);
}

.table-wrap th,
.table-wrap td {
    padding: 12px;
    border-bottom: 1px solid var(--theme-border-soft);
    text-align: left;
    vertical-align: top;
}

.table-wrap th {
    color: var(--theme-blue-text);
    background: var(--theme-soft-bg);
    font-weight: 900;
}

.empty {
    padding: 20px;
    border: 1px dashed var(--theme-border);
    border-radius: 16px;
    color: var(--theme-muted-text);
    font-weight: 800;
}

.chart {
    display: grid;
    grid-template-columns: repeat(7, minmax(70px, 1fr));
    gap: 12px;
    align-items: end;
    min-height: 160px;
}

.chart div {
    display: grid;
    gap: 7px;
    justify-items: center;
    color: var(--theme-muted-text);
    font-size: .82rem;
    font-weight: 800;
}

.chart b {
    width: 34px;
    min-height: 8px;
    border-radius: 10px 10px 4px 4px;
    background: linear-gradient(180deg, #1EA7FF, #005BBF);
}

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

.result-grid p,
.result-box p {
    padding: 12px;
    border-radius: 12px;
    background: var(--theme-soft-bg);
    margin: 0;
}

details {
    margin-top: 14px;
}

pre {
    overflow: auto;
    padding: 14px;
    border-radius: 14px;
    background: #0b1b33;
    color: #d9f4ff;
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 100000;
    padding: 14px 18px;
    border-radius: 14px;
    background: #063b86;
    color: #fff;
    font-weight: 900;
    box-shadow: 0 18px 45px rgba(0,0,0,.18);
}

.dark-mode {
    --theme-page-bg: #08172b;
    --theme-card-bg: #101f36;
    --theme-card-bg-2: #0d1a2e;
    --theme-inner-bg: #0b1728;
    --theme-soft-bg: #122743;
    --theme-text: #edf7ff;
    --theme-blue-text: #8ecbff;
    --theme-muted-text: #b7c8df;
    --theme-border: #244466;
    --theme-border-soft: #203b5c;
    --theme-shadow: rgba(0, 0, 0, 0.28);
}

@media (max-width: 860px) {
    .chart {
        grid-template-columns: repeat(2, 1fr);
    }
}

body[data-page="user"] {
    display: block;
    padding: 0;
    overflow: auto;
    background: linear-gradient(135deg, #eef8ff, #ffffff 46%, #eafdf7);
}

.hidden { display: none !important; }

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

.user-login-card {
    width: min(420px, 100%);
    padding: 28px;
    border: 1px solid var(--theme-border-soft);
    border-radius: 24px;
    background: var(--theme-card-bg);
    box-shadow: 0 24px 70px var(--theme-shadow);
    display: grid;
    gap: 14px;
}

.user-login-card img {
    width: 220px;
    max-height: 90px;
    object-fit: contain;
    margin: auto;
}

.user-login-card h1 {
    margin: 0;
    color: var(--theme-blue-text);
    text-align: center;
}

.user-login-card label,
.user-form label {
    display: grid;
    gap: 8px;
    color: var(--theme-muted-text);
    font-weight: 900;
}

.user-login-card input,
.user-form input,
.user-form select {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--theme-border);
    border-radius: 14px;
    padding: 0 14px;
    background: var(--theme-inner-bg);
    color: var(--theme-text);
}

.user-login-card button,
.user-form button,
.user-panel button,
.qr-actions a,
.qr-actions button {
    min-height: 44px;
    border: 0;
    border-radius: 14px;
    padding: 0 16px;
    color: #fff;
    background: linear-gradient(135deg, #1EA7FF, #005BBF);
    font-weight: 950;
    text-decoration: none;
    display: inline-grid;
    place-items: center;
}

.user-dashboard {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
}

.user-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 18px;
    background: var(--theme-card-bg);
    border-right: 1px solid var(--theme-border-soft);
    box-shadow: 0 12px 34px var(--theme-shadow);
    transition: width .25s ease, transform .25s ease;
    overflow: hidden auto;
}

.user-sidebar.collapsed {
    width: 88px;
}

.user-sidebar.collapsed b,
.user-sidebar.collapsed .user-brand img {
    display: none;
}

.user-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.user-brand img {
    width: 190px;
    max-height: 70px;
    object-fit: contain;
}

.user-brand button,
#hamburger {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 14px;
    background: #e6f4ff;
    color: var(--theme-blue-text);
    font-weight: 950;
}

#userMenu {
    display: grid;
    gap: 9px;
}

#userMenu button {
    min-height: 48px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--theme-text);
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 13px;
    text-align: left;
    transition: background .2s ease, transform .2s ease;
}

#userMenu button.active,
#userMenu button:hover {
    background: #e6f4ff;
    color: var(--theme-blue-text);
    transform: translateX(2px);
}

.user-main {
    min-width: 0;
}

.user-header {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 78px;
    padding: 12px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: rgba(255,255,255,.9);
    border-bottom: 1px solid var(--theme-border-soft);
    backdrop-filter: blur(12px);
}

.user-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-header-title img {
    width: 86px;
    max-height: 42px;
    object-fit: contain;
}

.user-header-title p,
.user-header-title h1 {
    margin: 0;
}

.user-header-title p {
    color: var(--theme-muted-text);
    font-weight: 800;
}

.user-header-title h1 {
    color: var(--theme-blue-text);
}

.user-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.user-header-actions span,
.user-header-actions button {
    min-height: 36px;
    border: 1px solid var(--theme-border-soft);
    border-radius: 999px;
    padding: 0 12px;
    background: var(--theme-card-bg);
    color: var(--theme-blue-text);
    font-weight: 900;
}

#userRoleBadge {
    background: #e8fff4;
    color: #048650;
}

.user-content {
    padding: 22px;
    display: grid;
    gap: 18px;
    animation: adminFade .22s ease;
}

.user-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
}

.user-card,
.user-panel {
    background: var(--theme-card-bg);
    border: 1px solid var(--theme-border-soft);
    border-radius: 22px;
    padding: 20px;
    box-shadow: 0 18px 45px var(--theme-shadow);
}

.user-card h2,
.user-panel h2 {
    margin: 0 0 12px;
    color: var(--theme-blue-text);
    text-transform: uppercase;
}

.user-card p {
    margin: 0;
    font-size: 1.7rem;
    font-weight: 950;
}

.user-card span {
    color: var(--theme-muted-text);
    font-weight: 800;
}

.user-form {
    display: grid;
    gap: 14px;
}

.bank-picker {
    display: grid;
    gap: 10px;
}

.bank-list {
    max-height: 310px;
    overflow: auto;
    display: grid;
    gap: 8px;
}

.bank-list button {
    display: grid;
    grid-template-columns: 64px 1fr auto;
    gap: 10px;
    align-items: center;
    width: 100%;
    padding: 10px;
    border: 1px solid var(--theme-border-soft);
    border-radius: 16px;
    background: var(--theme-inner-bg);
    color: var(--theme-text);
    text-align: left;
}

.bank-list img {
    width: 58px;
    height: 36px;
    object-fit: contain;
    border-radius: 10px;
    background: #fff;
}

.bank-list small {
    display: block;
    color: var(--theme-muted-text);
}

.lookup-result,
.qr-output {
    display: grid;
    gap: 10px;
}

.lookup-result p,
.qr-output p {
    margin: 0;
    padding: 13px;
    border-radius: 15px;
    background: var(--theme-soft-bg);
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.lookup-result b,
.qr-output b {
    color: var(--theme-blue-text);
}

.not-found {
    padding: 18px;
    border-radius: 16px;
    background: #fff1f1;
    color: #bd1f1f;
    font-weight: 950;
}

.qr-output img {
    width: min(320px, 100%);
    margin: auto;
    border-radius: 18px;
    border: 1px solid var(--theme-border-soft);
    background: #fff;
}

.qr-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.toast-host {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 100000;
    display: grid;
    gap: 10px;
}

.user-toast {
    padding: 13px 16px;
    border-radius: 15px;
    color: #fff;
    font-weight: 950;
    box-shadow: 0 18px 44px rgba(0,0,0,.18);
    background: #075985;
}

.user-toast.success { background: #0a8f5a; }
.user-toast.error { background: #bd1f1f; }

body.dark-mode[data-page="user"] {
    --theme-page-bg: #111827;
    --theme-card-bg: #172033;
    --theme-card-bg-2: #111827;
    --theme-inner-bg: #111827;
    --theme-soft-bg: #1f2937;
    --theme-text: #ffffff;
    --theme-blue-text: #93c5fd;
    --theme-muted-text: #cbd5e1;
    --theme-border: #334155;
    --theme-border-soft: #243244;
    --theme-shadow: rgba(0,0,0,.32);
    background: #111827;
}

body.dark-mode[data-page="user"] .user-header {
    background: rgba(17,24,39,.9);
}

body.dark-mode[data-page="user"] #userMenu button.active,
body.dark-mode[data-page="user"] #userMenu button:hover {
    background: #1f2937;
}

@media (max-width: 980px) {
    .user-dashboard {
        display: block;
    }

    .user-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 282px;
        transform: translateX(-105%);
        z-index: 40;
    }

    .user-sidebar.open {
        transform: translateX(0);
    }

    .user-header {
        position: sticky;
        align-items: flex-start;
        flex-direction: column;
    }

    .user-header-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 560px) {
    .user-content {
        padding: 14px;
    }

    .lookup-result p,
    .qr-output p {
        display: grid;
    }

    .bank-list button {
        grid-template-columns: 54px 1fr;
    }

    .bank-list em {
        grid-column: 2;
    }
}
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; }
}
