@import url("https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Fira+Sans:wght@400;500;600;700&display=swap");

:root {
  color-scheme: dark;
  --bg: #070b14;
  --bg-elev: #0c1220;
  --surface: #111827;
  --surface-2: #162033;
  --line: rgba(148, 163, 184, 0.16);
  --line-strong: rgba(148, 163, 184, 0.28);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --faint: #64748b;
  --primary: #3b82f6;
  --primary-2: #2563eb;
  --telegram: #2aabee;
  --cta: #f97316;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --inset: #0b1220;
  --soft: rgba(255, 255, 255, 0.02);
  --hover: rgba(255, 255, 255, 0.04);
  --sidebar-bg: rgba(8, 12, 22, 0.92);
  --topbar-bg: rgba(7, 11, 20, 0.8);
  --login-bg: linear-gradient(180deg, rgba(22, 32, 51, 0.92), rgba(12, 18, 32, 0.96));
  --nav-active-text: #dbeafe;
  --err-text: #fca5a5;
  --overlay-bg: rgba(0, 0, 0, 0.58);
  --grid-line: rgba(255, 255, 255, 0.015);
  --glow-1: rgba(37, 99, 235, 0.16);
  --glow-2: rgba(42, 171, 238, 0.1);
  --ok-text: #86efac;
  --run-text: #93c5fd;
  --wait-text: #fdba74;
  --fail-text: #fca5a5;
  --tg-text: #7dd3fc;
  --apk-text: #c4b5fd;
  --web-text: #67e8f9;
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar: 248px;
  --topbar: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: "Fira Sans", "PingFang SC", "Noto Sans SC", sans-serif;
  --mono: "Fira Code", ui-monospace, monospace;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #eef2f7;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: rgba(15, 23, 42, 0.1);
  --line-strong: rgba(15, 23, 42, 0.2);
  --text: #0f172a;
  --muted: #475569;
  --faint: #94a3b8;
  --primary: #2563eb;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  --inset: #f8fafc;
  --soft: rgba(15, 23, 42, 0.03);
  --hover: rgba(15, 23, 42, 0.05);
  --sidebar-bg: rgba(255, 255, 255, 0.92);
  --topbar-bg: rgba(255, 255, 255, 0.85);
  --login-bg: #ffffff;
  --nav-active-text: #1d4ed8;
  --err-text: #dc2626;
  --overlay-bg: rgba(15, 23, 42, 0.4);
  --grid-line: rgba(15, 23, 42, 0.04);
  --glow-1: rgba(37, 99, 235, 0.08);
  --glow-2: rgba(42, 171, 238, 0.07);
  --ok-text: #15803d;
  --run-text: #1d4ed8;
  --wait-text: #c2410c;
  --fail-text: #b91c1c;
  --tg-text: #0369a1;
  --apk-text: #6d28d9;
  --web-text: #0e7490;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 80; background: var(--surface); padding: 8px 12px; border-radius: 8px; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 420px at 10% -10%, var(--glow-1), transparent 55%),
    radial-gradient(700px 360px at 110% 0%, var(--glow-2), transparent 50%),
    linear-gradient(180deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: auto, auto, 28px 28px, 28px 28px;
  z-index: 0;
}

#app { position: relative; z-index: 1; min-height: 100dvh; }

/* login */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(440px, 100%);
  background: var(--login-bg);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px 28px 28px;
}
.login-theme { position: fixed; top: 16px; right: 16px; z-index: 10; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  box-shadow: 0 0 24px rgba(59, 130, 246, 0.35);
}
.brand-mark svg { width: 26px; height: 26px; }
.login-card h1 { margin: 18px 0 6px; font-size: 26px; letter-spacing: -0.03em; }
.login-card p.lead { margin: 0 0 22px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field span { font-size: 13px; color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea, .input, .select, .textarea {
  width: 100%;
  background: var(--inset);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 11px 12px;
  min-height: 44px;
  transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease);
}
.field textarea, .textarea { min-height: 88px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  outline: none;
}
.captcha-row { display: grid; grid-template-columns: 1fr 120px; gap: 10px; align-items: end; }
.captcha-img {
  height: 44px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line);
  background: #fff; cursor: pointer;
}
.captcha-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.err { color: var(--err-text); font-size: 13px; min-height: 18px; margin: 4px 0 10px; }
/* USDT 套餐编辑行：输入框不在 .field 内，手动补齐同款样式 */
.pkg-row input {
  width: 100%;
  background: var(--inset);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 10px;
  min-height: 38px;
  color: inherit;
  font: inherit;
  transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease);
}
.pkg-row input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  outline: none;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 10px;
  min-height: 44px; padding: 0 16px; font-weight: 600;
  transition: transform 150ms var(--ease), background 150ms var(--ease), opacity 150ms;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(180deg, #3b82f6, #2563eb); color: #fff; width: 100%; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-cta { background: linear-gradient(180deg, #fb923c, #f97316); color: #111827; }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--text); }
.btn-ghost:hover { background: var(--hover); }
.btn-tg { background: var(--telegram); color: #06202b; }
.btn-danger { background: transparent; border-color: rgba(239,68,68,.4); color: var(--err-text); }
.btn-danger:hover { background: rgba(239,68,68,.12); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-icon { width: 40px; min-height: 40px; padding: 0; }
.btn-icon svg { width: 20px; height: 20px; }

/* shell */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 8px;
  backdrop-filter: blur(16px);
}
.logo-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px 16px; }
.logo-row strong { display: block; font-size: 15px; }
.logo-row small { color: var(--muted); font-size: 12px; }
.nav-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left; background: transparent; border: 0;
  color: var(--muted); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
.nav-btn svg { width: 18px; height: 18px; flex: none; }
.nav-btn:hover { background: var(--hover); color: var(--text); }
.nav-btn.active { background: rgba(59, 130, 246, 0.14); color: var(--nav-active-text); box-shadow: inset 3px 0 0 var(--primary); }
/* 侧边栏分组标签 */
.nav-group {
  margin: 16px 0 2px;
  padding: 0 12px;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--faint);
  user-select: none;
}
/* 页内 tab 栏（推广页 / 设置页） */
.tabbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.tab-btn {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  padding: 10px 14px 12px;
  cursor: pointer;
  transition: color 160ms var(--ease), border-color 160ms var(--ease);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.sidebar .spacer { flex: 1; }
.user-box { padding: 10px 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar);
  display: flex; align-items: center; gap: 12px;
  padding: 0 22px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.topbar h2 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.02em; }
