/* ------------------------------------------------------------------ */
/* LeadGen Pro — design system                                          */
/* Matte gray surfaces, orange-brown accent, flat & quiet.              */
/* ------------------------------------------------------------------ */

:root {
    /* Surfaces */
    --bg: #161618;
    --panel: #1e1e21;
    --panel-raised: #242428;
    --field: #1a1a1d;
    --border: #2e2e33;
    --border-strong: #3a3a40;

    /* Text */
    --text-primary: #ececea;
    --text-secondary: #9c9c99;
    --text-faint: #6f6f6c;

    /* Accent */
    --accent: #b45a25;
    --accent-hover: #c96a30;
    --accent-active: #9a4a1d;
    --accent-tint: rgba(180, 90, 37, 0.12);
    --accent-text: #d98b57;

    /* Status */
    --error: #c25e5e;
    --error-tint: rgba(194, 94, 94, 0.1);
    --success: #7da57d;
    --success-tint: rgba(125, 165, 125, 0.1);

    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.5;
}

h1, h2, h3 {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-weight: 600;
    letter-spacing: -0.01em;
}

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

.hidden { display: none !important; }
.muted { color: var(--text-secondary); }

/* ------------------------------------------------------------------ */
/* Top navigation                                                       */
/* ------------------------------------------------------------------ */

.topnav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0 max(calc((100vw - 1040px) / 2), 1.25rem);
    height: 56px;
    background: rgba(22, 22, 24, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.topnav .brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
}

.topnav .brand svg { color: var(--accent-text); }

.topnav nav {
    display: flex;
    gap: 0.25rem;
}

.topnav nav a {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.topnav nav a:hover {
    color: var(--text-primary);
    background: var(--panel-raised);
    text-decoration: none;
}

.topnav nav a.active {
    color: var(--accent-text);
    background: var(--accent-tint);
}

/* ------------------------------------------------------------------ */
/* Layout                                                               */
/* ------------------------------------------------------------------ */

.page {
    max-width: 1040px;
    margin: 0 auto;
    padding: 1.75rem 1.25rem 4rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
}

.panel-title {
    font-size: 1.05rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-title .count { color: var(--accent-text); font-size: 0.88rem; font-weight: 500; }

.panel-sub {
    color: var(--text-secondary);
    font-size: 0.87rem;
    margin: -0.9rem 0 1.25rem;
}

.page-head { display: flex; flex-direction: column; gap: 0.2rem; }
.page-head h1 { font-size: 1.5rem; }
.page-head p { color: var(--text-secondary); font-size: 0.92rem; }

.row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.row-end { display: flex; align-items: end; gap: 0.9rem; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }

.divider { border: none; border-top: 1px dashed var(--border); margin: 1.25rem 0; }

/* ------------------------------------------------------------------ */
/* Buttons                                                              */
/* ------------------------------------------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    height: 40px;
    padding: 0 1.1rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 550;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn svg { flex-shrink: 0; }

.btn-primary { background: var(--accent); color: #f5ede5; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) { background: var(--accent-active); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-strong);
}
.btn-ghost:hover:not(:disabled) { color: var(--text-primary); border-color: var(--text-faint); }

.btn-danger {
    background: transparent;
    color: var(--error);
    border-color: rgba(194, 94, 94, 0.4);
}
.btn-danger:hover:not(:disabled) { background: var(--error-tint); border-color: var(--error); }

.btn-sm { height: 32px; padding: 0 0.8rem; font-size: 0.82rem; }

/* ------------------------------------------------------------------ */
/* Forms                                                                */
/* ------------------------------------------------------------------ */

.field { display: flex; flex-direction: column; gap: 0.4rem; }

.field label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

input, select, textarea {
    height: 40px;
    padding: 0 0.85rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--field);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.92rem;
    outline: none;
    transition: border-color 0.15s ease;
    width: 100%;
}

textarea {
    height: auto;
    padding: 0.65rem 0.85rem;
    resize: vertical;
    line-height: 1.55;
}

select option { background: var(--panel); color: var(--text-primary); }

input:focus, select:focus, textarea:focus { border-color: var(--accent); }

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

input::placeholder, textarea::placeholder { color: var(--text-faint); }

/* Search form grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    align-items: end;
}

.form-grid .submit-cell { display: flex; }
.form-grid .submit-cell .btn { width: 100%; }

/* ------------------------------------------------------------------ */
/* Source cards (radio)                                                 */
/* ------------------------------------------------------------------ */

.source-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.radio-card { position: relative; cursor: pointer; }
.radio-card input { position: absolute; opacity: 0; width: 0; height: 0; }

.radio-card .card-content {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.95rem 1.1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--panel-raised);
    transition: border-color 0.15s ease, background-color 0.15s ease;
    height: 100%;
}

