:root {
  --bg: #f4f6f2;
  --panel: #ffffff;
  --ink: #16241f;
  --muted: #6a7c73;
  --line: #dfe5db;
  --brand: #0f5c46;
  --brand-soft: #e4efe9;
  --accent: #c7852a;
  --danger: #a4342a;
  --bar: #2f8f6d;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(22, 36, 31, .06), 0 8px 24px rgba(22, 36, 31, .05);
  --font: -apple-system, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 15px; letter-spacing: .01em; }

button, input, select { font-family: inherit; font-size: 14px; color: inherit; }

.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; margin: 4px 0 0; }
.note { margin: 12px 0 0; }

/* ---------- 登录 ---------- */
#login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 480px at 15% -10%, #dbeae2 0%, transparent 60%),
    radial-gradient(700px 420px at 100% 100%, #efe6d3 0%, transparent 55%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 28px 24px;
  box-shadow: var(--shadow);
}

.login-card .tagline { color: var(--muted); margin: 8px 0 22px; font-size: 13px; }
.login-card .foot { margin: 16px 0 0; text-align: center; }

/* ---------- 品牌 ---------- */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: .02em; }
.brand .mark {
  background: var(--brand);
  color: #fff;
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 12px;
  letter-spacing: .06em;
}
.brand .word { color: var(--ink); font-size: 15px; }
.brand.big .mark { font-size: 14px; padding: 4px 9px; }
.brand.big .word { font-size: 20px; }

/* ---------- 布局 ---------- */
#shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.side {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 22px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav button {
  text-align: left;
  background: none;
  border: 0;
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
  color: #3b4d45;
}
.side nav button:hover { background: #f1f5f1; }
.side nav button.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.who { margin-top: auto; font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.who .link { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; text-align: left; }
.pill {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 999px;
  padding: 1px 7px;
}

main { padding: 22px 26px 40px; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar .inline { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.topbar select { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

.view { display: flex; flex-direction: column; gap: 16px; }

/* ---------- 卡片与表格 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow);
}
.kpi .k { font-size: 12px; color: var(--muted); }
.kpi strong { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .u { font-size: 11px; color: var(--muted); }
.kpi.accent { background: var(--brand); border-color: var(--brand); color: #fff; }
.kpi.accent .k, .kpi.accent .u { color: #cfe6da; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data th { font-size: 12px; color: var(--muted); font-weight: 500; text-transform: none; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: #fafbf9; }
table.data .empty { color: var(--muted); text-align: center; padding: 22px 0; }

/* ---------- 图表 ---------- */
.chart svg { width: 100%; height: auto; display: block; }
.chart text.axis { font-size: 10px; fill: var(--muted); }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.field.wide { grid-column: 1 / -1; }
.field input, .field select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.form-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  font-size: 14px;
}
.btn:hover { border-color: #c7d2ca; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #0c4f3c; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; text-align: center; }
.btn.danger { color: var(--danger); border-color: #e6cdc9; background: #fff; padding: 4px 9px; font-size: 12px; }

.tools { display: flex; gap: 8px; align-items: center; }
.tools select { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  background: #fafbf9;
}
.chip strong { font-variant-numeric: tabular-nums; }

.status { font-size: 12px; border-radius: 999px; padding: 2px 9px; background: #f0f2ee; color: #44544c; }
.status.ok { background: #e1f0e8; color: #145c42; }
.status.wait { background: #faf0dd; color: #8a5c14; }
.status.bad { background: #f7e4e1; color: #932c22; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #16241f;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: var(--shadow);
  max-width: 360px;
  z-index: 50;
}
.toast.bad { background: var(--danger); }

/* ---------- 窄屏 ---------- */
@media (max-width: 960px) {
  #shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: column; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

@media print {
  .side, .topbar, .form-actions, .toast { display: none !important; }
  #shell { grid-template-columns: 1fr; }
  .card { box-shadow: none; border-color: #ccc; }
}
