:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --sidebar: #101826;
  --sidebar-soft: #172233;
  --text: #172033;
  --muted: #718096;
  --line: #e5e9f0;
  --accent: #1967d2;
  --accent-dark: #1255b4;
  --success: #0f8a5f;
  --warning: #b26a00;
  --danger: #c33737;
  --shadow: 0 10px 30px rgba(18, 31, 53, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  font-size: 14px;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--sidebar), #0b1320);
  color: #dce6f4;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #3b82f6, #174ea6);
  font-weight: 800; letter-spacing: .04em;
}
.brand strong { display: block; font-size: 15px; }
.brand span { display: block; color: #8fa1ba; font-size: 11px; margin-top: 4px; }
.nav { display: grid; gap: 6px; }
.nav-item {
  border: 0; border-radius: 11px; background: transparent; color: #aebbd0;
  text-align: left; padding: 11px 12px; display: flex; align-items: center; gap: 10px;
}
.nav-item span { width: 20px; text-align: center; opacity: .85; }
.nav-item:hover { background: var(--sidebar-soft); color: #fff; }
.nav-item.active { background: #1d4f95; color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.09); }
.sidebar-rule { margin-top: auto; background: rgba(255,255,255,.055); padding: 14px; border-radius: 13px; }
.sidebar-rule span, .sidebar-rule small { display: block; color: #8fa1ba; font-size: 11px; }
.sidebar-rule strong { display: block; margin: 5px 0; color: #f5f8ff; font-size: 13px; }

.main { min-width: 0; }
.topbar {
  min-height: 92px; padding: 20px 30px; display: flex; align-items: center; justify-content: space-between;
  gap: 20px; background: rgba(255,255,255,.84); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
  backdrop-filter: blur(16px);
}
h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.topbar p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.sync-badge { border: 1px solid #dbe4f0; color: #53627a; background: #fff; border-radius: 999px; padding: 7px 11px; font-size: 12px; }
.view { padding: 24px 30px 48px; }

.button {
  border: 1px solid #d8dee9; border-radius: 10px; background: #fff; color: #25324a;
  padding: 9px 14px; font-weight: 650; transition: .15s ease;
}
.button:hover { border-color: #b8c3d4; transform: translateY(-1px); }
.button.primary { background: var(--accent); border-color: var(--accent); color: white; }
.button.primary:hover { background: var(--accent-dark); }
.button.danger { background: #fff4f4; border-color: #f0c6c6; color: var(--danger); }
.button.success { background: #edf9f4; border-color: #b9e4d3; color: var(--success); }
.button.ghost { background: transparent; }
.button.small { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.icon-button { border: 0; background: transparent; font-size: 24px; color: #7b8799; line-height: 1; }

.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px; }
.metric-card { padding: 18px; min-height: 118px; display: flex; flex-direction: column; justify-content: space-between; }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { font-size: 28px; font-weight: 800; letter-spacing: -.04em; }
.metric-note { color: var(--muted); font-size: 12px; }
.section-title { display: flex; justify-content: space-between; align-items: flex-end; margin: 24px 0 12px; gap: 12px; }
.section-title h2 { margin: 0; font-size: 17px; }
.section-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid #edf0f5; vertical-align: middle; }
th { color: #69778d; background: #fafbfc; font-size: 12px; font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcff; }
.cell-main { font-weight: 700; }
.cell-sub { display: block; color: var(--muted); margin-top: 3px; font-size: 12px; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge.green { background: #eaf8f1; color: #087a52; }
.badge.blue { background: #eaf2ff; color: #1a5fbf; }
.badge.orange { background: #fff4df; color: #9a5d00; }
.badge.red { background: #fff0f0; color: #b83333; }
.badge.gray { background: #eff2f6; color: #607089; }
.badge.purple { background: #f1edff; color: #6543bd; }

.empty { padding: 42px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: #3a475c; margin-bottom: 6px; }
.rule-list { display: grid; gap: 10px; }
.rule-item { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: #f7f9fc; }
.rule-item span { flex: 0 0 auto; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 7px; background: #e6efff; color: var(--accent); font-weight: 800; }
.rule-item p { margin: 1px 0 0; line-height: 1.55; }

.modal { border: 0; padding: 0; background: transparent; width: min(680px, calc(100vw - 30px)); max-height: calc(100vh - 30px); }
.modal::backdrop { background: rgba(6, 14, 28, .55); backdrop-filter: blur(3px); }
.modal-card { margin: 0; background: #fff; border-radius: 18px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.28); }
.modal-head { padding: 20px 22px; display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.modal-body { padding: 20px 22px; max-height: min(64vh, 640px); overflow: auto; }
.modal-actions { padding: 14px 22px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; color: #58667b; font-weight: 700; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid #d9e0ea; border-radius: 10px; padding: 10px 11px; background: #fff; color: var(--text);
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: #7eacf2; box-shadow: 0 0 0 3px rgba(25,103,210,.1); }
.field small { color: var(--muted); line-height: 1.4; }
.checkbox-line { display: flex; gap: 9px; align-items: flex-start; padding: 10px 11px; background: #f7f9fc; border-radius: 10px; }
.checkbox-line input { width: auto; margin-top: 2px; }
.checkbox-line strong { display: block; font-size: 13px; }
.checkbox-line small { color: var(--muted); }

.toast {
  position: fixed; right: 24px; bottom: 24px; max-width: 380px; z-index: 100;
  background: #172033; color: #fff; border-radius: 12px; padding: 12px 15px; box-shadow: 0 16px 40px rgba(0,0,0,.25);
  opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #8f2929; }
.notice { border-radius: 12px; background: #eef4ff; color: #244e8f; padding: 12px 14px; line-height: 1.6; font-size: 12px; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { border: 1px solid #d9e0ea; border-radius: 10px; padding: 9px 11px; background: #fff; }

@media (max-width: 1040px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 14px; }
  .nav { display: flex; overflow-x: auto; }
  .nav-item { white-space: nowrap; }
  .sidebar-rule { display: none; }
  .topbar { padding: 16px; align-items: flex-start; }
  .topbar p { display: none; }
  .view { padding: 18px 14px 40px; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2, .form-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 96px; }
}

.hidden { display: none !important; }
.analytics-toolbar { position: relative; overflow: hidden; }
.analytics-toolbar::after {
  content: ""; position: absolute; right: -70px; top: -100px; width: 260px; height: 260px;
  background: radial-gradient(circle, rgba(25,103,210,.13), transparent 66%); pointer-events: none;
}
.toolbar-row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; position: relative; z-index: 1; }
.filter-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-group label { color: #65738a; font-size: 12px; font-weight: 700; white-space: nowrap; }
.filter-group select, .filter-group input {
  border: 1px solid #d8e0eb; border-radius: 10px; padding: 9px 11px; background: #fff; color: var(--text); min-height: 40px;
}
.filter-group select { min-width: 140px; }
.custom-range { padding: 0 4px; }
.custom-range input { min-width: 138px; }
.range-note { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; position: relative; z-index: 1; }
.range-note strong { color: #35435a; }
.growth { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 7px; margin-right: 5px; font-weight: 800; font-size: 11px; }
.growth.up { color: #087a52; background: #e8f8f0; }
.growth.down { color: #b53333; background: #fff0f0; }
.growth.flat { color: #607089; background: #eff2f6; }
.analytics-split { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, .8fr); gap: 16px; }
.analytics-split.equal { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chart-card { min-width: 0; }
.chart-svg { width: 100%; height: auto; overflow: visible; margin-top: 6px; }
.chart-grid-line { stroke: #e8edf4; stroke-width: 1; stroke-dasharray: 3 5; }
.chart-axis-label { fill: #8290a5; font-size: 10px; font-family: "Microsoft YaHei", sans-serif; }
.chart-dot { cursor: default; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 2px 0 2px; }
.chart-legend span { color: #66758b; font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i, .donut-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.donut-wrap { display: grid; grid-template-columns: 190px minmax(0,1fr); gap: 12px; align-items: center; min-height: 245px; }
.donut { width: 180px; max-width: 100%; }
.donut-track { fill: none; stroke: #edf1f6; stroke-width: 15; }
.donut-ring { transform: rotate(-90deg); transform-origin: 60px 60px; }
.donut-total { font-size: 10px; font-weight: 800; fill: #26344b; }
.donut-caption { font-size: 6px; fill: #8592a6; }
.donut-legend { display: grid; gap: 12px; }
.donut-legend > div { display: grid; grid-template-columns: 12px 1fr auto; gap: 4px 7px; align-items: center; }
.donut-legend span { color: #5f6d82; font-size: 12px; }
.donut-legend strong { font-size: 13px; }
.donut-legend small { grid-column: 2 / -1; color: var(--muted); font-size: 11px; }
.bar-list { display: grid; gap: 16px; min-height: 210px; align-content: center; }
.bar-row { display: grid; gap: 7px; }
.bar-row-head { display: flex; justify-content: space-between; gap: 12px; color: #5c6b81; font-size: 12px; }
.bar-row-head strong { color: #26344b; }
.bar-track { width: 100%; height: 11px; border-radius: 999px; overflow: hidden; background: #edf1f6; }
.bar-fill { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #1967d2, #5b9af4); min-width: 4px; }
.bar-fill.blue { background: linear-gradient(90deg, #1967d2, #62a5ff); }
.manager-bars { display: grid; gap: 14px; }
.manager-bar-row { display: grid; grid-template-columns: 28px minmax(0,1fr); gap: 10px; align-items: center; }
.rank { width: 28px; height: 28px; border-radius: 9px; background: #eef3fb; color: #315f9e; display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.manager-bar-main { display: grid; gap: 6px; }
.manager-bar-meta { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 11px; }
@media (max-width: 1120px) {
  .analytics-split, .analytics-split.equal { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .toolbar-row, .filter-group { width: 100%; }
  .filter-group select, .filter-group input { flex: 1; min-width: 0; }
  .custom-range { display: grid; grid-template-columns: 1fr 1fr; }
  .custom-range label { grid-column: span 1; }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .donut-legend { width: 100%; }
}

.login-page { min-height: 100vh; background: radial-gradient(circle at 15% 20%, #e8f1ff 0, transparent 35%), linear-gradient(135deg, #f7f9fc, #eef3f9); }
.login-shell { width: min(1060px, calc(100vw - 32px)); min-height: 100vh; margin: 0 auto; display: grid; grid-template-columns: 1.1fr .9fr; align-items: center; gap: 60px; padding: 40px 0; }
.login-brand { color: #16243a; }
.brand-mark.large { width: 62px; height: 62px; border-radius: 18px; font-size: 20px; margin-bottom: 28px; }
.eyebrow { color: #1967d2 !important; font-size: 11px !important; letter-spacing: .18em; font-weight: 800; margin-top: 0 !important; }
.login-brand h1 { font-size: clamp(34px, 5vw, 56px); line-height: 1.08; letter-spacing: -.055em; max-width: 600px; }
.login-brand > p { color: #65738a; font-size: 16px; line-height: 1.8; max-width: 520px; }
.login-rules { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 28px; }
.login-rules span { background: rgba(255,255,255,.8); border: 1px solid #dce5f0; border-radius: 999px; padding: 8px 12px; color: #526178; font-size: 12px; }
.login-card { background: rgba(255,255,255,.94); border: 1px solid rgba(217,225,235,.9); border-radius: 24px; padding: 32px; box-shadow: 0 28px 80px rgba(22,43,75,.13); backdrop-filter: blur(18px); }
.login-card-head h2 { margin: 0; font-size: 25px; letter-spacing: -.03em; }
.login-card-head p { margin: 7px 0 26px; color: var(--muted); }
.login-field { display: grid; gap: 8px; margin-bottom: 16px; }
.login-field span { font-size: 12px; font-weight: 700; color: #58667b; }
.login-field input { width: 100%; border: 1px solid #d9e0ea; border-radius: 12px; padding: 13px 14px; outline: none; background: #fff; }
.login-field input:focus { border-color: #7eacf2; box-shadow: 0 0 0 4px rgba(25,103,210,.1); }
.login-submit { width: 100%; min-height: 46px; margin-top: 6px; }
.login-error { background: #fff1f1; color: #a92e2e; border: 1px solid #f2cccc; padding: 10px 12px; border-radius: 10px; font-size: 12px; margin-bottom: 12px; }
.login-hint { border-top: 1px solid var(--line); margin-top: 24px; padding-top: 18px; }
.login-hint strong { font-size: 12px; color: #40506a; }
.login-hint p { color: var(--muted); font-size: 12px; line-height: 1.65; margin-bottom: 0; }
@media (max-width: 820px) {
  .login-shell { grid-template-columns: 1fr; gap: 28px; padding: 28px 0; }
  .login-brand h1 { font-size: 36px; }
  .login-card { padding: 24px; }
}

.user-area { display: flex; align-items: center; gap: 8px; padding-left: 8px; border-left: 1px solid var(--line); }
.user-badge { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #40506a; font-size: 12px; font-weight: 700; }
.nav-item[hidden] { display: none !important; }

.permission-catalog { display: grid; gap: 14px; margin-top: 16px; }
.permission-group { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: #fbfcfe; }
.permission-group-title { font-weight: 800; color: #2e3d55; margin-bottom: 10px; }
.permission-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.permission-item { display: flex; gap: 9px; align-items: flex-start; border: 1px solid #e1e7ef; border-radius: 10px; padding: 9px 10px; background: #fff; cursor: pointer; }
.permission-item:hover { border-color: #b9cce8; background: #f7faff; }
.permission-item input { margin-top: 3px; accent-color: var(--accent); }
.permission-item strong { display: block; font-size: 12px; color: #293850; }
.permission-item small { display: block; margin-top: 3px; color: #8a96a8; font-family: "Cascadia Mono", Consolas, monospace; font-size: 10px; }
.permission-head { margin-bottom: 4px; }
@media (max-width: 700px) { .permission-grid { grid-template-columns: 1fr; } }
.modal-error { margin: 14px 22px 0; padding: 10px 12px; border: 1px solid #efc9c9; border-radius: 10px; background: #fff2f2; color: #a72f2f; font-size: 12px; line-height: 1.5; }
.expiry-alert { margin-top: 16px; padding: 13px 15px; border-radius: 13px; border: 1px solid #f0d2a8; background: #fff8ed; display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.expiry-alert strong { display: block; color: #8f5500; margin-bottom: 3px; }
.expiry-alert span { color: #806b4d; font-size: 12px; }
.nav-count { margin-left: auto; min-width: 20px; height: 20px; border-radius: 999px; background: #e75c5c; color: #fff; display: inline-grid; place-items: center; font-size: 10px; padding: 0 5px; }
@media (max-width: 700px) { .expiry-alert { align-items: flex-start; flex-direction: column; } }

/* 客户与交易ID：同一客户下的交易ID合并成一个标签列表 */
.id-chip-list { display: flex; flex-wrap: wrap; gap: 6px; max-width: 560px; }
.id-chip { display: inline-flex; align-items: center; gap: 6px; background: #f1f5fb; border: 1px solid #e2e9f4; border-radius: 8px; padding: 4px 6px 4px 9px; font-size: 11px; font-family: ui-monospace, Consolas, monospace; color: #3d4c63; white-space: nowrap; }
.id-chip.inactive { background: #f6f7f9; border-color: #e6e8ec; color: #98a2b3; }
.id-chip .chip-tag { font-family: inherit; font-size: 10px; background: #fff4df; color: #9a5d00; border-radius: 999px; padding: 1px 6px; }
.id-chip .chip-tag.muted { background: #eff2f6; color: #607089; }
.id-chip .chip-action { border: 0; background: transparent; cursor: pointer; color: #b83333; font-size: 11px; font-weight: 700; padding: 0 2px; }
.id-chip .chip-action.restore { color: #087a52; }
.id-chip-more { background: #eef2f7; border-color: #e2e9f4; color: #607089; }
/* 批量场景：交易ID 多选 */
select[multiple].multi-select { min-height: 138px; padding: 6px; }
select[multiple].multi-select option { padding: 4px 6px; }
.multi-hint { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.multi-hint .cell-sub { margin-top: 0; }