/* ==========================================================================
   星火下载站 - 后台样式
   ========================================================================== */

:root {
  --bg: #f5f6fa;
  --panel: #ffffff;
  --panel-2: #fafbfe;
  --text: #12141c;
  --text-2: #3f4453;
  --muted: #7b8194;
  --line: #e9ecf3;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-soft: #eef2ff;
  --danger: #e11d48;
  --danger-soft: #fff1f4;
  --success: #059669;
  --success-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 4px 16px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.35; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.text-danger { color: var(--danger); }
.ta-c { text-align: center; }
.ta-r { text-align: right; }
.ico { width: 17px; height: 17px; flex: none; }
.link { color: var(--brand); font-size: 13px; font-weight: 600; }
.link:hover { text-decoration: underline; }

/* ---------- 骨架 ---------- */
.shell { display: grid; grid-template-columns: 238px minmax(0, 1fr); min-height: 100vh; }

.aside {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 18px 14px;
  z-index: 30;
}
.aside__brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.aside__mark {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 16px -8px rgba(79, 70, 229, .8);
}
.aside__mark svg { width: 19px; height: 19px; }
.aside__name { display: flex; flex-direction: column; font-weight: 800; font-size: 15px; line-height: 1.25; min-width: 0; }
.aside__name small { font-weight: 500; font-size: 11.5px; color: var(--muted); }

.aside__nav { display: flex; flex-direction: column; gap: 3px; }
.aside__link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  transition: background .16s, color .16s;
}
.aside__link:hover { background: var(--bg); color: var(--text); }
.aside__link.is-on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.aside__link--muted { color: var(--muted); font-size: 13px; }

