/* 云创 CRM 设计系统
 * 布局：左侧深色侧栏 + 顶栏 + 浅灰内容区；白色卡片承载内容。
 * 组件类名：card / kpi / btn / badge / progress / table / form-grid / field / dialog / msg / empty / segmented / menu / toolbar
 * 笔记本 1366×768 无横向滚动：表格长文本用 .truncate 截断，悬停 title 看全称。
 */

/* ---------------------------------------------------------------- 设计变量 */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e3e7ed;
  --border-strong: #cfd6df;
  --ink: #1e293b;
  --ink-2: #475569;
  --muted: #8a94a6;

  --primary: #1f4e8c;
  --primary-hover: #183f73;
  --primary-soft: #eaf1fa;
  --primary-ring: rgba(31, 78, 140, .18);

  --sidebar: #12223b;
  --sidebar-ink: #a9b6ca;
  --sidebar-active: #1d3457;
  --sidebar-accent: #5a9bf0;

  --success: #15803d;  --success-soft: #e7f5ec;
  --warning: #b8590b;  --warning-soft: #fff1e2;
  --danger:  #c62828;  --danger-soft:  #fdecec;
  --purple:  #6d3fd1;  --purple-soft:  #f1ebff;
  --info:    #1f4e8c;  --info-soft:    #eaf1fa;
  --neutral: #5b677a;  --neutral-soft: #eef1f5;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16), 0 2px 6px rgba(16, 24, 40, .08);

  --sidebar-w: 212px;
  --gap: 20px;
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
          "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
}

