:root {
    color-scheme: dark;
    --bg: #07111f;
    --panel: #0d1b31;
    --panel-2: #111f39;
    --line: #223a63;
    --text: #e5ecff;
    --muted: #8fa0bd;
    --blue: #4b8cff;
    --purple: #8b5cf6;
    --green: #27d17f;
    --red: #ff6b7a;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: radial-gradient(circle at 80% 10%, rgba(100, 80, 255, .26), transparent 34%), var(--bg);
}
a { color: inherit; text-decoration: none; }
input, button, select { font: inherit; }

.auth-page {
    display: grid;
    place-items: center;
    padding: 32px;
}
.install-card {
    width: min(480px, 100%);
    padding: 32px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(13, 27, 49, .94);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .38);
}
.logo {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    margin-bottom: 18px;
    background: linear-gradient(135deg, var(--blue), var(--purple));
    font-weight: 900;
    letter-spacing: .08em;
}
h1, h2, p { margin: 0; }
h1 { font-size: 30px; margin-bottom: 10px; }
h2 { font-size: 18px; margin-bottom: 10px; }
p { color: var(--muted); line-height: 1.65; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 220px;
    padding: 28px 18px;
    background: rgba(5, 11, 22, .94);
    border-right: 1px solid rgba(91, 123, 178, .26);
}
.brand {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 28px;
}
.brand strong { font-size: 20px; }
.brand span { color: var(--muted); font-size: 13px; }
nav { display: grid; gap: 8px; }
nav a {
    padding: 12px 14px;
    border-radius: 10px;
    color: var(--muted);
    font-weight: 700;
}
nav a.active, nav a:hover {
    color: white;
    background: linear-gradient(135deg, rgba(75, 140, 255, .28), rgba(139, 92, 246, .18));
}

.main {
    margin-left: 220px;
    padding: 34px;
}
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
}
.topbar p {
    color: #aab5ff;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .22em;
}
.topbar h1 { margin-top: 6px; }
.topbar span { color: var(--muted); }

.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}
.stat, .card {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(13, 27, 49, .88);
    box-shadow: 0 14px 50px rgba(0, 0, 0, .18);
}
.stat { padding: 22px; }
.stat span {
    display: block;
    margin-bottom: 8px;
    font-size: 34px;
    font-weight: 900;
}
.card { padding: 22px; }
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.form-stack, .form-grid { display: grid; gap: 12px; margin-top: 16px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wide { grid-column: 1 / -1; }
label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-weight: 700;
    font-size: 13px;
}
input, select {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid #2a426c;
    border-radius: 9px;
    color: var(--text);
    background: #081428;
    outline: none;
}
input:focus, select:focus { border-color: var(--blue); }
select { cursor: pointer; }

.primary, .button, .mini {
    border: 0;
    border-radius: 9px;
    color: white;
    cursor: pointer;
    font-weight: 800;
}
.primary {
    min-height: 42px;
    padding: 0 18px;
    background: linear-gradient(135deg, var(--blue), var(--purple));
}
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 14px;
    background: #13284b;
    border: 1px solid #2d4b78;
}
.button.block { width: 100%; margin-top: 12px; }
.mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0 10px;
    background: #172b4f;
    white-space: nowrap;
}
.link-mini { border: 0; }
.danger { background: rgba(255, 107, 122, .18); color: #ff9aa5; border-color: rgba(255, 107, 122, .42); }

.notice {
    padding: 12px 14px;
    margin: 0 0 16px;
    border: 1px solid rgba(75, 140, 255, .42);
    border-radius: 10px;
    background: rgba(75, 140, 255, .14);
    color: #cfe0ff;
}
.notice.success { border-color: rgba(39, 209, 127, .4); background: rgba(39, 209, 127, .12); color: #b7ffd6; }
.notice.error { border-color: rgba(255, 107, 122, .45); background: rgba(255, 107, 122, .12); color: #ffb5bd; }

.search { display: flex; gap: 10px; margin-top: 16px; }
.table-wrap { overflow: auto; }
table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
}
th, td {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(89, 119, 168, .18);
    text-align: left;
    vertical-align: top;
}
th { color: #b6c5e3; font-size: 12px; }
td { color: #d9e5ff; font-size: 13px; }
small { color: var(--muted); }
code {
    display: inline-block;
    padding: 5px 7px;
    border-radius: 7px;
    color: #bcd3ff;
    background: #071428;
}
.pill {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}
.pill.active { color: #b7ffd6; background: rgba(39, 209, 127, .12); }
.pill.disabled { color: #ffb5bd; background: rgba(255, 107, 122, .12); }
.pill.expired { color: #ffd08a; background: rgba(255, 179, 71, .12); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions form { margin: 0; }
.inline-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr)) auto;
    gap: 6px;
}
.inline-form select { height: 34px; }
.agent-form {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
}
.agent-form button { grid-column: 1 / -1; }

@media (max-width: 900px) {
    .sidebar { position: static; width: auto; }
    .main { margin-left: 0; padding: 20px; }
    .grid.two, .stats { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
}
