/* ==========================================================================
   晴川集团工作台 · 企业微信风格设计系统 + 完整移动端适配 + 浅色/深色双模
   ========================================================================== */

:root {
  /* === 品牌色 === */
  --brand:         #276ff5;          /* 企业微信蓝 */
  --brand-d:       #1d5cd9;          /* hover/active */
  --brand-l:       #e8f1ff;          /* selected chip bg */
  --brand-08:      rgba(39,111,245,.08);
  --brand-12:      rgba(39,111,245,.12);
  --brand-15:      rgba(39,111,245,.15);

  /* === 中性色（高对比；浅色模式下浅色版深色文字也清晰，深色模式下反之） === */
  --text:          #1c1f23;          /* 主文字（浅色模式） */
  --text-soft:     #4f5660;          /* 次要文字 */
  --text-muted:    #86909c;          /* 辅助文字 */
  --text-placeholder: #a8b0bd;       /* placeholder（足够亮但保持可见） */
  --inverse:       #ffffff;          /* 反色（按钮文字） */

  /* === 背景 === */
  --bg:            #f4f5f7;          /* 页面背景（轻微软冷灰，比纯白更护眼） */
  --bg-card:       #ffffff;          /* 卡片/弹窗背景 */
  --bg-soft:       #fafbfc;          /* 表格头 / 次级容器 */
  --bg-hover:      #f5f7fa;          /* 行 hover */
  --bg-selected:   #eaf2ff;          /* 选中行 */

  /* === 边线 / 阴影 === */
  --border:        #e5e8ed;          /* 1px 边线 */
  --border-strong: #d2d6dd;
  --divider:       #eef0f3;          /* 分割线（更弱） */
  --shadow-sm:     0 1px 2px rgba(20,32,54,.04);
  --shadow:        0 2px 8px rgba(20,32,54,.06), 0 0 0 1px rgba(20,32,54,.02);
  --shadow-lg:     0 12px 36px rgba(20,32,54,.16);

  /* === 语义色 === */
  --success:       #00b853;          /* 企业微信绿 */
  --success-l:     #e6f8ed;
  --danger:        #e5454d;          /* 危险红 */
  --danger-l:      #fdecec;
  --warning:       #ff9100;          /* 警示橙 */
  --warning-l:     #fff3e6;
  --info:          #276ff5;
  --info-l:        #e8f1ff;
  --accent:        #8e44ad;
  --accent-l:      #f3eaf7;

  /* === 圆角 / 间距 === */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 999px;

  /* === 顶部安全区 === */
  --safe-top:      env(safe-area-inset-top, 0px);
  --safe-bottom:   env(safe-area-inset-bottom, 0px);
  --topbar-h:      56px;
  --sidebar-w:     220px;

  /* === 字体 === */
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Segoe UI", Roboto, sans-serif;
}

/* === 自动深色模式：跟随系统；浅色模式下信息不会因颜色重合无法显示 === */
@media (prefers-color-scheme: dark) {
  :root {
    --text:          #e8eaed;
    --text-soft:     #b5b9c1;
    --text-muted:    #80868f;
    --text-placeholder: #5f6571;
    --bg:            #1c1d20;
    --bg-card:       #24262a;
    --bg-soft:       #2a2c30;
    --bg-hover:      #2f3236;
    --bg-selected:   #2c3a52;
    --border:        #363a40;
    --border-strong: #4a4f56;
    --divider:       #2f3236;
    --shadow:        0 2px 8px rgba(0,0,0,.3);
    --shadow-lg:     0 12px 36px rgba(0,0,0,.5);
    --brand-l:       #1e2c45;
    --brand-08:      rgba(120,170,255,.10);
    --brand-12:      rgba(120,170,255,.18);
    --success-l:     #14321f;
    --danger-l:      #3a1f1f;
    --warning-l:     #3a2814;
    --info-l:        #1e2c45;
    --accent-l:      #2c1f33;
  }
}

/* ==========================================================================
   基础重置
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
* { -webkit-tap-highlight-color: transparent; }
html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-size-adjust: 100%;
}
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  /* 用 clip 而非 hidden：hidden 会在 iOS 上创建滚动容器、截断内部 overflow-x:auto 的横向滚动链，
     导致表格无法手指拖动；clip 不创建滚动容器，既防横向溢出又不阻断内部横滑 */
  overflow-x: clip;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-d); }
img, svg { max-width: 100%; height: auto; }
hr { border: 0; border-top: 1px solid var(--divider); }

/* 修复 placeholder 颜色（默认浏览器 / 浅色模式可能用系统色与白底重合） */
::placeholder, ::-webkit-input-placeholder, ::-moz-placeholder {
  color: var(--text-placeholder);
  opacity: 1;
}
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--bg-card) inset;
  transition: background-color 5000s ease-in-out 0s;
}

/* 修复 iOS Safari 表单元素默认样式 */
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="tel"], input[type="url"], input[type="search"], input[type="date"],
input[type="datetime-local"], input[type="month"], input[type="time"], input[type="week"],
select, textarea {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border-radius: var(--r-sm);
  background-color: var(--bg-card);
}
/* iOS 不允许 input font-size < 16px 时自动放大 */
@media (max-width: 820px) {
  input, select, textarea { font-size: 16px; }
}

