/* ═══════════════════════════════════════════════════════════════════════════
   Dealer Scout — Stylesheet (Partner-first v2)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ──── Reset & variables ──── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #2a2a2d;
    --card-bg: #222226;
    --bg-card: #fafafa;
    --bg-card-hover: #f0f0f0;
    --bg-input: #f0f0f0;
    --border: #e2e2e2;
    --text: #f0f0f0;
    --text-card: #111111;
    --text-card-muted: #555555;
    --text-muted: #666666;
    --primary: #e4002b;
    --primary-hover: #ff1a3e;
    --success: #00a846;
    --warning: #e68000;
    --danger: #e4002b;
    --info: #1a6fdb;
    --accent: #e4002b;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 2px 16px rgba(0,0,0,.12);
    --sidebar-w: 220px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html { font-size: 15px; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

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

/* ──── Sidebar ──── */
.sidebar {
    width: var(--sidebar-w);
    background: #222225;
    border-right: 1px solid #333336;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}
.sidebar-logo {
    padding: 16px 18px;
    border-bottom: 1px solid #333336;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-logo-mark {
    width: 60px;
    height: 60px;
    border-radius: 0;
    object-fit: contain;
    /* Invert black line-art to white so it's visible on the dark sidebar */
    filter: brightness(0) invert(1);
    flex-shrink: 0;
    display: block;
}
body.light .sidebar-logo-mark {
    filter: none;
}
.sidebar-logo-text {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.sidebar-logo-sub {
    font-size: 10px;
    color: var(--text-muted);
}
.sidebar-logo h1 { font-size: 1rem; white-space: nowrap; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 16px; color: var(--text-muted);
    font-size: .88rem; transition: background .15s, color .15s;
    border-left: 3px solid transparent;
}
.nav-link:hover, .nav-link.active {
    background: rgba(228,0,43,0.12); color: #ffffff;
}
.nav-link.active {
    border-left-color: var(--primary);
    color: var(--text);
}
.nav-icon { font-size: 1.1rem; width: 22px; text-align: center; }
.badge {
    background: var(--primary); color: #fff;
    padding: 1px 7px; border-radius: 10px; font-size: .75rem; margin-left: auto;
}
.sidebar-footer {
    padding: 14px 18px; border-top: 1px solid #333336;
    color: #888888; font-size: .78rem;
}
.sidebar-gmail {
    display: flex; align-items: center; gap: 6px;
    margin-bottom: 6px; font-size: .78rem; color: #4ade80;
}
.sidebar-gmail.disconnected { color: var(--text-muted); }
.gmail-dot { font-size: .55rem; flex-shrink: 0; }
.gmail-addr {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 160px; color: #4ade80;
}

/* ──── Main content ──── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 24px 28px;
    min-height: 100vh;
}

/* ──── Flash messages ──── */
.flash-container { margin-bottom: 16px; }
.flash {
    padding: 12px 16px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px; font-size: .9rem;
}
.flash-success { background: rgba(34,197,94,.12); border: 1px solid var(--success); color: var(--success); }
.flash-error   { background: rgba(239,68,68,.12); border: 1px solid var(--danger); color: var(--danger); }
.flash-warning { background: rgba(245,158,11,.12); border: 1px solid var(--warning); color: var(--warning); }
.flash-info    { background: rgba(59,130,246,.12); border: 1px solid var(--info); color: var(--info); }
.flash-close   { background: none; border: none; color: inherit; cursor: pointer; font-size: 1.2rem; }

/* ──── Stats row ──── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px; margin-bottom: 20px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: 2px solid transparent;
    border-radius: var(--radius);
    padding: 18px 14px;
    text-align: center;
    transition: transform .15s, box-shadow .15s, border-top-color .15s;
}
a.stat-card-link:hover .stat-card,
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,.13);
    border-top-color: var(--primary);
}
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-label { font-size: .68rem; color: var(--text-muted); margin-top: 6px; text-transform: uppercase; letter-spacing: .06em; }

/* ──── Toolbar ──── */
.toolbar {
    display: flex; flex-wrap: wrap; gap: 10px;
    align-items: center; justify-content: space-between;
    margin-bottom: 16px;
}
.toolbar-filters {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.toolbar-actions {
    display: flex; gap: 8px; align-items: center;
}
.view-tabs {
    display: flex; gap: 2px; background: var(--bg-card);
    border-radius: var(--radius-sm); padding: 2px;
    border: 1px solid var(--border);
}
.view-tab {
    background: none; border: none; color: var(--text-muted);
    padding: 6px 12px; cursor: pointer; font-size: .9rem;
    border-radius: var(--radius-sm); transition: all .15s;
}
.view-tab:hover { color: var(--text-card); }
.view-tab.active { background: var(--primary); color: #fff; }

/* ──── Bulk bar ──── */
.bulk-bar {
    background: var(--bg-card); border: 1px solid var(--primary);
    border-radius: var(--radius-sm); padding: 10px 16px;
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 14px; font-size: .88rem;
}

/* ──── Buttons ──── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: var(--radius-sm);
    font-size: .88rem; font-weight: 500; cursor: pointer;
    border: 1px solid transparent; transition: all .15s;
    text-decoration: none; white-space: nowrap;
}
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary { background: var(--bg-card); color: var(--text-card); border-color: var(--border); }
.btn-secondary:hover { background: #3a3a3e; color: #fff; border-color: #3a3a3e; }
.btn-ghost     { background: none; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }

/* ──── Inputs ──── */
.input-field {
    width: 100%;
    background: var(--bg-input); color: var(--text-card);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 8px 12px; font-size: .88rem;
    font-family: var(--font);
    transition: border-color .15s;
}
.input-field:focus { border-color: var(--primary); outline: none; }
select.input-field { width: auto; min-width: 120px; }
textarea.input-field { resize: vertical; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: .82rem; color: var(--text-muted); margin-bottom: 4px; }
.form-actions { display: flex; gap: 8px; margin-top: 14px; }

/* ──── Partner card grid ──── */
.partner-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
}
.partner-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    transition: border-color .15s, box-shadow .15s;
}
.partner-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.partner-card-header {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.partner-name { font-weight: 600; flex: 1; }
.partner-card-body {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 8px; padding: 12px 14px;
}
.partner-metric { text-align: center; }
.metric-label { display: block; font-size: .72rem; color: var(--text-muted); text-transform: uppercase; }
.metric-value { font-size: 1rem; font-weight: 600; }
.partner-card-footer {
    padding: 8px 14px; border-top: 1px solid var(--border);
    display: flex; gap: 12px; font-size: .82rem; color: var(--text-muted);
    flex-wrap: wrap;
}
.contact-info { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }

/* ──── Priority pill ── */
.priority-pill {
    display: inline-block;
    padding: 2px 8px; border-radius: 10px;
    font-weight: 700; font-size: .85rem;
    color: #fff;
    background: color-mix(in srgb, var(--danger) calc(var(--score) * 10%), var(--success) calc((10 - var(--score)) * 10%));
}

/* ──── Status badges ──── */
.status-badge {
    font-size: .75rem; padding: 2px 8px; border-radius: 10px;
    font-weight: 600; text-transform: capitalize;
}
.status-new       { background: rgba(99,102,241,.18); color: var(--primary); }
.status-contacted { background: rgba(59,130,246,.18); color: var(--info); }
.status-replied   { background: rgba(34,197,94,.18);  color: var(--success); }
.status-converted { background: rgba(245,158,11,.18); color: var(--warning); }
.status-lost      { background: rgba(239,68,68,.12);  color: var(--danger); }
.status-sent      { background: rgba(34,197,94,.18);  color: var(--success); }
.status-filled    { background: rgba(245,158,11,.18); color: var(--warning); }

/* ──── Contact method badges ──── */
.contact-badge {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 2px 8px; border-radius: 10px;
    font-size: .72rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .3px;
    white-space: nowrap;
}
.contact-badge-email {
    background: rgba(59,130,246,.15); color: var(--info);
    border: 1px solid rgba(59,130,246,.3);
}
.contact-badge-webform {
    background: rgba(245,158,11,.15); color: var(--warning);
    border: 1px solid rgba(245,158,11,.3);
}
.contact-badge-none {
    background: rgba(239,68,68,.1); color: var(--danger);
    border: 1px solid rgba(239,68,68,.25);
}
.contact-method-display {
    display: flex; gap: 6px; align-items: center;
    padding: 4px 0;
}

/* ──── Data table ──── */
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table th, .data-table td {
    padding: 10px 12px; text-align: left;
    border-bottom: 1px solid var(--border);
}
.data-table th {
    background: var(--bg-card); color: var(--text-muted);
    font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
    position: sticky; top: 0;
}
.data-table th a { color: var(--text-muted); }
.data-table th a:hover { color: var(--text); }
.data-table tr:hover td { background: var(--bg-card); }
.data-table tbody tr { cursor: pointer; }
.data-table tr.map-active td { background: rgba(228,0,43,.06) !important; }

/* ──── Partner map-active highlight ──── */
.partner-card { cursor: pointer; }
.partner-card.map-active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(228,0,43,.22); }
.folder-partner-row { cursor: pointer; }
.folder-partner-row.map-active { background: rgba(228,0,43,.07) !important; border-left: 3px solid var(--primary); padding-left: 39px; }

/* ──── Checkbox ──── */
.checkbox-wrap { display: flex; align-items: center; }
.checkbox-wrap input[type="checkbox"] { accent-color: var(--primary); width: 16px; height: 16px; }

/* ──── Map ──── */
.map-split {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 16px;
    height: 500px;
}
.map-container {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    height: 100%;
    min-height: 400px;
    z-index: 1;
}
.map-sidebar {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px;
    overflow-y: auto;
}
.map-sidebar h3 { font-size: .92rem; margin-bottom: 12px; }
.state-list { list-style: none; }
.state-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0; border-bottom: 1px solid var(--border);
    font-size: .84rem;
}
.state-name { font-weight: 600; }
.state-stats { color: var(--text-muted); font-size: .78rem; }

.mini-map {
    height: 280px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    z-index: 1;
}

/* ──── Panels ──── */
.panel {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.panel h3 { font-size: .95rem; margin-bottom: 12px; }
.panel-danger { border-color: var(--danger); background: #fff5f5; }

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

/* ──── Quick Actions Bar ──── */
.quick-actions {
    display: flex;
    gap: 10px;
    padding: 14px 0 6px;
    flex-wrap: wrap;
}
.btn-action {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    color: var(--text-card);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
    box-shadow: 0 1px 3px rgba(0,0,0,.10);
    white-space: nowrap;
}
.btn-action:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(228,0,43,.30);
}
.btn-action-icon { font-size: 1.15rem; line-height: 1; }
.btn-action-label { letter-spacing: 0.01em; }

/* ──── Scrape slide-down panel ──── */
.scrape-slide-panel {
    background: var(--bg-card);
    border: 1.5px solid var(--primary);
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 14px;
    box-shadow: 0 4px 16px rgba(99,102,241,.15);
    animation: slideDown 0.15s ease;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.scrape-slide-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 10px;
    font-weight: 600;
}
.scrape-slide-header small { color: var(--text-muted); font-weight: 400; }
.scrape-slide-actions { display: flex; gap: 8px; margin-top: 10px; align-items: center; }

/* ──── Scrape panel ──── */
.scrape-panel { margin-top: 20px; }
.scrape-panel summary {
    cursor: pointer; padding: 12px; font-weight: 600;
}
.scrape-form { padding: 14px; display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.scrape-form textarea { flex: 1; min-width: 200px; }

/* ──── Chat panel ──── */
.chat-panel {
    position: fixed; bottom: 0; right: 28px;
    width: 380px; max-height: 500px;
    background: #222225; border: 1px solid #333336;
    border-top: 2px solid var(--primary);
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: 0 -4px 32px rgba(0,0,0,.4);
    z-index: 200;
    display: flex; flex-direction: column;
}
.chat-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 11px 16px; cursor: pointer;
    border-bottom: 1px solid #333336;
    font-weight: 600; font-size: .9rem;
    color: var(--text);
    background: #1e1e21;
    border-radius: var(--radius) var(--radius) 0 0;
}
.chat-toggle { font-size: .8rem; color: #666; }
.chat-body { display: flex; flex-direction: column; max-height: 430px; }
.chat-messages {
    flex: 1; overflow-y: auto; padding: 14px;
    display: flex; flex-direction: column; gap: 10px;
    max-height: 340px;
    background: #1a1a1d;
}
.chat-msg {
    padding: 9px 13px; border-radius: 10px;
    font-size: .84rem; max-width: 88%; line-height: 1.5;
    white-space: pre-wrap;
}
.chat-msg.user {
    align-self: flex-end;
    background: var(--primary); color: #fff;
    border-radius: 10px 10px 2px 10px;
}
.chat-msg.assistant {
    align-self: flex-start;
    background: #2e2e33; color: var(--text);
    border: 1px solid #383838;
    border-radius: 10px 10px 10px 2px;
}
.chat-input-row {
    display: flex; gap: 8px; padding: 10px 12px;
    border-top: 1px solid #333336;
    background: #222225;
}
.chat-input-row .input-field {
    flex: 1;
    background: #2a2a2d;
    border-color: #444448;
    color: var(--text);
}
.chat-input-row .input-field:focus { border-color: var(--primary); }

/* ──── Pagination ──── */
.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 12px; margin-top: 20px;
}
.page-info { font-size: .85rem; color: var(--text-muted); }

/* ──── Page header ──── */
.page-header {
    display: flex; align-items: center; gap: 12px; justify-content: space-between;
    margin-bottom: 20px;
}
.page-header h2 { font-size: 1.3rem; }

/* ──── Empty state ──── */
.empty-state {
    text-align: center; padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state h2 { color: var(--text); margin-bottom: 8px; }
.empty-state p { margin-bottom: 16px; }

/* ──── Settings grid ──── */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 16px;
}
.panel-highlight {
    border-color: var(--border) !important;
    background: #ffffff;
}

/* ──── Drafts ──── */
.drafts-list { display: flex; flex-direction: column; gap: 12px; }
.draft-card {
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    color: var(--text-card);
}
.draft-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 14px; border-bottom: 1px solid var(--border);
    flex-wrap: wrap; gap: 8px;
}
.draft-body { padding: 14px; }
.draft-body summary { cursor: pointer; font-weight: 500; margin-bottom: 10px; }
.draft-actions {
    display: flex; gap: 6px; padding: 10px 14px;
    border-top: 1px solid var(--border);
}

/* ──── State tags ──── */
.state-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.state-tag {
    background: rgba(99,102,241,.15); color: var(--primary);
    padding: 3px 10px; border-radius: 10px;
    font-size: .78rem; font-weight: 600;
}

/* ──── Setup wizard ──── */
.setup-wizard { max-width: 650px; }
.setup-wizard h2 { margin-bottom: 4px; }
.setup-wizard > p { color: var(--text-muted); margin-bottom: 20px; }
.setup-steps { display: flex; flex-direction: column; gap: 14px; }
.setup-step {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
}
.setup-step.done { border-color: var(--success); }
.step-header {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px; background: var(--bg-card-hover);
}
.step-num {
    width: 26px; height: 26px; line-height: 26px;
    text-align: center; border-radius: 50%;
    background: var(--primary); color: #fff;
    font-size: .8rem; font-weight: 700; flex-shrink: 0;
}
.step-title { font-weight: 600; flex: 1; }
.step-status { font-size: .82rem; color: var(--success); }
.step-body { padding: 14px 16px; }
.step-body p { margin-bottom: 10px; color: var(--text-muted); font-size: .9rem; }

/* ──── Upload ──── */
.file-drop {
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 30px; text-align: center; cursor: pointer;
    transition: border-color .2s;
}
.file-drop:hover { border-color: var(--primary); }
.file-drop input[type="file"] { margin-bottom: 8px; }
.file-drop p { color: var(--text-muted); font-size: .88rem; }

/* ──── Toast ──── */
.toast-container {
    position: fixed; top: 20px; right: 20px;
    z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
    background: var(--bg-card); color: var(--text-card);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 12px 16px; font-size: .88rem;
    box-shadow: var(--shadow);
    animation: slideIn .3s ease;
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0 } to { transform: none; opacity: 1 } }

