/* ==========================================================================
   后台管理样式
   ========================================================================== */
:root {
  --brand: #0B4F9E;
  --brand-dark: #083a75;
  --brand-light: #E8F0FA;
  --accent: #F5A623;
  --bg: #F2F5F9;
  --surface: #FFFFFF;
  --text: #182130;
  --text-2: #5A6675;
  --text-3: #8A94A6;
  --border: #E1E7EF;
  --ok: #0E7C5A;
  --warn: #B26A00;
  --danger: #C0392B;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(20, 40, 80, .07);
  --shadow-lg: 0 16px 48px rgba(20, 40, 80, .16);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }

/* ------------------------------------------------------------------ 登录 */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 420px at 10% 0%, rgba(11, 79, 158, .12), transparent 60%),
    radial-gradient(700px 380px at 90% 100%, rgba(245, 166, 35, .13), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 18px;
  box-shadow: var(--shadow-lg); padding: 38px 34px 32px; border: 1px solid var(--border);
}
.login-card .logo-mark {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff; font-weight: 800; font-size: 17px; margin-bottom: 18px;
  box-shadow: 0 6px 18px rgba(11, 79, 158, .3);
}
.login-card h1 { font-size: 21px; margin: 0 0 6px; font-weight: 750; }
.login-card p.hint { color: var(--text-3); font-size: 13.5px; margin: 0 0 26px; }

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

