* {
  margin: 0;
  padding: 0;
  box-sizing: border-box
}

:root {
  --bg: #070c15;
  --surface: #0f1623;
  --card: #161f2e;
  --card2: #1c2738;
  --border: #253045;
  --border-h: #2d3a52;
  --primary: #10b981;
  --primary-d: #059669;
  --primary-glow: rgba(16, 185, 129, .12);
  --primary-glow2: rgba(16, 185, 129, .06);
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, .1);
  --gold: #fbbf24;
  --gold-glow: rgba(251, 191, 36, .1);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, .08);
  --text: #f1f5f9;
  --text-s: #94a3b8;
  --text-m: #64748b;
  --text-d: #475569;
  --white: #fff;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, .3);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, .2);
  --transition: .25s cubic-bezier(.4, 0, .2, 1);
  --sidebar-w: 260px;
}

html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px;
  background: radial-gradient(ellipse at top, rgba(16, 185, 129, .08), transparent 60%), radial-gradient(ellipse at bottom right, rgba(99, 102, 241, .06), transparent 60%), var(--bg)
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 32px;
  width: 100%;
  max-width: 440px;
  animation: resultPop .5s ease
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin-bottom: 8px
}

.login-logo-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary), #047857);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px
}

.login-logo-text {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -.5px
}

.login-logo-text span {
  color: var(--primary)
}

.login-logo-text sup {
  font-size: 10px;
  color: var(--accent);
  margin-left: 1px
}

.login-subtitle {
  text-align: center;
  color: var(--text-m);
  font-size: 13px;
  margin-bottom: 28px
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px
}

.login-roles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px
}

.login-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-d)
}

.login-powered {
  color: var(--accent);
  font-weight: 600
}

/* Sidebar user */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--border)
}

.su-avatar {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--primary), #047857);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--white);
  flex-shrink: 0
}

.su-info {
  flex: 1;
  min-width: 0
}

.su-name {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.su-role {
  font-size: 11px;
  color: var(--text-m)
}

.su-logout {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--card);
  border-radius: 6px;
  color: var(--text-m);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition)
}

.su-logout:hover {
  background: var(--danger-glow);
  color: var(--danger)
}

/* Topbar user avatar */
.topbar-user {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), #047857);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--white);
  flex-shrink: 0
}

/* ===== APP SHELL ===== */
.app {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh
}

/* ===== SIDEBAR (Desktop ≥900px) ===== */
.sidebar {
  display: none;
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  overflow-y: auto
}

.sidebar-logo {
  padding: 20px 22px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border)
}

.sidebar-logo span {
  color: var(--primary)
}

.sidebar-logo sup {
  font-size: 9px;
  color: var(--accent);
  font-weight: 700;
  margin-left: 1px
}

.sidebar-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), #047857);
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: none;
  background: transparent;
  color: var(--text-m);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  font-family: inherit;
  text-align: left;
  width: 100%;
  position: relative
}

.sidebar-btn:hover {
  background: var(--card);
  color: var(--text-s)
}

.sidebar-btn.active {
  background: var(--primary-glow);
  color: var(--primary)
}

.sidebar-btn .sb-icon {
  font-size: 20px;
  width: 28px;
  text-align: center
}

.sidebar-btn .sb-label {
  flex: 1
}

.sidebar-btn .sb-badge {
  background: var(--danger);
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  min-width: 20px;
  text-align: center
}

.sidebar-program {
  padding: 12px;
  border-top: 1px solid var(--border)
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-d)
}

.sf-offline {
  font-weight: 600;
  color: var(--primary)
}

/* ===== MAIN ===== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh
}

/* Top Bar (Mobile only) */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px)
}

.topbar-logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.5px;
  display: flex;
  align-items: center;
  gap: 8px
}

.topbar-logo span {
  color: var(--primary)
}

.topbar-logo sup {
  font-size: 10px;
  color: var(--accent);
  margin-left: 1px
}