/* 滚动条美化 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
::-webkit-scrollbar-track { background: transparent; }

/* ==========================================================================
   登录
   ========================================================================== */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eaf2ff 0%, var(--bg) 50%, var(--bg-card) 100%);
  padding: 24px 16px;
  padding-top: calc(24px + var(--safe-top));
  padding-bottom: calc(24px + var(--safe-bottom));
}
.login-card {
  width: 400px;
  max-width: 100%;
  background: var(--bg-card);
  border-radius: var(--r-xl);
  padding: 40px 36px 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  border: 1px solid var(--border);
}
.login-logo { display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.login-logo img { height: 56px; width: auto; }
.login-card h1 { font-size: 22px; font-weight: 700; margin: 10px 0 4px; letter-spacing: .3px; color: var(--text); }
.login-sub { color: var(--text-muted); margin-bottom: 26px; font-size: 13px; }
.login-card label {
  display: block; text-align: left; font-size: 13px;
  color: var(--text-soft); margin: 14px 0 6px; font-weight: 500;
}
.login-card input {
  width: 100%; padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  outline: none; transition: .15s;
  color: var(--text);
  background: var(--bg-card);
}
.login-card input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-08);
}
.login-tip { margin-top: 18px; font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.error-text { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ==========================================================================
   按钮 · 企业微信风格：实色 + 12px 圆角 + 38px 高度触摸目标
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 16px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 400;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
  user-select: none;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--inverse);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(39,111,245,.18);
}
.btn.primary:hover { background: var(--brand-d); border-color: var(--brand-d); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn.danger {
  background: var(--bg-card);
  border-color: var(--danger-l);
  color: var(--danger);
}
.btn.danger:hover { background: var(--danger-l); border-color: var(--danger-l); color: var(--danger); }
.btn.warning { background: var(--warning-l); border-color: var(--warning-l); color: var(--warning); }
.btn.sm { min-height: 28px; padding: 3px 10px; font-size: 13px; }
.btn.xs { min-height: 22px; padding: 1px 8px; font-size: 12px; border-radius: var(--r-sm); }
.btn.block { width: 100%; min-height: 44px; margin-top: 18px; padding: 12px; font-size: 15px; }

/* ==========================================================================
   应用骨架
   ========================================================================== */
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  padding-top: var(--safe-top);
  height: calc(var(--topbar-h) + var(--safe-top));
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; letter-spacing: .2px; color: var(--text); }
.brand-logo { height: 28px; width: auto; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-badge {
  background: var(--brand-l);
  color: var(--brand-d);
  padding: 5px 12px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
}
.topbar-right .btn { min-height: 32px; }

.layout { display: flex; flex: 1; min-height: 0; }

/* ==========================================================================
   侧边栏
   ========================================================================== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 12px 0 16px;
  display: flex; flex-direction: column;
  position: sticky;
  top: var(--topbar-h);
  align-self: flex-start;
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h) - var(--safe-top));
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 18px 16px;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 8px;
}
.sidebar-brand img { height: 30px; width: auto; }
.sidebar-brand span { font-weight: 600; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tab {
  display: flex; align-items: center; gap: 10px;
  border: none; background: transparent;
  padding: 10px 14px;
  margin: 2px 8px;
  font-size: 14px;
  color: var(--text-soft);
  border-radius: var(--r-md);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  position: relative;
  transition: background .12s, color .12s;
  width: calc(100% - 16px);
}
.tab-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.tab:hover { background: var(--bg-hover); color: var(--text); }
.tab.active {
  background: var(--brand-l);
  color: var(--brand);
  font-weight: 600;
}
.tab.active .tab-icon { opacity: 1; }

/* ==========================================================================
   内容区域
   ========================================================================== */
.content {
  flex: 1;
  padding: 20px 24px 32px;
  min-width: 0;
  background: var(--bg);
}

/* ==========================================================================
   面板 · 企业微信风格：白底 + 8px 圆角 + 1px 边线，轻阴影
   ========================================================================== */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.panel h3 {
  font-size: 15px; font-weight: 600; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between;
  color: var(--text);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.panel-head h3 { margin-bottom: 0; }

/* ==========================================================================
   统计卡片
   ========================================================================== */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.stat-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--brand);
}
.stat-card:nth-child(2)::before { background: var(--success); }
.stat-card:nth-child(3)::before { background: var(--warning); }
.stat-card:nth-child(4)::before { background: var(--accent); }
.stat-card:nth-child(5)::before { background: #0ea5e9; }
.stat-card:nth-child(6)::before { background: #6366f1; }
.stat-card:nth-child(7)::before { background: #ec4899; }
.stat-card:nth-child(8)::before { background: #14b8a6; }
.stat-card:nth-child(9)::before { background: #f97316; }
.stat-card .num {
  font-size: 26px; font-weight: 700; color: var(--text);
  letter-spacing: -.3px;
  font-variant-numeric: tabular-nums;
}
.stat-card .lbl { color: var(--text-muted); margin-top: 4px; font-size: 13px; }
.stat-card.clickable { cursor: pointer; }
.stat-card.clickable:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--brand);
}

.section-title {
  font-size: 15px; font-weight: 600;
  margin: 18px 0 12px; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.section-title .badge {
  font-size: 12px; font-weight: 400;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 2px 8px; border-radius: var(--r-pill);
}

/* ==========================================================================
   工具栏 / 表单
   ========================================================================== */
.toolbar {
  display: flex; gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap; align-items: center;
}
.toolbar input[type=text],
.toolbar input[type=number],
.toolbar input[type=date],
.toolbar input[type=search] {
  flex: 1; min-width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  outline: none;
  background: var(--bg-card);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.toolbar input:focus, .toolbar select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-08);
}
.toolbar select, .toolbar .input, .form-field select.input, select.input {
  padding: 8px 28px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  outline: none;
  background-color: var(--bg-card);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2386909c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
}
.toolbar.filter-row {
  flex-wrap: wrap; gap: 8px 10px; align-items: center;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 12px;
  margin-bottom: 14px;
}
.toolbar.filter-row .filter-label { font-size: 13px; color: var(--text-soft); font-weight: 600; }
.toolbar.filter-row .filter-sep { font-size: 13px; color: var(--text-muted); margin-left: 4px; }

.hint {
  color: var(--text-soft);
  font-size: 13px;
  background: var(--brand-l);
  padding: 8px 12px;
  border-radius: var(--r-md);
  border-left: 3px solid var(--brand);
}

/* ==========================================================================
   表单字段
   ========================================================================== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-field.full { grid-column: 1 / -1; }
.form-field label {
  font-size: 13px; color: var(--text-soft); font-weight: 500;
  display: flex; align-items: center; gap: 4px;
}
.form-field input, .form-field select, .form-field textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  outline: none;
  background: var(--bg-card);
  color: var(--text);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.form-field select {
  padding-right: 30px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2386909c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  appearance: none;
  -webkit-appearance: none;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-08);
}
.form-field textarea { resize: vertical; min-height: 72px; font-family: inherit; }
.form-field input[disabled], .form-field select[disabled], .form-field textarea[disabled] {
  background: var(--bg-soft);
  color: var(--text-muted);
  cursor: not-allowed;
}

.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--divider);
}
@media (max-width: 560px) {
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; min-height: 44px; }
}

/* ==========================================================================
   列表 / 简易表格 / 数据表格
   ========================================================================== */
.simple-list .row {
  padding: 10px 0;
  border-bottom: 1px dashed var(--divider);
  font-size: 13px;
}
.simple-list .row:last-child { border-bottom: none; }
.simple-list .empty { color: var(--text-muted); padding: 12px 0; text-align: center; }

.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  /* 用 overflow:auto（双向）而非 overflow-x:auto：iOS Safari / 微信内置核对单轴横向滚动支持不稳定，
     双向 auto 能可靠启用触摸滚动；不设置 touch-action，避免微信内核误拦截横向手势 */
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}
.table-scroll { overflow: auto; -webkit-overflow-scrolling: touch; position: relative; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  padding: 13px 14px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--divider);
  color: var(--text);
  vertical-align: middle;
}
.data-table th {
  background: var(--bg-soft);
  color: var(--text-soft);
  font-weight: 600;
  white-space: nowrap;
  position: sticky; top: 0;
  z-index: 1;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }
.data-table .ops { display: flex; gap: 6px; flex-wrap: wrap; }

.status-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 500;
  background: var(--brand-l);
  color: var(--brand);
}
.status-tag.ok { background: var(--success-l); color: var(--success); }
.status-tag.warn { background: var(--warning-l); color: var(--warning); }
.status-tag.danger { background: var(--danger-l); color: var(--danger); }
.status-tag.muted { background: var(--bg-hover); color: var(--text-muted); }

