/* Blyync design system — "Everyday Mint": calm everyday utility, rounded
   mint surfaces, evergreen headings, white operational surfaces. Hand
   -written, zero external dependencies (system font stack), so the app is
   still simple to self-host. Logical properties are used where practical so
   RTL (dir="rtl") layouts work without a separate stylesheet. */

:root {
  /* Evergreen → mint scale (brand anchor to primary action) */
  --teal-900: #173c31; /* Evergreen — headings and brand anchor */
  --teal-800: #1e4a3b;
  --teal-700: #0f6650;
  --teal-600: #08775f; /* Action mint — primary actions and selected navigation */
  --teal-500: #14957a;
  --teal-100: #e4f3e9; /* Pale mint — wallet and selected surfaces */
  --teal-50: #f7faf7;  /* App surface — customer and dashboard canvas */

  /* Secondary emphasis stays in the mint family (single-hue brand) */
  --accent-600: #0a6b56;
  --accent-500: #0c8a6e;
  --accent-400: #2ea187;
  --accent-100: #e4f3e9;

  --bg: #f7faf7;
  --surface: #ffffff;
  --surface-sunken: #eff6f1;
  --border: #dce6de;
  --text: #1b2e27;
  --text-muted: #5c6a63;
  --text-faint: #8a9793;

  --success: #1f7a4d;
  --success-bg: #e4f3e9;
  --danger: #b23b3b;
  --danger-bg: #fbeaea;
  --warning: #8a6a1f;
  --warning-bg: #fbf1de;

  --radius-sm: 10px;
  --radius-md: 12px; /* Control radius */
  --radius-lg: 22px; /* Main radius — wallet and cards */
  --shadow-sm: 0 1px 2px rgba(23, 60, 49, 0.07), 0 1px 1px rgba(23, 60, 49, 0.05);
  --shadow-md: 0 8px 24px rgba(23, 60, 49, 0.10), 0 2px 6px rgba(23, 60, 49, 0.06);
  --shadow-lg: 0 20px 48px rgba(23, 60, 49, 0.16), 0 6px 16px rgba(23, 60, 49, 0.08);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 0.15s;
  --dur-base: 0.25s;
  --dur-slow: 0.5s;

  --font-sans: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;

  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden; /* safety net: nothing should force horizontal page scroll on phones */
}
img { max-width: 100%; }
a { color: var(--teal-600); transition: color var(--dur-fast) var(--ease-standard); }
a:hover { color: var(--teal-700); }
h1, h2, h3, h4 { margin: 0 0 var(--space-2); line-height: 1.2; color: var(--teal-900); font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.6rem, 1.3rem + 1.4vw, 2.4rem); }
h2 { font-size: clamp(1.25rem, 1.1rem + 0.7vw, 1.5rem); }
h3 { font-size: 1.125rem; }
p { margin: 0 0 var(--space-3); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); font-size: 0.85em; }

.container { max-width: 1120px; margin-inline: auto; padding-inline: var(--space-5); }
.container-narrow { max-width: 640px; margin-inline: auto; padding-inline: var(--space-5); }

@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; }
}

