/* ==========================================================================
   SnapCard Design System
   Theme is driven by [data-theme="light"|"dark"] on <html>.
   Bootstrap components follow via [data-bs-theme], set by the same script.
   ========================================================================== */

:root {
  /* Brand ramp */
  --brand-700: #0b5c56;
  --brand-600: #0f766e;
  --brand-500: #14b8a6;
  --brand-400: #2dd4bf;
  --brand-300: #5eead4;

  --brand: var(--brand-600);
  --brand-ink: #ffffff;
  --accent-gradient: linear-gradient(135deg, #0f766e 0%, #14b8a6 55%, #2dd4bf 100%);
  --accent-gradient-soft: linear-gradient(135deg, rgba(15, 118, 110, .12) 0%, rgba(45, 212, 191, .12) 100%);

  /* Radii */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 30px;
  --r-pill: 999px;

  /* Motion */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-spring: cubic-bezier(.175, .885, .32, 1.275);

  /* Layout */
  --nav-h: 64px;

  /* Typography scale */
  --text-xs: .6875rem;
  --text-sm: .8125rem;
  --text-base: .875rem;
  --text-md: .9375rem;
  --text-lg: 1.0625rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.375rem;

  /* Spacing */
  --space-page-y: 1rem;
  --space-card: 1rem;
  --space-section: 1.25rem;
}

/* ---------- Light theme (default) ---------- */
:root,
:root[data-theme="light"] {
  --bg: #f4f7f7;
  --bg-tint: radial-gradient(1200px 600px at 15% -10%, rgba(45, 212, 191, .16), transparent 60%),
             radial-gradient(900px 500px at 95% 0%, rgba(15, 118, 110, .10), transparent 55%);
  --surface: #ffffff;
  --surface-2: #f7faf9;
  --surface-glass: rgba(255, 255, 255, .72);
  --border: rgba(9, 30, 28, .09);
  --border-strong: rgba(9, 30, 28, .16);
  --text: #0d1917;
  --text-muted: #5f7370;
  --text-faint: #7d8f8c;
  --shadow-sm: 0 1px 2px rgba(9, 30, 28, .05), 0 1px 3px rgba(9, 30, 28, .04);
  --shadow: 0 4px 12px rgba(9, 30, 28, .06), 0 2px 4px rgba(9, 30, 28, .04);
  --shadow-lg: 0 18px 40px rgba(9, 30, 28, .10), 0 4px 12px rgba(9, 30, 28, .05);
  --brand-soft: rgba(15, 118, 110, .10);
  --brand-text: var(--brand-700);
  --ring: rgba(20, 184, 166, .28);
}

/* ---------- Dark theme ---------- */
:root[data-theme="dark"] {
  --bg: #080d0d;
  --bg-tint: radial-gradient(1200px 600px at 15% -10%, rgba(20, 184, 166, .16), transparent 60%),
             radial-gradient(900px 500px at 95% 0%, rgba(45, 212, 191, .08), transparent 55%);
  --surface: #111a19;
  --surface-2: #16211f;
  --surface-glass: rgba(17, 26, 25, .72);
  --border: rgba(255, 255, 255, .09);
  --border-strong: rgba(255, 255, 255, .18);
  --text: #e6efed;
  --text-muted: #90a5a1;
  --text-faint: #6b807c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 4px 14px rgba(0, 0, 0, .45);
  --shadow-lg: 0 20px 44px rgba(0, 0, 0, .55);
  --brand-soft: rgba(45, 212, 191, .14);
  --brand-text: var(--brand-300);
  --ring: rgba(45, 212, 191, .32);
  --brand: var(--brand-500);
}

/* ==========================================================================
   Base
   ========================================================================== */

* { -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body.pb-app {
  background-color: var(--bg);
  background-image: var(--bg-tint);
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--text);
  min-height: 100vh;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.5;
  overflow-x: clip;
  transition: background-color .4s var(--ease), color .3s var(--ease);
}

/* Clear the fixed bottom nav. Lives on <body> because Bootstrap's .py-* utilities
   on <main> are !important and would win. */
body.pb-app { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px); }

@media (min-width: 992px) {
  body.pb-app { padding-bottom: 0; }
}

