* { box-sizing: border-box; }
:root {
  --bg: #faf5f4;
  --panel: #ffffff;
  --ink: #332421;
  --muted: #7d6965;
  --line: #ecd9d6;
  --brand: #b3261e;
  --brand-dark: #8a1c17;
  --brand-soft: #fbeaea;
  --red: #c0392b;
  --red-soft: #fdeceb;
  --amber: #b7791f;
  --amber-soft: #fff6e5;
  --blue: #2b6cb0;
  --blue-soft: #eaf2fb;
  --shadow: 0 2px 12px rgba(36, 51, 47, .06);
  --radius: 10px;
}
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.55;
}

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #eef5f2 0%, #dcebe5 100%); padding: 20px; }
.login-card { width: 100%; max-width: 420px; background: var(--panel); border-radius: 16px; box-shadow: 0 10px 40px rgba(36,51,47,.12); padding: 36px; }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.login-brand h1 { font-size: 20px; margin: 0 0 4px; }
.login-brand p { margin: 0; color: var(--muted); font-size: 13px; }
.brand-mark { width: 46px; height: 46px; border-radius: 12px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; flex-shrink: 0; }
.brand-mark.small { width: 34px; height: 34px; border-radius: 9px; font-size: 17px; }
.login-card label { display: block; font-weight: 600; margin: 16px 0 6px; }
.login-card input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; outline: none; }
.login-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.login-hint { margin: 18px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
.form-error { color: var(--red); font-size: 13px; min-height: 20px; margin-top: 8px; }

/* ---------- shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; flex-shrink: 0; position: sticky; top: 0; height: 100vh; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; border-bottom: 1px solid var(--line); }
.sidebar-brand strong { display: block; font-size: 15px; }
.sidebar-brand span { display: block; font-size: 11px; color: var(--muted); }
.nav-menu { padding: 12px 10px; flex: 1; }
.nav-menu a { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 8px; color: #4a5b55; text-decoration: none; margin-bottom: 4px; font-weight: 500; }
.nav-menu a:hover { background: #f2f6f4; }
.nav-menu a.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; }
.nav-icon { width: 20px; text-align: center; font-size: 16px; }
.sidebar-foot { padding: 16px 18px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); line-height: 1.7; }
.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 26px; position: sticky; top: 0; z-index: 10; }
.page-title { font-size: 17px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.user-label { color: var(--muted); margin-right: 6px; font-size: 13px; }
.content { padding: 24px 26px 60px; max-width: 1300px; width: 100%; }

/* ---------- buttons ---------- */
.btn { border: 1px solid transparent; border-radius: 8px; padding: 9px 15px; font-size: 14px; cursor: pointer; font-family: inherit; font-weight: 600; background: #fff; color: var(--ink); transition: .15s; }
.btn:hover { filter: brightness(.97); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; padding: 12px; }
.btn-link { background: none; border: none; color: var(--brand); cursor: pointer; padding: 4px 6px; font-size: 13px; font-family: inherit; }
.btn-link.danger { color: var(--red); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.toolbar .spacer { flex: 1; }
input.field, select.field, textarea.field { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font-size: 14px; font-family: inherit; background: #fff; color: var(--ink); outline: none; }
input.field:focus, select.field:focus, textarea.field:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea.field { resize: vertical; min-height: 80px; }

/* ---------- cards / stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat-card .label { color: var(--muted); font-size: 13px; }
.stat-card .value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.stat-card .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-card.income .value { color: var(--brand); }
.stat-card.expense .value { color: var(--red); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.card h2 { font-size: 16px; margin: 0 0 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- table ---------- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid #f0f3f1; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafcfb; }
.table-wrap { overflow-x: auto; }
.amount-in { color: var(--brand); font-weight: 700; }
.amount-out { color: var(--red); font-weight: 700; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; background: #eef1f0; color: #5a6a64; white-space: nowrap; }
.badge.green { background: var(--brand-soft); color: var(--brand-dark); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.red { background: var(--red-soft); color: var(--red); }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; }

/* ---------- forms / modal ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(24,38,33,.45); display: flex; align-items: flex-start; justify-content: center; z-index: 100; padding: 40px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 680px; box-shadow: 0 16px 60px rgba(0,0,0,.18); }
.modal.small { max-width: 420px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-item label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.form-item .field { width: 100%; }
.req::after { content: ' *'; color: var(--red); }
.hint { font-size: 12px; color: var(--muted); }

/* ---------- uploader ---------- */
.upload-zone { border: 1.5px dashed #bcd2c9; border-radius: 10px; padding: 18px; text-align: center; background: #f8fbf9; cursor: pointer; }
.upload-zone:hover { border-color: var(--brand); }
.upload-zone .main { font-weight: 600; color: var(--brand-dark); }
.upload-zone .sub { font-size: 12px; color: var(--muted); }
.thumb-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.thumb { position: relative; width: 92px; height: 92px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .del { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; border: none; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; font-size: 13px; line-height: 18px; }
.thumb .processing { position: absolute; inset: 0; background: rgba(255,255,255,.75); display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--brand-dark); }
.img-viewer { max-width: 100%; max-height: 72vh; border-radius: 8px; display: block; margin: 0 auto; }

/* ---------- misc ---------- */
.toast-root { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 8px; padding: 12px 16px; box-shadow: 0 8px 24px rgba(0,0,0,.12); min-width: 200px; font-size: 13px; }
.toast.error { border-left-color: var(--red); }
.project-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.project-title h2 { margin: 0; font-size: 21px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-top: 16px; }
.detail-item .k { font-size: 12px; color: var(--muted); }
.detail-item .v { font-weight: 600; margin-top: 3px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.bar-row .name { width: 100px; flex-shrink: 0; font-size: 13px; text-align: right; color: var(--muted); }
.bar-track { flex: 1; height: 20px; background: #f0f3f1; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 4px; }
.bar-row .num { width: 100px; text-align: right; font-size: 13px; font-weight: 600; }
.link-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid #f0f3f1; font-size: 13px; gap: 10px; }
.link-row:last-child { border-bottom: none; }
.link-row .left { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-row .date { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.gallery { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.gallery img { width: 88px; height: 88px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; }
.news-list { display: flex; flex-direction: column; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filter-bar .field { width: auto; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented button { border: none; background: #fff; padding: 8px 14px; cursor: pointer; font-family: inherit; font-size: 13px; color: var(--muted); }
.segmented button.active { background: var(--brand); color: #fff; font-weight: 700; }
/* ---------- 手机与窄屏：单手操作优先 ---------- */
.mobile-nav { display: none; }
.mobile-sheet { display: none; }
@media (max-width: 900px) {
  .sidebar { display: none; }
  .app-shell { display: block; }
  .main-wrap { width: 100%; }
  .topbar { height: auto; min-height: 56px; padding: 0 14px; }
  .topbar-right { display: none; }
  .content { padding: 14px 12px 92px; }
  .mobile-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: #fff; border-top: 1px solid var(--line);
    box-shadow: 0 -4px 18px rgba(36,51,47,.08);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-nav a, .mobile-nav button {
    flex: 1; min-width: 0; min-height: 62px; border: 0; background: none;
    color: var(--muted); text-decoration: none; font-family: inherit; font-size: 11px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; padding: 6px 2px;
  }
  .mobile-nav .mn-icon { font-size: 20px; line-height: 1; }
  .mobile-nav a.active, .mobile-nav button.active { color: var(--brand-dark); font-weight: 700; }
  .mobile-sheet { position: fixed; inset: 0; z-index: 90; display: block; }
  .mobile-sheet[hidden] { display: none; }
  .ms-backdrop { position: absolute; inset: 0; background: rgba(24,38,33,.42); }
  .ms-panel {
    position: absolute; left: 0; right: 0; bottom: 0; background: #fff;
    border-radius: 16px 16px 0 0; padding: 8px 14px calc(18px + env(safe-area-inset-bottom));
  }
  .ms-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 4px 14px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
  .ms-head strong { font-size: 16px; }
  .ms-head button { border: 0; background: none; font-size: 24px; color: var(--muted); line-height: 1; padding: 4px 8px; }
  .ms-panel > button { width: 100%; min-height: 48px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; font-family: inherit; font-size: 15px; color: var(--ink); padding: 0 6px; }
  .ms-panel > button:last-child { border-bottom: 0; }
  .ms-panel > button.danger { color: var(--red); }
  .print-mode .mobile-nav, .print-mode .mobile-sheet { display: none !important; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .content { padding: 12px 10px 88px; }
  .card { padding: 14px; border-radius: 12px; margin-bottom: 12px; }
  .card h2 { font-size: 16px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
  .stat-card { padding: 14px; }
  .stat-card .value { font-size: 22px; }
  .stat-card .label { font-size: 12px; }
  .stage-mini-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stage-grid, .doc-type-grid, .plan-type-grid, .plan-type-pick { grid-template-columns: 1fr; gap: 10px; }
  .stage-card, .doc-type-card, .plan-type-card { padding: 14px; }
  .sc-desc, .dt-hint { min-height: 0; }
  .toolbar { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin-bottom: 14px; }
  .toolbar .spacer { display: none; }
  .toolbar .btn, .toolbar .field, .toolbar a { width: 100%; text-align: center; }
  .filter-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .filter-bar .field, .filter-bar .segmented { width: 100%; grid-column: 1 / -1; }
  .segmented button { flex: 1; min-height: 44px; }
  .btn { min-height: 44px; padding: 10px 14px; }
  .btn-sm { min-height: 36px; padding: 6px 10px; }
  .btn-link { min-height: 40px; padding: 8px 6px; }
  input.field, select.field, textarea.field { width: 100%; min-height: 44px; font-size: 16px; padding: 10px 12px; }
  textarea.field { min-height: 96px; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .form-item label { font-size: 13px; }
  /* 表格转卡片：字段名直接显示，避免横向滚动 */
  .table-wrap { overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: #fff; }
  .table-wrap td { border: 0; padding: 6px 0; display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
  .table-wrap td::before { content: attr(data-label); flex: 0 0 78px; color: var(--muted); font-size: 12px; font-weight: 600; }
  .table-wrap td:last-child { border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 10px; flex-wrap: wrap; }
  .table-wrap td a { min-height: 36px; display: inline-flex; align-items: center; }
  /* 详情表转上下结构 */
  .detail-table, .detail-table tbody, .detail-table tr, .detail-table th, .detail-table td { display: block; width: 100% !important; }
  .detail-table tr { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; }
  .detail-table th { width: auto !important; border: 0; background: none; color: var(--muted); padding: 2px 0; font-size: 12px; }
  .detail-table td { border: 0; padding: 2px 0 6px; font-size: 15px; font-weight: 600; }
  /* 活动行改纵向堆叠 */
  .plan-row { display: grid; gap: 10px; padding: 14px; }
  .plan-row > div { width: 100%; }
  .plan-status-select { width: 100%; min-height: 44px; font-size: 14px; }
  .case-box { flex-direction: column; align-items: stretch; gap: 12px; padding: 14px; }
  .case-actions { flex-wrap: wrap; }
  .case-actions .btn { flex: 1; }
  .bar-row .name { width: 74px; }
  .bar-row .num { width: 74px; }
  .link-row { font-size: 14px; }
  .gallery img { width: 76px; height: 76px; }
  .thumb { width: 78px; height: 78px; }
  .thumb .del { width: 24px; height: 24px; font-size: 15px; line-height: 21px; }
  .file-item { flex-wrap: wrap; padding: 10px; }
  .file-name { flex: 1 1 100%; }
  .file-size { margin-left: auto; }
  /* 弹窗变底部抽屉 */
  .modal-mask { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; display: flex; flex-direction: column; overflow: hidden; }
  .modal-head { padding: 14px 16px; flex-shrink: 0; }
  .modal-head h3 { font-size: 16px; }
  .modal-body { padding: 16px; overflow-y: auto; }
  .modal-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); gap: 8px; flex-shrink: 0; }
  .modal-foot .btn { flex: 1; }
  .toast-root { top: auto; bottom: calc(76px + env(safe-area-inset-bottom)); left: 10px; right: 10px; }
  .toast { min-width: 0; width: 100%; }
  .login-page { padding: 14px; align-items: flex-start; }
  .login-card { padding: 24px 20px; margin-top: 6vh; }
  .login-brand h1 { font-size: 18px; }
  .login-card input { min-height: 48px; font-size: 16px; }
}

/* ---------- 项目执行档案打印 ---------- */
.print-mode .sidebar, .print-mode .topbar { display: none; }
.print-mode .content { padding: 0; max-width: none; background: #eef1ef; }
.print-toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.print-page { max-width: 210mm; margin: 20px auto; background: #fff; padding: 16mm; box-shadow: 0 2px 18px rgba(0,0,0,.08); color: #1a1a1a; font-family: var(--print-font, "Microsoft YaHei", "PingFang SC", sans-serif); font-size: var(--print-font-size, 12px); }
.print-page h1, .print-page h2, .print-page h3 { font-family: var(--print-head-font, inherit); }
.print-table th { background: var(--print-th-bg, #f4f4f4); }
.thumb img { cursor: zoom-in; }
.print-cover { text-align: center; border-bottom: 2px solid #333; padding-bottom: 14px; margin-bottom: 22px; }
.print-org { font-size: 13px; letter-spacing: 3px; color: #444; }
.print-cover h1 { font-size: 24px; margin: 8px 0; }
.print-sub { font-size: 12px; color: #555; }
.print-section { margin-bottom: 24px; }
.print-section h2 { font-size: 16px; border-left: 4px solid var(--brand); padding-left: 8px; margin: 0 0 10px; }
.print-section h3 { font-size: 13px; margin: 16px 0 6px; }
.print-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 8px; }
.print-table th, .print-table td { border: 1px solid #999; padding: 6px 8px; text-align: left; vertical-align: top; }
/* 覆盖通用表格的 tr:last-child td 去底边框规则，保证归档表格四边完整 */
.print-table tbody tr:last-child td { border-bottom: 1px solid #999; }
.print-table thead th { background: #f2f5f3; font-weight: 700; }
.print-table.kv th { background: #f7f9f8; width: 18%; font-weight: 600; white-space: nowrap; }
.print-table.kv td { width: 32%; }
.print-table .num { text-align: right; white-space: nowrap; }
.print-table .desc { line-height: 1.6; }
.print-archive { border: 1px solid #ccc; border-radius: 4px; padding: 10px 12px; margin-bottom: 12px; break-inside: avoid; page-break-inside: avoid; }
.pa-head { display: flex; align-items: baseline; gap: 8px; border-bottom: 1px dashed #ccc; padding-bottom: 6px; margin-bottom: 8px; }
.pa-no { color: var(--brand); font-weight: 700; }
.pa-meta { margin-left: auto; font-size: 11px; color: #555; white-space: nowrap; }
.pa-content { font-size: 12px; line-height: 1.7; white-space: pre-wrap; }
.pa-content.muted { color: #888; }
.pa-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.pa-images img { max-width: 100%; max-height: 55mm; object-fit: contain; border: 1px solid #ddd; }
/* 只有一张图片时自动放大显示 */
.pa-images.single { justify-content: center; margin-top: 10px; }
.pa-images.single img { width: 100%; max-height: 190mm; object-fit: contain; border: 1px solid #bbb; }
.print-page .pa-images img { cursor: zoom-in; }
.print-empty { color: #777; font-size: 12px; }
.print-foot { border-top: 1px solid #999; margin-top: 24px; padding-top: 8px; font-size: 11px; color: #555; }
.arch-cover { text-align: center; padding: 20mm 0 16mm; }
.cover-top { font-size: 15px; letter-spacing: 4px; color: #333; margin-bottom: 8mm; }
.cover-no { text-align: right; font-size: 12px; color: #555; margin-bottom: 6mm; }
.arch-cover h1 { font-size: 26px; margin: 6mm 0 12mm; line-height: 1.5; }
.cover-table { text-align: left; margin-bottom: 12mm; }
.cover-bottom { text-align: right; font-size: 12px; color: #444; }
.arch-index, .arch-check, .arch-chapter { page-break-before: always; break-before: page; }
.pa-facts { font-size: 11px; color: #444; background: #f7f9f8; border-left: 3px solid var(--brand); padding: 5px 8px; margin-bottom: 6px; }
.pa-outcome { font-size: 12px; margin-top: 8px; padding: 6px 8px; background: #fbfdfc; border: 1px dashed #bbb; }
.pa-sign { font-size: 11px; color: #444; text-align: right; margin-top: 8px; }
.arch-chapter { page-break-before: auto; }
.print-table .check { color: var(--brand-dark); font-weight: 700; }
.sign-table th { width: 18%; }
.sign-table td { height: 34px; }

/* ---------- 八阶段 ---------- */
.stage-mini-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stage-mini { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fbfcfb; }
.stage-mini .sm-no { color: var(--brand); font-weight: 700; font-size: 12px; }
.stage-mini .sm-name { font-size: 13px; font-weight: 600; margin-top: 4px; }
.stage-mini .sm-count { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.stage-card { border: 1px solid var(--line); border-radius: 10px; padding: 16px; cursor: pointer; background: #fff; transition: .15s; }
.stage-card:hover { border-color: var(--brand); box-shadow: var(--shadow); transform: translateY(-2px); }
.sc-top { display: flex; align-items: center; gap: 8px; }
.sc-no { width: 26px; height: 26px; border-radius: 6px; background: var(--brand-soft); color: var(--brand-dark); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.sc-name { font-weight: 700; font-size: 15px; }
.sc-sub { font-size: 12px; color: var(--brand-dark); margin-top: 8px; }
.sc-desc { font-size: 12px; color: var(--muted); margin-top: 4px; min-height: 34px; line-height: 1.5; }
.sc-progress { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.sc-progress .bar-track { height: 8px; }
.sc-progress span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.stage-tag { font-weight: 700; color: var(--brand-dark); }
.doc-type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.doc-type-card { border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: #fbfcfb; }
.doc-type-card.locked { background: #fdf5f5; border-color: #f0d5d2; }
.dt-name { font-weight: 700; }
.dt-hint { font-size: 12px; color: var(--muted); margin-top: 5px; min-height: 32px; line-height: 1.5; }
.dt-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 8px; }
.case-box { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: #fff; border: 1px solid #f0d5d2; border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.case-box.unlocked { border-color: #bfe0d3; background: #f7fcf9; }
.case-box .hint { margin-top: 4px; }
.case-actions { display: flex; gap: 8px; flex-shrink: 0; }
.locked-note { border: 1px dashed #d99; background: #fff8f5; color: #8a4b32; padding: 12px; border-radius: 6px; font-size: 12px; margin: 10px 0; }
.print-doc { border: 1px solid #ddd; border-radius: 4px; padding: 10px 12px; margin-bottom: 10px; break-inside: avoid; page-break-inside: avoid; }
.pd-head { display: flex; justify-content: space-between; border-bottom: 1px dashed #bbb; padding-bottom: 6px; margin-bottom: 8px; font-size: 13px; }
.pd-head span { color: #666; font-size: 11px; }

.file-list { margin-top: 8px; }
.file-item { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-top: 6px; background: #fff; font-size: 13px; }
.file-icon { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 26px; border-radius: 4px; background: var(--brand-soft); color: var(--brand-dark); font-size: 11px; font-weight: 700; flex-shrink: 0; }
.file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.del-file { border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; }
.del-file:hover { color: var(--red); }
.print-attachment { border: 1px solid #ddd; border-radius: 4px; padding: 10px 12px; margin-bottom: 10px; break-inside: avoid; page-break-inside: avoid; }
.print-attachment .pa-actions { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.pdf-frame { width: 100%; height: 320px; border: 1px solid #ddd; background: #fafafa; }

.plan-type-grid, .plan-type-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.plan-type-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: #fbfcfb; cursor: pointer; transition: .15s; }
.plan-type-card:hover { border-color: var(--brand); transform: translateY(-1px); }
.plan-type-card.active { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 2px rgba(47,125,104,.12); }
.pt-icon { font-size: 22px; color: var(--brand); margin-bottom: 6px; }
.plan-type-card strong { display: block; font-size: 15px; margin-bottom: 4px; }
.plan-type-card .hint { margin-top: 3px; line-height: 1.5; }
.plan-row { display: flex; align-items: center; gap: 16px; justify-content: space-between; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-top: 10px; background: #fff; }
.plan-row > div:first-child { flex: 1; }
.plan-status-select { width: 112px; padding: 6px 8px; font-size: 12px; }
.plan-row .hint { margin-top: 3px; }
.detail-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.detail-table th, .detail-table td { border: 1px solid var(--line); padding: 8px 10px; font-size: 13px; text-align: left; }
.detail-table th { width: 22%; background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }

/* ---------- 系统设置 ---------- */
.brand-mark { background-image: var(--logo-url, none); background-size: cover; background-position: center; }
.settings-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.settings-tabs button { border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 8px; padding: 9px 14px; font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.settings-tabs button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.settings-pane { display: none; }
.settings-pane.active { display: block; }
.brand-logo-row { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.brand-logo-preview { width: 64px; height: 64px; border-radius: 14px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; flex-shrink: 0; background-size: cover; background-position: center; }
.brand-logo-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 8px; }
.theme-card { border: 2px solid var(--line); border-radius: 10px; padding: 10px; cursor: pointer; background: #fff; }
.theme-card.active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.theme-swatches { display: flex; gap: 4px; margin-bottom: 8px; }
.theme-swatches i { width: 22px; height: 22px; border-radius: 50%; display: block; border: 1px solid rgba(0,0,0,.08); }
.theme-card strong { font-size: 13px; }
.theme-card .hint { margin-top: 2px; }
.print-style-card { min-height: 74px; }
.margin-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.storage-mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.print-hf { pointer-events: none; }
.group-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; background: #fbfcfb; }
.group-head { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 12px; }
.perm-item { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); }
.perm-item input { accent-color: var(--brand); }
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cat-editor textarea { min-height: 220px; line-height: 1.8; }
.group-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
@media (max-width: 640px) {
  .settings-tabs { display: grid; grid-template-columns: 1fr 1fr; }
  .settings-tabs button { min-height: 44px; }
  .brand-logo-row { flex-direction: column; align-items: flex-start; }
  .group-head { grid-template-columns: 1fr; }
  .cat-grid { grid-template-columns: 1fr; }
  .perm-grid { grid-template-columns: 1fr 1fr; }
  .margin-grid { grid-template-columns: 1fr 1fr; }
  .storage-mode-grid { grid-template-columns: 1fr; }
}

@page { size: A4; margin: 0; }
@media print {
  html, body { background: #fff !important; margin: 0 !important; padding: var(--print-margin-top, 16mm) var(--print-margin-right, 10mm) var(--print-margin-bottom, 16mm) var(--print-margin-left, 10mm) !important; }
  .sidebar, .topbar, .mobile-nav, .mobile-sheet, .print-toolbar, .toast-root, .modal-mask { display: none !important; }
  .app-shell, .main-wrap, .content { display: block !important; padding: 0 !important; margin: 0 !important; max-width: none !important; }
  .print-page { box-shadow: none !important; margin: 0 !important; padding: 0 !important; max-width: none !important; }
  .print-table thead { display: table-header-group; }
  .print-table tr, .print-archive { break-inside: avoid; page-break-inside: avoid; }
  /* 封面单独一页；其余内容连续排布、自然分页，让每页尽量填满 */
  .arch-cover { break-after: page; page-break-after: always; }
  .arch-index, .arch-check, .arch-chapter { break-before: auto; page-break-before: auto; break-after: auto; page-break-after: auto; }
  /* 标题不与后文分离，避免标题孤零零留在页底 */
  .print-section h2, .print-section h3, .print-doc .pd-head { break-after: avoid; page-break-after: avoid; }
  /* 资料块允许跨页，避免多图资料被整体推到下一页形成空白 */
  .print-doc { break-inside: auto; page-break-inside: auto; }
  .pd-head, .print-doc table tr { break-inside: avoid; page-break-inside: avoid; }
  .pa-images img { max-height: 38mm !important; max-width: 100% !important; }
  /* 单张图片打印时放大到接近整页，避免大量空白 */
  .pa-images.single { justify-content: center !important; }
  .pa-images.single img { max-height: 190mm !important; max-width: 100% !important; object-fit: contain !important; }
  .pdf-frame, .print-attachment .pa-actions, .file-item { display: none !important; }
  .print-attachment { break-inside: auto; page-break-inside: auto; }
  a { text-decoration: none; color: inherit; display: none !important; }
  .print-toolbar .hint { display: none !important; }
}
