/* ============================================================
   极速赛车后台管理 · 样式
   设计令牌与客户端品牌保持一致：青绿 #0FC5C1 / 深色 #1A1A1A
   ============================================================ */

:root {
  --brand: #0fc5c1;
  --brand-dark: #0aa8a4;
  --dark: #1a1a1a;
  --bg: #f2f2f2;
  --card: #ffffff;
  --table-head: #e4e4e4;
  --stripe: #f6f6f6;
  --border: #d8d8d8;
  --text: #222222;
  --text-sub: #6b7280;
  --danger: #d14343;
  --success: #1a9e5a;
  --warning: #f5a623;
  --terminal-bg: #14201a;
  --terminal-fg: #2bd92b;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --sidebar-w: 210px;
  --topbar-h: 54px;
  --bottomnav-h: 60px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    Roboto, "PingFang SC", sans-serif;
  --mono: Consolas, "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

#app {
  min-height: 100vh;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
}

/* ===================== 应用外壳（桌面） ===================== */
.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--dark);
  color: #cfcfcf;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.brand .logo {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--dark);
  border: 1px solid #333;
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.nav {
  display: flex;
  flex-direction: column;
  padding: 6px 10px;
  gap: 2px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius);
  color: #cfcfcf;
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
  cursor: pointer;
  background: none;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  text-align: left;
  width: 100%;
  font-family: var(--font);
}

.nav-item:hover {
  background: #262626;
  color: #fff;
}

.nav-item.active {
  background: #242424;
  color: var(--brand);
  border-left-color: var(--brand);
  font-weight: 600;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.sidebar .logout-box {
  padding: 12px;
  border-top: 1px solid #2c2c2c;
}

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

.topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar .page-title {
  font-size: 16px;
  font-weight: 600;
}

.topbar .top-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-sub);
  font-size: 13px;
}

.icon-btn {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-sub);
  padding: 6px;
  border-radius: var(--radius);
  display: inline-flex;
}

.icon-btn:hover {
  background: #eee;
  color: var(--text);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* 顶栏退出入口仅手机端显示（桌面端用侧栏底部的“退出登录”） */
.topbar .logout-mobile {
  display: none;
}

.content {
  padding: 20px 22px 28px;
  flex: 1;
}

/* 手机底部导航，默认隐藏 */
.bottomnav {
  display: none;
}

/* ===================== 通用组件 ===================== */
.card,
.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid #ececec;
}

.panel {
  margin-bottom: 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #eee;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-title {
  font-size: 15px;
  font-weight: 600;
}

.panel-body {
  padding: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid #b5b5b5;
  background: #efefef;
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  background: #f8f8f8;
}

.btn:active {
  background: #e2e2e2;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand-dark);
  color: #06302e;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--brand-dark);
}

.btn-primary:active {
  background: #08938f;
}

.btn-danger {
  color: #fff;
  background: var(--danger);
  border-color: #b33434;
}

.btn-success {
  color: #fff;
  background: var(--success);
  border-color: #127a45;
}

.btn-success:hover {
  background: #168a4e;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 13px;
}

/* 表格行内操作：开关 + 一排小按钮 */
.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-danger-text {
  color: var(--danger);
  border-color: transparent;
  background: transparent;
}

.btn-danger-text:hover {
  background: rgba(209, 59, 59, 0.08);
}

.input,
select.input {
  width: 100%;
  height: 38px;
  padding: 7px 11px;
  border: 1px solid #c4c4c4;
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  background: #fff;
  color: var(--text);
}

.input:focus,
select.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(15, 197, 193, 0.18);
}

textarea.input {
  height: auto;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

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

.toolbar .spacer {
  flex: 1;
}

/* 开关 */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  position: absolute;
  inset: 0;
  background: #c4c4c4;
  border-radius: 24px;
  transition: 0.15s;
  cursor: pointer;
}

.switch .slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.15s;
}

.switch input:checked + .slider {
  background: var(--brand);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

/* 徽标 */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.6;
}

