:root {
    --bg: #07090e;
    --panel: rgba(17, 21, 29, 0.92);
    --panel-solid: #11151d;
    --field: #0b0f16;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.14);
    --text: #e6ebf4;
    --muted: #93a0b4;
    --dim: #667083;
    --accent: #7c8cff;
    --accent-deep: #5a6df0;
    --ok: #2ee6a6;
    --warn: #f5b942;
    --danger: #ff6b6b;
    --radius: 16px;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(900px 520px at 12% -8%, rgba(82, 104, 255, 0.18), transparent 60%),
        radial-gradient(820px 540px at 100% 0%, rgba(46, 230, 166, 0.07), transparent 55%),
        linear-gradient(150deg, #090b11 0%, #07090e 55%, #06070b 100%);
    font-family: "Microsoft YaHei UI", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.bg-glow {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(420px 280px at 78% 18%, rgba(124, 140, 255, 0.08), transparent 70%),
        radial-gradient(360px 340px at 18% 82%, rgba(46, 230, 166, 0.045), transparent 70%);
    z-index: 0;
}

h1,
h2,
p {
    margin: 0;
}

button,
input {
    font: inherit;
}

/* ---------------- 登录页 ---------------- */

.login-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 20px;
}

.login-card {
    width: min(392px, 100%);
    padding: 28px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: linear-gradient(to bottom, rgba(23, 29, 41, 0.98), rgba(14, 18, 26, 0.98));
    box-shadow: var(--shadow), 0 0 0 1px rgba(124, 140, 255, 0.04) inset;
    animation: rise 0.45s ease both;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 13px;
    background: linear-gradient(135deg, #8aa0ff 0%, #5a6df0 100%);
    color: #fff;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.02em;
    box-shadow: 0 8px 24px rgba(92, 112, 255, 0.42);
}

.brand h1 {
    font-size: 18px;
    line-height: 1.2;
    letter-spacing: 0.01em;
}

.brand p {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11.5px;
}

.brand.small .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 15px;
}

.brand.small h1 {
    font-size: 15px;
}

.brand.small p {
    font-size: 10.5px;
}

.login-card .brand {
    margin-bottom: 24px;
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

label {
    color: #93a0b4;
    font-size: 11.5px;
    padding-left: 1px;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    outline: none;
    background: var(--field);
    color: var(--text);
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input::placeholder {
    color: #5c6678;
}

input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124, 140, 255, 0.14);
}

.login-card input {
    margin-bottom: 6px;
}

.form-error {
    margin: 2px 0 4px;
    color: #ff9b92;
    font-size: 12px;
    word-break: break-word;
}

.login-foot {
    margin-top: 18px;
    padding-top: 15px;
    border-top: 1px solid var(--line);
    color: var(--dim);
    font-size: 10.5px;
    text-align: center;
}

/* ---------------- 按钮 ---------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 9px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.12s ease, background 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
    user-select: none;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, #8296ff 0%, #5b6df0 100%);
    color: #fff;
    box-shadow: 0 8px 22px rgba(91, 109, 240, 0.34);
}

.btn-primary:hover {
    filter: brightness(1.06);
}

.btn-ghost {
    border-color: var(--line);
    background: rgba(255, 255, 255, 0.025);
    color: var(--muted);
}

.btn-ghost:hover {
    border-color: var(--line-strong);
    background: rgba(255, 255, 255, 0.055);
    color: var(--text);
}

.btn-soft {
    border-color: rgba(124, 140, 255, 0.26);
    background: rgba(124, 140, 255, 0.12);
    color: #b7c1ff;
}

.btn-soft:hover {
    background: rgba(124, 140, 255, 0.2);
}

.btn-danger {
    border-color: rgba(255, 107, 107, 0.25);
    background: rgba(255, 107, 107, 0.09);
    color: #ff9b92;
}

.btn-danger:hover {
    background: rgba(255, 107, 107, 0.16);
}

.btn-sm {
    padding: 5px 9px;
    border-radius: 7px;
    font-size: 11.5px;
    font-weight: 500;
}

.login-card .btn-primary {
    margin-top: 8px;
    padding: 10px 14px;
    font-size: 13px;
}

/* ---------------- 主界面 ---------------- */

.console {
    position: relative;
    z-index: 1;
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 22px 24px 40px;
    animation: rise 0.45s ease both;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 18px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: linear-gradient(to bottom, rgba(20, 25, 35, 0.94), rgba(13, 17, 24, 0.94));
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.32);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.server-state {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 11px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    font-size: 11.5px;
}

.server-state .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 10px rgba(46, 230, 166, 0.8);
}

