:root {
    --bg: #07111f;
    --panel: rgba(15, 28, 49, .82);
    --panel-strong: rgba(21, 39, 66, .95);
    --border: rgba(127, 211, 255, .20);
    --border-hot: rgba(61, 226, 198, .42);
    --text: #eef7ff;
    --muted: #9fb5ca;
    --cyan: #42d9ff;
    --mint: #32e6b0;
    --blue: #2f6bff;
    --amber: #f4c362;
    --red: #ff5d6c;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html,
body {
    height: 100%;
    margin: 0;
}

body.pp-admin {
    height: 100vh;
    overflow: hidden;
    background:
        radial-gradient(circle at 18% 12%, rgba(47, 107, 255, .24), transparent 32%),
        radial-gradient(circle at 86% 18%, rgba(50, 230, 176, .16), transparent 28%),
        linear-gradient(135deg, #07111f 0%, #0b1629 48%, #061018 100%);
    color: var(--text);
    font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
    letter-spacing: 0;
}

body.pp-admin::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(66, 217, 255, .055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(66, 217, 255, .055) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .82), transparent);
}

#adminParticleCanvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    opacity: .78;
}

.admin-login,
.admin-shell {
    position: relative;
    z-index: 1;
}

.admin-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.admin-login-panel,
.admin-panel,
.stat-box {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 28px 80px rgba(0, 0, 0, .34);
    backdrop-filter: blur(20px);
}

.admin-login-panel {
    width: min(460px, 100%);
    padding: 30px;
}

.mini-kicker {
    display: block;
    margin-bottom: 8px;
    color: var(--cyan);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
}

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

h1 {
    margin-bottom: 12px;
    font-size: 34px;
    line-height: 1.1;
}

h2 {
    margin-bottom: 0;
    font-size: 22px;
}

p {
    color: var(--muted);
    line-height: 1.75;
}

label {
    display: block;
    margin: 18px 0 8px;
    color: #d7ecff;
    font-weight: 700;
}

input {
    width: 100%;
    min-height: 46px;
    border: 1px solid rgba(127, 211, 255, .18);
    border-radius: 8px;
    background: rgba(4, 13, 27, .76);
    color: var(--text);
    padding: 0 14px;
    outline: none;
}

input:focus {
    border-color: var(--border-hot);
    box-shadow: 0 0 0 3px rgba(50, 230, 176, .14);
}

button,
.ghost-action,
.danger-action {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 8px;
    border: 1px solid rgba(127, 211, 255, .18);
    background: rgba(255, 255, 255, .055);
    color: var(--text);
    padding: 0 14px;
    font: inherit;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

button:disabled {
    cursor: wait;
    opacity: .68;
}

svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.1;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.admin-button-icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--cyan);
}

button[type="submit"] {
    width: 100%;
    margin-top: 18px;
    border: 0;
    background: linear-gradient(135deg, var(--blue), var(--cyan));
    color: #fff;
}

.ghost-action:hover {
    border-color: var(--border-hot);
    background: rgba(66, 217, 255, .12);
}

.danger-action,
.row-danger {
    border-color: rgba(255, 93, 108, .30);
    color: #ffe6e9;
    background: rgba(255, 93, 108, .12);
}

.row-danger {
    min-height: 34px;
    padding: 0 10px;
}

.login-error {
    min-height: 22px;
    margin-top: 12px;
    color: #ffcbd2;
}

.admin-shell {
    width: min(1560px, calc(100% - 36px));
    height: calc(100vh - 36px);
    margin: 0 auto;
    padding: 22px 0 14px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.admin-header,
.panel-title,
.admin-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.admin-header {
    flex: 0 0 auto;
    margin-bottom: 16px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(15, 28, 49, .64);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .24);
}

.admin-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding-right: 4px;
}

.header-actions,
.panel-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

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

.overview-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.health-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.health-card {
    min-height: 130px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(47, 107, 255, .14), rgba(50, 230, 176, .07)),
        rgba(15, 28, 49, .72);
    box-shadow: 0 18px 48px rgba(0, 0, 0, .20);
    backdrop-filter: blur(18px);
    padding: 16px;
}

.health-card h2 {
    margin-bottom: 10px;
    font-size: 24px;
}

.health-card p {
    margin: 0;
    min-height: 38px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.48;
}

.health-good {
    color: var(--mint);
}

