:root {
  --bg: #f5f1e8;
  --panel: #fffdf7;
  --line: #ded4c2;
  --ink: #1e2a2f;
  --muted: #5c6a70;
  --accent: #0f766e;
  --warn: #b45309;
  --ok: #166534;
  --error: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 20% 0%, #fff8df, var(--bg) 55%);
  color: var(--ink);
}

.topbar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #fff8ea;
}

h1, h2, h3 {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.actions-inline {
  display: flex;
  gap: 8px;
}

button {
  border: 1px solid #1f4d47;
  background: var(--accent);
  color: white;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.95);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  padding: 12px 20px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.stat span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.stat strong {
  font-size: 22px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(330px, 440px) 1fr;
  gap: 12px;
  padding: 0 20px 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  min-height: 68vh;
}

.filters, .bulk-controls, .grid-2, .grid-3 {
  display: grid;
  gap: 8px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  font-size: 12px;
  color: var(--muted);
  display: grid;
  gap: 4px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid #b8b09f;
  border-radius: 8px;
  padding: 8px;
  font-size: 14px;
  background: #fffefb;
  color: var(--ink);
}

textarea {
  min-height: 160px;
  resize: vertical;
}

.lead-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  max-height: 48vh;
  overflow: auto;
}

.lead-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: start;
  cursor: pointer;
  background: #fffdf8;
}

.lead-card.active {
  border-color: var(--accent);
  background: #edf8f7;
}

.lead-company {
  font-size: 14px;
}

.lead-job, .lead-meta {
  margin: 3px 0;
  font-size: 12px;
  color: var(--muted);
}

.badge {
  font-size: 11px;
  border-radius: 999px;
  padding: 4px 8px;
  border: 1px solid #9ca3af;
  text-transform: none;
  background: #f3f4f6;
}

.muted {
  color: var(--muted);
}

.warn-box {
  border: 1px solid #f59e0b;
  color: #92400e;
  background: #fffbeb;
  padding: 10px;
  border-radius: 8px;
}

.error-box {
  border: 1px solid #ef4444;
  color: #991b1b;
  background: #fef2f2;
  padding: 10px;
  border-radius: 8px;
}

.log {
  background: #0f172a;
  color: #cbd5e1;
  padding: 10px;
  border-radius: 8px;
  max-height: 120px;
  overflow: auto;
  font-size: 12px;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffefb;
  padding: 10px;
}

.history-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.history-head span {
  color: var(--muted);
  font-size: 12px;
}

.history-meta {
  margin: 6px 0;
  color: var(--muted);
  font-size: 12px;
}

.history-body {
  white-space: pre-wrap;
  background: #f7f4ed;
  border: 1px solid #e6dcc8;
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
}

.history-reply {
  margin-top: 8px;
  border-left: 3px solid var(--accent);
  padding-left: 8px;
}

.history-reply-head {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
}

.history-compose {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.history-compose textarea {
  min-height: 88px;
}

.history-compose-actions {
  display: flex;
  justify-content: flex-end;
}

.history-followup-row {
  display: grid;
  grid-template-columns: minmax(180px, 220px) 1fr auto;
  gap: 8px;
  align-items: center;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .lead-list {
    max-height: 38vh;
  }
}