/* ---------------------------------------------------------------- 基础 */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.55 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 600; color: var(--ink); }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; }
.icon { flex: none; display: inline-block; vertical-align: middle; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.neg, .num.neg { color: var(--danger); }
.pos { color: var(--success); }
.nowrap { white-space: nowrap; }
.sub { color: var(--muted); font-size: 12px; }
.warn { color: var(--danger); font-weight: 600; }
.sub-line { display: block; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.4; }
.truncate { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 截断宽度随视口伸缩：1366 宽时约 90 / 123 / 177 / 260px，1920 宽时更宽 */
.t-sm { max-width: clamp(72px, 6.5vw, 140px); }
.t-md { max-width: clamp(100px, 9vw, 220px); }
.t-lg { max-width: clamp(140px, 13vw, 320px); }
.t-xl { max-width: clamp(200px, 19vw, 440px); }
.t-proj { max-width: clamp(200px, 16vw, 440px); } /* 项目列表的项目名：比 t-xl 窄，给"附件"列让位 */
.t-wide { max-width: min(52vw, 760px); }

/* ---------------------------------------------------------------- 布局 */
.app { display: flex; min-height: 100vh; background: linear-gradient(to right, var(--sidebar) var(--sidebar-w), transparent 0); }
.sidebar {
  position: sticky; top: 0; height: 100vh; flex: none; width: var(--sidebar-w);
  display: flex; flex-direction: column; background: var(--sidebar); color: var(--sidebar-ink);
  padding: 16px 12px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; color: #fff; }
.brand:hover { color: #fff; text-decoration: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text b { font-size: 15px; letter-spacing: .5px; }
.brand-text small { font-size: 11px; color: var(--sidebar-ink); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px;
  color: var(--sidebar-ink); font: inherit; background: none; border: 0; cursor: pointer; text-align: left;
  position: relative;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--sidebar-accent);
}
.nav-label { flex: 1; min-width: 0; white-space: nowrap; }
.nav-user { margin-left: 6px; color: #6f7f98; font-size: 12px; }
.nav-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center;
  background: #e5484d; color: #fff; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.nav-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .08); display: flex; flex-direction: column; gap: 2px; }
.nav-foot form { margin: 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 60px; padding: 10px 28px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 12px; row-gap: 2px; min-width: 0; }
/* 长标题（如项目名）最多折两行，不再一行截断 */
.topbar-title h1 {
  font-size: 18px; line-height: 1.35; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
}
.page-sub { color: var(--muted); font-size: 13px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-tools { display: flex; align-items: center; gap: 10px; flex: none; }
.content { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.grid-2-1 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--gap); }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------------------------------------------------------------- 卡片 */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-head .count { color: var(--muted); font-weight: 400; font-size: 13px; }
.card-tools { display: flex; align-items: center; gap: 8px; }
.card-body { padding: 16px 20px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 10px 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.card-note { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.card-hint { color: var(--muted); font-size: 12px; margin: 4px 0 0; font-weight: 400; }

/* ---------------------------------------------------------------- 指标卡 */
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; min-width: 0; display: flex; flex-direction: column; gap: 4px;
}
.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 22px; }
.kpi-label { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13px; }
.kpi-label .icon { color: var(--muted); }
.kpi-value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value a { color: inherit; }
.kpi-unit { margin-left: 4px; font-size: 13px; font-weight: 400; color: var(--muted); }
.kpi-sub { color: var(--muted); font-size: 12px; }
.kpi-alert { display: flex; align-items: center; gap: 4px; color: var(--danger); font-size: 12px; font-weight: 600; }
.kpi-danger .kpi-value { color: var(--danger); }
.kpi-success .kpi-value { color: var(--success); }
.kpi-warning .kpi-value { color: var(--warning); }

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 500; line-height: 1; white-space: nowrap; cursor: pointer;
  transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s; user-select: none;
}
.btn:hover { background: var(--surface-2); border-color: #b9c2ce; color: var(--ink); text-decoration: none; }
.btn:focus-visible, .nav-item:focus-visible, .segmented a:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-danger { background: var(--surface); border-color: #efc2c2; color: var(--danger); }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 5px; }
.btn-icon { padding: 0; width: 26px; color: var(--ink-2); }
.btn-close {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.btn-close:hover { background: var(--neutral-soft); color: var(--ink); }

/* 新建下拉 */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 160px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg);
}
.menu-list a { display: block; padding: 8px 12px; border-radius: 6px; color: var(--ink); white-space: nowrap; }
.menu-list a:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }

/* 主体切换（分段按钮） */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--neutral-soft); border-radius: 8px; }
.segmented a, .segmented button {
  padding: 5px 12px; border-radius: 6px; color: var(--ink-2); font: inherit; font-size: 13px; border: 0; background: none;
  cursor: pointer; white-space: nowrap;
}
.segmented a:hover, .segmented button:hover { color: var(--ink); text-decoration: none; }
.segmented .active { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }

/* ---------------------------------------------------------------- 徽标 */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 11px;
  font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--neutral-soft); color: var(--neutral);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }

