:root {
  --navy: #113768;
  --blue: #0598ce;
  --black: #000100;
  --dark-gray: #4d4d4d;
  --light-gray: #b3b3b3;
  --white: #ffffff;
  --bg: #f5f7fa;
  --success: #28a745;
  --danger: #dc3545;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--black);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

/* --- Screens --- */
.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0 16px 32px;
}
.screen.active {
  display: block;
}

/* --- Header --- */
header {
  display: flex;
  align-items: center;
  padding: 16px 0;
  gap: 12px;
  border-bottom: 1px solid #e8e8e8;
  margin-bottom: 16px;
}
header h2 {
  font-size: 17px;
  font-weight: 600;
  color: var(--navy);
  flex: 1;
  text-align: right;
}

/* --- Buttons --- */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--navy);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:hover {
  background: var(--blue);
}
.btn-primary:active {
  transform: scale(0.98);
}
.btn-primary:disabled {
  background: var(--light-gray);
  cursor: not-allowed;
}

.btn-text {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 0;
  white-space: nowrap;
}

/* --- Login Screen --- */
.login-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
}
.login-container form {
  width: 100%;
  max-width: 320px;
}
.logo {
  margin-bottom: 40px;
  text-align: center;
}
.logo h1 {
  font-size: 56px;
  color: var(--navy);
  letter-spacing: 6px;
  font-weight: 900;
}
.logo p {
  color: var(--dark-gray);
  font-size: 16px;
  margin-top: 4px;
  letter-spacing: 1px;
}

/* --- Form Fields --- */
.field {
  margin-bottom: 14px;
}
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--dark-gray);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.field input,
.field textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 16px;
  background: white;
  transition: border-color 0.2s;
  font-family: inherit;
}
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(5, 152, 206, 0.1);
}
.field.highlight input {
  border: 2px solid var(--blue);
  font-weight: 500;
}

.field-row {
  display: flex;
  gap: 12px;
}
.field-row .field {
  flex: 1;
}

/* --- Source Tags --- */
.source-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  margin-top: 4px;
  font-weight: 500;
}
.source-tag.apollo {
  background: #e8f5e9;
  color: #2e7d32;
}
.source-tag.badge {
  background: #e3f2fd;
  color: #1565c0;
}
.source-tag.manual {
  color: var(--danger);
  font-weight: 600;
}

/* --- Toggle Switch --- */
.toggle-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}
.toggle-field label {
  margin-bottom: 0;
  font-size: 14px;
}
.toggle-field input[type="checkbox"] {
  width: 50px;
  height: 26px;
  -webkit-appearance: none;
  appearance: none;
  background: #ddd;
  border-radius: 13px;
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-field input[type="checkbox"]::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-field input[type="checkbox"]:checked {
  background: var(--blue);
}
.toggle-field input[type="checkbox"]:checked::after {
  transform: translateX(24px);
}

/* --- Show Cards --- */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.show-card {
  background: white;
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 18px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.show-card:hover,
.show-card:active {
  border-color: var(--blue);
  box-shadow: 0 2px 12px rgba(5, 152, 206, 0.12);
}
.show-card h3 {
  font-size: 16px;
  color: var(--navy);
  margin-bottom: 4px;
}
.show-card p {
  font-size: 13px;
  color: var(--dark-gray);
}

/* --- Scanner --- */
.scanner-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 32px;
}
.scan-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 180px;
  height: 180px;
  background: var(--navy);
  border-radius: 50%;
  color: white;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
  user-select: none;
  -webkit-user-select: none;
}
.scan-button:active {
  transform: scale(0.93);
  background: var(--blue);
}
.scan-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 8px;
}
.scan-button span {
  font-size: 16px;
  font-weight: 600;
}
.scan-count {
  margin-top: 24px;
  font-size: 14px;
  color: var(--dark-gray);
}

/* --- Leads List --- */
.leads-list {
  width: 100%;
  margin-top: 16px;
}
.lead-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: white;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.lead-info h4 {
  font-size: 14px;
  color: var(--navy);
  font-weight: 600;
}
.lead-info p {
  font-size: 12px;
  color: var(--dark-gray);
  margin-top: 1px;
}
.lead-status {
  font-size: 18px;
  color: var(--success);
}
.lead-status.hot {
  color: #e65100;
}

/* --- Review Form --- */
.review-form {
  padding-top: 4px;
  padding-bottom: 24px;
}
.btn-submit {
  margin-top: 8px;
}

/* --- Loading Overlay --- */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(17, 55, 104, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.loading-overlay.hidden {
  display: none;
}
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top: 4px solid white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loading-overlay p {
  color: white;
  margin-top: 16px;
  font-size: 15px;
  font-weight: 500;
}

/* --- Debug Banner --- */
.debug-banner {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--dark-gray);
  word-break: break-word;
}
.debug-banner strong {
  color: var(--navy);
}

/* --- Utilities --- */
.error {
  color: var(--danger);
  font-size: 14px;
  margin-top: 10px;
  text-align: center;
}
.hidden {
  display: none !important;
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--success);
  color: white;
  padding: 12px 28px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  z-index: 200;
  animation: toastIn 0.3s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.toast.error {
  background: var(--danger);
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
