:root {
    --bg: #07080c;
    --bg-2: #0d1018;
    --panel: #121722;
    --panel-2: #181e2c;
    --line: rgba(255, 255, 255, 0.08);
    --text: #e8edf7;
    --muted: #8b95a8;
    --accent: #3de7c4;
    --accent-2: #5b8cff;
    --danger: #ff5d6c;
    --warn: #f5b942;
    --ok: #3de7c4;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
    --radius: 16px;
    --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    --display: "Segoe UI Semibold", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    font-family: var(--font);
    color: var(--text);
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(91, 140, 255, 0.18), transparent 55%),
        radial-gradient(900px 500px at 90% 0%, rgba(61, 231, 196, 0.12), transparent 50%),
        linear-gradient(160deg, #05060a 0%, #0a0d14 45%, #07090f 100%);
    min-height: 100%;
}

a { color: inherit; text-decoration: none; }

/* ===== Login ===== */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: "";
    position: absolute;
    inset: -20%;
    background:
        linear-gradient(120deg, transparent 40%, rgba(61, 231, 196, 0.05) 50%, transparent 60%),
        repeating-linear-gradient(0deg, transparent, transparent 38px, rgba(255,255,255,0.02) 39px),
        repeating-linear-gradient(90deg, transparent, transparent 38px, rgba(255,255,255,0.02) 39px);
    animation: drift 18s linear infinite;
    pointer-events: none;
}

@keyframes drift {
    from { transform: translate3d(0, 0, 0); }
    to { transform: translate3d(-40px, -40px, 0); }
}

.login-card {
    width: min(420px, 100%);
    background: linear-gradient(180deg, rgba(24, 30, 44, 0.95), rgba(14, 18, 28, 0.98));
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 36px 32px 28px;
    box-shadow: var(--shadow);
    position: relative;
    z-index: 1;
    backdrop-filter: blur(12px);
}

.login-card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(61, 231, 196, 0.45), transparent 35%, transparent 65%, rgba(91, 140, 255, 0.4));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.login-brand {
    text-align: center;
    margin-bottom: 28px;
}

.login-brand .logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 14px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    font-weight: 800;
    letter-spacing: 1px;
    background: linear-gradient(145deg, #1a2438, #0d121c);
    border: 1px solid rgba(61, 231, 196, 0.35);
    color: var(--accent);
    box-shadow: 0 0 30px rgba(61, 231, 196, 0.15);
    animation: pulse 2.8s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 20px rgba(61, 231, 196, 0.12); }
    50% { box-shadow: 0 0 36px rgba(61, 231, 196, 0.28); }
}

.login-brand h1 {
    font-family: var(--display);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 2px;
}

.login-brand p {
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
}

.field { margin-bottom: 16px; }

.field label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.field input, .field select, .field textarea {
    width: 100%;
    background: #0a0e16;
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 12px;
    padding: 12px 14px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    font-size: 14px;
    font-family: inherit;
}

