/* ==========================================================================
   多友财税 · 代账公司管理系统 —— 全局样式
   设计语言延续既有原型：深色侧栏 + 蓝色主色 + 圆角卡片 + 轻边框
   ========================================================================== */

:root {
  --bg-app: #F5F5FA;
  --surface: #FFFFFF;
  --surface-2: #F9FAFB;
  --sidebar: #0F1729;
  --sidebar-text: #E3E9F0;
  --sidebar-muted: #94A3B8;
  --border: #E6E7E8;
  --border-strong: #D5D7DC;
  --text-primary: #121726;
  --text-secondary: #6B7280;
  --text-tertiary: #9AA1AC;

  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-soft: #EFF6FF;
  --success: #059669;
  --success-bg: #ECFDF5;
  --warning: #D97706;
  --warning-bg: #FFFBEB;
  --danger: #DC2626;
  --danger-bg: #FEF2F2;
  --info: #0E7490;
  --info-bg: #ECFEFF;
  --purple: #7C3AED;
  --purple-bg: #F5F3FF;

  --row-alt: #F9FAFB;
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, .10);
  --shadow-lg: 0 20px 48px rgba(16, 24, 40, .18);

  --sidebar-w: 236px;
  --topbar-h: 64px;
}

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

html, body { height: 100%; }

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

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* 保留可见焦点环，满足键盘可达性 */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #D8DBE0; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #C3C7CE; background-clip: content-box; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ==========================  布局  ========================== */
.layout { display: flex; min-height: 100dvh; }

/* ----------  侧边栏  ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 14px;
  position: sticky;
  top: 0;
  height: 100dvh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px; background: var(--primary);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.brand .name { font-size: 17px; font-weight: 700; line-height: 1.2; }
.brand .sub { font-size: 11px; color: var(--sidebar-muted); margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); }
.nav-label {
  font-size: 11px; color: var(--sidebar-muted);
  padding: 14px 12px 6px; letter-spacing: .04em;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-muted);
  cursor: pointer; user-select: none;
  border: none; background: none; width: 100%; text-align: left;
  transition: background .15s, color .15s;
  font-size: 14px;
}
.nav-item svg { flex-shrink: 0; }
.nav-item .ico { color: currentColor; }
.nav-item:hover { color: var(--sidebar-text); background: rgba(255,255,255,.05); }
.nav-item.active { background: rgba(37, 99, 235, .22); color: #fff; font-weight: 600; }
.nav-item .count {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,.12); color: var(--sidebar-text);
  padding: 1px 7px; border-radius: 10px;
}
.nav-item.active .count { background: rgba(255,255,255,.22); }
.nav-sub { padding-left: 30px; font-size: 13px; }

/* 独立顶层模块：略强于普通项，突出为一级入口 */
.nav-item.nav-standalone {
  font-weight: 500; color: var(--sidebar-text);
}
.nav-item.nav-standalone:hover { color: #fff; }

/* 独立项与分组之间的视觉分隔 */
.nav-sep {
  height: 1px; margin: 6px 12px;
  background: linear-gradient(to right, transparent, rgba(255,255,255,.12), transparent);
}

/* ---------- 分组导航（悬停展开子模块） ---------- */
.nav-group {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
  transition: background .15s, color .15s; font-size: 14px; font-weight: 500;
  position: relative; user-select: none;
}
.nav-group:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-group.active { background: rgba(37, 99, 235, .22); color: #fff; }
.nav-group svg:first-child { flex-shrink: 0; opacity: .9; }
.nav-group .nav-arrow {
  margin-left: auto; width: 16px; height: 16px; flex-shrink: 0;
  opacity: .4; transition: transform .2s, opacity .2s;
}
.nav-group:hover .nav-arrow { opacity: .7; transform: translateX(2px); }

/* ---- 弹出面板 ---- */
.nav-popover-wrap {
  position: fixed; z-index: 800;
  animation: navPopIn .15s ease-out;
}
@keyframes navPopIn { from{opacity:0;transform:translateX(-6px)} to{opacity:1;transform:translateX(0)} }

.nav-popover {
  background: #1E293B; color: #E3E9F0;
  border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.06);
  min-width: 280px; max-width: 420px; overflow: hidden;
}
.nav-popover-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px 8px; font-size: 12px; font-weight: 600;
  color: var(--sidebar-muted); letter-spacing: .03em;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.nav-popover-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 8px;
}

