:root {
  --primary: #b8602d;
  --primary-dark: #8c4520;
  --primary-light: #f6e8db;
  --bg: #f5f1eb;
  --bg-card: #ffffff;
  --bg-soft: #faf6f1;
  --text: #2a2218;
  --text-muted: #8a7e6e;
  --text-light: #b8ad9d;
  --border: #e8e0d3;
  --border-light: #f0ebe2;
  --success: #2f8a4a;
  --success-bg: #e3f3e7;
  --warning: #b8860b;
  --warning-bg: #fdf3d8;
  --danger: #b13838;
  --danger-bg: #fbe5e5;
  --info: #2c6cb0;
  --info-bg: #e0eefb;
  --shadow-sm: 0 1px 2px rgba(60, 40, 20, .06);
  --shadow: 0 4px 12px rgba(60, 40, 20, .08);
  --radius: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: 0; background: transparent; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }
code { font-family: "Consolas", "Courier New", monospace; background: #f7f1e8; padding: 1px 6px; border-radius: 4px; font-size: 12px; }

/* ========== 登录 ========== */
.login-gate {
  position: fixed; inset: 0;
  background:
    radial-gradient(1200px 600px at 10% 10%, #f6e1c8 0%, transparent 60%),
    radial-gradient(900px 500px at 90% 90%, #e8d4b9 0%, transparent 60%),
    linear-gradient(135deg, #f7ecdc, #e6d3b3);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.login-card {
  width: 420px; max-width: calc(100% - 32px);
  background: #fff; border-radius: 16px; padding: 32px;
  box-shadow: 0 20px 60px rgba(80, 50, 20, .15);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; font-size: 24px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 14px rgba(184, 96, 45, .35);
}
.brand-mark.sm { width: 36px; height: 36px; font-size: 18px; border-radius: 8px; }
.brand-name { font-size: 16px; font-weight: 700; }
.brand-sub { font-size: 11px; color: var(--text-muted); letter-spacing: .08em; }
.login-form { display: flex; flex-direction: column; gap: 4px; }
.login-label { font-size: 12px; color: var(--text-muted); margin-top: 12px; margin-bottom: 4px; }
.login-input {
  height: 40px; padding: 0 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-soft); transition: all .15s;
}
.login-input:focus { outline: 0; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-light); }
.captcha-row { display: flex; gap: 8px; }
.captcha-row .login-input { flex: 1; }
.captcha-code {
  width: 110px; height: 40px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(120deg, #f6e1c8, #f0d4b0, #f9e8d3);
  color: var(--primary-dark); font-weight: 700; font-style: italic; font-size: 20px;
  letter-spacing: 4px; border-radius: var(--radius); user-select: none; cursor: pointer;
  font-family: "Times New Roman", serif;
}
.login-error { color: var(--danger); font-size: 12px; min-height: 18px; margin-top: 4px; }
.login-btn {
  margin-top: 18px; height: 44px; border-radius: var(--radius);
  background: var(--primary); color: #fff; font-size: 15px; font-weight: 600;
  transition: background .15s;
}
.login-btn:hover { background: var(--primary-dark); }
.login-hint { margin-top: 14px; font-size: 12px; color: var(--text-muted); text-align: center; }
.login-back { display: block; margin-top: 14px; text-align: center; color: var(--text-muted); font-size: 12px; }
.login-back:hover { color: var(--primary); }

/* ========== 主体 ========== */
.admin-app { display: grid; grid-template-columns: 240px 1fr; height: 100vh; min-height: 0; }
.admin-app.collapsed { grid-template-columns: 64px 1fr; }
.admin-app.collapsed .sidebar-brand .brand-name,
.admin-app.collapsed .sidebar-brand .brand-sub,
.admin-app.collapsed .nav-group,
.admin-app.collapsed .nav-item.sub,
.admin-app.collapsed .nav-item .badge,
.admin-app.collapsed .admin-info > div,
.admin-app.collapsed .btn-ghost { display: none; }
.admin-app.collapsed .nav-item { justify-content: center; padding: 10px 0; }
.admin-app.collapsed .nav-item .ico { margin: 0; }

/* 侧边栏 */
.sidebar {
  background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
  transition: width .2s;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px; border-bottom: 1px solid var(--border-light);
}
.nav { flex: 1; overflow-y: auto; padding: 8px 0 16px; }
.nav-group {
  padding: 12px 16px 6px; font-size: 11px; color: var(--text-light);
  letter-spacing: .1em;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; color: var(--text); font-size: 13.5px;
  border-left: 3px solid transparent; transition: all .12s;
}
.nav-item .ico { font-size: 16px; color: var(--text-muted); width: 20px; text-align: center; }
.nav-item.sub { padding-left: 36px; font-size: 13px; color: var(--text-muted); }
.nav-item:hover { background: var(--bg-soft); color: var(--primary); }
.nav-item:hover .ico { color: var(--primary); }
.nav-item.active {
  background: var(--primary-light); color: var(--primary);
  border-left-color: var(--primary); font-weight: 600;
}
.nav-item.active .ico { color: var(--primary); }
.nav-item .badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 11px; padding: 1px 7px; border-radius: 10px; min-width: 22px; text-align: center;
}
.sidebar-foot {
  padding: 12px 16px; border-top: 1px solid var(--border-light);
  display: flex; flex-direction: column; gap: 10px;
}
.admin-info { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.admin-name { font-size: 13px; font-weight: 600; }
.admin-role { font-size: 11px; color: var(--text-muted); }
.btn-ghost {
  height: 32px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-soft); font-size: 12px; color: var(--text-muted);
}
.btn-ghost:hover { color: var(--danger); border-color: var(--danger); }

/* 主区域 */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.hamburger { font-size: 20px; color: var(--text-muted); padding: 6px 10px; border-radius: 6px; }
.hamburger:hover { background: var(--bg-soft); color: var(--primary); }
.crumbs { font-size: 14px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-search {
  width: 260px; height: 34px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 17px;
  background: var(--bg-soft); font-size: 13px;
}
.topbar-search:focus { outline: 0; border-color: var(--primary); background: #fff; }
.topbar-time { font-size: 12px; color: var(--text-muted); }
.topbar-link { font-size: 12px; color: var(--text-muted); padding: 4px 10px; border-radius: 6px; }
.topbar-link:hover { background: var(--bg-soft); color: var(--primary); }

.view { flex: 1; overflow-y: auto; padding: 24px; }

/* ========== 通用组件 ========== */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.page-title { font-size: 20px; font-weight: 700; margin: 0; }
.page-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-title {
  font-size: 14px; font-weight: 700; margin: 0 0 14px; display: flex;
  align-items: center; justify-content: space-between;
}
.card-title .meta { font-size: 12px; font-weight: normal; color: var(--text-muted); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px;
  padding: 0 14px; border-radius: var(--radius); font-size: 13px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  transition: all .12s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn.danger { color: var(--danger); border-color: #e9c5c5; }
.btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.success { color: var(--success); border-color: #b6dbbe; }
.btn.success:hover { background: var(--success); color: #fff; border-color: var(--success); }
.btn.warning { color: var(--warning); border-color: #ead8a3; }
.btn.warning:hover { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { height: 26px; padding: 0 10px; font-size: 12px; }

.input, .select, textarea {
  height: 34px; padding: 0 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: #fff; color: var(--text);
  transition: all .12s; min-width: 120px;
}
.input:focus, .select:focus, textarea:focus {
  outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
textarea { height: auto; padding: 8px 12px; min-height: 80px; resize: vertical; }

.tag {
  display: inline-block; font-size: 12px; padding: 2px 8px;
  border-radius: 4px; background: var(--bg-soft); color: var(--text-muted);
  border: 1px solid var(--border-light);
}
.tag.amber { background: var(--primary-light); color: var(--primary); border-color: #ead4b8; }
.tag.success { background: var(--success-bg); color: var(--success); border-color: #c1e1c9; }
.tag.danger { background: var(--danger-bg); color: var(--danger); border-color: #ecc4c4; }
.tag.info { background: var(--info-bg); color: var(--info); border-color: #bcd6ee; }
.tag.warning { background: var(--warning-bg); color: var(--warning); border-color: #ecd9a3; }

/* 表格 */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: #fff; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 14px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.table th { background: var(--bg-soft); color: var(--text-muted); font-weight: 600; font-size: 12px; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fbf8f3; }
.table .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.table .id-cell { font-family: monospace; font-size: 12px; color: var(--text-muted); }
.table .ellip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table a.link { color: var(--primary); text-decoration: none; cursor: pointer; }
.table a.link:hover { text-decoration: underline; }

/* 用户详情网格 */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 4px; }
.grid-2 .card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; }
.grid-2 .card-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border-light); }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.kv { display: flex; padding: 6px 0; font-size: 13px; align-items: flex-start; gap: 8px; }
.kv .k { flex: 0 0 90px; color: var(--text-muted); }
.kv .v { flex: 1; color: var(--text); word-break: break-all; }

.empty {
  padding: 60px 20px; text-align: center; color: var(--text-muted);
  font-size: 13px; background: #fff; border: 1px dashed var(--border); border-radius: var(--radius-lg);
}
.empty .icon { font-size: 40px; margin-bottom: 10px; opacity: .4; }

/* 筛选条 */
.filterbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 16px;
}
.filterbar .grow { flex: 1; }
.filterbar .seg {
  display: inline-flex; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.filterbar .seg button {
  padding: 0 14px; height: 34px; font-size: 13px; color: var(--text-muted);
  border-right: 1px solid var(--border-light);
}
.filterbar .seg button:last-child { border-right: 0; }
.filterbar .seg button:hover { color: var(--primary); }
.filterbar .seg button.active { background: var(--primary); color: #fff; }

/* 数据看板 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px 20px; position: relative; overflow: hidden;
}
.stat-card .label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.stat-card .num { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-card .delta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.stat-card .delta.up { color: var(--success); }
.stat-card .delta.down { color: var(--danger); }
.stat-card .ico-bg {
  position: absolute; right: -10px; bottom: -16px; font-size: 70px;
  color: var(--primary-light); opacity: .7; font-weight: 700;
}

.dash-row { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 1100px) { .dash-row { grid-template-columns: 1fr; } }

/* 简单柱状图 */
.chart { padding: 12px 0; }
.chart-bars {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
  gap: 10px; align-items: end; height: 200px; border-bottom: 1px solid var(--border-light);
  padding-bottom: 6px; margin-bottom: 6px;
}
.chart-bar {
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  border-radius: 4px 4px 0 0; position: relative; min-height: 4px;
  display: flex; align-items: flex-end; justify-content: center;
  color: #fff; font-size: 10px; padding-bottom: 2px;
}
.chart-bar:hover { opacity: .85; }
.chart-labels { display: grid; grid-template-columns: repeat(auto-fit, minmax(40px, 1fr)); gap: 10px; }
.chart-labels span { font-size: 10px; color: var(--text-muted); text-align: center; }

/* 列表行内分类胶囊 */
.cat-chip { display: inline-flex; align-items: center; gap: 4px; }

/* 模态框 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(40, 30, 20, .45);
  display: flex; align-items: center; justify-content: center; z-index: 800;
  animation: fadeIn .15s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: var(--radius-lg);
  width: 520px; max-width: calc(100% - 32px); max-height: 86vh; overflow: auto;
  box-shadow: 0 20px 50px rgba(40, 30, 20, .25); animation: zoomIn .15s;
}
@keyframes zoomIn { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close { font-size: 18px; color: var(--text-muted); padding: 0 6px; }
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; gap: 8px; }
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row label { font-size: 12px; color: var(--text-muted); }

/* Toast */
.toast-root { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: rgba(40, 30, 20, .92); color: #fff; padding: 10px 18px;
  border-radius: var(--radius); font-size: 13px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
  animation: toastIn .2s;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warn { background: var(--warning); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* 详情 */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .detail-grid { grid-template-columns: 1fr; } }
.kv { display: flex; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--border-light); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--text-muted); width: 84px; flex-shrink: 0; }
.kv .v { flex: 1; word-break: break-all; }

.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* 分页 */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.pager .info { font-size: 12px; color: var(--text-muted); margin-right: auto; }
.pager button {
  height: 30px; min-width: 30px; padding: 0 10px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; font-size: 12px;
}
.pager button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pager button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager button:disabled { color: var(--text-light); cursor: not-allowed; }

/* 公告卡 */
.notice-item { padding: 12px 0; border-bottom: 1px dashed var(--border-light); }
.notice-item:last-child { border-bottom: 0; }
.notice-item .ti { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.notice-item .ct { color: var(--text-muted); font-size: 13px; margin-top: 6px; line-height: 1.7; }
.notice-item .mt { color: var(--text-light); font-size: 11px; margin-top: 6px; }

/* 移动端 */
@media (max-width: 768px) {
  .admin-app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -240px; top: 0; bottom: 0; width: 240px; z-index: 600; transition: left .2s; }
  .admin-app.mobile-open .sidebar { left: 0; }
  .topbar-search { width: 140px; }
  .view { padding: 14px; }
  .table th, .table td { padding: 8px 10px; }
}