.topbar-logo .logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), #047857);
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px
}

.topbar-badge {
  background: var(--primary-glow);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 99px;
  letter-spacing: .5px
}

.program-switch {
  display: flex;
  background: var(--card);
  border-radius: var(--radius-xs);
  padding: 3px;
  gap: 2px
}

.program-switch button {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  color: var(--text-m);
  background: transparent
}

.program-switch button.active {
  background: var(--primary);
  color: var(--white)
}

.program-switch button.soon {
  opacity: .5;
  cursor: default
}

/* Bottom Nav (Mobile only) */
.bottomnav {
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px)
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border: none;
  background: transparent;
  color: var(--text-m);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  border-radius: var(--radius-xs)
}

.nav-btn .nav-icon {
  font-size: 22px;
  line-height: 1
}

.nav-btn.active {
  color: var(--primary)
}

.nav-btn.active .nav-icon {
  transform: scale(1.1)
}

.nav-btn .nav-badge {
  position: absolute;
  top: -2px;
  right: -6px;
  background: var(--danger);
  color: var(--white);
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 99px;
  min-width: 16px;
  text-align: center
}

.nav-btn .nav-icon-wrap {
  position: relative
}

/* ===== VIEWS ===== */
.view {
  display: none;
  flex: 1;
  padding: 16px;
  padding-bottom: calc(80px + env(safe-area-inset-bottom))
}

.view.active {
  display: flex;
  justify-content: center;
  animation: viewIn .3s ease
}

.view-inner {
  width: 100%;
  max-width: 640px
}

.view-inner--wide {
  max-width: 960px
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(12px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

/* ===== WIZARD ===== */
.wizard-progress {
  display: flex;
  gap: 6px;
  margin-bottom: 24px
}

.wizard-dot {
  flex: 1;
  height: 5px;
  border-radius: 99px;
  background: var(--card);
  transition: var(--transition)
}

.wizard-dot.done {
  background: var(--primary)
}

.wizard-dot.current {
  background: linear-gradient(90deg, var(--primary), var(--accent))
}

.wizard-step {
  animation: stepIn .35s ease
}

@keyframes stepIn {
  from {
    opacity: 0;
    transform: translateX(30px)
  }

  to {
    opacity: 1;
    transform: translateX(0)
  }
}

.step-header {
  margin-bottom: 20px
}

.step-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px
}

.step-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2
}

.step-sub {
  color: var(--text-s);
  font-size: 14px;
  margin-top: 6px
}

/* Option Cards */
.opt-grid {
  display: grid;
  gap: 10px
}

.opt-grid.cols-2 {
  grid-template-columns: 1fr 1fr
}

.opt-card {
  padding: 16px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 12px;
  -webkit-user-select: none;
  user-select: none;
  min-height: 56px
}

.opt-card:hover {
  border-color: var(--border-h);
  background: var(--card2)
}

.opt-card:active {
  transform: scale(.97)
}

.opt-card.selected {
  border-color: var(--primary);
  background: var(--primary-glow)
}

.opt-card .opt-emoji {
  font-size: 24px;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: var(--primary-glow2);
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center
}

.opt-card.selected .opt-emoji {
  background: rgba(16, 185, 129, .2)
}

.opt-card .opt-text {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3
}

.opt-card .opt-desc {
  font-size: 12px;
  color: var(--text-m);
  margin-top: 2px;
  font-weight: 400
}

.opt-card .check-mark {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  margin-left: auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 14px;
  color: transparent
}

.opt-card.selected .check-mark {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--white)
}

/* Text Input */
.field-group {
  margin-bottom: 16px
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-s);
  margin-bottom: 6px;
  display: block
}

.field-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: var(--transition)
}

.field-input:focus {
  border-color: var(--primary)
}

.field-input::placeholder {
  color: var(--text-d)
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px
}

/* Buttons */
.btn {
  padding: 16px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 54px
}

