/* ============================================================
   天友代付 · 管理控制台
   设计基调：浅青灰纸面 + 深墨青导航 + 松绿主色（资金“结清”语义）
   状态色全站统一：SUCCESS 绿 / FAILED 砖红 / UNKNOWN 琥珀 / SENDING 蓝
   ============================================================ */
:root {
  --paper: #f2f4f0;
  --surface: #ffffff;
  --ink: #1c2b28;
  --ink-2: #5f6d68;
  --ink-3: #8b968f;
  --line: #dce2da;
  --line-soft: #e8ece5;

  --accent: #0d6b58;
  --accent-deep: #0a5546;
  --accent-soft: #e2efe9;
  --accent-ink: #0a5546;

  --ok: #0d6b58;       --ok-bg: #e2efe9;
  --bad: #b0392f;      --bad-bg: #f7e5e2;
  --warn: #96660a;     --warn-bg: #f6eed7;
  --info: #31608f;     --info-bg: #e3ecf4;
  --muted: #6d7873;    --muted-bg: #eceee9;

  --nav-bg: #14211e;
  --nav-ink: #b9c7c0;
  --nav-active: #ffffff;

  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(28, 43, 40, .06), 0 4px 16px rgba(28, 43, 40, .05);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent-soft); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------------- 登录 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1000px 500px at 85% -10%, rgba(13, 107, 88, .10), transparent 60%),
    var(--paper);
  padding: 24px;
}
.login-card {
  width: 360px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 36px 32px 28px;
}
.login-brand { border-left: 3px solid var(--accent); padding-left: 14px; margin-bottom: 28px; }
.login-title { font-size: 22px; font-weight: 650; letter-spacing: .02em; }
.login-sub { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.login-error {
  background: var(--bad-bg); color: var(--bad);
  border-radius: 6px; padding: 8px 12px; font-size: 13px; margin-bottom: 14px;
}
.login-note { color: var(--ink-3); font-size: 12px; margin: 18px 0 0; }
.captcha-row { display: flex; gap: 10px; align-items: center; }
.captcha-row input { flex: 1 1 auto; text-transform: uppercase; letter-spacing: .12em; }
.captcha-img {
  flex: 0 0 auto; width: 116px; height: 42px; border-radius: 6px;
  border: 1px solid var(--line); cursor: pointer; background: #fff; user-select: none;
}
.captcha-img:hover { border-color: var(--accent); }

/* ---------------- 框架 ---------------- */
.shell { display: grid; grid-template-columns: 212px minmax(0, 1fr); min-height: 100vh; }

.nav {
  background: var(--nav-bg);
  color: var(--nav-ink);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-name { color: #fff; font-size: 17px; font-weight: 650; letter-spacing: .04em; }
.brand-sub { font-size: 12px; color: var(--nav-ink); opacity: .75; margin-top: 2px; }

.nav-list { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 9px 12px; margin: 1px 0;
  border: 0; border-radius: 6px;
  background: none; color: var(--nav-ink);
  font: inherit; font-size: 13.5px; text-align: left;
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(13, 107, 88, .85); color: #fff; font-weight: 550; }
.nav-item .nav-badge {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px;
  background: #c25b41; color: #fff;
  font-size: 11px; line-height: 18px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.nav-item .nav-badge.zero { display: none; }
.nav-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.whoami { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { min-width: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ---------------- 多标签页 ---------------- */
.tabbar {
  display: flex; align-items: flex-end; gap: 4px;
  padding: 10px 18px 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto; flex: none;
  scrollbar-width: thin;
}
.tab-item {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 14px;
  font: inherit; font-size: 13px; color: var(--ink-2);
  background: transparent;
  border: 1px solid transparent; border-bottom: 0;
  border-radius: 8px 8px 0 0;
  cursor: pointer; white-space: nowrap; user-select: none;
}
.tab-item:hover { color: var(--ink); background: rgba(255,255,255,.65); }
.tab-item.active {
  background: var(--surface); border-color: var(--line);
  color: var(--accent-ink); font-weight: 600;
  position: relative; top: 1px;   /* 盖住 tabbar 底边线，与内容区连成一体 */
}
.tab-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 4px;
  border: 0; background: none; color: var(--ink-3);
  font-size: 14px; line-height: 1; cursor: pointer;
}
.tab-close:hover { background: var(--bad-bg); color: var(--bad); }
.tab-body { flex: 1; min-height: 0; overflow-y: auto; }
.tab-pane { min-height: 100%; }

.page { max-width: 1200px; margin: 0 auto; padding: 26px 34px 60px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-size: 19px; font-weight: 650; margin: 0; }
.page-sub { color: var(--ink-2); font-size: 13px; margin-top: 3px; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* ---------------- 卡片 ---------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-pad { padding: 18px 20px; }
.card-title { font-size: 13.5px; font-weight: 600; margin: 0 0 12px; }

/* ---------------- 概览 ---------------- */
.hero { display: grid; grid-template-columns: minmax(260px, 380px) 1fr; gap: 0; }
.hero-left { padding: 22px 24px; border-right: 1px solid var(--line-soft); }
.hero-label { color: var(--ink-2); font-size: 13px; }
.hero-amount { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 34px; font-weight: 650; letter-spacing: -.01em; margin: 6px 0 2px; }
.hero-amount .cny { font-size: 18px; color: var(--ink-2); margin-right: 4px; font-weight: 500; }
.hero-count { color: var(--ink-2); font-size: 13px; }
.hero-right { padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.split-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--muted-bg); }
.split-bar span { min-width: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

.todo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 16px; }
.todo {
  display: block; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; font: inherit;
  transition: border-color .15s;
}
.todo:hover { border-color: var(--accent); }
.todo .todo-num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 24px; font-weight: 650; }
.todo .todo-num.attention { color: var(--warn); }
.todo .todo-num.danger { color: var(--bad); }
.todo .todo-label { color: var(--ink-2); font-size: 12.5px; margin-top: 2px; }

.trend { display: flex; align-items: flex-end; gap: 14px; height: 150px; padding: 8px 4px 0; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.trend-bar { width: 62%; max-width: 46px; height: 120px; display: flex; align-items: flex-end; background: var(--line-soft); border-radius: 4px 4px 0 0; overflow: hidden; position: relative; }
.trend-bar .fill { width: 100%; background: #c9d6cf; }
.trend-bar .fill .ok-part { width: 100%; background: var(--accent); position: absolute; bottom: 0; left: 0; }
.trend-num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 11.5px; color: var(--ink-2); }
.trend-date { font-size: 11.5px; color: var(--ink-3); }
.trend-empty { color: var(--ink-3); font-size: 12.5px; padding: 30px 0; }

.kv-line { display: flex; flex-wrap: wrap; gap: 6px 26px; font-size: 13px; color: var(--ink-2); }
.kv-line b { color: var(--ink); font-weight: 600; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--ink-2);
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  background: #fafbf9; white-space: nowrap;
}
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #f7faf7; }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
td.mono { font-family: var(--mono); font-size: 12.5px; }
.cell-dim { color: var(--ink-2); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--ink-3); padding: 40px 0; font-size: 13px; }

/* ---------------- 徽标 ---------------- */
.badge {
  display: inline-block; padding: 1px 9px; border-radius: 20px;
  font-size: 12px; line-height: 20px; white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.muted { background: var(--muted-bg); color: var(--muted); }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 6px;
  padding: 7px 16px; font: inherit; font-size: 13.5px;
  cursor: pointer; background: var(--surface); color: var(--ink);
  border-color: var(--line);
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-deep); }
.btn.danger { color: var(--bad); border-color: #e4c4bf; }
.btn.danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn.small { padding: 3px 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.25); color: inherit; }
.btn.ghost:hover { border-color: #fff; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-size: 13px; color: var(--accent); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--bad); }

/* ---------------- 筛选/表单 ---------------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 14px 16px; }
.filters .field { margin: 0; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field > span { font-size: 12.5px; color: var(--ink-2); }
input, select, textarea {
  font: inherit; font-size: 13.5px; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 10px; min-width: 0;
}
.filters input, .filters select { width: 170px; }
.filters input.w-wide { width: 240px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .span2 { grid-column: span 2; }
.form-hint { color: var(--ink-3); font-size: 12px; margin-top: 4px; }
.form-error { background: var(--bad-bg); color: var(--bad); border-radius: 6px; padding: 8px 12px; font-size: 13px; margin-bottom: 14px; }
.form-foot { margin-top: 8px; display: flex; justify-content: flex-end; gap: 10px; }
.check-line { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 7px 0; cursor: pointer; }
.check-line input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.hint-list { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 13px; display: grid; gap: 6px; }

.secret-panel { background: #f4f8f6; border: 1px dashed var(--accent); border-radius: 8px; padding: 14px 16px; margin-bottom: 14px; }
.secret-panel .secret-value { font-family: var(--mono); font-size: 14px; word-break: break-all; margin: 6px 0 10px; }

/* ---------------- 配置检测 ---------------- */
.test-banner { border-radius: 8px; padding: 10px 14px; font-weight: 600; font-size: 14px; margin-bottom: 14px; }
.test-banner.ok { background: var(--ok-bg); color: var(--ok); }
.test-banner.warn { background: var(--warn-bg); color: var(--warn); }
.test-banner.bad { background: var(--bad-bg); color: var(--bad); }
.test-item { padding: 10px 2px; border-bottom: 1px solid var(--line-soft); }
.test-item:last-of-type { border-bottom: 0; }
.test-item-head { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.test-item-msg { color: var(--ink-2); font-size: 13px; margin-top: 4px; word-break: break-all; }

/* ---------------- 分页 ---------------- */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 12px 16px; font-size: 13px; color: var(--ink-2); }
.pager .page-no { font-variant-numeric: tabular-nums; }

/* ---------------- 标签页 ---------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { border: 0; background: none; font: inherit; font-size: 14px; color: var(--ink-2); padding: 8px 16px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent-ink); font-weight: 600; border-bottom-color: var(--accent); }

/* ---------------- 弹层 ---------------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 33, 30, .45);
  display: grid; place-items: center; padding: 24px;
}
.modal {
  background: var(--surface); border-radius: 10px;
  width: 620px; max-width: 100%; max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: 0 12px 40px rgba(20, 33, 30, .25);
}
.modal.wide { width: 780px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px 12px; border-bottom: 1px solid var(--line-soft); }
.modal-title { font-size: 15.5px; font-weight: 650; margin: 0; }
.modal-close { border: 0; background: none; font-size: 20px; line-height: 1; color: var(--ink-3); cursor: pointer; padding: 4px; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 18px; border-top: 1px solid var(--line-soft); }

.detail-grid { display: grid; grid-template-columns: 110px 1fr; gap: 7px 14px; font-size: 13px; }
.detail-grid dt { color: var(--ink-2); }
.detail-grid dd { margin: 0; word-break: break-all; }
.modal-body pre {
  background: #f5f7f4; border: 1px solid var(--line-soft); border-radius: 6px;
  padding: 12px; font-family: var(--mono); font-size: 12px;
  white-space: pre-wrap; word-break: break-all; margin: 8px 0 0;
}
.modal-body details { margin-top: 12px; }
.modal-body summary { cursor: pointer; color: var(--accent-ink); font-size: 13px; }

/* ---------------- 轻提示 ---------------- */
.toast-root { position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: #fff; font-size: 13.5px;
  border-radius: 6px; padding: 9px 18px;
  box-shadow: 0 6px 20px rgba(20, 33, 30, .3);
  animation: toast-in .18s ease-out;
}
.toast.bad { background: #8f2f27; }
.toast.ok { background: var(--accent-deep); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------- 响应式 ---------------- */
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .brand { border: 0; padding: 12px 16px; }
  .nav-list { display: flex; flex-wrap: wrap; padding: 6px; flex: 1; }
  .nav-foot { border: 0; padding: 8px 12px; }
  .main { height: auto; overflow: visible; }
  .tab-body { overflow: visible; }
  .tabbar { padding: 8px 10px 0; }
  .page { padding: 20px 16px 48px; }
  .hero { grid-template-columns: 1fr; }
  .hero-left { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .todo-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
  .filters input, .filters select { width: 100%; }
  .filters .field { flex: 1 1 45%; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
