:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --text: #111827;
  --muted: #5b6472;
  --line: #e5e7eb;
  --brand: #1d5bd8;
  --brand-weak: #edf3ff;
  --ok: #0f7a34;
  --ok-solid: #16a34a;
  --ok-weak: #e6f6eb;
  --warn: #a14a00;
  --warn-weak: #fff3e0;
  --bad: #c01818;
  --bad-weak: #fdecec;
  --gray-weak: #f3f4f6;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14.5px;
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 216px; background: #fff; color: var(--text); flex-shrink: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.sidebar .brand { padding: 18px 20px; font-weight: 700; color: var(--brand); font-size: 16px; border-bottom: 1px solid var(--line); line-height: 1.3; }
.sidebar .brand small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 3px; }
.sidebar nav { padding: 10px 8px; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.sidebar .nav-sep { font-size: 11.5px; color: #9ca3af; padding: 10px 12px 4px; font-weight: 600; }
.sidebar nav a { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; color: #374151; border-radius: 8px; font-weight: 500; }
.sidebar nav a:hover { background: var(--gray-weak); color: var(--text); }
.sidebar nav a.active { background: var(--brand-weak); color: var(--brand); font-weight: 600; }
.sidebar .who { padding: 14px 18px; border-top: 1px solid var(--line); font-size: 13px; background: #fafbfc; }
.sidebar .who button { margin-top: 8px; width: 100%; justify-content: center; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #f7f8fa; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 18px; font-weight: 700; }
.content { padding: 20px 24px 40px; max-width: 1500px; }

/* 新手四步引导栏 */
.guide-box { background: #fff; border: 1px solid #cfe0ff; border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px; box-shadow: 0 2px 8px rgba(29, 91, 216, 0.04); }
.guide-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.guide-head b { font-size: 15px; color: #1e3a8a; }
.steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.step-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: #fafbfd; display: flex; flex-direction: column; gap: 6px; }
.step-card.done { border-color: #bbf7d0; background: #f4fdf7; }
.step-card.todo { border-color: #93c5fd; background: #f5f9ff; }
.step-top { display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: 14px; }
.step-desc { font-size: 12.5px; color: var(--muted); line-height: 1.5; flex: 1; }
.step-act { margin-top: 4px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 18px; }
.card h3 { margin: 0 0 10px; font-size: 14px; color: #374151; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.card .big { font-size: 26px; font-weight: 700; }
.card .rows { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; font-size: 13.5px; }
.card .rows span:nth-child(even) { text-align: right; font-weight: 600; }
.card.plan { border-color: #c9d8f8; background: #f7faff; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; transition: border-color .15s, transform .1s; }
.kpi:hover { border-color: var(--brand); transform: translateY(-1px); }
.kpi .n { font-size: 26px; font-weight: 700; line-height: 1.2; }
.kpi .l { color: var(--muted); font-size: 13px; margin-top: 4px; }
.kpi.bad .n { color: var(--bad); }
.kpi.ok .n { color: var(--ok); }
.kpi.warn .n { color: var(--warn); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 15.5px; font-weight: 600; }
.panel-body { padding: 16px 18px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar .spacer { flex: 1; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--line); background: #fff; padding: 6px 14px; border-radius: 999px; cursor: pointer; font-size: 13.5px; }
.tabs button:hover { border-color: #b9c6dc; }
.tabs button.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

.big-tabs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.big-tabs button { border: 1px solid var(--line); background: #fff; padding: 10px 18px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.big-tabs button.active { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(29,91,216,.2); }

.btn { display: inline-flex; align-items: center; gap: 5px; border: 1px solid #d1d5db; background: #fff; padding: 7px 13px; border-radius: 7px; cursor: pointer; white-space: nowrap; font-weight: 500; }
.btn:hover { background: #f9fafb; border-color: #9ca3af; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.ok { background: var(--ok-solid); border-color: var(--ok-solid); color: #fff; }
.btn.danger { color: var(--bad); border-color: #f3c4c4; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { border: none; background: none; color: var(--brand); cursor: pointer; padding: 2px 5px; font-weight: 500; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--bad); }

input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  border: 1px solid #d1d5db; border-radius: 7px; padding: 7px 10px; background: #fff; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfd3fb; border-color: var(--brand); }
textarea { width: 100%; min-height: 120px; resize: vertical; font-family: inherit; line-height: 1.5; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-weight: 600; color: #4b5563; background: #f8f9fb; font-size: 13px; white-space: nowrap; position: sticky; top: 0; z-index: 1; }
tbody tr:hover { background: #f7faff; }
td.num, th.num { text-align: right; }
.table-wrap { overflow: auto; max-height: calc(100vh - 250px); }
.empty { padding: 42px 20px; text-align: center; color: var(--muted); line-height: 1.7; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--gray-weak); color: var(--muted); }
.badge.ok { background: var(--ok-weak); color: var(--ok); }
.badge.warn { background: var(--warn-weak); color: var(--warn); }
.badge.bad { background: var(--bad-weak); color: var(--bad); }
.badge.info { background: var(--brand-weak); color: var(--brand); }
.badge.solid-ok { background: var(--ok-solid); color: #fff; }
.badge.solid-bad { background: #dc2626; color: #fff; }
.badge.solid-warn { background: #d97706; color: #fff; }

.pstate { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 6px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.pstate.ok { background: var(--ok-solid); color: #fff; }
.pstate.bad { background: #dc2626; color: #fff; }
.pstate.warn { background: #f59e0b; color: #fff; }
.pstate.unknown { background: var(--gray-weak); color: var(--muted); }
.orange { color: var(--warn); }
.direct-card { margin-top: 16px; }
.direct-card .panel-head { justify-content: space-between; }
.direct-body { padding: 12px 16px 14px; display: grid; gap: 6px; line-height: 1.6; }
tr.proxy-ok td:first-child { box-shadow: inset 4px 0 0 var(--ok-solid); }
tr.proxy-bad td:first-child { box-shadow: inset 4px 0 0 #dc2626; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: #9ca3af; vertical-align: middle; }
.dot.ok { background: var(--ok-solid); }
.dot.bad { background: #dc2626; }
.dot.warn { background: #d97706; }

.progress { display: inline-block; min-width: 44px; font-weight: 600; }
.progress.done { color: var(--ok); }
.progress.part { color: var(--warn); }
.progress.none { color: var(--muted); }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-row label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; cursor: pointer; }
.plan-box { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; background: #fbfcfe; }
.counter { font-size: 12px; color: var(--muted); text-align: right; }
.counter.over { color: var(--bad); font-weight: 600; }

details.adv-box { margin-top: 16px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfc; }
details.adv-box > summary { padding: 12px 16px; cursor: pointer; font-weight: 600; color: #374151; user-select: none; }
details.adv-box > .adv-body { padding: 14px 16px; border-top: 1px solid var(--line); background: #fff; border-radius: 0 0 8px 8px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.ellipsis { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.red { color: var(--bad); }
.green { color: var(--ok); }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); }

.modal-mask { position: fixed; inset: 0; background: rgba(17, 24, 39, .45); display: flex; align-items: flex-start; justify-content: center; padding: 50px 16px; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal.wide { max-width: 740px; }
.modal header { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 16px; display: flex; justify-content: space-between; align-items: center; }
.modal .body { padding: 18px; }
.modal footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row label { font-weight: 600; font-size: 13.5px; }
.form-row .hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }

.toast-box { position: fixed; top: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #111827; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 420px; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.tpl { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: #fff; display: flex; flex-direction: column; gap: 8px; }
.tpl pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: inherit; max-height: 160px; overflow: auto; background: #f9fafb; padding: 10px; border-radius: 6px; }
.tpl img, .tpl video { max-width: 100%; max-height: 200px; object-fit: contain; border-radius: 6px; background: #f3f4f6; }

.notice { background: var(--warn-weak); color: var(--warn); border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; line-height: 1.5; }
.notice.info { background: var(--brand-weak); color: #1e40af; }
.notice.ok { background: var(--ok-weak); color: var(--ok); }

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #f7f8fa; }
.login-box { width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 32px; box-shadow: 0 8px 30px rgba(17, 24, 39, .06); }
.login-box h1 { font-size: 19px; margin: 0 0 6px; }
.login-box .sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.login-box input { width: 100%; }
.login-box .btn { width: 100%; justify-content: center; margin-top: 6px; padding: 10px; font-size: 15px; }
.err { color: var(--bad); min-height: 20px; margin-top: 10px; font-size: 13px; }