/* --- Motion primitives (kept subtle — calm everyday utility, not showy) --- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulseDot {
  0%, 100% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
  70% { box-shadow: 0 0 0 6px transparent; opacity: 0.7; }
}
@keyframes floatBlob {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(3%, -4%) scale(1.05); }
  66% { transform: translate(-3%, 3%) scale(0.97); }
}

/* --- Top bar / brand --------------------------------------------------- */
.topbar {
  background: var(--teal-900);
  color: #fff;
  padding-block: var(--space-3);
  position: sticky;
  top: 0;
  z-index: 60;
  box-shadow: 0 1px 0 rgba(255,255,255,0.06), 0 2px 16px rgba(23, 60, 49, 0.18);
}
.topbar .container { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: var(--space-2); font-weight: 800; font-size: 1.25rem; color: #fff; text-decoration: none; transition: transform var(--dur-fast) var(--ease-standard); }
.brand:hover { transform: translateY(-1px); color: #fff; }
.brand img { height: 36px; display: block; filter: brightness(0) invert(1); }
.topbar nav { display: flex; gap: var(--space-4); align-items: center; flex-wrap: wrap; }
.topbar nav a { color: rgba(255,255,255,0.85); text-decoration: none; font-size: 0.92rem; position: relative; }
.topbar nav a:not(.pill)::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 2px;
  background: var(--teal-100); transform: scaleX(0); transform-origin: center;
  transition: transform var(--dur-base) var(--ease-out);
}
.topbar nav a:not(.pill):hover::after { transform: scaleX(1); }
.topbar nav a:hover { color: #fff; }
.topbar .pill {
  background: rgba(255,255,255,0.14); padding: 8px 16px; border-radius: 999px; font-size: 0.85rem;
  transition: background var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard);
}
.topbar .pill:hover { background: rgba(255,255,255,0.24); transform: translateY(-1px); }

/* --- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 20px; border-radius: var(--radius-md); border: 1px solid transparent;
  font-size: 0.95rem; font-weight: 700; cursor: pointer; text-decoration: none;
  min-height: 48px; position: relative;
  transition: background var(--dur-base) var(--ease-standard), border-color var(--dur-base) var(--ease-standard),
    transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-base) var(--ease-standard);
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-primary { background: var(--teal-600); color: #fff; }
.btn-primary:hover { background: var(--teal-700); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-accent { background: var(--accent-500); color: #fff; }
.btn-accent:hover { background: var(--accent-600); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--surface); color: var(--teal-900); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-sunken); border-color: var(--teal-500); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--teal-600); }
.btn-ghost:hover { background: var(--teal-100); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #97302f; }
.btn-sm { padding: 8px 14px; min-height: 38px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.btn-block { width: 100%; }
.btn:focus-visible { outline: 2px solid var(--teal-500); outline-offset: 2px; }

/* --- Cards / surfaces ---------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-5); box-shadow: var(--shadow-sm);
  animation: fadeInUp var(--dur-slow) var(--ease-out) both;
  transition: box-shadow var(--dur-base) var(--ease-standard), border-color var(--dur-base) var(--ease-standard);
}
.card:hover { box-shadow: var(--shadow-md); }
.card + .card { margin-top: var(--space-4); }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-4);
  animation: fadeInUp var(--dur-slow) var(--ease-out) both;
  transition: box-shadow var(--dur-base) var(--ease-standard), transform var(--dur-base) var(--ease-standard);
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px;
  background: var(--teal-600);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .stat-value { font-size: 1.7rem; font-weight: 800; color: var(--teal-900); }
.stat-card .stat-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid > *:nth-child(1) { animation-delay: 0.02s; }
.grid > *:nth-child(2) { animation-delay: 0.08s; }
.grid > *:nth-child(3) { animation-delay: 0.14s; }
.grid > *:nth-child(4) { animation-delay: 0.2s; }
.grid > *:nth-child(n+5) { animation-delay: 0.24s; }

/* --- Forms ---------------------------------------------------------------- */
label { display: block; font-size: 0.85rem; font-weight: 700; color: var(--teal-900); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 1rem; background: var(--surface); color: var(--text); font-family: inherit;
  min-height: 48px; transition: border-color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard);
}
textarea { min-height: 80px; }
input:hover, select:hover, textarea:hover { border-color: var(--teal-500); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--teal-500); box-shadow: 0 0 0 4px rgba(8, 119, 95, 0.16);
}
.field { margin-bottom: var(--space-4); }
.field-hint { font-size: 0.78rem; color: var(--text-faint); margin-top: 4px; }
.field-error { font-size: 0.78rem; color: var(--danger); margin-top: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; min-height: auto; }

/* --- Tabs ------------------------------------------------------------------ */
.tabs { display: flex; gap: var(--space-2); border-bottom: 1px solid var(--border); overflow-x: auto; margin-bottom: var(--space-5); }
.tab {
  padding: 10px 4px; margin-inline-end: var(--space-5); background: none; border: none; cursor: pointer;
  font-size: 0.92rem; font-weight: 700; color: var(--text-muted); position: relative;
  white-space: nowrap; transition: color var(--dur-fast) var(--ease-standard);
}
.tab::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--teal-600); transform: scaleX(0); transform-origin: center;
  transition: transform var(--dur-base) var(--ease-out);
}
.tab.active { color: var(--teal-900); }
.tab.active::after { transform: scaleX(1); }
.tab:hover { color: var(--teal-700); }
.tab:focus-visible { outline: 2px solid var(--teal-500); }

