* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #c22f1e; --primary-dark: #a02618; --primary-light: #fdece9;
  --bg: #f4f5f7; --panel: #fff; --border: #e5e7eb;
  --text: #1f2937; --muted: #6b7280;
  --ok: #16a34a; --okbg: #f0fdf4; --warn: #d97706; --warnbg: #fffbeb;
  --bad: #dc2626; --badbg: #fef2f2; --blue: #2563eb; --bluebg: #eff6ff;
  --radius: 10px;
}
html { scroll-behavior: smooth; }
body { font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
body.modal-open { overflow: hidden; }
.hidden { display: none !important; }
a { color: var(--blue); cursor: pointer; text-decoration: none; }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #b91c1c 0%, #7f1d1d 55%, #3f1010 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 40px 44px; width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-logo { font-size: 13px; letter-spacing: 4px; color: var(--primary); font-weight: 700; }
.login-card h1 { font-size: 22px; margin: 8px 0 4px; }
.login-sub { color: var(--muted); font-size: 12px; margin-bottom: 24px; }
.login-msg { color: var(--bad); font-size: 12px; min-height: 18px; margin-top: 8px; }

/* 布局 */
#app-view { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #1f2430; color: #d1d5db; flex-shrink: 0; display: flex; flex-direction: column; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px; border-bottom: 1px solid #2d3342; }
.brand-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 800; }
.brand-text b { display: block; color: #fff; font-size: 15px; }
.brand-text span { font-size: 11px; color: #9ca3af; }
#nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.nav-group { font-size: 11px; color: #6b7280; padding: 14px 10px 6px; letter-spacing: 2px; }
.nav-item { padding: 10px 12px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; gap: 8px;
  transition: background .15s; }
.nav-item:hover { background: #2a3040; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .ni { width: 20px; text-align: center; }
.badge { background: var(--bad); color: #fff; font-size: 11px; border-radius: 10px; padding: 1px 7px; margin-left: auto; }
.badge.blue { background: var(--blue); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 56px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 20; }
.page-title { font-size: 17px; font-weight: 700; }
.top-right { display: flex; align-items: center; gap: 18px; }
.bell { cursor: pointer; font-size: 18px; position: relative; }
.bell .badge { position: absolute; top: -6px; right: -10px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.role-tag { background: var(--primary-light); color: var(--primary); border-radius: 6px; padding: 2px 8px; font-size: 12px; }

.sec { padding: 20px 24px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; min-width: 0; }
.grid2 > * { min-width: 0; }
@media (max-width: 1100px) { .grid2 { grid-template-columns: 1fr; } }

/* 组件 */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; min-width: 0; max-width: 100%; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-head h3 { font-size: 15px; }
.hint { color: var(--muted); font-size: 12px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
input, select, textarea { border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; font: inherit; font-size: 13px; background: #fff; color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(194,47,30,.10); }
.input { min-width: 150px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }
.form label input, .form label select { margin-top: 2px; }
.form .chk { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.btn { border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 8px 16px; cursor: pointer; font-size: 13px; transition: all .15s; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.danger { color: var(--bad); border-color: #fca5a5; }
.btn.danger:hover { background: var(--badbg); }
.btn.block { width: 100%; }
.seg { display: inline-flex; flex-wrap: wrap; background: #eef0f3; border-radius: 10px; padding: 3px; }
.seg-btn { border: none; background: transparent; padding: 7px 18px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.seg-btn.active { background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.12); font-weight: 600; color: var(--primary); }

/* 卡片 */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 16px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer; transition: transform .12s, box-shadow .12s; }
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.card .k { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.card .v { font-size: 22px; font-weight: 800; }
.card .d { font-size: 12px; margin-top: 6px; color: var(--muted); }
.card .d .up { color: var(--bad); font-weight: 700; }
.card .d .down { color: var(--ok); font-weight: 700; }
.card.primary-card { border-top: 3px solid var(--primary); }

/* 表格 */
.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 { background: #fafafa; color: var(--muted); font-weight: 600; }
tr:hover td { background: #fafafa; }
td .mono { font-family: Consolas, monospace; font-size: 12px; }
.tag { border-radius: 6px; padding: 2px 8px; font-size: 12px; }
.tag.ok { background: var(--okbg); color: var(--ok); }
.tag.bad { background: var(--badbg); color: var(--bad); }
.tag.warn { background: var(--warnbg); color: var(--warn); }
.tag.blue { background: var(--bluebg); color: var(--blue); }
.tag.gray { background: #f3f4f6; color: var(--muted); }
.link { color: var(--blue); cursor: pointer; margin-right: 8px; }
.pager { display: flex; align-items: center; gap: 10px; margin-top: 10px; justify-content: flex-end; font-size: 12px; color: var(--muted); }

/* 图表 */
.chart { width: 100%; max-width: 100%; min-width: 0; height: 300px; overflow: hidden; }

/* 模态 */
.modal { position: fixed; inset: 0; background: rgba(15,20,30,.5); display: flex; align-items: flex-start; justify-content: center; z-index: 100; padding: 40px 16px; overflow-y: auto; }
.modal-box { background: #fff; border-radius: 14px; width: 760px; max-width: 100%; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 20px; }
.close { font-size: 22px; color: var(--muted); cursor: pointer; padding: 0 4px; }
.close:hover { color: var(--bad); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; margin-bottom: 16px; }
.detail-grid .item .k { color: var(--muted); font-size: 12px; }
.detail-grid .item .v { font-weight: 600; }
.detail-grid .item.full { grid-column: 1/3; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.dept-note { padding: 10px 4px 0; line-height: 1.6; }
.empty-state { padding: 24px 8px; text-align: center; }
.personnel-pick-list { display: flex; flex-direction: column; gap: 10px; max-height: 58vh; overflow-y: auto; padding-right: 2px; }
.personnel-pick-card { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.personnel-pick-card:hover { border-color: #b8c7ff; background: var(--primary-light); }
.personnel-pick-main { flex: 1; min-width: 0; line-height: 1.65; }
.personnel-pick-main b { overflow-wrap: anywhere; }
.personnel-pick-export { flex-shrink: 0; }

/* AI 审核结果 */
.ai-block { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.ai-score { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.ai-score .s { font-size: 26px; font-weight: 800; }
.ai-checks { display: flex; flex-direction: column; gap: 6px; }
.ai-check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
.ai-check .st { width: 46px; text-align: center; border-radius: 6px; padding: 1px 0; font-size: 12px; flex-shrink: 0; }
.st-pass { background: var(--okbg); color: var(--ok); } .st-warn { background: var(--warnbg); color: var(--warn); } .st-fail { background: var(--badbg); color: var(--bad); }
.suggestions { margin-top: 8px; background: var(--warnbg); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.suggestions li { margin: 3px 0 3px 16px; }

/* 文件上传 */
.drop { border: 2px dashed var(--border); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; transition: all .15s; }
.drop:hover { border-color: var(--primary); color: var(--primary); }
.file-list { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.file-item { display: flex; justify-content: space-between; background: #f8fafc; border-radius: 6px; padding: 6px 10px; font-size: 12px; }
.file-item .del { color: var(--bad); cursor: pointer; }

/* 通知 */
.pop { position: fixed; top: 64px; right: 20px; width: 340px; background: #fff; border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.18); z-index: 90; }
.pop-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 700; }
.pop-body { max-height: 60vh; overflow-y: auto; }
.notify-top-actions { display: flex; align-items: center; gap: 10px; }
.notify-clear-all { border: 0; background: transparent; color: var(--primary); cursor: pointer; font-size: 12px; padding: 6px 2px; }
.notify-clear-all:disabled { color: var(--muted); cursor: default; }
.notify-item { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px 10px 16px; border-bottom: 1px solid #f3f4f6; }
.notify-item.unread { background: var(--primary-light); }
.notify-content { flex: 1; min-width: 0; cursor: pointer; }
.notify-item .t { font-weight: 600; font-size: 13px; }
.notify-item .c { color: var(--muted); font-size: 12px; margin-top: 3px; }
.notify-action { flex-shrink: 0; border: 0; background: transparent; color: var(--bad); cursor: pointer; font-size: 12px; padding: 6px; min-height: 32px; }

/* toast */
#toast-wrap { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1f2430; color: #fff; padding: 10px 22px; border-radius: 8px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.2); animation: fadein .2s; }
.toast.err { background: var(--bad); }
@keyframes fadein { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; } }

/* 菜单按钮（移动端显示） */
.menu-btn { display: none; background: none; border: none; font-size: 22px; cursor: pointer; min-width: 44px; min-height: 44px; padding: 6px 10px 6px 0; color: var(--text); }

/* ========== 移动端适配 ========== */
@media (max-width: 768px) {
  body { font-size: 14px; overscroll-behavior-y: none; }
  .menu-btn { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 80; width: 250px;
    transform: translateX(-105%); transition: transform .25s ease; box-shadow: 4px 0 20px rgba(0,0,0,.3); }
  .sidebar.open { transform: translateX(0); }
  .backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 70; }
  .main { width: 100%; min-width: 0; }
  .topbar { padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left)); height: 52px; }
  .page-title { font-size: 16px; }
  .top-right { gap: 10px; }
  .user-chip { font-size: 12px; gap: 6px; }
  #me-name { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sec { padding: 14px; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card { padding: 12px; }
  .card .v { font-size: 18px; }
  .card .d { font-size: 11px; }
  .grid2 { grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
  .panel { padding: 12px; margin-bottom: 12px; }
  .panel-head h3 { font-size: 14px; }
  th, td { padding: 7px 6px; font-size: 12px; }
  .toolbar { gap: 8px; }
  .filters select, .filters input { flex: 1 1 42%; min-width: 0; }
  input, select, textarea { min-height: 44px; font-size: 16px; }
  .btn { padding: 9px 14px; min-height: 44px; font-size: 13px; }
  .btn.sm { min-height: 40px; padding: 7px 12px; }
  .modal { padding: 12px 0 0; align-items: flex-end; background: rgba(15,20,30,.58); }
  .modal-box { width: 100% !important; max-height: calc(100dvh - 12px); overflow-y: auto; border-radius: 18px 18px 0 0; box-shadow: 0 -12px 40px rgba(0,0,0,.2); animation: sheet-in .2s ease-out; }
  .modal-head { padding: 12px 14px; }
  .modal-head .close, .pop-head .close { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; margin: -10px -10px -10px 0; }
  .modal-body { padding: 14px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid .item.full { grid-column: 1/2; }
  .form.grid2 { grid-template-columns: 1fr; gap: 10px; }
  .form.grid2 label, .form.grid2 div, .form.grid2 label[style*="grid-column"] { grid-column: 1/2 !important; }
  .chart { height: 240px; }
  .pop { width: calc(100vw - 20px); right: 10px; top: 56px; }
  .login-card { width: 100%; margin: 14px; padding: 28px 24px; }
  .pager { flex-wrap: wrap; justify-content: center; }
  .seg { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .seg-btn { min-width: 0; padding: 8px 6px; }
  .link { padding: 7px 4px; display: inline-block; }
  .drop { padding: 22px 14px; }
  #sec-demands > .toolbar > .btn.primary, #sec-reimbs > .toolbar > .btn.primary { width: 100%; }
  .detail-actions { position: sticky; bottom: -14px; margin: 10px -14px -14px; padding: 12px 14px max(12px, env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid var(--border); backdrop-filter: blur(10px); z-index: 2; }
  .detail-actions .btn { flex: 1 1 44%; }
  .personnel-pick-list { max-height: 60dvh; }
  .personnel-pick-card { align-items: stretch; flex-direction: column; padding: 12px; }
  .personnel-pick-export { width: 100%; }

  .table-wrap:has(.mobile-cards) { overflow: visible; }
  table.mobile-cards, table.mobile-cards tbody { display: block; }
  table.mobile-cards tr:first-child { display: none; }
  table.mobile-cards tr { display: block; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; padding: 6px 12px; background: #fff; box-shadow: 0 2px 8px rgba(15,23,42,.04); }
  table.mobile-cards tr:hover td { background: transparent; }
  table.mobile-cards td { display: grid; grid-template-columns: 104px minmax(0,1fr); gap: 10px; align-items: start; padding: 7px 0; border-bottom: 1px dashed #edf0f3; white-space: normal; overflow-wrap: anywhere; }
  table.mobile-cards td:last-child { border-bottom: 0; }
  table.mobile-cards td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 500; }
  table.mobile-cards td.mobile-actions { display: block; padding: 6px 0 2px; }
  table.mobile-cards td.mobile-actions::before { display: block; margin-bottom: 2px; }
}

.chat-msg { margin-bottom: 10px; padding: 10px 12px; border-radius: 10px; background: #f1f5f9; }
.chat-msg.user { background: #eff6ff; }
.chat-msg.assistant { background: #f0fdf4; }
.chat-msg b { display: block; margin-bottom: 4px; font-size: 12px; color: var(--muted); }

@keyframes sheet-in { from { transform: translateY(24px); opacity: .75; } to { transform: translateY(0); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