.topbar .grow { flex: 1; }
.search {
  width: min(360px, 42vw); background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px; min-height: 40px;
}
.content { padding: 22px; max-width: 1440px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px;
}
.stat b { display: block; font-size: 26px; font-family: var(--mono); letter-spacing: -0.04em; }
.stat span { color: var(--muted); font-size: 13px; }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.panel-hd {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; background: var(--soft); }
tr:hover td { background: var(--soft); }
.app-ico { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; background: var(--inset); border: 1px solid var(--line); }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600;
  border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-ok { color: var(--ok-text); background: rgba(34,197,94,.12); }
.b-run { color: var(--run-text); background: rgba(59,130,246,.14); }
.b-wait { color: var(--wait-text); background: rgba(249,115,22,.12); }
.b-fail { color: var(--fail-text); background: rgba(239,68,68,.12); }
.b-off { color: var(--muted); background: rgba(148,163,184,.1); }
.b-tg { color: var(--tg-text); background: rgba(42,171,238,.14); }
.b-apk { color: var(--apk-text); background: rgba(139,92,246,.14); }
.b-web { color: var(--web-text); background: rgba(6,182,212,.14); }

.empty {
  padding: 56px 20px; text-align: center; color: var(--muted);
}
.empty h3 { margin: 0 0 6px; color: var(--text); }
.pager { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; }

/* modal */
.overlay {
  position: fixed; inset: 0; background: var(--overlay-bg); z-index: 40;
  display: grid; place-items: center; padding: 20px;
}
.modal {
  width: min(760px, 100%); max-height: min(88dvh, 900px); overflow: auto;
  background: var(--bg-elev); border: 1px solid var(--line-strong);
  border-radius: 18px; box-shadow: var(--shadow);
}
.modal-hd { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-hd h3 { margin: 0; font-size: 16px; }
.modal-bd { padding: 18px; }
.modal-ft { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.choice {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px;
}
.choice button {
  text-align: left; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px; min-height: 96px;
}
.choice button.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.2); }
.choice strong { display: block; margin-bottom: 4px; }
.choice span { color: var(--muted); font-size: 13px; }

