:root {
    --bg: #f1f5f9;
    --side: #0f172a;
    --side-2: #1e293b;
    --primary: #2563eb;
    --primary-2: #1d4ed8;
    --danger: #dc2626;
    --text: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --card: #fff;
    --radius: 12px;
    --shadow: 0 8px 24px rgba(15, 23, 42, .06);
    --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 220px;
    background: linear-gradient(180deg, var(--side), #111827);
    color: #e2e8f0; display: flex; flex-direction: column; z-index: 20;
}
.brand {
    padding: 22px 20px 16px; font-weight: 700; font-size: 18px; letter-spacing: .02em;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar nav { padding: 12px 10px; flex: 1; }
.sidebar nav a {
    display: block; color: #cbd5e1; padding: 10px 12px; border-radius: 8px; margin-bottom: 4px;
}
.sidebar nav a:hover { background: var(--side-2); color: #fff; }
.sidebar nav a.on { background: var(--primary); color: #fff; }
.side-foot { padding: 14px 18px 18px; border-top: 1px solid rgba(255,255,255,.06); font-size: 13px; }
.side-foot .who { color: #94a3b8; margin-bottom: 6px; }
.side-foot a { color: #93c5fd; }
.main { margin-left: 220px; min-height: 100vh; }
.topbar {
    height: 58px; background: #fff; display: flex; align-items: center; gap: 12px;
    padding: 0 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.topbar h2 { font-size: 16px; margin: 0; font-weight: 650; }
.menu-btn { display: none; border: 0; background: #f1f5f9; width: 36px; height: 36px; border-radius: 8px; cursor: pointer; }
.content { padding: 22px; }
.card {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px 20px; margin-bottom: 16px;
}
.card h3 { margin: 0 0 14px; font-size: 16px; }
.table-card { padding: 0; overflow: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { background: #f8fafc; color: #475569; font-weight: 600; white-space: nowrap; }
.table tr:hover td { background: #f8fafc; }
.table .ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar {
    display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; align-items: center;
}
.toolbar .left, .toolbar .right { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search, select, input, textarea {
    font: inherit; border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 10px; background: #fff; color: var(--text);
}
.search { min-width: 220px; }
textarea { width: 100%; resize: vertical; }
label { display: block; font-size: 13px; color: #334155; margin: 10px 0 6px; font-weight: 600; }
.btn {
    border: 1px solid #cbd5e1; background: #fff; color: #334155; border-radius: 8px;
    padding: 8px 14px; cursor: pointer; font: inherit; font-size: 13px;
}
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.sm { padding: 4px 8px; font-size: 12px; }
.btn.block { width: 100%; display: block; }
.btn.link { border: 0; background: none; color: var(--primary); padding: 0; }
.pager {
    display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 12px 14px; font-size: 13px; color: var(--muted);
}
.pager .pages { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pager button.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.off { background: #fee2e2; color: #991b1b; }
.badge.idle { background: #e0e7ff; color: #3730a3; }
.grid-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat .num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat .lab { color: var(--muted); margin-top: 4px; font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.help-list { margin: 0; padding-left: 18px; line-height: 1.9; color: #334155; }
.muted { color: var(--muted); font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal {
    display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45);
    z-index: 50; align-items: center; justify-content: center; padding: 16px;
}
.modal.show { display: flex; }
.dialog {
    background: #fff; width: 480px; max-width: 100%; border-radius: 14px; padding: 20px 22px;
    max-height: 90vh; overflow: auto;
}
.dialog.wide { width: 680px; }
.dialog h3 { margin: 0 0 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.fmt { background: #f8fafc; padding: 10px 12px; border-radius: 8px; font-size: 12px; overflow: auto; }
.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.alert.err { background: #fef2f2; color: #991b1b; }
.alert.ok { background: #ecfdf5; color: #065f46; }
.toast {
    position: fixed; top: 18px; right: 18px; background: #0f172a; color: #fff;
    padding: 10px 14px; border-radius: 8px; z-index: 80; display: none; font-size: 13px;
}
.toast.show { display: block; }
.auth-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(160deg, #0f172a, #1e3a8a);
}
.auth-card {
    width: 400px; max-width: calc(100% - 24px); background: #fff; border-radius: 16px; padding: 28px 26px;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-card form input { width: 100%; }
.auth-card .btn { margin-top: 16px; padding: 10px 14px; }
@media (max-width: 960px) {
    .grid-stats, .grid-2 { grid-template-columns: 1fr 1fr; }
    .sidebar { transform: translateX(-100%); transition: .2s; }
    .sidebar.open { transform: none; }
    .main { margin-left: 0; }
    .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
}
@media (max-width: 640px) {
    .grid-stats, .grid-2, .row2 { grid-template-columns: 1fr; }
    .search { min-width: 0; width: 100%; }
}
