/* =============================================================
   朋友圈投放助手 —— 深色 UI（原生多页，零构建）
   ============================================================= */
:root {
  --bg: #0f1117;
  --bg-2: #141824;
  --panel: #171a23;
  --panel-2: #1d212e;
  --border: #262b38;
  --border-2: #333a4b;
  --text: #e6e8ee;
  --muted: #8b93a7;
  --accent: #7c5cff;
  --accent-2: #6b4bff;
  --accent-soft: rgba(124, 92, 255, .14);
  --success: #22c55e;
  --danger: #ff4d4f;
  --warn: #f59e0b;
  --info: #38bdf8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --tabbar-h: 58px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- 布局 ---------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
  padding: 0 18px;
  background: rgba(20, 24, 36, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}
.app-header .brand .dot {
  width: 10px; height: 10px; border-radius: 3px;
  background: linear-gradient(135deg, var(--accent), #b06bff);
}
.app-header .nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.app-header .nav::-webkit-scrollbar { display: none; }
.app-header .nav a {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--muted);
  white-space: nowrap;
}
.app-header .nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.app-header .nav a.active { background: var(--accent-soft); color: #cfc2ff; }

.app-header .user {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.app-header .user .name { color: var(--muted); font-size: 13px; }

.app-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 18px 40px;
}

.page-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 16px;
}
.page-title h1 { font-size: 19px; margin: 0; }
.page-title .sub { color: var(--muted); font-size: 12px; }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card + .card { margin-top: 14px; }
.card h2 {
  font-size: 14px;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card h2 .hint { font-weight: 400; color: var(--muted); font-size: 12px; }

.stat { text-align: left; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 2px; }
.stat .value small { font-size: 12px; color: var(--muted); font-weight: 400; }

/* ---------------- 表单 ---------------- */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
label.field > span .req { color: var(--danger); }

input[type="text"], input[type="password"], input[type="number"],
input[type="datetime-local"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #5b6377; }
select { appearance: none; background-image: none; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { background: #232838; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { background: transparent; border-color: rgba(255, 77, 79, .5); color: var(--danger); }
.btn.danger:hover { background: rgba(255, 77, 79, .12); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.tbl th { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
table.tbl tr:hover td { background: rgba(255, 255, 255, .015); }
table.tbl td.actions { white-space: nowrap; text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

/* ---------------- 标签 ---------------- */
.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border-2);
  color: var(--muted);
}
.tag.ok { color: var(--success); border-color: rgba(34, 197, 94, .4); background: rgba(34, 197, 94, .1); }
.tag.bad { color: var(--danger); border-color: rgba(255, 77, 79, .4); background: rgba(255, 77, 79, .1); }
.tag.warn { color: var(--warn); border-color: rgba(245, 158, 11, .4); background: rgba(245, 158, 11, .1); }
.tag.info { color: var(--info); border-color: rgba(56, 189, 248, .4); background: rgba(56, 189, 248, .1); }

.empty { color: var(--muted); text-align: center; padding: 28px 12px; font-size: 13px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.hidden { display: none !important; }

/* ---------------- 提示条 ---------------- */
.alert {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--panel-2);
  font-size: 13px;
  margin-bottom: 12px;
}
.alert.warn { border-color: rgba(245, 158, 11, .45); background: rgba(245, 158, 11, .1); color: #fbd38d; }
.alert.bad { border-color: rgba(255, 77, 79, .45); background: rgba(255, 77, 79, .1); color: #ffb4b4; }
.alert.ok { border-color: rgba(34, 197, 94, .45); background: rgba(34, 197, 94, .1); color: #a7f3c4; }
.alert.info { border-color: rgba(56, 189, 248, .45); background: rgba(56, 189, 248, .1); color: #bae6fd; }

/* ---------------- Toast ---------------- */
#mp-toasts {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.mp-toast {
  max-width: 92vw;
  padding: 9px 16px;
  border-radius: 999px;
  background: #262b38;
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: mp-in .18s ease-out;
}
.mp-toast.ok { border-color: rgba(34, 197, 94, .5); color: #b7f7cf; }
.mp-toast.bad { border-color: rgba(255, 77, 79, .5); color: #ffb4b4; }
.mp-toast.warn { border-color: rgba(245, 158, 11, .5); color: #fde8b5; }
@keyframes mp-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal .modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.qr-box { text-align: center; padding: 8px 0; }
.qr-box img {
  width: 200px; height: 200px;
  background: #fff;
  border-radius: 10px;
  padding: 8px;
  object-fit: contain;
}

/* ---------------- 底部 Tab（移动端） ---------------- */
.app-tabbar { display: none; }

@media (max-width: 768px) {
  .app-header .nav { display: none; }
  .app-header .user .name { display: none; }
  .app-main { padding: 14px 12px calc(var(--tabbar-h) + 24px); }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .app-tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: var(--tabbar-h);
    z-index: 40;
    display: flex;
    background: rgba(20, 24, 36, .96);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .app-tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--muted);
    font-size: 11px;
  }
  .app-tabbar a:hover { text-decoration: none; }
  .app-tabbar a .ic { font-size: 17px; line-height: 1; }
  .app-tabbar a.active { color: #cfc2ff; }
}

/* ---------------- 登录页 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(124, 92, 255, .18), transparent 60%),
    radial-gradient(700px 400px at 110% 110%, rgba(56, 189, 248, .12), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.login-card .logo { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.login-card .logo .dot { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #b06bff); }
.login-card h1 { font-size: 18px; margin: 0; }
.login-card .tip { color: var(--muted); font-size: 12px; margin-bottom: 20px; }
