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

:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --border: #e4e2db;
  --text: #1a1917;
  --muted: #7a7870;
  --accent: #2563eb;
  --accent-light: #eff4ff;
  --hot: #dc2626;
  --hot-bg: #fef2f2;
  --cold: #0891b2;
  --cold-bg: #ecfeff;
  --sent: #16a34a;
  --sent-bg: #f0fdf4;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ── Layout ───────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-logo {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-logo .dot {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
}

.topbar-meta {
  font-size: 13px;
  color: var(--muted);
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ── Stat Cards ───────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
}

.stat-card .label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.stat-card.hot .value { color: var(--hot); }
.stat-card.cold .value { color: var(--cold); }

/* ── Filter Bar ───────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.filter-bar span {
  font-size: 13px;
  color: var(--muted);
  margin-right: 4px;
}

.filter-btn {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}

.filter-btn:hover { border-color: #b0aaa0; color: var(--text); }
.filter-btn.active { background: var(--text); color: #fff; border-color: var(--text); }

/* ── Lead List ────────────────────────────────────────────── */
.leads-list { display: flex; flex-direction: column; gap: 8px; }

/* Outer wrapper holds the card link + actions row */
.lead-card-outer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow .15s, border-color .15s;
  overflow: hidden;
}

.lead-card-outer:hover {
  box-shadow: var(--shadow-md);
  border-color: #ccc9c0;
}

.lead-card-outer.sent { opacity: .6; }

/* The clickable card row */
.lead-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 20px;
  text-decoration: none;
  color: inherit;
}

/* Actions row (Regenerate Draft button) */
.lead-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px 10px;
  border-top: 1px solid var(--border);
  background: #fafaf8;
}

.lead-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lead-main { flex: 1; min-width: 0; }

.lead-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 3px;
}

