:root {
  --ink: #192218;
  --muted: #6c766c;
  --paper: #f5f6f1;
  --panel: #fff;
  --green: #20734a;
  --green-dark: #173c2a;
  --lime: #dcefb7;
  --line: #e2e7df;
  --red: #a73b30;
  --amber: #a45b18;
  --amber-bg: #fbf1e5;
  --shadow: 0 12px 32px #24302012;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.55 "Microsoft YaHei", system-ui, sans-serif;
}
button, input, select { font: inherit; }
button {
  border: 0; border-radius: 8px; padding: 10px 15px;
  background: var(--green); color: #fff; font-weight: 700; cursor: pointer;
}
button:hover { filter: brightness(.94); }
button.secondary { color: var(--green); background: #e8f1e8; }
button.danger { background: var(--red); }
button:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; color: var(--lime); padding: 0; }

/* ---------- 登录 ---------- */
.login-shell {
  min-height: 100vh; display: grid; place-items: center; background: #173c2a;
}
.login-card {
  width: min(410px, 90vw); background: #fff; padding: 42px;
  border-radius: 20px; box-shadow: var(--shadow); text-align: center;
}
.brand-mark {
  margin: auto; width: 54px; height: 54px; border-radius: 16px;
  background: var(--green); color: #fff; display: grid; place-items: center;
  font-size: 26px; font-weight: 700;
}
.login-card h1 { margin: 14px 0 0; font-size: 24px; }
.login-card p { color: var(--muted); margin: 3px 0 26px; }
.login-card form { display: grid; gap: 13px; text-align: left; }
label { display: grid; gap: 6px; font-weight: 700; }
input, select {
  width: 100%; padding: 10px 11px; border: 1px solid #cfd7cd;
  border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid #a6cba7; border-color: var(--green); }
.login-error {
  margin: 2px 0 0; padding: 9px 11px; border-radius: 8px;
  background: #fff0ed; color: var(--red); font-size: 13px; font-weight: 700; text-align: center;
}

/* ---------- 框架 ---------- */
#app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
aside {
  background: #173c2a; color: #fff; padding: 22px 14px;
  display: flex; flex-direction: column;
}
.side-brand {
  display: grid; grid-template-columns: 34px 1fr; gap: 0 10px;
  align-items: center; padding: 4px 9px 27px;
}
.side-brand span {
  grid-row: span 2; display: grid; place-items: center;
  background: var(--green); border-radius: 10px; width: 34px; height: 34px;
  font-weight: 700; font-size: 17px;
}
.side-brand b { font-size: 18px; }
.side-brand small { color: #b7c9b9; }
nav { display: grid; gap: 5px; }
nav button, nav a {
  text-align: left; background: transparent; color: #d5e4d6;
  font-weight: 500; padding: 11px 13px;
  text-decoration: none; border-radius: 8px;
  font-size: 14px; display: block;
}
nav button.active, nav button:hover, nav a:hover { background: #2a6245; color: #fff; }
.side-user {
  margin-top: auto; border-top: 1px solid #467058; padding: 17px 9px 5px;
  display: grid; gap: 8px;
}
.side-user b { font-size: 13px; }
main { padding: 28px 38px; max-width: 1500px; width: 100%; margin: 0 auto; }
header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
header h1 { margin: 0; font-size: 26px; }
header p { margin: 4px 0; color: var(--muted); }
#server-status { font-size: 12px; color: var(--muted); padding: 8px; }
#server-status i {
  display: inline-block; width: 8px; height: 8px; background: #5cac55;
  border-radius: 50%; margin-right: 5px;
}

/* ---------- 卡片 ---------- */
.metric-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px;
}
.metric-grid article, .panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 13px; box-shadow: var(--shadow);
}
.metric-grid article { padding: 20px; }
.metric-grid span { color: var(--muted); display: block; }
.metric-grid strong { display: inline-block; font-size: 32px; margin-top: 7px; }
.metric-grid em { font-style: normal; color: var(--muted); margin-left: 5px; }
.metric-grid small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.panel { padding: 20px; margin-bottom: 18px; }
.panel.no-pad { padding: 0; overflow: auto; }
.panel-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel h2 { font-size: 17px; margin: 0 0 10px; }
.panel-title h2 { margin: 0; }
.muted { color: var(--muted); }
.two-col { display: grid; grid-template-columns: 1.2fr .8fr; gap: 18px; }

