:root {
  --bg: #0a0f15;
  --bg-soft: #0e151e;
  --panel: #111a24;
  --panel-2: #16212d;
  --line: #23313f;
  --line-soft: #1b2733;
  --text: #e6edf5;
  --muted: #8b9bad;
  --accent: #52d3c5;
  --accent-2: #7cc4ff;
  --ok: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --bg-glow-1: rgba(82, 211, 197, 0.08);
  --bg-glow-2: rgba(124, 196, 255, 0.06);
  --topbar-bg: rgba(10, 15, 21, 0.82);
  --sidebar-bg: rgba(14, 21, 30, 0.55);
  --card-grad-a: rgba(22, 33, 45, 0.78);
  --card-grad-b: rgba(17, 26, 36, 0.88);
  --login-grad-a: rgba(22, 33, 45, 0.92);
  --login-grad-b: rgba(17, 26, 36, 0.96);
  --btn-hover-line: #344a5d;
  --btn-hover-bg: #1b2937;
  --meter-bg: #0b1219;
  --code-bg: #070c11;
  --code-text: #c7f9f0;
  --pre-text: #cbd5e1;
  --chan-bg: rgba(9, 14, 20, 0.5);
  --track-bg: rgba(35, 49, 63, 0.75);
  --modal-mask: rgba(2, 6, 10, 0.72);
  --toast-bg: #18352f;
  --toast-text: #d1fae5;
  --toast-err-bg: #3a1d22;
  --toast-err-text: #fecaca;
  --skeleton-a: #111a24;
  --skeleton-b: #182432;
  --ok-text: #bbf7d0;
  --bad-text: #fecaca;
  --warn-text: #fde68a;
  --chart-bg: rgba(7, 12, 17, 0.55);
  --chart-grid: rgba(35, 49, 63, 0.65);
  --chart-axis: #64748b;
  --chart-cursor: rgba(139, 155, 173, 0.75);
  --chart-dot-ring: rgba(7, 12, 17, 0.9);
  --chart-tip-bg: rgba(9, 14, 20, 0.94);
  --chart-tip-line: rgba(82, 211, 197, 0.4);
  --chart-tip-text: #e6edf5;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f3f6fa;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-2: #eef2f7;
  --line: #d7e0ea;
  --line-soft: #e6ecf3;
  --text: #16232e;
  --muted: #5b6b7c;
  --accent: #0e9488;
  --accent-2: #2563eb;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #dc2626;
  --shadow: 0 16px 40px rgba(16, 34, 51, 0.12);
  --bg-glow-1: rgba(14, 148, 136, 0.08);
  --bg-glow-2: rgba(37, 99, 235, 0.07);
  --topbar-bg: rgba(255, 255, 255, 0.86);
  --sidebar-bg: rgba(255, 255, 255, 0.68);
  --card-grad-a: #ffffff;
  --card-grad-b: #f7fafc;
  --login-grad-a: #ffffff;
  --login-grad-b: #f6f9fc;
  --btn-hover-line: #b8c6d6;
  --btn-hover-bg: #e8eef6;
  --meter-bg: #e3eaf2;
  --code-bg: #f5f8fb;
  --code-text: #0f5f57;
  --pre-text: #22303c;
  --chan-bg: #f7fafc;
  --track-bg: #e3eaf2;
  --modal-mask: rgba(20, 34, 48, 0.42);
  --toast-bg: #eafaf3;
  --toast-text: #0f5132;
  --toast-err-bg: #fdecec;
  --toast-err-text: #991b1b;
  --skeleton-a: #e9eef5;
  --skeleton-b: #f5f8fb;
  --ok-text: #15803d;
  --bad-text: #b91c1c;
  --warn-text: #92400e;
  --chart-bg: #fbfdff;
  --chart-grid: rgba(148, 166, 184, 0.35);
  --chart-axis: #6b7c8f;
  --chart-cursor: rgba(23, 43, 63, 0.55);
  --chart-dot-ring: #ffffff;
  --chart-tip-bg: rgba(255, 255, 255, 0.97);
  --chart-tip-line: rgba(14, 148, 136, 0.45);
  --chart-tip-text: #16232e;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(1200px 700px at 85% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(900px 600px at -10% 20%, var(--bg-glow-2), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 14px/1.6 "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--muted); letter-spacing: 0.04em; }

.brand-lockup { display: flex; align-items: center; gap: 14px; }
.brand-lockup h1 { font-size: 24px; letter-spacing: 0.01em; }
.brand-lockup p { color: var(--muted); margin-top: 2px; }
.brand-lockup.small { gap: 10px; }
.brand-lockup.small strong { display: block; font-size: 14px; }
.brand-lockup.small .muted { display: block; font-size: 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(140deg, rgba(82, 211, 197, 0.22), rgba(124, 196, 255, 0.12));
  border: 1px solid rgba(82, 211, 197, 0.35);
  color: var(--accent); font-weight: 800; letter-spacing: 0.06em;
}
.small .brand-mark { width: 34px; height: 34px; border-radius: 10px; font-size: 12px; }

.login {
  min-height: 100vh; display: grid; grid-template-columns: 1.15fr 0.85fr;
  gap: 48px; align-items: center; padding: 6vw;
}
.login-visual { max-width: 620px; }
.login-lead { color: var(--muted); font-size: 16px; margin: 28px 0 20px; }
.login-points { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; color: var(--muted); }
.login-points li { padding-left: 22px; position: relative; }
.login-points li::before { content: ""; position: absolute; left: 0; top: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(82, 211, 197, 0.1); }
.login-card {
  background: linear-gradient(180deg, var(--login-grad-a), var(--login-grad-b));
  border: 1px solid var(--line); border-radius: 20px; padding: 32px;
  box-shadow: var(--shadow); width: 100%; max-width: 440px; justify-self: end;
}
.login-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.login-card h2 { font-size: 22px; margin-bottom: 6px; }
.field { display: grid; gap: 8px; margin: 22px 0; }
.field span { color: var(--muted); font-size: 12px; letter-spacing: 0.04em; }
input[type="password"], input[type="text"], input[type="search"] {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); padding: 12px 14px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus { border-color: rgba(82, 211, 197, 0.65); box-shadow: 0 0 0 3px rgba(82, 211, 197, 0.1); }
.form-error { color: var(--danger); font-size: 13px; margin-bottom: 14px; }
.login-hint { color: var(--muted); font-size: 12px; margin-top: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 10px; padding: 9px 14px; transition: 0.15s; min-height: 38px;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--btn-hover-line); background: var(--btn-hover-bg); }
.btn.primary { background: linear-gradient(180deg, #43c6b7, #2fa89b); border-color: #43c6b7; color: #061211; font-weight: 700; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(248, 113, 113, 0.45); color: var(--bad-text); background: rgba(248, 113, 113, 0.08); }
.btn.danger:hover { background: rgba(248, 113, 113, 0.16); }
.btn.small { padding: 5px 10px; min-height: 30px; font-size: 12px; border-radius: 8px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.is-busy { opacity: 0.72; }

.topbar {
  height: 68px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; border-bottom: 1px solid var(--line-soft);
  background: var(--topbar-bg); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(14px);
}
.top-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-chip {
  display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 999px;
  font-size: 11px; color: var(--muted); border: 1px solid var(--line-soft);
  background: var(--bg-soft); white-space: nowrap; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis;
}
.top-chip:empty { display: none; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px;
  padding: 5px 10px; font-size: 12px; border: 1px solid var(--line);
  color: var(--muted); background: var(--bg-soft); white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.pill.online { color: var(--ok-text); border-color: rgba(74, 222, 128, 0.3); }
.pill.online::before { background: var(--ok); box-shadow: 0 0 8px rgba(74, 222, 128, 0.8); }
.pill.offline { color: var(--bad-text); border-color: rgba(248, 113, 113, 0.35); }
.pill.offline::before { background: var(--danger); }

.shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: calc(100vh - 68px); }
.sidebar {
  border-right: 1px solid var(--line-soft); padding: 18px 12px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: var(--sidebar-bg);
}
.nav { display: grid; gap: 4px; }
.nav-item {
  text-align: left; border: 0; background: transparent; color: var(--muted);
  padding: 10px 12px; border-radius: 9px; transition: 0.15s;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: linear-gradient(90deg, rgba(82, 211, 197, 0.16), rgba(82, 211, 197, 0.04)); color: var(--accent); box-shadow: inset 2px 0 0 var(--accent); }
.sidebar-foot { display: grid; gap: 4px; font-size: 11px; padding: 10px 8px; border-top: 1px solid var(--line-soft); }
.main { padding: 26px 30px 64px; min-width: 0; }
.view { max-width: 1180px; margin: 0 auto; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
  margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h2 { font-size: 20px; letter-spacing: 0.02em; }
.page-head p { margin-top: 5px; font-size: 13px; }
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.update-note { font-size: 12px; color: var(--muted); white-space: nowrap; }
main .view-body { display: flex; flex-direction: column; gap: 16px; }
main .view-body > * { margin-top: 0; margin-bottom: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card, .panel, .proxy-card, .chart-card {
  background: linear-gradient(180deg, var(--card-grad-a), var(--card-grad-b));
  border: 1px solid var(--line); border-radius: var(--radius);
}
.stat-card { padding: 16px; min-width: 0; }
.stat-card .label { color: var(--muted); font-size: 12px; }
.stat-card .value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin-top: 6px; }
.stat-card .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.meter { height: 6px; border-radius: 99px; background: var(--meter-bg); overflow: hidden; margin-top: 12px; }
.meter > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; }
.meter > span.bar-0 { width: 0%; }
.meter > span.bar-5 { width: 5%; }
.meter > span.bar-10 { width: 10%; }
.meter > span.bar-15 { width: 15%; }
.meter > span.bar-20 { width: 20%; }
.meter > span.bar-25 { width: 25%; }
.meter > span.bar-30 { width: 30%; }
.meter > span.bar-35 { width: 35%; }
.meter > span.bar-40 { width: 40%; }
.meter > span.bar-45 { width: 45%; }
.meter > span.bar-50 { width: 50%; }
.meter > span.bar-55 { width: 55%; }
.meter > span.bar-60 { width: 60%; }
.meter > span.bar-65 { width: 65%; }
.meter > span.bar-70 { width: 70%; }
.meter > span.bar-75 { width: 75%; }
.meter > span.bar-80 { width: 80%; }
.meter > span.bar-85 { width: 85%; }
.meter > span.bar-90 { width: 90%; }
.meter > span.bar-95 { width: 95%; }
.meter > span.bar-100 { width: 100%; }
.chart-legend .dot-1 { background: #52d3c5; }
.chart-legend .dot-2 { background: #fbbf24; }
.chart-legend .dot-3 { background: #7cc4ff; }
.chart-legend .dot-4 { background: #f472b6; }
.dot-teal { background: #52d3c5; }
.dot-blue { background: #7cc4ff; }
.dot-amber { background: #fbbf24; }
.dot-pink { background: #f472b6; }
.dot-red { background: #f87171; }
html[data-theme="light"] .dot-teal { background: #0e9488; }
html[data-theme="light"] .dot-blue { background: #2563eb; }
html[data-theme="light"] .dot-amber { background: #b45309; }
html[data-theme="light"] .dot-pink { background: #be185d; }
html[data-theme="light"] .dot-red { background: #dc2626; }
.meter.warn > span { background: linear-gradient(90deg, var(--warn), #f97316); }
.meter.danger > span { background: linear-gradient(90deg, var(--danger), #ef4444); }

.overview-grid { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 16px; align-items: start; }
.panel { padding: 18px; min-width: 0; }
.panel h3 { font-size: 14px; letter-spacing: 0.03em; margin-bottom: 12px; }
.panel + .panel { margin-top: 16px; }
.stack { display: grid; gap: 16px; }
.stack > .panel + .panel { margin-top: 0; }
.dl { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px 12px; font-size: 13px; }
.dl.two { grid-template-columns: 120px minmax(0, 1fr) 120px minmax(0, 1fr); gap: 10px 16px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }

.overview-audit { margin-top: 0; }
.audit-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.audit-head .section-title { margin: 0; }
.audit-timeline { display: grid; }
.audit-line {
  display: grid; grid-template-columns: 92px minmax(0, 1fr) 140px auto;
  align-items: center; gap: 12px; padding: 9px 2px; border-top: 1px solid var(--line-soft); font-size: 12px;
}
.audit-line:first-child { border-top: 0; }
.audit-time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.audit-action { font-weight: 600; overflow-wrap: anywhere; }
.audit-ip { color: var(--muted); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.service-list, .audit-list, .backup-list { display: grid; gap: 10px; }
.service-card, .backup-row, .audit-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line-soft); border-radius: 11px; background: var(--bg-soft);
}
.service-card .name { font-weight: 600; }
.service-card .desc, .backup-row .meta, .audit-row .meta { color: var(--muted); font-size: 12px; }
.service-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; border-radius: 999px; padding: 3px 9px; border: 1px solid var(--line); color: var(--muted); }
.status-pill.ok { color: var(--ok-text); border-color: rgba(74, 222, 128, 0.3); background: rgba(74, 222, 128, 0.07); }
.status-pill.bad { color: var(--bad-text); border-color: rgba(248, 113, 113, 0.3); background: rgba(248, 113, 113, 0.07); }
.status-pill.warn { color: var(--warn-text); border-color: rgba(251, 191, 36, 0.3); background: rgba(251, 191, 36, 0.07); }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 11px; border: 1px solid rgba(251, 191, 36, 0.28); background: rgba(251, 191, 36, 0.06); color: var(--warn-text); font-size: 13px; margin-bottom: 14px; }
.alert.bad { border-color: rgba(248, 113, 113, 0.3); background: rgba(248, 113, 113, 0.07); color: var(--bad-text); }
.alert.good { border-color: rgba(74, 222, 128, 0.28); background: rgba(74, 222, 128, 0.06); color: var(--ok-text); }

.proxy-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.proxy-card { padding: 16px; display: grid; gap: 12px; }
.proxy-card .proxy-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.proxy-card h3 { margin: 0; font-size: 14px; }
.proxy-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; font-size: 12px; color: var(--muted); }
.proxy-stats b { color: var(--text); font-weight: 600; display: block; font-size: 14px; }
.proxy-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.range-bar { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.range { border: 0; background: transparent; color: var(--muted); padding: 7px 12px; font-size: 12px; }
.range.active { background: rgba(82, 211, 197, 0.14); color: var(--accent); }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-card { padding: 16px; }
.chart-card h3 { margin: 0 0 4px; font-size: 13px; }
.chart-card .chart-sub { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.chart-canvas { width: 100%; height: 180px; display: block; cursor: crosshair; }
.chart-legend { display: flex; gap: 14px; color: var(--muted); font-size: 11px; margin-top: 8px; flex-wrap: wrap; }
.chart-legend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }

.chan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.chan-card { border: 1px solid var(--line-soft); border-radius: 11px; padding: 12px; background: var(--chan-bg); }
.chan-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 12px; margin-bottom: 6px; }
.chan-head strong { font-size: 13px; font-weight: 600; color: var(--text); }
.chan-canvas { width: 100%; height: 110px; display: block; cursor: crosshair; }

.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }
.kv-cell { font-size: 12px; color: var(--muted); display: flex; align-items: baseline; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line-soft); padding-bottom: 6px; }
.kv-cell b { color: var(--text); font-weight: 600; font-size: 14px; }

.lat-list { display: grid; gap: 5px; }
.lat-row { display: grid; grid-template-columns: 62px minmax(0, 1fr) 46px; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.lat-label { white-space: nowrap; }
.lat-track { height: 8px; border-radius: 4px; background: var(--track-bg); overflow: hidden; display: block; }
.lat-fill { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, rgba(82, 211, 197, 0.55), var(--accent)); }
.lat-count { text-align: right; }
.hf-0 { width: 0%; }
.hf-5 { width: 5%; }
.hf-10 { width: 10%; }
.hf-15 { width: 15%; }
.hf-20 { width: 20%; }
.hf-25 { width: 25%; }
.hf-30 { width: 30%; }
.hf-35 { width: 35%; }
.hf-40 { width: 40%; }
.hf-45 { width: 45%; }
.hf-50 { width: 50%; }
.hf-55 { width: 55%; }
.hf-60 { width: 60%; }
.hf-65 { width: 65%; }
.hf-70 { width: 70%; }
.hf-75 { width: 75%; }
.hf-80 { width: 80%; }
.hf-85 { width: 85%; }
.hf-90 { width: 90%; }
.hf-95 { width: 95%; }
.hf-100 { width: 100%; }

.target-list { display: grid; gap: 6px; }
.target-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line-soft); padding-bottom: 5px; }
.target-name { color: var(--accent-2); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 62%; }

.proxy-summary { display: grid; gap: 4px; font-size: 12px; }
.proxy-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.proxy-sub h4 { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.service-pills { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: 11px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 520px; }
.data-table th, .data-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.data-table th { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--bg-soft); }
.data-table tr:last-child td { border-bottom: 0; }
.data-table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table.right-num th.num, .data-table.right-num td.num { text-align: right; }

.diag-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.diag-head h3 { margin: 0; }
.diag-list { display: grid; gap: 10px; }
.diag-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 14px; border: 1px solid var(--line-soft); border-radius: 11px; background: var(--bg-soft);
}
.diag-item .name { font-weight: 600; font-size: 13px; }
.diag-item .desc { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.diag-hint { margin-top: 12px; font-size: 12px; }
.command-row { display: grid; gap: 6px; margin-bottom: 12px; }
.command-label { font-size: 12px; color: var(--muted); }
.copy-sink { position: fixed; left: -9999px; top: 0; opacity: 0; }

.toolbar { display: flex; gap: 8px; align-items: stretch; flex: 0 0 auto; }
.toolbar input { min-width: 220px; flex: 1 1 auto; height: 44px; }
.toolbar .btn { flex: 0 0 auto; min-height: 44px; padding: 0 16px; }
.command-box { display: flex; gap: 8px; align-items: flex-start; }
.command-box code {
  flex: 1; display: block; background: var(--code-bg); border: 1px solid var(--line);
  border-radius: 9px; padding: 10px 12px; color: var(--code-text); font: 12px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
  overflow-wrap: anywhere; white-space: pre-wrap;
}
.config-view { background: var(--code-bg); border: 1px solid var(--line); border-radius: 11px; padding: 14px; overflow: auto; max-height: 420px; }
.config-view pre { margin: 0; font: 12px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--pre-text); }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: stretch; }
.settings-grid .span-2 { grid-column: 1 / -1; }
.settings-grid > .panel { display: flex; flex-direction: column; }
.settings-grid > .panel > form { display: flex; flex-direction: column; flex: 1; }
.settings-grid > .panel > form .form-actions,
.settings-grid > .panel > .form-actions,
.settings-grid > .panel > .btn:last-child { margin-top: auto; }
.section-title { font-size: 14px; margin-bottom: 12px; }
.form-grid { display: grid; gap: 12px; }
.form-grid label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
.form-grid input, .form-grid select { margin: 0; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }

.modal { position: fixed; inset: 0; z-index: 50; background: var(--modal-mask); display: grid; place-items: center; padding: 20px; }
.modal-card { width: min(760px, 100%); max-height: min(80vh, 720px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line-soft); position: sticky; top: 0; background: var(--panel); }
.modal-head h3 { font-size: 15px; }
.modal-body { padding: 18px; }
.modal-body pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.6 ui-monospace, Consolas, monospace; color: var(--pre-text); background: var(--code-bg); border: 1px solid var(--line); border-radius: 9px; padding: 12px; }

.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 60; background: var(--toast-bg);
  border: 1px solid rgba(82, 211, 197, 0.35); color: var(--toast-text); padding: 12px 16px;
  border-radius: 11px; box-shadow: var(--shadow); max-width: min(420px, calc(100vw - 44px));
}
.toast.error { background: var(--toast-err-bg); border-color: rgba(248, 113, 113, 0.4); color: var(--toast-err-text); }
.skeleton { height: 90px; border-radius: 12px; background: linear-gradient(90deg, var(--skeleton-a) 25%, var(--skeleton-b) 37%, var(--skeleton-a) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; }
.empty { padding: 26px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; }

@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

.sb-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.sb-core { margin-bottom: 16px; }
.sb-core h3 { margin: 0 0 4px; }
.sb-core .stat-grid { margin: 12px 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sb-core-hint { margin: 0 0 12px; font-size: 12px; }
.sb-nodes { display: grid; gap: 14px; margin-bottom: 16px; }
.sb-node {
  background: linear-gradient(180deg, var(--card-grad-a), var(--card-grad-b));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px;
}
.sb-node-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sb-node-head h3 { margin: 0; font-size: 15px; }
.sb-node-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.sb-links { display: grid; gap: 8px; }
.sb-link {
  display: grid; grid-template-columns: 92px minmax(0, 1fr) auto auto; gap: 8px; align-items: center;
  background: var(--bg-soft); border: 1px solid var(--line-soft); border-radius: 10px; padding: 8px 10px;
}
.sb-link-label { font-size: 12px; color: var(--muted); }
.sb-link code {
  font: 11px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--code-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sb-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sb-types { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
.sb-type {
  text-align: left; border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  border-radius: 11px; padding: 11px 12px; display: grid; gap: 4px; transition: 0.15s;
}
.sb-type:hover { border-color: var(--btn-hover-line); }
.sb-type.active { border-color: rgba(82, 211, 197, 0.7); box-shadow: 0 0 0 3px rgba(82, 211, 197, 0.1); background: rgba(82, 211, 197, 0.06); }
.sb-type-name { font-weight: 600; font-size: 13px; }
.sb-type-hint { color: var(--muted); font-size: 12px; }
.sb-type-meta { color: var(--muted); font-size: 11px; }
.sb-form { margin-top: 6px; }
.sb-qr { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: 12px; margin: 12px 0; }
.sb-qr-img { width: 260px; height: 260px; image-rendering: pixelated; }
.config-editor {
  width: 100%; min-height: 320px; background: var(--code-bg); border: 1px solid var(--line); border-radius: 11px;
  color: var(--pre-text); padding: 12px; resize: vertical;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.sb-form select, .config-editor:focus { outline: none; }
.sb-form select {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); padding: 11px 12px;
}

@media (max-width: 1080px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid, .chart-grid, .settings-grid, .chan-grid, .proxy-body { grid-template-columns: 1fr; }
  .sb-types { grid-template-columns: 1fr; }
  .proxy-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .update-note { display: none; }
  .login { grid-template-columns: 1fr; padding: 30px 20px; gap: 26px; }
  .login-card { justify-self: stretch; max-width: none; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line-soft); padding: 10px; }
  .nav { grid-template-columns: repeat(9, 1fr); }
  .nav-item { min-width: 0; }
  .nav-item { text-align: center; padding: 9px 4px; font-size: 12px; }
  .sidebar-foot { display: none; }
  .main { padding: 18px 16px 50px; }
  .top-chip { max-width: 130px; }
}
@media (max-width: 560px) {
  .topbar { padding: 0 14px; height: 62px; }
  .brand-lockup.small .muted, #top-status { display: none; }
  .top-chip { max-width: 96px; font-size: 10px; padding: 3px 7px; }
  #panel-key { display: none; }
  .top-actions { gap: 6px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 13px; }
  .stat-card .value { font-size: 21px; }
  .page-head { align-items: stretch; }
  .toolbar { width: 100%; }
  .toolbar input { min-width: 0; flex: 1; }
  .dl { grid-template-columns: 96px minmax(0, 1fr); }
  .service-card, .backup-row, .audit-row { flex-direction: column; align-items: flex-start; }
  .service-actions { justify-content: flex-start; }
  .audit-line { grid-template-columns: 74px minmax(0, 1fr) auto; }
  .audit-ip { display: none; }
  .sb-link { grid-template-columns: minmax(0, 1fr) auto auto; }
  .sb-link-label { grid-column: 1 / -1; }
}
