:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #101828;
  --ink-2: #475467;
  --ink-3: #98a2b3;
  --line: #e6eaf0;
  --brand: #2563eb;
  --brand-soft: #eff4ff;
  --green: #12b76a;
  --green-soft: #ecfdf3;
  --orange: #f79009;
  --orange-soft: #fffaeb;
  --red: #f04438;
  --red-soft: #fef3f2;
  --grey-soft: #f2f4f7;
  --radius: 12px;
  --sidebar: #0d1526;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* ---------- 登录 ---------- */

.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 460px at 15% 0%, #dbe7ff 0%, transparent 60%),
    radial-gradient(700px 420px at 100% 100%, #e6f4ff 0%, transparent 55%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 18px 50px -24px rgba(16, 24, 40, .35);
}

.login-brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.3px;
  margin: 0 0 4px;
}

.login-brand span { color: var(--brand); }

.login-sub {
  color: var(--ink-3);
  font-size: 13px;
  margin: 0 0 22px;
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.input, select.input, textarea.input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 9px 11px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 16px;
  font-weight: 600;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  transition: filter .15s, background .15s;
}

.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-block { width: 100%; }

.btn-ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--ink-2);
}

.btn-ghost:hover { background: var(--grey-soft); }

.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }

.btn-danger { background: var(--red); }

.btn-soft {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: #dbe6ff;
}

/* ---------- 布局 ---------- */

.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  color: #cbd5e1;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  padding: 4px 10px 18px;
  letter-spacing: -.2px;
}

