:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-light: #EFF6FF;
  --primary-soft: #DBEAFE;
  --background: #F8FAFC;
  --surface: #FFFFFF;
  --surface-secondary: #F1F5F9;
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --border: #E2E8F0;
  --success: #16A34A;
  --warning: #F59E0B;
  --danger: #DC2626;
  --star: #F59E0B;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-2: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--background);
  color: var(--text-primary);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

a { color: inherit; }

button {
  font-family: inherit;
  cursor: pointer;
}

img { max-width: 100%; display: block; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

:focus-visible {
  outline: 3px solid var(--primary-dark);
  outline-offset: 2px;
}

/* ---------- Layout shells ---------- */

.app-shell { min-height: 100vh; }

.customer-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 48px;
}

.customer-container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------- Admin layout ---------- */

.admin-shell {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 20px;
}

.brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 15px;
}

.brand-text strong { display: block; font-size: 15px; }
.brand-text span { display: block; font-size: 11px; color: var(--text-muted); }

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-link:hover { background: var(--surface-secondary); color: var(--text-primary); }
.nav-link.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }

.admin-main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 60px;
  max-width: 1080px;
}

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

@media (max-width: 860px) {
  .admin-sidebar { display: none; }
  .admin-shell { flex-direction: column; }
  .admin-topbar { display: flex; }
  .admin-main { padding: 20px 16px 48px; }
  .admin-topbar.open + .admin-sidebar-mobile { display: flex; }
}

.admin-sidebar-mobile {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px 16px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-header h1 { margin: 0 0 4px; font-size: 24px; font-weight: 700; }
.page-header p { margin: 0; color: var(--text-secondary); font-size: 14px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  background: var(--surface-secondary);
  color: var(--text-primary);
  transition: background 0.15s ease, border-color 0.15s ease;
}

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

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-outline { background: transparent; border-color: var(--border); }
.btn-outline:hover { background: var(--surface-secondary); }

.btn-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: #FEF2F2; border-color: #FCA5A5; }

.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}

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

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
}

.stat-card .stat-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.stat-card .stat-value { font-size: 30px; font-weight: 800; }
.stat-card.accent .stat-value { color: var(--primary-dark); }
.stat-card.warn .stat-value { color: var(--text-muted); }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.field .hint { font-size: 12px; color: var(--text-muted); }

.input, textarea.input, select.input {
  width: 100%;
  padding: 10px 12px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 14px;
  color: var(--text-primary);
  font-family: inherit;
}

.input:focus, textarea.input:focus, select.input:focus {
  border-color: var(--primary);
}

textarea.input { min-height: 90px; resize: vertical; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 180px; }

/* ---------- Tables / lists ---------- */

.table-wrap { overflow-x: auto; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data-table th {
  text-align: left;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
table.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data-table tr:last-child td { border-bottom: none; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-active { background: #ECFDF5; color: #15803D; }
.badge-disabled { background: #F1F5F9; color: var(--text-muted); }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
}
.empty-state h3 { margin: 10px 0 6px; color: var(--text-primary); }

/* ---------- Toolbar ---------- */

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  align-items: center;
}
.toolbar .input { min-width: 200px; flex: 1; }
.toolbar select.input { flex: none; width: auto; }

/* ---------- QR list cards (mobile) ---------- */

.qr-cards { display: grid; gap: 12px; }
.qr-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.qr-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.qr-card-title { font-weight: 700; }
.qr-card-meta { font-size: 12px; color: var(--text-muted); }
.qr-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

/* ---------- Keywords ---------- */

.keyword-list { display: flex; flex-direction: column; gap: 8px; }
.keyword-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--surface);
}
.keyword-row input.input { flex: 1; min-height: 38px; }
.keyword-row .drag-handle { color: var(--text-muted); cursor: grab; }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 460px;
  width: 100%;
  padding: 24px;
  box-shadow: var(--shadow-2);
}
.modal h2 { margin-top: 0; }

/* ---------- Toasts ---------- */

.toast-region {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  width: min(92vw, 420px);
}
.toast {
  background: var(--text-primary);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: var(--shadow-2);
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ================= CUSTOMER FLOW ================= */

.business-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow-1);
}

.business-logo {
  width: 64px; height: 64px;
  border-radius: 16px;
  object-fit: cover;
  margin: 0 auto 14px;
  background: var(--primary-light);
}

.business-logo-fallback {
  width: 64px; height: 64px;
  border-radius: 16px;
  margin: 0 auto 14px;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 22px;
}

.business-card h1 { font-size: 20px; margin: 0 0 6px; }
.business-card .tagline { color: var(--text-secondary); font-size: 14px; margin: 0; }

.rev-tag {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin: 0;
}

.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  box-shadow: var(--shadow-1);
}

.step-card h2 { margin: 0 0 4px; font-size: 18px; }
.step-card .step-sub { margin: 0 0 18px; color: var(--text-secondary); font-size: 14px; }

.star-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
}

.star-btn {
  background: none;
  border: none;
  padding: 4px;
  min-width: 48px;
  min-height: 48px;
  display: flex; align-items: center; justify-content: center;
}

.star-btn svg { width: 34px; height: 34px; transition: transform 0.12s ease; }
.star-btn:hover svg { transform: scale(1.08); }

.star-label {
  text-align: center;
  font-weight: 600;
  color: var(--star);
  min-height: 20px;
  margin-bottom: 4px;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  min-height: 40px;
}

.chip.selected {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

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

.review-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.review-card p { margin: 0 0 12px; font-size: 14px; line-height: 1.5; color: var(--text-primary); }

.review-card-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.review-card-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary-dark);
  font-weight: 600;
  font-size: 13px;
}

.progress-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 4px;
}
.progress-dots span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border);
}
.progress-dots span.done { background: var(--primary); }

.google-note {
  background: var(--primary-light);
  border: 1px solid var(--primary-soft);
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 14px;
  color: var(--text-primary);
  text-align: center;
}

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

.status-page .card { max-width: 380px; }
.status-page .status-icon { font-size: 40px; margin-bottom: 10px; }

.link-btn {
  background: none;
  border: none;
  color: var(--primary-dark);
  font-weight: 600;
  font-size: 14px;
  padding: 8px;
}

/* QR preview page */
.qr-preview-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 16px;
}
.qr-preview-box img, .qr-preview-box canvas { border: 1px solid var(--border); border-radius: var(--radius-sm); }
