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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --green: #10b981;
    --red: #ef4444;
    --yellow: #f59e0b;
    --blue: #3b82f6;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #0f172a;
    --border: rgba(255,255,255,.08);
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --radius: 12px;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); }

/* Login */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 3rem; text-align: center; width: 380px; }
.login-card h1 { font-size: 1.5rem; margin-bottom: .5rem; background: linear-gradient(135deg, #6366f1, #8b5cf6); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.login-card p { color: var(--text-muted); margin-bottom: 1.5rem; font-size: .9rem; }
.login-card input { width: 100%; padding: .75rem 1rem; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text); font-size: .95rem; margin-bottom: 1rem; }
.login-card button { width: 100%; padding: .75rem; background: var(--primary); color: #fff; border: none; border-radius: 8px; font-size: 1rem; font-weight: 600; cursor: pointer; }
.login-card button:hover { background: var(--primary-dark); }
.error { color: var(--red); font-size: .85rem; margin-top: .5rem; }

/* Topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem; height: 56px; background: var(--bg-card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.topbar-logo { font-weight: 700; font-size: 1.1rem; }
.topbar-logo span { color: var(--primary); font-weight: 400; }
.topbar-tabs { display: flex; gap: .25rem; }
.tab-btn { padding: .5rem 1rem; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: .85rem; border-radius: 6px; transition: all .2s; }
.tab-btn:hover { color: #fff; background: rgba(255,255,255,.05); }
.tab-btn.active { color: #fff; background: var(--primary); }
.logout-btn { background: none; border: 1px solid var(--border); color: var(--text-muted); padding: .4rem 1rem; border-radius: 6px; cursor: pointer; font-size: .8rem; }

/* Tabs */
.tab-content { display: none; padding: 1.5rem; max-width: 1400px; margin: 0 auto; }
.tab-content.active { display: block; }

/* Page header */
.page-header { margin-bottom: 1.5rem; }
.page-header h2 { font-size: 1.5rem; margin-bottom: .25rem; }
.page-header p { color: var(--text-muted); font-size: .9rem; }

/* Cards */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1rem; }
.card h3 { font-size: 1rem; margin-bottom: 1rem; color: var(--text-muted); }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.stat-card .stat-value { font-size: 2rem; font-weight: 800; }
.stat-card .stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }
.stat-card.purple .stat-value { color: var(--primary); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.blue .stat-value { color: var(--blue); }
.stat-card.yellow .stat-value { color: var(--yellow); }

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* Forms */
.form-row { display: flex; gap: 1rem; margin-bottom: 1rem; }
.form-group { flex: 1; margin-bottom: 1rem; }
.form-group label { display: block; font-size: .8rem; color: var(--text-muted); margin-bottom: .4rem; }
input[type="text"], input[type="number"], input[type="password"], select, textarea {
    width: 100%; padding: .6rem .8rem; border-radius: 8px; border: 1px solid var(--border);
    background: var(--bg-input); color: var(--text); font-size: .9rem; font-family: inherit;
}
textarea { resize: vertical; }
select { cursor: pointer; }

/* Categories grid */
.categories-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.cat-chip { padding: .4rem .8rem; border-radius: 8px; border: 1px solid var(--border); background: none; color: var(--text-muted); cursor: pointer; font-size: .8rem; transition: all .2s; }
.cat-chip:hover { border-color: var(--primary); color: var(--text); }
.cat-chip.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Buttons */
.btn { padding: .6rem 1.5rem; border: none; border-radius: 8px; font-size: .9rem; font-weight: 600; cursor: pointer; transition: all .2s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: none; border: 1px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--text-muted); color: var(--text); }
.btn-sm { padding: .3rem .8rem; font-size: .75rem; border-radius: 6px; }
.btn-xs { padding: .2rem .5rem; font-size: .7rem; border-radius: 4px; min-width: 24px; text-align: center; font-weight: 700; }
.btn-green { background: var(--green); color: #fff; }
.btn-red { background: var(--red); color: #fff; }

/* Table */
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--border); font-size: .85rem; }
th { color: var(--text-muted); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; }
tr:hover td { background: rgba(255,255,255,.02); }

