/* ============ 内测分发平台 ============ */
/* 主题：html[data-theme="light"|"dark"]，由 js/theme.js 设置。
   组件规则一律用 var()，深色主题只覆盖变量，不要在组件里写死颜色。 */
:root {
  color-scheme: light;

  --bg: #f5f6fa;
  --bg-soft: #f7f8fa;
  --bg-hover: #fafbff;
  --bg-top: #eef0fb;
  --panel: #ffffff;
  --border: #e6e8f0;
  --border-strong: #c9cede;
  --text: #1f2330;
  --text-2: #5a6172;
  --text-3: #9aa1b2;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef0ff;
  --green: #16a34a;
  --green-soft: #e8f7ee;
  --red: #dc2626;
  --red-soft: #fdecec;
  --danger-border: #f3c6c6;
  --orange: #d97706;
  --orange-soft: #fdf3e3;
  --blue: #2563eb;
  --blue-soft: #e8efff;
  --purple: #7c3aed;
  --purple-soft: #f3e8ff;
  --chip-soft: #f0f1f5;
  --ok: #2a9d5c;
  --err: #c0392b;
  --warn-bg: #fff6e0;
  --warn-border: #f2d79b;
  --warn-text: #7a5200;
  --note-text: #3c3a72;
  --note-border: #dcdcfb;
  --toast-bg: #23273a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20, 24, 46, 0.06), 0 4px 16px rgba(20, 24, 46, 0.05);
  --shadow-hover: 0 6px 22px rgba(20, 24, 46, .1);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .2);
}

/* 深色主题：只覆盖变量 */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #14161d;
  --bg-soft: #1e222d;
  --bg-hover: #242a38;
  --bg-top: #1b2030;
  --panel: #1b1e27;
  --border: #2b3040;
  --border-strong: #3b4256;
  --text: #e7e9f0;
  --text-2: #a9b0c1;
  --text-3: #7a8398;
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-soft: rgba(99, 102, 241, .16);
  --green: #4ade80;
  --green-soft: rgba(74, 222, 128, .14);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, .14);
  --danger-border: rgba(248, 113, 113, .34);
  --orange: #fbbf24;
  --orange-soft: rgba(251, 191, 36, .13);
  --blue: #60a5fa;
  --blue-soft: rgba(96, 165, 250, .16);
  --purple: #c084fc;
  --purple-soft: rgba(192, 132, 252, .16);
  --chip-soft: #262b38;
  --ok: #4ade80;
  --err: #f87171;
  --warn-bg: rgba(251, 191, 36, .12);
  --warn-border: rgba(251, 191, 36, .32);
  --warn-text: #fcd34d;
  --note-text: #c7c9ff;
  --note-border: rgba(99, 102, 241, .35);
  --toast-bg: #2f3546;
  --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 6px 20px rgba(0, 0, 0, .35);
  --shadow-hover: 0 8px 26px rgba(0, 0, 0, .5);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .55);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .18s ease, color .18s ease;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }

.page-loading { padding: 80px 0; text-align: center; color: var(--text-3); }

/* ---------- 布局 ---------- */
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 20px;
  height: 58px; display: flex; align-items: center; gap: 16px;
}
.brand { font-size: 17px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; cursor: pointer; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
}
.topbar .spacer { flex: 1; }
.topbar .user-chip { color: var(--text-2); font-size: 13px; display: flex; align-items: center; gap: 10px; }
.container { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }
.container-narrow { max-width: 640px; margin: 0 auto; padding: 24px 20px 60px; }

/* ---------- 卡片 / 通用 ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.section-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--text-2); }
.tiny { font-size: 12px; color: var(--text-3); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 9px; padding: 8px 16px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { color: var(--red); border-color: var(--danger-border); }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-lg { padding: 12px 22px; font-size: 15px; border-radius: 11px; }
.btn-block { width: 100%; }
/* 弹窗内的危险操作区（删除应用） */
.danger-zone {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--red-soft); border: 1px solid var(--danger-border); border-radius: 10px;
  padding: 10px 12px;
}
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 13px; padding: 0; }
.link-btn:hover { text-decoration: underline; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 12px; font-size: 14px; font-family: inherit; color: var(--text);
  background: var(--panel); outline: none; transition: border .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.textarea { resize: vertical; min-height: 84px; }
.form-error { color: var(--red); font-size: 13px; margin: 8px 0; min-height: 18px; }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }
.code-btn { white-space: nowrap; min-width: 104px; }

