/* ==========================================================================
   资源下载门户 —— 后台样式
   ========================================================================== */

:root {
  --primary: #0e7c66;
  --primary-dark: #0a5f4e;
  --primary-soft: #e8f4f1;
  --primary-line: #cfe6e0;

  --text: #1b2733;
  --text-2: #5b6b7c;
  --text-3: #93a1ae;

  --bg: #f2f5f5;
  --card: #ffffff;
  --border: #e6eaec;
  --border-2: #eef1f2;

  --sidebar-bg: #16232a;
  --sidebar-text: #9fb3b8;
  --sidebar-active: #0e7c66;

  --radius: 10px;
  --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ------------------------------ 布局 ------------------------------ */

.admin-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px;
  background: var(--sidebar-bg);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px 20px 18px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.sidebar-brand .mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.sidebar-brand .txt { line-height: 1.25; }
.sidebar-brand .txt small { display: block; font-size: 11px; font-weight: 400; color: var(--sidebar-text); }

.nav-group { padding: 16px 0 4px; }

.nav-group-title {
  padding: 0 20px 8px;
  font-size: 11px;
  letter-spacing: 1px;
  color: #5d7079;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  border-left: 3px solid transparent;
  transition: all .15s;
}

.nav-item:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.nav-item.active {
  background: rgba(14, 124, 102, .16);
  color: #fff;
  border-left-color: var(--primary);
  font-weight: 500;
}

.nav-item .ico { width: 17px; text-align: center; font-size: 14px; opacity: .9; }

.sidebar-foot {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, .07);
  font-size: 12px;
  color: #5d7079;
}
.sidebar-foot a { color: var(--sidebar-text); }
.sidebar-foot a:hover { color: #fff; }

/* ------------------------------ 主区 ------------------------------ */

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

.topbar {
  height: 58px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 { margin: 0; font-size: 16.5px; font-weight: 600; }

.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 13.5px; }

.topbar-right .who { color: var(--text-2); }
.topbar-right .who b { color: var(--text); }

.content { padding: 22px 24px 48px; }

/* ------------------------------ 卡片 ------------------------------ */

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-2);
  flex-wrap: wrap;
}

.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head .sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

/* ------------------------------ 统计卡 ------------------------------ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-card .ico {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}

.stat-card .k { font-size: 12.5px; color: var(--text-3); margin-bottom: 2px; }
.stat-card .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-card .v small { font-size: 12.5px; font-weight: 500; color: var(--text-3); margin-left: 2px; }

/* ------------------------------ 图表 ------------------------------ */

.chart-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 170px;
  padding-top: 10px;
}

.bar-chart .bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 6px;
  min-width: 0;
}

.bar-chart .bar {
  width: 100%;
  max-width: 30px;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
  min-height: 3px;
  transition: opacity .15s;
  position: relative;
}
.bar-chart .bar-wrap:hover .bar { opacity: .75; }

.bar-chart .bar-val {
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.bar-chart .bar-lbl { font-size: 10.5px; color: var(--text-3); white-space: nowrap; }

.dist-list { padding: 4px 0; }
.dist-item { margin-bottom: 14px; }
.dist-item .dt { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.dist-item .dt .n { color: var(--text-2); }
.dist-item .dt .c { color: var(--text-3); font-variant-numeric: tabular-nums; }
.dist-item .track { height: 7px; background: var(--border-2); border-radius: 4px; overflow: hidden; }
.dist-item .track i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }

/* ------------------------------ 表格 ------------------------------ */

.tbl-wrap { overflow-x: auto; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }

table.tbl th {
  text-align: left;
  padding: 11px 14px;
  background: #fafbfb;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
}

table.tbl td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-2);
  vertical-align: middle;
}

table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: #fafcfb; }

table.tbl .t-title { font-weight: 500; max-width: 380px; }
table.tbl .t-title a:hover { color: var(--primary); }

table.tbl .nowrap { white-space: nowrap; }
table.tbl .num { font-variant-numeric: tabular-nums; }