/* Badges */
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 6px; font-size: .7rem; font-weight: 600; }
.badge-new { background: rgba(59,130,246,.15); color: var(--blue); }
.badge-sent { background: rgba(245,158,11,.15); color: var(--yellow); }
.badge-converted { background: rgba(16,185,129,.15); color: var(--green); }
.badge-unsub { background: rgba(239,68,68,.15); color: var(--red); }
.badge-running { background: rgba(99,102,241,.15); color: var(--primary); }
.badge-completed { background: rgba(16,185,129,.15); color: var(--green); }
.badge-draft { background: rgba(148,163,184,.15); color: var(--text-muted); }
.badge-failed { background: rgba(239,68,68,.15); color: var(--red); }

/* Progress bar */
.progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width .5s; }

/* Scan progress indicator */
.scan-progress {
    display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem;
    background: rgba(99,102,241,.1); border: 1px solid rgba(99,102,241,.3);
    border-radius: 8px; margin-bottom: 1rem; color: var(--primary); font-size: .85rem;
}
.scan-progress-bar {
    width: 20px; height: 20px; border: 3px solid rgba(99,102,241,.3);
    border-top-color: var(--primary); border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
tr.row-running { background: rgba(99,102,241,.05); }

/* Filters toolbar */
.leads-toolbar { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; gap: 1rem; flex-wrap: wrap; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { width: auto; min-width: 120px; padding: .4rem .6rem; font-size: .8rem; }
.checkbox-label { display: flex; align-items: center; gap: .3rem; font-size: .8rem; color: var(--text-muted); cursor: pointer; }

/* Pagination */
.pagination { display: flex; gap: .25rem; justify-content: center; margin-top: 1rem; }
.pagination button { padding: .3rem .7rem; border: 1px solid var(--border); background: none; color: var(--text-muted); border-radius: 6px; cursor: pointer; font-size: .8rem; }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal-content { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); width: 600px; max-width: 95vw; max-height: 85vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; }
.modal-body { padding: 1.5rem; }

/* Toast */
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--bg-card); border: 1px solid var(--green); color: var(--text); padding: .75rem 1.5rem; border-radius: 8px; z-index: 300; font-size: .9rem; animation: slideIn .3s; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Scan Log Panel */
.scan-log-panel {
    background: #0a0e1a; border: 1px solid var(--border); border-radius: var(--radius);
    margin-top: 1rem; overflow: hidden;
}
.scan-log-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: .6rem 1rem; background: rgba(99,102,241,.08);
    border-bottom: 1px solid var(--border); cursor: pointer;
}
.scan-log-header h4 { font-size: .85rem; color: var(--primary); margin: 0; }
.scan-log-header .scan-log-badge {
    font-size: .7rem; padding: .15rem .5rem; border-radius: 4px;
    background: rgba(99,102,241,.2); color: var(--primary);
}
.scan-log-body {
    max-height: 400px; overflow-y: auto; padding: .5rem 0;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace; font-size: .78rem; line-height: 1.6;
}
.scan-log-body::-webkit-scrollbar { width: 6px; }
.scan-log-body::-webkit-scrollbar-track { background: transparent; }
.scan-log-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.log-entry { padding: .15rem 1rem; display: flex; gap: .6rem; }
.log-entry:hover { background: rgba(255,255,255,.02); }
.log-time { color: var(--text-dim); min-width: 55px; }
.log-msg { word-break: break-word; }
.log-entry.info .log-msg { color: var(--text-muted); }
.log-entry.success .log-msg { color: var(--green); }
.log-entry.warn .log-msg { color: var(--yellow); }
.log-entry.error .log-msg { color: var(--red); }
.scan-log-progress {
    display: flex; align-items: center; gap: .5rem;
    padding: .4rem 1rem; font-size: .75rem; color: var(--text-muted);
    border-top: 1px solid var(--border);
}
.scan-log-progress .progress-bar { flex: 1; height: 4px; }