.btn:active {
  transform: scale(.97)
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #047857);
  color: var(--white);
  box-shadow: 0 4px 20px rgba(16, 185, 129, .3)
}

.btn-primary:hover {
  box-shadow: 0 8px 32px rgba(16, 185, 129, .4);
  transform: translateY(-1px)
}

.btn-secondary {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text)
}

.btn-ghost {
  background: transparent;
  color: var(--text-s);
  font-weight: 500;
  padding: 12px
}

.btn-danger {
  background: var(--danger-glow);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, .2)
}

.wizard-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px
}

.wizard-actions .btn {
  flex: 1
}

/* ===== RESULT ===== */
.result-hero {
  text-align: center;
  padding: 32px 20px;
  background: linear-gradient(135deg, rgba(16, 185, 129, .1), rgba(99, 102, 241, .08));
  border: 1px solid rgba(16, 185, 129, .2);
  border-radius: var(--radius);
  margin-bottom: 16px;
  animation: resultPop .5s ease
}

@keyframes resultPop {
  from {
    opacity: 0;
    transform: scale(.9)
  }

  to {
    opacity: 1;
    transform: scale(1)
  }
}

.result-hero .hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-glow);
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 99px;
  margin-bottom: 12px
}

.result-hero .hero-amount {
  font-size: 42px;
  font-weight: 900;
  color: var(--gold);
  line-height: 1
}

.result-hero .hero-label {
  font-size: 14px;
  color: var(--text-s);
  margin-top: 8px
}

.result-hero .hero-pct {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 4px
}

.result-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px
}

.result-section h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .04);
  font-size: 13px
}

.result-row:last-child {
  border: none
}

.result-row .rl {
  color: var(--text-s)
}

.result-row .rv {
  font-weight: 700;
  color: var(--primary)
}

.result-row .rv.gold {
  color: var(--gold)
}

.doc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-size: 13px;
  color: var(--text-s)
}

.doc-item .di-check {
  color: var(--primary);
  font-weight: 700;
  font-size: 16px
}

/* ===== DASHBOARD ===== */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center
}

.stat-card .stat-val {
  font-size: 28px;
  font-weight: 900;
  color: var(--primary);
  line-height: 1
}

.stat-card .stat-label {
  font-size: 11px;
  color: var(--text-m);
  margin-top: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px
}

.stat-card.gold .stat-val {
  color: var(--gold)
}

.lead-list {
  display: flex;
  flex-direction: column;
  gap: 8px
}

.lead-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: var(--transition)
}

.lead-card:hover {
  border-color: var(--border-h);
  background: var(--card2)
}

.lead-card .lead-avatar {
  width: 40px;
  height: 40px;
  background: var(--primary-glow);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0
}

.lead-card .lead-info {
  flex: 1;
  min-width: 0
}

.lead-card .lead-name {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.lead-card .lead-meta {
  font-size: 12px;
  color: var(--text-m);
  margin-top: 2px
}

.lead-card .lead-amount {
  font-size: 14px;
  font-weight: 800;
  color: var(--gold);
  text-align: right;
  white-space: nowrap
}

.lead-card .lead-status {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
  margin-top: 4px;
  display: inline-block
}

.lead-card .lead-status.s-new {
  background: var(--accent-glow);
  color: var(--accent)
}

.lead-card .lead-status.s-contact {
  background: var(--gold-glow);
  color: var(--gold)
}

.lead-card .lead-status.s-offer {
  background: rgba(56, 189, 248, .1);
  color: #38bdf8
}

.lead-card .lead-status.s-signed {
  background: var(--primary-glow);
  color: var(--primary)
}

.lead-card .lead-status.s-submitted {
  background: rgba(168, 85, 247, .1);
  color: #a855f7
}

.lead-card .lead-status.s-done {
  background: rgba(34, 197, 94, .15);
  color: #22c55e
}

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px
}

.dash-header h2 {
  font-size: 20px;
  font-weight: 800
}

.dash-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-m)
}

.dash-empty .de-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: .5
}

