:root {
    --primary: #2f5bea;
    --primary-dark: #2448c2;
    --bg: #f3f5f9;
    --card: #ffffff;
    --text: #1d2433;
    --muted: #6b7489;
    --border: #e2e6ee;
    --danger: #d93a3a;
    --radius: 12px;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, Segoe UI, sans-serif;
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
h1 { margin: 0 0 4px; font-size: 24px; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(16, 24, 40, .04);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 18px; border-radius: 8px; border: 1px solid transparent;
    font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
    transition: background .15s, border-color .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-light { background: #fff; color: var(--text); border-color: var(--border); }
.btn-light:hover { background: #f6f7fb; }
.btn-danger { background: #fff; color: var(--danger); border-color: #f2c6c6; }
.btn-danger:hover { background: #fdf0f0; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.icon-btn { background: none; border: 0; cursor: pointer; font-size: 16px; opacity: .55; }
.icon-btn:hover { opacity: 1; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; flex: 1; min-width: 0; }
.field label, .f-item label {
    display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #3a4357;
}
.field label span { color: var(--danger); }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=date], select {
    width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px;
    font: inherit; font-size: 14px; background: #fff; color: var(--text);
}
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 91, 234, .15); }
.row { display: flex; gap: 16px; }
.hp { position: absolute; left: -9999px; height: 0; width: 0; opacity: 0; }

.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }
.alert-success { background: #e9f8ef; color: #17693a; border: 1px solid #bfe8cf; }
.alert-error { background: #fdeeee; color: #a42626; border: 1px solid #f3c5c5; }

/* ---------- Client pages ---------- */
.client-body { background: linear-gradient(135deg, #eef2ff 0%, #f6f8fc 60%); min-height: 100vh; }
.client-wrap { display: flex; justify-content: center; align-items: flex-start; padding: 48px 16px; }
.form-card { width: 100%; max-width: 560px; padding: 32px; }
.form-card.narrow { max-width: 420px; }
.form-card > .muted { margin: 0 0 24px; }

/* ---------- Admin layout ---------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
    background: #fff; border-bottom: 1px solid var(--border); padding: 14px 28px;
    position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a { padding: 8px 14px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 14px; }
.topbar nav a:hover { background: #f3f5f9; color: var(--text); }
.topbar nav a.active { background: #eaf0ff; color: var(--primary); }
.topbar nav a.logout { color: var(--danger); }

.admin-wrap { max-width: 1400px; margin: 0 auto; padding: 28px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 0; }
.head-actions { display: flex; gap: 8px; }
.admin-form { max-width: 720px; }

/* ---------- Status colours ---------- */
.st-new        { --st: #2f5bea; --st-bg: #eaf0ff; }
.st-in_process { --st: #b7791f; --st-bg: #fdf4e3; }
.st-visit      { --st: #7a3fd1; --st-bg: #f3ecfd; }
.st-converted  { --st: #1f8a4c; --st-bg: #e7f7ee; }
.st-fake       { --st: #c53030; --st-bg: #fdecec; }

.status-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.status-tabs .tab {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--border);
    color: var(--text); font-weight: 600; font-size: 13px;
}
.status-tabs .tab .count {
    background: var(--st-bg, #eef0f4); color: var(--st, var(--muted));
    padding: 1px 8px; border-radius: 999px; font-size: 12px;
}
.status-tabs .tab:hover { border-color: var(--st, var(--primary)); }
.status-tabs .tab.active { background: var(--st, var(--primary)); border-color: var(--st, var(--primary)); color: #fff; }
.status-tabs .tab.active .count { background: rgba(255, 255, 255, .25); color: #fff; }

.status-select {
    width: auto; min-width: 150px; padding: 7px 10px; font-weight: 600; font-size: 13px;
    color: var(--st); background: var(--st-bg); border-color: transparent; cursor: pointer;
}

/* ---------- Filters ---------- */
.filters, .inline-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filters { padding: 16px; margin-bottom: 16px; }
.f-item { min-width: 140px; }
.f-item.grow { flex: 1; min-width: 200px; }
.f-btns { display: flex; gap: 8px; }
.inline-form input[type=text] { width: auto; flex: 1; min-width: 160px; }

.add-box { display: none; padding: 16px; margin-bottom: 16px; }
.add-box.open { display: block; }

/* ---------- Table ---------- */
.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
.leads-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.leads-table th {
    text-align: left; padding: 12px 14px; background: #f8f9fc; color: var(--muted);
    font-size: 12px; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.leads-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.leads-table tr:last-child td { border-bottom: 0; }
.leads-table tbody tr:hover { background: #fafbfe; }
.leads-table .empty { text-align: center; padding: 40px; color: var(--muted); }
.leads-table .actions { display: flex; gap: 6px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.src-general { background: #eef0f4; color: #4a5468; }
.src-project { background: #e7f2fd; color: #1d5fa8; }
.src-admin   { background: #fff2e5; color: #a3570f; }
.badge-btn { border: 0; cursor: pointer; padding: 4px 12px; border-radius: 999px; font: inherit; font-size: 12px; font-weight: 600; }
.badge-btn.on  { background: #e7f7ee; color: #1f8a4c; }
.badge-btn.off { background: #eef0f4; color: var(--muted); }

.pagination { display: flex; gap: 6px; padding: 14px; justify-content: center; flex-wrap: wrap; border-top: 1px solid var(--border); }
.pagination a { min-width: 34px; text-align: center; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border); color: var(--text); font-size: 13px; }
.pagination a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Toast ---------- */
.toast {
    position: fixed; bottom: 24px; right: 24px; background: #1d2433; color: #fff;
    padding: 12px 18px; border-radius: 8px; font-size: 14px; font-weight: 500;
    opacity: 0; transform: translateY(10px); transition: all .2s; pointer-events: none; z-index: 100;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
    .row { flex-direction: column; gap: 0; }
    .form-card { padding: 22px 18px; }
    .client-wrap { padding: 24px 12px; }
    .topbar { padding: 12px 16px; }
    .admin-wrap { padding: 16px; }
    .f-item, .f-item.grow { min-width: 100%; }
    .head-actions { width: 100%; }
    .head-actions .btn { flex: 1; }
}