.sidebar .brand span { color: #60a5fa; }

.sidebar .brand em {
  font-style: normal;
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  background: #1e293b;
  padding: 2px 6px;
  border-radius: 5px;
  margin-left: 6px;
  vertical-align: 2px;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav button {
  text-align: left;
  background: transparent;
  border: 0;
  color: #94a3b8;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
}

.nav button:hover { background: #16203a; color: #e2e8f0; }

.nav button.active {
  background: #1c2a4a;
  color: #fff;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px #2a3d66;
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px 10px 0;
  border-top: 1px solid #1e293b;
  font-size: 12px;
  color: #7c8ba3;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-foot .whom {
  color: #cbd5e1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-foot button {
  background: transparent;
  border: 1px solid #2a3d66;
  color: #94a3b8;
  border-radius: 7px;
  padding: 6px 10px;
  cursor: pointer;
}

.sidebar-foot button:hover { color: #fff; border-color: #3d5a92; }

.main {
  padding: 26px 30px 60px;
  min-width: 0;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-head h1 {
  font-size: 21px;
  margin: 0 0 4px;
  letter-spacing: -.3px;
}

.page-head p { margin: 0; color: var(--ink-3); font-size: 13px; }

/* ---------- 卡片 / 统计 ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
}

.stat .label { font-size: 12px; color: var(--ink-3); margin-bottom: 8px; }

.stat .value {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -.6px;
  font-variant-numeric: tabular-nums;
}

.stat .value small { font-size: 13px; font-weight: 600; color: var(--ink-3); margin-left: 4px; }

.stat.accent { background: linear-gradient(180deg, #f7faff, #fff); border-color: #dbe6ff; }
.stat.accent .value { color: var(--brand); }
.stat.warn .value { color: var(--orange); }
.stat.bad .value { color: var(--red); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.card-head h2 { font-size: 14px; margin: 0; }

.card-body { padding: 16px; }

/* ---------- 表格 ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar .input { width: auto; min-width: 180px; }

.table-scroll { overflow-x: auto; }

table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

table.grid th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-3);
  font-weight: 600;
  padding: 10px 14px;
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
}

table.grid td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f4f8;
  vertical-align: middle;
}

table.grid tbody tr:hover { background: #fbfcfe; }
table.grid tbody tr:last-child td { border-bottom: 0; }

.cell-strong { font-weight: 600; }
.cell-sub { color: var(--ink-3); font-size: 12px; }
.cell-num { font-variant-numeric: tabular-nums; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--grey-soft);
  color: var(--ink-2);
}

.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge.active { background: var(--green-soft); color: #067647; }
.badge.paused { background: var(--grey-soft); color: #667085; }
.badge.expired { background: var(--orange-soft); color: #b54708; }
.badge.banned { background: var(--red-soft); color: #b42318; }
.badge.plan { background: var(--brand-soft); color: var(--brand); }
.badge.plan.free { background: var(--grey-soft); color: var(--ink-2); }
.badge.plan.pro { background: #f4ebff; color: #6941c6; }
.badge.plan.enterprise { background: #fff3d6; color: #a15c00; }

.progress {
  width: 92px;
  height: 5px;
  background: #eef2f7;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 5px;
}

.progress > i {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
}

.progress.warn > i { background: var(--orange); }
.progress.bad > i { background: var(--red); }

.row-actions { display: flex; gap: 6px; }

.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--ink-3);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-3);
}

.pager .pages { display: flex; gap: 4px; }

.pager button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  min-width: 30px;
  padding: 5px 8px;
  cursor: pointer;
  color: var(--ink-2);
}

.pager button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager button:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 图表 ---------- */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 150px;
  padding: 8px 2px 0;
}

.chart .bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.chart .bar {
  width: 100%;
  max-width: 34px;
  background: linear-gradient(180deg, #6ea0ff, #2563eb);
  border-radius: 5px 5px 3px 3px;
  min-height: 3px;
  transition: height .3s;
}

.chart .x { font-size: 10px; color: var(--ink-3); white-space: nowrap; }

/* ---------- 弹窗 ---------- */

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal-back.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 70px -20px rgba(16, 24, 40, .5);
}

.modal-head {
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.modal-head h3 { margin: 0 0 3px; font-size: 16px; }
.modal-head p { margin: 0; font-size: 12.5px; color: var(--ink-3); }

.modal-body { padding: 18px 20px; overflow: auto; }

.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid .full { grid-column: 1 / -1; }

.hint { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }

.divider {
  grid-column: 1 / -1;
  border-top: 1px dashed var(--line);
  margin: 4px 0;
}

.section-label {
  grid-column: 1 / -1;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-top: 2px;
}

/* ---------- 代理商品 ---------- */

.proxy-summary {
  border: 1px solid #dbe6ff;
  background: #f7faff;
  border-radius: 9px;
  padding: 10px 12px;
}

.proxy-summary-main { font-weight: 600; font-size: 13px; color: var(--ink); }

.proxy-summary-sub { font-size: 12px; color: var(--ink-3); margin-top: 4px; line-height: 1.6; }

.plan-region {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}

.plan-region-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fafbfd;
}

.plan-region-head h3 {
  margin: 0 0 3px;
  font-size: 14.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.plan-region-head p {
  margin: 0;
  font-size: 12px;
  color: var(--ink-3);
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
  gap: 12px;
  padding: 14px 16px 16px;
}

.plan-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 14px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow .15s, border-color .15s, transform .15s;
}

.plan-card:hover {
  border-color: #cfdcf5;
  box-shadow: 0 10px 24px -18px rgba(16, 24, 40, .55);
  transform: translateY(-1px);
}

.plan-card.off { opacity: .62; }

.plan-card .flag {
  position: absolute;
  top: -1px;
  right: 12px;
  background: linear-gradient(180deg, #2563eb, #1d4ed8);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 0 0 6px 6px;
  letter-spacing: .02em;
}

.plan-card .flag.hot { background: linear-gradient(180deg, #f79009, #dc6803); }
.plan-card .flag.neu { background: linear-gradient(180deg, #12b76a, #039855); }

.plan-card .pname { font-weight: 650; font-size: 13.5px; padding-right: 42px; }

.plan-card .price {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.7px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.plan-card .price small {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  margin-left: 2px;
  letter-spacing: 0;
}

.plan-card .feats {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.plan-card .feats li {
  font-size: 12px;
  color: var(--ink-2);
  padding-left: 14px;
  position: relative;
  line-height: 1.45;
}

.plan-card .feats li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brand);
  opacity: .7;
}

.plan-card .meta {
  font-size: 11.5px;
  color: var(--ink-3);
  border-top: 1px dashed var(--line);
  padding-top: 8px;
  margin-top: auto;
  line-height: 1.6;
}

.plan-card .foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.plan-card .foot .cell-sub { font-size: 11.5px; }

/* ---------- Toast ---------- */

#toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
}

.toast {
  background: #101828;
  color: #fff;
  padding: 10px 15px;
  border-radius: 9px;
  font-size: 13px;
  box-shadow: 0 12px 30px -12px rgba(16, 24, 40, .6);
  animation: toast-in .18s ease-out;
}

.toast.error { background: #b42318; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .main { padding: 18px; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════════
 * 订单：侧栏角标 / 状态 tabs / 概要卡片 / 处理弹窗
 * ══════════════════════════════════════════════════════════════ */

.nav button { position: relative; }

.nav-badge {
  display: inline-block;
  min-width: 18px;
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  vertical-align: 1px;
}

.nav button.active .nav-badge { background: #fff; color: #1c2a4a; }

.order-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.order-kpis .kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.order-kpis .kpi .label { font-size: 12px; color: var(--ink-3); }
.order-kpis .kpi .value { font-size: 22px; font-weight: 700; margin-top: 4px; letter-spacing: -0.5px; }
.order-kpis .kpi.warn .value { color: var(--orange); }
.order-kpis .kpi.bad .value { color: var(--red); }
.order-kpis .kpi.good .value { color: var(--green); }

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 16px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.tabs button {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  padding: 7px 12px;
  border-radius: 8px 8px 0 0;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tabs button:hover { color: var(--ink); background: var(--grey-soft); }

.tabs button.active {
  color: var(--brand);
  font-weight: 600;
  border-bottom-color: var(--brand);
  background: transparent;
}

.badge.pending { background: var(--orange-soft); color: #b54708; }
.badge.processing { background: var(--brand-soft); color: var(--brand); }
.badge.fulfilled { background: var(--green-soft); color: #067647; }
.badge.rejected { background: var(--red-soft); color: #b42318; }
.badge.cancelled { background: var(--grey-soft); color: #667085; }

.kind-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  background: var(--grey-soft);
  color: var(--ink-2);
}

.kind-tag.proxy { background: var(--brand-soft); color: var(--brand); }
.kind-tag.subscription { background: #f4ebff; color: #6941c6; }
.kind-tag.credits { background: var(--green-soft); color: #067647; }

.order-summary {
  border: 1px solid var(--line);
  background: #f9fafc;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.order-summary-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.order-summary-no {
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.order-summary-name {
  font-size: 15px;
  font-weight: 650;
  margin-top: 2px;
}

.order-summary-price {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
  white-space: nowrap;
}

.order-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px 18px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.order-summary-grid b { color: var(--ink); font-weight: 600; }

.order-summary-note {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.6;
  white-space: pre-wrap;
}

.inline-field {
  display: flex;
  gap: 6px;
  align-items: center;
}

.inline-field .input { flex: 1; }

.order-warn {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--orange-soft);
  border: 1px solid #fedf89;
  color: #b54708;
  font-size: 12.5px;
  line-height: 1.6;
}

.order-warn.is-error {
  background: var(--red-soft);
  border-color: #fecdca;
  color: #b42318;
}

.order-feedback {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--green-soft);
  border: 1px solid #abefc6;
  color: #067647;
  font-size: 12.5px;
  line-height: 1.6;
}

.order-modal-foot {
  justify-content: space-between;
}

.order-modal-foot .row-actions { display: flex; gap: 8px; }

.order-days-hint { font-size: 11.5px; color: var(--ink-3); }

/* ---------- 代理专线 ---------- */

.line-body { display: flex; flex-direction: column; gap: 8px; }

.line-row {
  display: grid;
  grid-template-columns: minmax(200px, 1.7fr) minmax(230px, 1fr) 92px 74px;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.line-row.is-off { opacity: .5; }

.line-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.line-main b { font-size: 13px; color: var(--ink); font-weight: 600; }
.line-main .cell-sub { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.line-price { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); }
.line-price b { color: var(--ink-2); font-weight: 600; }
.line-price-input { width: 78px; padding: 4px 8px; font-size: 12px; }

.line-stock { font-size: 12px; color: var(--ink-3); }
.line-ops { display: flex; justify-content: flex-end; }

@media (max-width: 900px) {
  .line-row { grid-template-columns: 1fr; gap: 6px; }
  .line-ops { justify-content: flex-start; }
}

#btn-line-sync { white-space: nowrap; }
