:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-solid: #ffffff;
  --panel-thin: rgba(255, 255, 255, 0.62);
  --line: rgba(0, 0, 0, 0.055);
  --line-strong: rgba(0, 0, 0, 0.10);
  --inner-light: rgba(255, 255, 255, 0.92);

  --text: #1d1d1f;
  --text-2: #424245;
  --sub: #6e6e73;
  --sub-2: #a1a1a6;

  --brand: #0071e3;
  --brand-dark: #0062c4;
  --brand-soft: rgba(0, 113, 227, 0.09);

  --ok: #1d9d55;
  --warn: #d98300;
  --bad: #e0322f;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;

  --shadow: 0 0.5px 1px rgba(0, 0, 0, 0.035), 0 4px 20px rgba(0, 0, 0, 0.055);
  --glass-blur: blur(24px) saturate(180%);

  --seg-track: rgba(118, 118, 128, 0.12);
  --seg-active: #ffffff;
  --seg-shadow: 0 1px 2px rgba(0, 0, 0, 0.10), 0 0 0 0.5px rgba(0, 0, 0, 0.06);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --row-h: 44px;
  --num: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro SC", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.app { display: flex; height: 100vh; overflow: hidden; }

/* ---------------- 侧栏 ---------------- */
.sidebar {
  width: 252px; flex: 0 0 252px;
  display: flex; flex-direction: column;
  padding: 16px 12px 10px;
  background: var(--panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 14px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, #2f9bff, #0071e3 62%, #0059b3);
  color: #fff; font-size: 15px; font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.34), inset 0 0.5px 0 rgba(255, 255, 255, 0.5);
}
.brand-text { display: flex; flex-direction: column; gap: 1px; line-height: 1.25; }
.brand-text strong { font-size: 13.5px; font-weight: 600; letter-spacing: -0.2px; }
.brand-text span { font-size: 10.5px; color: var(--sub-2); letter-spacing: 0.24px; }

.pf-node { margin-bottom: 2px; }
.pf-head {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 9px;
  border: 0; border-radius: var(--radius-xs);
  background: transparent; color: var(--text);
  font-family: inherit; font-size: 12.5px; font-weight: 550;
  cursor: pointer; text-align: left;
  transition: background .16s var(--ease);
}
.pf-head:hover { background: var(--seg-track); }
.pf-node.active > .pf-head { background: var(--brand-soft); color: var(--brand); }
.pf-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--sub-2); flex: 0 0 6px; }
.pf-dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(29, 157, 85, .14); }
.pf-name { flex: 1; }
.pf-caret { font-size: 11px; color: var(--sub-2); transition: transform .16s var(--ease); }
.pf-node.open .pf-caret { transform: rotate(90deg); }
.pf-body { padding: 2px 0 8px; }

.acct-card {
  margin: 0 4px 10px; padding: 11px 12px;
  border-radius: var(--radius-sm);
  background: var(--panel-thin);
  border: 1px solid var(--line);
  box-shadow: inset 0 0.5px 0 var(--inner-light);
}
.acct-row { display: flex; align-items: center; gap: 7px; }
.acct-name { font-size: 12.5px; font-weight: 550; letter-spacing: -0.1px; }
.acct-meta { margin-top: 7px; font-size: 11px; color: var(--sub); line-height: 1.65; }
.acct-meta b { color: var(--text-2); font-weight: 550; font-variant-numeric: tabular-nums; }

.side-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 8px 7px;
  font-size: 11px; font-weight: 550; color: var(--sub-2); letter-spacing: .3px;
}

.side-foot { margin-top: auto; padding: 8px 4px 0; border-top: 1px solid var(--line); }
.side-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 7px 9px;
  border: 0; border-radius: var(--radius-xs);
  background: transparent; color: var(--text-2);
  font-family: inherit; font-size: 12px; text-align: left; cursor: pointer;
  transition: background .16s var(--ease);
}
.side-btn:hover { background: var(--brand-soft); color: var(--brand); }
.side-ver { padding: 5px 9px 2px; font-size: 10px; color: var(--sub-2); font-family: var(--num); }