h1, h2, h3, h4, h5, h6 {
  letter-spacing: -0.02em;
  font-weight: 600;
}

a { color: var(--brand-text); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand-500); }

::selection { background: var(--brand-soft); color: var(--brand-text); }

/* Focus ring — consistent across every interactive element */
:where(a, button, input, select, textarea, .segmented-item, .nav-item-btn):focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
  border-radius: var(--r-xs);
}

/* ==========================================================================
   Brand utilities (kept as the existing class names so views inherit)
   ========================================================================== */

.bg-brand { background: var(--brand) !important; color: var(--brand-ink) !important; }
.bg-brand-soft { background: var(--brand-soft) !important; }
.bg-brand-gradient { background: var(--accent-gradient) !important; color: #fff !important; }
.text-brand { color: var(--brand-text) !important; }

.btn {
  --bs-btn-focus-box-shadow: 0 0 0 3px var(--ring);
  font-weight: 600;
  font-size: var(--text-sm);
  border-radius: var(--r-pill);
  transition: transform .15s var(--ease), box-shadow .2s var(--ease),
              background .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease);
}
.btn:active { transform: scale(.97); }
.btn-sm { font-size: var(--text-xs); padding: .35rem .75rem; }
.btn-lg { font-size: var(--text-md); padding: .65rem 1.25rem; }

.btn-brand {
  background: var(--accent-gradient);
  background-size: 160% 160%;
  background-position: 0% 50%;
  border: none;
  color: #fff;
  box-shadow: 0 4px 14px rgba(15, 118, 110, .28);
}
.btn-brand:hover,
.btn-brand:focus {
  background-position: 100% 50%;
  color: #fff;
  box-shadow: 0 8px 22px rgba(15, 118, 110, .38);
}

.btn-outline-brand {
  color: var(--brand-text);
  border: 1px solid var(--border-strong);
  background: transparent;
}
.btn-outline-brand:hover {
  background: var(--brand-soft);
  border-color: var(--brand-500);
  color: var(--brand-text);
}

/* Neutral outline buttons follow the theme instead of Bootstrap's fixed grey */
.btn-outline-secondary {
  --bs-btn-color: var(--text-muted);
  --bs-btn-border-color: var(--border-strong);
  --bs-btn-hover-color: var(--text);
  --bs-btn-hover-bg: var(--surface-2);
  --bs-btn-hover-border-color: var(--border-strong);
  --bs-btn-active-color: var(--text);
  --bs-btn-active-bg: var(--surface-2);
  --bs-btn-active-border-color: var(--border-strong);
}

.btn-light {
  --bs-btn-bg: var(--surface);
  --bs-btn-border-color: var(--border);
  --bs-btn-color: var(--text);
  --bs-btn-hover-bg: var(--surface-2);
  --bs-btn-hover-border-color: var(--border-strong);
  --bs-btn-hover-color: var(--text);
}

/* ==========================================================================
   Surfaces
   ========================================================================== */

.card {
  --bs-card-bg: var(--surface);
  --bs-card-border-color: var(--border);
  --bs-card-color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow-sm);
  color: var(--text);
}

.card.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.card.shadow { box-shadow: var(--shadow) !important; }

.card-header {
  background: transparent !important;
  border-bottom-color: var(--border) !important;
  color: var(--text);
}

.rounded-4 { border-radius: var(--r-lg) !important; }
.rounded-3 { border-radius: var(--r-md) !important; }

.text-muted { color: var(--text-muted) !important; }
.text-dark { color: var(--text) !important; }
.bg-white { background: var(--surface) !important; }
.bg-light { background: var(--surface-2) !important; }
.border-bottom { border-bottom-color: var(--border) !important; }
.border-top { border-top-color: var(--border) !important; }

hr { border-color: var(--border); opacity: 1; }

/* Section eyebrow label used above card groups.
   Text-bearing elements use --text-muted; --text-faint is reserved for
   decorative marks (icons, chevrons, placeholders) that need no AA contrast. */
