:root {
  color-scheme: light;
  --bg: #f5f6fa;
  --panel: #fff;
  --ink: #182236;
  --muted: #5f6d83;
  --line: #e5e9f1;
  --accent: #4e50d7;
  --accent-deep: #3e3fb7;
  --green: #12715a;
  --red: #a43851;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
svg { width: 18px; height: 18px; display: block; flex: 0 0 auto; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 31px; letter-spacing: -.055em; line-height: 1.2; }
h2 { font-size: 17px; letter-spacing: -.02em; }
h3 { font-size: 14px; font-weight: 650; }
.subtle { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 222px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; gap: 36px; position: sticky; top: 0; align-self: start; height: 100vh; padding: 26px 16px 20px; background: #fff; border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; font-size: 15px; line-height: 1.2; font-weight: 750; letter-spacing: -.02em; padding: 0 8px; }
.brand-mark { display: grid; align-items: center; justify-items: center; width: 38px; height: 38px; background: #5052dc; color: #fff; border-radius: 11px; box-shadow: 0 4px 9px #4e50d72d; }
.brand-mark svg { width: 22px; height: 22px; }
.brand small { display: block; color: var(--muted); font-size: 9px; margin-top: 5px; letter-spacing: .085em; font-weight: 650; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav button, .logout { border: 0; border-radius: 8px; background: transparent; text-align: left; color: var(--muted); padding: 11px 12px; font-weight: 580; display: flex; align-items: center; gap: 11px; }
.sidebar nav button:hover, .logout:hover { background: #f5f6fb; color: var(--ink); }
.sidebar nav button.active { color: var(--accent-deep); background: #ebecff; font-weight: 700; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 9px; }
.sidebar-status { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 8px; border: 1px solid var(--line); font-size: 13px; }
.sidebar-status small { display: block; color: var(--muted); margin-top: 2px; }
.system-dot, .dot { display: inline-block; width: 7px; height: 7px; background: currentColor; border-radius: 50%; flex: 0 0 auto; }
.system-dot { color: #24aa83; box-shadow: 0 0 0 4px #e5f6ef; margin: 0 3px; }
.system-dot.offline { color: #bf6173; box-shadow: 0 0 0 4px #f8eaef; }
.main { min-width: 0; }
.topbar { min-height: 64px; border-bottom: 1px solid var(--line); background: var(--panel); padding: 0 32px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.breadcrumb, .top-actions { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.breadcrumb svg { width: 13px; height: 13px; }
.breadcrumb strong { color: var(--ink); font-weight: 660; }
.top-actions { font-size: 12px; }
.icon-button { color: var(--muted); display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; flex: 0 0 auto; }
.icon-button:hover { background: #f4f5fb; color: var(--accent); border-color: #d9dcf5; }
.content { max-width: 1540px; margin: 0 auto; padding: 30px 32px 48px; display: grid; gap: 22px; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.page-title p { color: var(--muted); margin-top: 7px; }
.page-actions, .actions, .card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.button { border: 1px solid #dfe4ee; border-radius: 8px; background: var(--panel); color: var(--ink); padding: 8px 12px; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; white-space: nowrap; }
.button:hover { border-color: #c4c8ec; background: #f5f5ff; }
.button svg { width: 16px; height: 16px; }
.primary { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 2px 4px #4e50d727; }
.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.text-button { border: 0; background: transparent; color: var(--accent-deep); border-radius: 5px; padding: 5px 7px; font-weight: 620; white-space: nowrap; }
.text-button:hover { background: #eeefff; }
.text-button.neutral { color: var(--muted); }
.text-button.danger { color: var(--red); }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; min-width: 0; box-shadow: 0 2px 4px #1f325805; }
.metric { padding: 16px 17px 14px; }
.metric-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; font-weight: 620; }
.metric-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: #efeeff; color: #5754d6; }
.metric-icon.green { background: #e6f7f0; color: #16836b; }
.metric-icon.blue { background: #eaf3ff; color: #2866c3; }
.metric-icon.amber { background: #fff4e1; color: #9a5d14; }
.metric strong { display: block; font-size: clamp(20px, 2.25vw, 30px); line-height: 1.2; letter-spacing: -.035em; margin: 7px 0 5px; font-variant-numeric: tabular-nums; }
.metric small { color: var(--muted); font-size: 12px; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 2.55fr) minmax(250px, 1fr); gap: 16px; align-items: start; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 18px; }
.card-head p { color: var(--muted); font-size: 12px; margin-top: 3px; }
.chart-body { padding: 0 18px 13px; position: relative; }
.legend { display: flex; gap: 16px; margin: 0 0 8px 4px; font-size: 12px; color: var(--muted); }
.legend > span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; background: #5756dd; }
.legend span:nth-child(2) i { background: #1ba78f; }
.chart-wrap { height: 221px; position: relative; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.chart-tip { position: absolute; top: 0; right: 4px; z-index: 1; background: #172039; color: #fff; padding: 7px 10px; border-radius: 7px; font-size: 11px; pointer-events: none; }
.node-list { padding: 0 17px 8px; display: grid; }
.node-line { padding: 12px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid #eff1f6; }
.node-line:first-child { border-top: 0; }
.node-label { display: flex; align-items: center; gap: 9px; min-width: 0; }
.node-label strong { display: block; overflow-wrap: anywhere; font-size: 13px; }
.node-label small { color: var(--muted); display: block; }
.node-emblem { display: grid; place-items: center; color: #59678e; width: 32px; height: 32px; flex: 0 0 auto; border-radius: 8px; background: #f2f4fa; }
.node-emblem svg { width: 15px; height: 15px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 650; border-radius: 20px; background: #eef1f7; color: #536278; padding: 3px 8px; white-space: nowrap; }
.badge.green { background: #e6f7ef; color: var(--green); }
.badge.violet { background: #eeedff; color: var(--accent-deep); }
.badge.amber { background: #fff2dc; color: #8c5511; }
.badge.red { background: #ffeef1; color: var(--red); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; font-size: 13px; }
thead { color: #5e6b82; background: #f8f9fc; }
th { white-space: nowrap; font-size: 11px; font-weight: 700; }
th, td { padding: 11px 16px; border-top: 1px solid #eff1f6; }
td strong { font-weight: 670; }
td small { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); }
td .actions { flex-wrap: nowrap; gap: 1px; }
tbody tr:hover { background: #fafaff; }
.rule-name { min-width: 108px; overflow-wrap: anywhere; }
.route { min-width: 100px; }
.route span { padding: 0 3px; color: var(--muted); }
.route b { font-weight: 600; }
.filter-bar { padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 6px; position: relative; }
.search svg { position: absolute; left: 9px; color: var(--muted); width: 14px; height: 14px; }
.search input { padding-left: 29px; }
select, input, textarea { border: 1px solid #dce2ed; border-radius: 7px; background: var(--panel); color: var(--ink); min-width: 0; padding: 8px 9px; }
input::placeholder, textarea::placeholder { color: #66738a; }
textarea { resize: vertical; min-height: 92px; }
.card-actions select { width: auto; font-size: 12px; }
.empty { padding: 24px 16px; text-align: center; color: var(--muted); }
.node-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.node-card { padding: 16px; display: grid; gap: 14px; }
.data-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; color: var(--muted); font-size: 12px; }
.data-pair strong { display: block; color: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; }
.monitor-resources { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.resource-gauge { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.resource-gauge strong { color: var(--ink); font-size: 14px; font-variant-numeric: tabular-nums; }
.resource-gauge meter { width: 100%; height: 7px; }
.resource-gauge meter::-webkit-meter-bar { border: 0; background: #edf0f6; }
.resource-gauge meter::-webkit-meter-optimum-value { background: var(--accent); }
.resource-gauge meter::-moz-meter-bar { background: var(--accent); }
.rule-steps { display: grid; gap: 8px; padding: 0; margin: 0; list-style: none; }
.rule-steps li { display: grid; grid-template-columns: 105px minmax(0, 1fr); gap: 8px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; }
.dialog-section { display: grid; gap: 9px; }
.notice { background: #f2f4fd; color: #394967; padding: 10px 11px; border-radius: 7px; font-size: 13px; }
.error, .network-error { background: #fff0f3; color: var(--red); padding: 9px 12px; border-radius: 7px; overflow-wrap: anywhere; }
.network-error { margin: 12px 32px 0; }
dialog { width: min(580px, calc(100vw - 22px)); max-height: 90vh; overflow: auto; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); padding: 21px; box-shadow: 0 18px 60px #12213b38; }
dialog::backdrop { background: #19213b66; }
.dialog-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 15px; }
#dialog-body > form, #dialog-body > .dialog-section { display: grid; gap: 13px; }
#dialog-error { margin-top: 12px; }
label { display: grid; align-content: start; gap: 5px; font-weight: 620; color: var(--ink); font-size: 13px; }
label small { font-weight: 400; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 6px; }
.check input { accent-color: var(--accent); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 3px; }
.toast { position: fixed; z-index: 3; bottom: 24px; right: 24px; background: #172239; color: white; box-shadow: 0 8px 24px #18243c39; border-radius: 8px; padding: 11px 15px; max-width: calc(100% - 32px); }
.login-screen, .startup { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(400px, 100%); display: grid; gap: 20px; padding: 28px; }
.login-card .brand { padding: 0; }
.login-card h1 { font-size: 23px; }
@media (max-width: 1040px) {
  .shell { grid-template-columns: 174px minmax(0, 1fr); }
  .topbar, .content { padding-left: 21px; padding-right: 21px; }
  .metrics { gap: 9px; }
  .metric { padding: 12px; }
  .node-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .shell { display: block; }
  .sidebar { position: static; height: auto; padding: 12px; gap: 10px; border-bottom: 1px solid var(--line); }
  .sidebar nav { display: flex; gap: 4px; overflow-x: auto; }
  .sidebar nav button { white-space: nowrap; padding: 8px; gap: 6px; font-size: 12px; }
  .sidebar nav button svg { width: 14px; height: 14px; }
  .sidebar-bottom { position: absolute; top: 12px; right: 12px; }
  .sidebar-status { display: none; }
  .topbar { min-height: 46px; }
  .content { padding-top: 21px; }
  .metric strong { font-size: 23px; }
}
@media (max-width: 595px) {
  .content, .topbar { padding-left: 12px; padding-right: 12px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid, .node-grid { grid-template-columns: minmax(0, 1fr); }
  .page-title { flex-wrap: wrap; }
  h1 { font-size: 26px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .chart-wrap { height: 194px; }
}