/* ---------------- 主区 ---------------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  height: 52px; padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  flex: 0 0 52px;
}

.view-tabs { display: flex; gap: 2px; }
.view-tabs button {
  padding: 6px 12px; border: 0; border-radius: var(--radius-xs);
  background: transparent; color: var(--sub);
  font-family: inherit; font-size: 12.5px; font-weight: 500;
  cursor: pointer; transition: all .16s var(--ease);
}
.view-tabs button:hover { color: var(--text); background: var(--seg-track); }
.view-tabs button.active {
  color: var(--text); font-weight: 600;
  background: var(--panel-solid); box-shadow: var(--seg-shadow);
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.seg {
  display: inline-flex; padding: 2px; gap: 2px;
  border-radius: 9px; background: var(--seg-track);
}
.seg button {
  padding: 4.5px 11px; border: 0; border-radius: 7px;
  background: transparent; color: var(--sub);
  font-family: inherit; font-size: 12px; font-weight: 500;
  cursor: pointer; white-space: nowrap; transition: all .16s var(--ease);
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--seg-active); color: var(--text); font-weight: 600; box-shadow: var(--seg-shadow); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; border: 0; border-radius: var(--radius-xs);
  background: var(--brand); color: #fff;
  font-family: inherit; font-size: 12.5px; font-weight: 550;
  cursor: pointer; transition: all .16s var(--ease);
  box-shadow: 0 1px 2px rgba(0, 113, 227, .24);
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: var(--seg-track); color: var(--text-2); box-shadow: none; }
.btn.ghost:hover { background: var(--line-strong); color: var(--text); }
.btn.sm { padding: 4px 9px; font-size: 11.5px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; color: var(--sub);
  background: var(--seg-track);
}
.badge.ok { color: var(--ok); background: rgba(29, 157, 85, .1); }
.badge.warn { color: var(--warn); background: rgba(217, 131, 0, .1); }
.badge.bad { color: var(--bad); background: rgba(224, 50, 47, .09); }

.view { display: none; flex-direction: column; min-height: 0; flex: 1; overflow: hidden; }
.view.active { display: flex; }

.toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  flex: 0 0 auto;
}
.toolbar .grow { margin-left: auto; }

.field {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--sub);
}
.field input[type="date"], .field select, .field input[type="text"], .field input[type="number"], .field input[type="password"] {
  padding: 4px 8px; font-size: 12px;
  border: 1px solid var(--line-strong); border-radius: 7px;
  background: var(--panel-solid); color: var(--text);
  font-family: inherit;
}
.field input::placeholder { color: var(--sub-2); }

.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); cursor: pointer; }
.chk input { accent-color: var(--brand); }

.sum-strip {
  display: flex; align-items: center; gap: 22px;
  padding: 10px 18px; border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.sum-strip .it { display: flex; flex-direction: column; gap: 1px; }
.sum-strip .it span { font-size: 10.5px; color: var(--sub-2); letter-spacing: .2px; }
.sum-strip .it b { font-size: 16px; font-weight: 600; font-family: var(--num); letter-spacing: -.2px; }
.sum-strip .it b.up { color: var(--bad); }
.sum-strip .it b.good { color: var(--ok); }

.table-wrap {
  flex: 1; min-height: 0;
  margin: 12px 18px 0;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-solid);
  box-shadow: var(--shadow);
  overflow: auto;
  position: relative;
}
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; }
thead th {
  position: sticky; top: 0; z-index: 3;
  padding: 9px 10px; text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 600; color: var(--sub);
  letter-spacing: .2px; background: var(--panel-solid);
  border-bottom: 1px solid var(--line-strong);
  cursor: pointer; user-select: none;
}
thead th:hover { color: var(--text); }
tbody td {
  padding: 0 10px; height: var(--row-h);
  border-bottom: 1px solid var(--line);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 280px; color: var(--text-2);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--brand-soft); }
td.num, th.num { text-align: right; font-family: var(--num); font-variant-numeric: tabular-nums; }
td.strong { color: var(--text); font-weight: 550; }
td.mono { font-family: var(--num); font-size: 11.5px; }
td .sub-cell { display: block; font-size: 10.5px; color: var(--sub-2); font-family: var(--num); }
.th-sticky, .td-sticky { position: sticky; left: 0; z-index: 2; background: var(--panel-solid); box-shadow: 1px 0 0 var(--line); }
thead th.th-sticky { z-index: 4; }

.footbar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 18px 11px; font-size: 11px; color: var(--sub-2);
  flex: 0 0 auto;
}
.footbar .grow { margin-left: auto; }

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 60px 20px; color: var(--sub); text-align: center;
}
.empty .big { font-size: 26px; opacity: .5; }
.empty h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text-2); }
.empty p { margin: 0; font-size: 12px; max-width: 460px; line-height: 1.7; }

/* ---------------- 巡检视图 ---------------- */
.patrol { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; padding: 14px 18px 0; min-height: 0; flex: 1; }
.panel {
  background: var(--panel-solid); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.panel-h {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.panel-h h3 { margin: 0; font-size: 12.5px; font-weight: 600; }
.panel-h .grow { margin-left: auto; }
.panel-body { overflow: auto; min-height: 0; flex: 1; }

.rule { padding: 11px 14px; border-bottom: 1px solid var(--line); }
.rule:last-child { border-bottom: 0; }
.rule-h { display: flex; align-items: center; gap: 8px; }
.rule-h b { font-size: 12px; font-weight: 550; }
.rule-h .hits { margin-left: auto; font-size: 11px; color: var(--sub-2); }
.rule p { margin: 4px 0 0; font-size: 11px; color: var(--sub); line-height: 1.55; }
.rule.off { opacity: .5; }

.sw { display: inline-flex; cursor: pointer; }
.sw input { display: none; }
.sw span {
  width: 30px; height: 18px; border-radius: 999px; background: #ddd; position: relative;
  transition: background .15s var(--ease);
}
.sw span::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18); transition: transform .15s var(--ease);
}
.sw input:checked + span { background: var(--ok); }
.sw input:checked + span::after { transform: translateX(12px); }

