/* ============================================================
   合同管理系统 · 样式表
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #eff4ff;
  --brand-line: #c7d7fe;

  --bg: #f2f5f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #e4e9f0;
  --line-strong: #cfd8e3;

  --text: #14202f;
  --text-2: #53637a;
  --text-3: #8a97a8;

  --ok: #0f9d58;
  --ok-soft: #e8f7ee;
  --warn: #d97706;
  --warn-soft: #fdf3e3;
  --danger: #dc2626;
  --danger-soft: #fdeceb;
  --info: #0891b2;
  --info-soft: #e5f6fa;
  --violet: #7c3aed;
  --violet-soft: #f2ecfe;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-xs: 0 1px 2px rgba(20, 32, 47, .06);
  --shadow-sm: 0 2px 8px rgba(20, 32, 47, .06);
  --shadow: 0 8px 24px rgba(20, 32, 47, .10);
  --shadow-lg: 0 24px 60px rgba(20, 32, 47, .18);
  --sidebar-w: 184px;
  --topbar-h: 58px;
}

html, body { height: 100%; }

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

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0 0 8px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #c6cfdb; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #a9b5c4; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- 启动占位 ---------------- */
.app-root { min-height: 100vh; }
.boot-splash {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; color: var(--text-3);
}
.boot-spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   登录页
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  background: var(--surface);
}
.login-hero {
  position: relative;
  padding: 56px 64px;
  color: #eaf1ff;
  background: linear-gradient(150deg, #0f2350 0%, #1b3a86 48%, #2563eb 100%);
  display: flex; flex-direction: column; justify-content: space-between;
  overflow: hidden;
}
.login-hero::after {
  content: ""; position: absolute; inset: -40% -20% auto auto;
  width: 620px; height: 620px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.16), transparent 62%);
}
.login-brand { display: flex; align-items: center; gap: 12px; z-index: 1; }
.login-brand .logo {
  width: 42px; height: 42px; border-radius: 50%; flex: none; object-fit: cover;
  background: rgba(255,255,255,.16);
  display: grid; place-items: center; font-size: 20px; font-weight: 700;
  border: 1px solid rgba(255,255,255,.28);
}
.login-brand b { font-size: 19px; letter-spacing: .5px; }
.login-hero h1 { font-size: 34px; line-height: 1.35; margin: 0 0 14px; z-index: 1; }
.login-hero .lead {
  /* 一整行不折行：字号用 clamp 跟视口走，下限 11.5px 保证 1000px 左右也放得下 */
  font-size: clamp(11.5px, 1.04vw, 15px);
  color: #b9cdf5; max-width: none; white-space: nowrap; z-index: 1;
}
.login-feats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; z-index: 1; }
.login-feats span {
  padding: 7px 14px; border-radius: 999px; font-size: 13px;
  background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.20); color: #d8e5ff;
}
.login-foot { font-size: 12.5px; color: #8fa9dc; z-index: 1; display: flex; flex-wrap: wrap; gap: 4px 30px; }

.login-panel { display: grid; place-items: center; padding: 40px; }
.login-box { width: 100%; max-width: 360px; }
.login-box h2 { font-size: 24px; margin-bottom: 6px; }
.login-box .sub { color: var(--text-3); font-size: 13px; margin-bottom: 28px; }
.login-box .field { margin-bottom: 16px; }
.login-box label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.login-box .remember {
  display: inline-flex; align-items: center; gap: 7px; margin: 2px 0 14px;
  font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none;
}
.login-box .remember input { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; margin: 0; }
.login-error {
  background: var(--danger-soft); color: var(--danger); border: 1px solid #f6c9c6;
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px;
}
/* 窄一点时先收 hero 的横向留白，再让副标题字号下滑 —— 保证那行始终是完整一行 */
@media (max-width: 1040px) {
  .login-hero { padding-left: 40px; padding-right: 40px; }
}
@media (max-width: 900px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { display: none; }
}

/* ============================================================
   主框架
   ============================================================ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, #101c33 0%, #16233d 100%);
  color: #b6c3d6;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid #0b1425;
}
/* 左上角「LOGO + 系统名称」是工作台（默认首页）的入口，故做成可点、有悬停与当前态 */
.sidebar-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 0 18px; height: var(--topbar-h); flex: none;
  border-bottom: 1px solid rgba(255,255,255,.07);
  cursor: pointer; user-select: none;
  transition: background .16s;
}
.sidebar-brand:hover { background: rgba(255,255,255,.06); }
.sidebar-brand:hover .name { color: #fff; }
.sidebar-brand:focus-visible { outline: 2px solid rgba(96,165,250,.7); outline-offset: -2px; }
.sidebar-brand.active {
  background: linear-gradient(90deg, rgba(37,99,235,.28), rgba(37,99,235,.06));
  box-shadow: inset 2px 0 0 #60a5fa;
}
.sidebar-brand.active .name { color: #fff; }
.sidebar-brand .logo {
  width: 32px; height: 32px; border-radius: 50%; flex: none; object-fit: cover;
  background: linear-gradient(135deg, #3b82f6, #7c3aed);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px;
}
/* min-width:0 是 flex 子项能收缩的前提；名称被改长时出省略号，不撑破侧边栏 */
.sidebar-brand .name {
  color: #f1f5fb; font-weight: 600; font-size: 15px; letter-spacing: .3px;
  white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-brand .name small { display: block; font-size: 11px; color: #7b8db0; font-weight: 400; letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px 24px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #26344f; }
.nav-group-title {
  font-size: 11px; color: #5d6f91; padding: 14px 10px 6px; letter-spacing: .8px; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; margin-bottom: 2px; border-radius: 8px;
  color: #b6c3d6; font-size: 13.5px; cursor: pointer;
  border: 1px solid transparent; transition: background .16s, color .16s;
  user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #e8eefb; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(37,99,235,.32), rgba(37,99,235,.10));
  color: #fff; border-color: rgba(96,165,250,.35);
}
.nav-item .ico { width: 18px; text-align: center; flex: none; opacity: .92; font-size: 15px; }
/* 菜单文案过长时省略，不换行、不撑破侧边栏 */
.nav-item > span:not(.ico):not(.badge-dot) {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-item .badge-dot {
  margin-left: auto; flex: none; background: var(--danger); color: #fff; font-size: 11px;
  min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 5px;
}
.sidebar-foot {
  flex: none; padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.07);
  font-size: 11.5px; color: #61738f; line-height: 1.7;
}

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h); flex: none;
  background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
  position: sticky; top: 0; z-index: 30;
}
.topbar .crumb { font-size: 13px; color: var(--text-3); display: flex; align-items: center; gap: 7px; }
.topbar .crumb b { color: var(--text); font-weight: 600; font-size: 15px; }
/* 面包屑上一级可点回列表页（详情页的第二条返回路径，比只有按钮更符合习惯） */
.topbar .crumb a.crumb-up {
  color: var(--text-3); text-decoration: underline dotted; text-decoration-color: #c3ccd8;
  text-underline-offset: 3px; transition: .15s;
}
.topbar .crumb a.crumb-up:hover { color: var(--brand); text-decoration: underline; text-decoration-color: currentColor; }
.topbar .spacer { flex: 1; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; color: var(--text-2);
  position: relative; transition: .16s;
}
.icon-btn:hover { border-color: var(--brand-line); color: var(--brand); background: var(--brand-soft); }
.icon-btn .dot {
  position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--danger); color: #fff; font-size: 10.5px;
  display: grid; place-items: center; border: 2px solid #fff;
}
.user-chip {
  display: flex; align-items: center; gap: 9px; padding: 5px 12px 5px 6px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
}
.user-chip:hover { border-color: var(--brand-line); background: var(--brand-soft); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none; object-fit: cover;
  background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff;
  display: grid; place-items: center; font-size: 12.5px; font-weight: 600;
}
.user-chip .meta { line-height: 1.25; }
.user-chip .meta b { display: block; font-size: 13px; font-weight: 600; }
.user-chip .meta small { color: var(--text-3); font-size: 11px; }

.dropdown {
  position: absolute; top: 50px; right: 0; min-width: 190px; z-index: 60;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px; display: none;
}
.dropdown.open { display: block; }
.dropdown .dd-head { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.dropdown .dd-head b { display: block; font-size: 13.5px; }
.dropdown .dd-head small { color: var(--text-3); font-size: 11.5px; }
.dropdown button {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 8px 11px; border: 0; background: transparent; border-radius: 7px; font-size: 13px; color: var(--text-2);
}
.dropdown button:hover { background: var(--surface-soft); color: var(--text); }
.dd-wrap { position: relative; }

.content { padding: 20px 22px 40px; flex: 1; min-width: 0; }

/* ============================================================
   通用组件
   ============================================================ */
.page-head { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 19px; }
.page-head .desc { color: var(--text-3); font-size: 12.5px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.card + .card { margin-top: 16px; }
/* grid 内卡片间距由 gap 控制，避免第二张卡被额外下推 16px 造成两栏错位 */
.grid > .card + .card { margin-top: 0; }
.card-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: 14.5px; }
.card-head .sub { font-size: 12px; color: var(--text-3); }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 16px 18px; }
.card-body.tight { padding: 0; }

/* 网格等高时，让卡片内的条形图表在纵向均分铺满，避免数据行数少的一栏底部留白而对不齐 */
.card.fill-chart { display: flex; flex-direction: column; }
.card.fill-chart > .card-body { flex: 1; display: flex; flex-direction: column; }
.card.fill-chart .chart-box { flex: 1; display: flex; flex-direction: column; justify-content: space-between; }
.card.fill-chart .chart-box > * { margin-bottom: 0 !important; }

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.c-2-1 { grid-template-columns: 2fr 1fr; }
.grid.c-1-2 { grid-template-columns: 1fr 2fr; }
@media (max-width: 1180px) {
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.c3, .grid.c-2-1, .grid.c-1-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .grid.c2, .grid.c4 { grid-template-columns: 1fr; }
}

/* 统计卡片 */
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 16px 18px; position: relative; overflow: hidden;
}
.stat .label { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 25px; font-weight: 650; letter-spacing: -.4px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .foot { font-size: 12px; color: var(--text-3); margin-top: 6px; display: flex; align-items: center; gap: 6px; }
.stat .mark { position: absolute; right: -14px; top: -14px; width: 76px; height: 76px; border-radius: 50%; opacity: .10; }
.stat.b .mark { background: var(--brand); }
.stat.g .mark { background: var(--ok); }
.stat.o .mark { background: var(--warn); }
.stat.r .mark { background: var(--danger); }
.stat.v .mark { background: var(--violet); }
.stat .value.sm { font-size: 21px; }
.stat.clickable { cursor: pointer; transition: .16s; }
.stat.clickable:hover { border-color: var(--brand-line); box-shadow: var(--shadow-sm); transform: translateY(-1px); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font-size: 13.5px; white-space: nowrap;
  transition: .15s; line-height: 1.5;
}
.btn:hover { border-color: #b7c3d2; background: var(--surface-soft); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(.93); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-soft); color: var(--text); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.block { width: 100%; padding: 10px; font-size: 14.5px; }
.btn.lg { padding: 10px 22px; font-size: 14.5px; }
/* 详情页左上角「返回」：原 ghost 透明无边框、字号又小，用户反馈"不专门找还真找不到"
   → 浅蓝底 + 蓝字 + 描边，在灰白页头里一眼可见，又不与右侧主按钮抢注意力 */
.btn.back-nav {
  background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand);
  font-weight: 600; font-size: 13px; padding: 5px 12px; gap: 5px;
}
.btn.back-nav:hover { background: #e3ecff; border-color: var(--brand); color: var(--brand-dark); }
.btn.back-nav svg { transition: transform .15s; }
.btn.back-nav:hover svg { transform: translateX(-2px); }

/* 行内文字按钮：也用作 <a>（如台账里的「查看合同」直链），故用 inline-flex 让图标与文字对齐 */
.link-btn { display: inline-flex; align-items: center; gap: 5px; border: 0; background: transparent; color: var(--brand); padding: 2px 4px; font-size: 13px; border-radius: 4px; }
.link-btn:hover { background: var(--brand-soft); text-decoration: none; }
.link-btn.danger { color: var(--danger); }
.link-btn.danger:hover { background: var(--danger-soft); }

/* 表单 */
.form-grid { display: grid; gap: 14px 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.c1 { grid-template-columns: 1fr; }
/* 四列（往来单位表单用）：一行 4 格，短字段各占 1 格 = 整宽的 1/4（即原来两列布局的一半），
   「单位名称 / 单位地址 / 开户行 / 银行账户」占 2 格维持原宽度，备注整行。
   这样仍是同一套弹窗宽度（size:'lg'），只是行内的疏密更有层次。 */
.form-grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .span2 { grid-column: span 2; }
.form-grid .span3 { grid-column: span 3; }
.form-grid .span4 { grid-column: span 4; }
/* 不对称三列（合同表单用）：前两列均分、第三列收窄到 190px。
   右侧一列只放短字段（存档编号 / 合同状态 / 到期提醒天数 / 日期），
   三列等宽时它会空出一大片，收窄后前两列更好录入。 */
.form-grid.c-asym { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 190px; }
/* 系统参数表单：四列不等宽 —— 第 1 列放长文本（系统名称 / 版权所有 / 备案号），
   后三列是「合同编号前缀 / 每页条数 / 提醒天数」这类两三个字的短数值，
   等宽网格会把它们拉到跟系统名称一样长，既难看也容易看成别的字段。
   实测比例 1.6 : 0.7 : 0.7 : 0.7 ≈ 长 440px / 短 195px（1500 视口下的设置页）。 */
.form-grid.c-param { grid-template-columns: minmax(0, 1.6fr) minmax(0, 0.7fr) minmax(0, 0.7fr) minmax(0, 0.7fr); }
/* ⚠ 修饰类必须显式列出：`.form-grid.c4`（0,2,0）优先级高于媒体查询里的 `.form-grid`（0,1,0），
   不写就会被基类单列规则盖掉、窄屏溢出。 */
@media (max-width: 980px) {
  .form-grid, .form-grid.c2, .form-grid.c4, .form-grid.c-asym, .form-grid.c-param { grid-template-columns: 1fr; }
  .form-grid .span2, .form-grid .span3, .form-grid .span4 { grid-column: auto; }
}

.field label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; }
.field label .req { color: var(--danger); margin-left: 3px; }
.field .hint { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }

.input, .select, .textarea {
  width: 100%; padding: 7.5px 11px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  transition: .15s; font-size: 13.5px;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.input::placeholder { color: #a9b4c2; }
.textarea { resize: vertical; min-height: 74px; line-height: 1.65; }
.input[readonly] { background: var(--surface-soft); color: var(--text-2); }
.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.input.invalid, .select.invalid { border-color: var(--danger); }

.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; }

/* 筛选条 */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--surface-soft);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.filters .field { min-width: 132px; }
.filters .field.grow { flex: 1; min-width: 190px; }
.filters .sp { flex: 1; }
.filters .label-top { font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; display: block; }
/* 选项文字较短的筛选下拉（合同状态 / 合同方向 / 签订年度）：不再占满整列，
   宽度按最长选项自适应，给整行留出余量，避免窗口略缩就多换一行 */
.filters .field.sm { min-width: 0; flex: 0 0 auto; }
.filters .field.sm .select { width: auto; min-width: 88px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.data th, table.data td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th {
  background: var(--surface-soft); color: var(--text-2); font-weight: 600; font-size: 12.5px;
  white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--brand); }
table.data tbody tr:hover { background: #fafcff; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data td.nowrap { white-space: nowrap; }
/* 宽表（报表）：不换行 + 横向滚动，长文本列自动省略 */
table.data.nowrap th, table.data.nowrap td { white-space: nowrap; }
table.data.nowrap td.txt { max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
table.data.nowrap td.txt > span { display: block; overflow: hidden; text-overflow: ellipsis; }
table.data td.actions-cell { white-space: nowrap; text-align: right; }
/* 台账两列的宽度分工（表格是 table-layout:auto 自动布局）：
   ┌「合同名称 / 往来单位」= 唯一的弹性列，**不设宽度**，页面拉宽时多余宽度优先给它；
   │  保底 12 个汉字（min-width），窄屏也不会被压到 12 汉字以下。
   └「所属项目」= 12 个汉字是**上限**，宽屏就占满 12 个汉字，窄屏优先让出空间、跟着收缩。
   要点与坑：
   - 列宽写在 **td** 而不是 th：th 字号 12.5px、td 13px，同一个 12em 会差 6px。
   - 全局 box-sizing:border-box，td 左右内边距合计 28px，所以「12 个汉字内容宽」
     在 td 上要写成 calc(12em + 28px)（12em = 12 × 13px = 156px 内容）。
   - 「所属项目」的 td 给的是**首选宽度**（宽屏占满 12 汉字，内容短也不会塌成一条），
     同时 td 可收缩到内容最小宽度，从而在窄屏让位；长项目名靠 overflow-wrap 继续折行，
     折到第 3 行由 .pj-name 的 line-clamp 截断，最多两行。 */
table.data td.cell-name { min-width: calc(12em + 28px); }
table.data td.cell-project {
  width: calc(12em + 28px); max-width: calc(12em + 28px);
  white-space: normal; overflow-wrap: anywhere;
}
table.data td.cell-project .pj-name {
  max-width: 12em; white-space: normal; overflow-wrap: anywhere; line-height: 1.5;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
/* 编号类单元格不折行。
   编号本身很短（JT-260902 / X2601 / C0001），但连字符与字母数字之间是天然断行点，
   窄列下会折成「SZ- / 260501」两行，看起来像数据断掉了 —— 用户明确反馈不好看。
   约定：表格单元格里的 .mono.small 一律按「编号」处理 → 不换行；
   需要折行的长文本（如系统设置里的数据库路径）用不带 .small 的 .mono。 */
table.data td.mono.small,
table.data td .mono.small { white-space: nowrap; }
table.data tfoot td { background: var(--surface-soft); font-weight: 600; border-top: 2px solid var(--line-strong); }
table.data tr.row-overdue > td { background: #fff7f7; }
table.data tr.row-overdue:hover > td { background: #fdf0f0; }
/* 「系统设置 → 系统参数 → 逾期高亮」可关：关掉后逾期行不铺红底，
   数据本身照旧（逾期状态、徽章、筛选都不受影响），只是不再高亮。
   td 背景置透明后，tr 的 hover 背景会自然透出来，与普通行一致。 */
:root[data-overdue-hl='off'] table.data tr.row-overdue > td,
:root[data-overdue-hl='off'] table.data tr.row-overdue:hover > td { background: transparent; }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 11.5px; color: var(--text-3); }
/* 表格内的两行堆叠单元格（进度条 + 金额行），行距紧凑且不折行 */
.stack3 { display: flex; flex-direction: column; gap: 3px; }
.stack3 > span { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.money { font-variant-numeric: tabular-nums; }
.money.pos { color: var(--danger); }
.money.neg { color: var(--ok); }

.empty {
  padding: 46px 20px; text-align: center; color: var(--text-3);
}
.empty .icon { font-size: 34px; opacity: .4; display: block; margin-bottom: 8px; }

/* 徽标 */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: 12px; line-height: 1.65;
  border: 1px solid transparent; white-space: nowrap;
}
.badge.gray { background: #f1f4f8; color: #5b6b80; border-color: #e2e8f0; }
.badge.blue { background: var(--brand-soft); color: var(--brand-dark); border-color: var(--brand-line); }
.badge.green { background: var(--ok-soft); color: #0b7a44; border-color: #bde8cd; }
.badge.orange { background: var(--warn-soft); color: #a95a06; border-color: #f5dcae; }
.badge.red { background: var(--danger-soft); color: #b91c1c; border-color: #f6c9c6; }
.badge.violet { background: var(--violet-soft); color: #6d28d9; border-color: #ddd0fb; }
.badge.cyan { background: var(--info-soft); color: #0e7490; border-color: #bfe8f1; }
.dot-mark { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* 分页 */
.pager { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager .info { color: var(--text-3); font-size: 12.5px; }
.pager .pages { margin-left: auto; display: flex; gap: 5px; align-items: center; }
.pager .pages button {
  min-width: 30px; height: 30px; padding: 0 8px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2); font-size: 13px;
}
.pager .pages button:hover:not(:disabled) { border-color: var(--brand-line); color: var(--brand); background: var(--brand-soft); }
.pager .pages button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager .pages button:disabled { opacity: .45; cursor: not-allowed; }

/* 标签页 */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 18px; overflow-x: auto; }
.tabs button {
  border: 0; background: transparent; padding: 11px 14px; font-size: 13.5px; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* 描述列表 */
.desc-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.desc-grid .item { padding: 11px 14px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); min-width: 0; }
.desc-grid .item .k { font-size: 12px; color: var(--text-3); margin-bottom: 3px; }
.desc-grid .item .v { font-size: 13.5px; word-break: break-word; }
.desc-grid .item.span2 { grid-column: span 2; }
.desc-grid .item.span3 { grid-column: span 3; }
/* 四列描述网格：字段少但卡片横跨整页时用，与上方 .grid.c4 金额卡列数对齐（项目详情） */
.desc-grid.cols4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.desc-grid.cols4 .item.span4 { grid-column: span 4; }
@media (max-width: 980px) { .desc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .desc-grid .item.span3 { grid-column: span 2; } .desc-grid.cols4 .item.span4 { grid-column: span 2; } }
@media (max-width: 640px) { .desc-grid { grid-template-columns: 1fr; } .desc-grid .item.span2, .desc-grid .item.span3 { grid-column: auto; } .desc-grid.cols4 .item.span4 { grid-column: auto; } }

/* 关于系统 · 头部：LOGO + 系统名称 + 版本徽章 */
.about-head { display: flex; align-items: center; gap: 12px; padding: 2px 0 14px; min-width: 0; }
.about-head .about-logo { width: 42px; height: 42px; flex: none; border-radius: 10px; object-fit: contain; background: var(--brand-soft); }
.about-head .t { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; min-width: 0; }
.about-head .t .n { font-size: 16px; font-weight: 600; color: var(--text); word-break: break-word; }
.about-head .about-ver { flex: none; background: var(--brand-soft); color: var(--brand-dark); border: 1px solid var(--brand-line); padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; }

/* 合同详情 · 基本信息分组：每组一张网格，组内必须逐行铺满（不留空格与断线） */
.desc-secs { display: grid; gap: 16px; }
.desc-sec-h {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
  margin: 0 0 8px; letter-spacing: .2px;
}
.desc-sec-h::before { content: ""; width: 3px; height: 12px; border-radius: 2px; background: var(--brand); }

/* 进度条 */
.progress { height: 7px; border-radius: 4px; background: #eef2f7; overflow: hidden; min-width: 70px; }
.progress > i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #3b82f6, #2563eb); }
.progress.ok > i { background: linear-gradient(90deg, #34d399, #0f9d58); }
.progress.warn > i { background: linear-gradient(90deg, #fbbf24, #d97706); }
.progress.danger > i { background: linear-gradient(90deg, #f87171, #dc2626); }

/* 时间线 */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline .tl-item { position: relative; padding-bottom: 16px; }
.timeline .tl-item::before {
  content: ""; position: absolute; left: -21px; top: 5px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--brand-line);
}
.timeline .tl-item.gray::before { background: var(--text-3); box-shadow: 0 0 0 1px #d5dce6; }
.timeline .tl-head { display: flex; gap: 10px; align-items: baseline; }
.timeline .tl-head b { font-size: 13.5px; }
.timeline .tl-head span { font-size: 12px; color: var(--text-3); }
.timeline .tl-body { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-start; justify-content: center; z-index: 200;
  padding: 40px 20px; overflow-y: auto; backdrop-filter: blur(2px);
  animation: fadeIn .16s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(14px); opacity: 0; } }
.modal {
  background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 720px;
  box-shadow: var(--shadow-lg); animation: slideUp .2s ease; display: flex; flex-direction: column;
  max-height: calc(100vh - 80px); margin: auto;
}
.modal.md { max-width: 560px; }
.modal.lg { max-width: 960px; }
.modal.xl { max-width: 1180px; }
/* 合同表单专用：右列收窄后，若仍用 1180px，前两列会被拉到 457px 显得空旷。
   1000px 下三列约 367 / 367 / 190，与前版匀称感一致。 */
.modal.form { max-width: 1000px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--line); flex: none; }
.modal-head h3 { font-size: 15.5px; }
.modal-head .sub { font-size: 12px; color: var(--text-3); }
.modal-head .x { margin-left: auto; border: 0; background: transparent; font-size: 20px; color: var(--text-3); line-height: 1; padding: 4px 8px; border-radius: 6px; }
.modal-head .x:hover { background: var(--surface-soft); color: var(--text); }
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 13px 20px; border-top: 1px solid var(--line); flex: none; background: var(--surface-soft); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.modal-foot .left { margin-right: auto; }

/* 附件预览 */
.preview-frame { background: var(--surface-soft); border-radius: var(--radius); padding: 12px; min-height: 280px; display: grid; place-items: center; }
.preview-image img { max-width: 100%; max-height: 72vh; display: block; border-radius: 6px; box-shadow: var(--shadow-sm); }
.preview-pdf iframe { width: 100%; height: 72vh; min-height: 480px; border: 0; border-radius: 6px; background: #fff; }
.preview-empty { min-height: 200px; }

/* 附件区分组 */
.file-section + .file-section { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); }
.file-section h4 { font-size: 13px; color: var(--text-2); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.file-section h4 .badge { background: var(--brand-soft); color: var(--brand-dark); padding: 1px 7px; border-radius: 10px; font-size: 11.5px; font-weight: 500; }
/* 分组标题后面跟的一句话口径说明，如「盖章正本 · 一份合同只能有 1 份」 */
.file-section h4 .sec-note { font-size: 11.5px; font-weight: 400; color: var(--text-3); }
@media (max-width: 860px) { .file-section h4 .sec-note { display: none; } }

/* 附件上传区段（表单弹窗内） */
.form-section { margin-top: 14px; padding: 12px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface-soft); }
.form-section .section-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--text-2); }

/* 提示 */
.toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: #16233d; color: #f1f5fb; padding: 9px 18px; border-radius: 9px; font-size: 13.5px;
  box-shadow: var(--shadow); animation: slideUp .2s ease; max-width: 520px;
}
.toast.ok { background: #065f46; }
.toast.err { background: #991b1b; }
.toast.warn { background: #92400e; }

/* 加载 */
.loading { padding: 40px; display: grid; place-items: center; color: var(--text-3); }
.spinner { width: 24px; height: 24px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
.inline-loading { display: inline-block; width: 14px; height: 14px; border-width: 2px; vertical-align: -2px; }

/* 图表 */
.chart-box { width: 100%; }
.chart-box svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-empty { padding: 40px; text-align: center; color: var(--text-3); font-size: 13px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12.5px; color: var(--text-2); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; }

/* 附件列表 */
.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft);
}
.file-item .fico { width: 32px; height: 32px; border-radius: 8px; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; flex: none; font-size: 15px; }
.file-item .fmeta { min-width: 0; flex: 1; }
.file-item .fmeta b { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .fmeta small { color: var(--text-3); font-size: 11.5px; }

/* 计划 / 明细行编辑 */
.plan-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.plan-table th { font-size: 12px; color: var(--text-2); text-align: left; padding: 6px 8px; background: var(--surface-soft); }
.plan-table th:first-child { border-radius: 7px 0 0 7px; }
.plan-table th:last-child { border-radius: 0 7px 7px 0; }
.plan-table td { padding: 5px 6px; vertical-align: middle; }
.plan-table .input { padding: 6px 9px; font-size: 13px; }

/* 金额变更：原合同金额 → 累计变更 → 变更后金额 的算式条 */
.ac-summary {
  display: flex; align-items: stretch; flex-wrap: wrap; gap: 8px;
  padding: 10px 12px; margin-bottom: 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft);
}
.ac-summary .ac-item { display: flex; flex-direction: column; gap: 2px; min-width: 130px; }
.ac-summary .ac-item .k { font-size: 11.5px; color: var(--text-3); }
.ac-summary .ac-item .v { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ac-summary .ac-item .v.strong { color: var(--brand-dark); }
.ac-summary .ac-op { display: grid; place-items: center; padding: 0 4px; color: var(--text-3); font-size: 16px; }
.ac-file { display: flex; align-items: center; gap: 4px; min-width: 0; }
.ac-file-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }

/* 台账金额列：第一行原金额划线，第二行变更后金额 */
.amount-two { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.amount-two .old { font-size: 11.5px; color: var(--text-3); text-decoration: line-through; }
/* 第二行不加粗：新旧金额靠「划线 vs 不划线」区分，不靠字重抢注意力 */
.amount-two .now { font-weight: 400; }

/* 权限树 */
.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 900px) { .perm-grid { grid-template-columns: 1fr; } }
.perm-group { border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 13px; }
.perm-group h4 { font-size: 13px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.perm-group h4 .all { font-size: 11.5px; color: var(--brand); border: 0; background: transparent; font-weight: 400; }
.perm-group label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); padding: 3px 0; cursor: pointer; }

/* 分段选择 */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 14px; font-size: 13px; color: var(--text-2); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--brand); color: #fff; }
.seg button:hover:not(.active) { background: var(--surface-soft); color: var(--text); }

/* 提醒条目 */
.alert-list { display: flex; flex-direction: column; }
.alert-item {
  display: flex; align-items: center; gap: 12px; padding: 7px 18px; border-bottom: 1px solid var(--line);
}
.alert-item:last-child { border-bottom: 0; }
.alert-item .tico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none; font-size: 15px; background: var(--warn-soft); color: var(--warn); }
.alert-item.overdue .tico { background: var(--danger-soft); color: var(--danger); }
.alert-item.normal .tico { background: var(--ok-soft); color: var(--ok); }
.alert-item .body { flex: 1; min-width: 0; }
.alert-item .body b { display: block; font-size: 13.5px; font-weight: 600; line-height: 1.45; }
.alert-item .body small { color: var(--text-3); font-size: 12px; line-height: 1.4; }
.alert-item .tail { text-align: right; flex: none; }
.alert-item .tail b { display: block; font-size: 14px; font-variant-numeric: tabular-nums; }

/* 工作台「重点预警」卡片：条数固定 6 条，剩余高度平均分给每条，
   让最后一条的底边与左侧「最近登记合同」表格的最后一行齐平 ——
   原来两条预警各自 6 条合计 12 条，比左边 8 行表格高出一大截，两张卡并排很难看。 */
.card-body.fill-alerts { display: flex; flex-direction: column; }
.card-body.fill-alerts .alert-list { flex: 1; }
.card-body.fill-alerts .alert-item { flex: 1 1 auto; }

/* 键值小列表 */
.kv-list { display: flex; flex-direction: column; }
.kv-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.kv-row:last-child { border-bottom: 0; }
.kv-row .k { color: var(--text-2); min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv-row .v { font-weight: 600; font-variant-numeric: tabular-nums; }

.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 120; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-mask { position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 110; }
  .content { padding: 14px 14px 34px; }
  .topbar { padding: 0 14px; }
  .menu-toggle { display: grid !important; }
}
.menu-toggle { display: none; }

/* 选择列表（用于"登记收付款→选合同"两步弹窗） */
.pick-list { max-height: 280px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.pick-item { padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .12s; }
.pick-item:last-child { border-bottom: none; }
.pick-item:hover { background: var(--hover); }
.pick-item.active { background: var(--primary-soft, #e8f0fe); border-left: 3px solid var(--primary, #2563eb); padding-left: 9px; }
.cell-link { text-decoration: none; }
.cell-link:hover { text-decoration: underline; }

/* 图片 LOGO：替换元素不需要 grid 居中，统一按块级图片处理 */
img.logo, img.avatar { display: block; }
.login-brand img.logo, .sidebar-brand img.logo, .user-chip img.avatar {
  background: transparent; border: 0; padding: 0;
}

/* 只读账号（viewer）：隐藏写操作入口。后端对写接口亦有拦截，这里只是让界面不自相矛盾。 */
body.role-viewer #app [data-act="new"],
body.role-viewer #app [data-act="new-contract"],
body.role-viewer #app [data-act="new-reminder"],
body.role-viewer #app [data-act="base-new"],
body.role-viewer #app [data-act="subject-new"],
body.role-viewer #app [data-act="user-new"],
body.role-viewer #app [data-act="add-plan"],
body.role-viewer #app [data-act="add-payment"],
body.role-viewer #app [data-act="del-plan"],
body.role-viewer #app [data-act="del-file"],
body.role-viewer #app [data-act="upload"],
body.role-viewer #app [data-act="upload-scan"],
body.role-viewer #app [data-act="save-company"],
body.role-viewer #app [data-act="backup-upload"],
body.role-viewer #app [data-act="log-clear"],
body.role-viewer #app [data-reset-scope],
body.role-viewer #app .link-btn.danger { display: none !important; }