.badge-success {
  background: #e3f6ec;
  color: var(--success);
}

.badge-danger {
  background: #fdeaea;
  color: var(--danger);
}

.badge-info {
  background: #e6f7f7;
  color: #0a8481;
}

.badge-warning {
  background: #fdf3e0;
  color: #b9770a;
}

.badge-muted {
  background: #ececec;
  color: var(--text-sub);
}

/* 表格 */
.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 560px;
}

.table th,
.table td {
  padding: 11px 14px;
  text-align: left;
  white-space: nowrap;
}

.table thead th {
  background: var(--table-head);
  font-weight: 600;
  font-size: 13px;
}

.table tbody tr:nth-child(even) {
  background: var(--stripe);
}

.table tbody tr:hover {
  background: #eefafa;
}

.table .col-wrap {
  white-space: normal;
  word-break: break-all;
}

/* 卡密列：保持完整不逐字折行，窄屏靠整表横向滚动查看 */
.table .col-code {
  min-width: 185px;
  white-space: nowrap;
}

/* 用户管理：主账号行展开所属子账号 */
.expand-arrow {
  display: inline-block;
  width: 18px;
  font-size: 10px;
  color: var(--text-sub);
  text-align: center;
  cursor: pointer;
  user-select: none;
}

.expand-arrow:hover,
.expand-target:hover {
  color: var(--brand-dark);
}

.expand-spacer {
  display: inline-block;
  width: 18px;
}

.expand-target {
  cursor: pointer;
}

.child-name {
  display: inline-block;
  padding-left: 26px;
  color: var(--text-sub);
  font-weight: 400;
}

.table tbody tr.child-row td {
  background: #fafafa;
}

.table tbody tr.child-row:hover td {
  background: #eefafa;
}

.text-danger {
  color: var(--danger);
}

.text-success {
  color: var(--success);
}

.text-sub {
  color: var(--text-sub);
}

.mono {
  font-family: var(--mono);
}

.empty {
  text-align: center;
  color: var(--text-sub);
  padding: 36px 0;
  font-size: 13px;
}

/* 分页 */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 12px 4px 2px;
  font-size: 13px;
  color: var(--text-sub);
  flex-wrap: wrap;
}

.pagination button {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font);
}

.pagination button.active {
  background: var(--brand);
  border-color: var(--brand-dark);
  color: #06302e;
  font-weight: 600;
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 子选项卡 */
.subtabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.subtab {
  padding: 9px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text-sub);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.subtab.active {
  color: #0a8481;
  border-bottom-color: var(--brand);
  font-weight: 600;
}

/* ===================== 仪表盘 ===================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--card);
  border: 1px solid #ececec;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.stat-card .stat-label {
  color: var(--text-sub);
  font-size: 13px;
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 24px;
  font-weight: 700;
}

.stat-card .stat-value.brand {
  color: #0a8481;
}

.stat-card .stat-sub {
  color: var(--text-sub);
  font-size: 12px;
  margin-top: 4px;
}

.dash-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

/* 纯 CSS 条形图 */
.bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 52px 1fr 78px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.bar-track {
  background: #eef1f1;
  border-radius: 4px;
  height: 16px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-dark));
  border-radius: 4px;
  min-width: 2px;
}

.bar-val {
  text-align: right;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}

.mini-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mini-list li {
  padding: 9px 2px;
  border-bottom: 1px dashed #ececec;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.mini-list li:last-child {
  border-bottom: none;
}

/* ===================== 日志终端 ===================== */
.log-terminal {
  background: var(--terminal-bg);
  color: var(--terminal-fg);
  font-family: var(--mono);
  font-size: 13px;
  border-radius: var(--radius);
  padding: 14px;
  height: 440px;
  overflow-y: auto;
  line-height: 1.7;
}

.log-line {
  white-space: pre-wrap;
  word-break: break-all;
}

.log-line .lvl-tag {
  display: inline-block;
  min-width: 44px;
}

.log-line.lvl-warning {
  color: var(--warning);
}