.guard { padding: 12px 14px; background: rgba(29, 157, 85, .045); border-top: 1px solid var(--line); }
.guard-row { display: flex; gap: 10px; align-items: flex-start; }
.guard b { font-size: 12px; font-weight: 550; }
.guard p { margin: 3px 0 0; font-size: 11px; color: var(--sub); line-height: 1.55; }
.guard input { width: 62px; padding: 1px 5px; font: inherit; font-size: 11px; text-align: right;
  border: 1px solid var(--line-strong); border-radius: 6px; }

.rail {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; font-size: 12px; color: #256b3c;
  background: rgba(29, 157, 85, .07); border-bottom: 1px solid rgba(29, 157, 85, .16);
  flex: 0 0 auto;
}
.rail b { font-weight: 600; }
.rail-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: 0 0 auto; }
.rail-btn {
  margin-left: auto; font: inherit; font-size: 11.5px; color: #256b3c;
  background: transparent; border: 1px solid rgba(29, 157, 85, .3);
  border-radius: 999px; padding: 2px 10px; cursor: pointer;
}
.rail-btn:hover { background: rgba(29, 157, 85, .1); }

.acts { overflow: auto; min-height: 0; flex: 1; }
.act {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 14px; padding: 11px 14px; border-bottom: 1px solid var(--line);
  align-items: start;
}
.act:hover { background: #fbfcfe; }
.act-name { font-size: 12.5px; }
.act-name b { font-weight: 550; }
.act-meta { font-size: 11px; color: var(--sub-2); margin-top: 2px; }
.act-metrics { font-size: 11.5px; color: var(--sub); margin-top: 3px; font-variant-numeric: tabular-nums; }
.act-metrics i { font-style: normal; color: var(--sub-2); }
.act-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.blocked-why {
  grid-column: 1 / -1; font-size: 11.5px; color: #8a2b28;
  background: rgba(224, 50, 47, .05); border: 1px solid rgba(224, 50, 47, .14);
  padding: 6px 9px; border-radius: var(--radius-xs); margin-top: 3px;
}
.act.done .act-name, .act.done .act-metrics { opacity: .45; }

.tag {
  font-size: 11px; padding: 2px 8px; border-radius: 6px;
  border: 1px solid var(--line); color: var(--sub); background: #fafafa;
  white-space: nowrap;
}
.tag.act { color: var(--brand); background: var(--brand-soft); border-color: rgba(0, 113, 227, .18); }
.tag.block { color: var(--bad); background: rgba(224, 50, 47, .07); border-color: rgba(224, 50, 47, .18); }
.tag.ok { color: var(--ok); background: rgba(29, 157, 85, .08); border-color: rgba(29, 157, 85, .2); }

/* ---------------- 凭据视图 ---------------- */
.creds { padding: 16px 18px 24px; overflow: auto; flex: 1; }
.cred-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(258px, 1fr)); gap: 14px; }
.cred {
  background: var(--panel-solid); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 0;
  overflow: hidden;
}
.cred-h { display: flex; align-items: center; gap: 8px; padding: 13px 15px 11px; border-bottom: 1px solid var(--line); }
.cred-h b { font-size: 13px; font-weight: 600; }
.cred-h .grow { margin-left: auto; }
.cred-b { padding: 13px 15px 15px; display: flex; flex-direction: column; gap: 10px; }
.cred-b label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--sub); }
.cred-b input {
  padding: 6px 9px; font-size: 12px; font-family: var(--num);
  border: 1px solid var(--line-strong); border-radius: var(--radius-xs);
  background: #fdfdfd; color: var(--text);
}
.cred-b .row { display: flex; align-items: center; gap: 8px; }
.cred-b .btn { white-space: nowrap; flex: 0 0 auto; }
.note {
  font-size: 11.5px; color: var(--sub); line-height: 1.7;
  background: rgba(0, 113, 227, .04); border: 1px solid rgba(0, 113, 227, .1);
  border-radius: var(--radius-sm); padding: 11px 13px;
}
.note b { color: var(--text-2); font-weight: 550; }
.note ol { margin: 6px 0 0; padding-left: 18px; }
.note li { margin: 2px 0; }

/* ---------------- 留痕 ---------------- */
.logs { padding: 14px 18px 0; flex: 1; min-height: 0; display: flex; flex-direction: column; }

.hint { font-size: 11px; color: var(--sub-2); }
.mono { font-family: var(--num); }

@media (max-width: 1000px) {
  .sidebar { display: none; }
  .patrol { grid-template-columns: minmax(0, 1fr); }
}
