/* ========== 管理员后台样式 ========== */
:root {
  --bg: #111827;
  --surface: #1f2937;
  --surface2: #374151;
  --border: #4b5563;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 8px;
  --font: 'Segoe UI', system-ui, sans-serif;
  --row-hover: rgba(255, 255, 255, 0.02);
  --overlay: rgba(0, 0, 0, 0.55);
  --drawer-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
  --nav-active-bg: rgba(99, 102, 241, 0.12);
}

/* 浅色主题 */
html[data-theme="light"] {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --row-hover: rgba(15, 23, 42, 0.04);
  --overlay: rgba(15, 23, 42, 0.35);
  --drawer-shadow: 4px 0 20px rgba(15, 23, 42, 0.08);
  --nav-active-bg: rgba(79, 70, 229, 0.1);
}

html[data-theme="light"] .tag-banned { color: #b91c1c; }
html[data-theme="light"] .tag-unused { color: #4338ca; }
html[data-theme="light"] .tag-claimed { color: #b45309; }
html[data-theme="light"] .sidebar-drawer.open {
  box-shadow: var(--drawer-shadow);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }

.layout {
  min-height: 100vh;
}

/* ========== 侧边抽屉 ========== */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.drawer-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.sidebar-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  max-width: 85vw;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 300;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--drawer-shadow);
}

.sidebar-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 16px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-drawer .logo {
  font-weight: 700;
  font-size: 1.05rem;
}

.drawer-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.drawer-close:hover {
  background: var(--border);
}

.drawer-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.drawer-nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 20px;
  color: var(--muted);
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
}

.nav-item-label {
  min-width: 0;
}

.nav-badge {
  flex-shrink: 0;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--panel, #1e293b);
}

.drawer-nav a:hover,
.drawer-nav a.active {
  color: var(--text);
  background: var(--nav-active-bg);
  border-left-color: var(--primary);
}

.drawer-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.drawer-user {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.page-title {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.welcome-text {
  color: var(--muted);
  font-size: 13px;
}

.btn-theme {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-theme:hover {
  background: var(--border);
  border-color: var(--muted);
}

.btn-theme .theme-icon {
  font-size: 14px;
  line-height: 1;
  opacity: 0.85;
}

.btn-icon {
  padding: 0;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.btn-icon:hover {
  background: var(--border);
}

.hamburger,
.hamburger::before,
.hamburger::after {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  position: relative;
}

.hamburger::before,
.hamburger::after {
  content: '';
  position: absolute;
  left: 0;
}

.hamburger::before { top: -6px; }
.hamburger::after { top: 6px; }

.content {
  flex: 1;
  padding: 20px 24px;
  overflow: auto;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.panel h2 {
  font-size: 1.1rem;
  margin-bottom: 16px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}

.toolbar input,
.toolbar select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  min-width: 140px;
}

.toolbar input[type="date"] {
  min-width: 150px;
}

.toolbar-label {
  font-size: 13px;
  color: var(--muted);
}

.toolbar-sep {
  font-size: 13px;
  color: var(--muted);
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.pager-info {
  font-size: 13px;
  color: var(--muted);
}

.panel-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.panel-head-row h2 {
  margin-bottom: 0;
}

.panel-hint {
  color: var(--muted);
  font-size: 12px;
  margin: -4px 0 14px;
}

.batch-table-wrap {
  max-height: 280px;
  overflow: auto;
}

.batch-table-wrap tr.row-active {
  background: rgba(99, 102, 241, 0.12);
}

.batch-code {
  font-size: 12px;
  color: var(--primary);
}

.batch-actions {
  white-space: nowrap;
}

.batch-actions .btn + .btn {
  margin-left: 6px;
}

.user-actions {
  white-space: nowrap;
}

.user-actions .btn + .btn {
  margin-left: 4px;
}

.batch-filter-banner {
  margin-bottom: 14px;
}

html[data-theme="light"] .batch-table-wrap tr.row-active {
  background: rgba(79, 70, 229, 0.08);
}

.btn {
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--surface2);
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  position: sticky;
  top: 0;
}

tr:hover td { background: var(--row-hover); }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.tag-pending { background: rgba(217, 119, 6, 0.2); color: var(--warning); }
.tag-approved { background: rgba(22, 163, 74, 0.2); color: var(--success); }
.tag-rejected { background: rgba(220, 38, 38, 0.2); color: var(--danger); }
.tag-banned { background: rgba(220, 38, 38, 0.3); color: #fca5a5; }
.tag-normal { background: rgba(22, 163, 74, 0.15); color: var(--success); }
.tag-online { background: rgba(22, 163, 74, 0.22); color: var(--success); }
.tag-offline { background: rgba(107, 114, 128, 0.22); color: var(--muted); }
.tag-unused { background: rgba(99, 102, 241, 0.2); color: #a5b4fc; }
.tag-claimed { background: rgba(217, 119, 6, 0.22); color: var(--warning); }
.tag-bound { background: rgba(22, 163, 74, 0.2); color: var(--success); }
.tag-invalidated { background: rgba(107, 114, 128, 0.3); color: var(--muted); }

.alert {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: 13px;
}

.alert-error { background: rgba(220, 38, 38, 0.15); border: 1px solid var(--danger); }
.alert-success { background: rgba(22, 163, 74, 0.15); border: 1px solid var(--success); }
.alert-info { background: rgba(99, 102, 241, 0.12); border: 1px solid rgba(99, 102, 241, 0.45); color: var(--text); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 440px;
}

.modal h3 { margin-bottom: 16px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

.modal-wide {
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
}

.report-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.report-images a,
.report-images button {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: transparent;
  cursor: zoom-in;
}

.report-images a:hover,
.report-images button:hover {
  border-color: #6366f1;
}

.report-images img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.image-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.78);
  cursor: zoom-out;
}

.image-preview-img {
  max-width: min(96vw, 1200px);
  max-height: 92vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  cursor: default;
}

.ip-cell {
  white-space: nowrap;
}

.btn-ip-history {
  margin-left: 6px;
  padding: 2px 6px;
  font-size: 11px;
  line-height: 1.4;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--accent, #6366f1);
  cursor: pointer;
  vertical-align: middle;
}

.btn-ip-history:hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.45);
}

td.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
}

.login-card h1 { margin-bottom: 8px; }
.login-card .subtitle { color: var(--muted); margin-bottom: 24px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 14px;
}

.stat-card .num { font-size: 1.5rem; font-weight: 700; }
.stat-card .label { color: var(--muted); font-size: 12px; }

.empty { text-align: center; color: var(--muted); padding: 40px; }

/* 宽屏：抽屉展开时主内容右移，无遮罩 */
@media (min-width: 1024px) {
  .drawer-overlay.visible {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  .sidebar-drawer.open {
    box-shadow: none;
  }

  .layout.drawer-open .main {
    margin-left: 260px;
    transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .main {
    transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

@media (max-width: 1023px) {
  .welcome-text { display: none; }
  .page-title { font-size: 0.95rem; }
  .btn-theme .theme-label { display: none; }
}

@media (max-width: 480px) {
  .topbar { padding: 10px 12px; }
  .content { padding: 14px 12px; }
}
