:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --sidebar: #090f1d;
  --sidebar-hover: #16223b;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --emerald: #059669;
  --amber: #d97706;
  --danger: #dc2626;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Auth Split / Card Wrapper */
.auth-page {
  min-height: 100vh;
  background: radial-gradient(800px 400px at 20% 10%, rgba(37,99,235,0.22), transparent 70%),
              linear-gradient(135deg, #081020 0%, #111c35 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
}
.auth-card {
  width: 100%;
  max-width: 520px;
  background: #ffffff;
  border-radius: 18px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
}
.auth-card h1 { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.auth-card .desc { font-size: 13.5px; color: var(--muted); margin-bottom: 20px; }

.seg-tabs {
  display: flex;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 20px;
}
.seg-tabs button {
  flex: 1;
  height: 36px;
  border: none;
  border-radius: 7px;
  background: transparent;
  font-weight: 700;
  font-size: 13.5px;
  color: #475569;
  cursor: pointer;
}
.seg-tabs button.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Console Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px;
  background: var(--sidebar);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sb-brand {
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}
.sb-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}
.sb-nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.sb-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 13px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: #cbd5e1;
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: 0.15s;
}
.sb-item:hover { background: var(--sidebar-hover); color: #fff; }
.sb-item.active { background: var(--primary); color: #fff; }
.sb-badge {
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 99px;
  font-weight: 700;
}
.sb-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 12px; color: #94a3b8; }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.content { padding: 24px 26px 56px; max-width: 1440px; width: 100%; }

/* Cards & Stats */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.kpi-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 2px 6px rgba(15,23,42,0.03);
}
.kpi-card .k-label { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.kpi-card .k-val { font-size: 26px; font-weight: 900; color: var(--text); font-variant-numeric: tabular-nums; }
.kpi-card .k-sub { font-size: 11.5px; color: var(--emerald); margin-top: 4px; font-weight: 600; }

.panel-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  margin-bottom: 20px;
  box-shadow: 0 2px 6px rgba(15,23,42,0.03);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.panel-head h3 { font-size: 16.5px; font-weight: 800; }

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 35px;
  padding: 0 13px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: 0.15s;
}
.btn-sm { height: 28px; padding: 0 9px; font-size: 11.5px; border-radius: 6px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
/* 与首页 portal.css 同值：panel 系页面（用户中心等）的金色强调按钮，缺此定义会裸奔成文字链 */
.btn-gold {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}
.btn-gold:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn-emerald { background: var(--emerald); color: #fff; }
.btn-amber { background: var(--amber); color: #fff; }
.btn-danger { background: #fee2e2; color: var(--danger); border-color: #fecaca; }
.btn-outline { background: #fff; color: #334155; border-color: #cbd5e1; }
.btn-outline:hover { background: #f8fafc; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: #334155; margin-bottom: 5px; }
.input, .select, .textarea {
  width: 100%;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  background: #fff;
}
.input, .select { height: 39px; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* Tables */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: middle;
}
.data-table th { background: #f8fafc; color: #475569; font-weight: 700; white-space: nowrap; }
.data-table tr:hover td { background: #f8fafc; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
}
.badge-green { background: #dcfce7; color: #15803d; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }

/* Modals & Fullscreen CodeMirror IDE */
.modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(8, 16, 32, 0.72);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal.open { display: flex; }
.modal-box {
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 16px;
  padding: 26px;
  position: relative;
  box-shadow: 0 25px 60px rgba(0,0,0,0.4);
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 7px;
  background: #f1f5f9;
  cursor: pointer;
  font-size: 17px;
}

/* CodeMirror Fullscreen Split Studio */
.ide-shell {
  width: 98vw;
  height: 95vh;
  background: #0f172a;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid #334155;
}
.ide-topbar {
  height: 50px;
  background: #081020;
  color: #f8fafc;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #1e293b;
}
.ide-split {
  flex: 1;
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  min-height: 0;
}
.ide-editor-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid #334155;
}
.ide-editor-pane .CodeMirror {
  flex: 1;
  height: 100% !important;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.ide-preview-pane {
  background: #334155;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.ide-preview-pane iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #e2e8f0;
}

/* 账号单选/多选删除、博主邮箱设置 */
.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}
.bulk-count { font-size: 13px; font-weight: 800; color: #0f172a; white-space: nowrap; }
.bulk-hint { font-size: 12px; color: #64748b; flex: 1 1 260px; line-height: 1.45; }
.bulk-actions { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.check-col { width: 38px; text-align: center !important; }
.account-check { width: 16px; height: 16px; accent-color: #2563eb; cursor: pointer; }
.account-check:disabled { cursor: not-allowed; opacity: .45; }
.blogger-email-settings {
  margin: 14px 0 4px;
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #eff6ff;
}
.blogger-email-settings > p { margin: 5px 0 10px; color: #475569; font-size: 12px; line-height: 1.5; }
.domain-list-editor { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.45; }
.readonly-info {
  padding: 9px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  font-size: 12.5px;
  line-height: 1.55;
}
.blogger-email-cell { margin-top: 5px; font-size: 11.5px; line-height: 1.45; color: #475569; overflow-wrap: anywhere; }
.btn-danger-solid {
  background: #dc2626;
  border: 1px solid #b91c1c;
  color: #fff;
  font-weight: 800;
}
.btn-danger-solid:hover:not(:disabled) { background: #b91c1c; }
.btn-danger-solid:disabled { opacity: .48; cursor: not-allowed; }
.delete-modal-box { max-width: 720px; width: min(720px, calc(100vw - 32px)); }
.delete-warning {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: 9px;
  background: #fef2f2;
  color: #991b1b;
  font-size: 13px;
  line-height: 1.55;
}
.delete-summary { font-size: 13px; font-weight: 700; color: #0f172a; margin-bottom: 8px; }
.delete-preview-list {
  max-height: 270px;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  margin-bottom: 14px;
  background: #fff;
}
.delete-preview-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12.5px;
  line-height: 1.5;
}
.delete-preview-item:last-child { border-bottom: none; }
.delete-preview-item .preview-account { min-width: 0; overflow-wrap: anywhere; }
.delete-preview-item .preview-account small { display: block; color: #64748b; }
.delete-preview-item .preview-state { flex: 0 0 auto; text-align: right; max-width: 300px; }
.delete-preview-item.deletable .preview-state { color: #047857; }
.delete-preview-item.blocked { background: #fff7ed; }
.delete-preview-item.blocked .preview-state { color: #9a3412; }
.delete-confirm-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0 14px;
  padding: 10px;
  border: 1px solid #fecaca;
  border-radius: 9px;
  background: #fff7f7;
  font-size: 12.5px;
  line-height: 1.55;
  cursor: pointer;
}
.delete-confirm-check input { margin-top: 3px; accent-color: #dc2626; }
.delete-result.hidden { display: none; }
.delete-result {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid #bbf7d0;
  border-radius: 9px;
  background: #f0fdf4;
  color: #14532d;
  font-size: 12.5px;
  line-height: 1.6;
  max-height: 180px;
  overflow: auto;
}
.delete-modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* 图形/邮箱验证码行（博主申请、登录与绑定共用） */
.captcha-row { display: flex; gap: 8px; align-items: stretch; }
.captcha-row .input { flex: 1; min-width: 0; }
.captcha-img {
  width: 132px;
  height: 39px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  background: #eef2f7;
  cursor: pointer;
  object-fit: cover;
  flex: 0 0 132px;
}
.captcha-row .btn { flex: 0 0 auto; height: 39px; white-space: nowrap; }
.captcha-row .btn:disabled,
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.field-hint { font-size: 12px; color: var(--muted); line-height: 1.65; margin-top: 6px; }
.allowed-domains-details { margin-top: 8px; font-size: 12px; color: var(--muted); }
.allowed-domains-details summary { cursor: pointer; color: var(--primary); font-weight: 700; }
.allowed-domains-list {
  margin-top: 7px;
  max-height: 112px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  padding: 8px 10px;
  line-height: 1.75;
  word-break: break-word;
}
.bind-email-alert {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.65;
  margin-bottom: 14px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  z-index: 700;
  background: #0f172a;
  color: #fff;
  padding: 11px 18px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: 0.22s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ==================== 列表分页器 / 排行排序 / 批量勾选补充（桌面 + 移动共用） ==================== */
.pager { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.pager-btn {
  height: 32px;
  padding: 0 11px;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  transition: 0.15s;
}
.pager-btn:hover:not(:disabled) { background: #eff6ff; border-color: #93c5fd; color: var(--primary); }
.pager-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager-btn:disabled { opacity: .45; cursor: not-allowed; }
.pager-btn.active:disabled { opacity: 1; }
.pager-info { font-size: 12.5px; color: var(--muted); margin-left: 4px; }
.pager-ellipsis { color: #94a3b8; padding: 0 2px; }
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover, .data-table th.sortable.sorted { color: var(--primary); }
.sb-mobile-logout { display: none; }
.user-search-input { width: 240px; height: 35px; }
.bulk-page-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: #334155; white-space: nowrap; cursor: pointer; }
.bulk-page-check input { width: 16px; height: 16px; accent-color: #2563eb; }
.table-wrap { -webkit-overflow-scrolling: touch; }

/* ==================== 响应式：小笔记本 / 平板 ==================== */
@media (max-width: 1024px) {
  .sidebar { width: 210px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 20px 18px 48px; }
}
@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .ide-split { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
}

/* ==================== 响应式：手机（≤768px） ==================== */
@media (max-width: 768px) {
  body { overflow-x: hidden; overflow-x: clip; }
  .layout { flex-direction: column; min-height: 100dvh; }

  /* 侧边栏 → 顶部横向滚动导航 */
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 60;
  }
  .sb-brand { padding: 12px 14px; }
  .sb-nav {
    flex: none;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 10px 10px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }
  .sb-item { flex: 0 0 auto; min-height: 40px; white-space: nowrap; }
  .sb-mobile-logout { display: flex; }
  .sb-footer { display: none; }

  .topbar { height: auto; padding: 12px 14px; align-items: flex-start; flex-wrap: wrap; }
  .topbar .topbar-db { display: none; }
  #adminPageTitle { font-size: 15px !important; }
  .content { padding: 16px 12px 40px; }
  .kpi-grid { gap: 10px; margin-bottom: 16px; }
  .kpi-card { padding: 14px; }
  .panel-card { padding: 14px; border-radius: 12px; margin-bottom: 16px; }
  .panel-head h3 { font-size: 15px; }

  /* 触控尺寸与 iOS 防聚焦放大（输入框 ≥16px） */
  .btn { min-height: 40px; padding: 10px 14px; }
  .btn-sm { min-height: 34px; padding: 8px 10px; font-size: 12px; }
  .pager-btn { min-height: 38px; padding: 0 13px; font-size: 13px; }
  .input, .select, .textarea { font-size: 16px; }
  .input, .select { min-height: 42px; }
  .user-search-input { width: auto; flex: 1 1 160px; height: 42px; min-height: 42px; }
  .account-check, .bulk-page-check input { width: 18px; height: 18px; }
  .modal-close { width: 36px; height: 36px; min-height: 36px; }
  .bulk-hint { flex-basis: 100%; }

  /* 弹窗与在线 IDE 近全屏 */
  .modal { padding: 8px; }
  .modal-box { max-width: none; width: calc(100vw - 16px); max-height: 92dvh; padding: 18px 16px; }
  .delete-modal-box { width: calc(100vw - 16px); }
  .ide-shell { width: 100%; height: calc(100dvh - 16px); border-radius: 10px; }
  .ide-split { grid-template-rows: 55% 45%; }
  .ide-editor-pane { border-right: none; border-bottom: 1px solid #334155; }
  .ide-topbar { height: auto; padding: 10px 12px; flex-wrap: wrap; }
  .delete-preview-item { flex-direction: column; gap: 4px; }
  .delete-preview-item .preview-state { text-align: left; max-width: none; }

  .toast { left: 16px; right: 16px; transform: translateY(30px); text-align: center; }
  .toast.show { transform: translateY(0); }

  /* 卡片式表格（.card-table）：一行 = 一张卡，标签在左、内容自然流式排版 */
  .card-table { display: block; }
  .card-table thead { display: none; }
  .card-table tbody { display: block; }
  .card-table tr {
    display: block;
    position: relative;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 12px;
    background: #fff;
  }
  .card-table tr:hover td { background: transparent; }
  .card-table td {
    display: block;
    position: relative;
    padding: 7px 0 7px 104px;
    border-bottom: 1px solid #f1f5f9;
    white-space: normal !important;
    max-width: none !important;
    min-height: 30px;
  }
  .card-table td:last-child { border-bottom: none; }
  .card-table td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    top: 7px;
    width: 92px;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.45;
  }
  .card-table td.check-col {
    position: absolute;
    top: 8px;
    right: 10px;
    width: auto;
    min-height: 0;
    padding: 4px;
    border: none;
    z-index: 2;
  }
  .card-table td.check-col::before { display: none; }
  .card-table td.check-col .account-check { width: 20px; height: 20px; }
  .card-table td[colspan] { padding-left: 0; text-align: center; }
  .card-table td[colspan]::before { display: none; }
  .card-table td code, .card-table td a { overflow-wrap: anywhere; }
  .card-table td .btn { margin: 2px 4px 2px 0; }
}

/* ==================== 响应式：小屏手机微调（≤480px） ==================== */
@media (max-width: 480px) {
  .auth-card { padding: 22px 16px; }
  .auth-page { padding: 16px 10px; }
  .kpi-grid { gap: 8px; }
  .kpi-card .k-val { font-size: 22px; }
  .panel-head h3 { font-size: 14.5px; }
  .pager { justify-content: center; }
  .pager-info { width: 100%; text-align: center; margin-left: 0; }
  .captcha-row { flex-wrap: wrap; }
}

/* ==================== 博主推广中心（blogger.php）手机补充适配 ====================
   全部以 .blogger-panel 作用域隔离，只影响博主页，不影响管理员后台。 */
.sb-short { display: none; }
@media (max-width: 768px) {
  .blogger-panel .topbar { gap: 8px; }
  .blogger-panel .topbar > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
  .blogger-panel .topbar > div:last-child .btn { flex: 1 1 auto; text-align: center; }
  .blogger-panel .panel-head { flex-wrap: wrap; gap: 8px; }
  .blogger-panel .panel-head .btn { width: 100%; }
  .blogger-panel .card-table td .btn { width: 100%; }
}
@media (max-width: 480px) {
  .blogger-panel .sb-full { display: none; }
  .blogger-panel .sb-short { display: inline; }
  .blogger-panel .grid-2 { grid-template-columns: 1fr; }
  .blogger-panel .kpi-card .k-val { font-size: 20px; }
  .blogger-panel .kpi-card .k-label { font-size: 11.5px; }
}