.eyebrow {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Page typography */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .75rem;
  margin-bottom: var(--space-section);
}
.page-header-main { min-width: 0; flex: 1; }
.page-title {
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: 1.25;
  margin: .15rem 0 0;
  color: var(--text);
}
.section-title {
  font-size: var(--text-md);
  font-weight: 600;
  margin-bottom: .25rem;
  color: var(--text);
}
.supporting-text {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0;
  line-height: 1.45;
}
.metric-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--brand-text);
}
.metric-caption {
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.35;
  color: var(--text);
}
.text-mono-sm {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: var(--text-xs);
}
.badge-xs {
  font-size: var(--text-xs) !important;
  font-weight: 500;
  vertical-align: middle;
}
.chevron-muted {
  color: var(--text-faint);
  font-size: var(--text-xs);
  flex-shrink: 0;
}
.form-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 1.25rem 0 .65rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--border);
}
.form-section-title:first-child { margin-top: 0; }
.card-body-compact { padding: var(--space-card) !important; }
.card-header-compact {
  padding: var(--space-card) var(--space-card) 0 !important;
  border-bottom: none !important;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-control,
.form-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: .55rem .75rem;
  font-size: var(--text-base);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
}
.form-control::placeholder { color: var(--text-faint); }
.form-control:focus,
.form-select:focus {
  background: var(--surface);
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--ring);
  color: var(--text);
}
.form-control:disabled,
.form-control[readonly] {
  background: var(--surface-2);
  color: var(--text-muted);
  opacity: .8;
}

.form-label {
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: .35rem;
}
.form-text { color: var(--text-muted); }

.input-group-text {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-muted);
}

/* Pill-shaped inputs keep their radius where views ask for it */
.form-control.rounded-pill,
.form-select.rounded-pill { border-radius: var(--r-pill) !important; }

/* ==========================================================================
   Alerts / badges / tables
   ========================================================================== */

.alert {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.alert-success { border-left: 3px solid #10b981; }
.alert-danger { border-left: 3px solid #ef4444; }
.alert-warning { border-left: 3px solid #f59e0b; }
.alert-info { border-left: 3px solid var(--brand-500); }

.badge.bg-brand { background: var(--brand-soft) !important; color: var(--brand-text) !important; font-weight: 600; }
.badge.bg-secondary {
  background: var(--surface-2) !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--border);
  font-weight: 600;
}

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--border);
}
.table > thead th {
  color: var(--text-muted);
  font-weight: 700;
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  border-bottom-color: var(--border);
}

.modal-content {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}
.modal-backdrop.show { opacity: .6; }

.list-group-item {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.list-group-item-action:hover,
.list-group-item-action:focus {
  background: var(--surface-2);
  color: var(--text);
}

/* ==========================================================================
   App shell — top bar
   ========================================================================== */

.app-bar {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: var(--surface-glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}

.app-bar-inner {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: 52px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-weight: 700;
  font-size: var(--text-md);
  letter-spacing: -.02em;
  color: var(--text);
  text-decoration: none;
}
.brand-mark:hover { color: var(--text); }
.brand-mark .brand-glyph {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-gradient);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: .9rem;
  box-shadow: 0 2px 8px rgba(15, 118, 110, .28);
}

/* Desktop nav links */
.top-nav {
  display: flex;
  align-items: center;
  gap: .25rem;
}
.top-nav-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .75rem;
  border-radius: var(--r-pill);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.top-nav-link:hover { background: var(--surface-2); color: var(--text); }
.top-nav-link.active { background: var(--brand-soft); color: var(--brand-text); }

/* Icon-only round button (theme toggle, avatar) */
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: inline-grid;
  place-items: center;
  transition: all .18s var(--ease);
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }

.avatar-chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .25rem .65rem .25rem .25rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  max-width: 160px;
  transition: all .18s var(--ease);
}
.avatar-chip:hover { color: var(--text); border-color: var(--border-strong); }
.avatar-chip .avatar-initial {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: .78rem;
  font-weight: 700;
  flex-shrink: 0;
}
.avatar-chip .avatar-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   App shell — mobile bottom nav
   ========================================================================== */

.mobile-bottom-nav {
  background: var(--surface-glass);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-top: 1px solid var(--border);
  height: var(--nav-h);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, .05);
  z-index: 1030;
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
}

