﻿:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --line: #e5e7eb;
  --text: #14171f;
  --muted: #667085;
  --brand: #e60023;
  --brand-soft: #ffe8ee;
}
* { box-sizing: border-box; }
.hidden { display: none !important; }
body { margin: 0; font-family: "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--text); }
.admin-body { background: var(--bg); display: grid; grid-template-columns: 200px 1fr; min-height: 100vh; }
.admin-sidebar { background: #111827; color: #fff; padding: 12px 10px; display: flex; flex-direction: column; gap: 8px; position: sticky; top: 0; height: 100vh; overflow: auto; z-index: 30; }
.brand { font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.admin-sidebar .brand { position: sticky; top: 0; background: #111827; padding: 8px 2px; margin-bottom: 4px; z-index: 1; }
.nav-btn { border: 0; text-align: left; border-radius: 10px; padding: 10px 12px; background: transparent; color: #d1d5db; cursor: pointer; font-size: 14px; }
.nav-btn:hover { background: #1f2937; color: #fff; }
.nav-btn.active { background: var(--brand); color: #fff; }
.nav-btn-disabled { opacity: .65; }
.back-link { margin-top: auto; text-decoration: none; color: #fca5a5; font-size: 13px; border: 1px solid rgba(255,255,255,.25); border-radius: 10px; padding: 8px 10px; text-align: center; }
.admin-main { padding: 18px; overflow: auto; }
.admin-header { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; }
.head-left { display: flex; align-items: center; gap: 10px; }
.admin-header h1 { margin: 0; font-size: 24px; }
.menu-toggle { display: none; }
.header-right { display: flex; align-items: center; gap: 12px; }
.tag { color: var(--brand); background: var(--brand-soft); border-radius: 999px; padding: 6px 12px; font-size: 12px; }
.view { display: none; margin-top: 14px; }
.view.active { display: block; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.small-cards { grid-template-columns: repeat(3, minmax(0,1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.card p { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.card h3 { margin: 0; font-size: 24px; color: var(--brand); }
.panel { margin-top: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.panel-title { font-size: 18px; font-weight: 700; }
.filters { display: grid; gap: 8px; margin-bottom: 10px; }
.filters.three { grid-template-columns: 2fr 1fr 1fr; }
.filters.four { grid-template-columns: 1fr 1fr 1fr auto; }
.filters.two { grid-template-columns: 1fr 1fr; }
input, select, button, textarea { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; background: #fff; }
textarea { min-height: 80px; resize: vertical; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1020px; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; font-size: 14px; vertical-align: middle; }
th { color: #111827; background: #fafafa; position: sticky; top: 0; }
.badge { border-radius: 999px; padding: 2px 8px; font-size: 12px; }
.badge.active, .badge.approved { background: #dcfce7; color: #166534; }
.badge.frozen, .badge.rejected { background: #fee2e2; color: #991b1b; }
.badge.pending { background: #fef9c3; color: #854d0e; }
.btn { background: var(--brand); color: #fff; border-color: var(--brand); cursor: pointer; }
.btn.ghost, .ghost-btn { background: #fff; color: #111827; border: 1px solid var(--line); cursor: pointer; }
.inline-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.table-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  object-fit: cover;
  display: block;
}
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.kv-grid label { display: grid; gap: 6px; color: #374151; font-size: 13px; }
.plain-list { margin: 0; padding-left: 18px; color: #374151; line-height: 1.7; }
.muted-note { color: #64748b; margin: 8px 0 0; }
.modal { position: fixed; inset: 0; background: rgba(17,24,39,.45); display: grid; place-items: center; z-index: 30; }
.modal.hidden { display: none; }
.modal-card { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; background: #fff; border-radius: 14px; border: 1px solid var(--line); padding: 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); display: grid; gap: 10px; }
.modal-wide { width: min(860px, calc(100vw - 16px)); }
.modal-card h3 { margin: 0; }
.modal-card label { display: grid; gap: 6px; font-size: 13px; color: #334155; }
.user-form-grid {
  display: grid;
  gap: 10px;
}
.user-avatar-preview-wrap {
  display: flex;
  align-items: center;
}
.user-avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1px solid var(--line);
  object-fit: cover;
  background: #f3f4f6;
}
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.tab-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tab-row .ghost-btn { border-radius: 999px; padding: 8px 14px; }
.tab-row .ghost-btn.active { background: var(--brand-soft); color: var(--brand); border-color: #ffd0d8; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.detail-item { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 8px; }
.field-label { font-size: 13px; color: #374151; margin-bottom: 6px; }
.thumb-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.thumb-grid img { width: 100%; height: 130px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; background: #f3f4f6; }
.review-stock-table-wrap { border: 1px solid var(--line); border-radius: 10px; overflow: auto; }
.review-stock-table { min-width: 520px; width: 100%; border-collapse: collapse; }
.review-stock-table th, .review-stock-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); }
.review-stock-table th { position: static; background: #fafafa; white-space: nowrap; }
.stock-name { font-weight: 700; color: #0f172a; }
.stock-code { margin-top: 2px; color: var(--muted); font-size: 12px; }
.muted-cell { text-align: center; color: var(--muted); }
.review-modal-actions {
  position: sticky;
  bottom: 0;
  background: #fff;
  padding-top: 8px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.image-viewer { position: relative; width: min(900px, 95vw); height: min(95vh, 760px); background: #0f172a; border-radius: 12px; display: grid; place-items: center; }
.image-viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.img-close { position: absolute; top: 10px; right: 10px; background: #fff; }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.36); z-index: 25; }
.sidebar-backdrop.hidden { display: none; }

@media (max-width: 980px) {
  .admin-body { grid-template-columns: 1fr; }
  .admin-sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; width: 220px; transform: translateX(-100%); transition: transform .2s ease;
    z-index: 40; overflow: auto;
  }
  .admin-sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-block; }
  .admin-main { padding: 10px; }
  .admin-header { padding: 10px; position: sticky; top: 0; z-index: 20; }
  .admin-header h1 { font-size: 20px; }
  .header-right { gap: 8px; }
  .tag { display: none; }
  .cards { grid-template-columns: 1fr 1fr; }
  .small-cards { grid-template-columns: 1fr 1fr; }
  .filters.three, .filters.four, .filters.two, .kv-grid, .detail-grid { grid-template-columns: 1fr; }
  .modal-card { width: calc(100vw - 12px); max-height: calc(100dvh - 12px); padding: 10px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .modal-wide { width: calc(100vw - 8px); }
  .thumb-grid { grid-template-columns: 1fr 1fr; }
  .thumb-grid img { height: 120px; }
  .review-stock-table { min-width: 480px; }
  .review-modal-actions { margin: 0 -2px -2px; padding: 10px 2px calc(10px + env(safe-area-inset-bottom)); }
  .image-viewer { width: 100vw; height: 100vh; border-radius: 0; }
}
