:root {
  --bg: #F6F8FC;
  --surface: #FFFFFF;
  --surface-elevated: #F8FAFC;
  --sidebar-bg: #14204A;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active: rgba(59, 102, 245, 0.24);
  --border: #E5E9F2;
  --text: #111827;
  --text-secondary: #475569;
  --muted: #64748B;
  --primary: #3B66F5;
  --primary-hover: #2E55DC;
  --primary-soft: rgba(59, 102, 245, 0.10);
  --ok: #059669;
  --ok-bg: #ECFDF5;
  --warn: #D97706;
  --warn-bg: #FEF3C7;
  --crit: #DC2626;
  --crit-bg: #FEF2F2;
  --idle: #64748B;
  --idle-bg: #F1F5F9;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.03);
  --radius-card: 12px;
  --radius-btn: 8px;
}

html[data-theme="dark"] {
  --bg: #0B1120;
  --surface: #111A2E;
  --surface-elevated: #17233D;
  --sidebar-bg: #0D152B;
  --sidebar-hover: rgba(255, 255, 255, 0.07);
  --sidebar-active: rgba(90, 130, 255, 0.22);
  --border: rgba(148, 163, 184, 0.14);
  --text: #F1F5F9;
  --text-secondary: #CBD5E1;
  --muted: #94A3B8;
  --primary: #5A82FF;
  --primary-hover: #4B72EE;
  --primary-soft: rgba(90, 130, 255, 0.15);
  --ok: #34D399;
  --ok-bg: rgba(16, 185, 129, 0.15);
  --warn: #FBBF24;
  --warn-bg: rgba(245, 158, 11, 0.16);
  --crit: #F87171;
  --crit-bg: rgba(239, 68, 68, 0.16);
  --idle: #94A3B8;
  --idle-bg: rgba(148, 163, 184, 0.14);
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-size: 12.5px; margin: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 12px; }

/* 按钮体系（参考附件2：8px圆角矩形 + 清晰主次对比） */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-btn);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, opacity .15s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn-block { width: 100%; height: 40px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-elevated); }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-elevated); }

/* 徽标胶囊 */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-up { background: var(--ok-bg); color: var(--ok); }
.pill-degraded { background: var(--warn-bg); color: var(--warn); }
.pill-down { background: var(--crit-bg); color: var(--crit); }
.pill-unknown, .pill-idle { background: var(--idle-bg); color: var(--idle); }
.pill-info { background: var(--primary-soft); color: var(--primary); }

/* 登录页 */
.login-body { min-height: 100vh; display: flex; }
.login-shell { display: grid; grid-template-columns: 420px 1fr; width: 100%; min-height: 100vh; }
.login-brand-pane {
  background: var(--sidebar-bg);
  color: #fff;
  padding: 40px 36px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, #3B66F5, #60A5FA);
  color: #fff; font-weight: 700; font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center;
}
.brand-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: rgba(255,255,255,0.65); }
.login-hero { font-size: 28px; line-height: 1.28; margin: 24px 0 12px; font-weight: 700; }
.login-desc { color: rgba(255,255,255,0.75); font-size: 13.5px; margin: 0; }
.login-meta-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; }
.login-meta-chips .chip {
  padding: 4px 10px; border-radius: 9999px; font-size: 12px;
  background: rgba(255,255,255,0.10); color: rgba(255,255,255,0.88);
}
.login-form-pane {
  padding: 28px 32px;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  position: relative;
}
.login-top-actions { position: absolute; top: 20px; right: 24px; }
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px; box-shadow: var(--shadow);
}
.login-card h2 { margin: 0 0 6px; font-size: 20px; }
.stack-form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12.5px; font-weight: 500; color: var(--text-secondary); }
.field input, .select-input, .search-box input {
  height: 38px; padding: 0 12px; border-radius: var(--radius-btn);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 13.5px; outline: none;
}
.field input:focus, .search-box input:focus { border-color: var(--primary); }
.form-error { padding: 9px 12px; border-radius: 8px; background: var(--crit-bg); color: var(--crit); font-size: 12.5px; }
.form-msg { padding: 9px 12px; border-radius: 8px; background: var(--ok-bg); color: var(--ok); font-size: 12.5px; }