/* ---------------------------------------------------------------- 进度条 */
.progress { display: flex; align-items: center; gap: 8px; min-width: 90px; }
.progress-track { flex: 1; height: 6px; border-radius: 3px; background: var(--neutral-soft); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; background: var(--primary); }
.progress-success .progress-fill { background: var(--success); }
.progress-warning .progress-fill { background: #e08a1e; }
.progress-danger .progress-fill { background: var(--danger); }
.progress-pct { width: 36px; text-align: right; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 表格 */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  position: sticky; top: 0; padding: 9px 10px; text-align: left; font-weight: 500; font-size: 12px; color: var(--ink-2);
  background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 9px 10px; border-bottom: 1px solid #edf0f4; vertical-align: middle; }
.table tbody tr:hover td { background: #f7f9fc; }
.table tbody tr:last-child td { border-bottom: 0; }
.table th.num, .table td.num { text-align: right; }
.table td.date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.table td a { color: var(--ink); }
.table td a:hover { color: var(--primary); }
.table td a.strong { font-weight: 600; }
.table tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 0; }
.table .table-empty { padding: 28px 12px; text-align: center; color: var(--muted); }
.table .actions-col { text-align: right; }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.actions .btn { vertical-align: middle; }
.table td.actions .btn + .btn { margin-left: 4px; }
.card > .table-wrap:first-child .table th:first-child { border-top-left-radius: var(--radius); }
.card > .table-wrap:first-child .table th:last-child { border-top-right-radius: var(--radius); }
.table th:first-child, .table td:first-child { padding-left: 18px; }
.table th:last-child, .table td:last-child { padding-right: 18px; }

/* ---------------------------------------------------------------- 工具栏 / 筛选 / 表单 */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
input[type=text], input[type=number], input[type=date], input[type=month], input[type=email], input[type=search], input[type=password],
input[type=tel], input[type=url], input[type=file], select, textarea {
  height: 34px; width: 100%; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 14px;
  transition: border-color .12s, box-shadow .12s;
}
input[type=file] { padding: 5px 8px; height: auto; }
textarea { height: auto; min-height: 80px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
select { padding-right: 28px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
input[type=number] { font-variant-numeric: tabular-nums; }
.toolbar input, .toolbar select { width: auto; min-width: 140px; }
.search { position: relative; }
.search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 32px; min-width: 260px; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters select, .filters input { width: auto; min-width: 140px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .span-2, .form-grid .form-errors, .form-grid .form-section { grid-column: 1 / -1; }
.form-section { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--border); font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field .req { color: var(--danger); margin-left: 2px; }
.field .help { font-size: 12px; color: var(--muted); }
.field .help:empty { display: none; }
.field .error { font-size: 12px; color: var(--danger); }
.field .error:empty, .form-errors:empty { display: none; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field-check > label { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--ink); cursor: pointer; }
.field-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row input { flex: 1; }
.form-errors { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 13px; }
.form-errors ul { margin: 0; padding-left: 18px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 8px; }

/* ---------------------------------------------------------------- 弹窗 */
.dialog {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 0; border-radius: 12px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); overflow: auto;
}
.dialog-sm { width: min(420px, calc(100vw - 32px)); }
.dialog-lg { width: min(760px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(15, 23, 42, .45); }
.dialog[open] { animation: dialog-in .14s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(6px) scale(.99); } to { opacity: 1; transform: none; } }
.dialog form { margin: 0; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 22px 12px; }
.dialog-head h3 { font-size: 16px; }
.dialog-sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.dialog-sub:empty { display: none; }
.dialog-body { padding: 8px 22px 20px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; background: var(--surface-2); border-top: 1px solid var(--border); }

/* ---------------------------------------------------------------- 消息条 */
.messages { display: flex; flex-direction: column; gap: 8px; }
.msg {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; border-radius: 8px; border: 1px solid;
  font-size: 14px; background: var(--info-soft); border-color: #cddcf0; color: var(--info);
}
.msg > span { flex: 1; color: var(--ink); }
.msg .btn-close { width: 26px; height: 26px; }
.msg-success { background: var(--success-soft); border-color: #bfe3cb; color: var(--success); }
.msg-warning { background: var(--warning-soft); border-color: #f5d3ad; color: var(--warning); }
.msg-error { background: var(--danger-soft); border-color: #f2c4c4; color: var(--danger); }
.alert { display: flex; align-items: flex-start; gap: 8px; padding: 10px 14px; border-radius: 8px; font-size: 13px; background: var(--warning-soft); color: var(--warning); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }

/* ---------------------------------------------------------------- 空状态 */
.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 36px 16px; text-align: center; color: var(--muted); }
.empty-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--neutral-soft); color: #9aa5b5; margin-bottom: 4px; }
.empty-text { color: var(--ink-2); font-size: 14px; }
.empty-hint { font-size: 12px; }
.empty .btn { margin-top: 8px; }
.empty-compact { padding: 16px; }

/* ---------------------------------------------------------------- 图表 */
.chart { width: 100%; }
.chart-svg { display: block; width: 100%; height: auto; margin: 0 auto; overflow: visible; font-family: var(--font); }
.chart-svg text { font-variant-numeric: tabular-nums; }
.chart-svg .hit { fill: transparent; transition: fill .12s; }
.chart-svg .band:hover .hit { fill: #f2f6fc; }
.chart-svg .dot { cursor: default; }
.chart-svg .dot:hover circle { r: 6; }
.chart-svg .chart-link text { fill: var(--ink); }
.chart-svg .chart-link:hover text { fill: var(--primary); text-decoration: underline; }
.chart-empty {
  display: grid; place-items: center; width: 100%; max-height: 220px; min-height: 120px;
  border: 1px dashed var(--border-strong); border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 13px;
}
.chart-caption { margin: 8px 0 0; color: var(--muted); font-size: 12px; }

/* ---------------------------------------------------------------- 窄屏：侧栏收成图标栏 */
@media (max-width: 1180px) {
  :root { --sidebar-w: 64px; }
  .sidebar { padding: 16px 10px; }
  .brand { justify-content: center; padding: 4px 0 20px; }
  .brand-text, .nav-label { display: none; }
  .nav-item { justify-content: center; padding: 10px 0; }
  .nav-item.active::before { left: -10px; }
  .nav-badge { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px; }
  .content { padding: 20px 20px 40px; }
  .topbar { padding: 10px 20px; }
  .grid-2, .grid-3, .grid-2-1 { grid-template-columns: minmax(0, 1fr); }
}

/* 页面内分组标题（卡片组之上） */
.section-title { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.section-title .count { color: var(--muted); font-weight: 400; font-size: 13px; }

/* 紧凑表格（卡片内的小型明细） */
.table-compact th, .table-compact td { padding: 6px 10px; }
.table-compact th:first-child, .table-compact td:first-child { padding-left: 4px; }
.table-compact th:last-child, .table-compact td:last-child { padding-right: 4px; }
.table-compact th { background: transparent; }
.segmented-sm a, .segmented-sm button { padding: 3px 12px; font-size: 13px; }
.fc-table { margin-top: 12px; }
.aging-note { margin-top: 14px; align-items: center; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); }
.aging-note .icon { color: var(--muted); }
.aging-note a { margin-left: 4px; white-space: nowrap; }
[hidden] { display: none !important; }

/* 表单页 */
.form-card { max-width: 900px; width: 100%; }
.form-card .form-grid { padding: 20px 24px; }
.form-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px; background: var(--surface-2); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); }
.field-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; }
.pair-label { color: var(--muted); font-size: 12px; white-space: nowrap; }
.danger-zone .card-body { gap: 16px; }
.danger-zone b { color: var(--danger); font-weight: 600; }
.field input[type=file] { background: var(--surface-2); }
.field .clearable-file-input, .field .current-file { font-size: 13px; color: var(--ink-2); }

/* 款项记录展开行 */
.link-btn { display: inline-flex; align-items: center; gap: 2px; padding: 0; border: 0; background: none; font: inherit; color: var(--primary); cursor: pointer; }
.link-btn.sub-line { display: inline-flex; color: var(--primary); }
.link-btn[aria-expanded="true"] .icon { transform: rotate(180deg); }
.table tr.records-row td, .table tbody tr.records-row:hover td { background: var(--surface-2); padding-top: 4px; padding-bottom: 12px; }
.records { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 10px 24px; }
.records-title { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.record { display: grid; grid-template-columns: 90px 120px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 3px 0; border-bottom: 1px dashed var(--border); }
.record:last-child { border-bottom: 0; }
.record form { margin: 0; }
.btn-ghost-danger { color: var(--danger); }
.btn-ghost-danger:hover { background: var(--danger-soft); color: var(--danger); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.contract-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.contract-alert { margin: 12px 20px 0; }
.alert-info { background: var(--info-soft); color: var(--ink-2); }

/* 新签向导 */
.wizard { max-width: 980px; }
.form-section { display: flex; align-items: center; gap: 8px; }
.form-section-first { margin-top: 0; padding-top: 0; border-top: 0; }
.step { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--primary); color: #fff; font-size: 12px; font-weight: 600; }
.choice-pills > div, .choice-list > div { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-list > div { flex-direction: column; }
.choice-pills label, .choice-list label {
  display: flex; align-items: center; gap: 8px; padding: 7px 14px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); cursor: pointer; font-weight: 400; color: var(--ink); font-size: 14px;
}
.choice-pills label:hover, .choice-list label:hover { border-color: var(--primary); }
.choice-pills label:has(input:checked), .choice-list label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.choice-pills input, .choice-list input { margin: 0; accent-color: var(--primary); }
.preview { border: 1px solid var(--border); border-radius: 8px; }
.preview input[type=date] { height: 30px; max-width: 170px; }
#sub-box { padding: 0; gap: 16px 20px; }

/* 操作后的消息条贴在顶栏下方，页面跳到锚点（如展开的记录行）时也能看到 */
.messages { position: sticky; top: 72px; z-index: 15; }
.msg { box-shadow: 0 4px 12px rgba(16, 24, 40, .08); }
.records-row { scroll-margin-top: 220px; }

/* 补日期 */
.dates-table .group-row td { background: var(--surface-2); font-weight: 600; padding-top: 8px; padding-bottom: 8px; }
.dates-table .group-row a { color: var(--ink); }
.dates-table input[type=date] { width: 160px; height: 30px; }
.dates-table .row-error td { background: var(--danger-soft); }
.dates-table .error { font-size: 12px; color: var(--danger); margin-top: 2px; }
.sticky-actions {
  position: sticky; bottom: 0; z-index: 10; display: flex; align-items: center; justify-content: flex-end; gap: 16px;
  padding: 12px 20px; background: rgba(255, 255, 255, .95); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 -4px 16px rgba(16, 24, 40, .06);
}

/* 商机卡片 */
.opp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.opp { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); min-width: 0; }
.opp:hover { border-color: #c5d3e6; box-shadow: var(--shadow); }
.opp-head { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.opp-name { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp-meta { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp-figures { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 0; }
.opp-figures div { min-width: 0; }
.opp-figures dt { font-size: 12px; color: var(--muted); }
.opp-figures dd { margin: 0; font-size: 13px; text-align: left; }
.opp-note { margin: 0; font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 10px; border-top: 1px dashed var(--border); }
.opp-foot form { margin: 0; }
.opp-stage select { height: 28px; width: auto; min-width: 96px; font-size: 13px; padding: 0 24px 0 8px; }
.stage-collapsed > summary { cursor: pointer; list-style: none; border-bottom: 0; }
.stage-collapsed > summary::-webkit-details-marker { display: none; }
.stage-collapsed[open] > summary { border-bottom: 1px solid var(--border); }

/* 往来单位 */
.badges { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
td.badges { display: table-cell; }
td.badges .badge { margin: 1px 4px 1px 0; }
.inline-form { display: inline; margin: 0; }
.link-list { list-style: none; margin: 0; padding: 6px 0; }
.link-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 20px; border-bottom: 1px solid #edf0f4; }
.link-list li:last-child { border-bottom: 0; }
.link-list a { color: var(--ink); min-width: 0; }
.link-list .muted { font-size: 12px; white-space: nowrap; }

/* 资金 */
.register-grid { gap: 12px 20px; }
.table tr.row-muted td { color: var(--muted); }
#register, #recurring, #snapshots { scroll-margin-top: 80px; }

/* ---------------------------------------------------------------- 404 / 500 / CSRF 过期页 */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.error-card { width: min(480px, 100%); }
.error-card h1 { font-size: 20px; margin-bottom: 8px; }
.error-card .row { margin-top: 16px; }

/* ---------------------------------------------------------------- 登录页 */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(180deg, var(--sidebar) 0 42%, var(--bg) 42%); }
.login-card { width: min(380px, 100%); }
.login-brand { display: flex; align-items: center; gap: 12px; padding: 24px 28px 4px; }
.login-brand b { display: block; font-size: 18px; }
.login-brand small { color: var(--muted); font-size: 12px; }
.login-card .card-body { padding: 16px 28px 28px; display: flex; flex-direction: column; gap: 14px; }
.login-card .btn-primary { width: 100%; justify-content: center; height: 40px; }

/* ---------------------------------------------------------------- 待办 / 跟进（三期） */
/* 今日待办横幅：看板与待办页顶部 */
.todo-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.todo-banner.has-todo { border-color: #cddcf0; background: linear-gradient(90deg, var(--primary-soft), var(--surface) 70%); }
.todo-banner-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none;
  background: var(--neutral-soft); color: var(--muted); }
.has-todo .todo-banner-icon { background: var(--primary); color: #fff; }
.todo-banner-title { font-size: 15px; font-weight: 600; white-space: nowrap; }
.todo-banner-title .num { color: var(--primary); font-size: 18px; }
.todo-banner-sub { font-size: 13px; }
.todo-banner-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.todo-banner-chips a.badge { text-decoration: none; height: 24px; padding: 0 10px; }
.todo-banner-chips a.badge:hover { filter: brightness(.96); text-decoration: none; }
.todo-banner-go { margin-left: auto; }
.todo-group { scroll-margin-top: 80px; }
.todo-none .card-head { border-bottom: 0; padding-top: 10px; padding-bottom: 10px; }
.todo-none h2 { color: var(--ink-2); font-weight: 500; }
.todo-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--neutral); }
.todo-dot-info { background: var(--info); }
.todo-dot-success { background: var(--success); }
.todo-dot-purple { background: var(--purple); }
.todo-dot-warning { background: var(--warning); }
.todo-dot-danger { background: var(--danger); }
.table td a.btn-primary, .table td a.btn-primary:hover { color: #fff; }
.todo-actions { display: inline-flex; align-items: center; gap: 4px; vertical-align: middle; }
.table td.actions .todo-actions { margin-left: 4px; }
.table td.actions .opp-stage { margin-left: 4px; display: inline-block; vertical-align: middle; }

/* 跟进时间线：单位详情、跟进页 */
.timeline { list-style: none; margin: 0; padding: 8px 0; }
.tl-item { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 0 18px; padding: 0 20px; position: relative; }
.tl-date { padding: 12px 0; text-align: right; line-height: 1.25; font-variant-numeric: tabular-nums; }
.tl-date b { display: block; font-size: 14px; color: var(--ink); }
.tl-date small { color: var(--muted); font-size: 11px; }
.tl-body { position: relative; min-width: 0; padding: 12px 0 14px 20px; border-left: 2px solid var(--border); border-bottom: 1px solid #edf0f4; }
.tl-item:last-child .tl-body { border-bottom: 0; }
.tl-body::before {
  content: ""; position: absolute; left: -7px; top: 16px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong);
}
.tl-open .tl-body::before { border-color: var(--info); background: var(--info-soft); }
.tl-late .tl-body::before { border-color: var(--danger); background: var(--danger-soft); }
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 26px; }
.tl-party { max-width: min(360px, 40vw); font-weight: 600; color: var(--ink); }
.tl-contact { color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.tl-tag { max-width: 260px; font-size: 12px; padding: 1px 8px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-2); }
.tl-tag:hover { border-color: #c5d3e6; color: var(--primary); text-decoration: none; }
.tl-tools { margin-left: auto; display: inline-flex; gap: 2px; opacity: .55; transition: opacity .12s; }
.tl-item:hover .tl-tools, .tl-tools:focus-within { opacity: 1; }
.tl-content { margin-top: 6px; color: var(--ink); font-size: 14px; overflow-wrap: anywhere; }
.tl-next { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.tl-next-text { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.tl-next-text .icon { color: var(--muted); }
.tl-next .todo-actions { margin-left: auto; }

/* 跟进页筛选 */
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.check-inline input, .filters .check-inline input { width: 16px; min-width: 0; height: 16px; margin: 0; accent-color: var(--primary); }
.filter-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px; border-radius: 15px; background: var(--primary-soft); font-size: 13px; color: var(--ink-2); }
.filter-chip .btn-close { width: 22px; height: 22px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); font-size: 13px; }
.pager span.btn { opacity: .45; cursor: default; }

/* 记跟进弹窗（内容较多，矮屏上弹窗内滚动时底部按钮保持可见） */
.dialog-foot { position: sticky; bottom: 0; }
.quick-dates { display: flex; flex-wrap: wrap; gap: 6px; }
.close-prev { align-self: start; padding-top: 26px; }
.dialog .choice-pills > div { gap: 6px; }
.dialog .choice-pills label { padding: 5px 14px; font-size: 13px; }
.dialog textarea { min-height: 72px; }

/* 商机卡片：最近跟进 */
.opp-follow { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; }
.opp-follow > span { display: inline-flex; align-items: center; gap: 4px; }
.opp-follow .warn { font-weight: 500; }

/* ---------------------------------------------------------------- Logo 底块（深色侧栏上用白色圆角底） */
.logo-tile {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center; padding: 2px;
  background: #fff; border-radius: 9px; box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.logo-tile img { display: block; width: 100%; height: 100%; object-fit: contain; }
.logo-tile-lg { width: 52px; height: 52px; padding: 3px; border-radius: 12px; box-shadow: 0 0 0 1px var(--border); }
.logo-tile-sm { width: 28px; height: 28px; padding: 2px; border-radius: 7px; box-shadow: 0 0 0 1px var(--border); }
.brand .brand-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 136px; }
.error-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.error-account { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; }

/* 侧栏底部账号（点进修改密码） */
.nav-account .nav-label { display: flex; flex-direction: column; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; }
.nav-account .nav-user { margin-left: 0; }

/* ---------------------------------------------------------------- 系统设置 */
.settings-foot { margin: 0; text-align: right; font-size: 12px; }
.settings-foot a { color: var(--muted); }
.settings-foot a:hover { color: var(--ink-2); }
.perm-matrix th.perm-col, .perm-matrix td.perm-col { text-align: center; padding-left: 4px; padding-right: 4px; }
.perm-matrix th.perm-col { cursor: help; white-space: nowrap; }
.perm-select { width: 84px; height: 30px; padding: 0 22px 0 8px; font-size: 13px; }
.perm-select[data-level="edit"], .perm-chip[data-level="edit"] { background-color: var(--success-soft); color: var(--success); border-color: #bfe3cb; }
.perm-select[data-level="view"], .perm-chip[data-level="view"] { background-color: var(--info-soft); color: var(--info); border-color: #cddcf0; }
.perm-select[data-level="none"], .perm-chip[data-level="none"] { color: var(--muted); }
.perm-select option { background: var(--surface); color: var(--ink); }
.perm-chip { display: inline-block; min-width: 64px; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--border); font-size: 12px; white-space: nowrap; }
.module-help { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px 24px; margin: 0; }
.module-help dt { font-weight: 600; font-size: 13px; }
.module-help dd { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.settings-site { align-items: start; }
.settings-site .form-card { max-width: none; }
.brand-preview { display: flex; align-items: center; gap: 10px; padding: 16px; border-radius: var(--radius); background: var(--sidebar); color: #fff; }
.brand-preview .brand-text small { color: var(--sidebar-ink); }
.login-preview { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: var(--radius); border: 1px solid var(--border); }
.login-preview b { display: block; font-size: 16px; }
.login-preview small { color: var(--muted); font-size: 12px; }

/* ---------------------------------------------------------------- 商机：已转项目提示、复盘区 */
.opp-converted { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; }
.review-zone { scroll-margin-top: 76px; }
.opp-lost { background: var(--surface-2); }
.opp-review { margin: 0; font-size: 12px; color: var(--ink-2); display: -webkit-box; -webkit-box-orient: vertical;
  -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; white-space: pre-line; }
.lost-card .card-head h2 a { color: inherit; }
.lost-chart { max-width: 760px; }

/* ---------------------------------------------------------------- 可排序表格（app.js：table[data-sortable]） */
.table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.table th.sortable:hover { color: var(--primary); }
.table th.sortable:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--primary-ring); }
.table th.sortable::after { content: "▲"; display: inline-block; margin-left: 4px; font-size: 9px; color: transparent; vertical-align: 1px; }
.table th.sortable:hover::after { color: var(--border-strong); }
.table th[aria-sort="ascending"]::after { content: "▲"; color: var(--primary); }
.table th[aria-sort="descending"]::after { content: "▼"; color: var(--primary); }
.table th.seq-col, .table td.seq { width: 44px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; padding-right: 4px; }
/* 项目列表"附件"列：无附件提示"待上传合同"；列紧凑，1366 宽笔记本不横向溢出 */
.table th.attach-col, .table td.attach-col { padding-left: 4px; padding-right: 4px; }
.attach-warn { color: var(--warning); font-size: 12px; white-space: nowrap; }
/* 有项目编辑权限时"待上传合同"/"另 N 份待上传"可点：直接选文件上传（attach_upload.html） */
.attach-form { display: inline; margin: 0; }
.attach-form input[type=file].sr-only { width: 1px; height: 1px; padding: 0; border: 0; }  /* 盖过 input[type=file] 的 width:100% */
.attach-form .link-btn, td.attach-col .link-btn { font-size: 12px; white-space: nowrap; }
td.attach-col .link-btn.attach-warn, td.attach-col a.attach-warn { color: var(--warning); text-decoration: underline dotted; }

/* ---------------------------------------------------------------- 列宽拖动（app.js：.table-wrap > table.table，排除 table-compact / perm-matrix） */
.table th .col-resizer { position: absolute; top: 0; right: 0; bottom: 0; width: 6px; cursor: col-resize; touch-action: none; }
.table th .col-resizer::after { content: ""; position: absolute; top: 0; right: 2px; bottom: 0; width: 2px; background: transparent; }
.table th .col-resizer:hover::after, .table th .col-resizer.dragging::after { background: var(--primary); }
.table.is-resized .truncate { max-width: none; }
.table.is-resized td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.disabled-wrap { display: inline-flex; cursor: not-allowed; }
/* 只给读屏 / 文本匹配用的文字（图标按钮的名称） */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.table td.actions .btn-icon + .btn-icon { margin-left: 3px; }
.table td.actions .btn-icon { color: var(--ink-2); }
.table td.actions .btn-icon:hover { color: var(--primary); }
/* 款项表（台账、看板、项目详情）列多：收紧单元格左右留白，保证 1366 宽不横向滚动 */
.table-ms th, .table-ms td { padding-left: 7px; padding-right: 7px; }
.table-ms th:first-child, .table-ms td:first-child { padding-left: 14px; }
.table-ms th:last-child, .table-ms td:last-child { padding-right: 14px; }
/* 因权限隐藏整块内容时的占位（QA #3） */
.no-perm { display: flex; align-items: center; gap: 8px; padding: 16px 20px; color: var(--muted); font-size: 13px; }
.no-perm .icon { flex: none; }
.dates-scope { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; }
.error-card .row .inline-form { display: inline-flex; margin: 0; }
.table tfoot tr.closed-note td { font-weight: 400; color: var(--muted); font-size: 12px; background: var(--surface-2); border-top: 0; }
.table td.actions .btn-slot { display: inline-block; width: 26px; height: 26px; vertical-align: middle; }

/* ---------------------------------------------------------------- 五期：单据 */
.upload-card .dropzone { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 16px; padding: 28px 16px;
  border: 2px dashed var(--border-strong); border-radius: var(--radius); text-align: center; cursor: pointer; }
.upload-card .dropzone.dragging { border-color: var(--primary); background: var(--primary-soft); }
.upload-card .dropzone input[type="file"] { margin-top: 8px; }
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.doc-preview iframe { display: block; width: 100%; height: calc(100vh - 190px); min-height: 520px; border: 0; }
.doc-preview img { display: block; max-width: 100%; margin: 0 auto; }
.doc-alerts { display: flex; flex-direction: column; gap: 8px; }
.doc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.doc-retry { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.doc-switch { align-self: flex-start; }
.ai-filled { background: var(--primary-soft) !important; }
.bank-rows select { max-width: 380px; }
.bank-rows .row-dup td { opacity: .7; }
.bank-snap { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; border-top: 1px solid var(--border); }
@media (max-width: 1100px) { .doc-layout { grid-template-columns: minmax(0, 1fr); } }