/* --- Badges / pills --------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; animation: fadeIn var(--dur-base) var(--ease-standard); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-warning::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulseDot 1.8s ease-in-out infinite; }
.badge-neutral { background: var(--surface-sunken); color: var(--text-muted); }
.badge-teal { background: var(--teal-100); color: var(--teal-700); }
.badge-accent { background: var(--accent-100); color: var(--accent-600); }

/* --- Tables ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: start; padding: 13px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 700; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr { animation: fadeIn var(--dur-base) var(--ease-standard) both; transition: background var(--dur-fast) var(--ease-standard); }
tbody tr:nth-child(1) { animation-delay: 0.01s; }
tbody tr:nth-child(2) { animation-delay: 0.03s; }
tbody tr:nth-child(3) { animation-delay: 0.05s; }
tbody tr:nth-child(4) { animation-delay: 0.07s; }
tbody tr:nth-child(5) { animation-delay: 0.09s; }
tbody tr:nth-child(n+6) { animation-delay: 0.1s; }
tbody tr:hover { background: var(--surface-sunken); }

/* --- States ------------------------------------------------------------------- */
.state-box { text-align: center; padding: var(--space-7) var(--space-4); color: var(--text-muted); animation: fadeIn var(--dur-base) var(--ease-standard); }
.spinner {
  width: 22px; height: 22px; border: 3px solid var(--teal-100); border-top-color: var(--teal-600);
  border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block;
}
.toast {
  position: fixed; inset-block-end: 20px; inset-inline-end: 20px; z-index: 100;
  background: var(--teal-900); color: #fff; padding: 12px 18px; border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); font-size: 0.9rem; max-width: 360px;
  animation: fadeInUp var(--dur-base) var(--ease-out);
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* --- Layout: app shell with side nav ------------------------------------------- */
.app-shell { display: flex; min-height: calc(100vh - 60px); }
.sidenav {
  width: 224px; flex-shrink: 0; background: var(--surface); color: var(--text); padding: var(--space-5) var(--space-3);
  display: flex; flex-direction: column; gap: 2px; border-inline-end: 1px solid var(--border);
}
.sidenav a {
  display: block; padding: 12px var(--space-4); color: var(--text-muted); text-decoration: none; font-size: 0.9rem;
  border-radius: var(--radius-sm); transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
  font-weight: 500;
}
.sidenav a:hover { background: var(--surface-sunken); color: var(--teal-900); }
.sidenav a.active { color: var(--teal-700); background: var(--teal-100); font-weight: 700; }
.main { flex: 1; padding: var(--space-5); min-width: 0; }

@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .sidenav { width: 100%; flex-direction: row; display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: var(--space-2); border-inline-end: none; border-bottom: 1px solid var(--border); }
  .sidenav a { padding: 12px 14px; white-space: nowrap; min-height: 44px; display: flex; align-items: center; }
  h1 { font-size: 1.4rem; }
}