/* ──── Helper text ──── */
.text-muted { color: var(--text-muted); }
code, .code {
    background: var(--bg-input); padding: 2px 6px;
    border-radius: 4px; font-size: .85rem;
    font-family: 'Cascadia Code', 'SF Mono', monospace;
}

/* ──── Dashboard layout: filter sidebar + content ──── */
.dashboard-layout {
    display: flex; gap: 16px;
}
.filter-sidebar {
    width: 260px; min-width: 260px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    position: sticky; top: 16px; max-height: calc(100vh - 48px);
    overflow-y: auto; transition: width .25s, min-width .25s, padding .25s, opacity .25s;
}
.filter-sidebar.collapsed {
    width: 0; min-width: 0; padding: 0; overflow: hidden; opacity: 0;
    border: none;
}
.filter-sidebar-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 14px;
}
.filter-sidebar-header h3 { font-size: .95rem; }
.dashboard-content { flex: 1; min-width: 0; }

/* ──── Filter groups ──── */
.filter-group { margin-bottom: 14px; }
.filter-group > label {
    display: block; font-size: .8rem; font-weight: 600;
    color: var(--text-muted); margin-bottom: 4px;
    text-transform: uppercase; letter-spacing: .04em;
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.filter-chip {
    background: var(--bg-input); color: var(--text-muted);
    border: 1px solid var(--border); border-radius: 14px;
    padding: 3px 10px; font-size: .78rem; cursor: pointer;
    transition: all .15s; user-select: none;
}
.filter-chip:hover { border-color: var(--primary); color: var(--text-card); }
.filter-chip.active {
    background: var(--primary); color: #fff;
    border-color: var(--primary);
}
/* Status-filter row in logs sidebar — same shape as filter-chip but smaller */
.status-chip {
    background: var(--bg-input); color: var(--text-muted);
    border: 1px solid var(--border); border-radius: 12px;
    padding: 2px 8px; font-size: .72rem; cursor: pointer;
    transition: all .15s; user-select: none;
}
.status-chip:hover { border-color: var(--primary); color: var(--text-card); }
.status-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.range-row {
    display: flex; gap: 8px; align-items: center;
}
.range-row input[type="range"] {
    flex: 1; accent-color: var(--primary);
    height: 6px; cursor: pointer;
}
.range-inputs { display: flex; gap: 6px; align-items: center; }

/* ──── ID pill (click to copy) ──── */
.id-pill {
    display: inline-block;
    background: var(--bg-input); color: var(--text-muted);
    border: 1px solid var(--border); border-radius: 8px;
    padding: 1px 7px; font-size: .7rem; font-weight: 700;
    font-family: 'Cascadia Code', 'SF Mono', monospace;
    cursor: pointer; user-select: none;
    transition: background .15s, color .15s;
    vertical-align: middle;
}
.id-pill:hover {
    background: var(--primary); color: #fff; border-color: var(--primary);
}

/* ──── Tag badges ──── */
.tag-badge {
    display: inline-block;
    background: rgba(99,102,241,.12); color: var(--primary);
    padding: 1px 8px; border-radius: 10px;
    font-size: .72rem; font-weight: 600;
    border: 1px solid rgba(99,102,241,.25);
}
.card-tags { padding: 4px 14px 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.card-actions {
    display: inline-flex; gap: 2px; margin-left: auto;
}

/* ──── Analytics panel ──── */
.analytics-panel {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px; margin-bottom: 14px;
}
.analytics-card {
    text-align: center; padding: 12px 8px;
    background: var(--bg-input); border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.analytics-icon { font-size: 1.3rem; margin-bottom: 4px; }
.analytics-value { font-size: 1.4rem; font-weight: 700; color: var(--primary); }
.analytics-label { font-size: .72rem; color: var(--text-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: .03em; }

/* ──── Status distribution bar ──── */
.status-bar-track {
    display: flex; height: 14px; border-radius: 7px;
    overflow: hidden; background: var(--bg-input);
    margin-bottom: 6px;
}
.status-bar-seg { transition: width .4s ease; }
.status-bar-legend {
    display: flex; flex-wrap: wrap; gap: 10px;
    font-size: .78rem; color: var(--text-muted);
}
.legend-dot {
    display: inline-block; width: 8px; height: 8px;
    border-radius: 50%; margin-right: 4px;
    vertical-align: middle;
}

/* ──── Modal ──── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15,17,23,.85);
    display: flex; align-items: center; justify-content: center;
    z-index: 9998;
}
.modal-content {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px;
    width: 90%; max-width: 520px;
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.modal-content h3 { margin-bottom: 6px; }

/* ──── Tone ──── */
.tone-options { display: flex; flex-direction: column; gap: 8px; }
.tone-option {
    display: flex; gap: 10px; cursor: pointer;
}
.tone-option input[type="radio"] {
    accent-color: var(--primary); margin-top: 14px;
}
.tone-card {
    flex: 1; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 14px; transition: border-color .15s;
}
.tone-option input:checked + .tone-card {
    border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary);
}
.tone-card strong { display: block; margin-bottom: 2px; font-size: .9rem; }
.tone-card p { font-size: .8rem; color: var(--text-muted); margin: 0; }

/* ──── Tone badges (drafts) ──── */
.tone-badge {
    display: inline-block; padding: 2px 8px; border-radius: 10px;
    font-size: .72rem; font-weight: 600;
}
.tone-casual { background: rgba(34,197,94,.15); color: var(--success); border: 1px solid rgba(34,197,94,.3); }
.tone-consultative { background: rgba(99,102,241,.15); color: var(--primary); border: 1px solid rgba(99,102,241,.3); }
.tone-formal { background: rgba(59,130,246,.15); color: var(--info); border: 1px solid rgba(59,130,246,.3); }

/* ──── Quality score badges ──── */
.quality-badge {
    display: inline-block; padding: 2px 8px; border-radius: 10px;
    font-size: .72rem; font-weight: 700;
}
.quality-excellent { background: rgba(34,197,94,.15); color: var(--success); border: 1px solid rgba(34,197,94,.3); }
.quality-good { background: rgba(245,158,11,.15); color: var(--warning); border: 1px solid rgba(245,158,11,.3); }
.quality-needs-work { background: rgba(239,68,68,.12); color: var(--danger); border: 1px solid rgba(239,68,68,.25); }

/* ──── Critic notes ──── */
.critic-notes {
    background: rgba(245,158,11,.06); border-top: 1px solid var(--border);
    padding: 10px 14px; font-size: .84rem; color: var(--text-muted);
    line-height: 1.5;
}
.critic-notes strong { color: var(--warning); }

/* ──── Draft meta row ──── */
.draft-meta {
    display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}

/* ──── Hidden status ──── */
.status-hidden { background: rgba(75,85,99,.18); color: #9ca3af; }

/* ──── State Folders view ──── */
.state-folder {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 10px;
    overflow: hidden;
}
.state-folder[open] > .state-folder-header { border-bottom: 1px solid var(--border); }
.state-folder-header {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; cursor: pointer;
    font-weight: 600; font-size: .95rem;
    transition: background .15s;
    list-style: none;
    user-select: none;
}
.state-folder-header::-webkit-details-marker { display: none; }
.state-folder-header::before {
    content: '▶'; font-size: .7rem; color: var(--text-muted);
    transition: transform .2s; flex-shrink: 0;
}
.state-folder[open] > .state-folder-header::before { transform: rotate(90deg); }
.state-folder-icon { font-size: 1.1rem; }
.state-folder-name { flex-shrink: 0; }
.state-folder-count {
    background: var(--primary); color: #fff;
    padding: 1px 8px; border-radius: 10px;
    font-size: .72rem; font-weight: 700;
}
.state-folder-stats {
    color: var(--text-muted); font-size: .8rem; font-weight: 400;
    margin-left: auto;
}
.state-folder-body { padding: 4px 0; }
.folder-partner-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 16px 8px 42px;
    border-bottom: 1px solid rgba(42,46,62,.4);
    transition: background .1s;
    flex-wrap: wrap;
}
.folder-partner-row:last-child { border-bottom: none; }
.folder-partner-row:hover { background: var(--bg-card-hover); }
.folder-partner-name {
    font-weight: 600; font-size: .9rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 220px;
}
.folder-partner-meta {
    color: var(--text-muted); font-size: .78rem;
    white-space: nowrap; margin-left: auto;
}

/* ──── Contact timeline (partner page) ──── */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
    content: ''; position: absolute; left: 8px; top: 0; bottom: 0;
    width: 2px; background: var(--border);
}
.timeline-item { position: relative; margin-bottom: 16px; }
.timeline-item::before {
    content: ''; position: absolute; left: -20px; top: 4px;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--primary); border: 2px solid var(--bg-card);
}
.timeline-item.sent::before { background: var(--success); }
.timeline-item.filled::before { background: var(--warning); }
.timeline-item.error::before { background: var(--danger); }
.timeline-date { font-size: .75rem; color: var(--text-muted); }
.timeline-subject { font-weight: 600; font-size: .88rem; }
.timeline-status { font-size: .75rem; }

/* ──── Partner tags editor ──── */
.tags-section { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.tags-section .tag-badge { font-size: .8rem; padding: 3px 10px; }

/* ──── Toast helper ──── */
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }

/* ──── Testing page ──── */
.test-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 16px;
}
.test-panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.test-panel h3 { margin-bottom: 10px; }
.test-result {
    margin-top: 10px; padding: 10px; background: var(--bg-input);
    border-radius: var(--radius-sm); font-size: .85rem;
    max-height: 200px; overflow-y: auto; white-space: pre-wrap;
    font-family: 'Cascadia Code', 'SF Mono', monospace;
}

