:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1f2937;
  --muted: #64748b;
  --primary: #1f4e79;
  --primary-soft: #e6f1fb;
  --amber: #ba7517;
  --amber-soft: #faeeda;
  --green: #3b6d11;
  --green-soft: #eaf3de;
  --red: #a32d2d;
  --red-soft: #fcebeb;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; }
a { color: var(--primary); }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px; box-shadow: 0 8px 28px rgba(31, 78, 121, .08);
}
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 24px; }
.login-brand h1 { font-size: 19px; color: var(--primary); }
.login-brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.login-hint { min-height: 20px; margin: 12px 0 0; font-size: 12px; color: var(--red); text-align: center; }

/* ---------- 框架 ---------- */
.topbar {
  height: 56px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
}
.brand { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 500; color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.user-name { color: var(--muted); }
.role-tag { background: var(--primary-soft); color: var(--primary); padding: 3px 9px; border-radius: 20px; font-size: 12px; }
.tabs { display: flex; gap: 4px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 12px 14px; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }
.tab:hover { color: var(--primary); }
.page { padding: 18px; max-width: 1400px; margin: 0 auto; }

/* ---------- 通用组件 ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { font-size: 15px; }
.section-title { font-size: 13px; color: var(--muted); margin: 16px 0 8px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); min-width: 130px; flex: 1; }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px;
  font: 13px/1.5 inherit; color: var(--text); background: #fff; outline: none;
}
.field textarea { resize: vertical; min-height: 72px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.field.full { flex-basis: 100%; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }

.btn { border: 1px solid var(--border); background: #fff; color: var(--text); padding: 8px 14px; border-radius: 7px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #163b5c; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-block { width: 100%; padding: 10px; font-size: 14px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: var(--red); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; line-height: 1.5; }
.b-blue { background: var(--primary-soft); color: var(--primary); }
.b-amber { background: var(--amber-soft); color: var(--amber); }
.b-green { background: var(--green-soft); color: var(--green); }
.b-red { background: var(--red-soft); color: var(--red); }
.b-gray { background: #f1f5f9; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; background: #fafbfd; }
tbody tr:hover { background: #fafcff; }
tr.clickable { cursor: pointer; }
.empty { text-align: center; color: var(--muted); padding: 32px 0; font-size: 13px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.right { text-align: right; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.summary-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.summary-card .label { font-size: 12px; color: var(--muted); }
.summary-card .value { font-size: 22px; font-weight: 500; color: var(--primary); margin-top: 4px; }

/* ---------- 小计时间线 ---------- */
.timeline { border-left: 2px solid var(--border); margin-left: 8px; padding-left: 16px; }
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item::before { content: ''; position: absolute; left: -21px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.tl-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.tl-body { margin-top: 5px; font-size: 13px; white-space: pre-wrap; }
.tl-comment { margin-top: 7px; background: var(--amber-soft); color: #6b460a; padding: 8px 10px; border-radius: 7px; font-size: 12px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px 16px; font-size: 13px; }
.kv .k { color: var(--muted); font-size: 12px; }

/* ---------- 弹窗 / 提示 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .42); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 760px; max-height: 90vh; overflow-y: auto; padding: 20px; }
.modal.wide { max-width: 940px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h2 { font-size: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #1f2937; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px; z-index: 100; max-width: 90vw; }
.toast.error { background: var(--red); }
.toast.ok { background: var(--green); }

@media (max-width: 720px) {
  .page { padding: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; }
  .user-name { display: none; }
  .modal { padding: 14px; }
}