.side {
  width: 226px; flex-shrink: 0; background: #101A28; color: #C3CDDC;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.side-head { padding: 22px 20px 20px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.side-head .logo-line { display: flex; align-items: center; gap: 10px; }
.side-head .logo-mark {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), #1a7ad4); color: #fff;
  font-weight: 800; font-size: 13.5px;
}
.side-head b { color: #fff; font-size: 14px; display: block; line-height: 1.3; }
.side-head span { color: #6E7C91; font-size: 11px; letter-spacing: .5px; }

.side-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.side-nav .nav-group {
  font-size: 10.5px; letter-spacing: 1.2px; color: #5A6678; text-transform: uppercase;
  padding: 14px 12px 6px; font-weight: 700;
}
.side-nav .nav-group:first-child { padding-top: 4px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 9px; color: #B4C0D2; text-decoration: none; font-size: 13.5px;
  margin-bottom: 3px; transition: .14s; cursor: pointer;
}
.side-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-nav a.active { background: var(--brand); color: #fff; font-weight: 600; }
.side-nav a .ic { width: 17px; text-align: center; font-size: 15px; }
.side-nav a .badge {
  margin-left: auto; background: rgba(255, 255, 255, .16); border-radius: 999px;
  font-size: 11px; padding: 1px 8px; font-weight: 600;
}
.side-nav a.active .badge { background: rgba(255, 255, 255, .28); }

.side-foot { padding: 14px 16px 18px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 12px; color: #6E7C91; }
.side-foot button {
  width: 100%; margin-top: 10px; background: rgba(255, 255, 255, .08); color: #D6DEEA;
  border: none; border-radius: 8px; padding: 9px; cursor: pointer; font-family: inherit; font-size: 13px;
}
.side-foot button:hover { background: rgba(255, 255, 255, .16); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 16px 28px; display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { margin: 0; font-size: 18px; font-weight: 700; }
.topbar .sub { color: var(--text-3); font-size: 13px; margin-left: 4px; font-weight: 400; }
.topbar .right { margin-left: auto; display: flex; gap: 10px; align-items: center; }

.content { padding: 24px 28px 60px; flex: 1; }
.page { display: none; }
.page.active { display: block; animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ 卡片 */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px;
}
.card-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

/* ------------------------------------------------------------------ 统计 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; position: relative; overflow: hidden;
}
.stat::after {
  content: ''; position: absolute; right: -18px; top: -18px; width: 64px; height: 64px;
  border-radius: 50%; background: var(--brand-light); opacity: .7;
}
.stat .lb { font-size: 12.5px; color: var(--text-3); position: relative; z-index: 1; }
.stat .vl { font-size: 27px; font-weight: 800; letter-spacing: -.6px; margin-top: 4px; position: relative; z-index: 1; }
.stat .vl.g { color: var(--ok); }
.stat .vl.b { color: var(--brand); }
.stat .vl.o { color: var(--warn); }
.stat .vl.r { color: var(--danger); }

/* ------------------------------------------------------------------ 表单 */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.8px; color: var(--text-2); font-weight: 600; }
.field label .req { color: var(--danger); }
.field .tip { font-size: 11.5px; color: var(--text-3); font-weight: 400; }

input[type=text], input[type=password], input[type=number], input[type=datetime-local],
input[type=date], select, textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; font-size: 14px; font-family: inherit; color: var(--text);
  background: #fff; outline: none; transition: .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
textarea { resize: vertical; min-height: 74px; line-height: 1.55; }
input[type=color] { width: 100%; height: 38px; padding: 3px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; }

.btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 8px; padding: 9px 17px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: .15s; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }
.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff; border-color: transparent; box-shadow: 0 3px 12px rgba(11, 79, 158, .25);
}
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.danger { color: var(--danger); border-color: #F0C9C4; }
.btn.danger:hover { background: #FDF2F1; color: var(--danger); border-color: var(--danger); }
.btn.sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; padding: 12px 16px; background: #F8FAFC;
  border-bottom: 1px solid var(--border); font-weight: 650; color: var(--text-2);
  font-size: 12.5px; white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid #F0F3F7; vertical-align: middle; }
tbody tr:hover { background: #FAFCFE; }
tbody tr:last-child td { border-bottom: none; }
.mono { font-family: var(--mono); letter-spacing: .3px; font-weight: 600; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 650; color: #fff; white-space: nowrap;
}
.pill.gray { background: #8A94A6; }
.pill.blue { background: var(--brand); }
.pill.green { background: var(--ok); }
.pill.orange { background: var(--warn); }
.pill.red { background: var(--danger); }
.pill.soft { background: var(--brand-light); color: var(--brand); }

.bar-mini { width: 78px; height: 6px; background: #EDF1F6; border-radius: 999px; overflow: hidden; display: inline-block; vertical-align: middle; }
.bar-mini i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--accent)); }

.empty { padding: 52px 20px; text-align: center; color: var(--text-3); }
.empty .big { font-size: 34px; margin-bottom: 10px; opacity: .5; }

/* ------------------------------------------------------------------ 提示 */
.toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 999; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: #101A28; color: #fff; padding: 12px 18px; border-radius: 10px;
  font-size: 13.5px; box-shadow: var(--shadow-lg); max-width: 380px;
  animation: slidein .22s ease; border-left: 3px solid var(--brand);
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
@keyframes slidein { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 26, 40, .5);
  display: grid; place-items: center; z-index: 200; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 780px;
  max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: pop .2s ease;
}
.modal.wide { max-width: 980px; }
.modal.narrow { max-width: 460px; }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(8px); } to { opacity: 1; transform: none; } }
.modal-head {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-head .x {
  margin-left: auto; background: none; border: none; font-size: 22px; cursor: pointer;
  color: var(--text-3); line-height: 1; padding: 0 4px;
}
.modal-head .x:hover { color: var(--text); }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ------------------------------------------------------------------ 地址解析结果 */
.parse-box {
  background: var(--brand-light); border: 1px solid rgba(11, 79, 158, .18);
  border-radius: 9px; padding: 13px 15px; font-size: 13.5px; margin-top: 9px;
}
.parse-box.ok { background: #EAF7F1; border-color: rgba(14, 124, 90, .22); }
.parse-box.warn { background: #FFF8E9; border-color: rgba(178, 106, 0, .25); }
.parse-box b { color: var(--brand); }
.parse-box.ok b { color: var(--ok); }
.parse-box.warn b { color: var(--warn); }
.parse-box .kw { font-size: 12px; color: var(--text-2); margin-top: 4px; }

/* 单号预览 */
.tn-preview {
  background: #101A28; color: #fff; border-radius: 11px; padding: 18px 20px;
  font-family: var(--mono); font-size: 24px; letter-spacing: 2px; text-align: center;
  margin-top: 6px; font-weight: 700;
}
.tn-preview.small { font-size: 17px; padding: 12px; letter-spacing: 1.2px; }
.tn-legend { display: flex; justify-content: center; gap: 0; flex-wrap: wrap; font-size: 11.5px; color: var(--text-3); margin-top: 8px; }
.tn-legend span { font-family: var(--mono); padding: 0 6px; border-left: 1px solid var(--border); }
.tn-legend span:first-child { border-left: none; }
.tn-legend span i { display: block; font-style: normal; font-family: inherit; color: var(--brand); font-weight: 700; }

/* ------------------------------------------------------------------ 时间轴（后台） */
.admin-tl { position: relative; }
.admin-tl .ti { position: relative; padding: 0 0 20px 26px; }
.admin-tl .ti::before {
  content: ''; position: absolute; left: 5px; top: 14px; bottom: 0; width: 2px; background: var(--border);
}
.admin-tl .ti:last-child::before { display: none; }
.admin-tl .ti.reached::before { background: var(--ok); }
.admin-tl .dot {
  position: absolute; left: 0; top: 5px; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 2px solid var(--border); z-index: 1;
}
.admin-tl .ti.reached .dot { background: var(--ok); border-color: var(--ok); }
.admin-tl .ti.planned .dot { border-style: dashed; }
.admin-tl .ti.custom .dot { background: var(--accent); border-color: var(--accent); }
.admin-tl .ti .tm { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.admin-tl .ti .tx { font-size: 13.8px; font-weight: 600; }
.admin-tl .ti.planned .tx { color: var(--text-3); font-weight: 500; }
.admin-tl .ti .lc { font-size: 12px; color: var(--text-3); }

/* ------------------------------------------------------------------ 其他 */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type=text] { max-width: 260px; }
.toolbar select { max-width: 190px; }

.brand-swatch { width: 26px; height: 26px; border-radius: 7px; display: inline-block; vertical-align: middle; border: 1px solid rgba(0, 0, 0, .08); }

.help-text { font-size: 12.5px; color: var(--text-3); line-height: 1.7; }
.help-text code { background: #F1F4F8; border-radius: 4px; padding: 1px 6px; font-family: var(--mono); font-size: 12px; color: var(--brand); }

@media (max-width: 860px) {
  .side { position: fixed; left: 0; top: 0; z-index: 100; transform: translateX(-100%); transition: .22s; }
  .side.open { transform: none; }
  .content { padding: 16px 14px 50px; }
  .topbar { padding: 14px 16px; }
  .menu-btn { display: inline-flex !important; }
}
.menu-btn { display: none; }
.backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; }
.backdrop.on { display: block; }

/* ------------------------------------------------------------------ Tab */
.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tab-bar button {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 9px 15px; font-size: 13.5px; font-weight: 600; color: var(--text-2);
  cursor: pointer; font-family: inherit; transition: .15s; margin-bottom: -1px;
}
.tab-bar button:hover { color: var(--brand); }
.tab-bar button.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ------------------------------------------------------------------ 对接卡片 */
.itg-card {
  border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px;
  margin-bottom: 12px; background: #fff; display: flex; gap: 16px; align-items: flex-start;
  flex-wrap: wrap;
}
.itg-card.off { opacity: .62; background: #FAFBFC; }
.itg-icon {
  width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 18px;
  background: var(--brand-light); color: var(--brand);
}
.itg-main { flex: 1; min-width: 220px; }
.itg-main b { font-size: 15px; display: block; margin-bottom: 3px; }
.itg-main .sub { font-size: 12.5px; color: var(--text-3); line-height: 1.6; }
.itg-stats { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--text-2); }
.itg-stats b { color: var(--text); font-size: 13.5px; }
.itg-actions { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }

.webhook-box {
  background: #101A28; color: #7FD8A8; font-family: var(--mono); font-size: 12px;
  padding: 11px 13px; border-radius: 8px; word-break: break-all; margin-top: 10px; line-height: 1.5;
}
.webhook-box span { color: #6E7C91; }

/* ------------------------------------------------------------------ 迷你指标 */
.mini-stats { display: flex; gap: 22px; flex-wrap: wrap; }
.mini-stats > div { font-size: 12.5px; color: var(--text-3); }
.mini-stats > div b { display: block; font-size: 19px; font-weight: 800; color: var(--text); letter-spacing: -.3px; }
.mini-stats > div b.g { color: var(--ok); }
.mini-stats > div b.b { color: var(--brand); }
.mini-stats > div b.o { color: var(--warn); }
.mini-stats > div b.r { color: var(--danger); }

/* ------------------------------------------------------------------ 报价卡 */
.rate-item {
  border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px;
  margin-bottom: 10px; background: #fff;
}
.rate-item .rt-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rate-item .rt-head b { font-size: 14.5px; }
.rate-item .rt-body { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin-top: 8px; }
.rate-item .rt-body em { font-style: normal; color: var(--text-3); }

/* 计费明细 */
.charge-line {
  display: flex; justify-content: space-between; padding: 7px 0;
  border-bottom: 1px dashed var(--border); font-size: 13.5px;
}
.charge-line:last-child { border-bottom: none; }
.charge-total {
  display: flex; justify-content: space-between; padding: 12px 0 0;
  margin-top: 8px; border-top: 2px solid var(--brand); font-weight: 700; font-size: 16px;
}
.charge-total span:last-child { color: var(--brand); }

/* 筛选条里的日期 */
.toolbar input[type=date] { max-width: 155px; }