/* Quick-bot */
.quickbot-preview {
    background: rgba(16,185,129,.05); border: 1px solid rgba(16,185,129,.2);
    border-radius: var(--radius); padding: 1rem; margin-top: 1rem;
}
.quickbot-preview h4 { color: var(--green); margin-bottom: .75rem; font-size: .9rem; }
.quickbot-prompt {
    background: #0a0e1a; border-radius: 8px; padding: 1rem;
    font-family: monospace; font-size: .8rem; line-height: 1.5;
    color: var(--text-muted); white-space: pre-wrap; max-height: 300px; overflow-y: auto;
}
.btn-bot { background: linear-gradient(135deg, #10b981, #059669); color: #fff; }
.btn-bot:hover { background: linear-gradient(135deg, #059669, #047857); }

/* Analytics cards */
.analytics-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.25rem; margin-bottom: .75rem; transition: border-color .2s;
}
.analytics-card:hover { border-color: rgba(99,102,241,.4); }
.analytics-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: .75rem; }
.analytics-header h4 { font-size: 1rem; margin: 0; }
.analytics-header h4 a { color: var(--text); text-decoration: none; }
.analytics-header h4 a:hover { color: var(--primary); }
.analytics-conversion {
    font-size: 1.3rem; font-weight: 800; min-width: 50px; text-align: right;
}
.conv-high { color: var(--green); }
.conv-med { color: var(--yellow); }
.conv-low { color: var(--text-dim); }
.analytics-meta { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--text-muted); margin-bottom: .75rem; }
.analytics-meta span { display: flex; align-items: center; gap: .3rem; }
.analytics-bars { display: flex; gap: 1.5rem; margin-bottom: .75rem; }
.analytics-bar { flex: 1; }
.analytics-bar-label { font-size: .7rem; color: var(--text-dim); margin-bottom: .3rem; text-transform: uppercase; letter-spacing: .5px; }
.analytics-bar-track { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.analytics-bar-fill { height: 100%; border-radius: 3px; transition: width .5s; }
.analytics-issues { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .75rem; }
.issue-tag { font-size: .7rem; padding: .15rem .5rem; border-radius: 4px; background: rgba(239,68,68,.1); color: var(--red); }
.issue-tag.good { background: rgba(16,185,129,.1); color: var(--green); }
.analytics-pitch {
    font-size: .8rem; color: var(--text-muted); padding: .6rem .8rem;
    background: rgba(99,102,241,.05); border-radius: 6px; border-left: 3px solid var(--primary);
    margin-bottom: .75rem;
}
.analytics-actions { display: flex; gap: .5rem; }
.analytics-email-preview {
    margin-top: .75rem; padding: .75rem; background: #0a0e1a; border-radius: 8px;
    font-size: .8rem; line-height: 1.5; color: var(--text-muted); white-space: pre-wrap; display: none;
}

/* Guide Banner */
.guide-banner {
    background: var(--bg-card); border: 1px solid rgba(99,102,241,.25);
    border-radius: var(--radius); margin-bottom: 1rem; overflow: hidden;
}
.guide-header {
    display: flex; align-items: center; gap: .6rem; padding: .75rem 1rem;
    cursor: pointer; user-select: none; transition: background .2s;
}
.guide-header:hover { background: rgba(99,102,241,.05); }
.guide-icon {
    width: 24px; height: 24px; border-radius: 50%; background: var(--primary);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: .8rem; font-weight: 700; flex-shrink: 0;
}
.guide-header > span:nth-child(2) { font-weight: 600; font-size: .9rem; flex: 1; }
.guide-toggle { font-size: .75rem; color: var(--text-dim); }
.guide-body { padding: 0 1rem 1rem; }
.guide-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.guide-step {
    display: flex; gap: .6rem; align-items: flex-start; padding: .6rem .8rem;
    background: rgba(99,102,241,.05); border-radius: 8px; font-size: .82rem; color: var(--text-muted); line-height: 1.4;
}
.step-num {
    width: 22px; height: 22px; border-radius: 50%; background: var(--primary);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: .7rem; font-weight: 700; flex-shrink: 0;
}
.guide-presets { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.guide-presets-label { font-size: .8rem; color: var(--text-dim); margin-right: .25rem; }
.preset-btn {
    padding: .35rem .75rem; border-radius: 6px; border: 1px solid rgba(99,102,241,.3);
    background: rgba(99,102,241,.08); color: var(--primary); cursor: pointer;
    font-size: .78rem; transition: all .2s;
}
.preset-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Global Status Bar */
/* ─── Floating Status Panel ─── */
.status-fab {
    position: fixed; bottom: 20px; right: 20px; z-index: 99999;
    width: 48px; height: 48px; border-radius: 50%;
    background: var(--bg-card); border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all .3s ease;
    box-shadow: 0 4px 20px rgba(0,0,0,.4);
}
.status-fab:hover { transform: scale(1.1); border-color: var(--primary); }
.status-fab.active { border-color: var(--primary); animation: fab-pulse 2s infinite; }
.status-fab.error { border-color: var(--red); }
.status-fab.done { border-color: var(--green); }
.status-fab .fab-dot {
    width: 14px; height: 14px; border-radius: 50%; background: var(--text-dim);
    transition: background .3s;
}
.status-fab.active .fab-dot { background: var(--primary); }
.status-fab.error .fab-dot { background: var(--red); }
.status-fab.done .fab-dot { background: var(--green); }
@keyframes fab-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(99,102,241,.2); }
    50% { box-shadow: 0 4px 30px rgba(99,102,241,.6); }
}

.status-panel {
    position: fixed; bottom: 80px; right: 20px; z-index: 99998;
    width: 340px; max-height: 400px; overflow-y: auto;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,.5);
    display: none; flex-direction: column;
}
.status-panel.open { display: flex; }
.status-panel-header {
    padding: .75rem 1rem; border-bottom: 1px solid var(--border);
    font-weight: 600; font-size: .85rem; display: flex; justify-content: space-between; align-items: center;
}
.status-panel-body { padding: .5rem; flex: 1; overflow-y: auto; }
.status-entry {
    padding: .5rem .75rem; border-radius: 8px; margin-bottom: .4rem;
    font-size: .8rem; background: rgba(99,102,241,.05); border: 1px solid transparent;
}
.status-entry.running { border-color: var(--primary); background: rgba(99,102,241,.1); }
.status-entry.done { border-color: var(--green); opacity: .7; }
.status-entry.error { border-color: var(--red); background: rgba(239,68,68,.08); }
.status-entry-title { font-weight: 600; margin-bottom: .2rem; }
.status-entry-detail { color: var(--text-dim); font-size: .75rem; }
.status-entry-time { color: var(--text-dim); font-size: .65rem; float: right; }

