:root {
  --red: #9e2b25; --red-deep: #7c1f1a; --gold: #c8a45c; --gold-soft: #e7d3a6;
  --paper: #f6f3ee; --ink: #2c2622; --muted: #8a7f74; --line: #e3dccd; --green: #1f7a4d;
  --side: #2a211c; --side-2: #352a22;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; background: var(--paper); color: var(--ink); font-size: 14.5px; }
a { color: inherit; text-decoration: none; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--red), var(--red-deep)); }
.login-card { background: #fff; border-radius: 16px; padding: 30px 26px; width: 320px; box-shadow: 0 10px 40px rgba(0,0,0,.2); text-align: center; }
.login-card h1 { margin: 0; color: var(--red); font-size: 20px; letter-spacing: 1px; }
.login-sub { color: var(--muted); margin: 4px 0 18px; }
.login-back { display: block; margin-top: 14px; font-size: 13px; color: var(--muted); }
.input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14.5px; margin-bottom: 12px; font-family: inherit; }
.input:focus { outline: none; border-color: var(--gold); }

/* layout */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--side); color: #e9e2d8; display: flex; flex-direction: column; flex-shrink: 0; }
.side-brand { padding: 18px 16px; font-weight: 800; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); letter-spacing: 1px; }
.side-nav { flex: 1; padding: 8px; overflow-y: auto; }
.side-item { padding: 11px 14px; border-radius: 10px; cursor: pointer; margin-bottom: 4px; font-size: 14px; color: #d8cfc2; }
.side-item:hover { background: var(--side-2); }
.side-item.active { background: var(--red); color: #fff; }
.side-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12.5px; color: #b6ab9c; }

.admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 56px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 18px; gap: 12px; position: sticky; top: 0; z-index: 10; }
.topbar #pageTitle { font-weight: 700; font-size: 16px; }
.menu-btn { display: none; background: none; border: none; font-size: 22px; cursor: pointer; }
.view-site { margin-left: auto; color: var(--red); font-size: 13.5px; }
.admin-content { padding: 20px; max-width: 1100px; width: 100%; }

/* cards / sections */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; box-shadow: 0 1px 6px rgba(120,70,30,.05); }
.panel h3 { margin: 0 0 12px; font-size: 15px; color: var(--red-deep); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.stat { background: linear-gradient(135deg, #fff7e9, #fbeede); border: 1px solid var(--gold-soft); border-radius: 12px; padding: 14px; }
.stat .n { font-size: 22px; font-weight: 800; color: var(--red); }
.stat .l { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* table */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: 9px 10px; text-align: left; vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 600; background: #faf7f2; }
.tbl tr:hover td { background: #fcf9f4; }
.tbl .actions { white-space: nowrap; }
.tag { display: inline-block; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 1px 8px; font-size: 12px; color: var(--muted); margin: 0 4px 4px 0; }
.badge-ok { color: var(--green); font-weight: 600; }
.badge-pending { color: var(--gold); font-weight: 600; }
.badge-rejected { color: var(--red); font-weight: 600; }
.thumb { max-width: 54px; max-height: 44px; border-radius: 6px; cursor: pointer; }

/* buttons */
.btn-primary { background: var(--red); color: #fff; border: none; border-radius: 9px; padding: 9px 16px; font-size: 14px; cursor: pointer; }
.btn-primary:hover { background: var(--red-deep); }
.btn-ghost { background: #fff; color: var(--red); border: 1px solid var(--red); border-radius: 9px; padding: 7px 13px; font-size: 13px; cursor: pointer; }
.btn-ghost:hover { background: #fdf0ee; }
.btn-line { background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 9px; padding: 7px 13px; font-size: 13px; cursor: pointer; }
.btn-danger { color: var(--red); border-color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.link { color: var(--red); cursor: pointer; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }

/* forms */
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.form-row input, .form-row textarea, .form-row select { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; font-family: inherit; }
.form-row textarea { min-height: 120px; resize: vertical; }
.form-actions { display: flex; gap: 10px; margin-top: 10px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.perm-item { display: flex; align-items: center; gap: 6px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 13px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 14px; }

/* modal (reuse) */
[hidden] { display: none !important; }
.modal-mask { position: fixed; inset: 0; background: rgba(40,25,15,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: #fff; width: 100%; max-width: 560px; border-radius: 14px; padding: 18px 20px 22px; max-height: 90vh; overflow-y: auto; }
.modal-lg { max-width: 640px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.modal-close { background: none; border: none; font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-msg { color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 6px; }
.toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); background: rgba(40,25,15,.92); color: #fff; padding: 10px 18px; border-radius: 22px; font-size: 13.5px; z-index: 200; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.82); display: flex; align-items: center; justify-content: center; z-index: 300; }
.lightbox img { max-width: 92%; max-height: 88%; border-radius: 8px; }

@media (max-width: 720px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: block; }
}
