:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e7ebf3;
  --accent: #4f6ef7;
  --accent-soft: #eef2ff;
  --cyan: #06b6d4;
  --ok: #12b76a;
  --warn: #f59e0b;
  --danger: #e5484d;
  --sidebar: #0b1220;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -18px rgba(15, 23, 42, .25);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
svg { display: block; }

/* ---------- 表单与按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  cursor: pointer; white-space: nowrap; transition: .15s ease;
  font-weight: 500;
}
.btn:hover { border-color: #cfd8ea; background: #f8faff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #3f5ef0; border-color: #3f5ef0; }
.btn.danger { background: #fff1f1; border-color: #ffd9d9; color: var(--danger); }
.btn.danger:hover { background: #ffe7e7; }
.btn.ghost { background: transparent; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.icon-only { width: 34px; padding: 0; }
.btn.block { width: 100%; height: 42px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=email], select, textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 110, 247, .12);
}
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); }

/* ---------- 登录 ---------- */
.login-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 20% 10%, #172a4f 0%, #0b1220 45%, #070c15 100%);
  overflow: hidden;
}
.login-glow {
  position: absolute; width: 620px; height: 620px; border-radius: 50%;
  background: radial-gradient(circle, rgba(79,110,247,.35), transparent 62%);
  filter: blur(10px); top: -160px; right: -120px;
}
.login-card {
  position: relative; width: 380px; max-width: calc(100vw - 40px);
  padding: 36px 32px 26px; border-radius: 22px;
  background: rgba(255,255,255,.97); box-shadow: 0 30px 80px -20px rgba(2, 8, 23, .7);
  animation: rise .45s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.brand-mark {
  width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center;
  background: linear-gradient(135deg, #5b7cfa, #06b6d4); color: #fff;
  font-size: 26px; font-weight: 800; letter-spacing: -1px;
}
.brand-mark.small { width: 36px; height: 36px; border-radius: 11px; font-size: 18px; }
.login-card h1 { margin: 18px 0 4px; font-size: 24px; letter-spacing: -.4px; }
.login-sub { margin: 0 0 24px; color: var(--muted); font-size: 13px; }
.login-error {
  margin: -4px 0 12px; padding: 9px 12px; border-radius: 9px;
  background: #fff1f1; color: var(--danger); font-size: 13px;
}
.login-foot { margin: 20px 0 0; text-align: center; color: #94a3b8; font-size: 12px; }

/* ---------- 应用骨架 ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex: 0 0 236px; background: linear-gradient(180deg, #0c1526, #0a101c);
  color: #c7d2e6; display: flex; flex-direction: column; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.sidebar-brand strong { display: block; color: #fff; font-size: 15px; letter-spacing: .3px; }
.sidebar-brand span { display: block; color: #6b7c99; font-size: 11.5px; }
.nav { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; min-height: 0; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
  color: #9fb0cc; font-size: 13.5px; transition: .15s;
}
.nav a.sub { padding-left: 34px; font-size: 12.5px; color: #a7b6d3; }
.nav a.sub .nav-icon { width: 15px; height: 15px; opacity: .75; }
.nav a:hover { background: rgba(255,255,255,.05); color: #e2e8f5; }
.nav a.active {
  background: linear-gradient(90deg, rgba(79,110,247,.28), rgba(79,110,247,.10));
  color: #fff; box-shadow: inset 2px 0 0 var(--accent);
}
.nav-icon { display: inline-flex; opacity: .9; }
.sidebar-foot {
  margin-top: auto; display: flex; align-items: center; gap: 8px;
  padding: 12px 10px 2px; color: #5d6f8c; font-size: 12px; border-top: 1px solid rgba(255,255,255,.06);
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.online { background: var(--ok); box-shadow: 0 0 0 3px rgba(18,183,106,.18); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 68px; padding: 0 26px; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; background: rgba(244,246,251,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar h1 { margin: 0; font-size: 19px; letter-spacing: -.2px; white-space: nowrap; }
.host-pill {
  font-size: 12px; color: var(--muted); background: #fff; border: 1px solid var(--line);
  padding: 3px 10px; border-radius: 999px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 220px;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.user-chip { font-size: 13px; color: #334155; background: #fff; border: 1px solid var(--line);
  padding: 5px 12px; border-radius: 999px; white-space: nowrap; }
.view { padding: 24px 26px 60px; max-width: 1440px; width: 100%; }

/* ---------- 卡片与网格 ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 15px; letter-spacing: -.1px; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.stat-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12.5px; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.6px; margin: 6px 0 2px; }
.stat-value small { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.stat-foot { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 6px; border-radius: 999px; background: #eef1f8; overflow: hidden; margin: 10px 0 8px; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #5b7cfa, #06b6d4); transition: width .4s ease; }
.bar.warn > i { background: linear-gradient(90deg, #f59e0b, #f97316); }
.bar.danger > i { background: linear-gradient(90deg, #f87171, #e5484d); }
.metric-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.metric-row:last-child { border-bottom: 0; }
.metric { display: flex; flex-direction: column; gap: 4px; }
.metric > span { color: var(--muted); font-size: 12.5px; }
.metric > b { font-size: 24px; font-weight: 700; letter-spacing: -.5px; }
.pager { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.field.cols-2 { grid-column: span 2 / span 2; }
.field.cols-3 { grid-column: span 2 / span 2; }
/* 字段 span 默认 cols-2，避免长输入框换行
.field.cols-3 在三列 grid 中占 2 列（或显式设 3） */
.grid.cols-3 > .field.cols-3 { grid-column: span 3 / span 3; }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcff; overflow-x: auto; }
.chart-bar { flex: 1; min-width: 6px; height: 100%; display: flex; align-items: flex-end; }
.chart-bar > span { display: block; width: 100%; min-height: 2px; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, #7d96ff, #4f6ef7); }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11.5px; margin-top: 6px; }

/* ---------- 标签页与占比条 ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button {
  border: 0; border-bottom: 2px solid transparent; background: transparent;
  padding: 9px 14px; border-radius: 10px 10px 0 0; cursor: pointer;
  color: var(--muted); font-size: 13px; font-weight: 600; transition: .15s ease;
}
.tabs button:hover { color: var(--accent); background: #f8faff; }
.tabs button.active { color: var(--accent); background: var(--accent-soft); border-bottom-color: var(--accent); }
.share-row { margin-bottom: 10px; }
.share-row:last-child { margin-bottom: 0; }
.share-label { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; margin-bottom: 5px; }
.share-track { height: 7px; border-radius: 999px; background: #eef2f9; overflow: hidden; }
.share-track > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #7d96ff, #4f6ef7); }
.share-track > span.ok { background: linear-gradient(90deg, #34d399, #12b76a); }
.share-track > span.warn { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.share-track > span.crit { background: linear-gradient(90deg, #f87171, #e5484d); }
.share-cell { display: flex; align-items: center; gap: 8px; }
.share-cell .share-track { flex: 1; min-width: 80px; }
.metric-row span:first-child { color: var(--muted); }
.metric-row span:last-child { font-weight: 600; }

/* ---------- 表格 ---------- */
.table-wrap { overflow: auto; border-radius: 12px; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 12px;
  padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
  background: #fafcff; position: sticky; top: 0;
}
.table td { padding: 10px 12px; border-bottom: 1px solid #f1f4fa; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fafbff; }
.table .mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 12.3px; }
.table .nowrap { white-space: nowrap; }
.table .right { text-align: right; }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.table .name-cell { display: flex; align-items: center; gap: 9px; min-width: 0; }
.table .name-cell .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 460px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- 徽标 ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: #f1f5f9; color: #475569; white-space: nowrap;
}
.chip.ok { background: #e8f8ef; color: #0f9d58; }
.chip.notice { background: #eef2ff; color: #4f6ef7; }
.chip.warn { background: #fff6e5; color: #b45309; }
.chip.crit { background: #fff0f0; color: #d13a3f; }
.chip.error { background: #f3e8ff; color: #7e22ce; }
.chip.muted { background: #f1f5f9; color: #64748b; }
.tag { display: inline-block; padding: 0 7px; border-radius: 6px; background: #eef2ff; color: #4f6ef7; font-size: 11.5px; font-weight: 600; }
.type-badge {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  font-size: 9.5px; font-weight: 700; letter-spacing: .3px; flex: 0 0 26px;
}
.type-badge.dir { background: #eef2ff; color: #4f6ef7; }
.type-badge.file { background: #f1f5f9; color: #64748b; }
.type-badge.link { background: #ecfeff; color: #0891b2; }
.type-badge.other { background: #faf5ff; color: #9333ea; }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 13px; }
.crumbs a { color: var(--muted); padding: 2px 6px; border-radius: 6px; }
.crumbs a:hover { background: #eef2ff; color: var(--accent); }
.crumbs .sep { color: #cbd5e1; }
.crumbs .cur { color: var(--ink); font-weight: 600; padding: 2px 6px; }
.path-input { width: 260px; height: 32px; font-family: monospace; font-size: 12.5px; }
.select-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 12px;
  background: var(--accent-soft); border: 1px solid #dfe6ff; border-radius: 10px; font-size: 13px;
}
.empty {
  padding: 42px 16px; text-align: center; color: #94a3b8; font-size: 13px;
  border: 1px dashed var(--line); border-radius: 12px;
}
.hint { color: var(--muted); font-size: 12.5px; }
.notice-box {
  padding: 10px 14px; border-radius: 10px; background: #fff8e8; border: 1px solid #ffe7b8;
  color: #92580a; font-size: 12.5px; margin-bottom: 14px;
}
.form-grid { display: grid; grid-template-columns: 1.2fr 1.4fr .9fr auto; gap: 12px; align-items: end; }
.form-grid label { display: block; }
.form-grid label > span { display: block; margin-bottom: 6px; font-size: 12.5px; color: var(--muted); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center;
  padding: 7vh 16px 24px; background: rgba(8, 15, 30, .45); backdrop-filter: blur(3px);
  animation: fade .18s ease; overflow: auto;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal {
  width: 560px; max-width: 100%; background: #fff; border-radius: 18px;
  box-shadow: 0 40px 90px -30px rgba(2, 8, 23, .55); animation: rise .22s ease;
  display: flex; flex-direction: column; max-height: 86vh;
}
.modal.wide { width: 860px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 20px 12px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 15.5px; }
.modal-close {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
}
.modal-close:hover { background: #f1f5f9; color: var(--ink); }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }
.modal pre {
  margin: 0; padding: 14px; border-radius: 10px; background: #0b1220; color: #c9d6ea;
  font: 12px/1.7 "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; word-break: break-all;
  max-height: 52vh; overflow: auto;
}
.modal textarea { font: 12.5px/1.65 "SFMono-Regular", Consolas, monospace; min-height: 340px; }
.modal .form-note { color: var(--muted); font-size: 12px; margin: -6px 0 14px; }

/* ---------- Toast ---------- */
.toast-root { position: fixed; right: 20px; bottom: 22px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 200px; max-width: 380px; padding: 10px 14px; border-radius: 10px;
  background: #0f172a; color: #e6edf9; font-size: 13px; box-shadow: 0 14px 34px -12px rgba(2,8,23,.5);
  animation: rise .2s ease; word-break: break-word;
}
.toast.ok { background: #0e3b2a; color: #baf5d6; }
.toast.err { background: #451619; color: #ffd5d7; }
.toast.warn { background: #4a3407; color: #ffe9b8; }

/* ---------- 响应式 ---------- */
@media (max-width: 1180px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static; padding: 12px 14px;
    flex-direction: row; align-items: center; gap: 10px; overflow-x: auto;
  }
  .sidebar-brand { padding: 0 6px 0 0; }
  .sidebar-brand div:last-child { display: none; }
  .nav { flex-direction: row; gap: 2px; }
  .nav a { padding: 8px 10px; font-size: 12.5px; white-space: nowrap; }
  .nav a.active { box-shadow: inset 0 -2px 0 var(--accent); background: rgba(79,110,247,.16); }
  .nav-icon { display: none; }
  .sidebar-foot { display: none; }
  .topbar { height: auto; padding: 12px 16px; flex-wrap: wrap; }
  .topbar h1 { font-size: 17px; }
  .host-pill { max-width: 150px; }
  .view { padding: 16px 16px 48px; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2, .form-grid { grid-template-columns: 1fr; }
  .path-input { width: 100%; }
  .table .name-cell .nm { max-width: 180px; }
  .user-chip { display: none; }
}