/* Legacy (keep for backward compat) */
.global-status { display: none !important; }

/* === Delivery log (Status Panel content) === */
.status-panel { width: 440px; max-height: 70vh; }
.status-panel-body { padding: .35rem; max-height: calc(70vh - 50px); overflow-y: auto; }
.dl-empty { color: var(--text-dim); font-size: .82rem; padding: 1.2rem; text-align: center; }
.dl-toolbar { display: flex; gap: .4rem; padding: .25rem .25rem .55rem; border-bottom: 1px solid var(--border); margin-bottom: .35rem; }
.dl-row {
    display: grid;
    grid-template-columns: 70px 20px 42px 1fr;
    gap: .35rem;
    align-items: center;
    padding: .35rem .5rem;
    border-radius: 6px;
    font-size: .78rem;
    margin-bottom: .15rem;
    border-left: 3px solid transparent;
    background: rgba(255,255,255,.02);
}
.dl-row .dl-ts { color: var(--text-dim); font-family: ui-monospace, Menlo, monospace; font-size: .72rem; }
.dl-row .dl-icon { text-align: center; }
.dl-row .dl-kind { font-size: .68rem; padding: 1px 5px; border-radius: 4px; background: rgba(255,255,255,.05); color: var(--text-muted); text-align: center; }
.dl-row .dl-target { min-width: 0; overflow: hidden; }
.dl-row .dl-target .dl-to { display: block; color: var(--text-dim); font-size: .7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-row .dl-err { grid-column: 1 / -1; color: #fca5a5; font-size: .72rem; padding: .25rem .35rem; background: rgba(239,68,68,.08); border-radius: 4px; margin-top: .2rem; }
.dl-row.dl-sent { border-left-color: var(--green); }
.dl-row.dl-failed { border-left-color: var(--red); background: rgba(239,68,68,.04); }
.dl-row.dl-skipped { border-left-color: var(--yellow); }
.dl-row.dl-sending { border-left-color: var(--primary); background: rgba(99,102,241,.06); }

/* Unread badge on FAB */
.status-fab .fab-badge {
    position: absolute;
    top: -4px; right: -4px;
    min-width: 18px; height: 18px;
    border-radius: 9px;
    background: var(--red);
    color: #fff;
    font-size: .7rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
    box-shadow: 0 0 0 2px var(--bg);
}
.status-fab.has-unread { border-color: var(--primary); }
.status-fab.has-fail { border-color: var(--red); animation: fab-pulse-red 1.5s infinite; }
@keyframes fab-pulse-red {
    0%, 100% { box-shadow: 0 4px 20px rgba(239,68,68,.25); }
    50% { box-shadow: 0 4px 30px rgba(239,68,68,.7); }
}

@media (max-width: 600px) {
    .status-panel { width: calc(100vw - 24px); right: 12px; }
}
.status-indicator { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* Search Query Box */
.search-query-box {
    background: #0a0e1a; border: 1px solid var(--border); border-radius: 8px;
    padding: .75rem; transition: border-color .2s;
}
.search-query-box:focus-within { border-color: var(--primary); }
.search-query-box textarea {
    width: 100%; background: transparent; border: none; color: var(--green);
    font-family: 'SF Mono', 'Consolas', monospace; font-size: .85rem; line-height: 1.5;
    resize: none; outline: none;
}
.search-query-tags {
    display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem;
}
.search-tag {
    font-size: .7rem; padding: .15rem .5rem; border-radius: 4px;
    background: rgba(99,102,241,.15); color: var(--primary);
}
.search-query-hint {
    font-size: .72rem; color: var(--text-dim); margin-top: .4rem; line-height: 1.4;
}
.search-query-hint code {
    background: rgba(255,255,255,.08); padding: .1rem .3rem; border-radius: 3px;
    font-size: .72rem;
}

/* Scan Summary */
.scan-summary {
    font-size: .8rem; color: var(--text-muted); padding: .3rem .6rem;
    background: rgba(255,255,255,.03); border-radius: 6px;
}

/* Leads scan filter dropdown enhanced */
#filterScanJob { max-width: 200px; }

/* ═══════════════ Responsive ═══════════════ */

/* Tablet & phone (< 768px) */
@media (max-width: 768px) {
    /* Topbar — wrap, tabs become horizontal scroll strip */
    .topbar {
        flex-wrap: wrap; height: auto; padding: .5rem .75rem; gap: .5rem;
    }
    .topbar-logo { font-size: 1rem; }
    .topbar-tabs {
        display: flex; order: 3; width: 100%;
        overflow-x: auto; scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .topbar-tabs::-webkit-scrollbar { display: none; }
    .tab-btn {
        white-space: nowrap; padding: .4rem .75rem;
        font-size: .8rem; flex-shrink: 0;
    }
    .logout-btn { font-size: .7rem; padding: .3rem .6rem; }

    /* Tighter spacing on phone */
    .tab-content { padding: .75rem; }
    .card { padding: 1rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .page-header h2 { font-size: 1.25rem; }
    .page-header p { font-size: .8rem; }

    /* Grids stack */
    .grid-2 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: .5rem; }
    .stat-card { padding: 1rem; }
    .stat-card .stat-value { font-size: 1.5rem; }
    .form-row { flex-direction: column; gap: 0; }
    .guide-steps { grid-template-columns: 1fr; }
    .analytics-bars { flex-direction: column; gap: .5rem; }

    /* Tables — keep readable but allow horizontal scroll inside .card */
    table { font-size: .8rem; min-width: max-content; }
    th, td { padding: .5rem .6rem; }

    /* Leads toolbar — stack, filters become 2-col grid */
    .leads-toolbar { flex-direction: column; align-items: stretch; gap: .5rem; }
    .leads-toolbar .filters {
        display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; width: 100%;
    }
    .filters input, .filters select {
        width: 100%; min-width: 0; padding: .5rem .6rem; font-size: .85rem;
    }
    #leadSearch { grid-column: 1 / -1; }
    .checkbox-label { grid-column: 1 / -1; }
    .leads-toolbar .actions { display: flex; gap: .5rem; width: 100%; }
    .leads-toolbar .actions .btn { flex: 1; }

    /* Modal — fullscreen on phone */
    .modal-content {
        width: 100%; max-width: 100%; max-height: 100vh;
        height: 100vh; border-radius: 0;
    }
    .modal-header { padding: .75rem 1rem; }
    .modal-body { padding: 1rem; }

    /* Login card */
    .login-card { width: calc(100% - 2rem); max-width: 380px; padding: 2rem 1.5rem; }

    /* Floating status panel */
    .status-fab { width: 44px; height: 44px; bottom: 12px; right: 12px; }
    .status-panel {
        width: calc(100vw - 24px); max-width: 340px;
        bottom: 64px; right: 12px;
    }

    /* Scanner map smaller */
    #scanMap { height: 240px !important; }

    /* Buttons — bigger touch target */
    .btn { padding: .65rem 1rem; }
    .btn-sm { padding: .4rem .8rem; font-size: .8rem; }

    /* Toast — full width minus margins */
    .toast { left: 12px; right: 12px; bottom: 12px; }
}

/* Small phones (< 480px) */
@media (max-width: 480px) {
    .topbar-logo { font-size: .9rem; }
    .topbar-logo span { display: none; }
    .stats-grid { grid-template-columns: 1fr; }
    .tab-btn { font-size: .75rem; padding: .35rem .6rem; }
    .leads-toolbar .filters { grid-template-columns: 1fr; }
    .page-header h2 { font-size: 1.15rem; }
    .card h3 { font-size: .9rem; }
    .modal-header h3 { font-size: 1rem; }
}


/* ═══════════════ Mobile Lead Cards ═══════════════ */
.lead-cards { display: none; }

.lead-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem; margin-bottom: .75rem;
}
.lead-card-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: .6rem;
}
.lead-card-name { font-weight: 700; font-size: .95rem; flex: 1; margin-right: .5rem; }
.lead-card-status { flex-shrink: 0; }
.lead-card-meta {
    display: grid; grid-template-columns: 1fr 1fr; gap: .3rem .75rem;
    font-size: .82rem; color: var(--text-muted); margin-bottom: .75rem;
}
.lead-card-meta span { display: flex; align-items: center; gap: .3rem; overflow: hidden; }
.lead-card-meta a { color: var(--primary); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-card-meta .meta-label { color: var(--text-dim); font-size: .72rem; }
.lead-card-actions {
    display: flex; gap: .4rem; flex-wrap: wrap; padding-top: .6rem;
    border-top: 1px solid var(--border);
}
.lead-card-actions .btn { flex: 1; min-width: 0; text-align: center; font-size: .78rem; padding: .45rem .5rem; }

/* Desktop: show table, hide cards */
.lead-table-desktop { display: block; }

@media (max-width: 768px) {
    /* Hide table, show cards */
    .lead-table-desktop { display: none !important; }
    .lead-cards { display: block !important; }

    /* Scanner — preset buttons wrap nicer */
    .preset-btn { font-size: .72rem; padding: .3rem .6rem; }
    .guide-presets { gap: .3rem; }

    /* Campaign form tighter */
    .form-group { margin-bottom: .6rem; }

    /* Analytics — tighter cards */
    .analytics-card { padding: 1rem; }
    .analytics-header h4 { font-size: .9rem; }
    .analytics-actions { flex-wrap: wrap; }
    .analytics-actions .btn { flex: 1; min-width: 0; text-align: center; }

    /* Pagination bigger touch targets */
    .pagination button { padding: .45rem .85rem; font-size: .85rem; }

    /* Modal email form */
    .modal-body textarea { font-size: .85rem; }
    .modal-body input { font-size: .85rem; }

    /* Contact icons more compact */
    .contact-icons { display: flex; gap: .2rem; flex-wrap: wrap; }
}

@media (max-width: 480px) {
    .lead-card-meta { grid-template-columns: 1fr; gap: .2rem; }
    .lead-card-actions { gap: .3rem; }
    .lead-card-actions .btn { font-size: .72rem; padding: .4rem .3rem; }

    /* Even tighter spacing */
    .card { padding: .75rem; }
    .tab-content { padding: .5rem; }
}


/* ═══════════════ Sender Profile Banner ═══════════════ */
.profile-banner {
    background: var(--bg-card); border-bottom: 1px solid var(--border);
    max-width: 1400px; margin: 0 auto;
}
.profile-banner-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: .6rem 1.5rem; cursor: pointer; user-select: none;
    transition: background .2s;
}
.profile-banner-header:hover { background: rgba(99,102,241,.05); }
.profile-banner-header span:first-child { font-weight: 600; font-size: .85rem; }
.profile-status {
    font-size: .72rem; padding: .15rem .5rem; border-radius: 4px;
    background: rgba(239,68,68,.15); color: var(--red);
}
.profile-status.filled {
    background: rgba(16,185,129,.15); color: var(--green);
}
.profile-banner-body { padding: 0 1.5rem 1rem; }
.profile-form { max-width: 700px; }

@media (max-width: 768px) {
    .profile-banner-header { padding: .5rem .75rem; }
    .profile-banner-body { padding: 0 .75rem .75rem; }
}

/* Lead card priority highlight */
.lead-card.hot { border-left: 3px solid var(--green); }
.lead-card.warm { border-left: 3px solid var(--yellow); }
.lead-card.has-bot { border-left: 3px solid var(--primary); }
.lead-card.contacted { border-left: 3px solid var(--blue); opacity: .8; }

/* Desktop table row highlights */
tr.hot td:first-child { border-left: 3px solid var(--green); }
tr.warm td:first-child { border-left: 3px solid var(--yellow); }
tr.has-bot td:first-child { border-left: 3px solid var(--primary); }

/* Fix button overflow in table */
table td { vertical-align: middle; }
table .btn-sm { white-space: nowrap; margin-bottom: 2px; }

/* Date column styling */
.date-cell { white-space: nowrap; color: var(--text-muted); font-size: .8rem; }


/* Favorite star toggle */
.fav-star{display:inline-block;cursor:pointer;font-size:1.05rem;color:#9aa0ad;margin-right:.35rem;line-height:1;user-select:none;transition:transform .15s,color .2s;vertical-align:-1px}
.fav-star:hover{color:#ffb800;transform:scale(1.2)}
.fav-star.is-fav{color:#ffb800}
.fav-star.is-fav:hover{color:#e6a000}
.checkbox-label input[type=checkbox]{vertical-align:middle;margin-right:.25rem}


/* ═══════════════ Mobile Demos Cards (parallel to lead-cards) ═══════════════ */
.demos-cards { display: none; }

.demo-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem; margin-bottom: .75rem;
}
.demo-card-header {
    display: flex; justify-content: space-between; align-items: center; gap: .5rem;
    margin-bottom: .6rem; flex-wrap: wrap;
}
.demo-card-email { font-weight: 600; font-size: .9rem; word-break: break-all; flex: 1; min-width: 0; }
.demo-card-meta {
    display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .75rem;
    font-size: .82rem; color: var(--text-muted); margin-bottom: .6rem;
}
.demo-card-meta .meta-label { color: var(--text-dim); font-size: .7rem; display: block; margin-bottom: .1rem; }
.demo-card-meta a { color: var(--primary); text-decoration: none; }
.demo-card-actions {
    display: flex; gap: .4rem; flex-wrap: wrap; padding-top: .6rem;
    border-top: 1px solid var(--border); margin-top: .5rem;
}
.demo-card-actions .btn { flex: 1; min-width: 0; text-align: center; font-size: .78rem; padding: .45rem .5rem; }

@media (max-width: 768px) {
    .demos-table-desktop { display: none !important; }
    .demos-cards { display: block !important; }

    /* Tab nav: horizontal scroll for many tabs */
    .tab-nav, .tabs-container {
        overflow-x: auto; -webkit-overflow-scrolling: touch;
        white-space: nowrap; scrollbar-width: none;
    }
    .tab-nav::-webkit-scrollbar, .tabs-container::-webkit-scrollbar { display: none; }
    .tab-btn { flex-shrink: 0; }

    /* Section headers smaller */
    .page-header h2 { font-size: 1.15rem; }

    /* Sender profile banner more compact */
    .profile-banner-header span:first-child { font-size: .8rem; }

    /* Button gap tighter on mobile */
    .btn-sm { padding: .4rem .6rem; font-size: .75rem; }

    /* Form inputs full-width comfortable touch */
    .form-group input, .form-group select, .form-group textarea { font-size: 16px; }

    /* Modal more vertical room */
    .modal-content { width: 95% !important; max-height: 92vh !important; }
    .modal-body { max-height: 70vh; overflow-y: auto; padding: 1rem !important; }
}

@media (max-width: 480px) {
    .demo-card-meta { grid-template-columns: 1fr; gap: .25rem; }
    .demo-card-actions .btn { font-size: .72rem; padding: .4rem .4rem; }
    .demo-card { padding: .75rem; }

    /* Even tighter header */
    .page-header h2 { font-size: 1rem; }
    .page-header p { font-size: .75rem; }

    /* Stat cards stack */
    .stat-card { padding: .75rem; }
    .stat-value { font-size: 1.25rem !important; }
    .stat-label { font-size: .7rem !important; }
}

/* ═══════════════ Operator Console — Mobile Composer ═══════════════ */
@media (max-width: 640px) {
    .composer-toolbar {
        font-size: 11px !important;
    }
    .composer-toolbar > span { display: none; }  /* hide hint on small screens */
}

/* === Anchor contrast fix (28.05.2026) === */
table a,
table a:visited,
.lead-row a,
.lead-row a:visited { color: #93c5fd; text-decoration: none; }
table a:hover,
.lead-row a:hover { color: #c7d8ff; text-decoration: underline; }
table tbody td { color: var(--text); }

/* === Leads table compact layout (28.05.2026 v3) === */
.lead-table-desktop { overflow-x: auto; }
.leads-table { width: 100%; table-layout: fixed; border-collapse: collapse; }
.leads-table th, .leads-table td { padding: .55rem .6rem; vertical-align: top; border-bottom: 1px solid var(--border); }
.leads-table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); text-align: left; }
.leads-table .col-cb       { width: 36px;  text-align: center; }
.leads-table .col-biz      { width: 24%; }
.leads-table .col-contacts { width: 30%; }
.leads-table .col-city     { width: 110px; }
.leads-table .col-status   { width: 90px;  }
.leads-table .col-actions  { width: auto;  }
.leads-table .biz-name { font-size: .92rem; line-height: 1.25; word-break: break-word; }
.leads-table .biz-meta { margin-top: .25rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.leads-table .cat-pill { background: rgba(99,102,241,.18); color: #c7d2fe; padding: 1px 8px; border-radius: 10px; font-size: .7rem; }
.leads-table .biz-date { color: var(--text-dim); font-size: .7rem; }
.leads-table .col-contacts a.c-link {
    display: block; color: #93c5fd; text-decoration: none;
    font-size: .82rem; line-height: 1.35;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 100%;
}
.leads-table .col-contacts a.c-link:hover { color: #c7d8ff; text-decoration: underline; }
.leads-table .col-contacts .c-empty { color: var(--text-dim); }
.leads-table .col-city { color: var(--text); font-size: .85rem; word-break: break-word; }
.leads-table .row-actions { display: flex; flex-wrap: wrap; gap: .3rem; }
.leads-table .row-actions .btn { min-width: 32px; padding: .35rem .5rem; font-size: .82rem; line-height: 1; }

@media (max-width: 1100px) {
    .leads-table .col-city { display: none; }
    .leads-table .col-biz { width: 28%; }
    .leads-table .col-contacts { width: 36%; }
}

/* === Bulk Preview modal v2 (split list + iframe) === */
.modal.modal-wide .modal-content {
    width: min(1200px, 96vw);
    max-width: 1200px;
    height: 92vh;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
}
.modal.modal-wide .modal-body { flex: 1; overflow: hidden; display: flex; flex-direction: column; padding: 1rem; }
.bp-shell { flex: 1; display: grid; grid-template-columns: 260px 1fr; gap: 1rem; min-height: 0; }
.bp-list { overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; background: rgba(255,255,255,.02); padding: .35rem; }
.bp-li { padding: .55rem .65rem; border-radius: 6px; cursor: pointer; margin-bottom: .2rem; border: 1px solid transparent; }
.bp-li:hover { background: rgba(255,255,255,.05); }
.bp-li.bp-active { background: rgba(99,102,241,.18); border-color: rgba(99,102,241,.5); }
.bp-li.bp-empty .bp-li-name { color: var(--text-muted); }
.bp-li-name { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bp-li-meta { font-size: .72rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: .15rem; }
.bp-li-warn { font-size: .7rem; color: var(--yellow); margin-top: .15rem; }
.bp-main { display: flex; flex-direction: column; min-width: 0; gap: .55rem; }
.bp-toolbar { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; }
.bp-nav { display: flex; gap: .4rem; align-items: center; }
.bp-counter { font-weight: 600; color: var(--text); font-size: .9rem; }
.bp-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.bp-meta { background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: 8px; padding: .55rem .7rem; display: grid; grid-template-columns: 1fr 1fr; gap: .25rem .8rem; font-size: .8rem; }
.bp-meta-label { color: var(--text-muted); font-size: .72rem; margin-right: .25rem; }
.bp-preview { flex: 1; min-height: 300px; display: flex; }
.bp-footer { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding-top: .8rem; border-top: 1px solid var(--border); margin-top: .8rem; flex-wrap: wrap; }
.bp-help { color: var(--text-muted); font-size: .8rem; }

@media (max-width: 900px) {
    .bp-shell { grid-template-columns: 1fr; }
    .bp-list { max-height: 160px; }
    .bp-meta { grid-template-columns: 1fr; }
}