.aside__bottom { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.aside__user { display: flex; align-items: center; gap: 9px; padding: 8px 6px; }
.avatar {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  color: #fff; background: linear-gradient(135deg, #6366f1, #a855f7);
}
.aside__user-info { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.aside__user-info b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aside__user-info small { font-size: 11px; color: var(--muted); }
.form-inline { margin: 0; }

.content { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  height: 64px; padding: 0 26px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar__title { font-size: 17px; font-weight: 800; letter-spacing: -.2px; }
.topbar__right { display: flex; align-items: center; gap: 10px; }

.page { padding: 22px 26px 48px; display: flex; flex-direction: column; gap: 18px; }

/* ---------- 提示 ---------- */
.alert { padding: 11px 15px; border-radius: 11px; font-size: 13.5px; border: 1px solid transparent; }
.alert a { font-weight: 700; text-decoration: underline; }
.alert--success { background: var(--success-soft); color: var(--success); border-color: #bbf7d0; }
.alert--danger { background: var(--danger-soft); color: var(--danger); border-color: #fecdd3; }
.alert--warn { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.alert--info { background: var(--brand-soft); color: var(--brand); border-color: #dfe3ff; }

/* ---------- 统计卡片 ---------- */
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.stat {
  display: flex; gap: 13px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 17px; box-shadow: var(--shadow-sm);
}
.stat__icon {
  width: 40px; height: 40px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
}
.stat__icon svg { width: 19px; height: 19px; }
.stat__icon--indigo { background: #eef2ff; color: #4f46e5; }
.stat__icon--violet { background: #f5f3ff; color: #7c3aed; }
.stat__icon--emerald { background: #ecfdf5; color: #059669; }
.stat__icon--amber { background: #fffbeb; color: #b45309; }
.stat__label { font-size: 12.5px; color: var(--muted); }
.stat__num { font-size: 25px; font-weight: 800; line-height: 1.2; letter-spacing: -.6px; }
.stat__sub { font-size: 11.5px; color: var(--muted); }
.stat__sub a { color: var(--brand); }

/* ---------- 卡片 ---------- */
.cols { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.cols--wide { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card--sticky { position: sticky; top: 82px; }
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.card__title { font-size: 14.5px; font-weight: 700; }
.card__body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.card__foot { padding: 12px 18px; border-top: 1px solid var(--line); font-size: 12.5px; }

/* ---------- 表格 ---------- */
.tablewrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--muted);
  padding: 10px 14px; background: var(--panel-2);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--brand) 3%, transparent); }
.table--compact td { padding: 10px 18px; }

.cell-item { display: flex; align-items: center; gap: 11px; min-width: 0; }
.cell-item__text { min-width: 0; }
.thumb {
  width: 54px; height: 38px; border-radius: 8px; flex: none;
  object-fit: cover; display: grid; place-items: center;
  color: #fff; font-size: 10.5px; font-weight: 800;
}
.cell-title { font-weight: 600; color: var(--text); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 340px; }
.cell-title:hover { color: var(--brand); }
.cell-sub { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge--on { background: var(--success-soft); color: var(--success); }
.badge--off { background: #f3f4f6; color: #6b7280; }
.badge--demo { background: var(--warn-soft); color: var(--warn); }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--line);
  font-size: 11.5px; color: var(--muted); white-space: nowrap;
}

.rowactions { display: inline-flex; align-items: center; gap: 4px; justify-content: flex-end; }
.rowactions form { margin: 0; }
.icon-btn {
  width: 31px; height: 31px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer;
  display: inline-grid; place-items: center; transition: .15s;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--bg); color: var(--brand); border-color: var(--line); }
.icon-btn--danger:hover { background: var(--danger-soft); color: var(--danger); border-color: #fecdd3; }

/* ---------- 筛选栏 ---------- */
.filterbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.search-input { position: relative; display: flex; align-items: center; }
.search-input svg { position: absolute; left: 11px; width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.search-input .input { padding-left: 33px; width: 230px; }

/* ---------- 表单控件 ---------- */
.input {
  height: 38px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--panel);
  outline: none; width: 100%; transition: border-color .16s, box-shadow .16s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent); }
.input--sm { height: 32px; font-size: 13px; }
.input--lg { height: 44px; font-size: 15px; font-weight: 600; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.filterbar .select { width: auto; min-width: 116px; }
.textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.7; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: 12.5px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.field__hint { font-weight: 400; color: var(--muted); font-size: 11.5px; }
.req { color: var(--danger); font-style: normal; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.inline-form { display: flex; align-items: center; gap: 8px; }
.inline-form .input { max-width: 220px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 15px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-size: 13.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: .16s;
}
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 8px 16px -9px rgba(79, 70, 229, .9); }
.btn--primary:hover { filter: brightness(1.06); }
.btn--light { background: var(--panel); border-color: var(--line); color: var(--text-2); }
.btn--light:hover { border-color: var(--brand); color: var(--brand); }
.btn--ghost { background: transparent; color: var(--muted); }
.btn--ghost:hover { color: var(--brand); }
.btn--danger { background: var(--danger-soft); color: var(--danger); border-color: #fecdd3; }
.btn--danger:hover { background: var(--danger); color: #fff; }
.btn--sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn--lg { height: 44px; font-size: 14.5px; }
.btn--block { width: 100%; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); }
.pager__item { padding: 6px 14px; border-radius: 8px; border: 1px solid var(--line); font-size: 13px; color: var(--text-2); background: var(--panel); }
.pager__item:hover { border-color: var(--brand); color: var(--brand); }
.pager__info { font-size: 12.5px; color: var(--muted); }

/* ---------- 空状态 ---------- */
.emptybox { padding: 46px 20px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; color: var(--muted); }

/* ---------- 时间线 ---------- */
.timeline { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.timeline li { display: flex; gap: 11px; }
.timeline__dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.timeline__title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 330px; }
.timeline__meta { font-size: 11.5px; color: var(--muted); }

/* ---------- 表单布局 ---------- */
.formgrid { display: grid; grid-template-columns: minmax(0, 1fr) 302px; gap: 18px; align-items: start; }
.formgrid__main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.formgrid__side { display: flex; flex-direction: column; gap: 18px; }

/* 单选卡片 */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice__box {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px; border-radius: 11px;
  border: 1.5px solid var(--line); background: var(--panel-2);
  transition: .16s;
}
.choice__box b { font-size: 13.5px; }
.choice__box small { font-size: 11.5px; color: var(--muted); }
.choice input:checked + .choice__box { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 10%, transparent); }

/* 上传区 */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 26px 18px; border: 1.5px dashed color-mix(in srgb, var(--muted) 45%, transparent);
  border-radius: 12px; background: var(--panel-2);
  cursor: pointer; text-align: center; transition: .16s;
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--brand); background: var(--brand-soft); }
.dropzone svg { width: 26px; height: 26px; color: var(--brand); }
.dropzone__title { font-size: 13.5px; font-weight: 600; }
.dropzone__hint { font-size: 11.5px; color: var(--muted); }
.dropzone__input { display: none; }
.dropzone__picked:not(:empty) {
  margin-top: 6px; font-size: 12px; color: var(--brand); font-weight: 600;
  background: var(--brand-soft); padding: 3px 10px; border-radius: 6px;
}

/* 文件 / 封面预览 */
.filebox {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--panel-2); font-size: 13px;
}
.filebox__ext {
  width: 40px; height: 40px; border-radius: 9px; flex: none;
  display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 800;
}
.filebox__text { min-width: 0; display: flex; flex-direction: column; }
.filebox__text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filebox__text small { color: var(--muted); font-size: 11.5px; }
.filebox__del { margin-left: auto; font-size: 12px; color: var(--danger); white-space: nowrap; display: flex; align-items: center; gap: 5px; }

.coverbox { display: flex; align-items: center; gap: 14px; }
.coverbox img { width: 168px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.coverbox__del { font-size: 12.5px; color: var(--danger); display: flex; align-items: center; gap: 5px; }

.meta-note { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; padding-top: 10px; border-top: 1px dashed var(--line); }
.meta-note a { color: var(--brand); }

.infolist { display: flex; flex-direction: column; gap: 9px; font-size: 12.5px; }
.infolist li { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
.infolist li:last-child { border-bottom: 0; padding-bottom: 0; }
.infolist span { color: var(--muted); }
.infolist b { font-weight: 600; text-align: right; overflow-wrap: anywhere; }

/* 封面渐变（与前台一致） */
.cover--tone-zip { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.cover--tone-win { background: linear-gradient(135deg, #2563eb, #06b6d4); }
.cover--tone-app { background: linear-gradient(135deg, #10b981, #0ea5e9); }
.cover--tone-img { background: linear-gradient(135deg, #7c3aed, #ec4899); }
.cover--tone-doc { background: linear-gradient(135deg, #f43f5e, #f97316); }
.cover--tone-media { background: linear-gradient(135deg, #db2777, #8b5cf6); }
.cover--tone-file { background: linear-gradient(135deg, #475569, #0f172a); }

/* ---------- 登录页 ---------- */
body.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 12% 0%, #eef2ff, transparent 60%),
    radial-gradient(800px 500px at 95% 100%, #f5f3ff, transparent 55%),
    var(--bg);
}
.auth__card {
  width: 100%; max-width: 880px; display: grid; grid-template-columns: 1fr 1fr;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 22px; overflow: hidden; box-shadow: 0 26px 60px -30px rgba(30, 27, 75, .4);
}
.auth__side {
  position: relative; overflow: hidden; padding: 40px 34px;
  color: #fff; display: flex; flex-direction: column; gap: 14px;
  background: linear-gradient(150deg, #4f46e5, #7c3aed 60%, #a855f7);
}
.auth__side::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(380px 220px at 85% 5%, rgba(255, 255, 255, .3), transparent 65%);
}
.auth__brand { position: relative; display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; }
.auth__brand .aside__mark { background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .28); }
.auth__slogan { position: relative; font-size: 14px; color: rgba(255, 255, 255, .85); }
.auth__list { position: relative; display: flex; flex-direction: column; gap: 9px; margin-top: 10px; font-size: 13px; color: rgba(255, 255, 255, .9); }
.auth__list li { display: flex; align-items: center; gap: 8px; }
.auth__list svg { width: 15px; height: 15px; flex: none; }
.auth__back { position: relative; margin-top: auto; font-size: 12.5px; color: rgba(255, 255, 255, .8); }
.auth__back:hover { color: #fff; }

.auth__form { padding: 40px 34px; display: flex; flex-direction: column; gap: 16px; }
.auth__title { font-size: 21px; font-weight: 800; }
.auth__sub { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.auth__form form { display: flex; flex-direction: column; gap: 14px; }
.auth__tip { font-size: 12px; color: var(--muted); }
.auth__tip code { background: var(--bg); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; font-size: 11.5px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1120px) {
  .cols, .cols--wide { grid-template-columns: minmax(0, 1fr); }
  .formgrid { grid-template-columns: minmax(0, 1fr); }
  .card--sticky { position: static; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .aside { position: static; height: auto; flex-direction: row; align-items: center; gap: 12px; padding: 10px 14px; overflow-x: auto; }
  .aside__brand { padding: 0 6px 0 0; flex: none; }
  .aside__name { display: none; }
  .aside__nav { flex-direction: row; gap: 4px; flex: none; }
  .aside__link { padding: 8px 12px; white-space: nowrap; }
  .aside__bottom { margin: 0 0 0 auto; flex-direction: row; align-items: center; border-top: 0; padding-top: 0; flex: none; }
  .aside__link--muted { display: none; }
  .aside__user { padding: 0; }
  .aside__user-info { display: none; }
  .topbar { height: auto; padding: 12px 16px; }
  .topbar__right .btn span { display: none; }
  .page { padding: 16px 14px 40px; }
  .cell-title { max-width: 180px; }
}

@media (max-width: 700px) {
  .auth__card { grid-template-columns: minmax(0, 1fr); max-width: 440px; }
  .auth__side { padding: 26px 24px; }
  .auth__list { display: none; }
  .auth__form { padding: 26px 24px 30px; }
  .choices { grid-template-columns: minmax(0, 1fr); }
  .filterbar .search-input, .search-input .input { width: 100%; }
  .filterbar { width: 100%; }
}
