:root {
  --bg: #f6f4f2;
  --card: #ffffff;
  --text: #1f1d1b;
  --muted: #77706a;
  --line: #e7e2dd;
  --accent: #b5577a;
  --accent-2: #8f3f5d;
  --accent-soft: #f3e6ec;
  --danger: #c0392b;
  --radius: 12px;
}

* { box-sizing: border-box; }

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

a { color: var(--accent-2); }
h1, h2, h3 { margin: 0 0 12px; }
h2 { font-size: 22px; }
h3 { font-size: 16px; }

main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }

/* top bar */
.top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; color: var(--accent-2); font-size: 17px; }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.top nav a { padding: 6px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.top nav a.on { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
.me { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.pill { background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 7px; font-size: 12px; margin-left: 4px; }

/* cards & layout */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.detail { display: grid; grid-template-columns: 1fr 1.1fr; gap: 16px; align-items: start; }
@media (max-width: 800px) { .detail { grid-template-columns: 1fr; } }

.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { color: var(--muted); padding: 28px; text-align: center; }
.hidden { display: none !important; }

/* lead card */
.lead { display: block; text-decoration: none; color: inherit; transition: border-color .15s; }
.lead:hover { border-color: var(--accent); }
.lead .muted { margin-top: 4px; }
.meta { color: var(--muted); font-size: 13px; margin-top: 8px; }

.badge {
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: #eee; color: #555; white-space: nowrap;
}
.s-new { background: #fde8f0; color: #a3284f; }
.s-contacted { background: #e6effc; color: #2a56a3; }
.s-no_answer { background: #fdf3dc; color: #8a5a00; }
.s-booked { background: #e5f5ea; color: #23703f; }
.s-visited { background: #e4f5f4; color: #17706a; }
.s-lost { background: #eeeeee; color: #666; }
.badge.red { background: #fbe3e0; color: var(--danger); }

.tag {
  font-size: 12px; background: #f1eeeb; color: var(--muted);
  padding: 2px 7px; border-radius: 6px; margin-right: 6px; white-space: nowrap;
}

/* toolbar & tabs */
.toolbar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar-right { display: flex; gap: 8px; flex: 1; justify-content: flex-end; flex-wrap: wrap; }
.search { max-width: 360px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { padding: 6px 12px; border-radius: 999px; font-size: 14px; }
.tab.on { background: var(--accent-2); color: #fff; border-color: var(--accent-2); }
.tab span { opacity: .75; margin-left: 4px; }

/* forms */
input, select, textarea {
  font: inherit; width: 100%; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text);
}
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; margin-bottom: 12px; }
.form-grid button { align-self: end; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.inline input { flex: 1 1 160px; width: auto; }
form.stack { display: flex; flex-direction: column; gap: 10px; }

button, .btn {
  font: inherit; border-radius: 8px; border: 1px solid var(--line); background: var(--card);
  padding: 9px 14px; cursor: pointer; color: var(--text); text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { border-color: var(--accent); }
button.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
button.primary:hover { background: #7a3350; }
button.ghost { background: transparent; }
button.danger { color: var(--danger); border-color: #f0c4bf; }
button.small { padding: 5px 10px; font-size: 13px; }

/* lead detail */
.back { display: inline-block; margin-bottom: 12px; text-decoration: none; color: var(--muted); }
.contact { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.facts { display: grid; gap: 8px; margin: 14px 0; }
.facts > div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; word-break: break-word; }
details { margin: 10px 0; }
summary { cursor: pointer; color: var(--accent-2); margin-bottom: 10px; }
.danger-zone { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }

.timeline, .list { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .body { white-space: pre-wrap; margin-top: 4px; }

.rem { padding: 12px 0; border-bottom: 1px solid var(--line); }
.rem:last-child { border-bottom: 0; }
.rem.due strong { color: var(--danger); }
.rem.done { opacity: .55; }
.actions-row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* lists on reminders page */
.rem-card p { margin: 6px 0; }
.rem-card .actions-row { margin-top: 10px; }
.group-title { margin: 22px 0 10px; color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: .04em; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; }
td input[type=password] { width: 170px; }
td select { width: auto; }

/* settings */
.checks { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin: 12px 0 16px; }
.check { flex-direction: row; align-items: center; color: var(--text); font-size: 15px; }
.check input { width: auto; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; }
.login h1 { color: var(--accent-2); }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 14px; }

/* modal & toast */
.modal { border: none; border-radius: 14px; padding: 22px; width: min(440px, calc(100% - 32px)); }
.modal::backdrop { background: rgba(0, 0, 0, .35); }
.modal form { display: flex; flex-direction: column; gap: 12px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: #2b2624; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px;
  z-index: 50; box-shadow: 0 6px 24px rgba(0, 0, 0, .2); max-width: calc(100% - 32px);
}
.toast.err { background: var(--danger); }

@media (max-width: 600px) {
  main { padding: 14px 12px 60px; }
  .search { max-width: none; }
  .toolbar-right { justify-content: stretch; }
  .toolbar-right > * { flex: 1 1 100%; }
}