/* ──── Clickable stat cards ──── */
.hub-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 0;
    margin-bottom: 0;
}
.hub-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
}
.hub-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    overflow-x: auto;
    flex: 1;
}
.hub-header + .hub-tabs,
.hub-header ~ * { }
/* ──── email hub tab bar ──── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }
/* old hub-tab kept for compat */
.hub-tab {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 10px 18px; font-size: .88rem; font-weight: 500;
    color: var(--text-muted); border-bottom: 2px solid transparent;
    margin-bottom: -1px; white-space: nowrap;
    transition: color .15s, border-color .15s;
    background: none; border-top: none; border-left: none; border-right: none;
    font-family: var(--font); cursor: pointer;
}
.hub-tab:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.hub-tab.active { color: var(--text); border-bottom-color: var(--primary); }

/* ──── Responsive ──── */
@media (max-width: 900px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .detail-grid { grid-template-columns: 1fr; }
    .map-split { grid-template-columns: 1fr; height: auto; }
    .partner-grid { grid-template-columns: 1fr; }
    .dashboard-layout { flex-direction: column; }
    .filter-sidebar { width: 100%; min-width: 0; position: static; max-height: none; }
    .analytics-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
    .test-grid { grid-template-columns: 1fr; }
}

/* Cards use white bg — override text to dark */
.panel, .stat-card, .partner-card, .section-block,
.draft-card, .analytics-panel, .analytics-card,
.setup-step, .state-folder, .test-panel {
    color: var(--text-card);
}
.panel .text-muted, .stat-card .text-muted,
.partner-card .text-muted, .section-block .text-muted,
.draft-card .text-muted, .analytics-panel .text-muted,
.partner-card-footer,
.stat-label, .metric-label, .folder-partner-meta,
.batch-field label, .form-group label, .filter-group > label {
    color: var(--text-card-muted) !important;
}
.data-table th { color: var(--text-card-muted); background: var(--bg-card-hover); }
.data-table tr:hover td { background: var(--bg-card-hover); }
.panel h3, .partner-name, .partner-card-header,
.folder-partner-name, .section-title,
.metric-value, .analytics-value, .draft-header strong,
.test-panel h3 { color: #111111; }

/* Input fields inside white cards */
.panel .input-field, .section-block .input-field,
.settings-grid .input-field, .batch-controls .input-field,
.batch-controls select, .batch-controls input {
    background: #f8f8f8;
    border-color: #d0d0d0;
    color: #111111;
}
.panel .input-field:focus, .section-block .input-field:focus {
    border-color: var(--primary);
}
select option { background: #ffffff; color: #111111; }
a.stat-card-link {
    text-decoration: none; color: inherit;
    display: block;
}
a.stat-card-link:hover {
    text-decoration: none;
}

/* ──── Loading overlay ──── */
.loading-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 17, 23, .85);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
}
.loading-content { text-align: center; }
.dancing-guy {
    font-size: 5rem;
    animation: dance 0.6s ease-in-out infinite alternate;
}
@keyframes dance {
    0%   { transform: translateY(0) rotate(-5deg); }
    50%  { transform: translateY(-18px) rotate(5deg) scaleX(-1); }
    100% { transform: translateY(0) rotate(-5deg); }
}

