/* ============================================================
   IPA 分发平台 - 全局样式
   简约、现代、响应式；支持浅色/深色自动切换
   ============================================================ */
:root {
  --brand: #6366f1;
  --brand-2: #8b5cf6;
  --brand-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f1f6;
  --text: #1f2430;
  --text-soft: #6b7280;
  --text-faint: #9ca3af;
  --border: #e6e8ef;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .14);
  --radius: 16px;
  --radius-sm: 10px;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #171a21;
    --surface-2: #1f232c;
    --text: #e8eaf0;
    --text-soft: #9aa1ad;
    --text-faint: #6b7280;
    --border: #262b35;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
    --danger-soft: #2a1416;
  }
}

* { 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;
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------------- 顶部导航 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar .container {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 11px; background: var(--brand-grad);
  display: grid; place-items: center; box-shadow: 0 6px 16px rgba(99, 102, 241, .35);
}
.brand .logo svg { width: 22px; height: 22px; }
.brand h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: .2px; }
.brand .sub { font-size: 12px; color: var(--text-faint); margin: 0; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: 10px;
  padding: 9px 15px; font-size: 14px; font-weight: 600;
  transition: all .16s ease; white-space: nowrap; background: none; color: var(--text);
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--brand-grad); color: #fff; box-shadow: 0 6px 16px rgba(99, 102, 241, .3); }
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-ghost:hover { background: color-mix(in srgb, var(--surface-2) 80%, var(--brand) 20%); }
.btn-outline { border-color: var(--border); background: var(--surface); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 11px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; filter: none; }

/* ---------------- 页面主体 ---------------- */
main { padding: 28px 0 64px; }
.section-title { font-size: 15px; font-weight: 700; margin: 30px 0 14px; display: flex; align-items: center; gap: 8px; }
.section-title .count { color: var(--text-faint); font-weight: 500; }

/* ---------------- 提示条 ---------------- */
.banner {
  display: flex; gap: 12px; align-items: flex-start;
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px;
  border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow);
  font-size: 13.5px;
}
.banner.warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }
.banner.ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.banner .ico { flex: 0 0 auto; width: 20px; height: 20px; margin-top: 1px; }
.banner.warn .ico { color: var(--warn); }
.banner.ok .ico { color: var(--ok); }
.banner b { font-weight: 700; }
.banner code {
  background: var(--surface-2); padding: 1px 6px; border-radius: 6px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 12.5px;
}

/* ---------------- 上传区 ---------------- */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--surface); padding: 34px 20px; text-align: center;
  transition: all .18s ease; box-shadow: var(--shadow); cursor: pointer;
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--surface) 92%, var(--brand) 8%);
}
.dropzone .up-ico {
  width: 54px; height: 54px; margin: 0 auto 12px; border-radius: 15px;
  background: color-mix(in srgb, var(--brand) 12%, var(--surface));
  display: grid; place-items: center; color: var(--brand);
}
.dropzone .up-ico svg { width: 28px; height: 28px; }
.dropzone h3 { margin: 0 0 4px; font-size: 16px; }
.dropzone p { margin: 0; color: var(--text-soft); font-size: 13.5px; }
.dropzone .browse { color: var(--brand); font-weight: 700; }

