/* 方羽AI 管理后台：和网站同一套深色 + 青柠配色，表格为主 */
:root {
  --ink: #111214;
  --surface: #17181b;
  --card: rgba(255, 255, 255, 0.035);
  --field: rgba(255, 255, 255, 0.05);
  --hover: rgba(255, 255, 255, 0.06);
  --line-weak: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.14);
  --lime: #bef264;
  --lime-soft: rgba(190, 242, 100, 0.12);
  --text: #ececee;
  --t300: #d4d4d4;
  --t400: #a3a3a3;
  --t500: #737373;
  --rose: #fda4af;
  --rose-bg: rgba(244, 63, 94, 0.12);
  --amber: #fcd34d;
  --amber-bg: rgba(245, 158, 11, 0.12);
  --sky: #7dd3fc;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--ink); color: var(--text); font: 13px/1.6 var(--font-sans); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--t500); }
.plus { color: var(--lime); }
.minus { color: var(--rose); }

/* 顶栏 */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 28px; height: 56px; padding: 0 24px; background: rgba(17, 18, 20, 0.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line-weak); }
.brand { display: flex; flex-shrink: 0; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--lime); color: #000; font-size: 13px; }
/* 线上数据 / 本地数据 切换：当前这边高亮，线上用青柠色，免得在线上数据里误操作 */
.env-switch { display: inline-flex; flex-shrink: 0; padding: 2px; border-radius: 99px; background: var(--field); border: 1px solid var(--line-weak); font-size: 12px; }
.env-switch > * { padding: 2px 10px; border: 0; border-radius: 99px; background: none; color: var(--t400); line-height: 18px; white-space: nowrap; }
.env-switch button { cursor: pointer; }
.env-switch button:hover { color: var(--text); background: var(--hover); }
.env-switch button.is-off { color: var(--t500); }
.env-switch .is-here { font-weight: 600; }
.env-switch .is-here.is-prod { background: var(--lime-soft); color: var(--lime); }
.env-switch .is-here.is-local { background: var(--hover); color: var(--text); }
.nav { display: flex; gap: 4px; min-width: 0; overflow-x: auto; }
.nav a { flex-shrink: 0; padding: 6px 12px; border-radius: 8px; color: var(--t400); text-decoration: none; }
.nav a:hover { color: var(--text); background: var(--hover); }
.nav a.is-active { color: var(--text); background: var(--field); }
.tz { margin-left: auto; color: var(--t500); font-size: 12px; white-space: nowrap; }
.me { display: flex; align-items: center; gap: 10px; flex-shrink: 0; color: var(--t300); font-size: 12px; white-space: nowrap; }
/* 窄一点的屏幕放不下「时间均为北京时间」，名字和退出靠右 */
@media (max-width: 1180px) {
  .tz { display: none; }
  .me { margin-left: auto; }
}

/* 登录：没登录时只显示登录框 */
body.logged-out .topbar, body.logged-out .page { display: none; }
.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-box { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 340px; padding: 28px; }
.login-box .brand { margin-bottom: 6px; font-size: 16px; }
.login-box input { width: 100%; height: 36px; }
.login-box .btn { height: 36px; }
.login-error, .login-tip { margin: 0; font-size: 12px; }

.page { max-width: 1240px; margin: 0 auto; padding: 24px 24px 80px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
h1 { margin: 0; font-size: 20px; font-weight: 600; }
h2 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.section { margin-top: 28px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 0 16px; }

/* 卡片、数字块 */
.card { background: var(--card); border: 1px solid var(--line-weak); border-radius: 12px; padding: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line-weak); border-radius: 12px; padding: 14px 16px; }
.stat-label { color: var(--t400); font-size: 12px; }
.stat-value { margin-top: 2px; font: 600 22px/1.3 var(--font-mono); font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--t500); font-size: 12px; }

/* 表格 */
.table-wrap { overflow-x: auto; border: 1px solid var(--line-weak); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--line-weak); }
th { position: sticky; top: 0; background: var(--surface); color: var(--t400); font-weight: 500; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
td.r, th.r { text-align: right; }
td.wrap { white-space: normal; min-width: 200px; max-width: 360px; overflow-wrap: anywhere; }
tr.clickable { cursor: pointer; }
.empty-row td { padding: 32px; text-align: center; color: var(--t500); }

/* 按钮、输入 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--lime); border-color: var(--lime); color: #000; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--lime); opacity: 0.9; }
.btn-danger { color: var(--rose); }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }
.link { padding: 0; border: 0; background: none; color: var(--sky); cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }
.link-danger { color: var(--rose); }
input[type="text"], input[type="number"], input[type="password"], input[type="search"] { height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); outline: none; }
select { height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); outline: none; }
input:focus, select:focus { border-color: var(--lime); }
.check { display: inline-flex; align-items: center; gap: 6px; height: 32px; color: var(--t300); cursor: pointer; white-space: nowrap; }
.form-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { color: var(--t400); font-size: 12px; }
.seg { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--field); border: 1px solid var(--line-weak); }
.seg button { padding: 3px 12px; border: 0; border-radius: 6px; background: none; color: var(--t400); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--hover); color: var(--text); }

/* 状态小标签 */
.pill { display: inline-block; padding: 0 8px; border-radius: 99px; font-size: 12px; line-height: 20px; background: var(--hover); color: var(--t300); }
.pill-ok { background: var(--lime-soft); color: var(--lime); }
.pill-bad { background: var(--rose-bg); color: var(--rose); }
.pill-wait { background: var(--amber-bg); color: var(--amber); }

/* 开关：标内部账号用。开着是青柠色，请求没回来时半透明 */
.switch { position: relative; display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; cursor: pointer; user-select: none; }
.switch input { position: absolute; width: 0; height: 0; opacity: 0; }
.switch-track { position: relative; flex-shrink: 0; width: 28px; height: 16px; border-radius: 99px; background: var(--line); transition: background 0.15s; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--text); transition: transform 0.15s; }
.switch input:checked + .switch-track { background: var(--lime); }
.switch input:checked + .switch-track::after { transform: translateX(12px); background: #000; }
.switch input:disabled + .switch-track { opacity: 0.45; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--lime); outline-offset: 2px; }
.switch-text { color: var(--t500); font-size: 12px; }
.switch input:checked ~ .switch-text { color: var(--text); }
.status-cell .pill { vertical-align: middle; }