.dash-empty p {
  font-size: 14px
}

.search-bar {
  width: 100%;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  margin-bottom: 12px;
  transition: var(--transition)
}

.search-bar:focus {
  border-color: var(--primary)
}

.search-bar::placeholder {
  color: var(--text-d)
}

.filter-chips {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px
}

.filter-chip {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  background: transparent;
  color: var(--text-m);
  font-family: inherit
}

.filter-chip.active {
  border-color: var(--primary);
  background: var(--primary-glow);
  color: var(--primary)
}

/* ===== KNOWLEDGE BASE ===== */
.kb-section {
  margin-bottom: 20px
}

.kb-section h3 {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px
}

.kb-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 8px
}

.kb-card h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between
}

.kb-card .kb-body {
  font-size: 13px;
  color: var(--text-s);
  line-height: 1.7
}

.kb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 8px
}

.kb-table th {
  text-align: left;
  padding: 8px;
  background: var(--surface);
  color: var(--text-s);
  font-weight: 600;
  border-bottom: 1px solid var(--border)
}

.kb-table td {
  padding: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, .04)
}

.kb-table tr:hover td {
  background: var(--card2)
}

.kb-highlight {
  color: var(--primary);
  font-weight: 700
}

.kb-gold {
  color: var(--gold);
  font-weight: 700
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .2s ease
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  animation: modalPop .3s ease
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: scale(.9)
  }

  to {
    opacity: 1;
    transform: scale(1)
  }
}

@keyframes fadeIn {
  from {
    opacity: 0
  }

  to {
    opacity: 1
  }
}

.modal h3 {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 16px
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--card);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  z-index: 300;
  animation: toastIn .3s ease;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 320px
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(30px)
  }

  to {
    opacity: 1;
    transform: translateX(0)
  }
}

/* ===== DESKTOP LAYOUT (≥900px) ===== */
@media(min-width:900px) {
  .sidebar {
    display: flex
  }

  .main {
    margin-left: var(--sidebar-w)
  }

  .topbar {
    display: none
  }

  .bottomnav {
    display: none
  }

  .view {
    padding: 32px 40px;
    padding-bottom: 40px
  }

  .view-inner {
    max-width: 700px
  }

  .view-inner--wide {
    max-width: 1100px
  }

  .step-title {
    font-size: 28px
  }

  .opt-grid {
    gap: 12px
  }

  .dash-stats {
    grid-template-columns: repeat(4, 1fr)
  }

  .result-hero .hero-amount {
    font-size: 52px
  }

  .modal {
    border: 1px solid var(--border)
  }

  /* Desktop lead list gets extra columns */
  .lead-card {
    padding: 16px 20px;
    gap: 16px
  }

  .lead-card .lead-name {
    font-size: 15px
  }
}

/* ===== TABLET (600-899px) ===== */
@media(min-width:600px) and (max-width:899px) {
  .view {
    padding: 24px
  }

  .opt-grid {
    gap: 12px
  }

  .dash-stats {
    grid-template-columns: repeat(4, 1fr)
  }

  .topbar {
    padding: 14px 28px
  }
}

/* ===== SMALL MOBILE ===== */
@media(max-width:400px) {
  .opt-grid.cols-2 {
    grid-template-columns: 1fr
  }

  .field-row {
    grid-template-columns: 1fr
  }

  .result-hero .hero-amount {
    font-size: 32px
  }
}

/* ===== AI FLOATING CHAT ===== */
#ai-fab {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  border: none;
  font-size: 28px;
  cursor: pointer;
  z-index: 150;
  box-shadow: 0 4px 20px rgba(99, 102, 241, .4);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fabPulse 2s ease infinite
}

#ai-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 32px rgba(99, 102, 241, .5)
}

#ai-fab.hidden {
  transform: scale(0);
  opacity: 0;
  pointer-events: none
}

