/* ── Reset & Variables ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #F9F6F2;
  --navy:     #18324C;
  --navy-lt:  #1E3D5C;
  --gold:     #C39949;
  --gold-lt:  #D4AE6A;
  --white:    #FFFFFF;
  --gray-50:  #F5F4F2;
  --gray-100: #EAEAEA;
  --gray-300: #C4C4C4;
  --gray-500: #8A8A8A;
  --gray-700: #4A4A4A;
  --red:      #C94F4F;
  --green:    #2E7A52;

  --font: 'Montserrat', sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,.07);
  --shadow-md: 0 4px 14px rgba(0,0,0,.10);

  --nav-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--navy);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  height: 100vh;
  background: var(--bg);
}

/* ── Loading Screen ── */
.loading-screen {
  position: fixed; inset: 0;
  background: var(--navy);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 28px; z-index: 1000;
  transition: opacity .35s ease;
}
.loading-screen.fade-out { opacity: 0; pointer-events: none; }

.loading-logo {
  display: flex; flex-direction: column;
  align-items: center; gap: 14px;
  color: var(--white);
}
.loading-logo .brand-name {
  font-size: 22px; font-weight: 700; letter-spacing: 2px;
  text-transform: uppercase;
}
.loading-logo .brand-sub {
  font-size: 12px; font-weight: 500; letter-spacing: 1px;
  color: rgba(255,255,255,.55); text-transform: uppercase;
  margin-top: -8px;
}

.loading-spinner {
  width: 34px; height: 34px;
  border: 3px solid rgba(195,153,73,.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Screen Container ── */
.screen-container {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
  background: var(--bg);
}
.screen-container.no-nav { padding-bottom: 0; }

/* ── Bottom Nav ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--navy);
  display: flex; align-items: stretch;
  z-index: 100;
}

.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 5px; border: none; background: none;
  color: rgba(255,255,255,.45); cursor: pointer;
  font-family: var(--font); font-size: 10px; font-weight: 600;
  letter-spacing: .8px; text-transform: uppercase;
  transition: color .2s;
  -webkit-tap-highlight-color: transparent;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--gold); }

/* ── Utility ── */
.hidden { display: none !important; }
.flex-row { display: flex; align-items: center; }
.flex-1 { flex: 1; }

/* ── Page Header ── */
.page-header {
  background: var(--navy);
  padding: 16px 16px 14px;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 50;
  min-height: 58px;
}
.page-header h1 {
  font-size: 16px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--white); flex: 1;
}
.page-header .back-btn {
  background: none; border: none; color: var(--white);
  cursor: pointer; padding: 4px; display: flex;
  align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.page-header .back-btn svg { width: 22px; height: 22px; }
.page-header .header-right {
  display: flex; align-items: center; gap: 10px;
}
.rep-avatar-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--gold); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font); font-size: 13px; font-weight: 700;
  color: var(--white); -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.header-icon-btn {
  background: none; border: none; color: var(--white);
  cursor: pointer; padding: 4px; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.header-icon-btn svg { width: 22px; height: 22px; }

/* Hexagon logo mark in header */
.hex-logo {
  width: 30px; height: 30px; flex-shrink: 0;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 14px 20px;
  font-family: var(--font); font-size: 13px; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none;
  transition: opacity .2s, transform .1s;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary   { background: var(--gold);  color: var(--white); }
.btn-secondary { background: var(--navy);  color: var(--white); }
.btn-outline   {
  background: transparent; color: var(--navy);
  border: 1.5px solid var(--navy);
}
.btn-danger    { background: var(--red);   color: var(--white); }
.btn-ghost     { background: var(--gray-100); color: var(--navy); }

.btn-sm { padding: 10px 16px; font-size: 12px; width: auto; }

/* ── Form Fields — gold underline style ── */
.form-group { display: flex; flex-direction: column; gap: 0; }

.form-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--gray-500); margin-bottom: 6px;
}

