:root {
  --brand: #03a4e0;
  --brand-600: #0288c4;
  --brand-700: #0369a1;
  --brand-50: #e8f6fd;
  --navy: #0b1b33;
  --navy-2: #13294b;
  --bg: #f3f6fb;
  --card: #ffffff;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --line: #e5eaf1;
  --line-2: #eef2f7;
  --ok: #16a34a;   --ok-bg: #e8f8ee;   --ok-text: #166534;
  --warn: #d97706; --warn-bg: #fff6e5; --warn-text: #92400e;
  --err: #dc2626;  --err-bg: #fdecec;  --err-text: #991b1b;
  --info-bg: #e8f6fd; --info-text: #075985;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 24px rgba(15, 23, 42, .05);
  --shadow-lg: 0 10px 40px rgba(2, 40, 80, .18);
  --sidebar: 232px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.6 "Inter", -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-feature-settings: "tnum" 1, "cv11" 1;
}
a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); }
h1 { font-size: 24px; font-weight: 700; margin: 0 0 18px; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; margin: 0 0 14px; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- 后台外框：侧边栏 ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%); color: #cbd5e1; padding: 18px 14px;
}
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 22px; color: #fff; font-weight: 700; font-size: 15px; }
.sb-brand img { height: 30px; background: #fff; border-radius: 8px; padding: 3px 6px; }
.sb-brand:hover { color: #fff; }
.sb-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.sb-nav a {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 10px; color: #b6c2d6; font-weight: 500; line-height: 1.35;
  transition: background .15s, color .15s;
}
.sb-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sb-nav a.on { background: linear-gradient(90deg, var(--brand) 0%, var(--brand-600) 100%); color: #fff; box-shadow: 0 6px 18px rgba(3, 164, 224, .35); }
.sb-nav .badge { margin-left: auto; }
.sb-group { padding: 6px 12px 3px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #6f7f99; }
.sb-group-sep { margin-top: 8px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .08); }
.sb-nav-bottom { flex: none; padding-top: 10px; margin-top: 10px; border-top: 1px solid rgba(255, 255, 255, .08); }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 12px 10px 4px; border-top: 1px solid rgba(255, 255, 255, .08); margin: 12px 0 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: #fff; font-weight: 700; }
.sb-user-name { flex: 1; color: #fff; font-weight: 600; line-height: 1.2; }
.sb-user-name small { display: block; color: #8ea0bb; font-weight: 400; font-size: 12px; }
.icon-btn { background: none; border: 0; color: inherit; cursor: pointer; padding: 6px; border-radius: 8px; display: grid; place-items: center; opacity: .8; }
.icon-btn:hover { background: rgba(255, 255, 255, .1); opacity: 1; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: #ef4444; color: #fff; font-size: 11px; line-height: 20px; text-align: center; font-weight: 700; }

.shell > main { padding: 28px 32px 48px; max-width: 1720px; width: 100%; }

/* ---------- 代理专区外框 ---------- */
.agent-bar {
  display: flex; align-items: center; gap: 24px; padding: 0 28px; height: 64px; background: #fff;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.ab-brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; }
.ab-brand img { height: 32px; }
.agent-bar nav { display: flex; gap: 4px; flex: 1; }
.agent-bar nav a { display: flex; gap: 8px; align-items: center; padding: 8px 14px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.agent-bar nav a.on { background: var(--brand-50); color: var(--brand-700); }
.ab-user { display: flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; margin: 0; }
.ab-user .icon-btn:hover { background: var(--line-2); }
.agent-content > main { max-width: 1100px; margin: 0 auto; padding: 28px 24px 48px; }

/* ---------- 登录 / 公开页 ---------- */
.auth-bg {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(3, 164, 224, .35), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(3, 164, 224, .25), transparent 60%),
    linear-gradient(160deg, var(--navy) 0%, #0d2a52 100%);
}
.auth-bg main { width: 100%; max-width: 420px; }
.auth-bg .card { padding: 32px; box-shadow: var(--shadow-lg); border: 0; }
.auth-bg .card h2 { text-align: center; font-size: 20px; margin-bottom: 20px; }
.auth-logo { display: block; margin: 0 auto 8px; width: 150px; }
.auth-bg .alert { box-shadow: var(--shadow); }
.auth-bg .card.login-card { position: relative; }
.login-card .remember { margin: -2px 0 6px; color: var(--text-2); font-size: 13px; cursor: pointer; }

/* ---------- 通用元件 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card.center, .center { text-align: center; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; align-items: start; }
.actions-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions-row form { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.nowrap { white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border: 1px solid transparent; border-radius: 10px;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-600) 100%); color: #fff; font: inherit; font-weight: 600; cursor: pointer;
  white-space: nowrap; box-shadow: 0 1px 2px rgba(3, 105, 161, .25), inset 0 1px 0 rgba(255, 255, 255, .15); transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.05); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn-ghost { background: #fff; color: var(--text-2); border-color: var(--line); box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.btn-ghost:hover { background: #f8fafc; color: var(--text); border-color: #d5dde8; }
.btn-danger { background: #fff; color: var(--err); border-color: #f3c4c4; box-shadow: none; }
.btn-danger:hover { background: var(--err-bg); color: var(--err); }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn.block { display: flex; width: 100%; margin-top: 10px; padding: 11px; }
button.link { background: none; border: 0; color: inherit; cursor: pointer; font: inherit; padding: 0; }

label { display: block; margin-bottom: 14px; color: var(--text-2); font-size: 13px; font-weight: 500; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 9px 12px; border: 1px solid #d6dde8; border-radius: 10px; font: inherit; color: var(--text);
  background: #fff; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(3, 164, 224, .15); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); display: inline-block; flex: none; }
input[type=file] { padding: 7px; background: #f8fafc; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset:disabled { opacity: .5; }
legend { font-weight: 650; margin-bottom: 14px; font-size: 14px; color: var(--text); padding: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px 32px; }
.form-actions { grid-column: 1 / -1; border-top: 1px solid var(--line-2); padding-top: 16px; margin-top: 4px; }
.form-narrow { max-width: 440px; }
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { margin: 0; }
.inline-form .grow { flex: 1; min-width: 200px; margin: 0; }
.search { display: flex; gap: 8px; align-items: center; }
.search input, .search select { margin: 0; }
.search input { width: 280px; }
.search select { width: auto; }
form.inline { display: inline; margin: 0; }
.w-num { width: 84px !important; }
.w-code { width: 130px !important; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.card.table-wrap { padding: 0; }
.card.table-wrap > h2, .card.table-wrap > .card-head, .card.table-wrap > p { margin: 0; padding: 18px 22px 12px; }
.card.table-wrap > .card-head h2 { padding: 0; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th, .table td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); text-align: left; white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; background: #f8fafc; border-bottom: 1px solid var(--line); }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover td { background: #f6fbfe; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { font-weight: 700; background: #f8fafc; border-top: 1px solid var(--line); border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.inactive td { color: #a0aec0; }
.table form { margin: 0; }
.table.dense th, .table.dense td { padding: 7px 10px; font-size: 13px; }
.table.dense th:first-child, .table.dense td:first-child { position: sticky; left: 0; z-index: 1; background: #fff; box-shadow: 1px 0 0 var(--line-2); }
.table.dense th:first-child, .table.dense tfoot td:first-child { background: #f8fafc; }
.table.dense tbody tr:hover td:first-child { background: #f6fbfe; }
.table td b { font-weight: 650; }
.neg { color: #ff1a1a !important; font-weight: 600; }
.diff td.old { color: var(--muted); text-decoration: line-through; }
.diff td.new { color: var(--ok-text); font-weight: 600; }
.diff { margin-bottom: 14px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.table.tiers { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 8px; }
.table.tiers td { padding: 4px; border-bottom: 1px solid var(--line-2); }
.table.tiers input { margin: 0; padding: 6px 8px; border-radius: 7px; }
.compact-form td { vertical-align: middle; }
.compact-form input, .compact-form select { margin: 0; padding: 5px 8px; display: inline-block; width: auto; max-width: 180px; border-radius: 8px; }
tr.group-start td { border-top: 2px solid var(--line); }

/* ---------- 标签、提示 ---------- */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 0 9px; border-radius: 999px; background: #f1f5f9; color: var(--text-2); font-size: 12px; line-height: 22px; font-weight: 500; }
.tag-ok { background: var(--ok-bg); color: var(--ok-text); }
.tag-info { background: var(--info-bg); color: var(--info-text); }
.tag-warn { background: var(--warn-bg); color: var(--warn-text); }
.tag-err { background: var(--err-bg); color: var(--err-text); }
.tag-ok::before, .tag-info::before, .tag-warn::before, .tag-err::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }

.alert { padding: 13px 16px 13px 44px; border-radius: 12px; margin-bottom: 18px; position: relative; border: 1px solid transparent; }
.alert::before { content: ""; position: absolute; left: 16px; top: 15px; width: 16px; height: 16px; border-radius: 50%; background: currentColor; opacity: .9; }
.alert::after { content: "i"; position: absolute; left: 16px; top: 15px; width: 16px; height: 16px; border-radius: 50%; color: #fff; font: 700 11px/16px Georgia, serif; text-align: center; }
.alert-success { background: var(--ok-bg); color: var(--ok-text); border-color: #c9efd6; }
.alert-success::after { content: "✓"; font-family: inherit; }
.alert-error { background: var(--err-bg); color: var(--err-text); border-color: #f6cccc; }
.alert-error::after { content: "!"; }
.alert-warn { background: var(--warn-bg); color: var(--warn-text); border-color: #fbe1b0; }
.alert-warn::after { content: "!"; }
.alert-info { background: var(--info-bg); color: var(--info-text); border-color: #c4e8f8; }
.alert a { color: inherit; text-decoration: underline; }
details.alert > summary { list-style: none; }

/* ---------- 统计卡 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); overflow: hidden; }
.stat::after { content: ""; position: absolute; right: -24px; top: -24px; width: 84px; height: 84px; border-radius: 50%; background: var(--brand-50); }
.stat:nth-child(4n+2)::after { background: #eef2ff; }
.stat:nth-child(4n+3)::after { background: #fff4e5; }
.stat:nth-child(4n+4)::after { background: #e9f9ef; }
.stat-label { position: relative; z-index: 1; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat-value { position: relative; z-index: 1; font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-value.warn { color: var(--warn); }
.stats.compact { gap: 12px; margin-bottom: 4px; }
.stats.compact .stat { box-shadow: none; background: #f8fafc; padding: 14px 16px; }
.stats.compact .stat::after { display: none; }
.stats.compact .stat-value { font-size: 19px; }

.notice-item { padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.notice-item:last-child { border-bottom: 0; }
.notice-item.bank, .notice.bank { border-left: 3px solid #f59e0b; padding-left: 14px; }

/* 分页标签（segmented） */
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: #e9eef5; border-radius: 12px; }
.tabs a { padding: 7px 14px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 13px; }
.tabs a:hover { color: var(--text); }
.tabs a.on { background: #fff; color: var(--brand-700); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.tabs-lg { display: flex; flex-wrap: wrap; margin-bottom: 18px; width: fit-content; max-width: 100%; }
.tabs-lg a { padding: 9px 18px; font-size: 14px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .tabs-lg { margin: 0; }
.toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 500; padding: 7px 12px; border-radius: 10px; background: #fff; border: 1px solid var(--line); }
.toggle:hover { color: var(--text); border-color: #d5dde8; }
.toggle .dot { width: 30px; height: 18px; border-radius: 9px; background: #cbd5e1; position: relative; transition: background .15s; }
.toggle .dot::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.toggle.on .dot { background: var(--brand); }
.toggle.on .dot::after { left: 14px; }

/* 区块标题 */
.block-title { display: flex; align-items: center; gap: 10px; }
.block-title::before { content: ""; width: 4px; height: 18px; border-radius: 2px; background: linear-gradient(180deg, var(--brand), var(--brand-700)); }
.block-title .meta { margin-left: auto; font-size: 12.5px; color: var(--muted); font-weight: 500; }

.pager { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.pager-info { margin-right: auto; }
.pager-info b { color: var(--text); font-weight: 600; }
.pager-pages { display: flex; gap: 4px; }
.pg { min-width: 34px; height: 34px; padding: 0 8px; display: inline-grid; place-items: center; border-radius: 9px; background: #fff; border: 1px solid var(--line); color: var(--text-2); font-weight: 600; }
.pg:hover { border-color: var(--brand); color: var(--brand-700); }
.pg.on { background: linear-gradient(180deg, var(--brand), var(--brand-600)); border-color: transparent; color: #fff; box-shadow: 0 4px 12px rgba(3, 164, 224, .3); }
.pg.off { opacity: .4; pointer-events: none; }
.pg.gap { background: none; border: 0; min-width: 18px; }
.pager-jump, .pager-per { display: flex; align-items: center; gap: 6px; margin: 0; }
.pager-jump input { width: 70px; margin: 0; padding: 6px 8px; text-align: center; }
.pager-per select { width: auto; margin: 0; padding: 6px 30px 6px 10px; }
.card.table-wrap + .pager { margin-top: -4px; }
ul.plain { padding-left: 18px; margin: 0; }
details > summary { cursor: pointer; font-weight: 600; }
details[open] > summary { margin-bottom: 12px; }
details.card > summary { color: var(--text-2); }
.mail-preview { width: 100%; height: 760px; border: 1px solid var(--line); border-radius: 10px; background: #f3f4f6; }
pre.sms { white-space: pre-wrap; background: #f8fafc; padding: 14px; border-radius: 10px; border: 1px solid var(--line); }

.confirm-box { align-items: flex-start; margin: 4px 0 12px; }
.confirm-box input { margin-top: 3px; }
#overwrite-box { padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); border: 1px solid #fbe1b0; color: var(--warn-text); }

/* 汇入状态 / 月份卡片 */
.import-status { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.import-item { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: #f8fafc; min-width: 0; }
.import-item.done { background: #f3fbf6; border-color: #cdebd8; }
.import-item.missing { background: #fffaf0; border-color: #fbe1b0; }
.import-item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.period-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.period-card { display: block; color: var(--text); margin: 0; transition: border-color .15s, transform .1s, box-shadow .15s; }
.period-card:hover { color: var(--text); border-color: var(--brand); transform: translateY(-1px); box-shadow: 0 10px 30px rgba(3, 105, 161, .12); }
.period-card-head { display: flex; justify-content: space-between; align-items: center; font-size: 17px; margin-bottom: 10px; }
.period-card-amount { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-bottom: 4px; }
.period-card.pending { border-style: dashed; }

/* 代理资料（key-value） */
.kv { display: grid; grid-template-columns: minmax(130px, 40%) 1fr; gap: 12px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; font-weight: 500; word-break: break-all; }

/* 测试模式 */
.test-banner { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: -8px 0 18px; padding: 9px 14px; border-radius: 10px;
  background: repeating-linear-gradient(135deg, #fff6e5 0 12px, #fff0d4 12px 24px); border: 1px dashed #f5b84b; color: var(--warn-text); font-size: 13px; }
.test-banner a { margin-left: auto; color: inherit; font-weight: 600; text-decoration: underline; }
.radio-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; font-weight: 400; }
.radio-card input { width: 16px; height: 16px; margin: 3px 0 0; accent-color: var(--brand); flex: none; }
.radio-card b { display: block; color: var(--text); }
.radio-card small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.5; margin-top: 2px; }
.radio-card:has(input:checked) { border-color: var(--brand); background: var(--brand-50); }
.radio-card.warn:has(input:checked) { border-color: #f5b84b; background: var(--warn-bg); }

/* 帐号管理：一次性显示的登录资料 */
.credential { border-color: #bfe6f7; background: linear-gradient(180deg, #f2fbff, #fff); }
.cred-box { display: grid; gap: 8px; margin: 12px 0 14px; max-width: 460px; }
.cred-box > div { display: grid; grid-template-columns: 80px 1fr; align-items: center; }
.cred-box code { font: 600 15px/1.4 ui-monospace, Consolas, monospace; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; user-select: all; }

/* 账单页 */
.statement-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.bill-wrap { margin-bottom: 18px; min-width: 0; }
.bill-wrap > table { box-shadow: var(--shadow); }
.adjust { position: sticky; top: 20px; }
.adjust input { margin-bottom: 0; }

@media (max-width: 1100px) {
  .statement-layout { grid-template-columns: 1fr; }
  .adjust { position: static; }
}
@media (max-width: 900px) {
  /* minmax(0, 1fr)：避免宽表格把整页撑宽；表格在卡片内左右滑动 */
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .shell > main, .agent-content > main { min-width: 0; }
  /* 侧边栏变成顶部列：第一行 logo + 登出，第二行可左右滑动的选单 */
  .sidebar { position: sticky; top: 0; height: auto; min-height: 0; flex-direction: row; flex-wrap: wrap; align-items: center; align-content: flex-start; padding: 10px 12px 0; gap: 0 6px; z-index: 30; min-width: 0; }
  .sb-brand { order: 1; flex: 1 1 auto; padding: 0 0 8px; min-width: 0; }
  .sb-brand img { height: 26px; }
  .sb-user { order: 3; flex: none; border: 0; margin: 0; padding: 0 0 8px; }
  .sb-user-name, .sb-user .avatar { display: none; }
  .sb-nav { order: 5; flex: 1 1 100%; min-width: 0; flex-direction: row; overflow-x: auto; gap: 2px; padding-bottom: 8px; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .sb-nav::-webkit-scrollbar { display: none; }
  .sb-group { display: none; }
  .sb-group-sep { display: block; flex: none; width: 1px; margin: 6px 6px; padding: 0; border: 0; background: rgba(255, 255, 255, .18); font-size: 0; }
  .sb-nav a { padding: 7px 10px; white-space: nowrap; gap: 6px; font-size: 13px; border-radius: 9px; }
  .sb-nav-bottom { order: 2; flex: none; border: 0; margin: 0; padding: 0 0 8px; gap: 0; overflow: visible; -webkit-mask-image: none; mask-image: none; }
  .sb-nav-bottom a { padding: 7px 8px; }
  .sb-nav-bottom a span { display: none; }
  .shell > main { padding: 16px 14px 40px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 20px; word-break: break-all; }
  .stats.compact .stat-value { font-size: 16px; }
  h1 { font-size: 20px; }
  .page-head { gap: 10px; }
  .page-head h1 { flex-basis: 100%; }
  .card { padding: 16px; border-radius: 12px; }
  .card.table-wrap > h2, .card.table-wrap > .card-head, .card.table-wrap > p { padding: 14px 16px 10px; }
  .search { flex-wrap: wrap; width: 100%; }
  .search input { width: auto; flex: 1 1 160px; min-width: 0; }
  .search select { flex: 1 1 100%; }
  .inline-form > label, .inline-form > .grow { flex: 1 1 100%; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .tabs, .tabs-lg { overflow-x: auto; max-width: 100%; flex-wrap: nowrap; scrollbar-width: none; }
  .tabs a { white-space: nowrap; }
  .pager { gap: 10px; }
  .pager-info { flex-basis: 100%; }
  .pager-pages { overflow-x: auto; max-width: 100%; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 10px; }
  .cred-box > div { grid-template-columns: 70px minmax(0, 1fr); }
  .cred-box code { word-break: break-all; }
  .agent-bar { padding: 0 12px; gap: 6px; height: 56px; }
  .agent-bar nav { min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .agent-bar nav a { padding: 8px 10px; }
  .agent-bar nav a span { display: none; }
  .agent-bar nav a.on span { display: none; }
  .agent-bar .lang-switch a { padding: 3px 7px; }
  .ab-brand span { display: none; }
  .agent-content > main { padding: 18px 14px 40px; }
  .test-banner { margin-top: 0; }
  .actions-row { width: 100%; }
  .diff { display: block; overflow-x: auto; }
}
@media print {
  .sidebar, .agent-bar, .no-print, .alert, .adjust { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  .card, .bill-wrap { border: 0; box-shadow: none; padding: 0; }
  .statement-layout { display: block; }
  .bill-wrap { overflow: visible; }
}

/* 语言切换 */
.lang-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 9px; background: rgba(15, 23, 42, .06); font-size: 12px; font-weight: 600; }
.lang-switch a { padding: 3px 9px; border-radius: 7px; color: var(--muted); }
.lang-switch a.on { background: #fff; color: var(--brand-700); box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }
.sb-lang { margin: 10px 10px 0; background: rgba(255, 255, 255, .08); align-self: flex-start; }
.sb-lang a { color: #9fb0c8; }
.sb-lang a.on { background: rgba(255, 255, 255, .16); color: #fff; box-shadow: none; }
.auth-lang { position: fixed; top: 16px; right: 16px; background: rgba(255, 255, 255, .12); z-index: 5; }
.auth-lang a { color: #cfe3f5; }
.auth-lang a.on { background: #fff; color: var(--brand-700); }
@media (max-width: 900px) {
  .sb-lang { order: 3; margin: 0 0 8px; padding: 2px; }
  .sb-lang a { padding: 3px 7px; }
  .sb-user { order: 4; }
  .sb-brand span { display: none; }
}

/* ---------- 厂商帐务 ---------- */
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filters input[type=search], .filters select { width: auto; min-width: 0; margin: 0; }
.filters .check { margin: 0; white-space: nowrap; }
.vendor-totals { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 8px; }
.vendor-totals div { display: flex; flex-direction: column; }
.vendor-totals small { color: var(--muted); font-size: 11.5px; font-weight: 600; }
.vendor-totals b { font-size: 19px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.vendor-block { margin-bottom: 14px; scroll-margin-top: 80px; }
.vendor-block-head { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.vendor-block-head h2 { margin: 0; }
.vendor-block-total { display: flex; gap: 14px; font-weight: 700; font-variant-numeric: tabular-nums; margin-left: auto; }
.vendor-block-total small { color: var(--muted); font-weight: 600; }
.vendor-block-actions { display: flex; gap: 8px; align-items: center; }
.vendor-block-actions form { margin: 0; }
.vendor-block > p.small { padding: 0 22px 8px; }
form.inline { display: inline; margin: 0; }
.tag-btn { border: 0; cursor: pointer; font: inherit; font-size: 12px; }
.tag-btn:disabled { cursor: default; }
.tag-btn:not(:disabled):hover { filter: brightness(.95); box-shadow: 0 0 0 2px rgba(3, 164, 224, .25); }
.table tr.row-warn td { background: #fff7ed; }
.table tr.muted td { color: var(--muted); }
.edit-table input, .edit-table select { margin: 0; min-width: 0; padding: 6px 8px; font-size: 13px; }
.edit-table td { padding: 4px 4px; vertical-align: middle; }
.edit-table .w-xs { width: 64px; } .edit-table .w-sm { width: 92px; } .edit-table .w-md { width: 120px; } .edit-table .w-lg { width: 220px; }
.formula-note { font-size: 12px; color: var(--muted); max-width: 260px; }
.pay-accounts summary { cursor: pointer; color: var(--brand-700); font-size: 12.5px; }
.pay-accounts table { margin-top: 6px; }
@media (max-width: 900px) {
  .vendor-block-total { margin-left: 0; flex-basis: 100%; }
  .filters { width: 100%; }
  .filters input[type=search] { flex: 1 1 140px; }
}
.remark-cell { min-width: 220px; max-width: 360px; white-space: normal; }
.stat a.small { position: relative; z-index: 1; display: inline-block; margin-top: 4px; }
.fx-card { margin-bottom: 18px; }
.fx-card > summary { cursor: pointer; list-style: none; margin: 0; }
.fx-card > summary::-webkit-details-marker { display: none; }
.fx-card[open] > summary { margin-bottom: 12px; }
.fx-table { width: auto; margin-bottom: 12px; }
.fx-table input { width: 120px; margin: 0; padding: 6px 8px; }
.fx-table td, .fx-table th { padding: 6px 8px; }
.settle-switch { margin: 0; }
.settle-switch label { display: flex; align-items: center; gap: 6px; margin: 0; }
.settle-switch select { width: auto; margin: 0; padding: 4px 8px; font-size: 13px; }
.rate-tag { font-size: 10.5px; line-height: 16px; padding: 0 5px; }
dialog.modal { border: 0; border-radius: var(--radius); padding: 24px; width: min(460px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(15, 23, 42, .3); }
dialog.modal::backdrop { background: rgba(15, 23, 42, .45); }
dialog.modal h2 { margin-top: 0; }
dialog.modal .hint { margin: -4px 0 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.vendor-ids { display: flex; gap: 14px; font-size: 13px; font-variant-numeric: tabular-nums; }
.vendor-ids small { color: var(--muted); font-weight: 600; margin-right: 2px; }
.vendor-hero { padding: 22px 24px; }
.vendor-hero-head { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.vendor-hero-head h2 { margin: 2px 0 0; font-size: 26px; letter-spacing: -.02em; }
.vendor-progress { flex: 1; min-width: 220px; max-width: 420px; }
.vendor-progress-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.vendor-progress-label b { color: var(--text); }
.vendor-hero-head .btn { margin-left: auto; }
.vendor-hero-totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.vendor-hero-totals > div { background: #f8fafc; border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; }
.vendor-hero-totals small { color: var(--muted); font-size: 12px; font-weight: 600; }
.vendor-hero-totals b { font-size: 21px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.bar { height: 8px; border-radius: 99px; background: #e9eef5; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.bar i.full { background: linear-gradient(90deg, #16a34a, #22c55e); }
.vendor-months tbody tr { cursor: pointer; }
.vendor-months tbody tr:hover td { background: #f5faff; }
.vendor-months td { vertical-align: middle; }
.progress-cell { min-width: 150px; }
.progress-cell .bar { display: inline-block; width: 90px; vertical-align: middle; margin-right: 8px; }
@media (max-width: 900px) {
  .vendor-hero-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vendor-hero-totals b { font-size: 17px; }
  .vendor-hero-head .btn { margin-left: 0; }
}
.rate-cell { white-space: nowrap; }
.rate-input { display: inline-block; vertical-align: middle; width: 96px; margin: 0; padding: 4px 8px; font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; border-color: transparent; background: #f8fafc; }
.rate-input:hover:not(:disabled) { border-color: var(--line); background: #fff; }
.rate-input:focus { background: #fff; }
.rate-input:disabled { background: transparent; color: var(--text); }
.rate-input.missing { border-color: #f59e0b; background: #fff7ed; }
.rate-input.ok { border-color: #22c55e; background: #f0fdf4; }
.rate-input.err { border-color: #ff1a1a; background: #fef2f2; }
.rate-cell .rate-tag { margin-left: 4px; }
.bill-meta { display: flex; flex-wrap: wrap; gap: 14px 32px; }
.bill-meta > div { display: flex; flex-direction: column; gap: 4px; }
.bill-meta small { color: var(--muted); font-size: 12px; font-weight: 600; }
.bill-meta select { width: auto; margin: 0; }
.ok-mark { color: #16a34a; font-weight: 700; }
.err-mark { color: #ff1a1a; font-weight: 700; }
a.tag { text-decoration: none; }
.select-search { margin-bottom: 6px; }
select.searchable.open { height: auto; padding: 4px; }
select.searchable.open option { padding: 6px 8px; border-radius: 6px; }
.payout-table tr.row-paid td { background: #f6fef9; }
.nowrap { white-space: nowrap; }