.radio-card:hover .card-content { border-color: var(--border-strong); }

.radio-card input:checked ~ .card-content {
    border-color: var(--accent);
    background: var(--accent-tint);
}

.radio-card input:focus-visible ~ .card-content { border-color: var(--accent-hover); }

.radio-card .icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    background: var(--field);
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: color 0.15s ease;
}

.radio-card input:checked ~ .card-content .icon { color: var(--accent-text); }

.radio-card h3 { font-size: 0.92rem; font-weight: 600; }
.radio-card p { font-size: 0.78rem; color: var(--text-secondary); }

/* ------------------------------------------------------------------ */
/* Tables                                                               */
/* ------------------------------------------------------------------ */

.table-container {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

table { width: 100%; border-collapse: collapse; text-align: left; }

th, td { padding: 0.8rem 0.7rem; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { padding-left: 1rem; }
th:last-child, td:last-child { padding-right: 1rem; }

th {
    background: var(--panel-raised);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

td { font-size: 0.9rem; vertical-align: top; }

tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.015); }
tbody tr:hover td { background: var(--accent-tint); }

td .sub { font-size: 0.78rem; color: var(--text-secondary); margin-top: 0.1rem; }

/* ------------------------------------------------------------------ */
/* Badges & chips                                                       */
/* ------------------------------------------------------------------ */

.badge {
    display: inline-block;
    padding: 0.18rem 0.6rem;
    border-radius: 5px;
    background: var(--panel-raised);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 500;
    white-space: nowrap;
}

/* One chip per address, stacked. Addresses used to be joined into a single
   "a@x; b@y" blob that broke mid-word and was unreadable in a narrow column. */
.email-list {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
}

.email-badge {
    display: inline-block;
    max-width: 100%;
    padding: 0.18rem 0.6rem;
    border-radius: 5px;
    background: var(--accent-tint);
    border: 1px solid rgba(180, 90, 37, 0.3);
    color: var(--accent-text);
    font-size: 0.82rem;
    font-weight: 500;
    /* Break between the local part and the domain, not mid-word. */
    word-break: normal;
    overflow-wrap: anywhere;
    line-height: 1.45;
}

a.email-badge:hover {
    text-decoration: none;
    background: rgba(180, 90, 37, 0.22);
    border-color: var(--accent);
    color: var(--text-primary);
}

/* Emails are the point of the whole app — give the column real room, but not
   so much that the columns after it get pushed out of view. */
.col-emails { min-width: 12.5rem; width: 26%; }
.col-name { min-width: 8.5rem; width: 17%; }
.col-tight { white-space: nowrap; width: 1%; }

.status-ok { color: var(--success); font-size: 0.85rem; }
.status-bad { color: var(--error); font-size: 0.85rem; }
.status-dim { color: var(--text-secondary); font-size: 0.85rem; }

.stat-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1.25rem; }

.stat-chip {
    background: var(--panel-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 1rem;
    min-width: 110px;
}

.stat-chip .value { font-size: 1.25rem; font-weight: 650; font-family: 'Space Grotesk', sans-serif; }
.stat-chip .label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.1rem;
}

/* ------------------------------------------------------------------ */
/* Messages & states                                                    */
/* ------------------------------------------------------------------ */

.error-msg, .success-msg { padding: 0.8rem 1rem; border-radius: var(--radius); font-size: 0.9rem; margin-bottom: 1rem; }
.error-msg { background: var(--error-tint); border: 1px solid rgba(194, 94, 94, 0.3); color: var(--error); }
.success-msg { background: var(--success-tint); border: 1px solid rgba(125, 165, 125, 0.3); color: var(--success); }

