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

:root {
  --bg: #0a0e17;
  --bg-card: #111827;
  --bg-input: #0d1220;
  --border: #1e293b;
  --border-light: #334155;
  --text: #e2e8f0;
  --text-dim: #64748b;
  --text-bright: #f8fafc;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --green: #22c55e;
  --green-bg: rgba(34,197,94,0.12);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,0.12);
  --yellow: #eab308;
  --yellow-bg: rgba(234,179,8,0.1);
}

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

/* ========== LOGIN ========== */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #111827 0%, #0a0e17 70%);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 36px;
  width: 380px;
}

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

.login-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.login-brand h1 {
  font-size: 18px;
  letter-spacing: 2px;
  color: var(--text-bright);
  font-weight: 700;
}

.login-brand p {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ========== FORMS ========== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.form-group input, .add-form input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus, .add-form input:focus {
  border-color: var(--accent);
}

/* ========== BUTTONS ========== */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--red); color: #fff; }
.btn-secondary { background: var(--border-light); color: var(--text); }
.btn-warning { background: var(--yellow); color: #000; }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-light); }
.btn-sm { padding: 6px 12px; font-size: 11px; }
.btn-full { width: 100%; }

/* ========== TOP BAR ========== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 28px;
}

.top-bar h1 {
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--text-bright);
  font-weight: 700;
}

.top-bar p {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 1px;
}

/* ========== CONTAINER ========== */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 24px;
}

/* ========== STATS ROW ========== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  text-align: center;
}

.stat-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-bright);
}

/* Status badge */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.status-badge.active {
  background: var(--green-bg);
  color: var(--green);
}

.status-badge.inactive {
  background: var(--red-bg);
  color: var(--red);
}

/* ========== CARDS ========== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 20px;
  overflow: hidden;
}

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

.card-header h2 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.card-body { padding: 18px 20px; }
.card-body.no-pad { padding: 0; }

.client-count {
  font-size: 13px;
  color: var(--text-dim);
}

/* ========== ADD FORM ========== */
.add-form {
  display: flex;
  gap: 10px;
}

.add-form input { flex: 1; }

/* ========== CLIENT LIST ========== */
.client-item {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.client-item:last-child { border-bottom: none; }
.client-item:hover { background: rgba(255,255,255,0.02); }

.client-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  margin-right: 14px;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}

.client-info {
  flex: 1;
  min-width: 0;
}

.client-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-bright);
}

.client-date {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.client-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Avatar colors by index */
.client-avatar.c0 { background: #3b82f6; }
.client-avatar.c1 { background: #8b5cf6; }
.client-avatar.c2 { background: #06b6d4; }
.client-avatar.c3 { background: #f59e0b; }
.client-avatar.c4 { background: #ec4899; }
.client-avatar.c5 { background: #10b981; }

/* ========== ALERTS ========== */
.alert {
  padding: 12px 18px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
}

.alert-warning {
  background: var(--yellow-bg);
  border: 1px solid rgba(234,179,8,0.3);
  color: var(--yellow);
}

.alert-error {
  background: var(--red-bg);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--red);
  display: none;
}

/* ========== MODAL ========== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 360px;
  overflow: hidden;
}

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

.modal-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover { color: var(--text); }

.modal-body {
  padding: 24px 20px;
  text-align: center;
}

.qr-container {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  display: inline-block;
  margin-bottom: 16px;
}

.qr-container svg { display: block; }

.qr-uri {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 10px;
  color: var(--text-dim);
  word-break: break-all;
  padding: 10px;
  background: var(--bg-input);
  border-radius: 6px;
  margin-bottom: 14px;
  max-height: 60px;
  overflow-y: auto;
}

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 32px;
  color: var(--text-dim);
  font-size: 14px;
}

/* ========== TOAST ========== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.25s;
  z-index: 1000;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error { border-color: var(--red); color: var(--red); }

/* ========== SPINNER ========== */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .stats-row { grid-template-columns: repeat(3, 1fr); }
  .top-bar { padding: 12px 16px; }
  .container { padding: 16px; }
  .client-actions { flex-wrap: wrap; }
  .client-actions .btn-sm { padding: 5px 8px; font-size: 10px; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .add-form { flex-direction: column; }
}
