/* XW 管理后台设计系统 */
:root {
  --bg: #0b0e14;
  --panel: #11151d;
  --panel-2: #151a24;
  --panel-3: #1a2130;
  --border: #232a38;
  --border-soft: #1c2330;
  --text: #e6eaf2;
  --muted: #8b94a7;
  --muted-2: #6b7487;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --teal: #22c1c3;
  --ok: #35c46f;
  --ok-soft: rgba(53, 196, 111, 0.14);
  --warn: #f0a92e;
  --warn-soft: rgba(240, 169, 46, 0.14);
  --crit: #f2555a;
  --crit-soft: rgba(242, 85, 90, 0.14);
  --info: #58a6ff;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  --radius: 8px;
  --sidebar-w: 216px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a3342; border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 布局 ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; }
.brand svg { flex: none; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.brand-sub { color: var(--muted-2); font-size: 11px; margin-top: -2px; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-title { color: var(--muted-2); font-size: 11px; padding: 12px 10px 4px; letter-spacing: .06em; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: 6px;
  color: var(--muted); cursor: pointer; user-select: none;
  border: 1px solid transparent;
}
.nav-item svg { width: 16px; height: 16px; flex: none; opacity: .9; }
.nav-item:hover { color: var(--text); background: var(--panel-2); }
.nav-item.active { color: var(--text); background: var(--accent-soft); border-color: rgba(79,140,255,.25); }
.nav-item .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.user-box { display: flex; align-items: center; gap: 9px; padding: 6px 8px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #3b6fd8, #2f9ea6);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff; flex: none;
}
.user-name { font-size: 13px; }
.user-role { font-size: 11px; color: var(--muted-2); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; min-height: 56px;
  background: rgba(11, 14, 20, .88); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.page-title { font-size: 16px; font-weight: 650; }
.page-sub { color: var(--muted-2); font-size: 12px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.content { padding: 18px 20px 40px; max-width: 1500px; width: 100%; margin: 0 auto; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.card-title { font-size: 13.5px; font-weight: 650; white-space: nowrap; }
.card-title small { color: var(--muted-2); font-weight: 400; margin-left: 6px; }
.card-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.small { font-size: 12px; }
.mono-num { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-3); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 11px; font-size: 12.5px; cursor: pointer;
  transition: background .12s, border-color .12s, opacity .12s;
  white-space: nowrap;
}
.btn:hover { background: #202838; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }
.btn.primary { background: #2f6fe0; border-color: #3d7ce8; color: #fff; }
.btn.primary:hover { background: #3a7cf0; }
.btn.danger { background: rgba(242,85,90,.14); border-color: rgba(242,85,90,.45); color: #ff8d91; }
.btn.danger:hover { background: rgba(242,85,90,.24); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn.icon { padding: 5px 7px; }
.btn-group { display: inline-flex; gap: 6px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 20px; padding: 1.5px 9px; font-size: 11.5px; font-weight: 550;
  border: 1px solid transparent; white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: #5fd58f; background: var(--ok-soft); border-color: rgba(53,196,111,.3); }
.pill.warn { color: #f5bd5e; background: var(--warn-soft); border-color: rgba(240,169,46,.3); }
.pill.crit { color: #ff8388; background: var(--crit-soft); border-color: rgba(242,85,90,.35); }
.pill.info { color: #7fb3ff; background: var(--accent-soft); border-color: rgba(79,140,255,.3); }
.pill.muted { color: var(--muted); background: rgba(139,148,167,.1); border-color: rgba(139,148,167,.22); }
.pill.teal { color: #55d6d8; background: rgba(34,193,195,.12); border-color: rgba(34,193,195,.3); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--border-soft);
  border-radius: 6px; padding: 2px 8px; font-size: 12px; color: var(--muted);
}
.chip b { color: var(--text); font-weight: 600; }

.progress { height: 6px; border-radius: 4px; background: #1d2432; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 4px; background: var(--accent); transition: width .35s ease; }
.progress.ok > i { background: var(--ok); }
.progress.warn > i { background: var(--warn); }
.progress.crit > i { background: var(--crit); }

table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: 6px; }
table.data th {
  text-align: left; color: var(--muted-2); font-weight: 550; font-size: 11.5px;
  padding: 7px 10px; border-bottom: 1px solid var(--border);
  background: var(--panel-2); position: sticky; top: 0; z-index: 2;
  letter-spacing: .02em;
}
table.data td { padding: 6px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: rgba(79,140,255,.05); }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data td.num { font-family: var(--mono); }

.input, .select, textarea.input {
  background: #0e1219; color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; font-size: 13px; outline: none; font-family: inherit;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--muted-2); }
.select { appearance: none; padding-right: 26px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b94a7' fill='none' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; }
textarea.input { width: 100%; min-height: 120px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12.5px; color: var(--muted); }
.field .hint { font-size: 11.5px; color: var(--muted-2); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab {
  padding: 7px 13px; color: var(--muted); cursor: pointer; font-size: 13px;
  border-bottom: 2px solid transparent; white-space: nowrap; user-select: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.stat { display: flex; flex-direction: column; gap: 3px; }
.stat-label { color: var(--muted-2); font-size: 11.5px; }
.stat-value { font-size: 21px; font-weight: 650; font-family: var(--mono); letter-spacing: -0.3px; }
.stat-value small { font-size: 12px; color: var(--muted-2); font-weight: 400; margin-left: 4px; }
.stat-sub { color: var(--muted-2); font-size: 11.5px; }

.node-card { cursor: pointer; transition: border-color .15s, transform .15s; }
.node-card:hover { border-color: #31405a; transform: translateY(-1px); }
.node-card.offline { border-color: rgba(242,85,90,.35); }
.node-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.node-flag {
  width: 36px; height: 36px; border-radius: 7px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-3); border: 1px solid var(--border);
  font-weight: 700; font-size: 12px; color: var(--muted); letter-spacing: .03em;
}
.node-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.node-metric { display: flex; flex-direction: column; gap: 4px; }
.node-metric .k { color: var(--muted-2); font-size: 11px; display: flex; justify-content: space-between; }
.node-metric .k b { color: var(--muted); font-weight: 550; font-family: var(--mono); }

.alert-banner {
  display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid rgba(242,85,90,.4); background: rgba(242,85,90,.08);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px;
}
.alert-banner.warn { border-color: rgba(240,169,46,.4); background: rgba(240,169,46,.07); }
.alert-banner svg { flex: none; margin-top: 2px; }

.toasts { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; box-shadow: var(--shadow); font-size: 13px;
  animation: toast-in .18s ease; display: flex; gap: 8px; align-items: flex-start;
}
.toast.ok { border-color: rgba(53,196,111,.4); }
.toast.err { border-color: rgba(242,85,90,.5); }
.toast.warn { border-color: rgba(240,169,46,.45); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(5, 7, 11, .66); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px;
  overflow-y: auto; animation: fade-in .12s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); width: 100%; max-width: 560px; animation: modal-in .14s ease;
}
.modal.wide { max-width: 860px; }
.modal.xwide { max-width: 1100px; }
.modal-head { display: flex; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.modal-title { font-weight: 650; font-size: 14px; }
.modal-x { margin-left: auto; cursor: pointer; color: var(--muted); border: none; background: none; font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 5px; }
.modal-x:hover { background: var(--panel-3); color: var(--text); }
.modal-body { padding: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
@keyframes modal-in { from { opacity: 0; transform: translateY(-8px) scale(.99); } to { opacity: 1; transform: none; } }

.pre {
  background: #0a0d13; border: 1px solid var(--border-soft); border-radius: 6px;
  padding: 10px 12px; font-family: var(--mono); font-size: 12px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-all; max-height: 60vh; overflow: auto; margin: 0;
  color: #c8d1e0;
}
.pre.tall { max-height: 68vh; }

.sparkline { width: 100%; height: 34px; display: block; }
.chart-box { position: relative; width: 100%; }
.chart-box canvas { width: 100%; display: block; }

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background:
    radial-gradient(1000px 500px at 20% -10%, rgba(79,140,255,.09), transparent 60%),
    radial-gradient(800px 400px at 100% 110%, rgba(34,193,195,.07), transparent 60%),
    var(--bg);
}
.login-card { width: 100%; max-width: 380px; }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; justify-content: center; }
.login-logo .brand-name { font-size: 19px; }
.login-err { background: var(--crit-soft); border: 1px solid rgba(242,85,90,.4); color: #ff9c9f; border-radius: 6px; padding: 8px 12px; font-size: 12.5px; margin-bottom: 12px; display: none; }
.login-hint { text-align: center; color: var(--muted-2); font-size: 12px; margin-top: 14px; }

.term-wrap { background: #0a0d13; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.term-head { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-bottom: 1px solid var(--border-soft); background: var(--panel-2); font-size: 12px; color: var(--muted); }
.term-body { height: 62vh; min-height: 380px; padding: 6px 4px 6px 8px; }
.term-body .xterm { height: 100%; }

.file-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.breadcrumb { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; font-size: 12.5px; font-family: var(--mono); }
.breadcrumb span.crumb { cursor: pointer; color: var(--accent); padding: 2px 4px; border-radius: 4px; }
.breadcrumb span.crumb:hover { background: var(--accent-soft); }
.breadcrumb span.sep { color: var(--muted-2); }
.file-name { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.file-name:hover { color: var(--accent); }
.file-icon { flex: none; width: 16px; height: 16px; color: var(--muted); }

.empty { text-align: center; color: var(--muted-2); padding: 34px 10px; font-size: 13px; }
.empty svg { opacity: .5; margin-bottom: 8px; }
.loading { color: var(--muted-2); padding: 28px; text-align: center; font-size: 13px; }

.list-clean { list-style: none; margin: 0; padding: 0; }
.list-clean li { display: flex; align-items: center; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; }
.list-clean li:last-child { border-bottom: none; }

.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px; gap: 2px; }
.seg button { border: none; background: transparent; color: var(--muted); padding: 3px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; }
.seg button.active { background: var(--panel-3); color: var(--text); }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 12.5px; }
.kv dt { color: var(--muted-2); } .kv dd { margin: 0; }

.drawer-mask { position: fixed; inset: 0; background: rgba(5,7,11,.5); z-index: 90; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 94vw);
  background: var(--panel); border-left: 1px solid var(--border); z-index: 95;
  display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow: auto; padding: 14px 16px; }

.search-hl { background: rgba(240,169,46,.35); border-radius: 2px; }

.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.ok { background: var(--ok); box-shadow: 0 0 6px rgba(53,196,111,.7); }
.status-dot.crit { background: var(--crit); box-shadow: 0 0 6px rgba(242,85,90,.7); }
.status-dot.warn { background: var(--warn); }
.status-dot.muted { background: var(--muted-2); }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 240px;
    transform: translateX(-100%); transition: transform .18s ease;
  }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: var(--shadow); }
  body.nav-open .nav-mask { display: block; }
  .nav-mask { display: none; position: fixed; inset: 0; background: rgba(5,7,11,.55); z-index: 35; }
  .menu-btn { display: inline-flex !important; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 14px 12px 40px; }
  .topbar { padding: 10px 12px; }
  .form-row { grid-template-columns: 1fr; }
  .term-body { height: 52vh; }
}
.menu-btn { display: none; }