.amount { color: var(--success); font-weight: 600; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.pos { color: var(--success); font-weight: 600; }
.neg { color: var(--danger); font-weight: 600; }
.bold { font-weight: 600; }

.badge {
  display: inline-block;
  font-size: 12px; font-weight: 600;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  background: var(--bg-hover);
  color: var(--text-soft);
}
.badge.ok { background: var(--success-l); color: var(--success); }
.badge.warn { background: var(--warning-l); color: var(--warning); }
.badge.danger { background: var(--danger-l); color: var(--danger); }
.badge.brand { background: var(--brand-l); color: var(--brand); }
.badge.muted { background: var(--bg-hover); color: var(--text-muted); }

.mask-tag {
  background: var(--bg-hover);
  padding: 2px 6px; border-radius: var(--r-xs);
  color: var(--text-muted);
  font-family: monospace;
}

.pager {
  display: flex; align-items: center; gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.pager button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--r-md);
  font-weight: 500;
  color: var(--text);
}
.pager button:hover:not(:disabled) { background: var(--bg-hover); }
.pager button:disabled { opacity: .4; cursor: not-allowed; }
.pager button.active {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--inverse);
}

.empty {
  color: var(--text-muted);
  text-align: center;
  padding: 36px 20px;
  font-size: 14px;
}
.empty .empty-ico { font-size: 32px; margin-bottom: 8px; opacity: .5; }
.empty .empty-title { color: var(--text-soft); font-size: 14px; margin-bottom: 4px; }

/* ==========================================================================
   弹窗
   ========================================================================== */
.modal {
  position: fixed; inset: 0;
  background: rgba(15,20,30,.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 16px;
  padding-top: calc(16px + var(--safe-top));
  padding-bottom: calc(16px + var(--safe-bottom));
}
.modal-box {
  background: var(--bg-card);
  width: 600px;
  max-width: 100%;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 32px);
  display: flex; flex-direction: column;
  overflow: hidden;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--divider);
  background: var(--bg-card);
  flex-shrink: 0;
}
.modal-head h3 { font-size: 16px; font-weight: 600; color: var(--text); }
.modal-close {
  border: none; background: transparent;
  font-size: 24px; line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }
.modal-body {
  padding: 18px 20px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
}

/* ==========================================================================
   通用多选/单选选择器 (Multi-Select Picker)
   ========================================================================== */
.msp-toolbar {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 10px;
}
.msp-search-wrap { flex: 1; position: relative; min-width: 0; }
.msp-search {
  width: 100%; padding: 8px 12px 8px 34px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg-card); color: var(--text); outline: none;
  font-size: 14px; line-height: 1.4;
  transition: border-color .15s, box-shadow .15s;
}
.msp-search:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-08);
}
.msp-search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; flex: none;
  color: var(--text-muted); pointer-events: none;
}
.msp-quick { display: flex; gap: 6px; flex-shrink: 0; }
.msp-status {
  font-size: 12px; color: var(--text-muted); margin-bottom: 8px;
}
.msp-status b { color: var(--brand); font-weight: 600; }
.msp-list {
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg-card); max-height: 320px; overflow-y: auto;
}
.msp-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--divider);
  cursor: pointer; transition: background .12s;
}
.msp-row:last-child { border-bottom: none; }
.msp-row:hover { background: var(--bg-hover); }
.msp-row.selected { background: var(--bg-selected); }
.msp-row-check { margin-top: 2px; flex: none; }
.msp-row-body { flex: 1; min-width: 0; }
.msp-row-main { font-size: 14px; color: var(--text); font-weight: 500; }
.msp-row-no { color: var(--text-muted); font-weight: 400; margin-left: 4px; font-size: 13px; }
.msp-row-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.msp-empty, .msp-loading {
  text-align: center; padding: 30px 12px; color: var(--text-muted); font-size: 13px;
}

