/* ============================================================
   企业财务管理系统 · 样式表
   ============================================================ */

:root {
  --primary: #1a83b8;
  --primary-dark: #15729f;
  --primary-deep: #0f5a80;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --info: #0891b2;
  --info-bg: #cffafe;

  --text: #1e293b;
  --text-2: #475569;
  --text-3: #94a3b8;
  --border: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;

  --sidebar-bg: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  --sidebar-active: #1a83b8;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .18);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.num { font-variant-numeric: tabular-nums; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-3); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }

/* ================= 登录页（左右分栏） ================= */
.login-page {
  min-height: 100vh;
  display: flex;
}

/* 左侧品牌区 */
.login-brand-panel {
  flex: 1.25;
  background: linear-gradient(150deg, #0f4a6d 0%, #15729f 55%, #1a83b8 100%);
  color: #fff;
  display: flex; flex-direction: column;
  padding: 56px 48px 28px;
  position: relative; overflow: hidden;
}
.login-brand-panel::before, .login-brand-panel::after {
  content: ""; position: absolute; border-radius: 50%;
  background: rgba(255, 255, 255, .06);
}
.login-brand-panel::before { width: 420px; height: 420px; right: -140px; top: -120px; }
.login-brand-panel::after { width: 300px; height: 300px; left: -100px; bottom: -100px; }

.brand-inner { position: relative; z-index: 1; flex: 1; }
.brand-logo { font-size: 44px; line-height: 1; }
.brand-logo img { width: 64px; height: 64px; object-fit: contain; }
.brand-title { font-size: 30px; margin-top: 18px; letter-spacing: 2px; }
.brand-slogan { color: rgba(255, 255, 255, .82); font-size: 15px; margin-top: 10px; letter-spacing: 1px; }

.brand-features { margin-top: 48px; display: flex; flex-direction: column; gap: 24px; }
.brand-feature { display: flex; align-items: center; gap: 16px; }
.bf-icon {
  width: 48px; height: 48px; flex-shrink: 0;
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.brand-feature strong { font-size: 15px; letter-spacing: .5px; }
.brand-feature p { color: rgba(255, 255, 255, .68); font-size: 12px; margin-top: 2px; }

.brand-footer {
  position: relative; z-index: 1;
  color: rgba(255, 255, 255, .55); font-size: 12px;
  border-top: 1px solid rgba(255, 255, 255, .16); padding-top: 18px;
}

/* 右侧表单区 */
.login-form-panel {
  flex: 1; background: #f8fafc;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 32px 24px;
}
.login-card {
  width: 400px; max-width: 100%;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 42px 40px 34px;
}

.login-brand { margin-bottom: 28px; }
.login-brand h2 { font-size: 24px; color: var(--text); letter-spacing: 1px; }
.login-brand p { color: var(--text-3); font-size: 13px; margin-top: 8px; }

.login-form .field { display: block; margin-bottom: 18px; }
.login-form .field-icon { position: relative; }
.login-form .field-icon .fi {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  font-size: 15px; opacity: .6; pointer-events: none;
}
.login-form .field input {
  width: 100%; height: 46px; padding: 0 14px 0 42px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.login-form .field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 131, 184, .14);
}

.btn-login {
  height: 46px; font-size: 15px; letter-spacing: 6px;
  background: #1a83b8; border-color: #1a83b8; border-radius: 23px;
  box-shadow: 0 6px 16px rgba(26, 131, 184, .35);
}
.btn-login:hover { background: #15729f; border-color: #15729f; }

.login-error {
  background: var(--danger-bg); color: var(--danger);
  border-radius: 6px; padding: 8px 12px; font-size: 13px; margin-bottom: 16px;
}

.login-tips {
  margin-top: 20px; padding: 12px 14px;
  background: #f8fafc; border: 1px dashed var(--border); border-radius: 6px;
  font-size: 12px; color: var(--text-3); line-height: 1.9;
}
.login-tips code {
  color: var(--primary-dark); background: #e8f4fa;
  padding: 1px 6px; border-radius: 4px; font-size: 12px;
}
.login-footer { text-align: center; color: var(--text-3); font-size: 12px; margin-top: 22px; }

@media (max-width: 860px) {
  .login-page { flex-direction: column; }
  .login-brand-panel { padding: 36px 28px 20px; }
  .brand-features { margin-top: 24px; gap: 14px; }
  .brand-title { font-size: 24px; }
  .login-form-panel { padding: 28px 20px; }
}

/* ================= 整体布局：CRM 风格 ================= */
.app-layout { display: flex; flex-direction: column; min-height: 100vh; }

/* 顶部导航 */
.topnav {
  position: relative;
  height: 46px; background: #1a83b8;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; flex-shrink: 0; z-index: 100;
}
.nav-toggle {
  display: none; flex-shrink: 0;
  width: 38px; height: 30px; margin-left: 10px;
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.35);
  border-radius: 6px; color: #fff; font-size: 15px; line-height: 1;
  cursor: pointer; transition: background .15s;
}
.nav-toggle:hover { background: rgba(255,255,255,.28); }
.topnav-logo {
  display: flex; align-items: center; gap: 8px;
  color: #fff; font-size: 15px; font-weight: 600;
  white-space: nowrap;
}
.topnav-logo-img {
  width: 32px; height: 32px; border-radius: 4px; object-fit: contain;
  background: rgba(255,255,255,.12); padding: 2px;
}
.topnav-menu { display: flex; align-items: center; gap: 2px; flex: 1; margin-left: 16px; }
.topnav-menu .nav-item {
  position: relative;
  padding: 0 14px; height: 46px; line-height: 46px;
  color: rgba(255,255,255,.9); text-decoration: none;
  font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: background .15s;
}
.topnav-menu .nav-item:hover { background: rgba(255,255,255,.12); color: #fff; }
.topnav-menu .nav-item.active {
  background: rgba(0,0,0,.14); color: #fff; font-weight: 500;
}
.topnav-menu .nav-item.active::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 0;
  height: 3px; background: #fff; border-radius: 2px 2px 0 0;
}
.nav-badge {
  display: inline-block; min-width: 16px; height: 16px; line-height: 16px;
  padding: 0 4px; border-radius: 8px; background: #e74c3c; color: #fff;
  font-size: 10px; font-weight: 600; text-align: center; font-style: normal;
  margin-left: 4px; vertical-align: 1px;
}
.topnav-right {
  display: flex; align-items: center; gap: 12px;
  color: rgba(255,255,255,.85); font-size: 12px;
}
.topbar-date {
  font-size: 11px; color: rgba(255,255,255,.6); white-space: nowrap;
}
.topnav-logout {
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.25);
  color: #fff; font-size: 12px; padding: 3px 10px; border-radius: 4px;
  cursor: pointer; transition: background .15s;
}
.topnav-logout:hover { background: rgba(255,255,255,.25); }

/* 主体 */
.app-body { display: flex; flex: 1; min-height: 0; }

/* 左侧二级菜单 */
.submenu {
  width: 70px; flex: 0 0 70px;
  background: #f4f6f8; border-right: 1px solid #e2e8f0;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.submenu-title {
  padding: 8px 4px 4px; font-size: 10px; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 1px; text-align: center;
}
.submenu-group { margin-bottom: 4px; }
.submenu-group-label {
  display: flex; align-items: center; gap: 2px;
  padding: 4px 4px; font-size: 11px; color: #64748b;
  font-weight: 600; text-align: center; justify-content: center;
}
.submenu-item {
  display: block; padding: 6px 2px 6px 5px;
  font-size: 11px; color: #475569; text-decoration: none;
  cursor: pointer; transition: all .12s;
  border-left: 2px solid transparent;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.submenu-item:hover { background: #e8ecf1; color: #1e293b; }
.submenu-item.active { background: #e8f4fa; color: #1a83b8; border-left-color: #1a83b8; font-weight: 500; }
.submenu-count {
  display: inline-block; color: #94a3b8; font-size: 10px; margin-left: 2px;
}
.submenu-item.active .submenu-count { color: #1a83b8; }

.content { flex: 1; padding: 14px 3px 24px; overflow-y: auto; background: #f8fafc; }

/* ================= 按钮 ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  height: 30px; padding: 0 12px;
  border: 1px solid var(--border); background: #fff; color: var(--text-2);
  border-radius: 6px; font-size: 12px; cursor: pointer;
  transition: all .15s; white-space: nowrap; font-family: inherit;
}
.btn:hover { border-color: var(--primary); color: var(--primary); background: #f5fafd; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(26, 131, 184, .28); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; box-shadow: 0 3px 9px rgba(26, 131, 184, .35); }
.btn-success { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; border-color: #15803d; color: #fff; }
.btn-warning { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; border-color: #d97706; color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-edit { background: #196fa9; border-color: #196fa9; color: #fff; }
.btn-edit:hover { background: #196fa9; border-color: #196fa9; color: #fff; }
.btn-del { background: #e24d3a; border-color: #e24d3a; color: #fff; }
.btn-del:hover { background: #e24d3a; border-color: #e24d3a; color: #fff; }
.btn-invoice { background: #30a530; border-color: #30a530; color: #fff; }
.btn-invoice:hover { background: #2a912a; border-color: #2a912a; color: #fff; }
.btn-export { background: #ec921d; border-color: #ec921d; color: #fff; }
.btn-export:hover { background: #d97f10; border-color: #d97f10; color: #fff; }
.btn-import { background: #16aac4; border-color: #16aac4; color: #fff; }
.btn-import:hover { background: #1295aa; border-color: #1295aa; color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #f1f5f9; }
.btn-sm { height: 24px; padding: 0 8px; font-size: 11px; border-radius: 4px; }
.btn-block { width: 100%; height: 42px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ================= 卡片 ================= */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-title::before {
  content: ""; width: 3px; height: 14px; background: var(--primary); border-radius: 2px;
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }

/* 统计卡片 */
.stat-card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; display: flex; align-items: center; gap: 14px;
  transition: transform .18s, box-shadow .18s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .1);
}
.stat-icon {
  width: 46px; height: 46px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  flex-shrink: 0;
}
.stat-icon.bg-blue { background: #e8f4fa; }
.stat-icon.bg-green { background: #dcfce7; }
.stat-icon.bg-red { background: #fee2e2; }
.stat-icon.bg-amber { background: #fef3c7; }
.stat-info { min-width: 0; }
.stat-label { font-size: 12px; color: var(--text-3); }
.stat-value { font-size: 22px; font-weight: 700; margin-top: 2px; white-space: nowrap; }
.stat-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ================= 表格 ================= */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
  border: 1px solid #ededed;
}
.data-table th {
  background: #f0f7fb; color: #33607a; font-weight: 600;
  text-align: left; padding: 9px 1px; white-space: nowrap;
  border: 1px solid #ededed;
}
.data-table td {
  padding: 8px 1px; border: 1px solid #ededed; vertical-align: middle;
  white-space: nowrap; text-align: left; font-weight: normal;
}
.data-table td.text-right,
.data-table td.num,
.data-table td.numbers { text-align: right; }
.data-table th.text-right,
.data-table th.num,
.data-table th.numbers { text-align: right; }
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover { background: #f5fafd; }
.data-table .col-actions { white-space: nowrap; text-align: right; }
.data-table .col-actions .btn { margin-right: 4px; }

/* 合同附件上传 */
.attach-box { display: flex; flex-direction: column; gap: 8px; }
.attach-upload-btn {
  align-self: flex-start;
  background: #fff; color: #196fa9; border: 1px solid #196fa9; border-radius: 6px;
  padding: 6px 20px; font-size: 13px; cursor: pointer; transition: background .12s;
}
.attach-upload-btn:hover { background: #e8f4fa; }
.attach-list { display: flex; flex-direction: column; gap: 6px; }
.attach-item { display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.attach-dl-btn {
  background: #fff; color: #196fa9; border: 1px solid #196fa9; border-radius: 4px;
  padding: 1px 10px; font-size: 12px; cursor: pointer; text-decoration: none; line-height: 1.6;
}
.attach-dl-btn:hover { background: #e8f4fa; }
.attach-name { color: #196fa9; text-decoration: underline; cursor: pointer; word-break: break-all; }
.attach-size { color: #94a3b8; font-size: 12px; }
.attach-del { color: #e24d3a; background: none; border: none; cursor: pointer; font-size: 12px; padding: 0 4px; }
.attach-empty { color: #94a3b8; font-size: 12px; }

/* 合同操作日志悬浮气泡 */
.log-icon { height: 26px; width: 26px; border-radius: 50%; cursor: help; object-fit: cover; display: inline-block; border: 1px solid #d9e8f2; vertical-align: middle; }
.log-popover {
  position: fixed; z-index: 1100; width: 360px; max-height: 320px; overflow-y: auto;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .22); padding: 10px 12px;
}
.log-popover .log-row { padding: 5px 0; border-bottom: 1px dashed #f0f0f0; }
.log-popover .log-row:last-child { border-bottom: none; }
.log-popover .log-time { font-size: 11px; color: #94a3b8; line-height: 1.5; }
.log-popover .log-txt { font-size: 11px; color: #475569; line-height: 1.5; word-break: break-all; }
.log-empty { font-size: 12px; color: #94a3b8; padding: 4px 2px; }
.data-table.dense th { padding: 8px 10px; font-size: 12px; }
.data-table.dense td { padding: 6px 10px; }

/* ====== 横向日历式 月份+季度合并汇总表 ====== */
table.rpt-mq-grid { border-collapse: separate; border-spacing: 0; }
table.rpt-mq-grid thead th.rpt-m {
  background: #f1f5f9; color: #475569; font-weight: 600;
  text-align: center; font-size: 12px; padding: 8px 10px;
  border-right: 1px solid #e2e8f0; border-bottom: 1px solid #e2e8f0;
  min-width: 80px;
}
table.rpt-mq-grid thead th.rpt-q {
  background: #1a83b8 !important; color: #fff !important; font-weight: 700;
  text-align: center; font-size: 12px; padding: 8px 12px;
  border-right: 2px solid #0f5a80; border-bottom: 2px solid #0f5a80;
  min-width: 92px;
}
table.rpt-mq-grid thead th.rpt-corner {
  background: #0f5a80; color: #fff; font-weight: 600;
  font-size: 13px; padding: 8px 14px; text-align: left;
  border-right: 1px solid #e2e8f0; border-bottom: 2px solid #0f5a80;
  white-space: nowrap;
}
table.rpt-mq-grid thead th.rpt-year {
  background: #16a34a; color: #fff; font-weight: 700;
  text-align: center; font-size: 12px; padding: 8px 12px;
  border-bottom: 2px solid #0f7a38;
}
table.rpt-mq-grid tbody td {
  padding: 8px 10px; font-size: 12px; white-space: nowrap;
  border-right: 1px solid #f1f5f9; border-bottom: 1px solid #f1f5f9;
}
table.rpt-mq-grid tbody td.rpt-corner {
  background: #f1f5f9; font-weight: 600; color: #334155;
  text-align: left; padding: 8px 14px;
}
table.rpt-mq-grid tbody td.rpt-q-v {
  background: #e8f4fa; color: #0f5a80; font-weight: 700;
  border-right: 2px solid #1a83b8; border-bottom: 2px solid #1a83b8;
  font-size: 12px;
}
table.rpt-mq-grid tbody td.rpt-year-v {
  background: #dcfce7; color: #0f7a38; font-weight: 700;
  border-left: 2px solid #16a34a; font-size: 13px;
}
table.rpt-mq-grid tbody tr:hover td:not(.rpt-q-v):not(.rpt-year-v):not(.rpt-corner) {
  background: #f8fafc;
}

/* 状态标签（CRM 风格） */
.tag {
  display: inline-block; padding: 1px 6px; border-radius: 3px;
  font-size: 11px; line-height: 1.5; white-space: nowrap;
}
.tag-green { background: var(--success-bg); color: var(--success); }
.tag-red { background: var(--danger-bg); color: var(--danger); }
.tag-blue { background: #e8f4fa; color: var(--primary-dark); }
.tag-orange { background: var(--warning-bg); color: var(--warning); }
.tag-gray { background: #f1f5f9; color: var(--text-2); }
.pw-masked { font-family: "Segoe UI Symbol", sans-serif; letter-spacing: 1px; color: #333; }
.pw-masked.pw-shown { font-family: inherit; letter-spacing: 0; color: var(--brand); font-weight: 600; }
.tag-cyan { background: var(--info-bg); color: var(--info); }

.hl { background: #fde68a; color: #92400e; padding: 0 2px; border-radius: 3px; }

/* ================= 表单 ================= */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-item label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.form-item label .req { color: var(--danger); margin-right: 2px; }
.form-item input, .form-item select, .form-item textarea {
  width: 100%; padding: 8px 11px; font-size: 13px; font-family: inherit;
  border: 1px solid var(--border); border-radius: 6px; outline: none;
  transition: border-color .15s, box-shadow .15s; background: #fff; color: var(--text);
}
.form-item textarea { resize: vertical; min-height: 64px; }
.form-item input:focus, .form-item select:focus, .form-item textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26, 131, 184, .12);
}
.form-item input:disabled, .form-item select:disabled { background: #f8fafc; color: var(--text-3); }
.form-hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* 筛选栏（CRM 风格：淡蓝底） */
.filter-bar {
  background: #f0f7fb; border-radius: 6px; box-shadow: var(--shadow);
  padding: 10px 12px; margin-bottom: 12px;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-end;
  border: 1px solid #d9e8f2;
}
.filter-bar .form-item { margin: 0; flex-shrink: 0; min-width: 130px; }
.filter-bar .form-item label { font-size: 11px; margin-bottom: 3px; }
.filter-bar .form-item input,
.filter-bar .form-item select { width: 130px; height: 25px; font-size: 12px; padding: 0 4px; }
.filter-bar .filter-actions { display: flex; gap: 6px; margin-left: auto; }
.filter-bar .filter-actions .btn { height: 25px; }

/* 自动完成下拉框 */
.autocomplete-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  background: #fff; border: 1px solid #d9e8f2; border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.1); max-height: 240px; overflow-y: auto;
  margin-top: 4px;
}
.autocomplete-search { padding: 8px; border-bottom: 1px solid #f0f0f0; }
.autocomplete-search input {
  width: 100%; height: 30px; padding: 0 10px; border: 1px solid var(--border);
  border-radius: 4px; font-size: 13px; outline: none;
}
.autocomplete-search input:focus { border-color: var(--primary); }
.autocomplete-item {
  padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #f5f5f5;
}
.autocomplete-item:hover { background: #f0f7fb; }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-name { font-size: 13px; font-weight: 500; color: var(--text); }
.autocomplete-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* 工具栏 */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.toolbar .toolbar-left, .toolbar .toolbar-right { display: flex; gap: 8px; align-items: center; }

/* ================= 模态框 ================= */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 1000; padding: 60px 16px; overflow-y: auto;
  animation: fadeIn .18s;
}
.modal {
  background: #fff; border-radius: 10px; width: 680px; max-width: 100%;
  box-shadow: var(--shadow-lg); animation: slideDown .2s;
}
.modal.modal-lg { width: 720px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-3); line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; max-height: 65vh; overflow-y: auto; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* 弹窗编辑表单：输入框统一 130×25，固定 4 列紧凑排列 */
.modal .form-grid { grid-template-columns: repeat(4, 130px); gap: 12px 14px; }
.modal .form-grid-5 { grid-template-columns: repeat(5, 130px); gap: 12px 12px; }
.modal .receipt-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px 12px; }
.modal .receipt-grid .form-item input:not([type="file"]),
.modal .receipt-grid .form-item select { width: 100%; }
.modal.modal-xl { width: 760px; }
/* 合同列表中由其他模块自动汇总的字段：蓝色表头 + 悬停提示 */
th.sync-col { color: #1a83b8; cursor: help; border-bottom: 1px dashed #1a83b8; }
/* 发票编辑器：上传预览 */
.inv-img-preview {
  width: 130px; height: 90px; border: 1px dashed #d9e8f2; border-radius: 6px;
  background: #f8fafc; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.inv-img-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.inv-pdf-placeholder { font-size: 11px; color: #64748b; padding: 4px 6px; text-align: center; }
.inv-upload-wrap { display: flex; flex-direction: column; gap: 4px; }
.modal .form-item label { margin-bottom: 4px; font-size: 12px; }
.modal .form-item input:not([type="file"]),
.modal .form-item select { width: 130px; height: 25px; padding: 0 6px; font-size: 12px; }
.modal .form-item textarea { width: 100%; min-height: 64px; }
.modal .autocomplete-dropdown { min-width: 220px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: translateY(0); } }

/* ================= Toast ================= */
#toastRoot { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 240px; max-width: 380px;
  background: #fff; border-radius: 8px; box-shadow: var(--shadow-lg);
  padding: 12px 16px; font-size: 13px; display: flex; align-items: center; gap: 10px;
  border-left: 4px solid var(--primary);
  animation: toastIn .22s;
}
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast .toast-icon { font-size: 16px; }
.toast.removing { animation: toastOut .2s forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }

/* ================= 分页 ================= */
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.pagination .page-info { color: var(--text-3); font-size: 12px; margin-right: 8px; }
.page-btn {
  min-width: 30px; height: 30px; padding: 0 8px;
  border: 1px solid var(--border); background: #fff; border-radius: 6px;
  cursor: pointer; font-size: 12px; color: var(--text-2);
}
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ================= 空状态 ================= */
.empty-state { padding: 48px 16px; text-align: center; color: var(--text-3); }
.empty-state .empty-icon {
  width: 72px; height: 72px; margin: 0 auto;
  background: #f0f7fb; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; opacity: .9;
}
.empty-state p { margin-top: 12px; font-size: 13px; }

/* ================= 滚动条 ================= */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c5d3de; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a8bccb; }

/* ================= 图表 ================= */
.chart-box { position: relative; width: 100%; }
.chart-box canvas { display: block; width: 100%; }
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 8px 16px;
  margin-top: 10px; font-size: 12px; color: var(--text-2);
}
.chart-legend .legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.legend-item .legend-value { color: var(--text); font-weight: 600; }

.doughnut-layout { display: flex; align-items: center; gap: 18px; }
.doughnut-layout .chart-box { width: 190px; flex-shrink: 0; }
.doughnut-legend { flex: 1; display: flex; flex-direction: column; gap: 7px; font-size: 12px; min-width: 0; }
.doughnut-legend .dl-item { display: flex; align-items: center; gap: 8px; }
.doughnut-legend .dl-label { flex: 1; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doughnut-legend .dl-value { font-weight: 600; white-space: nowrap; }
.doughnut-legend .dl-pct { width: 44px; text-align: right; color: var(--text-3); }

/* 账户卡片 */
.account-card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; border-top: 3px solid var(--primary);
}
.account-card .ac-name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.account-card .ac-balance { font-size: 22px; font-weight: 700; margin-top: 10px; }
.account-card .ac-meta { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.account-card.ac-cash { border-top-color: #16a34a; }
.account-card.ac-bank { border-top-color: #1a83b8; }
.account-card.ac-alipay { border-top-color: #0891b2; }
.account-card.ac-wechat { border-top-color: #16a34a; }
.account-card.ac-other { border-top-color: #94a3b8; }

/* 汇总行 */
.summary-row {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.summary-pill {
  flex: 1; min-width: 150px; background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 18px;
  transition: transform .18s, box-shadow .18s;
}
.summary-pill:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .1);
}
.summary-pill .sp-label { font-size: 12px; color: var(--text-3); }
.summary-pill .sp-value { font-size: 19px; font-weight: 700; margin-top: 4px; }
.summary-pill-inline { display: flex; align-items: baseline; gap: 8px; flex: 0 0 auto; }
.summary-pill-inline .sp-value { font-size: 16px; margin-top: 0; white-space: nowrap; }

/* 设置页分区 */
.settings-section { margin-bottom: 20px; }
.settings-section h4 { font-size: 14px; margin-bottom: 12px; color: var(--text); }
.log-list { max-height: 320px; overflow-y: auto; font-size: 12px; }
.log-item { padding: 7px 0; border-bottom: 1px dashed var(--border); color: var(--text-2); display: flex; gap: 10px; }
.log-item .log-time { color: var(--text-3); white-space: nowrap; }
.log-item .log-user { color: var(--primary-dark); white-space: nowrap; min-width: 90px; }

.timeline-count { font-size: 12px; color: var(--text-3); }

/* ================= 响应式 ================= */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2-1 { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .topnav-menu { display: none; }
  .topnav-menu.open {
    display: flex; flex-direction: column; align-items: stretch; gap: 0;
    position: absolute; top: 46px; left: 0; right: 0; margin-left: 0;
    background: var(--primary-dark);
    box-shadow: 0 10px 24px rgba(15, 23, 42, .22);
    max-height: calc(100vh - 46px); overflow-y: auto;
  }
  .topnav-menu.open .nav-item {
    height: 44px; line-height: 44px; padding: 0 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
  }
  .topnav-menu.open .nav-item.active { background: rgba(0,0,0,.2); }
  .topnav-menu.open .nav-item.active::after { display: none; }
}

@media (max-width: 768px) {
  .submenu { width: 0; overflow: hidden; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 10px; }
  .topnav { padding: 0 10px; }
  .topbar-date { display: none; }
  .user-name, .user-role { display: none; }
  .doughnut-layout { flex-direction: column; align-items: stretch; }
  .filter-bar .filter-actions { margin-left: 0; width: 100%; }
}

/* ================= 无障碍：减少动效 ================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ================= 打印 ================= */
@media print {
  .topnav, .submenu, .toolbar, .filter-bar, .pagination,
  .col-actions, .no-print { display: none !important; }
  .content { padding: 0; }
  .card, .summary-pill { box-shadow: none; border: 1px solid #e2e8f0; break-inside: avoid; }
  body { background: #fff; }
}

/* ================= 网址访问口令门 ================= */
.gate-page {
  position: fixed; inset: 0; z-index: 9999;
  background: linear-gradient(135deg, #0f5a80 0%, #1a83b8 60%, #15729f 100%);
  display: flex; align-items: center; justify-content: center;
}
.gate-card {
  background: #fff; border-radius: 14px; padding: 38px 34px 30px;
  width: 340px; box-shadow: 0 24px 70px rgba(0,0,0,.28);
  text-align: center; box-sizing: border-box;
}
.gate-logo img { width: 58px; border-radius: 12px; }
.gate-card h2 { margin: 14px 0 2px; font-size: 20px; color: #1f2937; }
.gate-card input {
  width: 100%; box-sizing: border-box; margin-bottom: 12px;
  padding: 11px 13px; border: 1px solid #d4dde5; border-radius: 8px;
  font-size: 14px; outline: none; transition: border-color .15s;
}
.gate-card input:focus { border-color: #1a83b8; }