.nav-item-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: .625rem;
  font-weight: 500;
  transition: color .2s var(--ease);
  width: 100%;
  min-width: 0;
  height: 100%;
  position: relative;
  padding: 0 2px;
}
.nav-item-btn span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-item-btn i { font-size: 1.15rem; transition: transform .25s var(--ease-spring); }
.nav-item-btn:hover { color: var(--text); }
.nav-item-btn.active { color: var(--brand-text); }
.nav-item-btn.active i { transform: translateY(-2px); }

/* Active pill indicator behind the icon */
.nav-item-btn.active::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 54px;
  height: 28px;
  border-radius: var(--r-pill);
  background: var(--brand-soft);
  z-index: -1;
}

/* Centre FAB */
.scan-btn-main { position: relative; overflow: visible; height: auto; }
.scan-btn-main.active::before { display: none; }

.scan-fab {
  position: absolute;
  top: -24px;
  width: 46px;
  height: 46px;
  background: var(--accent-gradient);
  border-radius: 14px;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(15, 118, 110, .38);
  border: 2px solid var(--bg);
  transition: transform .25s var(--ease-spring), box-shadow .25s var(--ease);
}
.scan-fab i { color: #fff; font-size: 1.2rem; }
.scan-label { margin-top: 22px; font-weight: 500; font-size: .625rem; color: var(--text-muted); }
.scan-btn-main.active .scan-label { color: var(--brand-text); }
.scan-btn-main:hover .scan-fab,
.scan-btn-main:active .scan-fab {
  transform: translateY(-3px) scale(1.06);
  box-shadow: 0 12px 30px rgba(15, 118, 110, .55);
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .mobile-bottom-nav { height: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
}

/* ==========================================================================
   Dashboard
   ========================================================================== */

.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  padding: 1.15rem 1.25rem;
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: var(--shadow);
  isolation: isolate;
}

/* Weather tint sits over the brand gradient — subtle, not a full page wash */
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0;
  transition: opacity 1s var(--ease);
  background: var(--hero-weather, transparent);
}
.hero[data-weather]::after { opacity: 1; }

.hero[data-weather="sunny"] { --hero-weather: linear-gradient(135deg, rgba(251, 191, 36, .55), rgba(14, 165, 165, .2)); }
.hero[data-weather="cloudy"] { --hero-weather: linear-gradient(135deg, rgba(148, 163, 184, .5), rgba(15, 118, 110, .25)); }
.hero[data-weather="rainy"] { --hero-weather: linear-gradient(135deg, rgba(56, 89, 138, .6), rgba(15, 118, 110, .3)); }
.hero[data-weather="snowy"] { --hero-weather: linear-gradient(135deg, rgba(203, 213, 225, .55), rgba(15, 118, 110, .2)); }
.hero[data-weather="night"] { --hero-weather: linear-gradient(135deg, rgba(15, 23, 42, .7), rgba(30, 27, 75, .55)); }

/* Decorative light bloom */
.hero-bloom {
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .3), transparent 65%);
  top: -140px;
  right: -80px;
  pointer-events: none;
}

.hero-greeting {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .75);
}
.hero-name {
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.2;
  margin: .15rem 0 .25rem;
}
.hero-sub { color: rgba(255, 255, 255, .82); font-size: var(--text-sm); }

.weather-badge {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: rgba(255, 255, 255, .18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, .28);
  padding: .45rem .9rem;
  border-radius: var(--r-pill);
  font-size: .82rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

/* Stat tiles */
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: .85rem 1rem;
  box-shadow: var(--shadow-sm);
  height: 100%;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.stat-tile:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.stat-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-text);
  display: grid;
  place-items: center;
  font-size: .95rem;
  margin-bottom: .5rem;
}
.stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--brand-text);
}
.stat-label { font-size: var(--text-xs); color: var(--text-muted); font-weight: 500; margin-top: .25rem; }

/* Quick action tiles */
.action-tile {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .7rem .85rem;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: var(--text-sm);
  box-shadow: var(--shadow-sm);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s var(--ease);
}
.action-tile:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  color: var(--text);
}
.action-tile .action-glyph {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-text);
  font-size: .9rem;
  flex-shrink: 0;
}
.action-tile .bi-chevron-right { margin-left: auto; color: var(--text-faint); font-size: var(--text-xs); }