.drop {
  border: 1px dashed var(--line-strong); border-radius: 14px; padding: 28px;
  text-align: center; color: var(--muted); background: var(--soft);
}
.drop.over { border-color: var(--primary); background: rgba(59,130,246,0.08); }
.drop input { display: none; }

.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 60;
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: 12px; padding: 12px 14px; min-width: 240px; box-shadow: var(--shadow);
}
.toast.ok { border-color: rgba(34,197,94,.4); }
.toast.err { border-color: rgba(239,68,68,.45); }

.cards { display: grid; grid-template-columns: 1.1fr .9fr; gap: 16px; }
.help-list { margin: 0; padding-left: 18px; color: var(--muted); }
.help-list li { margin: 8px 0; }
.switch { display: inline-flex; align-items: center; gap: 8px; }
.switch input { width: 18px; height: 18px; }
.job { padding: 12px 0; border-bottom: 1px solid var(--line); }
.job:last-child { border-bottom: 0; }
.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: 40px; z-index: 12;
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: 12px; min-width: 180px; padding: 6px; box-shadow: var(--shadow);
}
.menu-pop button { display: block; width: 100%; text-align: left; background: transparent; border: 0; padding: 9px 10px; border-radius: 8px; color: var(--text); }
.menu-pop button:hover { background: var(--hover); }

.hamb { display: none; }
.topbar .btn-cta { flex-shrink: 0; }
@media (max-width: 1024px) {
  .stats, .cards, .grid-2, .grid-3, .choice { grid-template-columns: 1fr; }
  .search { display: none; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(84vw, 280px); z-index: 30;
    transform: translateX(-105%); transition: transform 220ms var(--ease);
  }
  .sidebar.open { transform: none; }
  .hamb { display: inline-flex; }
  .content { padding: 16px; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 25; }
  .topbar .grow { display: none; }
  .topbar .btn-cta { margin-left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* TG 用户页：数字/日期不换行 */
.nw { white-space: nowrap; }

/* Vue 挂载前隐藏原始模板，避免刷新时闪现错乱页面 */
[v-cloak] { display: none; }

/* 推广统计页 */
/* 推广员行可点展开渠道明细 */
.ps-row { cursor: pointer; }
.ps-caret { display: inline-block; color: var(--faint); font-size: 11px; transition: transform 160ms var(--ease); }
.ps-caret.open { transform: rotate(90deg); }
/* 展开行：浅色缩进的渠道子表 */
.ps-sub-row > td, .ps-sub-row:hover > td { background: var(--inset); padding: 8px 14px 14px 34px; }
.ps-sub-table { font-size: 13px; }
.ps-sub-table th, .ps-sub-table td { padding: 8px 10px; }
.ps-sub-table thead th { background: transparent; }
/* 每日趋势：纯 div 微型条形图，容器纵向滚动 */
.ps-chart { max-height: 420px; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.ps-day { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center; }
.ps-day-label { color: var(--faint); font-size: 11px; text-align: right; }
.ps-bars { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ps-bar-row { display: grid; grid-template-columns: 28px 1fr 36px; gap: 8px; align-items: center; }
.ps-bar-tag { color: var(--faint); font-size: 11px; }
.ps-bar-track { height: 10px; border-radius: 5px; background: rgba(127,127,127,.12); overflow: hidden; }  /* 极淡轨道：0 值时看起来是空槽而非满条 */
.ps-bar { height: 100%; border-radius: 5px; transition: width 240ms var(--ease); }
.ps-bar-dl { background: linear-gradient(90deg, #475569, #64748b); }
.ps-bar-a { background: linear-gradient(90deg, #1d4ed8, #3b82f6); }
.ps-bar-b { background: linear-gradient(90deg, #15803d, #22c55e); }
.ps-bar-val { color: var(--muted); font-size: 11px; text-align: right; }
/* 安装记录明细：筛选行 */
.ps-filter { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.ps-filter select, .ps-filter input {
  background: var(--inset); border: 1px solid var(--line-strong); border-radius: 10px;
  min-height: 36px; padding: 6px 10px; color: inherit;
}
.ps-filter select { min-width: 130px; }
.ps-filter input { min-width: 150px; }
.ps-filter .btn { width: auto; }