.nav-popover-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
  color: var(--sidebar-muted); font-size: 13px; transition: all .12s;
  user-select: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-popover-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-popover-item.active { background: rgba(37,99,235,.25); color: #fff; font-weight: 600; }
.nav-popover-item svg { flex-shrink: 0; opacity: .7; }
.nav-popover-item.active svg { opacity: 1; }
.nav-popover-item .count {
  margin-left: auto; font-size: 10px; font-weight: 600;
  background: rgba(255,255,255,.1); color: var(--sidebar-muted);
  padding: 1px 6px; border-radius: 8px; flex-shrink: 0;
}
.nav-popover-item.active .count { background: rgba(255,255,255,.18); color: #fff; }

/* 内联子项（移动端手风琴展开用） */
.nav-group-children { display: none; }
.nav-group.expanded .nav-arrow { transform: rotate(90deg); }

.user-mini {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 10px; margin-top: 10px;
  background: rgba(255, 255, 255, 0.06);
}
.user-mini .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: #fff;
}
.user-mini .uname { font-size: 13px; font-weight: 600; }
.user-mini .urole { font-size: 11px; color: var(--sidebar-muted); margin-top: 1px; }

/* ----------  主区  ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h); background: var(--surface);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.topbar .title { font-size: 18px; font-weight: 700; line-height: 1.2; }
.topbar .breadcrumb { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.menu-toggle { display: none; }

.role-switch {
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 10px 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 13px; color: var(--text-secondary);
}
.role-switch select { border: none; outline: none; background: transparent; font-weight: 600; color: var(--text-primary); cursor: pointer; }

.icon-btn {
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative;
  background: var(--surface); border: 1px solid var(--border);
}
.icon-btn:hover { background: #F3F4F6; }
.bell-dot {
  position: absolute; top: 7px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); border: 2px solid var(--surface);
}
.avatar-btn {
  width: 38px; height: 38px; border-radius: 50%; background: var(--primary);
  border: none; cursor: pointer; color: #fff; font-weight: 600; font-size: 13px;
}

.content { padding: 24px; display: flex; flex-direction: column; gap: 18px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 17px; font-weight: 700; }
.page-head .desc { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }

/* ==========================  通用元素  ========================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 14px;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 14px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-primary);
  transition: background .15s, border-color .15s, opacity .15s; white-space: nowrap;
}
.btn:hover { background: #F3F4F6; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn.ghost:hover { background: #F3F4F6; color: var(--text-primary); }
.btn.danger { color: var(--danger); border-color: #F3C9C9; background: var(--danger-bg); }
.btn.danger:hover { background: #FDE7E7; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--surface); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge.gray { background: #F3F4F6; color: var(--text-secondary); }
.badge.green { background: var(--success-bg); color: var(--success); }
.badge.orange { background: var(--warning-bg); color: var(--warning); }
.badge.red { background: var(--danger-bg); color: var(--danger); }
.badge.blue { background: var(--primary-soft); color: var(--primary); }
.badge.cyan { background: var(--info-bg); color: var(--info); }
.badge.purple { background: var(--purple-bg); color: var(--purple); }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 8px 0 10px; border-radius: 13px;
  background: var(--primary-soft); color: var(--primary);
  font-size: 12px; font-weight: 600;
}
.chip button { border: none; background: none; cursor: pointer; color: inherit; line-height: 1; font-size: 14px; }

.link { color: var(--primary); cursor: pointer; background: none; border: none; padding: 0; font-size: 13px; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--danger); }
.muted { color: var(--text-secondary); }
.num-cell { font-variant-numeric: tabular-nums; font-weight: 600; }
.text-right { text-align: right; }
.money-in { color: var(--danger); font-weight: 600; }   /* 收入 · 中式红涨 */
.money-out { color: var(--success); font-weight: 600; } /* 支出 · 中式绿跌 */

/* ==========================  统计卡  ========================== */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stats.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 8px;
}
.stat .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat .label { font-size: 13px; color: var(--text-secondary); }
.stat .num { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .num small { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-left: 3px; }
.stat .delta { font-size: 12px; color: var(--text-secondary); }
.delta.up { color: var(--danger); }     /* 上升用红（国内习惯） */
.delta.down { color: var(--success); }
.delta.warn { color: var(--warning); }
.stat .ico-wrap {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ==========================  面板 / 卡片  ========================== */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.panel-head h3 { font-size: 15px; font-weight: 700; }
.panel-head .sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.panel-body { padding: 18px; }
.grid-2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 18px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px; align-items: start; }

/* ==========================  筛选栏  ========================== */
.filters {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.filter-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 12px; color: var(--text-secondary); }
.field.grow { flex: 1; min-width: 200px; }

.input, .select {
  height: 38px; padding: 0 11px; min-width: 132px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); outline: none; color: var(--text-primary);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.input::placeholder { color: var(--text-tertiary); }
textarea.input { height: auto; padding: 9px 11px; resize: vertical; min-height: 76px; }
.select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 9px center; padding-right: 30px;
}
.search-field { position: relative; display: flex; align-items: center; }
.search-field svg { position: absolute; left: 11px; pointer-events: none; }
.search-field .input { padding-left: 34px; width: 100%; }