/* Empty state */
.empty-state { text-align: center; padding: 2rem 1rem; }
.empty-glyph {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  margin: 0 auto .75rem;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  background: var(--brand-soft);
  color: var(--brand-text);
}
.empty-state p { color: var(--text-muted); font-size: var(--text-sm); }

/* ==========================================================================
   Contacts list
   ========================================================================== */

/* The icon centres against the input alone, not the whole filter group */
.android-search-field { position: relative; }
.android-search-bar {
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: .6rem 1rem;
  font-weight: 400;
  font-size: var(--text-base);
  box-shadow: var(--shadow-sm);
}
.android-search-bar:focus { background: var(--surface); }
.android-search-icon {
  position: absolute;
  left: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  z-index: 5;
  pointer-events: none;
}
.android-search-input { padding-left: 2.75rem !important; }

.alphabet-group-header {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--brand-text);
  letter-spacing: .08em;
  padding: .25rem 0;
  margin: .85rem 0 .25rem;
  border-bottom: 1px solid var(--border);
}

.android-contact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .55rem .5rem;
  margin: 0 -.5rem;
  border-radius: var(--r-sm);
  text-decoration: none;
  color: inherit;
  transition: background .15s var(--ease);
}
.android-contact-row + .android-contact-row { border-top: 1px solid var(--border); border-radius: var(--r-md); }
.android-contact-row:hover { background: var(--surface-2); }

.android-contact-avatar {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--brand-soft);
  color: var(--brand-text);
  font-weight: 600;
  font-size: var(--text-md);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.android-contact-info { flex-grow: 1; margin-left: .75rem; min-width: 0; }
.android-contact-name { font-weight: 500; font-size: var(--text-sm); color: var(--text); margin-bottom: .05rem; }
.android-contact-meta { font-size: var(--text-xs); color: var(--text-muted); }

/* A–Z rail */
.alphabet-sidebar {
  position: fixed;
  right: 4px;
  top: 130px;
  bottom: calc(var(--nav-h) + 20px);
  width: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  z-index: 99;
  user-select: none;
}
.alphabet-sidebar-link {
  font-size: .68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-decoration: none;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  transition: all .15s var(--ease);
}
.alphabet-sidebar-link:hover,
.alphabet-sidebar-link:active {
  background: var(--brand-500);
  color: #fff !important;
  transform: scale(1.25);
}

@media (max-width: 991px) {
  .pb-app main {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    padding-top: var(--space-page-y) !important;
    padding-bottom: var(--space-page-y) !important;
  }
  .android-contact-row,
  .android-contact-row > .d-flex { min-width: 0; max-width: 100%; }
  .hero { padding: 1rem; border-radius: var(--r-md); }
  .hero-name { font-size: var(--text-xl); }
  .form-control,
  .form-select { font-size: 1rem; }
}

@media (max-width: 575px) {
  .stat-tile-col { flex: 0 0 100%; max-width: 100%; }
  .stepper-node > span { display: none; }
  .premium-stepper { gap: .5rem; margin-bottom: 1.25rem; }
  .stepper-line { width: 28px; }
  .create-inline-form { flex-direction: column; }
  .create-inline-form .btn { width: 100%; }
}

/* Reserve room for the A–Z rail only in the range where it is actually shown
   (it is d-none below 576px, and the container has its own margins above 768px). */
@media (min-width: 576px) and (max-width: 991px) {
  .pb-app main { padding-right: 28px !important; }
}

/* ==========================================================================
   Segmented control
   ========================================================================== */

.premium-segmented-control {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: var(--r-pill);
}