/* ------------------------------ 徽章 ------------------------------ */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 11px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.7;
  white-space: nowrap;
}
.badge-green { background: #e8f4f1; color: #0a5f4e; }
.badge-gray { background: #f1f4f5; color: #5b6b7c; }
.badge-amber { background: #fffbeb; color: #92400e; }
.badge-red { background: #fef2f2; color: #b91c1c; }
.badge-blue { background: #eff6ff; color: #1d4ed8; }

/* ------------------------------ 表单 ------------------------------ */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
}
.form-grid .full { grid-column: 1 / -1; }

.field { margin-bottom: 0; }
.field > label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.field > label .req { color: #b91c1c; margin-left: 2px; }

.field input[type="text"],
.field input[type="number"],
.field input[type="email"],
.field input[type="password"],
.field input[type="file"],
.field select,
.field textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fbfcfc;
  color: var(--text);
  outline: none;
  transition: all .16s;
}

.field input[type="file"] { padding: 8px 12px; height: auto; }

.field textarea { height: auto; min-height: 92px; padding: 10px 12px; resize: vertical; line-height: 1.65; }

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(14, 124, 102, .08);
}

.field .hint { margin-top: 5px; font-size: 12px; color: var(--text-3); }

.field-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
}
.switch input { width: 38px; height: 21px; appearance: none; background: #cbd5e1; border-radius: 11px; position: relative; cursor: pointer; transition: background .18s; flex-shrink: 0; }
.switch input::after {
  content: '';
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s;
}
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(17px); }
.switch span { font-size: 13.5px; color: var(--text-2); }

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 9px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fbfcfc;
}
.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
}
.checkbox-grid input { width: 15px; height: 15px; accent-color: var(--primary); }

/* ------------------------------ 按钮 ------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-size: 13.5px;
  white-space: nowrap;
  transition: all .16s;
}
.btn:hover { background: var(--primary-dark); color: #fff; }

.btn-ghost { background: #fff; border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }

.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; }
.btn-block { width: 100%; }

.btn-link {
  background: none;
  border: 0;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  font-size: 13px;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: #dc2626; }

/* ------------------------------ 筛选条 ------------------------------ */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar input[type="text"], .toolbar select {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  outline: none;
  min-width: 150px;
}
.toolbar input[type="text"]:focus, .toolbar select:focus { border-color: var(--primary); }

/* ------------------------------ 分页 ------------------------------ */

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 18px 0 4px;
  flex-wrap: wrap;
}
.pager a, .pager span {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.pager a:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.pager .cur { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.pager .dots { border: 0; background: transparent; color: var(--text-3); }
.pager .disabled { color: #cbd5e1; background: #fafbfb; }

/* ------------------------------ 提示 ------------------------------ */

.alert {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.alert-info { background: var(--primary-soft); border: 1px solid var(--primary-line); color: var(--primary-dark); }

.empty-tip { padding: 48px 20px; text-align: center; color: var(--text-3); font-size: 13.5px; }

/* ------------------------------ 登录页 ------------------------------ */

.admin-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #16232a;
  padding: 24px;
}

.admin-login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 14px;
  padding: 38px 34px 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
}

.admin-login-card .brand {
  text-align: center;
  margin-bottom: 26px;
}

.admin-login-card .brand .mark {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 23px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.admin-login-card .brand h1 { margin: 0 0 5px; font-size: 18px; font-weight: 600; }
.admin-login-card .brand p { margin: 0; font-size: 12.5px; color: var(--text-3); }

.admin-login-card .btn { height: 42px; margin-top: 8px; }

.admin-login-foot {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border-2);
  text-align: center;
  font-size: 12.5px;
  color: var(--text-3);
}
.admin-login-foot a { color: var(--primary); }

/* ------------------------------ 详情栅格 ------------------------------ */

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.kv-list { padding: 4px 0; }
.kv-list .kv {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-2);
  font-size: 13.5px;
}
.kv-list .kv:last-child { border-bottom: 0; }
.kv-list .kv .k { color: var(--text-3); flex-shrink: 0; }
.kv-list .kv .v { text-align: right; word-break: break-all; }

/* ------------------------------ 响应式 ------------------------------ */

@media (max-width: 1100px) {
  .chart-row { grid-template-columns: minmax(0, 1fr); }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 820px) {
  .sidebar { width: 62px; }
  .sidebar-brand .txt, .nav-group-title, .nav-item span:not(.ico), .sidebar-foot { display: none; }
  .nav-item { justify-content: center; padding: 12px 0; }
  .nav-item .ico { font-size: 17px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .content { padding: 16px 14px 40px; }
  .topbar { padding: 0 14px; }
}