.health-warn {
    color: var(--amber);
}

.health-bad {
    color: var(--red);
}

.overview-card {
    min-height: 238px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background:
        radial-gradient(circle at 92% 8%, rgba(66, 217, 255, .12), transparent 34%),
        rgba(15, 28, 49, .72);
    box-shadow: 0 22px 62px rgba(0, 0, 0, .24);
    backdrop-filter: blur(20px);
    padding: 16px;
}

.compact-title {
    margin-bottom: 12px;
}

.overview-list {
    display: grid;
    gap: 9px;
    max-height: 172px;
    overflow: auto;
    padding-right: 4px;
}

.overview-item {
    display: grid;
    gap: 6px;
    padding: 10px;
    border: 1px solid rgba(127, 211, 255, .12);
    border-radius: 8px;
    background: rgba(255, 255, 255, .035);
}

.overview-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.overview-main {
    min-width: 0;
    color: #eaf6ff;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.overview-sub {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.mini-pill {
    flex: 0 0 auto;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    border-radius: 8px;
    padding: 0 8px;
    color: #d9fff4;
    background: rgba(50, 230, 176, .14);
    font-size: 12px;
    font-weight: 800;
}

.mini-pill.warn {
    color: #fff0d0;
    background: rgba(244, 195, 98, .16);
}

.mini-pill.danger {
    color: #ffd7dd;
    background: rgba(255, 93, 108, .18);
}

.stat-box {
    position: relative;
    min-height: 106px;
    padding: 18px;
    overflow: hidden;
}

.stat-box::after {
    content: "";
    position: absolute;
    right: -30px;
    top: -42px;
    width: 118px;
    height: 118px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(66, 217, 255, .18), transparent 65%);
}

.stat-icon {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    border-radius: 8px;
    color: var(--mint);
    background: rgba(50, 230, 176, .10);
    border: 1px solid rgba(50, 230, 176, .18);
}

.stat-box span {
    display: block;
    color: var(--muted);
}

.stat-box strong {
    display: block;
    margin-top: 10px;
    font-size: 34px;
}

.admin-panel {
    margin-bottom: 18px;
    padding: 18px;
}

.admin-panel:last-child {
    margin-bottom: 0;
}

.table-wrap {
    width: 100%;
    max-height: 360px;
    overflow: auto;
    margin-top: 16px;
    border: 1px solid rgba(127, 211, 255, .12);
    border-radius: 8px;
}

table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
}

th,
td {
    padding: 13px 12px;
    border-bottom: 1px solid rgba(127, 211, 255, .10);
    text-align: left;
    vertical-align: middle;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: var(--muted);
    background: rgba(21, 39, 66, .98);
    font-weight: 800;
}

td {
    color: #d9eaff;
}

tr:last-child td {
    border-bottom: 0;
}

.state-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 8px;
    padding: 0 10px;
    font-weight: 800;
    font-size: 13px;
}

.state-waiting {
    color: #d9fff4;
    background: rgba(50, 230, 176, .14);
}

.state-connecting {
    color: #e9f0ff;
    background: rgba(47, 107, 255, .26);
}

.state-connected {
    color: #e2fbff;
    background: rgba(66, 217, 255, .18);
}

.state-offline {
    color: #cbd7e4;
    background: rgba(159, 181, 202, .12);
}

.event-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
    max-height: 420px;
    overflow: auto;
    padding-right: 4px;
}

.event-row {
    display: grid;
    grid-template-columns: 170px 210px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
    border: 1px solid rgba(127, 211, 255, .12);
    border-radius: 8px;
    background: rgba(255, 255, 255, .035);
}

.event-row span {
    color: var(--muted);
}

.event-row strong {
    color: var(--cyan);
}

.muted {
    color: var(--muted);
}

.admin-footer {
    flex: 0 0 auto;
    padding: 12px 2px 0;
    color: rgba(238, 247, 255, .62);
    font-size: 13px;
}

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

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

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

    .admin-header,
    .panel-title,
    .admin-footer {
        align-items: flex-start;
        flex-direction: column;
    }

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

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

@media (max-width: 560px) {
    .admin-shell {
        width: min(100% - 24px, 1560px);
        padding-top: 18px;
    }

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

    .overview-card {
        min-height: auto;
    }

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

    h1 {
        font-size: 28px;
    }
}