.segmented-item {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 7px 4px;
  border-radius: var(--r-pill);
  transition: all .2s var(--ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  outline: none !important;
}
.segmented-item i { font-size: 1rem; }
.segmented-item:hover { color: var(--text); }
.segmented-item.active {
  background: var(--surface);
  color: var(--brand-text);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Auth
   ========================================================================== */

.auth-card { margin-top: 3rem; }
.auth-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto;
  border-radius: 20px;
  background: var(--accent-gradient);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  box-shadow: 0 8px 24px rgba(15, 118, 110, .35);
}

/* ==========================================================================
   Partner detail / scan wizard
   ========================================================================== */

.partner-card { transition: transform .15s var(--ease), box-shadow .15s var(--ease); }
.partner-card:hover { transform: translateY(-2px); box-shadow: var(--shadow) !important; }

.detail-dl dt { color: var(--text-muted); font-weight: 600; font-size: .85rem; }
.detail-dl dd { margin-bottom: .85rem; }

/* A single field row in the partner profile */
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: .65rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }
.detail-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  flex-shrink: 0;
}
.detail-key {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.detail-val { font-weight: 500; font-size: var(--text-sm); color: var(--text); margin-top: .15rem; word-break: break-word; }

@media (max-width: 575px) {
  .detail-row { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: nowrap; gap: 0.75rem; }
  .detail-row-actions { width: auto; display: flex; flex-wrap: nowrap; gap: 0.35rem; }
  .detail-row-actions .btn { flex: 0 0 auto; width: auto; padding: 0.3rem 0.6rem; font-size: 0.75rem; }
}

/* Manage list rows (replaces table on compact UI) */
.manage-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .75rem var(--space-card);
  border-bottom: 1px solid var(--border);
}
.manage-list-item:last-child { border-bottom: none; }
.manage-list-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  word-break: break-word;
}

/* Partner profile hero chip */
.profile-hero-chip {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .2);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.card-danger-zone { border-color: rgba(239, 68, 68, .35) !important; }

/* QR scan reader */
#reader { min-height: 280px; background: #000; border-radius: var(--r-md); }
#reader video { border-radius: var(--r-md); }

.filter-select-sm { font-size: var(--text-sm) !important; }

.vcard-qr {
  width: 276px;
  max-width: 100%;
  min-height: 276px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: #fff;
  display: grid;
  place-items: center;
}
.vcard-qr img,
.vcard-qr canvas {
  display: block;
  width: 256px !important;
  height: 256px !important;
  max-width: 100%;
}

/* OCR chips */
.ocr-blocks {
  min-height: 120px;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .6rem;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
}
.ocr-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .4rem .7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  color: var(--text);
  cursor: grab;
  user-select: none;
  font-size: .85rem;
  max-width: 100%;
  box-shadow: var(--shadow-sm);
  touch-action: none;
}
.ocr-chip:active { cursor: grabbing; }
.ocr-chip.selected {
  border-color: var(--brand-500);
  background: var(--brand-soft);
  color: var(--brand-text);
  box-shadow: 0 0 0 3px var(--ring);
}
.ocr-chip .chip-type {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  opacity: .65;
}

.drop-field .drop-target {
  border: 2px dashed var(--border-strong);
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.drop-field.drag-over .drop-target,
.drop-field.tap-target .drop-target {
  border-color: var(--brand-500);
  background: var(--brand-soft);
}

@media (max-width: 576px) {
  .ocr-chip { font-size: .8rem; }
}

/* Scan wizard */
.scan-wizard-step { display: none; animation: fadeInStep .4s var(--ease) forwards; }
.scan-wizard-step.active { display: block; }

/* Opacity only — a lingering transform creates a containing block and
   breaks position:fixed children (landscape camera fullscreen). */
@keyframes fadeInStep {
  from { opacity: 0; }
  to { opacity: 1; }
}

.premium-stepper {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}
.stepper-node {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: .88rem;
}
.stepper-node.active { color: var(--brand-text); }
.stepper-node.completed { color: #10b981; }
.stepper-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: grid;
  place-items: center;
  font-size: .8rem;
  transition: all .3s var(--ease);
}
.stepper-node.active .stepper-circle {
  border-color: var(--brand-500);
  background: var(--brand-soft);
  color: var(--brand-text);
  box-shadow: 0 0 0 4px var(--ring);
}
.stepper-node.completed .stepper-circle {
  border-color: #10b981;
  background: rgba(16, 185, 129, .12);
  color: #10b981;
}
.stepper-line { width: 44px; height: 2px; background: var(--border-strong); }
.stepper-node.completed + .stepper-line { background: #10b981; }

/* Camera */
.camera-container {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow-lg);
  aspect-ratio: 4 / 3;
}
.camera-video { width: 100%; height: 100%; object-fit: cover; }

.camera-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
}
.camera-card-frame {
  width: 85%;
  height: 70%;
  border: 2px dashed rgba(255, 255, 255, .5);
  border-radius: var(--r-md);
  position: relative;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .6);
  transition: border-color .3s var(--ease);
}
.camera-card-frame::before,
.camera-card-frame::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: #fff;
  border-style: solid;
  pointer-events: none;
}
.camera-card-frame::before {
  top: -2px; left: -2px;
  border-width: 4px 0 0 4px;
  border-top-left-radius: 14px;
}
.camera-card-frame::after {
  bottom: -2px; right: -2px;
  border-width: 0 4px 4px 0;
  border-bottom-right-radius: 14px;
}
.camera-card-frame.scanning { border-color: var(--brand-400); }
.camera-card-frame.scanning::before,
.camera-card-frame.scanning::after { border-color: var(--brand-400); }