/* ---------- 表格 ---------- */
table { border-collapse: collapse; width: 100%; min-width: 760px; }
th, td { text-align: left; padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; background: #fafbf8; font-weight: 700; }
tbody tr:last-child td { border-bottom: 0; }
td small { color: var(--muted); }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f8faf6; }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 99px;
  font-size: 12px; font-weight: 700; background: #edf0eb; color: #586456;
}
.badge.ok { background: #dbefd8; color: #177243; }
.badge.partial { background: #fff3d6; color: #9a6812; }
.badge.short { background: #ffe5df; color: #a33b30; }
.badge.waiting { background: #fbf1e5; color: var(--amber); }

/* ---------- 工具条 ---------- */
.toolbar { display: flex; gap: 10px; margin-bottom: 15px; align-items: stretch; flex-wrap: wrap; }
.toolbar input { max-width: 260px; }
.toolbar select { max-width: 160px; }
.spacer { flex: 1; }

/* ---------- 导入 ---------- */
.dropzone {
  border: 2px dashed #b7cbbb; border-radius: 12px; min-height: 170px;
  display: grid; place-items: center; align-content: center; gap: 6px;
  margin: 18px 0; cursor: pointer; color: var(--green); text-align: center;
  transition: background .15s ease;
}
.dropzone:hover, .dropzone.over { background: #f4f8f1; }
.dropzone input { display: none; }
.dropzone b { font-size: 15px; }
.dropzone span { font-size: 12px; color: var(--muted); font-weight: 400; }

.result-card { border-left: 3px solid var(--green); padding-left: 14px; margin: 12px 0; }
.result-card.fail { border-color: var(--red); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

/* ---------- 弹层 ---------- */
#modal { position: fixed; inset: 0; background: #10231599; display: grid; place-items: center; padding: 24px; z-index: 50; }
#modal[hidden] { display: none; }
.modal-box {
  background: #fff; border-radius: 16px; width: min(1080px, 96vw);
  max-height: 90vh; overflow: auto; padding: 24px; position: relative;
}
#modal-close {
  position: absolute; right: 14px; top: 12px; background: #eef2ec;
  color: #4a564a; width: 32px; height: 32px; padding: 0; border-radius: 50%;
  font-size: 18px; line-height: 1;
}

/* ---------- 提示 ---------- */
#toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: #173c2a; color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 60;
}
#toast.show { opacity: 1; }

/* ---------- 进度条 ---------- */
.bar { height: 8px; border-radius: 99px; background: #eef2ea; overflow: hidden; min-width: 90px; }
.bar > i { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.bar.warn > i { background: #d9a441; }
.bar.bad > i { background: #c0564a; }

.pill-group { display: flex; gap: 6px; }
.pill-group button {
  padding: 4px 10px; border-radius: 999px; background: #f4f8f1;
  color: #52705b; font-size: 12px; border: 1px solid #c9dbca; font-weight: 600;
}
.pill-group button.active { background: var(--green); border-color: var(--green); color: #fff; }

/* ---------- 账号设置 ---------- */
.kv small { font-size: 12px; }
.pw-meter { height: 6px; border-radius: 99px; background: #eef2ea; overflow: hidden; margin-top: -6px; }
.pw-meter > i { display: block; height: 100%; width: 0; border-radius: 99px; background: #c0564a; transition: width .18s ease, background .18s ease; }
.small { font-size: 12px; }
.tip-box {
  margin-top: 20px; padding: 14px 16px; border-radius: 10px;
  background: #f6f9f3; border: 1px solid var(--line);
  font-size: 12.5px; color: #4d5a4c; line-height: 1.85;
}
.tip-box b { display: block; margin-bottom: 4px; color: var(--green-dark); font-size: 13px; }
.tip-box ul { margin: 0; padding-left: 16px; }
.tip-box li { margin: 2px 0; }

@media (max-width: 980px) {
  #app { grid-template-columns: 1fr; }
  aside { flex-direction: row; align-items: center; gap: 10px; padding: 10px; overflow-x: auto; }
  .side-brand { padding: 0 10px 0 0; }
  .side-brand small, .side-user { display: none; }
  nav { display: flex; gap: 4px; }
  nav button { white-space: nowrap; padding: 8px 12px; }
  main { padding: 18px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}
