/* ============ 后台管理样式 ============ */
:root {
  --side: #101623;
  --side-line: #1d2736;
  --bg: #f3f5f9;
  --card: #fff;
  --line: #e4e8f0;
  --text: #232a38;
  --muted: #7b8498;
  --accent: #2563eb;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 10px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { text-decoration: none; color: var(--accent); }
img { display: block; }

/* ---------- 登录页 ---------- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(900px 500px at 20% -10%, #1d2b4d 0%, #0b101c 60%) fixed;
}
.login-card {
  width: 360px; max-width: 92vw; background: #141c2c; border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px; padding: 34px 30px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-logo { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 22px; color: #f1f5fb; letter-spacing: .5px; }
.login-card label { display: block; font-size: 13px; color: #9fb0c9; margin: 14px 0 7px; }
.login-card input {
  width: 100%; padding: 10px 12px; border: 1px solid rgba(255,255,255,.14); border-radius: 8px; outline: none; font-size: 14px;
  background: rgba(255,255,255,.06); color: #e6ecf5;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.18); }
.login-card input::placeholder { color: #7c8aa6; }
.login-err { background: rgba(220,38,38,.12); color: #ffb4b4; border: 1px solid rgba(220,38,38,.25); padding: 8px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 6px; }
.btn-block { width: 100%; margin-top: 20px; }
.login-tip { font-size: 12px; color: #8fa0ba; text-align: center; margin-top: 12px; }
.login-back { display: block; text-align: center; font-size: 13px; margin-top: 12px; color: #8fa0ba; }
.login-back:hover { color: #fff; }

/* ---------- 布局 ---------- */
.admin-body { display: flex; min-height: 100vh; }
.a-side {
  width: 210px; background: var(--side); color: #cdd6e4; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.a-logo { display: block; padding: 22px 20px; font-size: 17px; font-weight: 700; color: #fff; border-bottom: 1px solid var(--side-line); text-decoration: none; }
.a-logo:hover { color: #fff; opacity: .9; }
.a-nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.a-nav a { color: #9aa7bd; padding: 10px 14px; border-radius: 8px; font-size: 14px; }
.a-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.a-nav a.on { background: var(--accent); color: #fff; font-weight: 600; }
.a-side-foot { padding: 16px 10px; border-top: 1px solid var(--side-line); display: flex; flex-direction: column; gap: 6px; }
.a-side-foot a { color: #8fa0ba; padding: 8px 14px; font-size: 13px; }
.a-side-foot a:hover { color: #fff; }
.a-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.a-top { display: flex; align-items: center; justify-content: space-between; padding: 18px 26px; background: var(--card); border-bottom: 1px solid var(--line); }
.a-top h1 { font-size: 17px; }
.a-top span { color: var(--muted); font-size: 13px; }
.a-content { padding: 22px 26px; }

/* ---------- 组件 ---------- */
.a-flash { padding: 10px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.a-flash.ok { background: #f0fdf4; color: var(--ok); border: 1px solid #bbf7d0; }
.a-flash.err { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.a-warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stat-card b { display: block; font-size: 26px; color: var(--accent); }
.stat-card span { color: var(--muted); font-size: 13px; }
.a-h2 { font-size: 15px; margin: 22px 0 12px; color: #374151; }

.a-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.a-table th, .a-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
.a-table th { background: #f8fafc; color: #64748b; font-weight: 600; white-space: nowrap; }
.a-table tr:last-child td { border-bottom: none; }
.a-table tr:hover td { background: #f8fafc; }
.t-thumb { width: 72px; height: 40px; object-fit: cover; border-radius: 6px; background: #e2e8f0; display: block; transition: .2s; }
.t-thumb-link:hover .t-thumb { opacity: .8; border-color: var(--accent); }
.t-thumb-link { display: inline-block; position: relative; border: 1px solid transparent; border-radius: 6px; }
.t-storage { position: absolute; right: 2px; bottom: 2px; padding: 1px 5px; border-radius: 4px; font-size: 10px; line-height: 1.4; color: #fff; background: #64748b; pointer-events: none; }
.t-storage.q { background: #f59e0b; }
.t-storage.l { background: #3b82f6; }
.t-title { font-weight: 600; }
.t-title-link { color: inherit; cursor: pointer; }
.t-title-link:hover { color: var(--accent); text-decoration: underline; }
.t-title-input { width: 100%; min-width: 140px; box-sizing: border-box; padding: 2px 6px; font: inherit; color: inherit; background: #fff; border: 1px solid var(--accent); border-radius: 4px; outline: none; }
.t-title-link.saved { color: var(--ok); }
.t-sort-link { color: inherit; cursor: pointer; }
.t-sort-link:hover { color: var(--accent); text-decoration: underline; }
.t-sort-link.saved { color: var(--ok); }
.t-sort-input { width: 70px; box-sizing: border-box; padding: 2px 6px; font: inherit; color: inherit; background: #fff; border: 1px solid var(--accent); border-radius: 4px; outline: none; }
.t-disp-link { color: inherit; cursor: pointer; }
.t-disp-link:hover { color: var(--accent); text-decoration: underline; }
.t-disp-link.saved { color: var(--ok); }
.t-disp-input { width: 80px; box-sizing: border-box; padding: 2px 6px; font: inherit; color: inherit; background: #fff; border: 1px solid var(--accent); border-radius: 4px; outline: none; }
.t-pass-link.saved { color: var(--ok); }
.t-pass-input { width: 110px; box-sizing: border-box; padding: 2px 6px; font: inherit; color: inherit; background: #fff; border: 1px solid var(--accent); border-radius: 4px; outline: none; }
.t-cat-link { color: inherit; cursor: pointer; }
.t-cat-link:hover { color: var(--accent); text-decoration: underline; }
.t-cat-link.saved { color: var(--ok); }
.t-cat-input { font: inherit; color: inherit; background: #fff; border: 1px solid var(--accent); border-radius: 4px; padding: 2px 4px; outline: none; }
.t-sub { font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; background: #f1f5f9; color: #64748b; }
.badge.on { background: #dcfce7; color: var(--ok); }
.badge-btn { display: inline-block; padding: 4px 14px; border-radius: 999px; font-size: 12px; border: none; background: #f1f5f9; color: #64748b; cursor: pointer; transition: .2s; }
.badge-btn.on { background: #dcfce7; color: var(--ok); }
.badge-btn:hover { opacity: .85; filter: brightness(.97); }
.t-ops { white-space: nowrap; }
.t-ops form { display: inline; }
.tlink { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; padding: 2px 6px; }
.tlink:hover { text-decoration: underline; }
.tlink.danger { color: var(--danger); }
.a-empty { text-align: center; color: var(--muted); padding: 40px 0 !important; }

.btn {
  display: inline-block; padding: 8px 18px; border-radius: 8px; border: 1px solid #d1d5db;
  background: #fff; color: #374151; font-size: 14px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #1d4ed8; color: #fff; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar input[type=text], .toolbar-form input[type=text], .toolbar select, .toolbar-form select, .toolbar input[type=number] {
  padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px; outline: none;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--accent); }
.toolbar-count { margin-left: auto; color: var(--muted); font-size: 13px; }

.pager { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pg { min-width: 34px; text-align: center; padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px; color: #4b5563; font-size: 13px; background: #fff; }
.pg.current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- 表单 ---------- */
.a-form { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.form-row { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; color: #4b5563; margin-bottom: 6px; font-weight: 600; }
.a-form input[type=text], .a-form input[type=password], .a-form input[type=number], .a-form select, .a-form textarea {
  width: 100%; max-width: 520px; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; outline: none;
}
.a-form input:focus, .a-form select:focus, .a-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.check { font-size: 14px; color: #374151; display: inline-flex; align-items: center; gap: 6px; }
.form-check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: #374151; margin-top: 8px; cursor: pointer; }
.img-preview { margin-top: 10px; }
.img-preview img { max-width: 360px; max-height: 200px; border-radius: 8px; border: 1px solid var(--line); }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }

.a-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.a-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 12px; color: #0f172a; }
.cell-input { padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; outline: none; }
.cell-input:focus { border-color: var(--accent); }
.cell-sort { width: 72px; }
.inline-form { display: inline; }

/* ---------- 响应式：窄屏侧边栏转为顶部导航，表格可横滑 ---------- */
@media (max-width: 860px) {
  .admin-body { flex-direction: column; }
  .a-side {
    width: 100%; height: auto; position: static;
    flex-direction: row; align-items: center; flex-wrap: wrap;
    gap: 4px 8px; padding: 10px 14px;
  }
  .a-logo { padding: 0 14px 0 0; border-bottom: none; font-size: 15px; }
  .a-nav { flex-direction: row; flex-wrap: wrap; padding: 0; gap: 6px; flex: 1; }
  .a-nav a { padding: 7px 12px; font-size: 13px; }
  .a-side-foot { flex-direction: row; padding: 0; border-top: none; gap: 4px; }
  .a-side-foot a { padding: 7px 10px; font-size: 12px; }
  .a-top { padding: 12px 14px; }
  .a-top h1 { font-size: 16px; }
  .a-content { padding: 14px; }
  .a-table { display: block; overflow-x: auto; white-space: nowrap; }
  .a-cards { grid-template-columns: 1fr; }
  .form-actions { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .a-top span { display: none; }
  .a-content { padding: 10px; }
  .a-nav a { padding: 6px 9px; font-size: 12px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card { padding: 14px; }
  .stat-card b { font-size: 22px; }
  .toolbar-count { margin-left: 0; }
  .a-form { padding: 16px; }
  .a-card { padding: 16px; }
  .img-preview img { max-width: 100%; }
  .cell-sort { width: 60px; }
}