.scan-laser-line {
  position: absolute;
  top: 0;
  left: 3%;
  width: 94%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--brand-500), var(--brand-300), var(--brand-500), transparent);
  box-shadow: 0 0 10px var(--brand-400);
  animation: laserScan 2s infinite linear;
  display: none;
}
.camera-card-frame.scanning .scan-laser-line { display: block; }

@keyframes laserScan {
  0% { top: 3%; }
  50% { top: 94%; }
  100% { top: 3%; }
}

.camera-preview-captured {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
  position: absolute;
  top: 0;
  left: 0;
}

/* ==========================================================================
   Profile nudge
   ========================================================================== */

@keyframes profile-nudge-blink {
  0%, 100% {
    border-color: var(--brand-500) !important;
    box-shadow: 0 4px 15px rgba(13, 110, 110, 0.1), inset 0 0 8px rgba(13, 110, 110, 0.02);
    background: linear-gradient(135deg, rgba(13, 110, 110, 0.05) 0%, var(--surface) 100%);
  }
  50% {
    border-color: var(--accent) !important;
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.35), inset 0 0 12px rgba(245, 158, 11, 0.08);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, var(--surface) 100%);
    transform: scale(1.01);
  }
}

.profile-nudge-card {
  border: 1.5px solid var(--brand-500) !important;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
  animation: profile-nudge-blink 3s infinite ease-in-out;
}
@keyframes profile-nudge-gradient-border {
  0% {
    border-color: var(--brand-500) !important;
    box-shadow: 0 4px 15px rgba(13, 110, 110, 0.15);
  }
  25% {
    border-color: var(--accent) !important;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.25);
  }
  50% {
    border-color: #3b82f6 !important;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.25);
  }
  75% {
    border-color: #ec4899 !important;
    box-shadow: 0 4px 15px rgba(236, 72, 153, 0.25);
  }
  100% {
    border-color: var(--brand-500) !important;
    box-shadow: 0 4px 15px rgba(13, 110, 110, 0.15);
  }
}

.profile-nudge-card.active-pulse {
  border-width: 2px !important;
  animation: profile-nudge-gradient-border 4s infinite linear !important;
}

@keyframes card-pop-bounce {
  0% { transform: scale(0.9); opacity: 0; }
  70% { transform: scale(1.03); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.card-pop-bounce-in {
  animation: card-pop-bounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}


.nudge-dismiss-btn {
  background: transparent;
  border: none;
  font-size: 1.15rem;
  color: var(--text-muted);
  padding: 0 4px;
  line-height: 1;
  transition: color .15s var(--ease);
}
.nudge-dismiss-btn:hover { color: #ef4444; }

/* ==========================================================================
   Misc helpers used by views
   ========================================================================== */

.max-width-md { max-width: 720px; }
.max-width-sm { max-width: 420px; }
.min-width-0 { min-width: 0; }
.pointer-events-none { pointer-events: none; }

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

/* ==========================================================================
   Page Transitions & Preloader
   ========================================================================== */

#pb-preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  visibility: visible;
  opacity: 1;
}

.preloader-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--brand-100);
  border-left-color: var(--brand-500);
  border-radius: 50%;
  animation: pb-spin 0.75s linear infinite;
}

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

.pb-page-transition {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pb-page-transition.page-entered {
  opacity: 1;
  transform: translateY(0);
}

.pb-page-transition.page-exited {
  opacity: 0;
  transform: translateY(-8px);
}

