/* TG号码管理 · 旧站 Bootstrap 基础壳 */

:root {
  --app-bg: #f5f6fa;
  --app-nav: #212529;
  --app-accent: #7b1fa2;
  --app-surface: #ffffff;
  --app-text: #212529;
  --app-muted: #6c757d;
  --app-border: #dee2e6;
  --app-warning: #ffc107;
  --app-radius: 8px;
  --app-shadow: 0 .125rem .25rem rgba(0, 0, 0, .06);
  --bs-body-font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Arial, sans-serif;
  --bs-body-font-size: 14px;
  --bs-body-color: var(--app-text);
  --bs-body-bg: var(--app-bg);
  --bs-primary: var(--app-accent);
  --bs-primary-rgb: 123, 31, 162;
  --bs-link-color: var(--app-accent);
  --bs-link-hover-color: #5d177b;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--app-bg);
  color: var(--app-text);
  font-family: var(--bs-body-font-family);
  font-size: 14px;
}

a {
  color: var(--app-accent);
}

/* 旧站顶栏 */
.top-bar {
  background: var(--app-nav);
  padding: 8px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.top-brand {
  color: #fff;
  font-weight: 700;
  margin-right: 1rem;
  white-space: nowrap;
}

.top-bar a {
  color: rgba(255, 255, 255, .7);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 14px;
}

.top-bar a:hover,
.top-bar a.active {
  color: #fff;
  background: rgba(255, 255, 255, .12);
}

.top-user-area {
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.top-user {
  color: rgba(255, 255, 255, .5);
  font-size: 12px;
  margin-right: 8px;
}

.top-bar a.top-selfpw {
  color: rgba(255, 255, 255, .7);
  font-size: 12px;
}

.top-bar a.top-logout,
.top-bar a.top-logout:hover {
  color: var(--app-warning);
  font-size: 12px;
}

/* 全站内容容器 */
.container-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

h2 {
  margin: 0 0 16px;
  font-size: 24px;
  font-weight: 600;
}

h3,
h4 {
  color: #333;
  font-weight: 600;
}

/* 基础卡片：与旧站 .card 同步 */
.card,
article {
  background: var(--app-surface);
  border: none;
  border-radius: 8px;
  box-shadow: var(--app-shadow);
  margin-bottom: 16px;
}

article {
  padding: 16px;
}

article > h3:first-child,
article > h4:first-child,
article > header:first-child {
  margin-top: 0;
}

.card-header {
  background: #fff;
  font-weight: 600;
  border-bottom: 1px solid #eee;
}

/* 现有语义化表单在移除 Pico 后仍可用 */
form label {
  display: block;
  margin-bottom: 12px;
  font-weight: 600;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 7px 10px;
  color: var(--app-text);
  background: #fff;
  border: 1px solid #ced4da;
  border-radius: 6px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #b36acb;
  outline: 0;
  box-shadow: 0 0 0 .2rem rgba(123, 31, 162, .15);
}

button,
[type="submit"],
a[role="button"] {
  display: inline-block;
  padding: 7px 12px;
  color: #fff;
  font-weight: 600;
  background: var(--app-accent);
  border: 1px solid var(--app-accent);
  border-radius: 6px;
}

button:hover,
[type="submit"]:hover,
a[role="button"]:hover {
  color: #fff;
  background: #681a88;
  border-color: #681a88;
}

button.secondary.outline,
.secondary.outline {
  color: var(--app-muted);
  background: transparent;
  border-color: #adb5bd;
}

small {
  color: var(--app-muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

/* 基础表格 */
table {
  width: 100%;
  margin-bottom: 16px;
  color: var(--app-text);
  border-collapse: collapse;
}

table th,
table td {
  padding: 8px;
  border-bottom: 1px solid var(--app-border);
}

table th {
  font-weight: 600;
  white-space: nowrap;
}

table td {
  vertical-align: middle;
}

table code {
  color: #495057;
}

mark {
  display: inline-block;
  padding: 8px 12px;
  color: #842029;
  background: #f8d7da;
  border-radius: 6px;
}

progress {
  width: 100%;
}

/* 旧站国家胶囊与八项 KPI */
.country-btn {
  padding: 6px 20px;
  border: 2px solid #ddd;
  border-radius: 20px;
  color: #555;
  background: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.country-btn:hover {
  border-color: #7b1fa2;
  color: #7b1fa2;
  background: #fff;
}

.country-btn.active {
  border-color: #7b1fa2;
  color: #fff;
  background: #7b1fa2;
}

.country-btn.active:hover {
  border-color: #7b1fa2;
  color: #fff;
  background: #7b1fa2;
}

.country-btn small {
  color: inherit;
  opacity: .5;
}

/* 九项 KPI 必须完整显示数字。旧站用 flex + 省略号，号码池到八位数时
   会被截成 "22,204,..."，运营看不到真实库存。改成等宽栅格：宽度不够时
   整体换行而不是把数字吃掉。 */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
}

.kpi-item {
  min-width: 0;
}

.kpi {
  padding: 14px 4px;
  border-radius: 12px;
  text-align: center;
}

.kpi h3 {
  margin: 0;
  /* 字号压到八位数带千分位也能整行放下；不再用 overflow/ellipsis 截断。 */
  font-size: clamp(.8rem, 1.05vw, 1.15rem);
  font-weight: 800;
  line-height: 1.15;
  white-space: nowrap;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}

.kpi .label {
  margin-top: 4px;
  color: #666;
  font-size: 10px;
  white-space: nowrap;
}

.kpi-pool { background: #f3e5f5; }
.kpi-pool h3 { color: #7b1fa2; }
.kpi-pending { background: #ede7f6; }
.kpi-pending h3 { color: #9575cd; }
.kpi-sendable { background: #e8f5e9; }
.kpi-sendable h3 { color: #198754; }
.kpi-refilter { background: #fff3e0; }
.kpi-refilter h3 { color: #fd7e14; }
.kpi-dormant { background: #fff8e1; }
.kpi-dormant h3 { color: #f0ad4e; }
.kpi-sent { background: #e3f2fd; }
.kpi-sent h3 { color: #0dcaf0; }
.kpi-unregistered { background: #efebe9; }
.kpi-unregistered h3 { color: #a1887f; }
.kpi-inactive { background: #fbe9e7; }
.kpi-inactive h3 { color: #e0603a; }
.kpi-expired { background: #fafafa; }
.kpi-expired h3 { color: #bbb; }

/* 旧站活跃等级明细 */
.sec {
  margin: 36px 0 16px;
  padding-bottom: 6px;
  border-bottom: 2px solid #eee;
  color: #555;
  font-size: 14px;
  font-weight: 700;
}

.levels-card {
  overflow: hidden;
}

.level-row {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid #f0f0f0;
}

.level-row:last-child {
  border: none;
}

.level-row:hover {
  background: #fafafa;
}

.level-name {
  width: 70px;
  text-align: center;
}

.level-row .badge {
  min-width: 48px;
  padding: 5px 8px;
}

.level-progress {
  flex: 1 1 auto;
  margin: 0 16px;
}

.level-row .progress {
  height: 8px;
}

.level-counts {
  display: flex;
  justify-content: space-between;
  width: 240px;
  font-size: 12px;
}

.level-total {
  font-weight: 700;
}

.level-unsent {
  color: var(--app-muted);
}

.level-sent {
  color: #0dcaf0;
}

.level-summary {
  background: #f8f9fa;
  font-weight: 700;
}

.level-pending .badge,
.level-pending .progress-bar { background: #9575cd; }
.level-today .badge,
.level-today .progress-bar { background: #4caf50; }
.level-d3 .badge,
.level-d3 .progress-bar { background: #ff9800; }
.level-d7 .badge,
.level-d7 .progress-bar { background: #ff9800; }
.level-d30 .badge,
.level-d30 .progress-bar { background: #ff9800; }
.level-d90 .badge,
.level-d90 .progress-bar { background: #f0ad4e; }
.level-inactive .badge,
.level-inactive .progress-bar { background: #e0603a; }
.level-unregistered .badge,
.level-unregistered .progress-bar { background: #a1887f; }
.level-expired .badge,
.level-expired .progress-bar { background: #ccc; }

.board-toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
}

.board-toolbar label {
  margin: 0;
}

.board-refresh-note {
  display: block;
  margin-top: 12px;
}

/* 旧站工作台导入卡片 */
.imp-card {
  overflow: hidden;
  background: #fff;
  border-radius: 12px;
}

.imp-card .hd {
  padding: 12px 16px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.imp-card .bd {
  padding: 16px;
}

.imp-raw .hd { background: #9575cd; }
.imp-results .hd { background: #4caf50; }
.imp-source .hd { background: #a1887f; }
.imp-sent .hd { background: #42a5f5; }

.dashboard-country {
  display: none !important;
}

.drop {
  margin-top: 8px;
  padding: 22px 10px;
  border: 2px dashed #d0d0d0;
  border-radius: 10px;
  color: #6c757d;
  text-align: center;
  cursor: pointer;
}

.drop:hover {
  border-color: #7b1fa2;
  background: #f9f0ff;
}

/* 旧站工作台导出卡片 */
.export-limit-bar select {
  width: 130px;
  margin-top: 0;
}

.export-limit-bar input {
  width: 140px;
  margin-top: 0;
}

.exp-card {
  padding: 20px;
  border: 2px solid;
  border-radius: 12px;
}

.exp-title {
  margin-bottom: 4px;
  font-size: 1.25rem;
  font-weight: 700;
}

.exp-count {
  font-size: 1.75rem;
  font-weight: 700;
}

.exp-send {
  background: #e8f5e9;
  border-color: #4caf50;
}

.exp-send .exp-title,
.exp-send .exp-count { color: #198754; }

.exp-send .btn {
  background: #198754;
  border-color: #198754;
}

.exp-first {
  background: #ede7f6;
  border-color: #9575cd;
}

.exp-first .exp-title,
.exp-first .exp-count,
.batch-label,
#rawBatchRem { color: #7b1fa2; }

.batch-label {
  white-space: nowrap;
}

.exp-first-button {
  color: #fff;
  background: #9575cd;
  border-color: #9575cd;
}

.exp-refilter {
  background: #fff3e0;
  border-color: #ff9800;
}

.exp-refilter .exp-title,
.exp-refilter .exp-count { color: #ff9800; }

.exp-refilter .btn {
  color: #212529;
  background: #ffc107;
  border-color: #ffc107;
}

.exp-sent {
  background: #e3f2fd;
  border-color: #1e88e5;
}

.exp-sent .exp-title,
.sent-total { color: #1565c0; }

.exp-sent .btn-primary {
  color: #fff;
  background: #0d6efd;
  border-color: #0d6efd;
}

.exp-sent .btn-outline-primary {
  color: #0d6efd;
  background: transparent;
  border-color: #0d6efd;
}

/* 回收失活导出卡：可回收暖橙，区别于已销号灰与休眠 #fff8e1 */
.exp-inactive {
  background: #fbe9e7;
  border-color: #e0603a;
}

.exp-inactive .exp-title,
.exp-inactive .exp-count { color: #e0603a; }

.exp-inactive .btn {
  color: #fff;
  background: #e0603a;
  border-color: #e0603a;
}

.refilter-tiers label,
.refilter-cooldown-row label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  font-weight: 400;
}

#rawBatchSel {
  min-width: 150px;
  margin-top: 0;
  font-size: 12px;
}

#excludeDays {
  width: 60px;
  margin-top: 0;
}

.mark-card {
  border: 1px dashed #a1887f;
}

.mark-title {
  color: #a1887f;
}

/* 登录页 */
.login-card {
  max-width: 384px;
  margin: 8vh auto 0;
}

.login-card h2,
.login-brand {
  text-align: center;
}

.login-brand {
  color: var(--app-muted);
  margin-bottom: 20px;
}

@media (max-width: 768px) {
  .top-bar,
  .top-bar-left,
  .top-user-area {
    flex-wrap: wrap;
  }

  .top-bar {
    gap: 8px;
    padding: 8px 12px;
  }

  .top-brand {
    width: 100%;
  }

  .top-bar a {
    padding: 6px 8px;
  }

  .container-main {
    padding: 16px;
  }

  /* 活跃等级明细：桌面是「等级 | 进度条 | 三个数字」一行摆平，
     但右侧计数固定 240px，窄屏上会把进度条挤没并撑出横向滚动。
     窄屏改成两行：上行等级+计数，下行整条进度条。 */
  .level-row {
    flex-wrap: wrap;
    padding: 10px 12px;
  }

  .level-progress {
    order: 3;
    flex: 1 0 100%;
    margin: 8px 0 0;
  }

  .level-counts {
    width: auto;
    flex: 1 1 auto;
    gap: 12px;
    justify-content: flex-end;
  }

  /* KPI 九宫格在窄屏改成两列，数字不再被挤成省略号 */
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* 导入四卡与导出五卡在窄屏各占整行 */
  .imp-card,
  .exp-card {
    height: auto;
  }

  /* 表格类页面（批次记录/设置/账号）横向可滚，不撑破页面 */
  .table-responsive-narrow {
    overflow-x: auto;
  }
}

/* 友好错误页：居中卡片，只放中文人话 + 返回入口 */
.error-wrap {
  display: flex;
  justify-content: center;
  padding: 40px 0;
}

.error-card {
  width: 100%;
  max-width: 520px;
  padding: 32px 28px;
  text-align: center;
}

.error-icon {
  font-size: 40px;
  line-height: 1;
  color: var(--app-accent);
}

.error-code {
  margin-top: 8px;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--app-muted);
}

.error-title {
  margin: 10px 0 8px;
  font-size: 20px;
  font-weight: 600;
}

.error-msg {
  margin: 0 0 22px;
  line-height: 1.8;
  color: var(--app-muted);
}

/* 顶栏代理切换：深色顶栏上的浅色小控件，宽度跟着内容走但有上限，
   免得代理名一长就把用户名和退出挤出去。 */
.top-agent-switch {
  width: auto;
  max-width: 200px;
  height: 28px;
  padding: 2px 24px 2px 8px;
  font-size: 12px;
  background-color: rgba(255, 255, 255, .12);
  border-color: rgba(255, 255, 255, .25);
  color: #fff;
}

.top-agent-switch option {
  color: #212529;
}

/* 超管总览表：一眼看全部代理的家底 */
.agent-overview td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