.date-range { display: flex; align-items: center; gap: 6px; }
.date-range .input { min-width: 138px; }
.date-range span { color: var(--text-tertiary); }

.filter-actions { display: flex; gap: 8px; margin-left: auto; }
.active-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); }

/* ==========================  工具条  ========================== */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; background: #EDEEF2; padding: 4px; border-radius: 10px; flex-wrap: wrap; }
.tab {
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
  color: var(--text-secondary); border: none; background: none; transition: all .15s; white-space: nowrap;
}
.tab:hover { color: var(--text-primary); }
.tab.active { background: var(--surface); color: var(--text-primary); font-weight: 600; box-shadow: var(--shadow-sm); }
.tab .n { font-variant-numeric: tabular-nums; opacity: .7; margin-left: 3px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* 下拉菜单（导出等） */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40;
  min-width: 208px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 6px; display: none;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 9px 10px; border: none; background: none; cursor: pointer;
  border-radius: var(--radius-sm); font-size: 13px; text-align: left;
}
.dropdown-menu button:hover { background: var(--surface-2); }
.dropdown-menu .sep { height: 1px; background: var(--border); margin: 5px 4px; }
.dropdown-menu .hint { padding: 6px 10px 4px; font-size: 11px; color: var(--text-tertiary); }

/* ==========================  数据表格  ========================== */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table.dt { width: 100%; border-collapse: collapse; }
table.dt th, table.dt td { padding: 12px 14px; text-align: left; white-space: nowrap; }
table.dt thead th {
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  background: var(--surface-2); border-bottom: 1px solid var(--border); user-select: none;
}
table.dt thead th.sortable { cursor: pointer; }
table.dt thead th.sortable:hover { color: var(--text-primary); }
table.dt thead th .th-in { display: inline-flex; align-items: center; gap: 5px; }
.sort-ico { opacity: .35; transition: opacity .15s; }
th.sorted .sort-ico { opacity: 1; color: var(--primary); }
table.dt tbody tr { border-bottom: 1px solid var(--border); transition: background .12s; }
table.dt tbody tr:last-child { border-bottom: none; }
table.dt tbody tr:nth-child(even) { background: var(--row-alt); }
table.dt tbody tr:hover { background: #F0F4FB; }
table.dt tbody tr.selected { background: var(--primary-soft); }
table.dt td.wrap { white-space: normal; min-width: 200px; }
table.dt td .sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
table.dt .col-check, table.dt th.col-check { width: 42px; padding-right: 0; }
table.dt .col-ops { text-align: right; }
.ops { display: inline-flex; gap: 12px; justify-content: flex-end; }

input[type="checkbox"].cb {
  width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; margin: 0; vertical-align: middle;
}

.table-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-top: 1px solid var(--border);
  font-size: 13px; color: var(--text-secondary); flex-wrap: wrap;
}
.pager { display: flex; align-items: center; gap: 6px; }
.page-btn, .page-num {
  height: 32px; min-width: 32px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font-size: 13px; color: var(--text-primary);
}
.page-btn { color: var(--text-secondary); }
.page-btn:hover:not(:disabled), .page-num:hover { background: #F3F4F6; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-num.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.page-dot { color: var(--text-tertiary); padding: 0 2px; }
.page-size { display: flex; align-items: center; gap: 6px; }
.page-size select { height: 32px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); padding: 0 6px; cursor: pointer; }

