/* ===== 基础 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f4f6fa; --card: #fff; --line: #e3e8f0; --txt: #1c2333;
  --muted: #6b7590; --brand: #3565e0; --brand-d: #2449ab;
  --green: #0e9f6e; --red: #e02424; --amber: #d97706;
  --radius: 12px;
  --shadow-1: 0 1px 2px rgba(16,22,38,.05), 0 6px 20px -8px rgba(16,22,38,.10);
  --shadow-2: 0 2px 6px rgba(16,22,38,.08), 0 16px 40px -16px rgba(16,22,38,.18);
}
body { font: 14px/1.55 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
       background: linear-gradient(180deg, #f7f9fd 0%, #edf1f8 100%);
       color: var(--txt); min-height: 100vh; }
a { color: var(--brand); text-decoration: none; }
table { border-collapse: collapse; width: 100%; background: var(--card); }
th, td { padding: 9px 12px; border-bottom: 1px solid #edf0f6;
         text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 650; font-size: 11px;
     text-transform: uppercase; letter-spacing: .05em; background: #fafbfd; }
td { transition: background .12s ease; }
tr:hover td { background: #f7f9fd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.loading { padding: 80px; text-align: center; color: var(--muted); }

/* ===== 左右布局 ===== */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #101626; color: #cdd6ea; flex-shrink: 0;
           display: flex; flex-direction: column; position: sticky; top: 0;
           height: 100vh; transition: width .18s ease; overflow: hidden; }
.sidebar-brand { padding: 18px 14px 14px; font-size: 17px; color: #fff;
                 border-bottom: 1px solid #1d2740; display: flex;
                 align-items: center; gap: 8px; white-space: nowrap; }
.brand-ico { font-size: 18px; }
.sb-toggle { margin-left: auto; background: #1d2740; color: #8fa0c5;
             border: none; border-radius: 6px; width: 26px; height: 26px;
             cursor: pointer; font-size: 14px; line-height: 1; flex-shrink: 0; }
.sb-toggle:hover { background: #2a3757; color: #fff; }
.ico { flex-shrink: 0; }

/* 收起状态: 仅图标 */
.layout.collapsed .sidebar { width: 64px; }
.layout.collapsed .nav-label { display: none; }
.layout.collapsed .sidebar-brand { justify-content: center; padding: 18px 4px 14px; }
.layout.collapsed .sb-toggle { margin-left: 0; }
.layout.collapsed .sidebar-nav a { justify-content: center; padding: 10px 0; }
.layout.collapsed .nav-sep { visibility: hidden; height: 6px; padding: 0; }
.layout.collapsed .sidebar-user { text-align: center; }
.layout.collapsed .u-row { justify-content: center; margin-bottom: 6px; }
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex;
               flex-direction: column; gap: 2px; }
.sidebar-nav a { color: #b8c2d9; padding: 10px 14px; border-radius: 8px;
                 font-size: 14px; display: flex; align-items: center;
                 gap: 10px; }