/* 上传进度 */
.upload-list { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.upload-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; box-shadow: var(--shadow);
}
.upload-item .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13.5px; }
.upload-item .fname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item .pct { color: var(--text-soft); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.progress { height: 7px; border-radius: 5px; background: var(--surface-2); margin-top: 9px; overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: var(--brand-grad); border-radius: 5px; transition: width .15s ease; }
.upload-item.error .pct { color: var(--danger); }
.upload-item.done .pct { color: var(--ok); }

/* ---------------- 应用卡片 ---------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); transition: transform .16s ease, box-shadow .16s ease;
  display: flex; flex-direction: column; gap: 14px;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card .head { display: flex; gap: 14px; align-items: center; }
.app-icon {
  width: 62px; height: 62px; border-radius: 14px; flex: 0 0 auto; object-fit: cover;
  background: var(--surface-2); box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}
.card .meta { min-width: 0; flex: 1; }
.card .meta .name { font-size: 16px; font-weight: 700; margin: 0 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta .bid { font-size: 12.5px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, Consolas, monospace; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; color: var(--text-soft); background: var(--surface-2); padding: 3px 9px; border-radius: 20px; }

/* 平台徽章 */
.pbadge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.pbadge svg { width: 13px; height: 13px; }
.pbadge.ios { background: color-mix(in srgb, #0a84ff 16%, var(--surface)); color: #0a84ff; }
.pbadge.android { background: color-mix(in srgb, #3ddc84 22%, var(--surface)); color: #1faf63; }
.card .actions { display: flex; gap: 8px; margin-top: auto; }
.card .actions .btn { flex: 1; }
.icon-btn {
  width: 38px; height: 38px; flex: 0 0 auto; border-radius: 10px; display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); transition: all .15s ease;
}
.icon-btn:hover { color: var(--brand); border-color: var(--brand); }
.icon-btn.danger:hover { color: #fff; background: var(--danger); border-color: var(--danger); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------------- 空状态 ---------------- */
.empty { text-align: center; padding: 60px 20px; color: var(--text-soft); }
.empty .big { width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 20px; background: var(--surface-2); display: grid; place-items: center; color: var(--text-faint); }
.empty .big svg { width: 36px; height: 36px; }
.empty h3 { margin: 0 0 6px; color: var(--text); }

/* ---------------- 折叠帮助 ---------------- */
.help { margin-top: 34px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.help summary { list-style: none; cursor: pointer; padding: 18px 20px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; }
.help summary::-webkit-details-marker { display: none; }
.help summary .arrow { transition: transform .2s ease; color: var(--text-faint); }
.help[open] summary .arrow { transform: rotate(90deg); }
.help .body { padding: 0 20px 22px; border-top: 1px solid var(--border); }
.help h4 { margin: 20px 0 8px; font-size: 14px; color: var(--brand); }
.help ol, .help ul { margin: 0; padding-left: 20px; color: var(--text-soft); font-size: 13.5px; }
.help li { margin: 5px 0; }
.help code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; color: var(--text); }

/* ---------------- 模态框 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 17, 23, .55); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 380px; padding: 24px; text-align: center;
  animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h3 { margin: 0 0 4px; font-size: 17px; }
.modal p { margin: 0 0 16px; color: var(--text-soft); font-size: 13.5px; }
.modal .qr { width: 240px; height: 240px; margin: 0 auto 14px; border-radius: 14px; background: #fff; padding: 10px; box-shadow: var(--shadow); }
.modal .qr img { width: 100%; height: 100%; display: block; }
.modal .modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal .modal-actions .btn { flex: 1; }

/* ---------------- Toast ---------------- */
.toast-wrap { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #1f2430; color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 13.5px;
  box-shadow: var(--shadow-lg); animation: slideUp .2s ease; display: flex; align-items: center; gap: 8px; max-width: 90vw;
}
.toast.ok { background: #16a34a; }
.toast.err { background: #ef4444; }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------------- 安装页 ---------------- */
.install-wrap { max-width: 460px; margin: 0 auto; padding: 30px 20px 60px; }
.install-card { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow); padding: 30px 24px; text-align: center; }
.install-card .big-icon { width: 108px; height: 108px; border-radius: 24px; margin: 0 auto 16px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); background: var(--surface-2); object-fit: cover; }
.install-card .app-name { font-size: 22px; font-weight: 800; margin: 0 0 4px; }
.install-card .app-bid { font-size: 12.5px; color: var(--text-faint); font-family: ui-monospace, Consolas, monospace; margin: 0 0 16px; word-break: break-all; }
.install-card .info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0 22px; }
.install-card .info-grid .cell { background: var(--surface-2); border-radius: 12px; padding: 10px 8px; }
.install-card .info-grid .k { font-size: 11px; color: var(--text-faint); margin-bottom: 2px; }
.install-card .info-grid .v { font-size: 14px; font-weight: 700; }
.install-card .btn-install { width: 100%; padding: 15px; font-size: 16px; border-radius: 14px; }
.install-card .qr-box { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--border); }
.install-card .qr-box .qr { width: 190px; height: 190px; margin: 12px auto 0; background: #fff; border-radius: 14px; padding: 10px; box-shadow: var(--shadow); }
.install-card .qr-box .qr img { width: 100%; height: 100%; }
.install-note { font-size: 12.5px; color: var(--text-soft); margin-top: 8px; }
.install-steps { text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-top: 18px; }
.install-steps h4 { margin: 0 0 10px; font-size: 14px; }
.install-steps ol { margin: 0; padding-left: 20px; color: var(--text-soft); font-size: 13.5px; }
.install-steps li { margin: 6px 0; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-soft); font-size: 13.5px; margin-bottom: 16px; }
.back-link:hover { color: var(--brand); }
.center-loading { text-align: center; padding: 80px 20px; color: var(--text-soft); }

.spinner { width: 20px; height: 20px; border: 2.5px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
.spinner.dark { border-color: var(--border); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 顶栏操作区 & 登录页 ---------------- */
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-soft); background: var(--surface-2); padding: 6px 12px; border-radius: 20px; font-weight: 600; }
.user-chip svg { width: 15px; height: 15px; }

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-wrap { width: 100%; max-width: 380px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 34px 30px; text-align: center; }
.login-logo { width: 56px; height: 56px; border-radius: 16px; background: var(--brand-grad); display: inline-grid; place-items: center; box-shadow: 0 8px 20px rgba(99, 102, 241, .35); margin-bottom: 16px; }
.login-logo svg { width: 30px; height: 30px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-sub { color: var(--text-soft); font-size: 13.5px; margin: 0 0 24px; }
.login-form { text-align: left; }
.login-form .field { margin-bottom: 16px; }
.login-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-soft); }
.login-form input { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-2); color: var(--text); font-size: 15px; transition: border-color .15s, box-shadow .15s, background .15s; }
.login-form input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); background: var(--surface); }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 6px; }
.login-btn { width: 100%; padding: 13px; font-size: 15px; border-radius: 12px; margin-top: 4px; }
.login-foot { text-align: center; color: var(--text-faint); font-size: 12.5px; margin-top: 18px; }

/* ---------------- 下载记录弹窗 ---------------- */
.modal-wide { max-width: 640px; }
.rec-sub { color: var(--text-soft); font-size: 12.5px; margin: 0 0 12px; }
.rec-wrap { max-height: 52vh; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.rec-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rec-table th, .rec-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.rec-table th { position: sticky; top: 0; background: var(--surface); color: var(--text-faint); font-weight: 600; z-index: 1; }
.rec-table tr:last-child td { border-bottom: none; }
.rec-table td:first-child { font-family: ui-monospace, Consolas, monospace; }
.badge-ban { color: var(--danger); font-weight: 600; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 560px) {
  .brand .sub { display: none; }
  .grid { grid-template-columns: 1fr; }
  .topbar .container { height: 58px; }
  .user-chip { display: none; }
  #help-btn span, #help-btn { font-size: 0; }
  #help-btn svg { width: 18px; height: 18px; }
}