.bulkbar {
  display: none; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--primary-soft);
  border-bottom: 1px solid #DBE7FE; font-size: 13px; color: var(--primary);
}
.bulkbar.show { display: flex; }
.bulkbar .spacer { flex: 1; }

.empty { padding: 52px 20px; text-align: center; color: var(--text-secondary); }
.empty svg { margin-bottom: 12px; }
.empty .t { font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }

/* ==========================  弹窗 / 抽屉  ========================== */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 41, .45);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 24px;
}
.overlay.show { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  width: min(720px, 100%); max-height: min(82dvh, 760px);
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg); overflow: hidden;
  animation: pop .16s ease-out;
}
.modal.narrow { width: min(460px, 100%); }
.modal.wide { width: min(980px, 100%); }
@keyframes pop { from { transform: translateY(8px) scale(.985); opacity: 0; } }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-head .sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1 1 0%; min-height: 0; overscroll-behavior: contain; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.close-x { border: none; background: none; cursor: pointer; width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); }
.close-x:hover { background: #F3F4F6; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid .field { gap: 6px; }
.form-grid .field.full { grid-column: 1 / -1; }
.field .req { color: var(--danger); margin-left: 2px; }
.field .err { font-size: 12px; color: var(--danger); display: none; }
.field.invalid .err { display: block; }
.field.invalid .input, .field.invalid .select { border-color: var(--danger); }
.form-note { font-size: 12px; color: var(--text-secondary); margin-top: 12px; }

/* 详情视图 */
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 2px 24px; }
.detail-item { padding: 10px 0; border-bottom: 1px dashed var(--border); }
.detail-item .k { font-size: 12px; color: var(--text-secondary); }
.detail-item .v { font-size: 14px; margin-top: 3px; word-break: break-all; }
.detail-item.full { grid-column: 1 / -1; }

/* ==========================  Toast  ========================== */
.toasts { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 250px; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow-md);
  animation: slidein .2s ease-out; font-size: 13px;
}
@keyframes slidein { from { transform: translateX(16px); opacity: 0; } }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warning); }
.toast .t { font-weight: 600; }
.toast .m { color: var(--text-secondary); margin-top: 1px; }

/* ==========================  工作台专用  ========================== */
.chart-wrap { width: 100%; overflow: hidden; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); }
.legend .li { display: flex; align-items: center; gap: 6px; }