/* ==========================================================================
   Toast
   ========================================================================== */
#toast.toast {
  position: fixed;
  bottom: 30px; left: 50%;
  transform: translateX(-50%);
  background: rgba(28,31,35,.92);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--r-md);
  font-size: 14px;
  z-index: 2000;
  box-shadow: var(--shadow-lg);
  max-width: 80vw;
  pointer-events: none;
}

/* ==========================================================================
   时间线 / 步骤
   ========================================================================== */
.timeline { border-left: 2px solid var(--divider); margin-left: 8px; padding-left: 16px; }
.tl-item { position: relative; padding: 0 0 16px 0; }
.tl-item::before {
  content: ''; position: absolute;
  left: -23px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--brand);
}
.tl-meta { font-size: 12px; color: var(--text-muted); }
.tl-content { margin-top: 4px; color: var(--text); }
.tl-type {
  display: inline-block; background: var(--bg-hover);
  border-radius: var(--r-xs); padding: 1px 7px;
  font-size: 12px; color: var(--text-soft);
  margin-right: 6px;
}
.tl-next { color: var(--brand-d); font-size: 12px; margin-top: 4px; }

/* ==========================================================================
   角色行 / 类型卡片
   ========================================================================== */
.role-row {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-bottom: 10px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px;
  background: var(--bg-card);
}
.role-row .drag-handle { cursor: grab; color: var(--text-muted); user-select: none; font-size: 16px; flex-shrink: 0; }
.role-row .role-info { flex: 1; min-width: 0; }
.role-row.drag-over { border-color: var(--brand); background: var(--bg-selected); }

.type-card {
  transition: border-color .15s, box-shadow .15s, transform .1s;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card);
}
.type-card:hover {
  border-color: var(--brand);
  box-shadow: 0 2px 10px rgba(39,111,245,.08);
  transform: translateY(-1px);
}
.tf-row { background: var(--bg-soft); }

/* ==========================================================================
   柱状图
   ========================================================================== */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-row .name { width: 84px; color: var(--text-soft); font-size: 13px; text-align: right; flex-shrink: 0; }
.bar-row .val { width: 64px; font-size: 13px; color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.bar-track { flex: 1; background: var(--bg-hover); border-radius: var(--r-sm); height: 22px; overflow: hidden; min-width: 60px; }
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #5b8cf5);
  border-radius: var(--r-sm);
  transition: width .45s ease;
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 8px; color: #fff; font-size: 12px; font-weight: 600;
  min-width: 32px;
}
.bar-row.clickable { cursor: pointer; border-radius: var(--r-md); padding: 4px; margin: 0 -4px; transition: background .12s; }
.bar-row.clickable:hover { background: var(--brand-08); }
.bar-row.clickable:hover .bar-fill { filter: brightness(1.06); }

/* ==========================================================================
   分段切换
   ========================================================================== */