.form-input, .form-textarea {
  width: 100%; padding: 6px 0 10px;
  font-family: var(--font); font-size: 15px; font-weight: 500;
  color: var(--navy);
  background: transparent;
  border: none; border-bottom: 1.5px solid var(--gold);
  border-radius: 0; outline: none;
  -webkit-appearance: none;
  transition: border-color .2s;
}
.form-input::placeholder, .form-textarea::placeholder {
  color: var(--gray-300); font-style: italic; font-weight: 400;
}
.form-input:focus, .form-textarea:focus {
  border-bottom-color: var(--navy);
}
.form-input.not-found {
  color: var(--gray-300); font-style: italic;
}
.form-textarea {
  resize: vertical; min-height: 90px;
  border: 1.5px solid var(--gray-100);
  border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: 14px;
}
.form-textarea:focus { border-color: var(--gold); }

/* ── Login Screen ── */
.login-screen {
  min-height: 100dvh; min-height: 100vh;
  background: var(--navy);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 24px;
}
.login-logo {
  display: flex; flex-direction: column;
  align-items: center; gap: 14px; margin-bottom: 44px;
}
.login-logo .brand-name {
  color: var(--white); font-size: 24px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase;
}
.login-logo .brand-tagline {
  color: rgba(255,255,255,.5); font-size: 12px; font-weight: 500;
  letter-spacing: 1px; text-transform: uppercase; margin-top: -6px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--white); border-radius: var(--radius-lg);
  padding: 28px 24px 32px; box-shadow: var(--shadow-md);
}
.login-card h2 {
  font-size: 17px; font-weight: 700; margin-bottom: 22px;
  color: var(--navy); text-align: center; letter-spacing: .5px;
}
.login-form { display: flex; flex-direction: column; gap: 18px; }
.login-divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--gray-300); font-size: 12px; font-weight: 600;
  letter-spacing: 1px; margin: 4px 0;
}
.login-divider::before, .login-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--gray-100);
}
.btn-google {
  background: var(--white); color: var(--gray-700);
  border: 1.5px solid var(--gray-100);
  font-size: 13px; font-weight: 600; letter-spacing: .5px;
}
.btn-google svg { width: 18px; height: 18px; }
.login-field { display: flex; flex-direction: column; gap: 6px; }
.login-field label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: var(--gray-500);
}
.login-field input {
  padding: 11px 13px; border: 1.5px solid var(--gray-100);
  border-radius: var(--radius-sm); font-family: var(--font);
  font-size: 15px; color: var(--navy); outline: none;
  transition: border-color .2s;
}
.login-field input:focus { border-color: var(--gold); }
.login-error {
  color: var(--red); font-size: 13px; font-weight: 500;
  text-align: center; min-height: 20px;
}

/* ── Scan Screen ── */
.scan-screen { background: var(--bg); }
.scan-top-area {
  padding: 20px 16px 12px;
}
.scan-top-area h2 {
  font-size: 18px; font-weight: 700; color: var(--navy);
}
.scan-top-area p {
  font-size: 13px; color: var(--gray-500); margin-top: 4px; font-weight: 500;
}
.scan-card-area {
  margin: 0 16px;
  background: #0E2030;
  border-radius: var(--radius-md);
  aspect-ratio: 4/3;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; cursor: pointer;
  position: relative; overflow: hidden;
  border: 1.5px solid rgba(195,153,73,.25);
  -webkit-tap-highlight-color: transparent;
}
.scan-card-area:active { opacity: .9; }
.scan-card-area .camera-icon {
  width: 52px; height: 52px; color: var(--gold); opacity: .85;
}
.scan-card-label {
  color: var(--gold); font-size: 13px; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase;
}
.scan-card-hint {
  color: rgba(255,255,255,.45); font-size: 12px; font-weight: 500;
}
.scan-card-area video, .scan-card-area canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
}
.scan-viewfinder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.viewfinder-frame {
  width: 78%; aspect-ratio: 16/9;
  border: 2px solid var(--gold);
  border-radius: 8px;
  box-shadow: 0 0 0 2000px rgba(0,0,0,.45);
}
.scan-buttons {
  padding: 16px 16px 8px;
  display: flex; flex-direction: column; gap: 10px;
}
.scan-btn {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; width: 100%; padding: 14px;
  background: transparent; color: var(--navy);
  border: 1.5px solid var(--navy); border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 13px; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase; cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: background .2s;
}
.scan-btn:active { background: rgba(24,50,76,.06); }
.scan-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.preview-container {
  margin: 0 16px;
  border-radius: var(--radius-md); overflow: hidden;
  position: relative; aspect-ratio: 4/3;
  background: #0E2030;
}
.preview-container img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.processing-overlay {
  position: absolute; inset: 0;
  background: rgba(14,32,48,.88);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px; color: var(--white);
  font-size: 14px; font-weight: 600; letter-spacing: .5px;
}
.shutter-row {
  display: flex; align-items: center; justify-content: center;
  gap: 24px; padding: 16px;
}
.shutter-btn {
  width: 68px; height: 68px; border-radius: 50%;
  background: var(--gold); border: 4px solid var(--white);
  box-shadow: 0 0 0 2px var(--gold);
  cursor: pointer; transition: transform .15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.shutter-btn:active { transform: scale(.92); }
.retake-btn {
  background: none; border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm); padding: 10px 20px;
  font-family: var(--font); font-size: 12px; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase; color: var(--gray-700);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}