.lead-sender {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.tag.hot { background: var(--hot-bg); color: var(--hot); }
.tag.cold { background: var(--cold-bg); color: var(--cold); }
.tag.sent { background: var(--sent-bg); color: var(--sent); }

.tag .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.lead-subject {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lead-snippet {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lead-reason {
  font-style: italic;
}

.lead-time {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ── Send panel ───────────────────────────────────────────── */
.send-divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0 16px;
}

.send-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: var(--radius);
  padding: 14px 18px;
}

.send-panel-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.send-panel-text span { color: var(--muted); }
.send-panel-text em   { font-style: normal; font-weight: 600; color: var(--text); }

.btn-send {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 20px;
  border-radius: var(--radius);
  border: none;
  background: var(--sent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.btn-send:hover  { background: #15803d; }
.btn-send:active { transform: scale(.97); }

/* Sent state — read-only draft body */
.draft-sent-body {
  font-size: 14px;
  line-height: 1.75;
  color: #444;
  white-space: pre-wrap;
  background: #fafaf8;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.sent-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--sent);
}

/* ── Detail Page ──────────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
  transition: color .15s;
}
.back-link:hover { color: var(--text); }
.back-link::before { content: "←"; }

.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.detail-subject {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.detail-from {
  font-size: 13px;
  color: var(--muted);
}

.detail-body {
  font-size: 14px;
  line-height: 1.75;
  color: #333;
  white-space: pre-wrap;
}

.section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 12px;
}

textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  resize: vertical;
  transition: border-color .15s;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: #1d4ed8; }

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover { border-color: #999; background: var(--bg); }

.btn-danger {
  background: var(--hot-bg);
  color: var(--hot);
  border-color: #fca5a5;
}
.btn-danger:hover { background: #fee2e2; }

.btn-success {
  background: var(--sent-bg);
  color: var(--sent);
  border-color: #86efac;
}
.btn-success:hover { background: #dcfce7; }

.actions-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.status-form { display: inline; }

/* ── Empty state ──────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 64px 24px;
  color: var(--muted);
}
.empty .icon { font-size: 40px; margin-bottom: 12px; }
.empty p { font-size: 15px; }

/* ── Regenerate Draft button ──────────────────────────────── */
.btn-regen {
  padding: 5px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all .15s;
}
.btn-regen:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

/* ── Sync button ──────────────────────────────────────────── */
.btn-sync {
  padding: 6px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all .15s;
}
.btn-sync:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Flash messages ───────────────────────────────────────── */
.flash {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.flash-success { background: var(--sent-bg);  color: var(--sent); border-color: #86efac; }
.flash-error   { background: var(--hot-bg);   color: var(--hot);  border-color: #fca5a5; }
.flash-info    { background: var(--cold-bg);  color: var(--cold); border-color: #67e8f9; }

/* ── Topbar divider ───────────────────────────────────────── */
.topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 2px;
}

/* ── Outlook sync button ──────────────────────────────────── */
.btn-sync-outlook {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid #0078d4;
  background: #e8f3fc;
  font-size: 13px;
  font-weight: 600;
  color: #0078d4;
  cursor: pointer;
  transition: all .15s;
}
.btn-sync-outlook:hover { background: #d0e8f8; }

/* ── Connect Outlook button ───────────────────────────────── */
.btn-connect-ms {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.btn-connect-ms:hover { border-color: #0078d4; color: #0078d4; background: #e8f3fc; }

/* ── Source badge (Gmail / Outlook) ───────────────────────── */
.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  letter-spacing: 0.01em;
}
.source-badge.gmail   { background: #fce8e6; color: #c5221f; }
.source-badge.outlook { background: #e8f3fc; color: #0078d4; }

/* ── Microsoft connect page ───────────────────────────────── */
.connect-step {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.step-num {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.callback-box {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 8px 0 6px;
  word-break: break-all;
  color: var(--text);
  user-select: all;
}

.secret-name {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  color: var(--text);
}

.btn-ms-connect {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: 1px solid #0078d4;
  background: #0078d4;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  text-decoration: none;
}
.btn-ms-connect:hover { background: #006abc; }

/* ── Send panel source label ──────────────────────────────── */
.send-panel-source {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
  color: #0078d4;
}

/* ── Logout button ────────────────────────────────────────── */
.btn-logout {
  padding: 5px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.btn-logout:hover { color: var(--hot); border-color: #fca5a5; background: var(--hot-bg); }

/* ── Sent stat card ───────────────────────────────────────── */
.stat-card.sent-card .value { color: var(--sent); }

/* ── Login page ───────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-wrap {
  width: 100%;
  max-width: 360px;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 32px 32px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.login-dot {
  width: 9px; height: 9px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
}

.login-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
}

.login-field {
  margin-bottom: 16px;
}

.login-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.login-field input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  transition: border-color .15s;
}

.login-field input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.btn-login {
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.btn-login:hover { background: #1d4ed8; }

/* ── Login switch link ────────────────────────────────────── */
.login-switch {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.login-switch a {
  color: var(--accent);
  font-weight: 500;
}
.login-switch a:hover { text-decoration: underline; }

/* ── Home / Landing page ──────────────────────────────────── */
.home-page {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.home-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.home-nav-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.home-nav-logo {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.home-nav-dot {
  width: 9px; height: 9px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
}

.btn-nav-login {
  padding: 6px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all .15s;
}
.btn-nav-login:hover { border-color: #999; background: var(--surface); }

.home-hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 24px 80px;
}

.home-hero-inner {
  max-width: 580px;
  width: 100%;
  text-align: center;
}

.home-pill {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-bottom: 28px;
}

.home-headline {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.12;
  color: var(--text);
  margin-bottom: 20px;
}

.home-sub {
  font-size: 16px;
  color: var(--muted);
  line-height: 1.65;
  max-width: 460px;
  margin: 0 auto 36px;
}

.home-cta-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 48px;
  flex-wrap: wrap;
}

.home-btn-primary {
  padding: 12px 28px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.home-btn-primary:hover  { background: #1d4ed8; }
.home-btn-primary:active { transform: scale(.97); }

.home-btn-secondary {
  padding: 12px 28px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  transition: all .15s;
  white-space: nowrap;
}
.home-btn-secondary:hover { border-color: #999; background: var(--surface); }

.home-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  max-width: 360px;
  margin: 0 auto;
}

.home-features li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.home-features li strong { color: var(--text); }

.home-feat-icon {
  color: var(--accent);
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .container { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
  .detail-card { padding: 20px 18px; }
}
