:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-alt: #eef1f4;
  --text: #17202a;
  --muted: #6b7785;
  --line: #dfe4e8;
  --primary: #1667d9;
  --primary-dark: #0e4fae;
  --green: #137a52;
  --green-bg: #e8f6ef;
  --red: #b42318;
  --red-bg: #fef0ef;
  --amber: #9a6700;
  --amber-bg: #fff7df;
  --shadow: 0 10px 30px rgba(25, 38, 54, .08);
  --radius: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 "Microsoft YaHei", "PingFang SC", system-ui, sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error-text { color: var(--red); min-height: 20px; }
.app-header { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.95); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.header-inner { max-width: 1480px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.brand-mark { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #1667d9, #20a4a8); font-size: 24px; font-weight: 700; }
.brand-mark.small { width: 38px; height: 38px; border-radius: 11px; font-size: 20px; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.date-field { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.date-field input { border: 1px solid var(--line); border-radius: 9px; padding: 7px 9px; background: #fff; color: var(--text); }
.user-chip { padding: 6px 10px; border-radius: 999px; background: var(--surface-alt); color: var(--muted); font-size: 12px; }
.page-shell { max-width: 1480px; margin: 0 auto; padding: 18px 20px 50px; }
.main-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { border: 0; background: transparent; padding: 12px 18px; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 600; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.section-head h1 { margin: 0 0 4px; font-size: 24px; }
.section-head p { margin: 0; }
.filter-bar { display: grid; grid-template-columns: 150px 250px 140px 190px minmax(220px, 1fr); gap: 10px; margin-bottom: 12px; }
.date-filter-wrap { display: flex; align-items: center; gap: 6px; }
.date-filter-wrap input { min-width: 0; }
.filter-bar select, .filter-bar input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; }
.stats-line { color: var(--muted); font-size: 12px; margin: 4px 0 12px; }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.content-card, .plan-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 3px 12px rgba(25,38,54,.03); }
.content-card { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 8px; font-size: 12px; background: var(--surface-alt); color: var(--muted); }
.badge.account { background: #edf3ff; color: #225bb5; }
.badge.type { background: #f2edff; color: #6742a8; }
.status-pill { border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 700; background: var(--amber-bg); color: var(--amber); white-space: nowrap; }
.status-pill.approved { background: var(--green-bg); color: var(--green); }
.status-pill.rejected { background: var(--red-bg); color: var(--red); }
.status-pill.locked { background: #e8f2ff; color: var(--primary); }
.cover-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cover-box { border: 1px solid var(--line); border-radius: 10px; padding: 9px; background: #fbfcfd; min-height: 76px; }
.cover-box.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(22,103,217,.12); }
.cover-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.cover-text { white-space: pre-wrap; font-weight: 700; line-height: 1.55; overflow-wrap: anywhere; }
.content-title { font-size: 16px; line-height: 1.45; margin: 0; }
.opening { margin: 0; padding: 10px 12px; background: #f7f9fb; border-radius: 10px; white-space: pre-wrap; color: #354150; }
.card-meta { color: var(--muted); font-size: 12px; display: flex; gap: 12px; flex-wrap: wrap; }
.card-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: auto; }
.btn { border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; background: #fff; color: var(--text); }
.btn:hover { border-color: #b9c3cc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: #fff; color: #43505e; }
.btn.small { padding: 5px 9px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.wide { width: 100%; }
.empty { grid-column: 1 / -1; padding: 44px 18px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); background: rgba(255,255,255,.6); }
.account-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.account-tab { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px; color: var(--muted); }
.account-tab.active { border-color: var(--primary); color: var(--primary); background: #edf4ff; font-weight: 700; }
.plan-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 10px 0 14px; }
.plan-list { display: flex; flex-direction: column; gap: 10px; }
.plan-item { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; padding: 14px; align-items: center; }
.plan-position { width: 42px; height: 42px; border-radius: 12px; background: #edf4ff; color: var(--primary); display: grid; place-items: center; font-size: 17px; font-weight: 800; }
.plan-main { min-width: 0; }
.plan-main h3 { margin: 0 0 5px; font-size: 16px; }
.plan-main p { margin: 3px 0; }
.plan-cover { font-weight: 700; white-space: pre-wrap; color: #2e3a48; }
.drag-handle { cursor: grab; color: #9aa6b2; font-size: 20px; user-select: none; }
.plan-controls { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(16,24,33,.48); display: grid; place-items: center; padding: 18px; }
.modal { width: min(560px, 100%); max-height: 92vh; overflow: auto; background: #fff; border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.wide-modal { width: min(980px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 20px; }
.icon-btn { border: 0; background: transparent; font-size: 26px; line-height: 1; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
label { display: flex; flex-direction: column; gap: 5px; color: #3d4957; margin: 10px 0; }
input, select, textarea { border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; background: #fff; color: var(--text); width: 100%; }
textarea { resize: vertical; line-height: 1.6; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.code-area { min-height: 300px; font-family: Consolas, "Courier New", monospace; font-size: 13px; }
.history-content { display: flex; flex-direction: column; gap: 10px; }
.history-event { border: 1px solid var(--line); border-radius: 11px; padding: 12px; background: #fbfcfd; }
.history-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.diff-row { display: grid; grid-template-columns: 120px 1fr 1fr; gap: 8px; padding: 8px 0; border-top: 1px dashed var(--line); }
.diff-row strong { color: var(--muted); font-size: 12px; }
.diff-old { color: var(--red); white-space: pre-wrap; }
.diff-new { color: var(--green); white-space: pre-wrap; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #17202a; color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s ease; z-index: 80; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.login-body { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 20% 10%, #dceaff 0, transparent 36%), radial-gradient(circle at 85% 90%, #d9f4ee 0, transparent 32%), var(--bg); padding: 20px; }
.login-card { width: min(420px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); text-align: center; }
.login-card h1 { margin: 12px 0 4px; }
.login-card .brand-mark { margin: 0 auto; }
.login-card label { text-align: left; }
@media (max-width: 980px) {
  .card-grid { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .header-inner { align-items: flex-start; }
  .header-actions { max-width: 70%; }
}
@media (max-width: 640px) {
  .header-inner { padding: 10px 12px; }
  .brand small { display: none; }
  .header-actions { max-width: 100%; gap: 6px; }
  .user-chip { display: none; }
  .page-shell { padding: 12px 10px 40px; }
  .section-head { flex-direction: column; align-items: stretch; }
  .section-head .btn { width: 100%; }
  .filter-bar { grid-template-columns: 1fr; }
  .cover-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .plan-item { grid-template-columns: 42px minmax(0, 1fr); align-items: start; }
  .plan-controls { grid-column: 1 / -1; justify-content: flex-start; padding-left: 54px; }
  .plan-toolbar { align-items: flex-start; flex-direction: column; }
  .plan-toolbar > div { display: flex; gap: 8px; width: 100%; }
  .plan-toolbar .btn { flex: 1; }
  .diff-row { grid-template-columns: 1fr; }
  .date-field { width: 100%; }
  .date-field input { flex: 1; }
}