@keyframes fabPulse {

  0%,
  100% {
    box-shadow: 0 4px 20px rgba(99, 102, 241, .4)
  }

  50% {
    box-shadow: 0 4px 28px rgba(99, 102, 241, .6)
  }
}

#ai-panel {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 400px;
  max-width: 100vw;
  height: 600px;
  max-height: calc(100vh - 60px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
  transition: transform .3s ease, opacity .2s ease;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .4)
}

#ai-panel.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all
}

.ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(99, 102, 241, .15), rgba(99, 102, 241, .05));
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  flex-shrink: 0
}

.ai-header-left {
  display: flex;
  align-items: center;
  gap: 10px
}

.ai-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px
}

.ai-header-title {
  font-size: 14px;
  font-weight: 700
}

.ai-header-sub {
  font-size: 11px;
  color: var(--text-m)
}

.ai-header-actions {
  display: flex;
  gap: 4px
}

.ai-hdr-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--card);
  border-radius: 6px;
  color: var(--text-m);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition)
}

.ai-hdr-btn:hover {
  background: var(--card2);
  color: var(--text)
}

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px
}

.ai-msg {
  display: flex;
  gap: 8px;
  animation: fadeIn .3s ease
}

.ai-msg.ai-user {
  flex-direction: row-reverse
}

.ai-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0
}

.ai-msg-body {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.6
}

.ai-bot .ai-msg-body {
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px
}

.ai-user .ai-msg-body {
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: var(--white);
  border-bottom-right-radius: 4px
}

.ai-msg-text strong {
  color: var(--primary)
}

.ai-user .ai-msg-text strong {
  color: var(--white)
}

.ai-typing {
  display: flex;
  gap: 4px;
  padding: 4px 0
}

.ai-typing span {
  width: 7px;
  height: 7px;
  background: var(--text-m);
  border-radius: 50%;
  animation: bounce .6s ease infinite
}

.ai-typing span:nth-child(2) {
  animation-delay: .1s
}

.ai-typing span:nth-child(3) {
  animation-delay: .2s
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(0)
  }

  50% {
    transform: translateY(-5px)
  }
}

.ai-suggestions {
  display: flex;
  gap: 6px;
  padding: 8px 16px;
  overflow-x: auto;
  flex-shrink: 0;
  border-top: 1px solid var(--border)
}

.ai-chip {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  background: transparent;
  color: var(--text-m);
  font-family: inherit;
  transition: var(--transition)
}

.ai-chip:hover {
  border-color: var(--accent);
  color: var(--accent)
}

.ai-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0
}

.ai-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none
}

.ai-input:focus {
  border-color: var(--accent)
}

.ai-input::placeholder {
  color: var(--text-d)
}

.ai-send {
  width: 40px;
  height: 40px;
  border: none;
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  border-radius: var(--radius-xs);
  color: var(--white);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0
}

.ai-send:hover {
  transform: scale(1.05)
}

.ai-no-key {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap
}

/* AI Recommendation Card */
.ai-reco-card {
  background: linear-gradient(135deg, rgba(99, 102, 241, .08), rgba(99, 102, 241, .03));
  border: 1px solid rgba(99, 102, 241, .2);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  animation: fadeIn .4s ease
}

.ai-reco-header {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap
}

.ai-reco-badge {
  font-size: 10px;
  font-weight: 600;
  background: var(--accent-glow);
  color: var(--accent);
  padding: 3px 8px;
  border-radius: 99px
}

.ai-reco-body {
  font-size: 13px;
  color: var(--text-s);
  line-height: 1.8
}

.ai-reco-body strong {
  color: var(--text)
}

.ai-reco-loading {
  text-align: center;
  padding: 24px
}

.ai-reco-card.loading {
  animation: pulse 1.5s ease infinite
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: .6
  }
}

/* Desktop FAB position */
@media(min-width:900px) {
  #ai-fab {
    bottom: 24px;
    right: 24px
  }

  #ai-panel {
    right: 20px;
    bottom: 20px;
    border-radius: var(--radius);
    height: 640px
  }
}