/* 巨量多账户管理后台 - 统一 UI v3 */
:root {
  --primary: #1677ff;
  --primary-hover: #0958d9;
  --danger: #ff4d4f;
  --success: #52c41a;
  --warn: #faad14;
  --bg: #f0f2f5;
  --card: #fff;
  --border: #e8e8e8;
  --text: #262626;
  --muted: #8c8c8c;
  --header: #001529;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5715;
  font-size: 14px;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
.app-header a { color: inherit; }
.app-header a:hover { color: #fff; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.app-header {
  background: var(--header);
  color: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.app-brand {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.app-nav { display: flex; gap: 4px; flex-wrap: wrap; }

.app-nav .nav-item {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}

.app-nav .nav-item:hover,
.app-nav .nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.app-main {
  flex: 1;
  max-width: 1160px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

/* 页面标题 */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--text);
}

.page-header .desc {
  font-size: 13px;
  color: var(--muted);
  max-width: 680px;
  line-height: 1.6;
}

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 16px;
}

.card > h2 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.card-head h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-head .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 400;
}

.card-body-tight { margin-top: -4px; }

/* 工具栏 / 操作区 */
.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.page-actions {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: center;
}

/* 表单 */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px 16px;
  margin-bottom: 4px;
}

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
}

.form-group .hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.5;
}

.radio-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.radio-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
  margin: 0;
}

/* 账户选择器 */
.account-picker {
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 240px;
  overflow: auto;
  background: #fafafa;
}

.account-picker table { margin: 0; background: #fff; }

.account-picker th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fafafa;
}

.account-picker .empty-hint {
  padding: 24px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  background: #fff;
}

/* 表格 */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
  max-height: 520px;
  background: #fff;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th, td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  background: #fafafa;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafafa; }

th:first-child, td:first-child { width: 44px; text-align: center; }

/* 徽章 */
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 20px;
  border: 1px solid transparent;
  font-weight: 500;
}

.badge-success { background: #f6ffed; color: #389e0d; border-color: #b7eb8f; }
.badge-danger { background: #fff2f0; color: #cf1322; border-color: #ffccc7; }
.badge-info { background: #e6f7ff; color: #096dd9; border-color: #91d5ff; }
.badge-warn { background: #fff7e6; color: #d46b08; border-color: #ffd591; }
.badge-default { background: #fafafa; color: #666; border-color: #d9d9d9; }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  line-height: 1.4;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { opacity: 0.92; color: #fff; }

.btn-default { background: #fff; color: var(--text); border-color: #d9d9d9; }
.btn-default:hover:not(:disabled) { color: var(--primary); border-color: var(--primary); }

.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  padding: 0;
  cursor: pointer;
  font-size: 13px;
}

/* 提示框 */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.5;
}

.alert-success { background: #f6ffed; color: #389e0d; border: 1px solid #b7eb8f; }
.alert-error { background: #fff2f0; color: #cf1322; border: 1px solid #ffccc7; }
.alert-warn { background: #fffbe6; color: #ad6800; border: 1px solid #ffe58f; }
.alert-info { background: #e6f7ff; color: #096dd9; border: 1px solid #91d5ff; }

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
  font-size: 13px;
}

/* 进度 / 结果 */
.progress-bar {
  height: 6px;
  background: #f0f0f0;
  border-radius: 3px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-bar .fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s;
  border-radius: 3px;
}

.progress-text { font-size: 12px; color: var(--muted); }

.progress-panel {
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafafa;
}

.result-box {
  background: #fafafa;
  padding: 14px 16px;
  border-radius: 8px;
  margin-top: 12px;
  font-size: 13px;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--border);
  line-height: 1.6;
}

.result-success { border-left: 3px solid var(--success); }
.result-fail { border-left: 3px solid var(--danger); }

/* 分页 */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

.pager-info { font-size: 12px; color: var(--muted); }
.pager-size { display: flex; align-items: center; }
.pager-size select {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 12px;
}
.pager-btns { display: flex; gap: 4px; }

.pager-btns button {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid #d9d9d9;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}

.pager-btns button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.pager-btns button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Toast / Modal */
.toast-container {
  position: fixed;
  top: 72px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 16px;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  max-width: 360px;
}

.toast-success { background: #389e0d; }
.toast-error { background: #cf1322; }
.toast-info { background: #096dd9; }
.toast-warn { background: #d46b08; }

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-mask.show { display: flex; }

.modal-box {
  background: #fff;
  border-radius: 10px;
  width: 400px;
  max-width: 92vw;
  padding: 24px;
  border: 1px solid var(--border);
}

.modal-box h3 { margin: 0 0 8px; font-size: 16px; }
.modal-box p { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.loading {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #ddd;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* 统计 / 导航卡片 */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}

.stat-card .label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-card .value { font-size: 22px; font-weight: 600; color: var(--primary); margin-top: 6px; }
.stat-card .hint { font-size: 12px; color: var(--muted); margin: 8px 0 14px; line-height: 1.5; }

.nav-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 140px;
}

.flex { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* Auth 弹窗 / Tab */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
  background: #fff;
  border-radius: 10px;
  width: 900px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 15px; font-weight: 600; margin: 0; }

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

.modal-body { flex: 1; overflow: auto; padding: 20px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: #fafafa;
  border-radius: 0 0 10px 10px;
}

.modal-tabs, .page-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.modal-tab, .page-tab {
  padding: 10px 18px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
}

.modal-tab.active, .page-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.tab-content, .page-tab-content { display: none; }
.tab-content.active, .page-tab-content.active { display: block; }

.tip-bar {
  background: #fffbe6;
  border: 1px solid #ffe58f;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.import-textarea {
  width: 100%;
  min-height: 240px;
  padding: 12px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  font-size: 13px;
  font-family: ui-monospace, Consolas, monospace;
  resize: vertical;
}

.sub-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
}

.sub-modal-overlay.active { display: flex; }

.sub-modal {
  background: #fff;
  border-radius: 10px;
  width: 800px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
}

.status-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.status-badge.authorized { background: #f6ffed; color: #389e0d; }
.status-badge.unauthorized { background: #fff2f0; color: #cf1322; }

/* Auth 专用 */
.import-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.import-count .num, .import-total .num { color: var(--danger); font-weight: 600; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.search-box input { flex: 1; }

.expand-area {
  background: #fafafa;
  border-radius: 8px;
  padding: 16px;
  margin-top: 8px;
  border: 1px solid var(--border);
}

/* 响应式 */
@media (max-width: 768px) {
  .app-header {
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    padding: 12px 16px;
  }

  .app-main { padding: 16px; }

  .page-header h1 { font-size: 18px; }

  .card { padding: 16px; }

  .form-row { grid-template-columns: 1fr; }
}