.server-state.offline {
    color: #ff9b92;
    border-color: rgba(255, 107, 107, 0.22);
}

.server-state.offline .dot {
    background: var(--danger);
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.7);
}

.admin-chip {
    padding: 5px 11px;
    border-radius: 999px;
    border: 1px solid rgba(124, 140, 255, 0.24);
    background: rgba(124, 140, 255, 0.1);
    color: #b7c1ff;
    font-size: 11.5px;
    font-weight: 600;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.stat {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 16px 18px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: linear-gradient(to bottom right, rgba(20, 25, 35, 0.86), rgba(13, 17, 24, 0.86));
}

.stat-label {
    color: var(--muted);
    font-size: 11.5px;
}

.stat strong {
    font-size: 25px;
    line-height: 1;
    letter-spacing: -0.02em;
}

.stat strong.ok,
.ok {
    color: var(--ok);
}

.panel {
    margin-top: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: 0 18px 54px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(8px);
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 17px 20px 14px;
    border-bottom: 1px solid var(--line);
}

.panel-head h2 {
    font-size: 14.5px;
    font-weight: 600;
}

.panel-head p {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11.5px;
}

.create-form {
    display: grid;
    grid-template-columns: minmax(180px, 1.2fr) minmax(220px, 1.4fr) auto;
    gap: 13px;
    align-items: end;
    padding: 17px 20px 20px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-row {
    display: flex;
    gap: 7px;
    align-items: center;
}

.input-row input {
    flex: 1;
    min-width: 0;
}

.create-submit {
    height: 38px;
    margin-bottom: 1px;
}

textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    outline: none;
    background: var(--field);
    color: var(--text);
    font: inherit;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

textarea::placeholder {
    color: #5c6678;
}

textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124, 140, 255, 0.14);
}

.update-current {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 18px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
}

.update-current > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 12px;
}

.update-current b {
    font-size: 13px;
}

.update-current-actions {
    margin-left: auto;
}

.update-notes {
    margin: 14px 20px 0;
    padding: 12px 14px;
    border-radius: 11px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.22);
    color: #c7d0de;
    font-size: 12.5px;
    white-space: pre-wrap;
    word-break: break-word;
}

.update-form {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(260px, 2fr);
    gap: 12px 14px;
    align-items: end;
    padding: 16px 20px 20px;
}

.update-notes-field {
    grid-column: 2;
    grid-row: 1 / span 2;
}

.update-bundle-form {
    display: grid;
    gap: 12px;
    padding: 16px 20px 20px;
    border-top: 1px dashed var(--line);
}

.update-history {
    padding: 4px 20px 18px;
    border-top: 1px dashed var(--line);
}

.update-history-title {
    margin: 12px 0 8px;
    color: var(--muted);
    font-size: 12px;
}

.update-history ul {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.update-history li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: rgba(0, 0, 0, 0.18);
    color: var(--muted);
    font-size: 12px;
}

.update-history li b {
    color: var(--text);
    font-weight: 600;
}

.update-force {
    grid-column: 1 / -1;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 12.5px;
    cursor: pointer;
}

.check input {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
}

.update-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.update-actions progress {
    width: 160px;
    height: 8px;
    accent-color: var(--accent);
}

.update-status {
    flex: 1;
    min-width: 0;
    color: var(--muted);
    font-size: 12px;
    word-break: break-word;
}

