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

:root {
  --bg: #0D0B0E;
  --surface: #161318;
  --surface-2: #1C1820;
  --amber: #E8A84C;
  --amber-dim: #E8A84C44;
  --amber-glow: #E8A84C22;
  --warm: #F5E6D0;
  --muted: #9B8F9E;
  --white: #FAF7F5;
  --border: #2A2530;
  --hot: #E85C4C;
  --hot-bg: #E85C4C18;
  --warm-color: #E8A84C;
  --warm-bg: #E8A84C18;
  --cold: #4C8CE8;
  --cold-bg: #4C8CE818;
  --success: #4CE88A;
  --danger: #E85C4C;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--white);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.grain {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  z-index: 9999;
}

/* ===== TOP BAR ===== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.topbar-logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 20px;
  color: var(--amber);
  text-decoration: none;
}

.topbar-nav {
  display: flex;
  gap: 4px;
}

.topbar-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 100px;
  transition: all 0.2s;
}

.topbar-nav a:hover,
.topbar-nav a.active {
  color: var(--white);
  background: var(--surface);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.btn-logout {
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  color: var(--white);
  border-color: var(--muted);
}

/* ===== MAIN CONTENT ===== */
.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px;
}

/* ===== AUTH VIEWS ===== */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80vh;
  padding: 32px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px;
  width: 100%;
  max-width: 420px;
}

.auth-card .logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 28px;
  color: var(--amber);
  text-align: center;
  margin-bottom: 8px;
}

.auth-card .subtitle {
  font-size: 15px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--white);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--amber);
}

.form-group input::placeholder {
  color: #4A4250;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--amber);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.auth-toggle {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--muted);
}

.auth-toggle a {
  color: var(--amber);
  text-decoration: none;
  font-weight: 500;
}

.auth-toggle a:hover {
  text-decoration: underline;
}

.auth-error {
  background: var(--hot-bg);
  color: var(--hot);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}

/* ===== STATS BAR ===== */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  transition: border-color 0.2s;
}

.stat-card:hover {
  border-color: var(--amber-dim);
}

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

.stat-value {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 32px;
  letter-spacing: -1px;
}

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

/* ===== SECTION HEADER ===== */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 20px;
  color: var(--white);
}

.section-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ===== FILTER BAR ===== */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-pill {
  padding: 7px 16px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-pill:hover {
  border-color: var(--muted);
  color: var(--white);
}

.filter-pill.active {
  background: var(--amber);
  color: var(--bg);
  border-color: var(--amber);
}

.search-input {
  padding: 7px 16px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--white);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  outline: none;
  width: 200px;
  margin-left: auto;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--amber);
}

.search-input::placeholder {
  color: #4A4250;
}

/* ===== CONTACT LIST ===== */
.contact-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.contact-card {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 16px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.contact-card:hover {
  border-color: var(--amber-dim);
  transform: translateY(-1px);
}

.warmth-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.warmth-dot.hot { background: var(--hot); box-shadow: 0 0 8px var(--hot); }
.warmth-dot.warm { background: var(--warm-color); box-shadow: 0 0 8px var(--warm-color); }
.warmth-dot.cold { background: var(--cold); box-shadow: 0 0 8px var(--cold); }

.contact-info h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 3px;
}

.contact-info p {
  font-size: 13px;
  color: var(--muted);
}

.contact-meta {
  text-align: right;
}

.contact-meta .time {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.contact-meta .count {
  font-size: 12px;
  color: #4A4250;
  margin-top: 2px;
}

.warmth-badge {
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.warmth-badge.hot { background: var(--hot-bg); color: var(--hot); }
.warmth-badge.warm { background: var(--warm-bg); color: var(--warm-color); }
.warmth-badge.cold { background: var(--cold-bg); color: var(--cold); }

/* ===== CONTACT DETAIL ===== */
.detail-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  justify-content: flex-end;
}

.detail-panel {
  width: 560px;
  max-width: 100%;
  background: var(--bg);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  animation: slideIn 0.25s ease-out;
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

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

.detail-header-info h2 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 24px;
  margin-bottom: 4px;
}

.detail-header-info p {
  font-size: 14px;
  color: var(--muted);
}

.btn-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.btn-close:hover {
  color: var(--white);
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
}

.detail-stat {
  text-align: center;
}

.detail-stat .value {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--white);
}

.detail-stat .label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* Follow-up section in detail */
.detail-section {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
}

.detail-section-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--warm);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-generate {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--amber);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-generate:hover {
  opacity: 0.9;
}

.btn-generate:disabled {
  opacity: 0.5;
  cursor: wait;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  color: var(--white);
  border-color: var(--muted);
}

.followup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 12px;
}

.followup-subject {
  font-weight: 600;
  font-size: 14px;
  color: var(--warm);
  margin-bottom: 8px;
}

.followup-message {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
  white-space: pre-wrap;
}

.followup-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.btn-copy {
  padding: 6px 14px;
  background: var(--surface-2);
  color: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-copy:hover {
  border-color: var(--amber);
}

.btn-dismiss {
  padding: 6px 14px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-dismiss:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* Interaction timeline */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.timeline-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.timeline-direction {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  align-self: flex-start;
  margin-top: 2px;
}

.timeline-direction.sent {
  background: var(--amber-glow);
  color: var(--amber);
}

.timeline-direction.received {
  background: var(--cold-bg);
  color: var(--cold);
}

.timeline-content {
  flex: 1;
  min-width: 0;
}

.timeline-subject {
  font-size: 14px;
  font-weight: 500;
  color: var(--white);
  margin-bottom: 3px;
}

.timeline-snippet {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.timeline-date {
  font-size: 12px;
  color: #4A4250;
  white-space: nowrap;
  align-self: flex-start;
  margin-top: 2px;
}

/* ===== SETTINGS PAGE ===== */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 24px;
}

.settings-section h3 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 18px;
  color: var(--white);
  margin-bottom: 8px;
}

.settings-section p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 16px;
}

.gmail-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.gmail-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.gmail-status .dot.connected { background: var(--success); }
.gmail-status .dot.disconnected { background: var(--muted); }

.gmail-status span {
  font-size: 14px;
  color: var(--white);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 32px;
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--white);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 15px;
  color: var(--muted);
  max-width: 400px;
  margin: 0 auto 24px;
  line-height: 1.6;
}

.btn-demo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--amber);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-demo:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* ===== LOADING ===== */
.loading {
  display: flex;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--white);
  font-size: 14px;
  z-index: 9000;
  animation: fadeUp 0.3s ease-out;
  max-width: 360px;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== TONE SELECTOR ===== */
.tone-selector {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.tone-pill {
  padding: 5px 12px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.tone-pill:hover { color: var(--white); border-color: var(--muted); }
.tone-pill.active { background: var(--amber); color: var(--bg); border-color: var(--amber); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .topbar {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .topbar-nav { gap: 2px; }
  .topbar-right { display: none; }

  .main { padding: 20px 16px; }

  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .contact-card {
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    padding: 14px 16px;
  }

  .contact-card .warmth-badge { display: none; }

  .detail-panel { width: 100%; }

  .detail-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 16px 20px;
  }

  .filter-bar { gap: 6px; }
  .search-input { width: 100%; margin-left: 0; }

  .auth-card { padding: 32px 24px; }
}