/* 主应用双栏骨架（复刻附件2左侧深蓝栏 + 右侧极净主画布） */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--sidebar-bg); color: #fff;
  padding: 20px 14px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: sticky; top: 0; height: 100vh;
}
.admin-badge-card {
  margin-top: 18px; padding: 11px 12px; border-radius: 10px;
  background: rgba(255,255,255,0.06);
  display: flex; align-items: center; gap: 10px;
}
.admin-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: #3B66F5; color: #fff; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.admin-name { font-size: 13px; font-weight: 600; }
.admin-role { font-size: 11.5px; color: rgba(255,255,255,0.65); }

.side-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 20px; flex: 1; }
.side-link {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px; border: none; border-radius: 8px;
  background: transparent; color: rgba(255,255,255,0.78);
  font-size: 13.5px; font-weight: 500; cursor: pointer; text-align: left;
  transition: background-color .15s ease, color .15s ease;
}
.side-link:hover { background: var(--sidebar-hover); color: #fff; }
.side-link.is-active { background: var(--sidebar-active); color: #fff; }
.nav-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.35); }
.side-link.is-active .nav-dot { background: #60A5FA; }
.nav-count {
  margin-left: auto; font-size: 11px; padding: 1px 7px; border-radius: 9999px;
  background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.9);
}

.sidebar-footer { display: flex; flex-direction: column; gap: 6px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.10); }
.side-action {
  background: transparent; border: none; color: rgba(255,255,255,0.75);
  padding: 8px 10px; text-align: left; border-radius: 8px; cursor: pointer; font-size: 12.5px;
}
.side-action:hover { background: var(--sidebar-hover); color: #fff; }
.danger-text { color: #FCA5A5; }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.mobile-menu-btn { display: none; }
.page-title { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.page-subtitle { font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-box input { width: 200px; height: 32px; font-size: 12.5px; background: var(--surface); }

.theme-segmented {
  display: inline-flex; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 2px;
}
.theme-segmented button {
  border: none; background: transparent; color: var(--muted);
  padding: 4px 10px; border-radius: 6px; font-size: 12px; cursor: pointer;
}
.theme-segmented button.is-active { background: var(--primary); color: #fff; font-weight: 500; }

.content { padding: 20px 24px 36px; display: flex; flex-direction: column; gap: 18px; max-width: 1520px; width: 100%; margin: 0 auto; }

/* 状态横幅 */
.hero-status {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 14px 18px; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.hero-status-left { display: flex; align-items: center; gap: 12px; }
.pulse-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.pulse-dot.is-up { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-bg); }
.pulse-dot.is-warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-bg); }
.pulse-dot.is-crit { background: var(--crit); box-shadow: 0 0 0 4px var(--crit-bg); }
.hero-headline { font-size: 15px; font-weight: 600; }
.hero-sub { font-size: 12px; color: var(--muted); }
.attention-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.att-btn {
  border: none; cursor: pointer; padding: 4px 10px; border-radius: 9999px;
  font-size: 12px; font-weight: 500;
}

/* KPI 五联卡 */
.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 25px; font-weight: 700; margin: 6px 0 4px; letter-spacing: -0.02em; }
.kpi-foot { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 面板与卡片 */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 18px; box-shadow: var(--shadow);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.panel-head h2 { margin: 0; font-size: 15.5px; font-weight: 600; }

.subtabs { display: inline-flex; border-bottom: 1px solid var(--border); gap: 4px; }
.subtab-btn {
  border: none; background: transparent; color: var(--muted);
  padding: 6px 12px; cursor: pointer; font-size: 13px; font-weight: 500;
  border-bottom: 2px solid transparent;
}
.subtab-btn.is-active { color: var(--primary); border-bottom-color: var(--primary); }

/* 服务器探针卡片网格（附件1密度 × 附件2舒朗呼吸感） */
.node-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.node-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 15px 16px; cursor: pointer; position: relative; overflow: hidden;
  transition: border-color .15s ease, transform .12s ease;
  border-left: 3px solid var(--idle);
}
.node-card:hover { border-color: var(--primary); }
.node-card.st-up { border-left-color: var(--ok); }
.node-card.st-degraded { border-left-color: var(--warn); }
.node-card.st-down { border-left-color: var(--crit); }

.node-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.node-name { font-size: 14.5px; font-weight: 600; }
.node-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.node-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.mini-chip {
  font-size: 11.5px; padding: 2px 8px; border-radius: 6px;
  background: var(--surface-elevated); border: 1px solid var(--border); color: var(--text-secondary);
}

.metric-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 10px 0; }
.bar-item-head { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.bar-track { height: 6px; border-radius: 999px; background: var(--surface-elevated); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--primary); transition: width .25s ease; }
.bar-fill.is-warn { background: var(--warn); }
.bar-fill.is-crit { background: var(--crit); }

.node-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding-top: 10px; margin-top: 10px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
}

