@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #f1f5f9;
  --bg-subtle: #e2e8f0;
  --card: #ffffff;
  --card-hover: #f8fafc;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --primary-hover: #1d4ed8;
  --primary-shadow: rgba(37, 99, 235, 0.25);
  --success: #059669;
  --success-light: #d1fae5;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --info: #0284c7;
  --info-light: #e0f2fe;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ===== Auth ===== */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(37, 99, 235, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(14, 165, 233, 0.06) 0%, transparent 50%),
    linear-gradient(160deg, #f8fafc 0%, #e2e8f0 100%);
}

.auth-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

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

.auth-brand-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--primary) 0%, #0ea5e9 100%);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 8px 20px var(--primary-shadow);
}

.auth-box h3 {
  text-align: center;
  margin-bottom: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 6px;
  margin-bottom: 28px;
}

.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
}

input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:hover, select:hover, textarea:hover {
  border-color: #cbd5e1;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea {
  resize: vertical;
  min-height: 120px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
}

.hint-text {
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-bottom: 12px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-shadow);
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px var(--primary-shadow);
}

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { background: #047857; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #b91c1c; }

.btn-secondary {
  background: var(--card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg);
  border-color: #cbd5e1;
}

.btn-info {
  background: var(--info-light);
  color: var(--info);
  border: 1px solid #bae6fd;
}
.btn-info:hover {
  background: #bae6fd;
}

.btn-sm { padding: 6px 12px; font-size: 0.8125rem; }
.btn-block { width: 100%; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.auth-link {
  text-align: center;
  margin-top: 20px;
  color: var(--text-muted);
  font-size: 0.875rem;
  cursor: pointer;
  transition: color 0.2s;
}
.auth-link:hover { color: var(--primary); }

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), #0ea5e9);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  background: var(--primary-light);
  color: var(--primary);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.8125rem;
  font-weight: 600;
  border: 1px solid #bfdbfe;
}

.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

/* ===== Cards ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: var(--shadow);
}

.card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.page-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  letter-spacing: -0.02em;
}

.row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.row .form-group { flex: 1; min-width: 150px; }

/* ===== Table ===== */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

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

th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: none;
  letter-spacing: 0.01em;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: #f8fafc; }

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #34d399);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ===== Filter tabs ===== */
.filter-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.2s;
}

.filter-tab:hover {
  border-color: #cbd5e1;
  color: var(--text-secondary);
}

.filter-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-shadow);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== Status tags ===== */
.status-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-pending { background: #f1f5f9; color: #64748b; }
.status-processing { background: var(--info-light); color: var(--info); }
.status-success { background: var(--success-light); color: var(--success); }
.status-normal { background: var(--success-light); color: var(--success); }
.status-no_face { background: var(--warning-light); color: var(--warning); }
.status-banned { background: var(--danger-light); color: var(--danger); }
.status-error { background: var(--danger-light); color: var(--danger); }
.status-abnormal { background: var(--danger-light); color: var(--danger); }

.search-box {
  position: relative;
  margin-bottom: 14px;
}

.search-box textarea {
  padding-left: 38px;
  background: #f8fafc;
  min-height: 44px;
  resize: vertical;
  line-height: 1.5;
}

.search-box input {
  padding-left: 38px;
  background: #f8fafc;
}

.search-box::before {
  content: "🔍";
  position: absolute;
  left: 13px;
  top: 14px;
  font-size: 0.85rem;
  opacity: 0.5;
}

.empty-cell {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 16px !important;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal h3 {
  margin-bottom: 18px;
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-wide { max-width: 720px; }

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

.result-url {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  word-break: break-all;
  font-family: 'Consolas', monospace;
  font-size: 0.85rem;
  margin: 12px 0;
  color: var(--text-secondary);
}

.qr-modal {
  text-align: center;
  max-width: 380px;
  padding: 32px 28px;
}

.qr-tip {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 6px;
}

.qr-account {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 18px;
  color: var(--text);
}

.qr-box {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
  background: #fff;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.qr-box canvas,
.qr-box img { display: block; }

.qr-url-input {
  width: 100%;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-bottom: 16px;
  text-align: center;
}

.qr-copy-btn {
  padding: 12px;
  font-size: 0.9375rem;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  color: #fff;
  z-index: 2000;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }

/* ===== Admin ===== */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), #0ea5e9);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.sidebar h2 {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
}

.sidebar nav {
  padding: 12px 10px;
  flex: 1;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 2px;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
}

.sidebar nav a:hover {
  color: var(--text);
  background: #f1f5f9;
}

.sidebar nav a.active {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}

.sidebar nav a.nav-logout {
  margin-top: 12px;
  color: var(--danger);
}

.sidebar nav a.nav-logout:hover {
  background: var(--danger-light);
  color: var(--danger);
}

.admin-main {
  flex: 1;
  padding: 28px 32px;
  overflow-y: auto;
  background: var(--bg);
}

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

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.stat-card .label {
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  margin-top: 4px;
}

.trend-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.875rem;
}

.trend-item:last-child { border-bottom: none; }

.trend-item .count {
  color: var(--primary);
  font-weight: 600;
}

.checkbox-col { width: 40px; }

.pwd-mask { letter-spacing: 2px; font-family: monospace; }

.copyable {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
  border-radius: 4px;
}

.copyable:hover {
  color: var(--primary);
}

code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .header {
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px;
  }
  .main-content { padding: 16px; }
  .admin-main { padding: 16px; }
  .auth-box { padding: 28px 24px; }
}