.seg {
  display: inline-flex;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 2px;
  gap: 2px;
}
.seg-btn {
  border: none; background: transparent;
  color: var(--text-soft);
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
  border-radius: var(--r-sm);
  min-height: 30px;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active {
  background: var(--bg-card);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   通讯录
   ========================================================================== */
.contacts-layout {
  display: flex; gap: 16px; align-items: flex-start;
}
.contacts-layout .dept-panel {
  width: 280px; flex: 0 0 280px;
  max-height: 70vh; overflow: auto;
}
.dept-filter-hint { font-size: 12px; color: var(--text-muted); margin: 8px 0; }
.dept-filter-active { background: var(--brand-l); border-color: var(--brand); }
.tag-dept {
  display: inline-block; font-size: 12px;
  padding: 1px 8px; border-radius: var(--r-pill);
  background: var(--brand-l); color: var(--brand-d);
  margin: 1px 3px 1px 0;
}

/* ==========================================================================
   流转单
   ========================================================================== */
.flow-meta {
  display: flex; flex-wrap: wrap; gap: 8px 26px;
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 16px;
  font-size: 13px;
}
.flow-meta b { color: var(--text-soft); font-weight: 600; margin-right: 4px; }

.flow-timeline { display: flex; flex-direction: column; gap: 10px; }
.flow-node {
  position: relative;
  padding: 14px 14px 14px 18px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: var(--r-md);
  margin-bottom: 0;
  background: var(--bg-card);
  transition: box-shadow .15s, border-color .15s;
}
.flow-node.current {
  border-left-color: var(--brand);
  background: var(--brand-l);
}
.flow-node.done { border-left-color: var(--success); }
.flow-node.rejected { border-left-color: var(--danger); }
.flow-node.pending { border-left-color: var(--warning); }
.flow-node-head {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  color: var(--text);
}
.flow-node-idx {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff; font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.flow-node-name { font-weight: 600; font-size: 14px; color: var(--text); }
.flow-node-assignee { font-size: 12px; color: var(--text-muted); }
.flow-node-comment {
  margin-top: 8px; font-size: 12px;
  color: var(--text-soft);
  background: var(--bg-soft);
  padding: 6px 10px; border-radius: var(--r-sm);
}
.flow-assign { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.flow-act { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.flow-hist {
  list-style: none; margin: 10px 0 0; padding: 8px 0 0;
  border-top: 1px dashed var(--divider);
}
.flow-hist li { font-size: 12px; color: var(--text-soft); padding: 2px 0; }
.flow-hist .hist-actor { font-weight: 600; color: var(--text); }

/* ==========================================================================
   流转单 · 步骤进度条
   ========================================================================== */
.flow-progress { margin: 6px 0 14px; }
.flow-progress-head {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 8px; flex-wrap: wrap;
}
.flow-progress-title { font-weight: 600; font-size: 14px; color: var(--text); }
.flow-progress-pct { font-size: 18px; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.flow-progress-sub { color: var(--text-muted); font-size: 12px; }
.flow-progress-track {
  height: 6px;
  background: var(--bg-hover);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.flow-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #4dd99a);
  border-radius: var(--r-pill);
  transition: width .4s ease;
}

.flow-steps {
  display: flex; align-items: flex-start; gap: 0;
  margin: 0 0 18px;
  overflow-x: auto;
  padding: 2px 0 6px;
  -webkit-overflow-scrolling: touch;
}
.flow-step {
  flex: 1 0 96px; min-width: 96px;
  position: relative; text-align: center;
  cursor: pointer;
  padding: 0 6px;
}
.flow-step-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border-strong);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
  position: relative; z-index: 2;
  transition: .15s;
}
.flow-step-line {
  position: absolute; top: 13px; left: 50%;
  width: 100%; height: 2px;
  background: var(--border-strong);
  z-index: 1;
}
.flow-step:last-child .flow-step-line { display: none; }
.flow-step-line.done { background: var(--success); }
.flow-step-name {
  margin-top: 6px;
  font-size: 12px; font-weight: 500;
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
.flow-step-status { font-size: 11px; margin-top: 2px; color: var(--text-muted); }
.flow-step.done .flow-step-dot {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.flow-step.rejected .flow-step-dot {
  background: var(--danger); border-color: var(--danger); color: #fff;
}
.flow-step.active .flow-step-dot {
  border-color: var(--brand);
  color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-08);
}
.flow-step.active .flow-step-name { color: var(--brand); font-weight: 600; }
.flow-step:hover .flow-step-dot { border-color: var(--brand); }

/* ==========================================================================
   模板与路由配置
   ========================================================================== */
.cfg-list { display: flex; flex-direction: column; gap: 10px; }
.cfg-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-card);
}
.cfg-main b { font-size: 14px; }
.cfg-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.cfg-ops { display: flex; gap: 6px; flex-shrink: 0; }
.tpl-node-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ==========================================================================
   移动端：汉堡按钮 + 抽屉式侧边栏
   ========================================================================== */
.topbar-left { display: flex; align-items: center; gap: 10px; }
.btn-menu {
  display: none;
  font-size: 22px;
  padding: 4px 10px;
  min-height: 36px;
  min-width: 36px;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  inset: calc(var(--topbar-h) + var(--safe-top)) 0 0 0;
  background: rgba(15,20,30,.5);
  z-index: 99;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

/* ==========================================================================
   审批进度 · 通知 · toast 相关
   ========================================================================== */
.apv-panel { transition: box-shadow .15s, background .15s, transform .15s; }
.apv-panel:hover {
  background: var(--bg-hover);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.apv-step-row { transition: background .15s; padding: 4px 6px; margin: 2px -6px; border-radius: var(--r-sm); }
.apv-step-row:hover { background: var(--bg-selected); }

.notif-toast-container {
  position: fixed; right: 18px; bottom: 18px;
  z-index: 1500;
  display: flex; flex-direction: column-reverse; gap: 10px;
  pointer-events: none;
  max-width: calc(100vw - 36px);
}
.notif-toast {
  pointer-events: auto;
  width: 340px; max-width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text);
  position: relative;
  cursor: pointer;
  transform: translateX(120%);
  opacity: 0;
  transition: transform .32s cubic-bezier(.2,.8,.2,1), opacity .28s ease;
}
.notif-toast.show { transform: translateX(0); opacity: 1; }
.notif-toast.leaving { transform: translateX(120%); opacity: 0; }
.notif-toast.kind-flowsheet { border-left-color: var(--accent); }
.notif-toast.kind-service-assign { border-left-color: var(--success); }
.notif-toast.kind-contract,
.notif-toast.kind-approval { border-left-color: var(--brand); }
.notif-toast.kind-collection { border-left-color: var(--warning); }
.notif-toast.kind-renewal { border-left-color: var(--accent); }
.notif-toast .nt-title {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; font-weight: 600; line-height: 1.35; padding-right: 22px;
}
.notif-toast .nt-title-text { flex: 1; min-width: 0; }
.notif-toast .nt-close {
  position: absolute; top: 6px; right: 8px;
  background: transparent; border: 0; color: var(--text-muted);
  font-size: 16px; line-height: 1; cursor: pointer;
  padding: 2px 4px; border-radius: var(--r-xs);
}
.notif-toast .nt-close:hover { background: var(--bg-hover); color: var(--text); }
.notif-toast .nt-body {
  color: var(--text-soft);
  font-size: 12px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.notif-toast .nt-time { color: var(--text-muted); font-size: 11px; margin-top: 2px; }

/* ==========================================================================
   服务分配（sa-*）
   ========================================================================== */
.sa-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.sa-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--brand);
  transition: transform .2s, box-shadow .2s;
}
.sa-stat:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.sa-stat-pending { border-left-color: var(--warning); }
.sa-stat-pending .sa-stat-num { color: var(--warning); }
.sa-stat-assigned { border-left-color: var(--success); }
.sa-stat-assigned .sa-stat-num { color: var(--success); }
.sa-stat-customer { border-left-color: var(--brand); }
.sa-stat-customer .sa-stat-num { color: var(--brand); }
.sa-stat-num {
  font-size: 30px; font-weight: 700; line-height: 1.1; margin-bottom: 4px;
  font-variant-numeric: tabular-nums; color: var(--text);
}
.sa-stat-lbl { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.sa-stat-hint { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

.sa-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.sa-toolbar-left, .sa-toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sa-tab {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-soft);
  padding: 9px 16px;
  font-size: 14px; font-weight: 500;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all .15s;
}
.sa-tab:hover { border-color: var(--brand); color: var(--brand); }
.sa-tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--inverse);
  box-shadow: 0 2px 6px rgba(39,111,245,.2);
}
.sa-tab-ico { font-size: 16px; line-height: 1; }
.sa-tab-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 7px;
  background: var(--bg-hover); color: var(--brand);
  border-radius: var(--r-pill);
  font-size: 12px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.sa-tab.active .sa-tab-count { background: rgba(255,255,255,.22); color: #fff; }

.sa-batch-btn {
  display: inline-flex !important; align-items: center; gap: 6px;
  font-size: 14px !important; font-weight: 600 !important;
  padding: 9px 18px !important;
  background: linear-gradient(135deg, var(--warning) 0%, #d97a00 100%) !important;
  border-color: #d97a00 !important;
  color: #fff !important;
  box-shadow: 0 2px 6px rgba(255,145,0,.22);
}
.sa-batch-btn:hover { transform: translateY(-1px); }
.sa-btn-ico { font-size: 15px; line-height: 1; }

.sa-hint-bar {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--brand-l);
  border: 1px solid var(--brand-15);
  border-radius: var(--r-md);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 12.5px;
  color: var(--text-soft);
  line-height: 1.55;
}
.sa-hint-ico { flex-shrink: 0; font-size: 14px; line-height: 1.55; }
.sa-row-action {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--warning);
  color: #fff; border: 0;
  padding: 6px 14px;
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.sa-row-action:hover { background: #d97a00; transform: translateY(-1px); }
.sa-row-action.sa-row-reassign { background: var(--brand); }
.sa-row-action.sa-row-reassign:hover { background: var(--brand-d); box-shadow: 0 2px 8px rgba(39,111,245,.3); }

.sa-empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 56px 20px;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  text-align: center;
}
.sa-empty-state .sa-empty-ico { font-size: 48px; margin-bottom: 12px; opacity: .5; }
.sa-empty-state .sa-empty-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.sa-empty-state .sa-empty-hint { font-size: 13px; line-height: 1.5; max-width: 420px; }

.sa-entry-banner {
  display: flex; align-items: center; gap: 12px;
  background: var(--warning-l);
  border: 1px solid var(--warning-l);
  border-radius: var(--r-md);
  padding: 12px 18px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}
.sa-entry-banner .sa-entry-ico { font-size: 22px; flex-shrink: 0; }
.sa-entry-banner .sa-entry-text { flex: 1; }
.sa-entry-banner b { color: var(--warning); font-weight: 700; }
.sa-entry-banner button { flex-shrink: 0; }

.sa-batch-toolbar {
  display: none; align-items: center; justify-content: space-between;
  gap: 12px;
  background: var(--warning-l);
  border: 1px solid var(--warning-l);
  border-radius: var(--r-md);
  padding: 8px 14px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text);
}
.sa-batch-toolbar.show { display: flex; }
.sa-batch-toolbar .sa-batch-info b { color: var(--warning); font-weight: 700; }

.sa-row-action-sm {
  display: inline-flex; align-items: center; gap: 4px;
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--brand);
  padding: 5px 12px;
  border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.sa-row-action-sm:hover { background: var(--brand-08); }

/* ==========================================================================
   素材库
   ========================================================================== */
.materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
}
.material-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.material-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--brand);
}
.material-thumb {
  height: 130px;
  background: var(--bg-soft);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.material-thumb img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.material-thumb .file-icon { font-size: 40px; color: var(--text-muted); }
.material-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.material-name {
  font-size: 13px; font-weight: 600;
  word-break: break-all; line-height: 1.35;
  color: var(--text);
}
.material-meta {
  font-size: 12px; color: var(--text-muted);
  display: flex; justify-content: space-between; gap: 8px;
}
.material-cat {
  display: inline-block; font-size: 11px;
  color: var(--brand-d);
  background: var(--brand-l);
  border-radius: var(--r-pill);
  padding: 1px 8px;
  margin-top: 2px;
  align-self: flex-start;
}
.material-ops { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.material-empty { grid-column: 1 / -1; text-align: center; color: var(--text-muted); padding: 40px; }

.mat-crumbs {
  font-size: 13px; color: var(--text-muted);
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 4px;
  flex-wrap: wrap;
}
.mat-crumb { color: var(--brand); cursor: pointer; }
.mat-crumb:hover { text-decoration: underline; }
.mat-crumb-sep { color: var(--text-muted); }
.mat-folder-grid { margin-bottom: 18px; }
.mat-folder-grid-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; font-weight: 600;
  color: var(--text); margin-bottom: 10px;
}
.mat-folder-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 14px;
}
.mat-folder-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  padding: 16px 12px 12px;
  text-align: center;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, border-color .12s;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.mat-folder-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: var(--shadow);
}
.mat-folder-card-ico { font-size: 40px; line-height: 1; }
.mat-folder-card-name {
  font-size: 13px; font-weight: 600;
  color: var(--text);
  word-break: break-all; line-height: 1.3;
  max-height: 2.6em; overflow: hidden;
}
.mat-folder-card-count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-hover);
  border-radius: var(--r-pill);
  padding: 1px 8px;
}
.mat-card-ops {
  position: absolute; top: 6px; right: 6px;
  display: none; gap: 2px;
}
.mat-folder-card:hover .mat-card-ops { display: inline-flex; }
body:not(.is-admin) .mat-card-ops { display: none !important; }
.mat-card-ops .btn.xs { padding: 0 6px; font-size: 11px; line-height: 18px; }

