/* ==========================================================
   后台管理界面
   ========================================================== */
:root {
  --a-primary: #4a5568; --a-primary-dark: #2d3748; --a-primary-light: #718096;
  --a-accent: #17a2b8; --a-green: #28a745; --a-orange: #fd7e14;
  --a-red: #dc3545; --a-purple: #6f42c1; --a-yellow: #ffc107;
  --a-bg: #f4f6f9; --a-surface: #ffffff; --a-border: #e3e8ef;
  --a-text: #212529; --a-muted: #6c757d;
  --a-shadow: 0 2px 10px rgba(23, 43, 77, .08);
  --a-radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--a-bg); color: var(--a-text); min-height: 100vh; line-height: 1.6;
}
a { color: var(--a-primary); text-decoration: none; }
a:hover { color: var(--a-accent); }
h1, h2, h3 { color: var(--a-text); }

/* ---------- 布局 ---------- */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: linear-gradient(180deg, #3c4658 0%, #222b38 100%);
  color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.sidebar-brand { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-brand strong { font-size: 1.15rem; display: block; letter-spacing: .5px; }
.sidebar-brand span { font-size: .8rem; opacity: .65; }
.sidebar-nav { padding: 14px 10px; flex: 1; }
.nav-title { font-size: .72rem; text-transform: uppercase; letter-spacing: 1.2px; opacity: .5; padding: 12px 12px 6px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px;
  color: rgba(255,255,255,.82); font-size: .93rem; margin-bottom: 2px; transition: all .2s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-nav a.active { background: linear-gradient(135deg, #17a2b8, #138496); color: #fff; font-weight: 600; box-shadow: 0 4px 12px rgba(23,162,184,.3); }
.sidebar-nav .ico { width: 20px; text-align: center; font-size: 1.05rem; }
.sidebar-foot { padding: 14px 18px; font-size: .78rem; opacity: .55; border-top: 1px solid rgba(255,255,255,.1); }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--a-surface); border-bottom: 1px solid var(--a-border);
  padding: 12px 26px; display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 100;
}
.topbar h1 { font-size: 1.25rem; font-weight: 700; }
.topbar .breadcrumb { font-size: .82rem; color: var(--a-muted); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-right .who { font-size: .88rem; color: var(--a-muted); }
.admin-content { padding: 22px 26px 40px; flex: 1; }

/* ---------- 卡片 / 统计 ---------- */
.card { background: var(--a-surface); border: 1px solid var(--a-border); border-radius: var(--a-radius); box-shadow: var(--a-shadow); margin-bottom: 20px; }
.card-head { padding: 15px 20px; border-bottom: 1px solid var(--a-border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head h2 { font-size: 1.05rem; font-weight: 700; }
.card-head .sub { font-size: .83rem; color: var(--a-muted); }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--a-surface); border: 1px solid var(--a-border); border-radius: var(--a-radius); box-shadow: var(--a-shadow); padding: 18px 20px; position: relative; overflow: hidden; }
.stat-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--a-accent); }
.stat-card.c2::before { background: var(--a-green); } .stat-card.c3::before { background: var(--a-orange); }
.stat-card.c4::before { background: var(--a-purple); } .stat-card.c5::before { background: var(--a-yellow); }
.stat-card.c6::before { background: var(--a-red); }
.stat-label { font-size: .85rem; color: var(--a-muted); }
.stat-value { font-size: 1.9rem; font-weight: 800; line-height: 1.3; margin-top: 4px; }
.stat-foot { font-size: .78rem; color: var(--a-muted); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; font-size: .9rem; font-weight: 600;
  background: var(--a-primary); color: #fff; border: 1px solid transparent; cursor: pointer;
  transition: all .2s; white-space: nowrap;
}
.btn:hover { background: var(--a-primary-dark); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,.14); }
.btn-primary { background: linear-gradient(135deg, #17a2b8, #138496); }
.btn-primary:hover { background: linear-gradient(135deg, #138496, #117a8b); }
.btn-success { background: var(--a-green); } .btn-success:hover { background: #218838; }
.btn-warning { background: var(--a-yellow); color: #212529; } .btn-warning:hover { background: #e0a800; color: #212529; }
.btn-danger { background: var(--a-red); } .btn-danger:hover { background: #c82333; }
.btn-purple { background: var(--a-purple); } .btn-purple:hover { background: #5a32a3; }
.btn-ghost { background: #fff; color: var(--a-primary); border-color: var(--a-border); }
.btn-ghost:hover { background: var(--a-bg); color: var(--a-primary); box-shadow: none; }
.btn-sm { padding: 5px 10px; font-size: .8rem; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 6px; color: #495057; }
.field label .req { color: var(--a-red); }
.field input[type=text], .field input[type=password], .field input[type=number], .field input[type=date],
.field input[type=url], .field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--a-border); border-radius: 8px;
  background: #fff; color: var(--a-text); font-size: .92rem; outline: none; transition: all .2s;
}
.field textarea { min-height: 110px; resize: vertical; line-height: 1.7; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--a-accent); box-shadow: 0 0 0 3px rgba(23,162,184,.14); }
.field .hint { font-size: .8rem; color: var(--a-muted); margin-top: 5px; }
.check-line { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; margin-top: 6px; }
.check-line input { width: auto; }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--a-border); }
.filter-bar input[type=text], .filter-bar select { padding: 8px 11px; border: 1px solid var(--a-border); border-radius: 8px; font-size: .9rem; background: #fff; outline: none; }
.filter-bar input[type=text] { min-width: 220px; }
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--a-accent); }
.filter-bar .spacer { flex: 1; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; position: relative; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
/* 操作列吸附在表格右侧：表格横向溢出时，编辑/预览/删除按钮始终可见可点 */
table.data th:last-child,
table.data td:last-child {
  position: sticky; right: 0; z-index: 3;
  background: #fff;
  box-shadow: -7px 0 12px -8px rgba(15, 23, 42, .35);
  background-clip: padding-box;
}
table.data thead th:last-child { z-index: 4; }
table.data tbody tr:hover td:last-child { background: #fafbfd; }
table.data th { background: #f8fafc; color: #64748b; font-weight: 700; text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--a-border); white-space: nowrap; }
table.data td { padding: 9px 10px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
table.data tr:hover td { background: #fafbfd; }
table.data tr:last-child td { border-bottom: none; }
table.data .nowrap { white-space: nowrap; }
table.data .cell-title { font-weight: 600; color: #253044; }
table.data .cell-sub { font-size: .78rem; color: var(--a-muted); max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data .actions { display: flex; flex-wrap: wrap; gap: 5px; white-space: normal; min-width: 130px; }
table.data .actions .btn { position: relative; z-index: 1; }
table.data .cell-preview-link { color: var(--a-primary); cursor: pointer; }
table.data .cell-preview-link:hover { color: var(--a-accent); }
table.data .thumb { cursor: pointer; }

/* 自定义确认弹窗与轻提示：不依赖浏览器原生 confirm/alert，避免被拦截后按钮"点不动" */
.confirm-overlay {
  position: fixed; inset: 0; z-index: 9999; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(15, 23, 42, .48);
}
.confirm-overlay.show { display: flex; }
.confirm-box {
  width: min(420px, 100%); background: #fff; border-radius: 14px; text-align: center;
  padding: 26px 26px 20px; box-shadow: 0 24px 64px rgba(0, 0, 0, .28);
  animation: confirmPop .16s ease-out;
}
@keyframes confirmPop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.confirm-icon { font-size: 2rem; line-height: 1; margin-bottom: 10px; }
.confirm-title { font-size: 1.05rem; font-weight: 700; color: #212529; }
.confirm-msg { color: #5c6779; font-size: .92rem; margin: 10px 0 20px; line-height: 1.6; word-break: break-word; }
.confirm-btns { display: flex; gap: 10px; justify-content: center; }
.confirm-btns .btn { min-width: 96px; padding: 9px 18px; }
.admin-toast {
  position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 16px);
  z-index: 10000; padding: 11px 20px; border-radius: 10px; font-size: .9rem;
  background: #2d3748; color: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.22);
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
.admin-toast.show { opacity: 1; transform: translate(-50%, 0); }
.admin-toast.is-error { background: #c82333; }
.thumb { width: 34px; height: 34px; border-radius: 8px; object-fit: contain; background: #f1f3f6; padding: 3px; vertical-align: middle; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: .75rem; font-weight: 700; }
.badge-on { background: #d9f2e3; color: #1e7e34; }
.badge-off { background: #f1f3f5; color: #868e96; }
.badge-hot { background: #fff0d6; color: #b87503; }
.badge-info { background: #d9eef5; color: #117a8b; }
.badge-purple { background: #ece2fa; color: #5a32a3; }
.badge-gray { background: #e9ecef; color: #495057; }

/* ---------- 提示 / 分页 ---------- */
.alert { padding: 12px 16px; border-radius: 9px; margin-bottom: 18px; font-size: .92rem; }
.alert-success { background: #eaf8ee; border: 1px solid #b7e4c7; color: #1e7e34; }
.alert-error { background: #fff0f0; border: 1px solid #f5c6cb; color: #b02a37; }
.alert-info { background: #e9f6fa; border: 1px solid #b8e2ed; color: #117a8b; }
.empty-state { text-align: center; padding: 46px 20px; color: var(--a-muted); }
.empty-state .ico { font-size: 2.8rem; display: block; margin-bottom: 10px; opacity: .6; }
.pagination { display: flex; gap: 6px; flex-wrap: wrap; padding: 16px 20px; border-top: 1px solid var(--a-border); }
.pagination a { padding: 6px 12px; border: 1px solid var(--a-border); border-radius: 7px; background: #fff; font-size: .86rem; }
.pagination a:hover { background: var(--a-bg); }
.pagination a.active { background: var(--a-primary); color: #fff; border-color: var(--a-primary); }
.page-summary { font-size: .85rem; color: var(--a-muted); padding: 12px 20px; border-top: 1px solid var(--a-border); }

/* ---------- 登录页 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(135deg, #4a5568, #2d3748 60%, #1a1a2e); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden; }
.login-hd { padding: 28px 30px 22px; text-align: center; border-bottom: 1px solid var(--a-border); }
.login-hd .logo { font-size: 2.4rem; }
.login-hd h1 { font-size: 1.35rem; margin-top: 6px; }
.login-hd p { color: var(--a-muted); font-size: .85rem; }
.login-bd { padding: 26px 30px 30px; }
.login-bd .field { margin-bottom: 16px; }
.login-bd .btn { width: 100%; padding: 11px; font-size: 1rem; }
.login-ft { text-align: center; margin-top: 16px; font-size: .82rem; color: var(--a-muted); }

/* ---------- 其它 ---------- */
.mini-list { list-style: none; }
.mini-list li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--a-border); font-size: .9rem; }
.mini-list li:last-child { border-bottom: none; }
.mini-list .rank { display: inline-block; width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 6px; background: var(--a-bg); color: var(--a-muted); font-size: .75rem; margin-right: 8px; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 12px; }
.quick-grid a { display: flex; align-items: center; gap: 10px; padding: 14px; border: 1px solid var(--a-border); border-radius: 10px; background: #fff; font-weight: 600; }
.quick-grid a:hover { border-color: var(--a-accent); box-shadow: var(--a-shadow); }
.quick-grid .ico { font-size: 1.5rem; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.inline-form input, .inline-form select { padding: 8px 10px; border: 1px solid var(--a-border); border-radius: 8px; font-size: .88rem; }
hr.sep { border: 0; border-top: 1px solid var(--a-border); margin: 22px 0; }
/* 平台列表里显示的图片型图标 */
.os-icon-img { width: 1.15em; height: 1.15em; object-fit: contain; display: inline-block; vertical-align: -.22em; }

@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .sidebar-brand strong, .sidebar-brand span, .sidebar-nav a span.txt, .nav-title, .sidebar-foot { display: none; }
  .sidebar-brand { padding: 18px 10px; text-align: center; }
  .sidebar-nav a { justify-content: center; padding: 10px; }
  .form-grid { grid-template-columns: 1fr; }
  .admin-content { padding: 16px; }
  .topbar { padding: 12px 16px; }
}
@media (max-width: 560px) {
  .topbar h1 { font-size: 1.05rem; }
  .topbar-right .who { display: none; }
}
