:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
}

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

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

.container { max-width: 640px; margin: 0 auto; padding: 24px 16px; }
.container-wide { max-width: 1200px; margin: 0 auto; padding: 24px 16px; }

.card {
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 16px;
}

h1 { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
h2 { font-size: 18px; font-weight: 600; margin-bottom: 12px; }
h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }

.subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }

label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }

select, input[type="text"], input[type="password"], textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
select:focus, input:focus, textarea:focus {
  border-color: var(--primary);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #dcfce7; color: #16a34a; }
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-yellow { background: #fef3c7; color: #d97706; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* Progress */
.progress-area {
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.qr-area { margin: 20px 0; }
.qr-area canvas { border-radius: 8px; }
.qr-link { font-size: 12px; color: var(--primary); word-break: break-all; margin-top: 8px; }

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-msg {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 8px;
}

.result-icon { font-size: 48px; margin-bottom: 12px; }

/* Log */
.log-area {
  background: #0f172a;
  color: #94a3b8;
  border-radius: 8px;
  padding: 12px;
  font-family: "Cascadia Code", "Fira Code", monospace;
  font-size: 12px;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 12px;
}
.log-area .log-line { padding: 2px 0; }
.log-area .log-line.error { color: #f87171; }
.log-area .log-line.success { color: #4ade80; }

/* Query section */
.query-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* Table */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; }
tr:hover { background: #f8fafc; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 2px solid var(--border); }
.tab {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: none;
  border-top: none; border-left: none; border-right: none;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Admin nav */
.admin-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.admin-nav h1 { font-size: 16px; margin: 0; }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}
.stat-card .value { font-size: 28px; font-weight: 700; }
.stat-card .label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 16px; }

/* Responsive */
@media (max-width: 640px) {
  .container { padding: 16px 12px; }
  .card { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Hidden */
.hidden { display: none !important; }