/* ==========================================================================
   审批发起 · 关联合同实时搜索
   ========================================================================== */
.contract-picker { position: relative; }
.cp-dropdown {
  position: absolute; left: 0; right: 0; top: 100%;
  z-index: 1100;
  margin-top: 4px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
}
.cp-item {
  padding: 8px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 13px;
  display: flex; align-items: center; gap: 6px;
  color: var(--text);
}
.cp-item:hover { background: var(--brand-l); }
.cp-item b { color: var(--brand); }
.cp-amt { margin-left: auto; color: var(--text-muted); font-size: 12px; }
.cp-sub { color: var(--text-muted); font-size: 12px; }
.cp-empty { padding: 10px; text-align: center; color: var(--text-muted); font-size: 13px; }
.cp-selected { min-height: 0; }

/* ==========================================================================
   过滤栏
   ========================================================================== */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.filter-bar .form-field label { font-size: 12px; color: var(--text-soft); font-weight: 500; }
.filter-bar .form-field { margin: 0; }

/* ==========================================================================
   全局权限
   ========================================================================== */
body:not(.is-admin) [data-admin] { display: none !important; }
body.is-readonly [data-write] { display: none !important; }

/* ==========================================================================
   响应式断点（mobile-first 渐进式）
   ========================================================================== */