/* ── Review Screen ── */
.review-screen { background: var(--bg); }
.review-subtitle {
  padding: 14px 16px 10px;
  font-size: 13px; color: var(--gray-500); font-weight: 500;
  line-height: 1.5;
}
.review-image-strip {
  width: calc(100% - 32px); margin: 0 16px 4px;
  height: 110px; object-fit: cover;
  border-radius: var(--radius-md);
  border-bottom: 3px solid var(--gold);
}
.review-form {
  padding: 8px 16px 120px;
  display: flex; flex-direction: column; gap: 20px;
}
.review-actions {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom));
  left: 0; right: 0;
  background: var(--white);
  padding: 12px 16px 14px;
  border-top: 1px solid var(--gray-100);
  display: flex; gap: 12px;
  box-shadow: 0 -3px 14px rgba(0,0,0,.07);
  z-index: 60;
}
.review-actions .btn { flex: 1; }
.btn-discard { background: transparent; color: var(--navy); border: 1.5px solid var(--navy); }
.btn-approve { background: var(--gold); color: var(--white); }

/* ── Leads Screen ── */
.leads-screen { background: var(--bg); }
.leads-subtitle {
  padding: 12px 16px 6px;
  font-size: 12px; color: var(--gray-500); font-weight: 500;
  letter-spacing: .2px;
}
.leads-filter {
  padding: 4px 16px 10px; display: flex; gap: 8px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.leads-filter::-webkit-scrollbar { display: none; }
.filter-chip {
  padding: 6px 14px; border-radius: 999px;
  border: 1.5px solid var(--gray-300); background: var(--white);
  font-family: var(--font); font-size: 11px; font-weight: 700;
  letter-spacing: .5px; text-transform: uppercase;
  color: var(--gray-500); cursor: pointer; white-space: nowrap;
  transition: all .15s; -webkit-tap-highlight-color: transparent;
}
.filter-chip.active {
  background: var(--navy); border-color: var(--navy); color: var(--white);
}

.leads-list { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 8px; }

.lead-card {
  background: var(--white); border-radius: var(--radius-md);
  padding: 14px 16px; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: box-shadow .15s;
}
.lead-card:active { box-shadow: var(--shadow-md); }
.lead-info { flex: 1; min-width: 0; }
.lead-name {
  font-size: 14px; font-weight: 700; color: var(--navy);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lead-company {
  font-size: 12px; color: var(--gray-500); font-weight: 500; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lead-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.lead-date { font-size: 10px; color: var(--gray-300); font-weight: 500; }

.status-badge {
  font-size: 10px; font-weight: 700; padding: 4px 10px;
  border-radius: 4px; text-transform: uppercase; letter-spacing: .6px;
  white-space: nowrap;
}
.badge-pending    { background: rgba(195,153,73,.15); color: #9A7620; border: 1px solid rgba(195,153,73,.35); }
.badge-approved   { background: rgba(46,122,82,.12); color: var(--green); border: 1px solid rgba(46,122,82,.3); }
.badge-in_hubspot { background: rgba(0,130,160,.10); color: #0082A0; border: 1px solid rgba(0,130,160,.3); }
.badge-error      { background: rgba(201,79,79,.10); color: var(--red); border: 1px solid rgba(201,79,79,.3); }
.badge-discarded  { background: var(--gray-100); color: var(--gray-500); border: 1px solid var(--gray-100); }

.empty-state {
  text-align: center; padding: 64px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.empty-state svg { width: 52px; height: 52px; color: var(--gray-300); }
.empty-state strong { font-size: 15px; color: var(--navy); font-weight: 700; }
.empty-state p { font-size: 13px; color: var(--gray-500); font-weight: 500; }

/* ── Profile Screen ── */
.profile-screen { background: var(--bg); }
.profile-hero {
  background: var(--navy); padding: 28px 24px 32px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.profile-avatar-lg {
  width: 68px; height: 68px; border-radius: 50%;
  background: var(--gold); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; margin-bottom: 4px;
}
.profile-name { font-size: 18px; font-weight: 700; color: var(--white); }
.profile-email { font-size: 12px; color: rgba(255,255,255,.55); font-weight: 500; }

.profile-stats {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 8px; padding: 16px;
}
.stat-card {
  background: var(--white); border-radius: var(--radius-md);
  padding: 14px 8px; text-align: center; box-shadow: var(--shadow-sm);
}
.stat-num { font-size: 22px; font-weight: 700; color: var(--navy); }
.stat-lbl { font-size: 10px; color: var(--gray-500); font-weight: 600;
  letter-spacing: .5px; text-transform: uppercase; margin-top: 3px; }

.profile-section {
  padding: 8px 16px 4px;
}
.profile-section-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: var(--gray-500); margin-bottom: 10px;
}
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-item {
  background: var(--white); border-radius: var(--radius-md);
  padding: 15px 16px; display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow-sm); cursor: pointer; border: none;
  font-family: var(--font); font-size: 14px; font-weight: 600;
  color: var(--navy); width: 100%; text-align: left;
  -webkit-tap-highlight-color: transparent; transition: opacity .15s;
}
.menu-item:active { opacity: .7; }
.menu-item .menu-icon { width: 20px; height: 20px; color: var(--gold); flex-shrink: 0; }
.menu-item .chevron { margin-left: auto; color: var(--gray-300); width: 16px; height: 16px; }
.menu-item.danger { color: var(--red); }
.menu-item.danger .menu-icon { color: var(--red); }

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
  left: 16px; right: 16px; z-index: 999;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center; pointer-events: none;
}
.toast {
  padding: 12px 20px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 600; color: var(--white);
  box-shadow: var(--shadow-md); max-width: 360px; width: 100%;
  text-align: center; pointer-events: auto;
  animation: slide-up .25s ease;
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
.toast.info    { background: var(--navy); }
.toast.warning { background: #B87333; }
@keyframes slide-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Offline Banner ── */
.offline-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  background: #B87333; color: var(--white);
  padding: 10px 16px; text-align: center;
  font-size: 12px; font-weight: 700; letter-spacing: .5px;
  transform: translateY(-100%); transition: transform .3s ease;
}
.offline-banner.visible { transform: translateY(0); }

/* ── Spinner inline ── */
.spinner-sm {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: var(--white);
  animation: spin .65s linear infinite; flex-shrink: 0;
}

@media (min-width: 480px) {
  .screen-container { max-width: 430px; margin: 0 auto; }
  .bottom-nav { max-width: 430px; left: 50%; transform: translateX(-50%); }
  .review-actions { max-width: 430px; left: 50%; transform: translateX(-50%); right: auto; width: 430px; }
  .toast-container { max-width: 430px; left: 50%; transform: translateX(-50%); right: auto; width: 430px; }
}