.log-line.lvl-success .lvl-tag {
  color: #7dffa8;
}

.log-line.lvl-error {
  color: var(--danger);
}

/* 实时动作区（本次停留临时显示）与下方真实日志之间的分隔线 */
.log-live-divider {
  border: none;
  border-top: 1px dashed rgba(255, 255, 255, 0.25);
  margin: 8px 0;
}

/* ===================== 登录页 ===================== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #1f2a2a 0%, #101616 100%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 10px;
  padding: 32px 28px 24px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.login-head {
  text-align: center;
  margin-bottom: 22px;
}

.login-head .logo {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--dark);
  color: var(--brand);
  font-weight: 800;
  font-size: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.login-head h1 {
  font-size: 19px;
}

.login-head p {
  color: var(--text-sub);
  font-size: 12.5px;
  margin: 6px 0 0;
}

.login-card .btn-primary {
  width: 100%;
  height: 42px;
}

.login-hint {
  margin-top: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-sub);
}

/* ===================== 弹窗 ===================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal {
  background: #fff;
  border-radius: 8px;
  width: 420px;
  max-width: 100%;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
}

.modal-header {
  padding: 15px 18px;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 15px;
}

.modal-close {
  border: none;
  background: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-sub);
}

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

.modal-footer {
  padding: 13px 18px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.radio-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.radio-group label {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 14px;
  cursor: pointer;
  font-size: 13px;
}

.radio-group input {
  margin-right: 5px;
}

.radio-group label:has(input:checked) {
  border-color: var(--brand);
  background: #eafafa;
  color: #0a8481;
  font-weight: 600;
}

/* Toast */
.toast-host {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: rgba(26, 26, 26, 0.92);
  color: #fff;
  padding: 9px 18px;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.toast.toast-success {
  background: rgba(26, 158, 90, 0.95);
}

.toast.toast-error {
  background: rgba(209, 67, 67, 0.95);
}

.loading {
  text-align: center;
  color: var(--text-sub);
  padding: 40px 0;
  font-size: 13px;
}

/* ============================================================
   手机端（≤768px）：隐藏侧栏，显示顶部标题 + 底部 5 Tab
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .topbar {
    padding: 0 14px;
  }

  .topbar .admin-name {
    display: none;
  }

  .topbar .logout-mobile {
    display: inline-flex;
  }

  .content {
    padding: 14px 12px calc(var(--bottomnav-h) + 20px);
  }

  .bottomnav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottomnav-h);
    background: var(--dark);
    border-top: 1px solid #000;
    z-index: 30;
  }

  .bn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #9a9a9a;
    text-decoration: none;
    font-size: 11px;
    cursor: pointer;
    background: none;
    border: none;
    font-family: var(--font);
    padding: 0;
  }

  .bn-item svg {
    width: 20px;
    height: 20px;
  }

  .bn-item.active {
    color: var(--brand);
  }

  .dash-cols {
    grid-template-columns: 1fr;
  }

  .toolbar .input,
  .toolbar select.input {
    min-width: 0;
    width: 100%;
  }

  .toolbar .spacer {
    display: none;
  }

  .toolbar {
    gap: 8px;
  }
}

/* ===================== 用户详情弹窗 ===================== */
.detail-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.detail-stat {
  padding: 10px 12px;
  box-shadow: none;
}

.detail-stat .stat-value {
  font-size: 20px;
}

.detail-section-title {
  font-weight: 600;
  font-size: 13px;
  margin: 16px 0 8px;
}

.profit-total {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.profit-days {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.profit-day {
  border: 1px solid #eee;
  border-radius: 6px;
  padding: 4px 8px;
  min-width: 72px;
  text-align: center;
  font-size: 12px;
}

.tree-list {
  border: 1px solid #f0f0f0;
  border-radius: 6px;
  max-height: 280px;
  overflow-y: auto;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid #f5f5f5;
  font-size: 13px;
  flex-wrap: wrap;
}

.tree-row:last-child {
  border-bottom: none;
}