.todo-list { display: flex; flex-direction: column; }
.todo {
  display: flex; gap: 12px; padding: 13px 0; border-bottom: 1px dashed var(--border);
}
.todo:last-child { border-bottom: none; }
.todo .ic { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.todo .t { font-size: 13px; font-weight: 600; }
.todo .d { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.todo .when { margin-left: auto; font-size: 12px; white-space: nowrap; }

.rank-list { display: flex; flex-direction: column; gap: 13px; }
.rank { display: flex; align-items: center; gap: 11px; }
.rank .idx {
  width: 22px; height: 22px; border-radius: 6px; background: var(--surface-2);
  color: var(--text-secondary); font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.rank .idx.top { background: var(--primary); color: #fff; }
.rank .body { flex: 1; min-width: 0; }
.rank .n { font-size: 13px; display: flex; justify-content: space-between; gap: 10px; }
.rank .bar { height: 6px; border-radius: 3px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.rank .bar i { display: block; height: 100%; border-radius: 3px; background: var(--primary); }

.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.quick {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
  display: flex; align-items: center; gap: 11px; cursor: pointer; background: var(--surface);
  text-align: left; transition: border-color .15s, background .15s;
}
.quick:hover { border-color: var(--primary); background: var(--primary-soft); }
.quick .ic { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.quick .t { font-size: 13px; font-weight: 600; }
.quick .d { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

/* ==========================  权限矩阵  ========================== */
.perm-table { width: 100%; border-collapse: collapse; }
.perm-table th, .perm-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.perm-table thead th { background: var(--surface-2); font-size: 12px; color: var(--text-secondary); font-weight: 600; text-align: center; }
.perm-table thead th:first-child { text-align: left; }
.perm-table td { text-align: center; }
.perm-table td:first-child { text-align: left; font-weight: 600; }
.perm-table tbody tr:hover { background: var(--surface-2); }
.perm-table .mod-desc { font-size: 11px; color: var(--text-secondary); font-weight: 400; margin-top: 2px; }

.role-list { display: flex; flex-direction: column; gap: 8px; }
.role-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; background: var(--surface); text-align: left; width: 100%;
}
.role-item:hover { border-color: var(--primary); }
.role-item.active { border-color: var(--primary); background: var(--primary-soft); }
.role-item .rn { font-size: 13px; font-weight: 600; }
.role-item .rd { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.role-item .rc { margin-left: auto; font-size: 11px; color: var(--text-secondary); }

.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.switch .track {
  width: 38px; height: 22px; border-radius: 11px; background: #D5D7DC;
  transition: background .15s; position: relative; flex-shrink: 0;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: transform .15s; box-shadow: var(--shadow-sm);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }

.no-perm { padding: 60px 24px; text-align: center; }
.no-perm .t { font-size: 16px; font-weight: 700; margin: 12px 0 6px; }
.no-perm .d { font-size: 13px; color: var(--text-secondary); }

/* ==========================  响应式  ========================== */
@media (max-width: 1280px) {
  .stats, .stats.five { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 90;
    transform: translateX(-100%); transition: transform .2s ease-out;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(15,23,41,.4); z-index: 80; display: none; }
  .scrim.show { display: block; }
  .menu-toggle { display: flex; }
  /* 移动端：内联子项可见，隐藏箭头（改用手风琴） */
  .nav-group-children { display: block; padding-left: 20px; border-left: 2px solid rgba(255,255,255,.06); margin-left: 14px; margin-bottom: 4px; }
  .nav-group-children .nav-item { font-size: 13px; padding: 7px 10px; }
  .nav-popover-wrap { display: none !important; } /* 移动端禁用悬浮面板 */
  .stats, .stats.five, .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .content { padding: 16px; }
  .topbar { padding: 0 14px; }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .filter-actions { margin-left: 0; width: 100%; }
  .field.grow { min-width: 100%; }
}
@media (max-width: 560px) {
  .stats, .stats.five, .grid-3, .quick-grid { grid-template-columns: 1fr; }
  .topbar .title { font-size: 16px; }
  .role-switch { display: none; }
}

@media print {
  .sidebar, .topbar, .filters, .toolbar, .table-foot, .bulkbar { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
}

/* 多选筛选器（如合同「剩余月份」1~24 期） */
.multi-dd .btn { display: inline-flex; align-items: center; gap: 5px; }
.multi-dd .m-sel { font-weight: 700; color: #2563EB; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multi-menu { left: 0; right: auto; min-width: 180px; max-height: 320px; overflow: auto; }
.multi-opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.multi-opt:hover { background: var(--surface-2); }
.multi-opt input { cursor: pointer; margin: 0; }

