:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-soft: #f7f9fd;
  --border: #e3e8f2;
  --text: #0f172a;
  --text-secondary: #5b667a;
  --text-muted: #8b95a7;
  --brand: #0a5bd3;
  --brand-deep: #051c5c;
  --brand-cyan: #00c8ff;
  --brand-soft: #e6f0fe;
  --green: #16a34a;
  --green-soft: #e6f7ec;
  --orange: #d97706;
  --orange-soft: #fef3e2;
  --red: #dc2626;
  --red-soft: #fdecec;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 2px 10px rgba(10, 35, 90, 0.04);
  --shadow-md: 0 12px 32px rgba(10, 35, 90, 0.09);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }

/* 顶部导航 */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 20px; height: 64px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand-group { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; box-shadow: 0 4px 12px rgba(10, 91, 211, 0.25); }
.brand-title { font-size: 17px; font-weight: 700; letter-spacing: 0.2px; }
.brand-sub { font-size: 12px; color: var(--text-secondary); }

.nav-actions { display: flex; align-items: center; gap: 10px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.16s ease;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, #0d62e8 0%, #073494 100%);
  color: #fff; box-shadow: 0 4px 14px rgba(10, 91, 211, 0.28);
}
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-soft); border-color: #cdd6e6; }
.btn-soft { background: var(--brand-soft); color: var(--brand); }
.btn-soft:hover { background: #d6e6fd; }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: #fbd8d8; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* 英雄横幅 */
.hero {
  background: radial-gradient(circle at 88% 15%, rgba(0, 200, 255, 0.26), transparent 44%),
              linear-gradient(135deg, #04154a 0%, #093ba1 55%, #0e63de 100%);
  color: #fff; padding: 40px 20px 44px;
}
.hero-inner { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.hero h1 { margin: 0 0 8px; font-size: 30px; font-weight: 800; letter-spacing: 0.3px; }
.hero p { margin: 0; font-size: 15px; color: rgba(255, 255, 255, 0.82); max-width: 620px; line-height: 1.6; }
.hero-stats { display: flex; gap: 24px; }
.hero-stat { background: rgba(255, 255, 255, 0.11); border: 1px solid rgba(255, 255, 255, 0.18); padding: 12px 18px; border-radius: 14px; min-width: 112px; }
.hero-stat .num { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hero-stat .lbl { font-size: 12px; color: rgba(255, 255, 255, 0.78); margin-top: 2px; }

/* 主容器 */
.container { max-width: 1180px; margin: 0 auto; padding: 24px 20px 64px; }

/* 工具条 */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.segmented {
  display: inline-flex; background: #e6ebf5; padding: 3px; border-radius: 11px; gap: 2px;
}
.segmented button {
  border: 0; background: transparent; color: var(--text-secondary);
  padding: 7px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: 0.15s;
}
.segmented button.active { background: #fff; color: var(--brand); box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08); }

.search-input {
  height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 14px; min-width: 240px; outline: none;
}
.search-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(10, 91, 211, 0.12); }

/* 卡片网格 */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; }
.product-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 16px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.card-head { display: flex; align-items: center; gap: 14px; }
.app-icon { width: 58px; height: 58px; border-radius: 14px; object-fit: cover; flex-shrink: 0; box-shadow: 0 4px 14px rgba(10, 35, 90, 0.14); }
.card-title-wrap { flex: 1; min-width: 0; }
.card-title { margin: 0; font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 5px; }
.card-summary { margin: 0; font-size: 13.5px; color: var(--text-secondary); line-height: 1.55; min-height: 42px; }

/* 徽标 */
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 600;
}
.badge-blue { background: var(--brand-soft); color: var(--brand); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-orange { background: var(--orange-soft); color: var(--orange); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-gray { background: #edf0f7; color: var(--text-secondary); }

/* 最新版本块 */
.release-box {
  background: var(--surface-soft); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 12px 14px;
}
.release-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ver-text { font-size: 15px; font-weight: 700; color: var(--text); }
.release-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; }
.changelog-preview {
  margin: 10px 0 0; padding: 10px 0 0; border-top: 1px dashed var(--border);
  font-size: 12.5px; color: var(--text-secondary); line-height: 1.6; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

.card-footer { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.card-footer .btn-primary { flex: 1; }

/* 后台统计卡片 */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.stat-card .lbl { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.stat-card .val { font-size: 28px; font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums; color: var(--text); }
.stat-card .val.accent { color: var(--brand); }

/* 表格与面板 */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 22px;
}
.panel-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; padding: 12px 16px; color: var(--text-secondary); font-weight: 600; background: var(--surface-soft); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }

/* 原生 Dialog 弹窗 */
dialog {
  border: 1px solid var(--border); border-radius: 20px; padding: 0; width: min(560px, 94vw);
  max-height: 90vh; box-shadow: 0 24px 64px rgba(10, 25, 60, 0.28); background: var(--surface); color: var(--text);
}
dialog.dialog-wide { width: min(860px, 95vw); }
dialog::backdrop { background: rgba(9, 15, 32, 0.52); backdrop-filter: blur(4px); }
.dialog-head {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.dialog-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.dialog-close {
  width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--surface-soft);
  color: var(--text-secondary); font-size: 18px; cursor: pointer; display: grid; place-items: center;
}
.dialog-close:hover { background: #e6ebf5; color: var(--text); }
.dialog-body { padding: 20px 22px; overflow-y: auto; max-height: calc(90vh - 130px); }
.dialog-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: var(--surface-soft); }

/* 表单 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.form-field input[type="text"],
.form-field input[type="password"],
.form-field input[type="number"],
.form-field select,
.form-field textarea {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 14px; outline: none;
}
.form-field textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(10, 91, 211, 0.12);
}
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }

/* 拖拽上传区 */
.dropzone {
  border: 2px dashed #c4d2ea; border-radius: 14px; padding: 24px 16px; text-align: center;
  background: var(--surface-soft); cursor: pointer; transition: 0.16s;
}
.dropzone.dragover { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .dz-title { font-size: 14.5px; font-weight: 600; color: var(--text); }
.dropzone .dz-sub { font-size: 12.5px; color: var(--text-secondary); margin-top: 4px; }
.progress-bar-wrap { height: 8px; background: #e3e8f2; border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress-bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, #0d62e8, #00c8ff); transition: width 0.12s linear; }

/* 登录屏 */
.login-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(circle at 50% 0%, rgba(10, 91, 211, 0.14), transparent 55%), var(--bg);
}
.login-card {
  width: min(400px, 94vw); background: var(--surface); border: 1px solid var(--border);
  border-radius: 22px; padding: 34px 28px; box-shadow: var(--shadow-md);
}
.login-card .logo-wrap { text-align: center; margin-bottom: 24px; }
.login-card .logo-wrap img { width: 72px; height: 72px; border-radius: 18px; box-shadow: 0 10px 26px rgba(10, 91, 211, 0.28); }
.login-card h1 { margin: 14px 0 4px; font-size: 21px; font-weight: 800; }
.login-card p { margin: 0; font-size: 13px; color: var(--text-secondary); }

/* Toast */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-16px);
  background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 99px;
  font-size: 13.5px; font-weight: 600; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
  opacity: 0; pointer-events: none; transition: all 0.22s ease; z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty-box { text-align: center; padding: 48px 20px; color: var(--text-secondary); }

/* ═════════ v2.0 Pro SaaS 侧边栏后台布局 ═════════ */
.admin-shell {
  display: flex; min-height: 100vh; background: var(--bg);
}
.sidebar {
  width: 244px; flex-shrink: 0;
  background: linear-gradient(180deg, #041446 0%, #07226b 60%, #092c85 100%);
  color: #fff; display: flex; flex-direction: column; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12); margin-bottom: 16px;
}
.sidebar-brand img { width: 38px; height: 38px; border-radius: 10px; box-shadow: 0 6px 18px rgba(0, 200, 255, 0.28); }
.sidebar-brand .t1 { font-size: 15.5px; font-weight: 800; letter-spacing: 0.2px; }
.sidebar-brand .t2 { font-size: 11px; color: rgba(255, 255, 255, 0.65); margin-top: 2px; }

.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side-nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; border: 0;
  background: transparent; color: rgba(255, 255, 255, 0.76); padding: 11px 13px;
  border-radius: 11px; font-size: 14px; font-weight: 600; cursor: pointer; text-align: left;
  transition: all 0.16s ease;
}
.side-nav button:hover { background: rgba(255, 255, 255, 0.09); color: #fff; }
.side-nav button.active {
  background: linear-gradient(90deg, rgba(13, 98, 232, 0.9), rgba(0, 200, 255, 0.35));
  color: #fff; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.side-foot {
  padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex; flex-direction: column; gap: 8px;
}
.side-foot .user-tag { font-size: 12px; color: rgba(255, 255, 255, 0.72); padding: 0 8px; }
.side-foot-btns { display: flex; gap: 6px; }
.side-foot-btns button, .side-foot-btns a {
  flex: 1; height: 32px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08); color: #fff; font-size: 12px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.side-foot-btns button:hover, .side-foot-btns a:hover { background: rgba(255, 255, 255, 0.18); }

.admin-main { flex: 1; min-width: 0; padding: 24px 28px 56px; max-width: 1320px; }
.page-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 22px; font-weight: 800; }
.page-head .sub { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }

/* 近 7 天下载趋势柱状图 */
.trend-chart {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px;
  align-items: end; height: 170px; padding: 20px 20px 16px;
}
.trend-col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.trend-bar-wrap { width: 100%; max-width: 44px; flex: 1; display: flex; align-items: flex-end; background: var(--surface-soft); border-radius: 8px; overflow: hidden; }
.trend-bar {
  width: 100%; min-height: 4px; border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, #00c8ff 0%, #0a5bd3 100%);
  transition: height 0.35s ease;
}
.trend-val { font-size: 12px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.trend-lbl { font-size: 11.5px; color: var(--text-muted); }

.qr-preview-box {
  display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 10px 0;
}
.qr-preview-box img {
  width: 200px; height: 200px; border-radius: 16px; border: 1px solid var(--border); padding: 8px; background: #fff;
}

@media (max-width: 860px) {
  .admin-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; padding: 14px; }
  .side-nav { flex-direction: row; overflow-x: auto; }
  .side-nav button { white-space: nowrap; width: auto; }
  .admin-main { padding: 18px 14px 48px; }
}

@media (max-width: 680px) {
  .form-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 24px; }
  .card-grid { grid-template-columns: 1fr; }
}
