:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e2e4e9;
  --text: #1c1f26;
  --text-muted: #6b7280;
  --accent: #2952e3;
  --accent-hover: #1e3fc4;
  --danger: #d64545;
  --success: #1f9d55;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* Top navigation */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand {
  font-weight: 700;
  color: var(--text);
  font-size: 16px;
}
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 14px;
}
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { color: var(--accent); background: #eaefff; }
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--text-muted); }

/* Login page */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px;
  width: 100%;
  max-width: 360px;
}
.login-card h1 { font-size: 20px; margin: 0 0 24px; text-align: center; }

/* Cards / surfaces */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

h1.page-title { font-size: 22px; margin: 0 0 20px; }
h2.section-title { font-size: 16px; margin: 0 0 14px; }

/* Forms */
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=email], input[type=tel], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(41, 82, 227, 0.12);
}
.field { margin-bottom: 16px; }
textarea { resize: vertical; min-height: 70px; }

.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #b83a3a; border-color: #b83a3a; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-link { color: var(--text-muted); font-weight: 500; }

/* Table */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--text-muted); font-weight: 600; font-size: 13px; }
tr.lead-row { cursor: pointer; }
tr.lead-row:hover { background: var(--bg); }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-new { background: #e0e9ff; color: #2952e3; }
.badge-progress { background: #fff2d6; color: #b9720c; }
.badge-closed { background: #dff5e4; color: #1f9d55; }

/* Filters bar */
.filters { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filters .field { margin-bottom: 0; }
.filters form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }
.alert-success { background: #dff5e4; color: #1a7a42; }
.alert-error { background: #fbe4e4; color: #a83232; }

/* Lead detail */
.lead-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
@media (max-width: 800px) { .lead-grid { grid-template-columns: 1fr; } }
.kv-row { display: flex; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv-row:last-child { border-bottom: none; }
.kv-key { width: 160px; color: var(--text-muted); flex-shrink: 0; }
.kv-val { word-break: break-word; }

.timeline-item { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.timeline-item:last-child { border-bottom: none; }
.timeline-meta { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

.note-item { background: var(--bg); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; font-size: 14px; }
.note-meta { color: var(--text-muted); font-size: 12px; margin-bottom: 4px; }

.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }

.webhook-box {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
  margin: 8px 0 16px;
}
