:root {
  --bg: #f4f1ec;
  --panel: #ffffff;
  --ink: #2d2926;
  --ink-soft: #5f564e;
  --muted: #948a80;
  --line: #ece4d9;
  --line-strong: #dfd4c6;
  --brand: #c4553b;
  --brand-dark: #a4412b;
  --brand-soft: #fbeee8;
  --green: #3f8f68;
  --green-soft: #e9f5ee;
  --amber: #b57a22;
  --amber-soft: #fbf2df;
  --red: #c0443b;
  --red-soft: #fbeae8;
  --sidebar: #282220;
  --sidebar-soft: #342c28;
  --shadow: 0 10px 30px rgba(74, 53, 36, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ========== 登录 ========== */
.login-view {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(140deg, #f8efe4 0%, #f4e3d2 45%, #e8c6ad 100%);
  padding: 40px 20px;
}

.login-deco {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.55;
}

.login-deco-1 {
  width: 520px;
  height: 520px;
  right: -160px;
  top: -180px;
  background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.9), rgba(196, 85, 59, 0.22));
}

.login-deco-2 {
  width: 420px;
  height: 420px;
  left: -150px;
  bottom: -180px;
  background: radial-gradient(circle at 60% 40%, rgba(255, 244, 230, 0.9), rgba(164, 65, 43, 0.18));
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 430px;
  background: rgba(255, 252, 247, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 22px;
  box-shadow: 0 30px 70px rgba(104, 58, 34, 0.18);
  padding: 42px 42px 30px;
  backdrop-filter: blur(8px);
}

.login-brand { text-align: center; margin-bottom: 28px; }

.brand-logo {
  width: 74px;
  height: 74px;
  margin: 0 auto 14px;
  border-radius: 22px;
  background: linear-gradient(145deg, #f3d9c6, #e2ad8d);
  box-shadow: 0 10px 22px rgba(180, 110, 70, 0.2);
  font-size: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-logo.small { width: 42px; height: 42px; border-radius: 12px; font-size: 23px; margin: 0; }

.login-brand h1 { margin: 0; font-size: 27px; letter-spacing: 3px; }
.login-brand p { margin: 7px 0 0; color: var(--muted); font-size: 13px; letter-spacing: 2px; }

.field { display: block; margin-bottom: 18px; }
.field > span { display: block; margin-bottom: 7px; color: var(--ink-soft); font-size: 13px; }

.field input,
.field select,
.field textarea,
.toolbar input,
.toolbar select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fffdfa;
  color: var(--ink);
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.toolbar input:focus,
.toolbar select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(196, 85, 59, 0.12);
}

.field textarea { resize: vertical; min-height: 90px; line-height: 1.65; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 16px;
  background: #fff;
  color: var(--ink-soft);
  line-height: 1.3;
  white-space: nowrap;
  transition: all 0.15s;
}

.btn:hover { border-color: var(--line-strong); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: transparent; }

.btn-ghost { background: transparent; border-color: var(--line-strong); }
.btn-ghost:hover { background: #fff; border-color: var(--brand); color: var(--brand); }

.btn-danger { background: var(--red-soft); color: var(--red); border-color: #f2d5d1; }
.btn-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }

.btn-success { background: var(--green-soft); color: var(--green); border-color: #d3eadc; }
.btn-success:hover { background: var(--green); color: #fff; border-color: var(--green); }

.btn-small { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; border-radius: 10px; }

.login-error {
  margin: 14px 0 0;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 13px;
  text-align: center;
}

.login-hint {
  margin: 24px 0 0;
  padding-top: 18px;
  border-top: 1px dashed var(--line-strong);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.9;
  text-align: center;
}

.login-hint code { background: #f3ece3; padding: 1px 5px; border-radius: 4px; color: var(--ink-soft); }
.login-footer { position: relative; z-index: 1; margin-top: 26px; color: rgba(90, 67, 50, 0.55); font-size: 12px; letter-spacing: 1px; }

/* ========== 框架 ========== */
.app { min-height: 100vh; }

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 232px;
  background: var(--sidebar);
  color: #cfc6bd;
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-title { color: #fbf5ed; font-size: 16px; font-weight: 700; letter-spacing: 1px; }
.sidebar-sub { margin-top: 3px; color: #8f8378; font-size: 11px; letter-spacing: 2px; }

.nav { flex: 1; overflow-y: auto; padding: 14px 12px 20px; }
.nav::-webkit-scrollbar { width: 4px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 4px; }

.nav-group {
  margin: 17px 10px 7px;
  color: #776b61;
  font-size: 11px;
  letter-spacing: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 3px;
  padding: 10px 12px;
  border-radius: 9px;
  color: #c3b9af;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: var(--sidebar-soft); color: #fff; }

.nav-item.active {
  background: linear-gradient(135deg, rgba(196, 85, 59, 0.95), rgba(164, 65, 43, 0.95));
  color: #fff;
  box-shadow: 0 6px 16px rgba(196, 85, 59, 0.26);
}

.nav-icon { width: 20px; text-align: center; font-size: 15px; }

.sidebar-footer {
  padding: 16px 16px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.admin-badge {
  margin-bottom: 10px;
  color: #f0e7dc;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer .btn-ghost { width: 100%; color: #b9aea3; border-color: rgba(255, 255, 255, 0.18); }
.sidebar-footer .btn-ghost:hover { background: rgba(255, 255, 255, 0.08); color: #fff; border-color: rgba(255, 255, 255, 0.3); }

.main { margin-left: 232px; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 32px;
  background: rgba(244, 241, 236, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.topbar-title h1 { margin: 0; font-size: 21px; letter-spacing: 0.5px; }
.topbar-title p { margin: 5px 0 0; color: var(--muted); font-size: 12.5px; }
.topbar-actions { display: flex; gap: 8px; }

.content { padding: 26px 32px 50px; }

.loading-block, .empty-block {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.empty-block .empty-emoji { display: block; margin-bottom: 10px; font-size: 36px; }

/* ========== 卡片 / 统计 ========== */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.panel-title { font-size: 15px; font-weight: 700; }
.panel-sub { margin-left: 8px; color: var(--muted); font-size: 12px; font-weight: 400; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-card::after {
  content: "";
  position: absolute;
  right: -22px;
  bottom: -30px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--brand-soft);
  opacity: 0.8;
}

.stat-icon { font-size: 20px; }
.stat-label { margin-top: 10px; color: var(--muted); font-size: 12.5px; }
.stat-value { margin-top: 4px; font-size: 30px; font-weight: 700; letter-spacing: -0.5px; }
.stat-foot { margin-top: 7px; color: var(--muted); font-size: 11.5px; }

.stat-card.accent { background: linear-gradient(150deg, #c4553b, #a4412b); border-color: transparent; color: #fff; }
.stat-card.accent .stat-label, .stat-card.accent .stat-foot { color: rgba(255, 255, 255, 0.72); }
.stat-card.accent::after { background: rgba(255, 255, 255, 0.1); }

.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; margin-top: 20px; }

.quick-list { padding: 6px 20px 12px; }
.quick-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.quick-item:last-child { border-bottom: none; }
.quick-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex-shrink: 0; }
.quick-main { flex: 1; min-width: 0; }
.quick-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.quick-meta { margin-top: 3px; color: var(--muted); font-size: 11.5px; }

.shortcut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 18px 20px 20px; }
.shortcut {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink-soft);
  font-size: 12.5px;
  transition: all 0.15s;
}
.shortcut:hover { border-color: var(--brand); color: var(--brand); background: #fffaf7; }

/* ========== 工具栏 / 表格 ========== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.toolbar input { width: 220px; padding: 8px 11px; }
.toolbar select { width: 140px; padding: 8px 11px; }
.toolbar .spacer { flex: 1; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }

th {
  padding: 11px 16px;
  background: #faf7f2;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

td {
  padding: 13px 16px;
  border-bottom: 1px solid #f3ede5;
  color: var(--ink-soft);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fffcf8; }

.cell-title { color: var(--ink); font-weight: 600; font-size: 13.5px; }
.cell-sub { margin-top: 4px; color: var(--muted); font-size: 11.5px; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-nowrap { white-space: nowrap; }
.cell-actions { display: flex; flex-wrap: wrap; gap: 5px; }

.thumb {
  width: 52px;
  height: 42px;
  border-radius: 7px;
  object-fit: cover;
  background: #f1e9df;
  display: block;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: #f1e9df;
  flex-shrink: 0;
}

.user-cell { display: flex; align-items: center; gap: 9px; }
.user-name { color: var(--ink); font-weight: 600; font-size: 13px; }
.user-id { color: var(--muted); font-size: 11px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  white-space: nowrap;
}

.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-gray { background: #f1ede7; color: #83786d; }
.badge-brand { background: var(--brand-soft); color: var(--brand); }

.badge + .badge { margin-left: 4px; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
}

.pagination .btn { padding: 5px 10px; font-size: 12px; }

/* ========== 设置 / 板块卡片 ========== */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.settings-form { padding: 20px; }
.settings-form .field { margin-bottom: 16px; }
.settings-form .field:last-child { margin-bottom: 0; }
.settings-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 20px; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute;
  inset: 0;
  background: #d9d0c4;
  border-radius: 24px;
  transition: background 0.2s;
}
.switch span::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(20px); }

.category-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.category-card { padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: #fffdfa; }
.category-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.category-icon { font-size: 22px; }
.category-name { margin-top: 8px; font-size: 15px; font-weight: 700; }
.category-desc { margin-top: 5px; min-height: 34px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.category-meta { margin-top: 12px; color: var(--muted); font-size: 11.5px; }
.category-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

/* ========== 弹窗 / Toast ========== */
.modal-root { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-mask { position: absolute; inset: 0; background: rgba(32, 26, 22, 0.55); backdrop-filter: blur(2px); }
.modal {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 760px;
  max-height: 88vh;
  overflow-y: auto;
  background: #fffdfa;
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(30, 20, 14, 0.3);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  background: #fffdfa;
  border-bottom: 1px solid var(--line);
}

.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { border: none; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; padding: 4px 8px; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 22px 22px; }

.post-detail-title { margin: 0 0 8px; font-size: 20px; line-height: 1.45; }
.post-detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.post-detail-content { margin-top: 18px; color: var(--ink-soft); font-size: 14px; line-height: 1.85; white-space: pre-wrap; word-break: break-word; }
.post-images { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.post-images img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: #f1e9df; cursor: zoom-in; }
.detail-section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 42px;
  z-index: 200;
  transform: translateX(-50%);
  max-width: 80vw;
  padding: 11px 20px;
  border-radius: 10px;
  background: rgba(40, 33, 29, 0.94);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: 1fr; }
  .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { width: 74px; }
  .sidebar-brand { justify-content: center; padding: 20px 8px; }
  .sidebar-brand > div:last-child, .nav-group, .nav-item:not(.active)::after { display: none; }
  .nav-item { justify-content: center; padding: 11px 0; font-size: 0; }
  .nav-icon { font-size: 17px; }
  .sidebar-footer { padding: 12px 8px; }
  .admin-badge { display: none; }
  .sidebar-footer .btn { font-size: 0; padding: 8px; }
  .sidebar-footer .btn::before { content: "退出"; font-size: 11px; }
  .main { margin-left: 74px; }
  .topbar, .content { padding-left: 18px; padding-right: 18px; }
  .topbar-actions { display: none; }
  .category-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .login-card { padding: 32px 24px 24px; }
  .stat-grid { grid-template-columns: 1fr; }
  .toolbar input { width: 100%; }
  .toolbar select { width: calc(50% - 5px); }
  .modal-root { padding: 10px; }
}
