:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --border: #e3e6ea;
  --text: #1f2430;
  --muted: #6b7280;
  --primary: #185fa5;
  --primary-light: #e6f1fb;
  --teal: #0f6e56;
  --teal-light: #e1f5ee;
  --amber: #854f0b;
  --amber-light: #faeeda;
  --red: #a32d2d;
  --red-light: #fcebeb;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.65 -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: #0c447c; color: #fff; display: flex; align-items: center;
  gap: 24px; padding: 0 24px; height: 52px;
}
.topbar .brand { font-weight: 600; font-size: 15px; color: #fff; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a {
  color: #cfe0f2; padding: 6px 12px; border-radius: 6px; font-size: 13px;
}
.topbar nav a:hover, .topbar nav a.active { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.topbar .who { font-size: 12px; color: #cfe0f2; }
.topbar .who a { color: #fff; margin-left: 12px; }

.container { max-width: 1080px; margin: 24px auto; padding: 0 20px; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px;
}
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 14px; }
.card h3 { font-size: 14px; font-weight: 600; margin: 18px 0 8px; }

.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .num { font-size: 26px; font-weight: 600; color: var(--primary); }
.stat .num.warn { color: var(--amber); }
.stat .label { font-size: 12px; color: var(--muted); margin-top: 2px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 500; white-space: nowrap; }
.tbl tr:hover td { background: #f8fafc; }

.input, select.input, textarea.input {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px;
  font: inherit; background: #fff; color: var(--text);
}
.input:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }
textarea.input { resize: vertical; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.help, .helptext { font-size: 11px; color: var(--muted); }

.btn {
  display: inline-block; padding: 7px 16px; border-radius: 7px; border: 1px solid var(--primary);
  background: var(--primary); color: #fff; font: inherit; cursor: pointer; font-size: 13px;
}
.btn:hover { opacity: .9; }
.btn.ghost { background: #fff; color: var(--primary); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.warn { background: #fff; color: var(--amber); border-color: var(--amber); }
.btn.danger { background: #fff; color: var(--red); border-color: var(--red); }
.btn.teal { background: var(--teal); border-color: var(--teal); }

.tag {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px;
  background: #f1f3f5; color: var(--muted); white-space: nowrap;
}
.tag.blue { background: var(--primary-light); color: var(--primary); }
.tag.teal { background: var(--teal-light); color: var(--teal); }
.tag.amber { background: var(--amber-light); color: var(--amber); }
.tag.red { background: var(--red-light); color: var(--red); }

.messages { list-style: none; margin: 0 0 14px; padding: 0; }
.messages li {
  padding: 9px 14px; border-radius: 8px; margin-bottom: 8px; font-size: 13px;
  background: var(--teal-light); color: var(--teal); border: 1px solid #9fe1cb;
}
.messages li.error { background: var(--red-light); color: var(--red); border-color: #f09595; }
.messages li.warning { background: var(--amber-light); color: var(--amber); border-color: #fac775; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline li:before {
  content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--primary); border: 2px solid #fff;
}
.timeline .t { font-weight: 500; font-size: 13px; }
.timeline .m { font-size: 12px; color: var(--muted); }

.login-wrap { max-width: 380px; margin: 10vh auto; }
.login-wrap .brand-title { text-align: center; font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.login-wrap .brand-sub { text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 20px; }

.kv { display: grid; grid-template-columns: 130px 1fr; row-gap: 6px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.action-form { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; background: #fbfcfd; }
.action-form .title { font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters select { width: auto; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.right { text-align: right; }
.mt0 { margin-top: 0; }
code.pw { background: #f1f3f5; padding: 2px 8px; border-radius: 6px; }

/* 退出按钮：外观同链接，但用表单 POST 提交（Django 5 要求） */
.logout-form { display: inline; margin: 0; }
.logout-form button.linklike {
  background: none; border: none; padding: 0; margin: 0;
  color: inherit; font: inherit; cursor: pointer; text-decoration: underline;
}

/* 病种场景指标分组：切换病种时由 JS 显隐，不刷新页面 */
.indicator-group { border-left: 3px solid var(--line); padding-left: 12px; margin-bottom: 4px; }
.scenario-tag {
  font-size: 12px; font-weight: 600; color: var(--muted);
  margin: 0 0 10px; letter-spacing: .02em;
}

/* 字段级校验错误提示 */
.field .errorlist, .field ul.errorlist {
  margin: 4px 0 0; padding: 0; list-style: none;
}
.field ul.errorlist li {
  color: var(--red, #c0392b); font-size: 12px; line-height: 1.5;
  padding: 2px 0;
}
.field.full ul.errorlist li { grid-column: 1 / -1; }

/* 双因素宽限期倒计时横幅：不阻断业务，但必须一直在眼前 */
.mfa-notice {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
  background: #FFF8E6; border: 1px solid #E0B34D; border-left: 4px solid #C8901E;
  border-radius: 8px; padding: 10px 14px; margin: 12px 0;
  font-size: 13px; line-height: 1.7; color: #5A3E06;
}
.mfa-notice strong { color: #A5541B; }