/* --- Phone breakpoint: tighten touch targets, prevent overflow, stack rows --- */
@media (max-width: 640px) {
  /* Any inline flex row (search bars, lookup rows, ask-assistant rows, hero CTAs)
     should wrap instead of squeezing children — this also lets .btn's mobile
     width:100% (below) actually take effect instead of being shrunk by its siblings. */
  .flex { flex-wrap: wrap; }

  /* Topbar: keep brand + nav + any business-name label from crowding/overflowing */
  .topbar .container { gap: var(--space-2); }
  .topbar .brand img { height: 30px; }
  .topbar nav a { padding-block: 6px; min-height: 44px; display: inline-flex; align-items: center; }
  #business-name-label { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Tables: scroll cleanly instead of squashing cell text unreadable */
  .table-wrap { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  .table-wrap table { min-width: 520px; }
  .table-wrap th, .table-wrap td { padding: 11px 10px; font-size: 0.85rem; }

  /* Wallet hero: less padding, smaller headline amount so it never wraps oddly */
  .wallet-hero { padding: var(--space-5) var(--space-4); }
  .wallet-hero .amount { font-size: 2.1rem; }

  /* Checkboxes: bigger tap target, better alignment for wrapping label text */
  .checkbox-row { align-items: flex-start; min-height: 44px; padding-block: 4px; }
  .checkbox-row input { width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px; }

  .tab { min-height: 44px; display: inline-flex; align-items: center; }
}

@media (max-width: 480px) {
  .container, .container-narrow { padding-inline: var(--space-4); }
  .btn { width: 100%; }
  .btn-sm { width: auto; }
  .flex-between { flex-direction: column; align-items: stretch; }
  .card { padding: var(--space-4); }
  .brand img { height: 28px; }

  /* Card grids: always single column on phones, even ones sized via inline style */
  .grid { grid-template-columns: 1fr !important; }

  .stat-card .stat-value { font-size: 1.4rem; }
  .wallet-hero .amount { font-size: 1.9rem; }
}

/* --- Wallet-specific (matches the Everyday Mint "balance" pattern) ------------- */
.wallet-hero {
  background: var(--teal-100); color: var(--teal-900);
  border-radius: var(--radius-lg); padding: var(--space-6); position: relative; overflow: hidden;
}
.wallet-hero .amount { font-size: 2.6rem; font-weight: 700; letter-spacing: -0.02em; }
.wallet-hero .label { opacity: 0.75; font-size: 0.85rem; }
.reward-row { display: flex; justify-content: space-between; align-items: center; padding: var(--space-3) 0; border-bottom: 1px solid var(--border); gap: var(--space-3); transition: background var(--dur-fast) var(--ease-standard); }
.reward-row:hover { background: var(--surface-sunken); }
.reward-row:last-child { border-bottom: none; }

/* --- QR display + scan modal ----------------------------------------------------- */
.qr-box {
  display: inline-flex; flex-direction: column; align-items: center; gap: var(--space-2);
  background: #fff; padding: var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--border);
}
.qr-box canvas { display: block; max-width: 100%; height: auto; }
.qr-id-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.72rem; word-break: break-all;
  color: var(--text-faint); text-align: center; max-width: 220px;
}
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200; background: rgba(23, 60, 49, 0.55);
  display: flex; align-items: center; justify-content: center; padding: var(--space-4);
  animation: fadeIn var(--dur-fast) var(--ease-standard);
}
.modal {
  width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: fadeInUp var(--dur-base) var(--ease-out);
}
.punch-card {
  background: var(--teal-100); border-radius: var(--radius-lg); padding: var(--space-4);
}
.punch-dots { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.punch-dot {
  width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 2px solid var(--teal-500);
  display: inline-block; flex-shrink: 0;
}
.punch-dot.filled { background: var(--teal-600); border-color: var(--teal-600); }

/* --- Hero / marketing (index.html) ---------------------------------------------- */
.hero { position: relative; overflow: hidden; padding-block: var(--space-8) var(--space-7); }
.hero-blobs { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.hero-blob {
  position: absolute; border-radius: 50%; filter: blur(60px); opacity: 0.28;
  animation: floatBlob 20s ease-in-out infinite;
}
.hero-blob.b1 { width: 380px; height: 380px; top: -120px; inset-inline-end: -80px; background: var(--teal-500); }
.hero-blob.b2 { width: 320px; height: 320px; bottom: -140px; inset-inline-start: -100px; background: var(--teal-100); opacity: 0.6; animation-delay: -6s; }
.hero-blob.b3 { width: 240px; height: 240px; top: 40%; inset-inline-start: 30%; background: var(--teal-100); opacity: 0.5; animation-delay: -11s; }
.hero-content { position: relative; z-index: 1; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--teal-700); background: var(--teal-100); padding: 6px 14px; border-radius: 999px;
  margin-bottom: var(--space-4); animation: fadeInUp var(--dur-slow) var(--ease-out) both;
}
.hero-content h1 { animation: fadeInUp var(--dur-slow) var(--ease-out) both 0.06s; }
.hero-content p { animation: fadeInUp var(--dur-slow) var(--ease-out) both 0.12s; }
.hero-content .flex { animation: fadeInUp var(--dur-slow) var(--ease-out) both 0.18s; }

/* --- Utility ---------------------------------------------------------------------- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.flex-col { display: flex; flex-direction: column; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.text-center { text-align: center; }
.w-full { width: 100%; }
[hidden] { display: none !important; }

.stepper-track { height: 6px; border-radius: 999px; background: var(--surface-sunken); overflow: hidden; margin-bottom: var(--space-4); }
.stepper-fill { height: 100%; border-radius: 999px; background: var(--teal-600); transition: width var(--dur-slow) var(--ease-out); }
.stepper { display: flex; gap: var(--space-2); margin-bottom: var(--space-6); flex-wrap: wrap; position: relative; }
.step { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-faint); transition: color var(--dur-base) var(--ease-standard); }
.step .dot {
  width: 24px; height: 24px; border-radius: 50%; background: var(--surface-sunken); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700;
  transition: background var(--dur-base) var(--ease-standard), color var(--dur-base) var(--ease-standard), transform var(--dur-base) var(--ease-out);
}
.step.active { color: var(--teal-900); font-weight: 700; }
.step.active .dot { background: var(--teal-600); color: #fff; transform: scale(1.12); }
.step.done .dot { background: var(--success); color: #fff; }

footer.site-footer { padding: var(--space-6) 0; color: var(--text-faint); font-size: 0.82rem; text-align: center; }
