:root {
    --brand: #6C3EFF;
    --brand-light: #EDE8FF;
    --brand-dark: #4A22DD;
    --accent: #FF6B35;
    --bg: #F5F3FF;
    --surface: #ffffff;
    --border: rgba(108,62,255,0.12);
    --text: #1A1025;
    --muted: #7B6A9A;
    --success: #1DB97B;
    --hot: #FF4444;
    --warm: #FF8C00;
    --cold: #3B82F6;
    --radius: 16px;
    --shadow: 0 4px 24px rgba(108,62,255,0.10);
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px 40px;
  }

  /* ── Hero ── */
  .hero {
    text-align: center;
    margin-bottom: 15px;
    max-width: 560px;
  }
  .hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--brand-light);
    color: var(--brand);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    padding: 5px 14px;
    border-radius: 999px;
    margin-bottom: 16px;
    text-transform: uppercase;
  }
  .hero h1 {
    font-family: 'Syne', sans-serif;
    font-size: clamp(22px, 5vw, 22px);
    font-weight: 800;
    line-height: 1.15;
    color: var(--text);
    margin-bottom: 10px;
  }
  .hero h1 span { color: var(--brand); font-size:22px; }
  .hero p { font-size: 15px; color: var(--muted); line-height: 1.6; }

  /* ── Card ── */
  .card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 520px;
    overflow: hidden;
  }



  /* ── Chat ── */
  .chat-messages {
    height: 360px;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: linear-gradient(180deg, #FDFCFF 0%, #F8F5FF 100%);
    scroll-behavior: smooth;
  }
  .chat-messages::-webkit-scrollbar { width: 4px; }
  .chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

  .msg { display: flex; flex-direction: column; max-width: 82%; gap: 4px; animation: fadeUp .25s ease; }
  @keyframes fadeUp { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
  .msg.bot { align-self: flex-start; }
  .msg.user { align-self: flex-end; }

  .bubble {
    padding: 11px 15px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.55;
  }
  .bot .bubble {
    background: white;
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 6px rgba(108,62,255,.06);
  }
  .user .bubble {
    background: var(--brand);
    color: white;
    border-bottom-right-radius: 4px;
  }
  .msg-time { font-size: 10px; color: var(--muted); padding: 0 4px; }
  .user .msg-time { text-align: right; }

  .typing-bubble {
    display: flex; gap: 5px; align-items: center;
    padding: 12px 16px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 1px 6px rgba(108,62,255,.06);
  }
  .typing-bubble span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--brand);
    opacity: .4;
    animation: blink 1.2s infinite;
  }
  .typing-bubble span:nth-child(2) { animation-delay: .2s; }
  .typing-bubble span:nth-child(3) { animation-delay: .4s; }
  @keyframes blink { 0%,60%,100%{opacity:.4;transform:scale(1)} 30%{opacity:1;transform:scale(1.15)} }

  .chat-footer {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    background: white;
    border-top: 1px solid var(--border);
    align-items: center;
  }
  .chat-input {
    flex: 1;
    border: 1.5px solid var(--border);
    border-radius: 999px;
    padding: 9px 16px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    color: var(--text);
    background: var(--bg);
    outline: none;
    transition: border .2s;
  }
  .chat-input:focus { border-color: var(--brand); background: white; }
  .chat-input::placeholder { color: var(--muted); }
  .send-btn {
    width: 38px; height: 38px;
    background: var(--brand);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background .2s, transform .1s;
  }
  .send-btn:hover { background: var(--brand-dark); }
  .send-btn:active { transform: scale(.94); }
  .send-btn svg { fill: white; width: 16px; height: 16px; }

  /* ── Form ── */
  .form-body {
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: white;
    max-height: 420px;
    overflow-y: auto;
  }
  .field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: .04em;
    text-transform: uppercase;
    margin-bottom: 6px;
  }
  .field input, .field select {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid #E8E3FF;
    border-radius: 10px;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    color: var(--text);
    background: #FDFCFF;
    outline: none;
    transition: border .2s, box-shadow .2s;
    appearance: none;
  }
  .field input:focus, .field select:focus {
    border-color: var(--brand);
    background: white;
    box-shadow: 0 0 0 3px rgba(108,62,255,.08);
  }
  .field input::placeholder { color: #C4BBDD; }
  .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .primary-btn {
    width: 100%;
    padding: 13px;
    background: var(--brand);
    color: white;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background .2s, transform .1s;
    display: flex; align-items: center; justify-content: center; gap: 8px;
  }
  .primary-btn:hover { background: var(--brand-dark); }
  .primary-btn:active { transform: scale(.98); }
  .primary-btn:disabled { background: #C4BBDD; cursor: not-allowed; }

  /* ── Leads ── */
  .leads-header {
    padding: 14px 18px;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .leads-header h3 { font-size: 14px; font-weight: 600; color: var(--text); }
  .count-badge {
    background: var(--brand-light);
    color: var(--brand);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
  }
  .leads-list {
    max-height: 390px;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #FAFAFA;
  }
  .lead-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: fadeUp .2s ease;
  }
  .lead-ava {
    width: 38px; height: 38px;
    border-radius: 12px;
    background: var(--brand-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--brand);
    flex-shrink: 0;
  }
  .lead-info { flex: 1; min-width: 0; }
  .lead-name { font-size: 14px; font-weight: 600; color: var(--text); }
  .lead-sub { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .lead-tags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
  .tag { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
  .tag-hot { background: #FFF0F0; color: var(--hot); }
  .tag-warm { background: #FFF5E6; color: var(--warm); }
  .tag-cold { background: #EFF6FF; color: var(--cold); }
  .tag-service { background: #F0EDFF; color: var(--brand); }
  .book-mini {
    font-size: 11px;
    font-weight: 600;
    color: var(--brand);
    background: var(--brand-light);
    border: none;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background .15s;
  }
  .book-mini:hover { background: #D9D0FF; }
  .empty-leads {
    text-align: center;
    padding: 50px 20px;
    color: var(--muted);
    font-size: 13px;
  }
  .empty-leads .icon { font-size: 32px; margin-bottom: 10px; }

  /* ── Modal ── */
  .overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20,10,40,.55);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
  }
  .overlay.show { display: flex; }
  .modal {
    background: white;
    border-radius: 20px;
    padding: 28px 24px;
    max-width: 360px;
    width: 100%;
    box-shadow: 0 24px 60px rgba(108,62,255,.25);
    animation: modalIn .3s cubic-bezier(.34,1.56,.64,1);
  }
  @keyframes modalIn { from{opacity:0;transform:scale(.88) translateY(16px)} to{opacity:1;transform:scale(1) translateY(0)} }
  .modal-icon { font-size: 40px; margin-bottom: 14px; }
  .modal h2 { font-family: 'Syne', sans-serif; font-size: 20px; font-weight: 800; color: var(--text); margin-bottom: 6px; }
  .modal p { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 20px; }
  .cal-btn {
    display: block;
    text-align: center;
    background: var(--brand);
    color: white;
    text-decoration: none;
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    font-size: 14px;
    padding: 13px;
    border-radius: 12px;
    transition: background .2s;
    margin-bottom: 10px;
  }
  .cal-btn:hover { background: var(--brand-dark); }
  .modal-close {
    display: block;
    text-align: center;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
    padding: 6px;
  }
  .modal-close:hover { color: var(--text); }

  /* ── Setup Banner ── */
  .setup-banner {
    background: #FFF8F0;
    border: 1px solid #FFD6B3;
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 12.5px;
    color: #7A4A00;
    line-height: 1.6;
    max-width: 520px;
    width: 100%;
    margin-bottom: 16px;
  }
  .setup-banner strong { color: #CC6600; }

  /* ── Sheets toast ── */
  .toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--text);
    color: white;
    font-size: 13px;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(0,0,0,.2);
    transition: transform .3s cubic-bezier(.34,1.2,.64,1);
    z-index: 300;
    white-space: nowrap;
  }
  .toast.show { transform: translateX(-50%) translateY(0); }

  @media (max-width: 420px) {
    .row2 { grid-template-columns: 1fr; }
  }