/* ---- 大屏及以上：默认样式 ---- */

/* ---- ≤ 980px：紧凑布局 ---- */
@media (max-width: 980px) {
  .stat-cards { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .content { padding: 18px 20px 24px; }
  .sa-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---- ≤ 820px：手机端 ---- */
@media (max-width: 820px) {
  :root {
    --topbar-h: 52px;
    --sidebar-w: 240px;
  }
  .btn-menu { display: inline-flex; align-items: center; justify-content: center; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-right { gap: 6px; }
  .topbar-right .btn { padding: 5px 8px; min-height: 30px; font-size: 13px; }
  #btn-change-pwd { display: none; }
  .user-badge { font-size: 11px; padding: 4px 10px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .brand-text { display: none; }
  .brand-logo { height: 26px; }

  .layout { display: block; }
  .sidebar {
    position: fixed;
    top: calc(var(--topbar-h) + var(--safe-top));
    left: 0; bottom: 0;
    width: 240px;
    max-width: 82vw;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 110;
    box-shadow: var(--shadow-lg);
    height: auto;
    border-right: 1px solid var(--border);
    background: var(--bg-card);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar .tab { justify-content: flex-start; }

  .content { padding: 14px; }

  /* 表格横向滚动：仅由 .table-wrap / .table-scroll 作为滚动容器，切忌在 .panel/.content 上
     再套 overflow-x:auto（会形成嵌套滚动容器，真机 touch 横滑手势被外层吞掉，表现为“无法拖动”）。
     所有业务表格均已用 .table-wrap 包裹，保证超宽表格可横向拖动、操作列可点。 */
  .table-scroll { overflow: auto; -webkit-overflow-scrolling: touch; position: relative; }
  .table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; position: relative; }
  .table-wrap > table { display: inline-table; }
  .data-table { width: auto; min-width: 720px; table-layout: auto; }
  .data-table th, .data-table td { padding: 11px 12px; font-size: 13px; }
  /* 操作列/按钮在窄屏不挤压，保证可点 */
  .data-table .row-actions, .data-table td:last-child { white-space: nowrap; }

  /* 表单字段在 mobile 单列 */
  .form-grid { grid-template-columns: 1fr; }

  /* 工具栏 */
  .toolbar input[type=text] { width: 100%; min-width: 0; }
  .toolbar { gap: 8px; }

  /* 弹窗：全屏 */
  .modal { padding: 0; align-items: stretch; }
  .modal-box {
    width: 100%; max-width: 100%;
    max-height: 100vh; max-height: 100dvh;
    border-radius: 0;
    height: 100%;
  }

  /* 头像/品牌隐藏 */
  .sidebar-brand { padding: 4px 14px 14px; }

  /* 通知 toast 充满宽度 */
  .notif-toast-container { right: 10px; bottom: 10px; }
  .notif-toast { width: calc(100vw - 20px); }

  /* 素材库文件夹 */
  .mat-folder-cards { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
  .mat-folder-card { padding: 12px 8px 8px; }
  .mat-folder-card-ico { font-size: 32px; }
}

/* ---- ≤ 640px：小屏折叠 ---- */
@media (max-width: 640px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px 14px; }
  .stat-card .num { font-size: 22px; }
  .panel { padding: 14px; }
  .panel h3 { font-size: 14px; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .modal-footer { flex-wrap: wrap; }
  .sa-stats { grid-template-columns: 1fr; }
  .sa-toolbar { flex-direction: column; align-items: stretch; }
  .sa-toolbar-left, .sa-toolbar-right { width: 100%; }
  .sa-batch-btn { width: 100%; justify-content: center; }

  /* 容器内容紧凑 */
  .filter-bar { gap: 8px; padding: 10px; }
  .flow-step { flex: 1 0 76px; min-width: 76px; }

  /* 隐藏非关键元素 */
  #collection-badge, #renewal-badge, #service-assign-badge,
  #approval-badge, #liuzhuan-badge { font-size: 10px !important; padding: 0 4px !important; }
}

/* ---- ≤ 480px：极小屏 ---- */
@media (max-width: 480px) {
  .topbar { padding: 0 10px; }
  .btn { font-size: 13px; padding: 6px 12px; min-height: 32px; }
  .btn.sm { font-size: 12px; min-height: 26px; }
  .data-table th, .data-table td { padding: 9px 8px; font-size: 12px; }
  .form-field input, .form-field select, .form-field textarea { padding: 9px 10px; }
  .bar-row .name { width: 60px; font-size: 12px; }
  .content { padding: 10px; }
  .panel { border-radius: var(--r-md); padding: 12px; }
}

/* ---- 横屏 / iPad 迷你适配 ---- */
@media (max-width: 820px) and (orientation: landscape) {
  .topbar { height: 48px; padding-top: var(--safe-top); height: calc(48px + var(--safe-top)); }
  :root { --topbar-h: 48px; }
}


/* ============================================================
   可点击信息分级体系 (Clickable-info taxonomy)
   目标：让不同「类别 / 层级 / 状态」的可点击信息在视觉上明显可区分
   手段：颜色(左色条 + 图标底色) · 图标 · 边框 · 间距 · 标签
   ============================================================ */
.ci {
  position: relative;
  display: block;
  padding: 10px 12px 10px 16px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--r-md);
  background: var(--bg-card);
  cursor: pointer;
  transition: box-shadow .15s ease, transform .15s ease, background .15s ease, border-color .15s ease;
}
.ci:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); background: var(--bg-hover); }
.ci:active { transform: translateY(0); }
.ci + .ci { margin-top: 8px; }

/* —— 类别色（左色条 + 图标徽标底色，按业务类别区分） —— */
.ci.cat-approval   { border-left-color: #2563eb; }
.ci.cat-flow       { border-left-color: #6366f1; }
.ci.cat-service    { border-left-color: #f59e0b; }
.ci.cat-share      { border-left-color: #8b5cf6; }
.ci.cat-collection { border-left-color: #16a34a; }
.ci.cat-renewal    { border-left-color: #f97316; }
.ci.cat-daily      { border-left-color: #0ea5e9; }
.ci.cat-customer   { border-left-color: #14b8a6; }
.ci.cat-lead       { border-left-color: #ec4899; }
.ci.cat-system     { border-left-color: #64748b; }
.ci.cat-default    { border-left-color: #94a3b8; }

/* —— 状态修饰（与类别叠加，强调层级 / 处理状态） —— */
.ci.unread    { background: var(--brand-08); }
.ci.st-pending   { box-shadow: inset 3px 0 0 #e67e22; }
.ci.st-approved  { box-shadow: inset 3px 0 0 #00b853; }
.ci.st-rejected  { box-shadow: inset 3px 0 0 #e5454d; }
.ci.st-serving   { box-shadow: inset 3px 0 0 #16a34a; }
.ci.st-finished  { opacity: .82; }

/* —— 图标徽标 —— */
.ci-ico {
  width: 32px; height: 32px; flex: 0 0 32px;
  border-radius: 9px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; background: var(--brand-12); color: var(--brand);
}
.ci.cat-approval   .ci-ico { background: #e8f0fe; color: #2563eb; }
.ci.cat-flow       .ci-ico { background: #eef2ff; color: #6366f1; }
.ci.cat-service    .ci-ico { background: #fff4e0; color: #c2410c; }
.ci.cat-share      .ci-ico { background: #f3e8ff; color: #7c3aed; }
.ci.cat-collection .ci-ico { background: #e8f7ee; color: #15803d; }
.ci.cat-renewal    .ci-ico { background: #fff1e6; color: #c2410c; }
.ci.cat-daily      .ci-ico { background: #e6f7fb; color: #0c7cb8; }
.ci.cat-customer   .ci-ico { background: #e6f7f4; color: #0f766e; }
.ci.cat-lead       .ci-ico { background: #fde8f3; color: #be185d; }
.ci.cat-system     .ci-ico { background: #eef1f4; color: #475569; }
.ci.cat-default    .ci-ico { background: #eef1f4; color: #475569; }

/* —— 类别 / 状态小标签（药丸） —— */
.ci-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; line-height: 1;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.ci-tag.t-approval   { background: #e8f0fe; color: #2563eb; }
.ci-tag.t-flow       { background: #eef2ff; color: #6366f1; }
.ci-tag.t-service    { background: #fff4e0; color: #c2410c; }
.ci-tag.t-share      { background: #f3e8ff; color: #7c3aed; }
.ci-tag.t-collection { background: #e8f7ee; color: #15803d; }
.ci-tag.t-renewal    { background: #fff1e6; color: #c2410c; }
.ci-tag.t-daily      { background: #e6f7fb; color: #0c7cb8; }
.ci-tag.t-customer   { background: #e6f7f4; color: #0f766e; }
.ci-tag.t-lead       { background: #fde8f3; color: #be185d; }
.ci-tag.t-system     { background: #eef1f4; color: #475569; }
.ci-tag.t-default    { background: #eef1f4; color: #475569; }

/* —— 通知条目内部排版 —— */
.ci-main { display: flex; gap: 10px; align-items: flex-start; }
.ci-body { flex: 1 1 auto; min-width: 0; }
.ci-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ci-title { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.ci.unread .ci-title { color: #1d4ed8; }
.ci-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ci-time { font-size: 11px; color: var(--text-placeholder); margin-top: 5px; }
.ci-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: 0 0 8px; align-self: center; }

/* —— 客户档案表格行：按状态加左侧强调色条，区分「服务中 / 已完结」 —— */
.ca-row.serving  { box-shadow: inset 3px 0 0 #16a34a; }
.ca-row.finished { box-shadow: inset 3px 0 0 #94a3b8; }

/* —— 通用状态药丸（增强原 status-tag，带图标更醒目） —— */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; line-height: 1;
  padding: 3px 9px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap;
}
.tag.ok     { background: var(--success-l); color: var(--success); border-color: #b7ebc9; }
.tag.warn   { background: var(--warning-l); color: var(--warning); border-color: #ffd9a8; }
.tag.danger { background: var(--danger-l);  color: var(--danger);  border-color: #f6c2c4; }
.tag.muted  { background: var(--bg-hover);  color: var(--text-muted); border-color: var(--border); }
.tag.info   { background: var(--info-l);    color: var(--info);    border-color: #b9d3fb; }

/* —— 审批待办面板：复用类别色与状态强调，与通知体系一致 —— */
.apv-panel.cat-approval   { border-left: 3px solid #2563eb; }
.apv-panel.cat-collection { border-left: 3px solid #16a34a; }
.apv-panel.cat-share      { border-left: 3px solid #8b5cf6; }
.apv-panel.cat-daily      { border-left: 3px solid #0ea5e9; }
.apv-panel.cat-renewal    { border-left: 3px solid #f97316; }
.apv-panel.cat-default    { border-left: 3px solid #94a3b8; }
.apv-panel.st-pending   { box-shadow: inset 3px 0 0 #e67e22; }
.apv-panel.st-approved  { box-shadow: inset 3px 0 0 #00b853; }
.apv-panel.st-rejected  { box-shadow: inset 3px 0 0 #e5454d; }

