* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "Microsoft YaHei", "PingFang SC", sans-serif; background: #f0f2f5; color: #1a1a1a; font-size: 14px; }
#app { display: flex; min-height: 100vh; }

/* 侧边栏 */
#sidebar { width: 210px; background: #1f2d3d; color: #c0c4cc; flex-shrink: 0; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.logo { padding: 18px 16px; font-size: 18px; font-weight: bold; color: #fff; border-bottom: 1px solid #2d3a4a; }
.logo span { font-size: 12px; color: #6b8cae; font-weight: normal; }
#nav { padding: 8px 0; flex: 1; overflow-y: auto; }
.sidebar-beian { padding: 12px 16px; font-size: 11px; border-top: 1px solid #2d3a4a; flex-shrink: 0; }
.sidebar-beian a { color: #6b8cae; text-decoration: none; }
.sidebar-beian a:hover { color: #fff; }
.nav-group { padding: 10px 16px 4px; font-size: 12px; color: #6b8cae; }
.nav-item { padding: 9px 16px 9px 24px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.nav-item:hover { background: #2d3a4a; color: #fff; }
.nav-item.active { background: #2f5597; color: #fff; border-right: 3px solid #7da3e0; }
.badge { background: #f56c6c; color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }

/* 主区 */
#main { flex: 1; min-width: 0; }
#topbar { background: #fff; height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; box-shadow: 0 1px 4px rgba(0,0,0,.08); position: sticky; top: 0; z-index: 10; }
.page-title { font-size: 16px; font-weight: bold; }
.top-actions { display: flex; align-items: center; gap: 14px; font-size: 13px; color: #666; }
#content { padding: 18px 20px 40px; }

/* 卡片与表格 */
.card { background: #fff; border-radius: 8px; padding: 16px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card h3 { font-size: 14px; margin-bottom: 12px; color: #2f5597; border-left: 3px solid #2f5597; padding-left: 8px; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { background: #4472C4; color: #fff; padding: 8px 8px; text-align: left; font-weight: 600; white-space: nowrap; }
table.grid td { padding: 7px 8px; border-bottom: 1px solid #eee; vertical-align: top; }
table.grid tr:hover td { background: #f5f8ff; }
.table-wrap { overflow-x: auto; }

/* KPI */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border-radius: 8px; padding: 14px 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.kpi .k-label { font-size: 12px; color: #888; }
.kpi .k-value { font-size: 22px; font-weight: bold; margin-top: 4px; color: #2f5597; }
.kpi .k-value.red { color: #c0392b; }
.kpi .k-value.green { color: #1e8449; }
.kpi .k-sub { font-size: 11px; color: #aaa; margin-top: 2px; }

/* 标签与状态 */
.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; white-space: nowrap; }
.tag-green { background: #C6EFCE; color: #006100; }
.tag-yellow { background: #FFEB9C; color: #9C6500; }
.tag-orange { background: #FCE4D6; color: #C55A11; }
.tag-red { background: #FFC7CE; color: #9C0006; }
.tag-gray { background: #E0E0E0; color: #555; }
.tag-blue { background: #D9E2F3; color: #2F5597; }

/* 按钮与表单 */
.btn { background: #2f5597; color: #fff; border: none; border-radius: 5px; padding: 7px 14px; cursor: pointer; font-size: 13px; }
.btn:hover { background: #25447a; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-green { background: #548235; } .btn-green:hover { background: #446a2b; }
.btn-red { background: #c0392b; } .btn-red:hover { background: #a03024; }
.btn-gray { background: #909399; } .btn-gray:hover { background: #7a7e83; }
.btn-link { background: none; color: #2f5597; padding: 2px 6px; text-decoration: underline; }
.toolbar { display: flex; gap: 10px; margin-bottom: 12px; align-items: center; flex-wrap: wrap; }
input, select, textarea { padding: 6px 8px; border: 1px solid #d0d5dd; border-radius: 5px; font-size: 13px; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid #7da3e0; border-color: #2f5597; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-item label { display: block; font-size: 12px; color: #666; margin-bottom: 4px; }
.form-item input, .form-item select, .form-item textarea { width: 100%; }
.form-actions { margin-top: 16px; text-align: right; display: flex; gap: 10px; justify-content: flex-end; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-mask.hidden { display: none; }
.modal { background: #fff; border-radius: 10px; width: 720px; max-width: 94vw; max-height: 88vh; overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid #eee; font-weight: bold; font-size: 15px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: #999; }
.modal-body { padding: 18px; }

/* 提示 */
.notice { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 13px; }
.notice-blue { background: #e8f0fe; color: #2f5597; border-left: 3px solid #2f5597; }
.notice-red { background: #fdecea; color: #c0392b; border-left: 3px solid #c0392b; }
.muted { color: #999; font-size: 12px; }

/* 单据预览层（PI/CI/PL）：页内全屏显示，打印时仅打印单据 */
#docOverlay { display: none; position: fixed; inset: 0; background: #fff; z-index: 300; overflow: auto; }
#docOverlay.show { display: block; }
.doc-toolbar { position: sticky; top: 0; background: #2F5597; padding: 10px 18px; display: flex; gap: 12px; align-items: center; z-index: 10; }
.doc-toolbar button { background: #fff; color: #2F5597; border: none; padding: 8px 18px; border-radius: 4px; font-size: 14px; font-weight: bold; cursor: pointer; }
.doc-toolbar button:hover { background: #e6eefb; }
.doc-toolbar span { color: #fff; font-size: 12px; }
.doc { position: relative; max-width: 820px; margin: 0 auto; padding: 36px 40px; z-index: 1; font-family: Arial, "Microsoft YaHei", sans-serif; color: #111; }
.doc .head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid #2F5597; padding-bottom: 14px; }
.doc .co { display: flex; align-items: center; gap: 14px; }
.doc .co img.logo { width: 72px; height: 72px; object-fit: contain; flex-shrink: 0; }
.doc .co h1 { font-size: 20px; color: #2F5597; }
.doc .co p { font-size: 12px; color: #555; line-height: 1.7; }
.doc .dt { text-align: right; }
.doc .dt h2 { font-size: 20px; letter-spacing: 1px; }
.doc .dt .no { font-size: 13px; font-weight: bold; margin-top: 6px; }
.doc .meta { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 13px; }
.doc .meta td { border: 1px solid #999; padding: 6px 10px; }
.doc .meta td.k { background: #E6F1FB; font-weight: bold; width: 22%; }
.doc table.items { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; table-layout: fixed; }
.doc table.items thead { display: table-header-group; }
.doc table.items tr { page-break-inside: avoid; }
.doc table.items th { background: #2F5597; color: #fff; padding: 8px; border: 1px solid #2F5597; font-size: 12px; text-align: left; }
.doc table.items td { border: 1px solid #aaa; padding: 8px; vertical-align: top; word-wrap: break-word; }
.doc .bank { margin-top: 16px; font-size: 12px; border: 1px solid #aaa; padding: 12px; }
.doc .pack { margin-top: 14px; font-size: 13px; border: 1px solid #aaa; padding: 12px; white-space: pre-line; }
.doc .sign { display: flex; justify-content: space-between; margin-top: 44px; font-size: 13px; page-break-inside: avoid; }
.doc .sig { text-align: center; }
.doc .sig .line { width: 170px; border-top: 1px solid #333; margin-top: 44px; padding-top: 6px; }
.doc .foot { text-align: center; font-size: 11px; color: #999; margin-top: 28px; page-break-inside: avoid; }
@page { size: A4; margin: 14mm; }
@media print {
  body > #app, .modal-mask { display: none !important; }
  #docOverlay { display: block !important; position: static; overflow: visible; background: #fff; }
  .doc-toolbar { display: none !important; }
  .doc { max-width: none; padding: 14mm; }
}
.money { font-variant-numeric: tabular-nums; }
.text-red { color: #c0392b; font-weight: bold; }
.text-green { color: #1e8449; }
.empty { padding: 30px; text-align: center; color: #999; }

/* 登录页 */
.login-mask { position: fixed; inset: 0; background: #f0f2f5; z-index: 500; display: flex; align-items: center; justify-content: center; }
.login-mask.hidden { display: none; }
.login-card { background: #fff; border-radius: 14px; padding: 34px 36px; width: 360px; box-shadow: 0 6px 24px rgba(0,0,0,.08); }
.login-logo { font-size: 22px; font-weight: bold; color: #2f5597; text-align: center; }
.login-logo span { font-size: 13px; color: #889; font-weight: normal; }
.login-title { text-align: center; font-size: 15px; color: #333; margin: 18px 0 22px; font-weight: bold; }
.login-card .form-item { margin-bottom: 14px; }
.login-card input { width: 100%; padding: 10px 12px; font-size: 14px; }
.login-btn { width: 100%; padding: 11px; font-size: 15px; margin-top: 6px; }
.login-err { color: #c0392b; font-size: 13px; min-height: 18px; margin-bottom: 4px; }
.login-beian { margin-top: 16px; text-align: center; font-size: 12px; }
.login-beian a { color: #999; text-decoration: none; }
.login-beian a:hover { color: #2f5597; }
.user-box { font-size: 13px; color: #2f5597; font-weight: bold; }