.sidebar-nav a:hover { background: #1d2740; color: #fff; }
.sidebar-nav a.active { background: var(--brand); color: #fff; }
.sidebar-nav .nav-sep { font-size: 11px; color: #5c6a8a; padding: 14px 14px 4px;
                         text-transform: uppercase; letter-spacing: .06em; }
.sidebar-user { padding: 14px 16px; border-top: 1px solid #1d2740;
                font-size: 13px; }
.sidebar-user .u-row { display: flex; align-items: center; gap: 8px;
                       margin-bottom: 8px; }
.sidebar-user a { color: #8fa0c5; font-size: 12px; }
.main { flex: 1; min-width: 0; }
@media (max-width: 768px) {
  .layout, .layout.collapsed { flex-direction: column; }
  .sidebar, .layout.collapsed .sidebar { width: 100%; height: auto;
                                         position: static; }
  .layout.collapsed .nav-label { display: inline; }
  .layout.collapsed .sidebar-nav a { justify-content: flex-start;
                                     padding: 10px 14px; }
  .sb-toggle { display: none; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-nav .nav-sep { display: none; }
  .sidebar-user { display: flex; justify-content: space-between;
                  align-items: center; }
  .sidebar-user .u-row { margin-bottom: 0; }
}

/* ===== 旧导航(兼容登录页) ===== */
.container { max-width: 1280px; margin: 20px auto; padding: 0 22px; }
.grid { display: grid; gap: 16px; }
.cards-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .cards-4 { grid-template-columns: repeat(2, 1fr); } }
.card { background: var(--card); border: 1px solid #edf0f6;
        border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-1); }
.card h3 { font-size: 13px; color: var(--muted); font-weight: 600;
           margin-bottom: 6px; }
.big { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin: 0 0 14px;
           flex-wrap: wrap; }
.toolbar h2 { font-size: 18px; margin-right: auto; }
.toolbar select { max-width: 170px; }
.toolbar input[type="search"] { width: 175px; }
input, select { padding: 7px 10px; border: 1px solid var(--line);
                border-radius: 7px; font-size: 13px; background: #fff; }
input[type=date] { color: var(--muted); }
.btn { padding: 7px 14px; border: none; border-radius: 7px; font-size: 13px;
       cursor: pointer; background: #eef1f7; color: var(--txt); }
.btn:hover { filter: brightness(.96); }
.btn-primary { background: linear-gradient(135deg, #3b6ef0, #2a55cc); color: #fff;
                box-shadow: 0 2px 10px -2px rgba(53,101,224,.55); }
.btn-primary:hover { background: linear-gradient(135deg, #4a7af5, #3560dd); }
.btn { transition: all .15s ease; }
.btn-danger { background: #fdeaea; color: var(--red); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 10px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px;
         font-size: 12px; font-weight: 600; }
.badge-admin { background: #312e81; color: #c7d2fe; }
.badge-op { background: #ecfdf5; color: var(--green); }
.badge-gray { background: #f1f3f9; color: var(--muted); }
.pos { color: var(--green); } .neg { color: var(--red); }
.warn-box { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
            padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.section-title { font-size: 15px; font-weight: 700; margin: 20px 0 10px; }

/* ===== 登录 ===== */
.login-body { display: flex; align-items: center; justify-content: center;
              min-height: 100vh; background: linear-gradient(135deg,#101626,#1d2740); }
.login-card { background: #fff; border-radius: 14px; padding: 34px;
              width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card h2 { margin-bottom: 18px; text-align: center; }
.login-card label { display: block; font-size: 12px; color: var(--muted);
                    margin: 12px 0 4px; }
.login-card input { width: 100%; padding: 10px 12px; }
.login-card .btn { width: 100%; margin-top: 18px; padding: 10px; }
.login-error { color: var(--red); font-size: 13px; margin-top: 10px;
               text-align: center; }

/* ===== 看板现代组件 ===== */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; }
.chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12px;
        color: var(--txt); background: var(--card); border: 1px solid var(--line);
        border-radius: 999px; padding: 6px 13px; box-shadow: var(--shadow-1); }
.chip b { font-variant-numeric: tabular-nums; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.fb { background: #1877f2; box-shadow: 0 0 0 3px rgba(24,119,242,.16); }
.dot.vc { background: #0e9f6e; box-shadow: 0 0 0 3px rgba(14,159,110,.16); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
         gap: 14px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid #edf0f6; border-radius: var(--radius);
        padding: 14px 18px 13px; box-shadow: var(--shadow-1);
        position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0;
                width: 3px; background: linear-gradient(180deg, #3b6ef0, #7aa2f7); }
.s-label { font-size: 11px; color: var(--muted); font-weight: 650;
           text-transform: uppercase; letter-spacing: .05em; }
.s-val { font-size: 25px; font-weight: 750; margin-top: 5px;
         font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.s-sub { font-size: 12px; color: var(--muted); margin-top: 4px;
         display: flex; gap: 8px; align-items: center; min-height: 18px; }
.delta { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.delta.pos { color: #0b7a55; background: rgba(14,159,110,.10); }
.delta.neg { color: #b91c1c; background: rgba(224,36,36,.09); }
.delta.neutral { color: var(--muted); background: #eef1f7; }

.seg { display: inline-flex; background: #e8ecf4; border-radius: 9px;
       padding: 3px; gap: 2px; }
.seg .btn { background: transparent; box-shadow: none; border-radius: 7px; }
.seg .btn.active { background: #fff; color: var(--brand); font-weight: 700;
                   box-shadow: 0 1px 5px rgba(16,22,38,.14); }

.table-card { padding: 0; overflow: hidden; }
.table-scroll { max-height: 64vh; overflow: auto; }
table.modern thead th { position: sticky; top: 0; z-index: 2;
                        background: rgba(250,251,253,.96); backdrop-filter: blur(6px);
                        box-shadow: 0 1px 0 var(--line); }
.cname { display: flex; align-items: center; gap: 10px; }
.avatar { width: 31px; height: 31px; border-radius: 9px; display: inline-flex;
          align-items: center; justify-content: center; font-weight: 750;
          font-size: 13px; flex-shrink: 0; }
.muted-num { color: var(--muted); }
.pwrap { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.pbar { display: block; width: 92px; height: 3px; border-radius: 2px;
        background: #edf0f6; overflow: hidden; }
.pbar i { display: block; height: 100%; border-radius: 2px; }
.pbar i.pos { background: linear-gradient(90deg, #12b981, #0e9f6e); }
.pbar i.neg { background: linear-gradient(90deg, #f04438, #e02424); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px;
        font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pill.pos { color: #0b7a55; background: rgba(14,159,110,.12); }
.pill.neg { color: #b91c1c; background: rgba(224,36,36,.10); }
.cell-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* 未归因行淡显 (保留展示, 不计入汇总) */
tr.unattr td { color: var(--muted); }
tr.unattr .avatar { filter: grayscale(.65); opacity: .75; }

/* ===== 系列明细弹窗 ===== */
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f5f8ff; }
.modal-overlay { position: fixed; inset: 0; background: rgba(13,18,32,.45);
                 backdrop-filter: blur(3px); display: flex; align-items: center;
                 justify-content: center; z-index: 100; padding: 24px; }
.modal { background: var(--card); border-radius: 14px; box-shadow: var(--shadow-2);
         width: min(860px, 100%); max-height: 84vh; display: flex;
         flex-direction: column; overflow: hidden;
         animation: pop .18s ease; }
@keyframes pop { from { transform: translateY(12px) scale(.98); opacity: 0; } }
.m-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px 12px;
          border-bottom: 1px solid var(--line); }
.m-head > div { flex: 1; min-width: 0; }
.m-head b { font-size: 15px; }
.m-sub { padding: 10px 20px 0; font-size: 12px; color: var(--muted); }
#m-body { padding: 12px 20px 16px; overflow: auto; }

/* ===== 表格合计行 ===== */
tr.totals td { background: linear-gradient(180deg, #f8fafd, #f0f4fb);
                border-top: 2px solid var(--brand); font-weight: 650; }
.form-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap;
            margin-bottom: 14px; }
.form-row > div { flex: 1; min-width: 130px; }
.form-row input, .form-row select { width: 100%; }
.form-row > .btn { flex-shrink: 0; white-space: nowrap; }
.form-row label { display: block; font-size: 12px; color: var(--muted);
                  margin-bottom: 3px; }

/* inline result notices (mapping discover/apply) */
.flash { background: #f0fdf5; border: 1px solid #bfe8d5; color: #0b7a55;
         border-radius: 10px; padding: 10px 14px; font-size: 13px; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }

/* ===== 系统设置页 & Toast ===== */
.cards-3 { grid-template-columns: repeat(3, 1fr); margin-bottom: 18px; }
@media (max-width: 900px) { .cards-3 { grid-template-columns: 1fr; } }
.sys-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 6px; }

/* 系统设置: 统一的 设置行 (label / 控件 / 说明) 与卡片底部操作区 */
.setting { margin-bottom: 14px; }
.setting label { display: block; font-size: 12px; color: var(--muted);
                 font-weight: 600; margin-bottom: 4px; }
.setting input, .setting select { width: 100%; }
.setting .hint { margin-top: 4px; }
.card-actions { display: flex; justify-content: flex-end; gap: 10px;
                margin-top: 4px; }
.setting-hint { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.setting-hint code { cursor: copy; }
@media (max-width: 900px) { .sys-2col { grid-template-columns: 1fr; } }
.sys-2col .card h3 { display: flex; align-items: center; gap: 8px; }
.out-pre { background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; overflow-x: auto; font-size: 12px; color: var(--muted);
  white-space: pre-wrap; margin: 0; }
#toasts { position: fixed; top: 16px; right: 16px; z-index: 1000; display: flex;
  flex-direction: column; gap: 8px; max-width: 380px; }
.toast { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; font-size: 13px; box-shadow: 0 8px 24px rgba(16,22,38,.14);
  animation: pp .25s ease; }
.toast.ok { border-color: #bfe8d5; background: #f0fdf5; color: #0b7a55; }
.toast.err { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }

/* ===== 刷新交互 ===== */
.spin-ico { display: inline-block; }
.btn.loading-btn { opacity: .75; }
.btn.loading-btn .spin-ico { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#table { transition: opacity .18s; }
#table.reloading { opacity: .5; }

/* 数据过期 chip (防漏跑可见性) */
.chip.stale-chip { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }

/* ===== 用户管理 ===== */
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.acct-link { color: var(--brand); font-weight: 600; cursor: pointer; }
.acct-link:hover { text-decoration: underline; }
.cell-click { cursor: pointer; max-width: 360px; overflow: hidden;
              text-overflow: ellipsis; white-space: nowrap; }
.cell-click:hover { color: var(--brand); text-decoration: underline; }

/* ---- 绑定页: 待办双卡片 + 分组表头 (v22) ---- */
.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:14px;
  align-items:start; margin-bottom:16px; }
@media (max-width:1100px) { .grid-2 { grid-template-columns:1fr; } }
.act-card { background:var(--card); border:1px solid var(--line);
  border-radius:var(--radius); box-shadow:var(--shadow-1); padding:14px 16px; }
.act-card h3 { margin:0 0 2px; font-size:14px; display:flex;
  align-items:center; gap:8px; }
.act-card h3 .pill { margin-left:auto; }
.act-row { display:flex; align-items:center; gap:10px; padding:9px 0; }
.act-row + .act-row { border-top:1px dashed var(--line); }
.act-row select { max-width:130px; }
table.modern tr.grp-head td { background:#f8fafd; padding:8px 12px; }
table.modern tr.grp-head .avatar { width:22px; height:22px;
  font-size:11px; margin-right:8px; flex:none; }

/* ---- 绑定页 v23: 面板统一 + 待办卡片自适应 ---- */
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); }
.act-card.warn { border-left: 3px solid var(--amber); }
.act-card.info { border-left: 3px solid var(--brand); }
.act-h { display: flex; align-items: center; gap: 8px; font-size: 14px;
  font-weight: 600; margin: 0 0 2px; }
.act-h .pill { margin-left: auto; }
.panel-h { display: flex; align-items: center; gap: 10px; padding: 11px 16px;
  border-bottom: 1px solid var(--line); background: #fafbfd; flex-wrap: wrap; }
.panel-h h3 { margin: 0; color: var(--txt); font-size: 14px; font-weight: 600; }
.panel-h .h-meta { color: var(--muted); font-size: 12px; }
.panel-h .h-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ---- 导入账户弹窗 (v24) ---- */
.imp-item { display:flex; align-items:center; gap:10px; padding:9px 10px;
  border-radius:8px; cursor:pointer; font-size:13px; }
.imp-item:hover { background:#f5f7fb; }
.imp-item + .imp-item { border-top:1px dashed var(--line); }

/* ---- 死绑定/封禁行高亮 (v29) ---- */
table.modern tr.row-alert td { background: #fff6f4; }
table.modern tr.row-alert:hover td { background: #fdeeed; }