/* 资产表格视图（对齐附件2表格风格） */
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 600;
  color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td {
  padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.data-table tbody tr { cursor: pointer; transition: background-color .12s ease; }
.data-table tbody tr:hover { background: var(--surface-elevated); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* 现代 Status 心跳条视图（SearXNG / AI 网关 / 站点） */
.monitor-group { margin-bottom: 20px; }
.monitor-group:last-child { margin-bottom: 0; }
.group-title {
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  margin: 0 0 10px; display: flex; align-items: center; gap: 8px;
}
.monitor-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.monitor-item {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
  background: var(--surface-elevated);
}
.monitor-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.monitor-name { font-weight: 600; font-size: 13.5px; }
.monitor-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.hb-strip {
  display: grid; grid-template-columns: repeat(48, minmax(0, 1fr)); gap: 2px;
  margin-top: 10px; height: 22px; align-items: end;
}
.hb-bar {
  height: 100%; border-radius: 2px; background: var(--idle-bg);
}
.hb-bar.st-up { background: var(--ok); opacity: 0.88; }
.hb-bar.st-degraded { background: var(--warn); }
.hb-bar.st-down { background: var(--crit); }

/* 异常时间线 */
.incidents-list { display: flex; flex-direction: column; gap: 8px; }
.incident-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-elevated);
}

/* 抽屉与弹窗 */
.drawer-backdrop, .modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 40;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 95vw);
  background: var(--surface); border-left: 1px solid var(--border); z-index: 50;
  display: flex; flex-direction: column; box-shadow: -8px 0 28px rgba(0,0,0,0.18);
}
.drawer-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.drawer-head h3 { margin: 0; font-size: 16px; }
.drawer-body { padding: 18px 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 16px; }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kv-box { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-elevated); }
.kv-k { font-size: 11.5px; color: var(--muted); }
.kv-v { font-size: 13.5px; font-weight: 600; margin-top: 2px; word-break: break-all; }
.token-box {
  padding: 12px; border-radius: 8px; border: 1px dashed var(--primary); background: var(--primary-soft);
  word-break: break-all; font-family: ui-monospace, monospace; font-size: 12px;
}

.modal-backdrop { display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop[hidden], .drawer-backdrop[hidden], .drawer[hidden] { display: none !important; }
.modal-card {
  width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); overflow: hidden;
}
.modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 20px; }
.modal-section h4 { margin: 0 0 10px; font-size: 14px; }
.inline-form { display: flex; gap: 10px; align-items: center; }

@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .node-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand-pane { display: none; }
  .sidebar { position: fixed; left: -260px; z-index: 60; transition: left .2s ease; }
  .sidebar.is-open { left: 0; }
  .mobile-menu-btn { display: inline-flex; }
  .kpi-grid, .node-grid, .monitor-list { grid-template-columns: 1fr; }
  .search-box input { width: 150px; }
}