/* 新生成的邀请码 */
.codes { margin-top: 14px; padding: 12px 14px; border-radius: 10px; background: var(--lime-soft); border: 1px solid rgba(190, 242, 100, 0.25); }
.codes-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; color: var(--lime); }
.codes pre { margin: 0; font: 14px/1.8 var(--font-mono); letter-spacing: 0.06em; white-space: pre-wrap; user-select: all; }

/* 用户详情 */
.back { display: inline-block; margin-bottom: 12px; color: var(--t400); text-decoration: none; }
.back:hover { color: var(--text); }
.user-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.avatar { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--lime-soft); color: var(--lime); font-size: 18px; font-weight: 600; }
.user-name { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 600; }
.user-meta { color: var(--t400); }
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-top: 12px; }
.actions .card h2 { margin-bottom: 10px; }
.actions input { width: 100%; }
.actions .form-row > .field { flex: 1; min-width: 90px; }
.tabs { display: flex; gap: 4px; margin: 28px 0 12px; border-bottom: 1px solid var(--line-weak); }
.tabs button { padding: 8px 14px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--t400); cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--lime); }

/* 生成记录 */
.batch { margin-bottom: 12px; }
.batch-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; color: var(--t400); }
.batch-head time { color: var(--text); }
.batch-body { display: grid; grid-template-columns: minmax(220px, 1fr) 2fr; gap: 20px; }
.inputs-imgs, .results { display: flex; flex-wrap: wrap; gap: 10px; }
.thumb { width: 88px; }
.thumb a, .thumb .ph { display: block; width: 88px; height: 88px; border-radius: 8px; overflow: hidden; background: var(--field); border: 1px solid var(--line-weak); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .ph { display: grid; place-items: center; color: var(--t500); font-size: 12px; text-align: center; }
.thumb-label { margin-top: 4px; color: var(--t500); font-size: 12px; }
.texts { margin: 10px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
.texts dt { color: var(--t500); }
.texts dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.result { width: 160px; }
.result .thumb, .result .thumb a, .result .thumb .ph { width: 160px; height: 160px; }
.result-meta { margin-top: 6px; font-size: 12px; color: var(--t400); line-height: 1.7; }
.result-error { color: var(--rose); white-space: normal; }
details { margin-top: 4px; }
summary { cursor: pointer; color: var(--t500); font-size: 12px; }
details pre { margin: 4px 0 0; padding: 8px; max-height: 200px; overflow: auto; border-radius: 6px; background: var(--field); font: 11px/1.5 var(--font-mono); white-space: pre-wrap; word-break: break-all; }
.more { display: block; margin: 16px auto 0; }

/* 提示条 */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 20; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }
.toast-ok { border-color: rgba(190, 242, 100, 0.4); color: var(--lime); }
.toast-error { border-color: rgba(244, 63, 94, 0.4); color: var(--rose); }

@media (max-width: 760px) {
  .topbar { gap: 12px; padding: 0 16px; }
  .tz { display: none; }
  .page { padding: 16px 16px 60px; }
  .batch-body { grid-template-columns: 1fr; }
}

/* 行为分析：每一步还剩多少人 */
.funnel { display: grid; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 120px 1fr 64px 44px; align-items: center; gap: 10px; }
.funnel-bar { height: 10px; border-radius: 99px; background: var(--field); overflow: hidden; }
.funnel-bar i { display: block; height: 100%; border-radius: 99px; background: var(--lime); }

/* 行为日志 */
.head-actions { display: flex; align-items: center; gap: 10px; }
.kv { display: inline-block; margin: 0 10px 2px 0; }
.kv b { margin-right: 4px; color: var(--t500); font-weight: 400; }
.detail-row td { background: var(--surface); white-space: normal; }
.detail-row pre { margin: 0; font: 12px/1.6 var(--font-mono); white-space: pre-wrap; word-break: break-all; }