.update-status.error {
    color: #ff9b92;
}

.create-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 20px 20px;
    padding: 12px 14px;
    border-radius: 11px;
    border: 1px solid rgba(46, 230, 166, 0.22);
    background: rgba(46, 230, 166, 0.07);
}

.create-result-text {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex-wrap: wrap;
    color: #a8f3d6;
    font-size: 12.5px;
}

.create-result-text b {
    color: var(--text);
}

code {
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--line);
    color: #dfe5ef;
    font-family: Consolas, "Cascadia Mono", monospace;
    font-size: 12px;
    word-break: break-all;
}

.table-wrap {
    overflow-x: auto;
    padding: 4px 8px 8px;
}

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

th,
td {
    padding: 11px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.055);
    vertical-align: middle;
}

th {
    color: var(--dim);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

td {
    font-size: 12.5px;
}

tbody tr {
    transition: background 0.14s ease;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.025);
}

tbody tr:last-child td {
    border-bottom: none;
}

.user-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-name {
    color: #f1f5fb;
    font-weight: 600;
}

.user-meta {
    color: var(--dim);
    font-size: 10.5px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    white-space: nowrap;
}

.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge-on {
    color: var(--ok);
    background: rgba(46, 230, 166, 0.09);
    border: 1px solid rgba(46, 230, 166, 0.2);
}

.badge-off {
    color: #ff8f86;
    background: rgba(255, 107, 107, 0.08);
    border: 1px solid rgba(255, 107, 107, 0.18);
}

.badge-wait {
    color: var(--warn);
    background: rgba(245, 185, 66, 0.08);
    border: 1px solid rgba(245, 185, 66, 0.2);
}

.room-code {
    display: inline-block;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.device-title {
    color: var(--text);
}

.device-since {
    display: block;
    margin-top: 2px;
    color: var(--dim);
    font-size: 10.5px;
}

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

.actions-col {
    width: 280px;
}

.row-actions {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.empty {
    padding: 30px 18px;
    color: var(--dim);
    font-size: 12.5px;
    text-align: center;
}

.page-foot {
    margin-top: 18px;
    color: #4f5868;
    font-size: 10.5px;
    text-align: center;
}

/* ---------------- 对话框 / 提示 ---------------- */

.dialog {
    width: min(420px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    background: linear-gradient(to bottom, #171d29, #0e121a);
    color: var(--text);
    box-shadow: var(--shadow);
}

.dialog::backdrop {
    background: rgba(3, 5, 9, 0.72);
    backdrop-filter: blur(4px);
}

.dialog form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 22px;
}

.dialog h2 {
    font-size: 16px;
}

.dialog-hint {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.55;
}

.dialog-hint b {
    color: var(--text);
}

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

.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 30;
    transform: translate(-50%, 10px);
    max-width: min(520px, calc(100vw - 32px));
    padding: 11px 16px;
    border-radius: 11px;
    border: 1px solid rgba(46, 230, 166, 0.24);
    background: rgba(17, 24, 31, 0.97);
    color: #b6f7dd;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
    font-size: 12.5px;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.toast.error {
    border-color: rgba(255, 107, 107, 0.28);
    color: #ffb3ad;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 900px) {
    .console {
        padding: 16px 14px 32px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-right {
        justify-content: flex-start;
        width: 100%;
    }

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

    .create-form {
        grid-template-columns: 1fr;
    }

    .create-submit {
        width: 100%;
    }

    .update-form {
        grid-template-columns: 1fr;
    }

    .update-notes-field {
        grid-column: 1;
        grid-row: auto;
    }

    .update-actions {
        flex-wrap: wrap;
    }
}

@media (max-width: 520px) {
    .login-card {
        padding: 23px;
    }

    .stats {
        gap: 9px;
    }

    .stat {
        padding: 13px 14px;
    }

    .stat strong {
        font-size: 21px;
    }

    .create-result {
        align-items: flex-start;
        flex-direction: column;
    }
}