/* ╔═══════════════════════════════════════════════════════════════════
   Light Theme
   ╚═══════════════════════════════════════════════════════════════════ */
body.light {
    --bg:            #f2f2f7;
    --card-bg:       #ffffff;
    --bg-card:       #ffffff;
    --bg-card-hover: #f5f5f8;
    --bg-input:      #e8e8ed;
    --border:        #d8d8de;
    --text:          #1c1c1e;
    --text-card:     #1c1c1e;
    --text-card-muted: #5a5a62;
    --text-muted:    #7a7a82;
    --text-secondary: #4a4a52;
    --input-bg:      #e8e8ed;
    --primary:       #e4002b;
    background:      #f2f2f7;
}
body.light .sidebar {
    background: #ffffff;
    border-right-color: #d8d8de;
}
body.light .sidebar-logo {
    border-bottom-color: #d8d8de;
}
body.light .sidebar-logo-text { color: #1c1c1e; }
body.light .sidebar-logo-sub  { color: #7a7a82; }
body.light .nav-link {
    color: #5a5a62;
}
body.light .nav-link:hover,
body.light .nav-link.active {
    background: rgba(228,0,43,0.09);
    color: #1c1c1e;
}
body.light .sidebar-footer {
    border-top-color: #d8d8de;
    color: #5a5a62;
}
body.light .sidebar-gmail      { color: #16a34a; }
body.light .sidebar-gmail.disconnected { color: #7a7a82; }
body.light #hermesUserWidget   { border-top-color: #d8d8de; }
body.light #hermesUserWidget:hover { background: rgba(0,0,0,.04); }
body.light #hermesUserName     { color: #1c1c1e !important; }
body.light #scrapePill         { background: #eeeeff; border-top-color: #d8d8de; color: #5046c8; }
body.light #globalFillBar      { border-top-color: #d8d8de; }
body.light .nav-archives-toggle { border-top-color: #d8d8de; color: #7a7a82; }
body.light .badge { color: #fff; }
body.light .main-content { background: #f2f2f7; }
.loading-text { font-size: 1.3rem; font-weight: 600; margin-top: 12px; }
.loading-sub { color: var(--text-muted); font-size: .9rem; margin-top: 6px; }

/* Progress bar */
.progress-container { margin-top: 18px; width: 320px; }
.progress-bar-track {
    width: 100%; height: 10px;
    background: rgba(255,255,255,.12);
    border-radius: 5px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--accent), #6ee7b7);
    border-radius: 5px;
    transition: width .3s ease;
}
.progress-label {
    text-align: center; margin-top: 6px;
    font-size: .8rem; color: var(--text-muted);
}
/* ═══════════════════════════════════════════════════════
   Morning Briefing Bar
   ═══════════════════════════════════════════════════════ */
.briefing-bar {
    display: flex;
    align-items: center;
    gap: 28px;
    flex-wrap: wrap;
    background: linear-gradient(135deg, #232326 0%, #1c1c1f 100%);
    border: 1px solid #333336;
    border-left: 4px solid var(--primary);
    border-radius: var(--radius);
    padding: 22px 26px;
    margin-bottom: 20px;
    color: var(--text);
    box-shadow: 0 2px 16px rgba(0,0,0,.2);
}
.briefing-greeting {
    font-size: 1rem;
    font-weight: 600;
    color: #f0f0f0;
    min-width: 160px;
    letter-spacing: -0.01em;
}
.briefing-stats {
    display: flex;
    gap: 28px;
    flex: 1;
    flex-wrap: wrap;
}
.briefing-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: 64px;
}
.bstat-number {
    font-size: 1.8rem;
    font-weight: 700;
    color: #f0f0f0;
    line-height: 1;
    letter-spacing: -0.03em;
}
.bstat-label {
    font-size: 0.64rem;
    color: #777;
    text-transform: uppercase;
    letter-spacing: .07em;
    white-space: nowrap;
}
.bstat-link {
    font-size: 0.68rem;
    color: var(--primary);
    text-decoration: none;
    margin-top: 2px;
}
.bstat-green .bstat-number  { color: #34d399; }
.bstat-amber .bstat-number  { color: var(--warning); }
.bstat-purple .bstat-number { color: var(--primary); }
.bstat-red .bstat-number    { color: #f87171; }
.btn-review-send {
    margin-left: auto;
    padding: 9px 22px;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background .15s, box-shadow .15s;
    box-shadow: 0 2px 8px rgba(228,0,43,.3);
}
.btn-review-send:hover { background: var(--primary-hover); box-shadow: 0 4px 16px rgba(228,0,43,.4); }

/* ═══════════════════════════════════════════════════════
   Section blocks (templates, batch send)
   ═══════════════════════════════════════════════════════ */
.section-block {
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
    color: var(--text-card);
    box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.section-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}
.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: #111111;
}
.section-count {
    font-size: 0.78rem;
    color: var(--text-card-muted);
    background: #f0f0f0;
    border-radius: 20px;
    padding: 1px 8px;
    margin-left: 6px;
}
.btn-action-sm {
    padding: 6px 14px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.82rem;
    cursor: pointer;
    transition: border-color .15s, color .15s;
}
.btn-action-sm:hover { border-color: var(--primary); color: var(--text-card); }
.btn-secondary-sm {
    padding: 4px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.78rem;
    cursor: pointer;
}
.empty-state-msg {
    color: var(--text-card-muted);
    font-size: 0.88rem;
    padding: 16px 0;
}

/* ═══════════════════════════════════════════════════════
   Template cards
   ═══════════════════════════════════════════════════════ */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
}
.tmpl-card {
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: var(--text-card);
}
.tmpl-card.status-approved { border-color: var(--success); }
.tmpl-card.status-rejected { opacity: .45; }
.tmpl-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.tmpl-tier {
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
}
.tier-small  { background: #1e3a5f; color: #60a5fa; }
.tier-mid    { background: #3b1f5e; color: #a78bfa; }
.tier-large  { background: #1f3b2e; color: #34d399; }
.tmpl-market { font-size: 0.72rem; color: var(--text-muted); }
.tmpl-status-badge { font-size: 0.72rem; color: var(--text-muted); margin-left: auto; }
.tmpl-subject {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-card);
}
.tmpl-body {
    font-size: 0.8rem;
    color: #333333;
    white-space: pre-wrap;
    line-height: 1.6;
    max-height: 160px;
    overflow-y: auto;
    background: #f4f4f5;
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: 6px;
}
.tmpl-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
}
.btn-approve {
    background: #064e3b;
    color: #34d399;
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
}
.btn-approve:hover { background: #065f46; }
.btn-reject {
    background: #3b0f0f;
    color: #f87171;
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
}
.btn-reject:hover { background: #7f1d1d; }
.approved-badge { color: var(--success); font-size: 0.8rem; font-weight: 600; }
.rejected-badge { color: var(--danger);  font-size: 0.8rem; font-weight: 600; }

/* Email Studio badges on template cards */
.studio-badge {
    background: rgba(99,102,241,.15);
    color: #a5b4fc;
    border: 1px solid rgba(99,102,241,.3);
    padding: 1px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}
.legacy-badge {
    background: rgba(100,116,139,.12);
    color: var(--text-muted);
    border: 1px solid rgba(100,116,139,.25);
    padding: 1px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
}
.tmpl-card.tmpl-legacy { opacity: 0.72; }
.tmpl-card.tmpl-legacy:hover { opacity: 1; }

/* A/B group wrapper */
.ab-group { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.ab-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.ab-variant-count { font-size: 0.72rem; color: var(--text-muted); margin-left: auto; }
/* Stats row */
.ab-stats-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.ab-stat-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 0.72rem;
    color: var(--text-muted);
}
.ab-label {
    background: #3b82f6;
    color: #fff;
    border-radius: 20px;
    padding: 0 7px;
    font-weight: 700;
    font-size: 0.68rem;
}
.ab-reply-rate { color: #34d399; font-weight: 600; }
/* Variant badge on card */
.ab-badge {
    background: #1e3a5f;
    color: #93c5fd;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
}

/* ═══════════════════════════════════════════════════════
   Email score badges
   ═══════════════════════════════════════════════════════ */
.score-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}
.score-a    { background: #064e3b; color: #34d399; }   /* ≥80 green  */
.score-b    { background: #1e3a5f; color: #60a5fa; }   /* ≥60 blue   */
.score-c    { background: #422006; color: #fb923c; }   /* ≥40 amber  */
.score-d    { background: #3b0f0f; color: #f87171; }   /* ≥1  red    */
.score-none { background: #1e293b; color: #475569; }   /* 0   grey   */

.drawer-score-section {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 12px;
}
.drawer-score-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* ═══════════════════════════════════════════════════════
   Batch controls
   ═══════════════════════════════════════════════════════ */
.batch-controls {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.batch-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.batch-field label {
    font-size: 0.72rem;
    color: var(--text-card-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}
.batch-progress {
    margin-top: 12px;
    padding: 10px 14px;
    background: #f5f5f5;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--text-card-muted);
    border: 1px solid #e8e8e8;
}

/* ═══════════════════════════════════════════════════════
   Data Health Bar
   ═══════════════════════════════════════════════════════ */
.health-bar-wrap {
    background: linear-gradient(135deg, #232326 0%, #1e1e21 100%);
    border: 1px solid #333336;
    border-radius: var(--radius);
    padding: 14px 20px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: var(--text);
}
.health-bar-label {
    font-size: 0.82rem;
    color: #999;
}
.health-bar-label strong { color: #f0f0f0; }
.health-warn { color: var(--warning); }
.health-bar-track {
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}
.health-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), #34d399);
    border-radius: 4px;
    transition: width .4s ease;
}
.health-bar-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.hleg {
    font-size: 0.75rem;
    color: #888;
}
.hleg-email { color: #1a6fdb; }
.hleg-form  { color: #00a846; }
.hleg-none  { color: #999999; }
.hleg-btn {
    background: transparent;
    border: 1px solid #444;
    border-radius: var(--radius-sm);
    color: var(--warning);
    font-size: 0.72rem;
    padding: 2px 10px;
    cursor: pointer;
    margin-left: auto;
    transition: border-color .15s;
}
.hleg-btn:hover  { border-color: var(--warning); }
.hleg-btn:disabled { color: #555; cursor: default; }
.hleg-btn-danger { color: var(--danger); }
.hleg-btn-danger:hover { border-color: var(--danger); }

/* ── Inbox / Logs two-panel layout ─────────────────────────────────── */
.inb-layout {
  display: flex;
  height: calc(100vh - 200px);
  min-height: 520px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 4px;
}

/* LEFT sidebar */
.inb-sidebar {
  width: 310px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: #fafafa;
  color: #111111;
}
.inb-sidebar-head {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.inb-search {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: #111111;
  font-size: 0.875rem;
}
.inb-search:focus { outline: none; border-color: var(--primary); }
.inb-filters { display: flex; flex-wrap: wrap; gap: 4px; }
.inb-list { flex: 1; overflow-y: auto; }

/* Conversation cards */
.conv-card {
  padding: 10px 13px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  border-left: 3px solid transparent;
  background: #fafafa;
  color: #111111;
}
.conv-card:hover { background: #eeeeee; }
.conv-card.active {
  background: #eeeeee;
  border-left-color: var(--primary);
}
.conv-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}
.conv-name {
  font-weight: 700;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  color: #111111;
}
.conv-date  { font-size: 0.72rem; color: #555555; white-space: nowrap; }
.conv-subject {
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
  color: #555555;
}
.conv-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.conv-badge {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 20px;
  font-weight: 500;
}
.conv-badge-sent     { background: #e8f4fd; color: #1565c0; }
.conv-badge-replied  { background: #e8f8f0; color: #1b7a45; }
.conv-badge-unread   { background: var(--primary); color: #fff; font-weight: 700; }
.conv-badge-followup { background: #fef3e0; color: #8a4f00; }

/* RIGHT thread panel */
.inb-thread-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.inb-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}
.inb-thread-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
  color: #111111;
  flex-shrink: 0;
}
.inb-thread-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Message bubbles */
.thread-msg-out,
.thread-msg-in {
  max-width: 82%;
  border-radius: 8px;
  padding: 12px 14px;
  background: #fafafa;
  color: #111111;
}
.thread-msg-out {
  align-self: flex-end;
  border-left: 3px solid var(--primary);
}
.thread-msg-in {
  align-self: flex-start;
  border-left: 3px solid #22c55e;
}
.thread-msg-bounce {
  align-self: flex-start;
  max-width: 82%;
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff5f5;
  color: #7f1d1d;
  border-left: 3px solid #ef4444;
}
.thread-msg-label {
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
  color: #555555;
}
.msg-time { font-weight: 400; opacity: 0.75; }
.thread-msg-subject {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #111111;
}
.thread-msg-body {
  font-size: 0.8125rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: #111111;
  max-height: 320px;
  overflow-y: auto;
  line-height: 1.5;
}