:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --line: #dfe6f0;
    --text: #111827;
    --muted: #5f6f86;
    --blue: #2563eb;
    --blue-soft: #eff6ff;
    --green: #10b981;
    --green-soft: #ecfdf5;
    --red: #dc2626;
    --red-soft: #fef2f2;
    --shadow: 0 8px 20px rgba(15, 23, 42, .06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    font-size: 14px;
}

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

button,
input,
select {
    font: inherit;
}

code {
    color: #0f3f8c;
    background: var(--blue-soft);
    border: 1px solid #cfe1ff;
    border-radius: 6px;
    padding: 2px 5px;
}

.auth-page {
    min-height: 100vh;
    background:
        linear-gradient(140deg, rgba(37, 99, 235, .10), transparent 34%),
        linear-gradient(320deg, rgba(16, 185, 129, .12), transparent 28%),
        var(--bg);
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 28px;
}

.brand-mark {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    border-radius: 8px;
    color: #fff;
    background: linear-gradient(135deg, var(--blue), var(--green));
    font-weight: 800;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: 26px;
}

h2 {
    font-size: 17px;
}

p {
    margin: 0;
}

.muted,
.page-head p,
.section-head p,
.auth-link {
    color: var(--muted);
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 22px;
    background: #ffffff;
    border-right: 1px solid var(--line);
    padding: 20px;
}

.side-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
}

.sidebar nav {
    display: grid;
    gap: 8px;
}

.sidebar nav a {
    padding: 10px 12px;
    border-radius: 8px;
    color: #374151;
}

.sidebar nav a.active,
.sidebar nav a:hover {
    color: var(--blue);
    background: var(--blue-soft);
}

.side-footer {
    margin-top: auto;
    display: grid;
    gap: 12px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.side-footer strong,
td strong {
    display: block;
}

.main-content {
    min-width: 0;
    padding: 26px;
}

.page-head,
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.page-head {
    margin-bottom: 22px;
}

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

.stat-card,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.stat-card {
    min-height: 132px;
    padding: 20px;
}

.stat-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: #0f172a;
    font-weight: 600;
}

.stat-icon {
    width: 26px;
    height: 26px;
    display: inline-grid;
    place-items: center;
    border-radius: 8px;
    font-weight: 800;
}

.stat-card.up .stat-icon {
    color: var(--green);
    background: var(--green-soft);
}

.stat-card.down .stat-icon {
    color: var(--blue);
    background: var(--blue-soft);
}

.stat-value {
    margin-top: 12px;
    font-size: 27px;
    font-weight: 800;
    line-height: 1.15;
}

.stat-sub {
    margin-top: 4px;
    color: #3d5575;
}

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

.flash-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.flash {
    border-radius: 8px;
    padding: 10px 12px;
    border: 1px solid;
}

.flash.success {
    color: #047857;
    background: var(--green-soft);
    border-color: #bbf7d0;
}

.flash.error {
    color: #b91c1c;
    background: var(--red-soft);
    border-color: #fecaca;
}

.stack-form,
.inline-form,
.row-form {
    display: grid;
    gap: 12px;
}

.inline-form {
    grid-template-columns: repeat(3, minmax(150px, 1fr)) auto;
    align-items: end;
}

.row-form {
    grid-template-columns: minmax(120px, 1fr) auto;
    gap: 8px;
}

label {
    display: grid;
    gap: 6px;
    color: #314158;
    font-weight: 600;
}

input,
select {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    padding: 8px 10px;
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.primary-btn,
.soft-btn,
.danger-btn {
    min-height: 36px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    white-space: nowrap;
}

.primary-btn {
    color: #fff;
    background: var(--blue);
}

.soft-btn {
    color: #1d4ed8;
    background: var(--blue-soft);
    border-color: #cfe1ff;
}

.danger-btn {
    color: var(--red);
    background: var(--red-soft);
    border-color: #fecaca;
}

.auth-link {
    margin-top: 16px;
}

.auth-link a {
    color: var(--blue);
    font-weight: 700;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

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

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: #54657d;
    font-size: 12px;
    font-weight: 700;
    background: #f8fafc;
}

td small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
}

.status,
.badge,
.live-dot {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 2px 9px;
    font-size: 12px;
    font-weight: 700;
}

.status.online,
.live-dot {
    color: #047857;
    background: var(--green-soft);
}

.status.offline {
    color: #64748b;
    background: #f1f5f9;
}

.badge {
    color: #1d4ed8;
    background: var(--blue-soft);
}

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

.actions form {
    display: inline;
}

.cpu-cell {
    max-width: 210px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.usage-bar {
    position: relative;
    width: 168px;
    height: 21px;
    overflow: hidden;
    border-radius: 4px;
    background: #e8ecf3;
}

.usage-bar span {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    background: #55c94d;
}

.usage-bar b {
    position: relative;
    z-index: 1;
    display: block;
    color: #263244;
    font-weight: 500;
    line-height: 21px;
    text-align: center;
}

.empty-state {
    display: grid;
    place-items: center;
    min-height: 120px;
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: #fbfdff;
}

.error-box {
    white-space: pre-wrap;
    color: #b91c1c;
    background: var(--red-soft);
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 12px;
}

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

@media (max-width: 780px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

    .main-content {
        padding: 18px;
    }

    .stat-grid,
    .inline-form {
        grid-template-columns: 1fr;
    }

    .page-head,
    .section-head {
        align-items: flex-start;
        flex-direction: column;
    }
}