/* 分发链接编辑：前缀固定展示，只让用户改 /s/ 后面的短码 */
.link-edit {
  display: flex; align-items: stretch; border: 1px solid var(--border);
  border-radius: 9px; overflow: hidden; background: var(--panel);
  transition: border .15s, box-shadow .15s;
}
.link-edit:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.link-edit-prefix {
  display: flex; align-items: center; padding: 0 10px; font-size: 13px; color: var(--text-3);
  background: var(--bg); border-right: 1px solid var(--border);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 68%;
}
.link-edit .input {
  border: none; border-radius: 0; box-shadow: none; flex: 1; min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.link-edit .input:focus { border-color: transparent; box-shadow: none; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; border-radius: 6px; padding: 2px 8px;
}
.badge-android { background: var(--green-soft); color: var(--green); }
.badge-ios { background: var(--blue-soft); color: var(--blue); }
.badge-harmony { background: var(--purple-soft); color: var(--purple); }
.badge-active { background: var(--green-soft); color: var(--green); }
.badge-archived { background: var(--chip-soft); color: var(--text-3); }
.badge-locked { background: var(--orange-soft); color: var(--orange); }
.badge-signed { background: var(--blue-soft); color: var(--blue); }
.badge-warn { background: var(--orange-soft); color: var(--orange); }
.badge-expired { background: var(--red-soft); color: var(--red); }

/* ---------- iOS 描述文件详情卡片 ---------- */
.pf-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.pf-bar select { width: auto; min-width: 220px; max-width: 100%; }
.cert-cards { display: flex; flex-direction: column; gap: 12px; }
.cert-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--panel); }
.cert-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 16px; }
.kv-grid > div { min-width: 0; }
.kv-grid span { display: block; font-size: 12px; color: var(--text-3); }
.kv-grid b { font-size: 13px; font-weight: 600; word-break: break-all; }
.dev-block { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 10px; }
.dev-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.dev-udids { display: flex; flex-wrap: wrap; gap: 6px; max-height: 150px; overflow-y: auto; }
.dev-udids code {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 3px 7px;
}

/* ---------- 统计 ---------- */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card { padding: 16px 18px; }
.stat-card .num { font-size: 24px; font-weight: 800; }
.stat-card .lbl { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ---------- 应用卡片 ---------- */
.apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.app-card { padding: 18px; display: flex; flex-direction: column; gap: 12px; cursor: pointer; transition: transform .15s, box-shadow .15s; }
.app-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.app-card .head { display: flex; gap: 12px; align-items: center; }
.app-icon {
  width: 52px; height: 52px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; overflow: hidden;
}
.app-icon img { width: 100%; height: 100%; object-fit: cover; }
/* 有真实图标时不要再垫渐变底：透明 PNG / 异形图标会从四角透出紫色方块 */
.app-icon-plain { background: none; }
.app-card .name { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.app-card .meta { font-size: 12px; color: var(--text-3); }
.app-card .foot { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border); padding-top: 12px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--text-3); font-weight: 600; font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }

/* 版本列表分页条 */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 14px 0 2px; }
.pager .btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ---------- 分发链接 ---------- */
.dist-grid { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.dist-main { flex: 1; min-width: 260px; }
.dist-qr { flex: none; text-align: center; }
.dist-qr img {
  display: block; width: 132px; height: 132px;
  border: 1px solid var(--border); border-radius: 10px; padding: 6px; background: #fff;
}
.dist-qr span { display: block; margin-top: 6px; }
.dist-qr-empty {
  width: 132px; height: 132px; display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--border); border-radius: 10px; background: var(--bg);
}
.dist-box { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.dist-link {
  flex: 1; min-width: 220px; background: var(--bg); border: 1px dashed var(--border);
  border-radius: 9px; padding: 9px 12px; font-size: 13px; color: var(--text-2);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qr-box { text-align: center; }
.qr-box img { border: 1px solid var(--border); border-radius: 8px; padding: 4px; background: #fff; }

/* 版本专属分发链接（表格内） */
.v-link {
  display: inline-block; max-width: 210px; vertical-align: bottom;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px;
  color: var(--primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.v-link:hover { text-decoration: underline; }
.v-link-acts { display: flex; gap: 6px; margin-top: 6px; }
.v-link-acts .btn { padding: 3px 8px; font-size: 12px; border-radius: 6px; }

/* ---------- 登录页 ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; padding: 32px; }
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo .brand-mark { width: 48px; height: 48px; border-radius: 14px; font-size: 22px; margin: 0 auto 12px; }
.auth-logo h1 { font-size: 20px; }
.auth-logo p { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.auth-tabs { display: flex; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.auth-tabs button {
  flex: 1; border: none; background: transparent; padding: 8px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer;
}
.auth-tabs button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }

/* ---------- 落地页 ---------- */
.landing { min-height: 100vh; background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 240px); }
.landing-card { max-width: 420px; margin: 40px auto; padding: 28px; text-align: center; }
.landing-icon { width: 84px; height: 84px; border-radius: 20px; margin: 0 auto 14px; font-size: 38px;
  background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; overflow: hidden; box-shadow: var(--shadow); }
.landing-icon img { width: 100%; height: 100%; object-fit: cover; }
.landing h1 { font-size: 22px; }
.landing .ver-line { color: var(--text-3); font-size: 13px; margin: 6px 0 18px; }
.changelog {
  text-align: left; background: var(--bg); border-radius: 10px; padding: 12px 14px;
  font-size: 13px; color: var(--text-2); white-space: pre-wrap; margin: 14px 0; max-height: 200px; overflow-y: auto;
}
.install-tip { font-size: 12px; color: var(--text-3); margin-top: 12px; }
.install-tip-err { color: var(--err); line-height: 1.7; text-align: left; }
.install-tip-err a { color: inherit; text-decoration: underline; word-break: break-all; }
/* 浏览器环境提示：iOS 在微信/内置浏览器里点安装会被静默吞掉 */
.env-banner {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  font-size: 12px;
  line-height: 1.7;
  text-align: left;
}
/* 版本专用链接提示 */
.pin-note {
  text-align: left; font-size: 12px; line-height: 1.7;
  background: var(--primary-soft); color: var(--note-text);
  border: 1px solid var(--note-border); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 10px;
}
.pin-note a { color: var(--primary); font-weight: 600; }
.pin-note a:hover { text-decoration: underline; }

/* 发布页：拖拽选包区 + 包内信息只读卡片 */
.drop-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 34px 16px; margin-top: 12px;
  border: 2px dashed var(--border, #d7dae2); border-radius: 14px;
  cursor: pointer; text-align: center; transition: border-color .15s, background .15s;
}
.drop-zone:hover, .drop-zone.drop-hover { border-color: var(--primary, #3b6ef5); background: var(--primary-soft); }
.parsed-box {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; margin-top: 10px;
  border: 1px solid var(--border, #e3e6ec); border-radius: 12px;
  background: var(--bg-soft);
}
.parsed-box img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; }
.ver-list { text-align: left; }
.ver-item {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
  background: var(--bg);
}
.ver-item-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ver-item-head .btn { margin-left: auto; }
.ver-item-log { margin-top: 6px; white-space: pre-wrap; max-height: 88px; overflow-y: auto; }
.landing-qr { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }
.pass-gate { margin: 18px 0 0; }

/* ---------- 弹窗 / Toast ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(18, 20, 33, .45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px 16px;
  overflow-y: auto;
}
.modal {
  background: var(--panel); border-radius: 14px; width: 100%; max-width: 480px;
  padding: 22px; box-shadow: var(--shadow-lg); animation: pop .18s ease;
}
.modal h3 { font-size: 16px; margin-bottom: 16px; }
.modal .modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--toast-bg); color: #fff; padding: 9px 18px; border-radius: 10px;
  font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.25); animation: pop .18s ease; max-width: 86vw;
}
.toast.err { background: #b91c1c; }
.toast.ok { background: #15803d; }

/* ---------- 其它 ---------- */
.empty { text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty .big { font-size: 15px; color: var(--text-2); font-weight: 600; margin-bottom: 6px; }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.breadcrumb { font-size: 13px; color: var(--text-3); margin-bottom: 14px; display: flex; align-items: center; gap: 6px; }
.breadcrumb a { color: var(--text-2); }
.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.up-progress { font-size: 13px; color: var(--primary); margin-top: 8px; min-height: 20px; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--primary); border-top-color: transparent; border-radius: 50%; animation: rot .8s linear infinite; vertical-align: -2px; }
@keyframes rot { to { transform: rotate(360deg); } }
.kbd {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 1px 6px; font-family: ui-monospace, Menlo, monospace; font-size: 12px;
}
.notice { background: var(--orange-soft); color: var(--warn-text); border-radius: 10px; padding: 12px 14px; font-size: 13px; margin-bottom: 16px; }
.notice b { font-weight: 700; }

/* ---------- 主题切换 ---------- */
.theme-slot { display: flex; align-items: center; }
/* 登录页 / 分发页没有顶栏，切换器浮在右上角 */
.theme-float { position: fixed; top: 10px; right: 12px; z-index: 70; }
.theme-float[hidden] { display: none; }
.theme-switch { position: relative; }
.theme-btn {
  width: 32px; height: 32px; padding: 0; border-radius: 9px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.theme-btn:hover { background: var(--bg-hover); border-color: var(--border-strong); color: var(--text); }
.theme-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.theme-btn svg { width: 16px; height: 16px; }
.theme-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 80;
  min-width: 140px; padding: 5px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg);
}
.theme-menu[hidden] { display: none; }
.theme-opt {
  display: flex; align-items: center; gap: 9px; width: 100%;
  border: 0; background: none; color: var(--text-2); text-align: left;
  font-size: 13px; padding: 7px 8px; border-radius: 7px; cursor: pointer;
}
.theme-opt:hover { background: var(--bg-hover); color: var(--text); }
.theme-opt.on { color: var(--primary); font-weight: 600; }
.theme-opt svg { width: 15px; height: 15px; flex: none; }
.theme-opt .tick { margin-left: auto; opacity: 0; }
.theme-opt.on .tick { opacity: 1; }

@media (max-width: 640px) {
  .stats-row { grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
  .stat-card .num { font-size: 19px; }
  .container { padding: 16px 14px 50px; }
  .form-row { flex-direction: column; gap: 0; }
  .theme-float { top: 8px; right: 10px; }
  /* 给浮动切换器让出空间，避免压在分发卡片上 */
  .landing-card { margin-top: 54px; }
}
