:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e6ebf2;
  --line-strong: #d6deea;
  --text: #172033;
  --muted: #748197;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eaf1ff;
  --success: #16a34a;
  --success-soft: #e9f8ef;
  --warning: #b45309;
  --warning-soft: #fff7e8;
  --danger: #dc2626;
  --danger-soft: #fff0f0;
  --shadow: 0 18px 50px rgba(22, 34, 56, .08);
  --radius: 16px;
  --sidebar: 232px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; color: var(--text); background: var(--bg); font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif; }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { display: inline-block; color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .16em; }
code { padding: 2px 6px; border-radius: 7px; background: #eef2f7; font-family: "Cascadia Code", Consolas, monospace; font-size: .9em; }

.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(390px, .82fr); background: #fff; }
.login-visual { position: relative; overflow: hidden; padding: 64px; display: flex; flex-direction: column; justify-content: space-between; background: radial-gradient(circle at 80% 20%, rgba(96, 165, 250, .28), transparent 32%), linear-gradient(145deg, #07152e 0%, #0e2b58 45%, #1e4c92 100%); color: #fff; }
.visual-grid { position: absolute; inset: 0; opacity: .18; background-image: linear-gradient(rgba(255,255,255,.16) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.16) 1px, transparent 1px); background-size: 42px 42px; mask-image: linear-gradient(to bottom, #000, transparent 85%); pointer-events: none; }
.brand-mark { position: relative; z-index: 1; display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; background: linear-gradient(145deg, #60a5fa, #2563eb); color: #fff; font-size: 25px; font-weight: 900; box-shadow: 0 12px 30px rgba(37, 99, 235, .35); }
.brand-mark.small { width: 36px; height: 36px; border-radius: 11px; font-size: 18px; }
.login-copy { position: relative; z-index: 1; max-width: 690px; padding-bottom: 42px; }
.login-copy .eyebrow { color: #93c5fd; }
.login-copy h1 { margin: 18px 0 20px; font-size: clamp(38px, 4.2vw, 68px); line-height: 1.08; letter-spacing: -.045em; }
.login-copy p { max-width: 590px; margin: 0; color: #c9d8f2; font-size: 17px; line-height: 1.8; }
.feature-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.feature-row span { padding: 8px 12px; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; color: #dbeafe; background: rgba(255,255,255,.08); font-size: 12px; }
.login-panel { display: grid; place-items: center; padding: 44px; background: linear-gradient(180deg, #fff, #f8fbff); }
.login-card { width: min(430px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 22px; background: rgba(255,255,255,.94); box-shadow: var(--shadow); }
.login-card h2 { margin: 10px 0 8px; font-size: 29px; letter-spacing: -.03em; }
.login-card > .muted { margin: 0 0 26px; line-height: 1.6; }
.mobile-brand { display: none; align-items: center; gap: 10px; margin-bottom: 26px; }
.field { display: grid; gap: 8px; margin-bottom: 16px; }
.field > span { color: #43516a; font-size: 13px; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 11px; background: #fff; color: var(--text); padding: 12px 13px; outline: none; transition: border-color .15s, box-shadow .15s; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #7aa7f8; box-shadow: 0 0 0 4px rgba(37,99,235,.1); }
.field textarea { min-height: 120px; resize: vertical; }
.field-hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 39px; padding: 9px 15px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; color: #334158; font-size: 13px; font-weight: 700; transition: .15s ease; }
.btn:hover { border-color: #aebbd0; background: #f8fafc; transform: translateY(-1px); }
.btn.primary { border-color: var(--primary); background: var(--primary); color: #fff; box-shadow: 0 7px 18px rgba(37,99,235,.2); }
.btn.primary:hover { border-color: var(--primary-dark); background: var(--primary-dark); }
.btn.danger { border-color: #fecaca; color: var(--danger); background: #fff; }
.btn.soft { border-color: transparent; color: var(--primary); background: var(--primary-soft); }
.btn.block { width: 100%; min-height: 46px; margin-top: 8px; }
.btn.small { min-height: 32px; padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
.form-error { margin: 12px 0 0; color: var(--danger); font-size: 13px; }
.login-footnote { margin: 22px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px; border-right: 1px solid var(--line); background: #fff; z-index: 20; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 25px; }
.sidebar-brand div { display: grid; gap: 2px; }
.sidebar-brand strong { font-size: 16px; letter-spacing: -.02em; }
.sidebar-brand small { color: var(--muted); font-size: 11px; }
.nav-group { display: grid; gap: 4px; }
.nav-label { margin: 19px 11px 7px; color: #9aa6b8; font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border: 0; border-radius: 10px; color: #5f6d82; background: transparent; text-align: left; font-size: 13px; font-weight: 650; transition: .15s ease; }
.nav-item:hover { color: var(--text); background: #f5f8fc; }
.nav-item.active { color: var(--primary); background: var(--primary-soft); }
.nav-icon { display: inline-grid; place-items: center; width: 22px; font-size: 17px; }
.sidebar-bottom { display: grid; gap: 2px; margin-top: auto; padding-top: 20px; border-top: 1px solid var(--line); }
.danger-text { color: #a04a4a; }
.danger-text:hover { color: var(--danger); background: var(--danger-soft); }
.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; min-height: 84px; display: flex; align-items: center; gap: 18px; padding: 16px 30px; border-bottom: 1px solid rgba(230,235,242,.85); background: rgba(245,247,251,.88); backdrop-filter: blur(14px); }
.page-heading h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.03em; }
.page-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 11px; margin-left: auto; }
.icon-btn { display: grid; place-items: center; width: 37px; height: 37px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: #4d5b70; font-size: 18px; }
.icon-btn:hover { background: #f7f9fc; border-color: var(--line-strong); }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 12px; font-weight: 700; }
.avatar { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 50%; background: #172033; color: #fff; font-size: 11px; }
.mobile-menu { display: none; border: 0; background: transparent; font-size: 23px; }
.content { padding: 26px 30px 45px; }
.hero-strip { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; gap: 22px; padding: 26px 28px; border-radius: var(--radius); background: linear-gradient(115deg, #10234b, #1f4c94 70%, #3977d6); color: #fff; box-shadow: 0 16px 40px rgba(37,99,235,.16); }
.hero-strip:after { content: ""; position: absolute; right: -70px; top: -100px; width: 300px; height: 300px; border-radius: 50%; background: rgba(255,255,255,.1); }
.hero-strip h2 { position: relative; z-index: 1; margin: 0 0 9px; font-size: 23px; letter-spacing: -.03em; }
.hero-strip p { position: relative; z-index: 1; margin: 0; color: #d4e2ff; font-size: 13px; line-height: 1.7; }
.hero-actions { position: relative; z-index: 1; display: flex; gap: 10px; flex: none; }
.hero-actions .btn { border-color: rgba(255,255,255,.24); background: rgba(255,255,255,.13); color: #fff; }
.hero-actions .btn.primary { background: #fff; color: #1e4c94; border-color: #fff; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 18px 0; }
.stat-card { padding: 18px 19px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.stat-card .stat-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
.stat-card .stat-value { margin-top: 12px; font-size: 25px; font-weight: 800; letter-spacing: -.04em; }
.stat-card .stat-note { margin-top: 6px; color: var(--muted); font-size: 11px; }
.stat-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 5px var(--primary-soft); }
.stat-dot.green { background: var(--success); box-shadow: 0 0 0 5px var(--success-soft); }
.stat-dot.orange { background: #ea8a15; box-shadow: 0 0 0 5px var(--warning-soft); }
.panel { margin-top: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 19px 20px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 15px; letter-spacing: -.02em; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.panel-body { padding: 20px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.toolbar .spacer { flex: 1; }
.device-tabs { display: inline-flex; align-items: center; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: #f8fafc; }
.device-tabs button { padding: 6px 10px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 700; }
.device-tabs button:hover { color: var(--text); }
.device-tabs button.active { color: var(--primary); background: #fff; box-shadow: 0 1px 4px rgba(31, 45, 70, .1); }
.search-box { position: relative; min-width: 245px; }
.search-box input { width: 100%; min-height: 36px; padding: 8px 12px 8px 34px; border: 1px solid var(--line-strong); border-radius: 9px; outline: none; background: #fff; font-size: 12px; }
.search-box:before { content: "⌕"; position: absolute; left: 12px; top: 6px; color: var(--muted); font-size: 18px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 16px; color: #8490a2; background: #fbfcfe; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 14px 16px; border-top: 1px solid #f0f3f7; color: #344158; font-size: 12px; vertical-align: middle; }
tr:hover td { background: #fcfdff; }
.rule-name { display: grid; gap: 4px; min-width: 140px; }
.rule-name strong { color: var(--text); font-size: 13px; }
.rule-name small { color: var(--muted); font-size: 10px; }
.endpoint { display: grid; gap: 4px; font-family: "Cascadia Code", Consolas, monospace; font-size: 11px; }
.endpoint .label { color: var(--muted); font-family: inherit; font-size: 10px; }
.endpoint .value { color: #27364f; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.badge:before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.active { color: var(--success); background: var(--success-soft); }
.badge.paused { color: #a26a13; background: var(--warning-soft); }
.badge.online { color: var(--success); background: var(--success-soft); }
.badge.offline { color: #8a95a7; background: #eef1f5; }
.badge.protocol { color: var(--primary); background: var(--primary-soft); text-transform: uppercase; }
.actions { display: flex; align-items: center; gap: 4px; }
.action-btn { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid transparent; border-radius: 8px; color: #657188; background: transparent; font-size: 15px; }
.action-btn:hover { border-color: var(--line); background: #f5f8fc; color: var(--primary); }
.action-btn.danger:hover { color: var(--danger); background: var(--danger-soft); border-color: #fecaca; }
.empty { display: grid; place-items: center; gap: 8px; min-height: 230px; padding: 30px; color: var(--muted); text-align: center; }
.empty strong { color: #4c5a70; font-size: 15px; }
.empty p { max-width: 420px; margin: 0; line-height: 1.7; font-size: 12px; }
.mini-list { display: grid; gap: 10px; }
.mini-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 12px 0; border-bottom: 1px solid #f0f3f7; }
.mini-row:last-child { border-bottom: 0; }
.mini-row strong { font-size: 12px; }
.mini-row span { color: var(--muted); font-size: 11px; }
.node-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.node-card { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(180deg, #fff, #fbfcff); }
.node-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.node-card h3 { margin: 0 0 5px; font-size: 14px; }
.node-card .address { color: var(--muted); font-family: "Cascadia Code", Consolas, monospace; font-size: 11px; }
.node-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line); }
.node-metrics span { display: block; color: var(--muted); font-size: 10px; }
.node-metrics strong { display: block; margin-top: 4px; font-size: 14px; }
.node-card .node-actions { display: flex; gap: 7px; margin-top: 16px; }
.modal-root { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(9, 18, 35, .45); backdrop-filter: blur(3px); }
.modal-card { position: relative; width: min(610px, 100%); max-height: min(88vh, 800px); overflow: auto; border: 1px solid rgba(255,255,255,.6); border-radius: 18px; background: #fff; box-shadow: 0 30px 80px rgba(33, 48, 74, .2); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 22px 24px 17px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 7px 0 0; font-size: 20px; letter-spacing: -.03em; }
.modal-body { padding: 21px 24px 24px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 21px; }
.info-box { padding: 13px 14px; border: 1px solid #dbe7ff; border-radius: 10px; color: #31527c; background: #f3f7ff; font-size: 12px; line-height: 1.7; }
.install-command { position: relative; margin-top: 14px; padding: 14px; border-radius: 10px; color: #d9e7ff; background: #101c32; font-family: "Cascadia Code", Consolas, monospace; font-size: 11px; line-height: 1.7; white-space: pre-wrap; word-break: break-all; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 200; max-width: min(420px, calc(100vw - 44px)); padding: 13px 16px; border: 1px solid #bfe8cd; border-radius: 11px; color: #14532d; background: #effcf3; box-shadow: var(--shadow); font-size: 12px; }
.toast.error { border-color: #fecaca; color: #991b1b; background: var(--danger-soft); }
.section-stack { display: grid; gap: 18px; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, .7fr); gap: 18px; }
.info-list { display: grid; gap: 14px; }
.info-list div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 13px; border-bottom: 1px solid #f0f3f7; }
.info-list div:last-child { padding-bottom: 0; border-bottom: 0; }
.info-list span { color: var(--muted); font-size: 12px; }
.info-list strong { font-size: 12px; text-align: right; }

@media (max-width: 1050px) {
  .login-page { grid-template-columns: 1fr; }
  .login-visual { min-height: 390px; padding: 38px; }
  .login-copy { padding: 30px 0 0; }
  .login-panel { padding: 32px 20px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .node-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .login-visual { display: none; }
  .login-panel { min-height: 100vh; padding: 22px; }
  .login-card { padding: 28px 23px; }
  .mobile-brand { display: flex; }
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; width: min(280px, 82vw); transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .app-shell.menu-open .sidebar { transform: translateX(0); }
  .mobile-menu { display: block; }
  .topbar { min-height: 72px; padding: 13px 17px; }
  .page-heading h1 { font-size: 19px; }
  .page-heading p { display: none; }
  .content { padding: 18px 15px 35px; }
  .hero-strip { align-items: flex-start; flex-direction: column; padding: 22px; }
  .hero-actions { width: 100%; }
  .hero-actions .btn { flex: 1; }
  .stat-grid, .node-grid { grid-template-columns: 1fr; }
  .toolbar { align-items: stretch; padding: 14px; }
  .toolbar .spacer { display: none; }
  .search-box { min-width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .modal-card { max-height: 92vh; }
  .modal-head, .modal-body { padding-left: 18px; padding-right: 18px; }
  .user-chip span:last-child { display: none; }
}