.progress-line {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-bottom: 1rem;
}

.empty-state {
    text-align: center;
    padding: 2.75rem 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.empty-state svg { color: var(--text-faint); margin-bottom: 0.6rem; }

/* ------------------------------------------------------------------ */
/* Spinner                                                              */
/* ------------------------------------------------------------------ */

.spinner {
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    border-top-color: currentColor;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

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

/* ------------------------------------------------------------------ */
/* Draft cards (outreach)                                               */
/* ------------------------------------------------------------------ */

.drafts-list { display: flex; flex-direction: column; gap: 0.75rem; }

.draft-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    background: var(--panel-raised);
}

.draft-card .draft-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
}

.draft-card .draft-subject { margin-bottom: 0.5rem; }

.draft-card textarea { font-size: 0.88rem; background: var(--field); }

/* ------------------------------------------------------------------ */
/* Follow-up popup                                                      */
/* ------------------------------------------------------------------ */

.toast-panel {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    width: 330px;
    max-height: 60vh;
    overflow-y: auto;
    background: var(--panel-raised);
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-lg);
    padding: 1rem;
    z-index: 1000;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.toast-panel .toast-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.toast-panel .toast-head strong {
    color: var(--accent-text);
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.toast-panel .close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.2rem;
    line-height: 1;
}
.toast-panel .close-btn:hover { color: var(--text-primary); }

.followup-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 0.75rem;
    background: var(--panel);
    margin-bottom: 0.55rem;
}
.followup-item:last-child { margin-bottom: 0; }
.followup-item .who { font-weight: 600; font-size: 0.88rem; }
.followup-item .when { font-size: 0.78rem; color: var(--text-secondary); margin: 0.15rem 0 0.45rem; }

/* ------------------------------------------------------------------ */
/* Tabs & pagination                                                    */
/* ------------------------------------------------------------------ */

.tabs { display: flex; gap: 0.25rem; background: var(--field); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.25rem; width: fit-content; }

.tab {
    height: 32px;
    padding: 0 1rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 550;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.tab:hover { color: var(--text-primary); }
.tab.active { background: var(--panel-raised); color: var(--accent-text); }

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.pagination .pages { display: flex; align-items: center; gap: 0.6rem; }
.pagination span { color: var(--text-secondary); font-size: 0.85rem; }

/* Filters row on DB page */
.filters { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters input[type="text"], .filters input[type="search"] { flex: 1; min-width: 220px; }
.filters select { width: auto; min-width: 140px; }

/* ------------------------------------------------------------------ */
/* Responsive                                                           */
/* ------------------------------------------------------------------ */

@media (max-width: 860px) {
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .source-cards { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .form-grid { grid-template-columns: 1fr; }
    .panel { padding: 1.25rem; }
    .topnav { gap: 1rem; }
    .toast-panel { left: 1.25rem; width: auto; }
}

/* ------------------------------------------------------------------ */
/* Global job bar — running scrapes/sends, visible on every page        */
/* ------------------------------------------------------------------ */

.jobbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--panel-raised);
    border-bottom: 1px solid var(--border);
}

.jobbar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 2rem;
    font-size: 0.85rem;
}

.jobbar-row.error { background: var(--error-tint); }
.jobbar-row.done { background: var(--success-tint); }

.jobbar-text {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
    min-width: 0;
}

.jobbar-text strong { font-weight: 600; }
.jobbar-label { color: var(--text-secondary); }
.jobbar-detail { color: var(--accent-text); }

.jobbar-count {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    white-space: nowrap;
}

.jobbar-link {
    font-size: 0.8rem;
    padding: 0.15rem 0.6rem;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    white-space: nowrap;
}
.jobbar-link:hover { text-decoration: none; border-color: var(--accent); }

.jobbar-track { height: 2px; background: var(--border); }
.jobbar-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.4s ease;
}

@media (max-width: 640px) {
    .jobbar-row { padding: 0.6rem 1.25rem; }
    .jobbar-label { display: none; }
}
