/* ===== 设计令牌 & 通用组件（全站共享） ===== */
:root {
  --brand: #2c6a4d;
  --brand-dark: #1d4a35;
  --brand-weak: #e9efe7;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --danger: #dc2626;
  --danger-weak: #fef2f2;
  --warn: #b45309;
  --warn-weak: #fffbeb;
  --info: #1d4ed8;
  --info-weak: #eff6ff;
  --bg: #f4f2ec;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(15, 45, 35, .08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.6; }
a { color: var(--brand-dark); text-decoration: none; }
h3 { margin: 0 0 12px; font-size: 16px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 10px; height: 40px; padding: 0 16px; font-size: 14px; font-family: inherit; cursor: pointer; transition: .15s; background: #fff; color: var(--ink); }
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); filter: none; }
.btn-ghost { border-color: var(--line); background: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }

.input { height: 38px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font-size: 14px; font-family: inherit; background: #fff; color: var(--ink); outline: none; transition: .15s; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(44, 106, 77, .18); }

.msg { border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin: 4px 0 12px; }
.msg-error { background: var(--danger-weak); color: var(--danger); border: 1px solid #fecaca; }
.msg-info { background: var(--info-weak); color: var(--info); border: 1px solid #bfdbfe; }
.msg-warn { background: var(--warn-weak); color: var(--warn); border: 1px solid #fde68a; }
.msg-ok { background: var(--brand-weak); color: var(--brand-dark); border: 1px solid #bbe7d4; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13.5px; color: #374151; margin-bottom: 6px; font-weight: 600; }
.field input, .field select { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font-size: 14.5px; font-family: inherit; background: #fff; color: var(--ink); outline: none; transition: .15s; }
.field input:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(44, 106, 77, .18); }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }

/* 顶栏 */
.topbar { background: #fff; border-bottom: 1px solid var(--line); min-height: 60px; display: flex; align-items: center; padding: 8px 24px; gap: 10px; position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.topbar .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16.5px; }
.topbar .logo svg { width: 30px; height: 30px; flex: none; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 13.5px; }
.topbar .who b { color: var(--ink); }

/* 卡片与页面容器 */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 18px; }
.page { max-width: 960px; margin: 26px auto; padding: 0 20px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 13px; background: #f3f1ea; }
tbody tr:hover { background: #f6f4ee; }

/* 徽章 */
.badge { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12.5px; line-height: 1.8; }
.badge-ok { background: var(--brand-weak); color: var(--brand-dark); }
.badge-danger { background: var(--danger-weak); color: var(--danger); }
.badge-warn { background: var(--warn-weak); color: var(--warn); }
.badge-info { background: var(--info-weak); color: var(--info); }
.badge-muted { background: #f3f4f6; color: var(--muted); }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-mask.open { display: flex; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 440px; padding: 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); max-height: 90vh; overflow: auto; }
.modal h3 { margin: 0 0 16px; font-size: 17px; }
.modal .modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* toast */
#toast { position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 99; max-width: 80vw; }
#toast.show { opacity: .95; }

/* ===== 移动端适配（手机访问） ===== */
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .page { margin: 14px auto; padding: 0 12px; }
  .card { padding: 16px; border-radius: 12px; margin-bottom: 12px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar .logo { font-size: 15px; }
  .topbar .who { font-size: 12.5px; }
  .btn-sm { height: 36px; }
  /* 输入字号 ≥16px，避免 iOS Safari 聚焦时自动放大页面 */
  .field input, .field select, .input { font-size: 16px; }
  .toolbar { gap: 8px; }
  .toolbar .input-search { flex: 1 1 100%; width: auto; }
  .modal-mask { padding: 12px; }
  .modal { padding: 18px 16px; }

  /* 表格在窄屏转为卡片列表，不再横向滚动 */
  .table-wrap { overflow-x: visible; }
  table { display: block; background: transparent; }
  thead { display: none; }
  tbody { display: block; }
  tbody tr { display: block; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px; margin-bottom: 10px; }
  tbody tr:hover { background: #fff; }
  tbody td { display: flex; align-items: center; justify-content: space-between; gap: 12px; white-space: normal; border-bottom: none; padding: 7px 0; text-align: right; }
  tbody td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; font-weight: 600; flex: none; }
  tbody td.td-actions { justify-content: flex-start; border-top: 1px dashed var(--line); margin-top: 4px; padding-top: 10px; }
  tbody td.td-actions::before { content: none; }
  td.col-optional { display: none; }
}