.field input:focus, .field select:focus, .field textarea:focus {
    border-color: rgba(61, 231, 196, 0.55);
    box-shadow: 0 0 0 3px rgba(61, 231, 196, 0.12);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 12px;
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .15s, opacity .15s, box-shadow .2s;
    font-family: inherit;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary {
    width: 100%;
    color: #04120f;
    background: linear-gradient(135deg, #5bffe0, #3de7c4 40%, #2bc4ff);
    box-shadow: 0 10px 30px rgba(61, 231, 196, 0.25);
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line);
}

.btn-danger {
    background: rgba(255, 93, 108, 0.15);
    color: #ff8a95;
    border: 1px solid rgba(255, 93, 108, 0.3);
}

.btn-sm { padding: 8px 12px; font-size: 12px; border-radius: 10px; }

.msg {
    margin-top: 14px;
    min-height: 20px;
    font-size: 13px;
    text-align: center;
    color: var(--danger);
}

/* ===== App shell ===== */
.app-body { min-height: 100vh; }

.app-shell {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, rgba(16, 20, 30, 0.98), rgba(8, 10, 16, 0.98));
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px 22px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 13px;
    color: var(--accent);
    background: linear-gradient(145deg, #182033, #0c111b);
    border: 1px solid rgba(61, 231, 196, 0.3);
}

.brand-text strong {
    display: block;
    font-size: 15px;
    letter-spacing: 1px;
}

.brand-text span {
    font-size: 11px;
    color: var(--muted);
}

.menu-tree { flex: 1; overflow: auto; }

.menu-group { margin-bottom: 18px; }

.menu-label {
    font-size: 11px;
    color: var(--muted);
    padding: 0 12px 8px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: 12px;
    color: #b7c0d1;
    margin-bottom: 4px;
    transition: background .15s, color .15s;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
}

.menu-item.active {
    background: linear-gradient(90deg, rgba(61, 231, 196, 0.16), rgba(91, 140, 255, 0.08));
    color: #fff;
    border: 1px solid rgba(61, 231, 196, 0.2);
}

.mi { width: 18px; text-align: center; opacity: .8; }

.sidebar-foot {
    border-top: 1px solid var(--line);
    padding-top: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(145deg, #243049, #121826);
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-2);
}

.user-chip .name {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-chip .role {
    font-size: 11px;
    color: var(--muted);
}

.logout-btn {
    font-size: 12px;
    color: var(--muted);
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--line);
}

.logout-btn:hover { color: #fff; border-color: rgba(255,255,255,.2); }

.main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 22px 28px 8px;
}

.topbar h1 {
    font-family: var(--display);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.topbar-meta {
    color: var(--muted);
    font-size: 12px;
}

.content {
    padding: 16px 28px 28px;
    flex: 1;
}

/* ===== Cards grid - one page layout ===== */
.grid {
    display: grid;
    gap: 16px;
}

.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-main { grid-template-columns: 1.3fr 1fr; }

.card {
    background: linear-gradient(180deg, rgba(22, 28, 40, 0.95), rgba(14, 18, 28, 0.98));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(61, 231, 196, 0.45), transparent);
}

.card-title {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-value {
    font-size: 30px;
    font-weight: 750;
    letter-spacing: 0.5px;
    background: linear-gradient(90deg, #fff, #9fdfff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.stat-sub {
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
}

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

.panel-head h2 {
    font-size: 16px;
    font-weight: 650;
}

.panel-head .hint {
    font-size: 12px;
    color: var(--muted);
}

.table-wrap {
    overflow: auto;
    border-radius: 12px;
    border: 1px solid var(--line);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th, td {
    padding: 11px 12px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

th {
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }

.tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    border: 1px solid var(--line);
}

.tag-admin { color: #9ec1ff; border-color: rgba(91,140,255,.35); background: rgba(91,140,255,.1); }
.tag-super { color: #7dffd3; border-color: rgba(61,231,196,.35); background: rgba(61,231,196,.1); }
.tag-user  { color: #d0d6e2; border-color: rgba(255,255,255,.12); background: rgba(255,255,255,.04); }
.tag-ok    { color: #7dffd3; border-color: rgba(61,231,196,.35); background: rgba(61,231,196,.1); }
.tag-fail  { color: #ff8a95; border-color: rgba(255,93,108,.35); background: rgba(255,93,108,.1); }
.tag-pending { color: #f5b942; border-color: rgba(245,185,66,.35); background: rgba(245,185,66,.1); }

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

.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 14px;
}

.toolbar .field { margin: 0; flex: 1; min-width: 180px; }

.textarea {
    min-height: 220px;
    resize: vertical;
    line-height: 1.6;
    font-family: ui-monospace, Consolas, monospace;
}

.progress {
    height: 8px;
    background: rgba(255,255,255,.06);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 12px;
}

.progress > span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    transition: width .3s ease;
}

.alert {
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
}

.alert-info {
    background: rgba(91, 140, 255, 0.08);
    border-color: rgba(91, 140, 255, 0.25);
    color: #b8ccff;
}

.alert-warn {
    background: rgba(245, 185, 66, 0.08);
    border-color: rgba(245, 185, 66, 0.3);
    color: #f5d78a;
}

.guide-steps {
    margin: 0;
    padding-left: 0;
    list-style: none;
    counter-reset: step;
}

.guide-steps li {
    position: relative;
    padding: 10px 12px 10px 44px;
    margin-bottom: 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
    font-size: 13px;
    line-height: 1.55;
    color: #c9d2e3;
}

.guide-steps li::before {
    counter-increment: step;
    content: counter(step);
    position: absolute;
    left: 12px;
    top: 12px;
    width: 22px;
    height: 22px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    color: #04120f;
    background: linear-gradient(135deg, #5bffe0, #3de7c4);
}

.guide-steps code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12px;
    color: var(--accent);
    background: rgba(61, 231, 196, 0.08);
    padding: 1px 6px;
    border-radius: 6px;
}

.guide-steps strong { color: #fff; }

.check-col { width: 36px; text-align: center; }
.check-col input { cursor: pointer; accent-color: #3de7c4; }

.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    display: none;
    place-items: center;
    z-index: 50;
    padding: 20px;
}

.modal-mask.show { display: grid; }

.modal {
    width: min(460px, 100%);
    background: #121722;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.modal h3 { margin-bottom: 14px; font-size: 16px; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 36px 12px;
    font-size: 13px;
}

.page-fit {
    display: grid;
    gap: 16px;
    min-height: calc(100vh - 110px);
    align-content: start;
}

@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-main, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: relative;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--line);
    }
    .content, .topbar { padding-left: 16px; padding-right: 16px; }
    .grid-4, .grid-2 { grid-template-columns: 1fr; }
}
