/* Theme variables */
:root {
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;

    --bg-page: transparent;
    --bg-card: rgba(255, 255, 255, 0.65);
    --bg-card-header: rgba(255, 255, 255, 0.4);
    --bg-input: rgba(255, 255, 255, 0.7);
    --bg-table-header: #f9fafb;
    --bg-code: #eee;
    --bg-progress: #e5e7eb;
    --bg-flash-error: #fee;
    --bg-flash-success: #efe;
    --bg-warning: #fefce8;
    --bg-warning-border: #fbbf24;

    --text-primary: #1a1a2e;
    --text-secondary: #666;
    --text-muted: #888;
    --text-light: #555;
    --text-link: var(--color-primary);

    --border-color: #ccc;
    --border-light: #eee;
    --border-tabs: #e5e7eb;

    --shadow-card: 0 4px 30px rgba(0, 0, 0, 0.08);
    --glass-blur: blur(16px);
    --glass-border: 1px solid rgba(255, 255, 255, 0.4);

    --navbar-bg: #1a1a2e;

    --btn-secondary-bg: #e5e7eb;
    --btn-secondary-text: #374151;
    --btn-secondary-hover: #d1d5db;

    --flash-error-text: #c33;
    --flash-error-border: #fcc;
    --flash-success-text: #363;
    --flash-success-border: #cec;

    --badge-processing-bg: #dbeafe;
    --badge-done-bg: #dcfce7;
    --badge-error-bg: #fee2e2;

    --general-contacts-text: #444;
    --general-contacts-heading: #555;

    --log-bg: #1a1a2e;
    --log-text: #c9d1d9;

    --bg-subtle: #f8fafc;
    --bg-hover: #f1f5f9;
    --card-bg: #fff;
}

[data-theme="dark"] {
    --color-primary: #3b82f6;
    --color-primary-hover: #2563eb;

    --bg-page: transparent;
    --bg-card: rgba(31, 41, 55, 0.55);
    --bg-card-header: rgba(31, 41, 55, 0.4);
    --bg-input: rgba(55, 65, 81, 0.6);
    --bg-table-header: #263040;
    --bg-code: #374151;
    --bg-progress: #374151;
    --bg-flash-error: #3b1a1a;
    --bg-flash-success: #1a3b1a;

    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #a1a1aa;
    --text-light: #9ca3af;
    --text-link: var(--color-primary);

    --border-color: #4b5563;
    --border-light: #374151;
    --border-tabs: #374151;

    --shadow-card: 0 4px 30px rgba(0, 0, 0, 0.3);
    --glass-blur: blur(16px);
    --glass-border: 1px solid rgba(255, 255, 255, 0.08);

    --navbar-bg: #0f172a;

    --btn-secondary-bg: #374151;
    --btn-secondary-text: #e5e7eb;
    --btn-secondary-hover: #4b5563;

    --flash-error-text: #fca5a5;
    --flash-error-border: #7f1d1d;
    --flash-success-text: #86efac;
    --flash-success-border: #14532d;

    --badge-processing-bg: #1e3a5f;
    --badge-done-bg: #14532d;
    --badge-error-bg: #7f1d1d;

    --general-contacts-text: #d1d5db;
    --general-contacts-heading: #9ca3af;

    --log-bg: #0f172a;
    --log-text: #c9d1d9;
    --bg-warning: #1c1400;
    --bg-warning-border: #92400e;

    --bg-subtle: #1e2532;
    --bg-hover: #263040;
    --card-bg: rgba(31, 41, 55, 0.55);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: transparent;
    color: var(--text-primary);
    line-height: 1.6;
    transition: color 0.2s;
}

/* Animated gradient background */
#glass-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--color-primary) 12%, white) 0%,
        color-mix(in srgb, var(--color-primary) 5%, #f5f7fa) 25%,
        color-mix(in srgb, var(--color-primary) 20%, white) 50%,
        color-mix(in srgb, var(--color-primary) 10%, #d0e1f0) 75%,
        color-mix(in srgb, var(--color-primary) 8%, #fef1f6) 100%);
    background-size: 400% 400%;
    animation: glass-bg-shift 20s ease infinite;
}
[data-theme="dark"] #glass-bg {
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--color-primary) 12%, #0f172a) 0%,
        color-mix(in srgb, var(--color-primary) 8%, #1a1025) 25%,
        color-mix(in srgb, var(--color-primary) 18%, #0f172a) 50%,
        color-mix(in srgb, var(--color-primary) 8%, #1a1025) 75%,
        color-mix(in srgb, var(--color-primary) 6%, #150a20) 100%);
    background-size: 400% 400%;
}
@keyframes glass-bg-shift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
}

.hidden { display: none !important; }

/* Navbar */
.navbar {
    background: rgba(26, 26, 46, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 0.75rem 0;
    margin-bottom: 2rem;
    position: relative;
    z-index: 50;
}
.navbar .container { display: flex; justify-content: space-between; align-items: center; }
.nav-brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.nav-right { display: flex; align-items: center; gap: 1rem; }
.nav-user { color: #a0a0b0; font-size: 0.9rem; }
.nav-link { color: #7eb8f7; text-decoration: none; font-size: 0.9rem; }
.nav-link:hover { text-decoration: underline; }

/* Hamburger button (hidden on desktop) */
.nav-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
    z-index: 51;
}
.nav-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
/* Animate to X when open */
.nav-hamburger--open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger--open span:nth-child(2) { opacity: 0; }
.nav-hamburger--open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 640px) {
    .nav-hamburger { display: flex; }
    .nav-right {
        display: none;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        background: rgba(26, 26, 46, 0.97);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        padding: 1rem 1.5rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        z-index: 50;
    }
    .nav-right.nav-open { display: flex; }
    [data-theme="dark"] .nav-right { background: rgba(15, 23, 42, 0.97); }
}

/* Theme toggle */
.theme-toggle {
    background: none;
    border: none;
    color: #a0a0b0;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.2rem;
    line-height: 1;
    transition: color 0.15s;
}
.theme-toggle:hover { color: #fff; }

/* Flash messages */
.flash-messages { margin-bottom: 1rem; }
.flash {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}
.flash-error { background: var(--bg-flash-error); color: var(--flash-error-text); border: 1px solid var(--flash-error-border); }
.flash-success { background: var(--bg-flash-success); color: var(--flash-success-text); border: 1px solid var(--flash-success-border); }

/* Auth pages */
.auth-container {
    max-width: 400px;
    margin: 3rem auto;
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
}
.auth-container h1 { margin-bottom: 1.5rem; font-size: 1.5rem; }
.auth-link { margin-top: 1rem; font-size: 0.9rem; color: var(--text-secondary); }
.auth-link a { color: var(--text-link); }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
    font-size: 0.9rem;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group textarea,
.form-control {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--bg-input);
    color: var(--text-primary);
}
.form-group input:focus,
.form-group textarea:focus,
.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1), inset 0 1px 2px rgba(255, 255, 255, 0.1);
}
.form-group.has-error input,
.form-group.has-error textarea {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}
.field-error {
    color: #dc2626;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}
.form-group textarea { resize: vertical; }
.form-group input[type="file"] { font-size: 0.9rem; }
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    position: relative;
}
.drop-zone:hover { border-color: var(--color-primary); }
.drop-zone.drag-over {
    border-color: var(--color-primary);
    background: rgba(37, 99, 235, 0.05);
}
.drop-zone-icon { font-size: 2rem; display: block; margin-bottom: 0.5rem; opacity: 0.6; }
.drop-zone-text { font-size: 0.9rem; color: var(--text-secondary); }
.drop-zone-browse { color: var(--text-link); font-weight: 600; }
.drop-zone-file {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}
.drop-zone-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0 1rem;
}
.form-group select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--bg-input);
    color: var(--text-primary);
}
.form-group select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1), inset 0 1px 2px rgba(255, 255, 255, 0.1);
}
.optional { color: var(--text-muted); font-weight: 400; }
.help-text { margin-top: 0.25rem; font-size: 0.8rem; color: var(--text-secondary); }
.help-text code { background: var(--bg-code); padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.8rem; }

.btn {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Loading spinner for submit/action buttons */
.btn-loading {
    position: relative;
    padding-right: 2.5rem;
    pointer-events: none;
}
.btn-loading::after {
    content: '';
    position: absolute;
    right: 0.75rem;
    top: 50%;
    margin-top: -7px;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.65s linear infinite;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn-secondary { background: var(--btn-secondary-bg); color: var(--btn-secondary-text); }
.btn-secondary:hover:not(:disabled) { background: var(--btn-secondary-hover); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-tabs);
}
.tab {
    padding: 0.5rem 1.25rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text-link); }
.tab.active { color: var(--text-link); border-bottom-color: var(--text-link); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Inner tabs (nested within a parent tab panel) */
.inner-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.25rem;
}
.inner-tab {
    padding: 0.35rem 1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.inner-tab:hover { color: var(--text-link); }
.inner-tab.active { color: var(--text-link); border-bottom-color: var(--text-link); }
.inner-tab-panel { display: none; }
.inner-tab-panel.active { display: block; }

/* Main page */
#form-section {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow-card);
    margin-bottom: 2rem;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
}
#form-section h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.subtitle { color: var(--text-secondary); margin-bottom: 0.6rem; font-size: 0.95rem; }

/* How-it-works toggle link */
.hiw-toggle {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 0.82rem;
    color: var(--text-link);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    white-space: nowrap;
}
.hiw-toggle:hover { opacity: 0.8; }

/* How-it-works panel */
.hiw-panel {
    background: var(--bg-card-header);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 1rem 1.1rem 0.75rem;
    margin-bottom: 1.25rem;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease, margin 0.3s ease;
}
.hiw-panel.hiw-hidden {
    max-height: 0 !important;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 0;
    pointer-events: none;
}
.hiw-steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.hiw-step {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.82rem;
    line-height: 1.4;
    color: var(--text-primary);
    position: relative;
    padding-left: 0;
}
.hiw-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.3rem;
    height: 1.3rem;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    margin-bottom: 0.1rem;
    flex-shrink: 0;
}
.hiw-icon {
    font-size: 1.2rem;
    line-height: 1;
    margin-bottom: 0.15rem;
}
.hiw-step strong { font-size: 0.85rem; }
.hiw-step span { color: var(--text-secondary); }
.hiw-dismiss {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.78rem;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    display: block;
    margin-left: auto;
}
.hiw-dismiss:hover { color: var(--text-secondary); }
@media (max-width: 640px) {
    .hiw-steps { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 380px) {
    .hiw-steps { grid-template-columns: 1fr; }
}

/* Results */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.results-header h2 { font-size: 1.3rem; }
.results-actions { display: flex; gap: 0.5rem; align-items: center; }
.export-group { display: flex; gap: 0; }
.export-group .btn { border-radius: 6px 0 0 6px; }
.export-select {
    padding: 0.6rem 0.5rem;
    border: 1px solid var(--border-color);
    border-left: none;
    border-radius: 0 6px 6px 0;
    font-size: 0.85rem;
    font-family: inherit;
    background: var(--bg-input);
    color: var(--text-primary);
    cursor: pointer;
}

/* Progress bar */
#progress-area {
    margin-bottom: 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: 8px;
    padding: 0.75rem;
}
.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 0.35rem;
}
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-progress);
    border-radius: 4px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}
.progress-fill.complete  { background: #16a34a; }
.progress-fill.stopping  { background: #d97706; transition: background 0.3s ease; }
.progress-fill.indeterminate {
    width: 35% !important;
    transition: none;
    animation: indeterminate-slide 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes indeterminate-slide {
    0%   { transform: translateX(-150%); }
    100% { transform: translateX(400%); }
}
/* Queue wait — active job mini-status card */
.queue-active-status { margin-top: 0.5rem; }
.queue-active-card {
    background: var(--bg-card-header);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 0.45rem 0.75rem 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.queue-active-label { display: block; margin-bottom: 0.3rem; }
.queue-active-bar-wrap {
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
}
.queue-active-bar {
    height: 100%;
    background: #16a34a;
    border-radius: 2px;
    transition: width 0.5s ease;
}
.progress-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.6;
}
.empty-state-text {
    font-size: 0.95rem;
}

/* Results filter */
#results-filter {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
#filter-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--bg-input);
    color: var(--text-primary);
}
#filter-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.filter-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Summary card */
#summary-card {
    background: var(--bg-card);
    border-radius: 8px;
    box-shadow: var(--shadow-card);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
}
.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    text-align: center;
}
.summary-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.summary-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}
.summary-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.summary-value.has-errors { color: #dc2626; }
.summary-value.all-found { color: #16a34a; }
@media (max-width: 600px) {
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Org cards */
.org-card {
    background: var(--bg-card);
    border-radius: 8px;
    box-shadow: var(--shadow-card);
    margin-bottom: 1rem;
    overflow: hidden;
    border-left: 4px solid var(--border-color);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: var(--glass-border);
    border-top: var(--glass-border);
    border-bottom: var(--glass-border);
}
.org-card.processing { border-left-color: var(--color-primary); }
.org-card.done { border-left-color: #16a34a; }
.org-card.error { border-left-color: #dc2626; }

.org-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-card-header);
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    user-select: none;
}
.org-card-header h3 { font-size: 1rem; }
.org-card-title { display: flex; align-items: center; gap: 0.5rem; }
.chevron {
    display: inline-block;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: transform 0.2s;
    transform: rotate(90deg);
}
.org-card.collapsed .chevron { transform: rotate(0deg); }
.org-card.collapsed .org-card-body { display: none; }
.org-card.collapsed .org-card-header { border-bottom: none; }

.status-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.status-badge.processing { background: var(--badge-processing-bg); color: #60a5fa; }
.status-badge.done { background: var(--badge-done-bg); color: #4ade80; }
.status-badge.error { background: var(--badge-error-bg); color: #f87171; }

/* Save-status badge — shown inline in contact name cell during live batch runs */
.save-status-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    vertical-align: middle;
    margin-left: 0.4rem;
}
.save-new      { background: #dcfce7; color: #166534; }
.save-updated  { background: #dbeafe; color: #1e40af; }
.save-existing { background: var(--surface-2, #2a2a2e); color: var(--text-muted, #9ca3af); }

/* Contact count badge shown in collapsed org card header */
.contact-count-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--badge-done-bg);
    color: #4ade80;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    margin-left: 0.35rem;
    vertical-align: middle;
    white-space: nowrap;
}
.org-card.error .contact-count-badge { display: none; }

/* Live counter below multi-org textarea */
.multi-org-count {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    min-height: 1.1em;
}

/* Large-batch confirmation card */
.batch-confirm {
    background: var(--bg-warning);
    border: 1px solid var(--bg-warning-border);
    border-radius: 6px;
    padding: 0.875rem 1rem;
    margin-bottom: 0.75rem;
}
.batch-confirm-msg {
    font-size: 0.9rem;
    margin: 0 0 0.625rem;
    line-height: 1.4;
}
.batch-confirm-actions {
    display: flex;
    gap: 0.5rem;
}

/* Org counter chip in Results heading (#12) */
.org-counter-chip {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-card-header);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 0.1rem 0.55rem;
    vertical-align: middle;
    margin-left: 0.35rem;
    letter-spacing: 0.01em;
}

/* Summary stats icons (#13) */
.summary-icon {
    font-size: 1.25rem;
    line-height: 1;
    display: block;
    margin-bottom: 0.1rem;
}

/* Contact priority P1/P2 badges (#15) */
.priority-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 3px;
    padding: 0.05rem 0.3rem;
    margin-right: 0.3rem;
    vertical-align: middle;
    line-height: 1.4;
    letter-spacing: 0.03em;
}
.p1-badge {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}
.p2-badge {
    background: #fefce8;
    color: #a16207;
    border: 1px solid #fde047;
}
[data-theme="dark"] .p1-badge {
    background: #14532d;
    color: #86efac;
    border-color: #16a34a;
}
[data-theme="dark"] .p2-badge {
    background: #1c1400;
    color: #fde047;
    border-color: #ca8a04;
}

/* Admin panel badge dark mode overrides */
[data-theme="dark"] .badge-success {
    background: #14532d;
    color: #86efac;
    border-color: #166534;
}
[data-theme="dark"] .badge-muted {
    background: var(--bg-subtle);
    color: var(--text-muted);
    border-color: var(--border-color);
}
[data-theme="dark"] .badge-warn,
[data-theme="dark"] .badge-warning {
    background: #1c1400;
    color: #fde047;
    border-color: #ca8a04;
}
[data-theme="dark"] .badge-pending {
    background: #1c1400;
    color: #fcd34d;
    border-color: #92400e;
}
[data-theme="dark"] .api-badge-active { background: #14532d; color: #86efac; }
[data-theme="dark"] .api-badge-warn   { background: #1c1400; color: #fde047; }
[data-theme="dark"] .api-badge-dim    { background: #1e2532; color: #94a3b8; }
[data-theme="dark"] .api-badge-none   { background: #1e2532; color: #6b7280; font-style: italic; }

.org-card-body { padding: 1rem; }
.skeleton-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.skeleton-line {
    height: 0.75rem;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--bg-progress) 25%, var(--bg-card-header) 50%, var(--bg-progress) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.found-url { margin-bottom: 0.75rem; font-size: 0.9rem; }
.found-url a { color: var(--text-link); }
.no-matches { color: var(--text-muted); font-style: italic; }
.error-text { color: #dc2626; }

/* Contacts table */
.table-wrap { overflow-x: auto; margin-bottom: 0.75rem; -webkit-overflow-scrolling: touch; }
.contacts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    table-layout: fixed;
}
.contacts-table th, .contacts-table td {
    text-align: left;
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid var(--border-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.contacts-table th { background: var(--bg-table-header); font-weight: 700; white-space: nowrap; }
/* Column widths for 8-col layout: Name, Role, Title, Email(icon), Valid, Phone(icon), Conf, [HubSpot] */
.contacts-table .col-name  { width: 18%; }
.contacts-table .col-role  { width: 14%; }
.contacts-table .col-title { width: 21%; }
.contacts-table .col-icon  { width: 4%; text-align: center; overflow: visible; position: relative; }
.contacts-table thead .col-icon { font-size: 1.5rem; }
.contacts-table thead .col-email-icon { font-size: 2rem; vertical-align: top; }
.contacts-table .col-valid { width: 7%; text-align: center; }
.contacts-table .col-conf  { width: 10%; }
.contacts-table .col-hs    { width: 8%; text-align: center; }
/* Center only the icon/action/numeric column headers */
.contacts-table th.col-icon,
.contacts-table th.col-valid,
.contacts-table th.col-conf,
.contacts-table th.col-hs { text-align: center; vertical-align: middle; }
/* Email cell icon size (1.6× phone icon to match header proportion) */
.copy-btn.email-icon { font-size: 2rem; }
.copy-btn.icon-only.email-icon { font-size: 2rem; }
/* Email validation status icons */
.email-status-icon { font-size: 1rem; font-weight: 700; cursor: default; }
.es-valid   { color: #16a34a; }
.es-risky   { color: #f97316; }
.es-invalid { color: #dc2626; }
.es-unknown { color: #0091ae; }
/* Verify-email button — same visual style as HubSpot Send button */
.verify-email-btn {
    display: inline-block;
    padding: 3px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid #0091ae;
    background: #fff;
    color: #0091ae;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.verify-email-btn:hover:not(:disabled) { background: #0091ae; color: #fff; }
.verify-email-btn:disabled { opacity: 0.6; cursor: default; }
/* Icon tooltip wrapper — hover reveals value */
.contact-tooltip-wrap { position: relative; display: inline-block; }
.contact-tooltip-wrap::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #222;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s;
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.contact-tooltip-wrap:hover::after { opacity: 1; visibility: visible; }
.copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0 0.2rem;
    color: var(--text-muted);
    vertical-align: middle;
    line-height: 1;
}
.copy-btn:hover { color: var(--text-link); }
/* Icon-only copy button used in col-icon cells */
.copy-btn.icon-only { font-size: 1rem; padding: 0; }
.sortable-th { cursor: pointer; user-select: none; }
.sortable-th:hover { color: var(--text-link); }
.sort-arrow { font-size: 0.7em; color: var(--text-muted); }
.contacts-table td a { color: var(--text-link); }
.guessed { color: var(--text-muted); font-size: 0.8em; }
.priority-1 { font-weight: 700; color: #16a34a; }
.priority-2 { color: #ca8a04; }
.conf-bar-wrap {
    width: 100%;
    height: 6px;
    background: var(--bg-progress);
    border-radius: 3px;
    overflow: hidden;
    min-width: 50px;
}
.conf-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}
.conf-bar-fill.conf-high { background: #16a34a; }
.conf-bar-fill.conf-med { background: #ca8a04; }
.conf-bar-fill.conf-low { background: #dc2626; }
.conf-label {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.1rem;
    display: inline-block;
}
.conf-high { color: #16a34a; }
.conf-med { color: #ca8a04; }
.conf-low { color: #dc2626; }

/* Collapsible sections */
details { margin-top: 0.5rem; }
details summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 600;
    padding: 0.25rem 0;
}
details summary:hover { color: var(--text-link); }

/* Supporting details (form collapsible) */
details.supporting-details { margin-bottom: 1rem; }
details.supporting-details summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding: 0.5rem 0;
}
details.supporting-details summary:hover { color: var(--text-link); }
details.supporting-details .details-body { padding-top: 0.5rem; }
.general-contacts-body { padding: 0.5rem 0 0 1rem; font-size: 0.85rem; }
.general-contacts-body h5 { margin: 0.5rem 0 0.25rem; font-size: 0.8rem; color: var(--general-contacts-heading); text-transform: uppercase; letter-spacing: 0.05em; }
.general-contacts-body ul { list-style: none; }
.general-contacts-body li { padding: 0.1rem 0; color: var(--general-contacts-text); }

.log-output {
    background: var(--log-bg);
    color: var(--log-text);
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    line-height: 1.4;
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 0.5rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Live processing log inside org cards */
.live-log {
    background: var(--log-bg);
    color: var(--log-text);
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 0.5rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Live log (collapsible, during processing) */
.live-log-section summary {
    cursor: pointer;
    font-size: 0.8rem;
    color: #64748b;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.live-log-section summary:hover { color: #334155; }
.live-log-section .log-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    flex-shrink: 0;
}
.live-log-section.log-active .log-dot {
    background: #22c55e;
    animation: log-pulse 1.2s ease-in-out infinite;
}
@keyframes log-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
    50%      { opacity: 0.7; box-shadow: 0 0 0 4px rgba(34,197,94,0); }
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-width: 380px;
    word-break: break-word;
    opacity: 0.75;
    animation: toast-in 0.25s ease-out;
    transition: opacity 0.3s, transform 0.3s;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.toast:hover {
    opacity: 1;
}
.toast.toast-removing {
    opacity: 0;
    transform: translateX(100%);
}
.toast-error {
    background: rgba(220, 38, 38, 0.85);
    color: #fff;
}
.toast-success {
    background: rgba(22, 163, 74, 0.85);
    color: #fff;
}
.toast-warning {
    background: rgba(202, 138, 4, 0.85);
    color: #fff;
}
.toast-info {
    background: rgba(26, 26, 46, 0.85);
    color: #fff;
}
@keyframes toast-in {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 0.75; transform: translateX(0); }
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}
.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    padding: 0.5rem 1rem;
    background: var(--text-link);
    color: #fff;
    z-index: 1000;
    display: inline-block;
    font-weight: 600;
    text-decoration: none;
    border-radius: 4px;
}
:focus-visible {
    outline: 2px solid var(--text-link);
    outline-offset: 2px;
}

/* Password strength meter */
.pw-strength {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.4rem;
}
.pw-strength-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-progress);
    border-radius: 3px;
    overflow: hidden;
}
.pw-strength-fill {
    height: 100%;
    width: 0;
    border-radius: 3px;
    transition: width 0.25s, background 0.25s;
}
.pw-strength-fill.pw-weak   { background: #dc2626; }
.pw-strength-fill.pw-fair   { background: #ca8a04; }
.pw-strength-fill.pw-good   { background: var(--color-primary); }
.pw-strength-fill.pw-strong { background: #16a34a; }
.pw-strength-label {
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 3.5rem;
    text-align: right;
}
.pw-weak   + .pw-strength-label, .pw-strength-label:empty { color: var(--text-secondary); }

/* Password requirements checklist */
.pw-requirements {
    list-style: none;
    padding: 0;
    margin: 0.4rem 0 0;
    font-size: 0.8rem;
}
.pw-requirements li {
    padding: 0.15rem 0 0.15rem 1.2rem;
    position: relative;
    color: var(--text-secondary);
}
.pw-requirements li::before {
    position: absolute;
    left: 0;
    font-weight: 700;
}
.pw-requirements li.unmet::before { content: '\2715'; color: #dc2626; }
.pw-requirements li.met::before   { content: '\2713'; color: #16a34a; }
.pw-requirements li.met { color: #16a34a; }

/* Password match message */
.pw-match-msg {
    font-size: 0.8rem;
    margin-top: 0.3rem;
    font-weight: 600;
}
.pw-match-ok { color: #16a34a; }
.pw-match-no { color: #dc2626; }

/* Password visibility toggle */
.pw-field { position: relative; }
.pw-field input[type="password"],
.pw-field input[type="text"] { padding-right: 2.5rem; }
.pw-toggle {
    position: absolute;
    right: 0.45rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.2rem 0.3rem;
    display: flex;
    align-items: center;
    border-radius: 3px;
    line-height: 1;
}
.pw-toggle:hover { color: var(--text-primary); }
.pw-toggle:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 1px; }

/* Breadcrumb */
.breadcrumb { margin-bottom: 1rem; font-size: 0.85rem; }
.breadcrumb ol {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.breadcrumb li + li::before {
    content: '/';
    color: var(--text-secondary);
    margin-right: 0.35rem;
}
.breadcrumb a { color: var(--text-link); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .active { color: var(--text-secondary); }

/* Sound toggle */
.btn-icon { padding: 0.4rem 0.55rem; font-size: 1.1rem; line-height: 1; }

/* File preview */
.file-preview {
    margin-top: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    padding: 0.75rem;
}
.file-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.btn-link {
    background: none;
    border: none;
    color: var(--text-link);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0;
    text-decoration: underline;
}
.btn-link:hover { opacity: 0.8; }
.file-preview-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.85rem;
}
.file-preview-list li {
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
.file-preview-list li:last-child { border-bottom: none; }
.file-preview-loading { color: var(--text-secondary); font-style: italic; }
.file-preview-error { color: #dc2626; }

/* Responsive */
@media (max-width: 600px) {
    .org-card-header { flex-direction: column; gap: 0.25rem; align-items: flex-start; }
    .results-header { flex-direction: column; gap: 0.5rem; align-items: flex-start; }
    /* Make every contacts-table independently scrollable on narrow screens.
       display:block preserves internal table layout while allowing overflow-x. */
    .contacts-table {
        font-size: 0.8rem;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    /* Stack duplicate-comparison side-by-side panels vertically on mobile */
    .dup-row { flex-direction: column; }
}

/* Upload progress bar (#11) */
#upload-progress-wrap {
    margin-bottom: 0.75rem;
    display: none;
}
#upload-progress-wrap .upload-bar-track {
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.3rem;
}
#upload-progress-wrap .upload-bar-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 3px;
    transition: width 0.2s linear;
    width: 0%;
}
#upload-progress-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Active-batch banner (index page, admin only) */
.active-batch-banner {
    background: var(--bg-warning);
    border: 1px solid var(--bg-warning-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.88rem;
}
.active-batch-banner .abl-text { flex: 1; min-width: 0; }
.active-batch-banner .abl-bar-wrap {
    width: 100%;
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.35rem;
}
.active-batch-banner .abl-bar { height: 100%; background: var(--color-primary); border-radius: 2px; transition: width 0.4s ease; }

/* Admin active-batch card (admin panel) */
.admin-active-batch {
    background: var(--bg-card);
    border: 1px solid var(--color-primary);
    border-radius: 8px;
    padding: 0.85rem 1.1rem;
    margin: 0.75rem auto 0;
    max-width: 1100px;
    font-size: 0.88rem;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 20%, transparent);
}
.admin-active-batch h3 { margin: 0 0 0.5rem; font-size: 0.95rem; color: var(--color-primary); }
.aab-meta { color: var(--text-secondary); margin-bottom: 0.5rem; }
.aab-bar-wrap { height: 6px; background: var(--bg-input); border-radius: 3px; overflow: hidden; margin-bottom: 0.6rem; }
.aab-bar { height: 100%; background: var(--color-primary); border-radius: 3px; transition: width 0.4s ease; }
.aab-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Admin panel */
.admin-tab-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 100%;
    margin: 1rem auto 0;
    flex-wrap: wrap;
}
.admin-tab-bar .tabs {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;       /* Firefox */
    -ms-overflow-style: none;    /* IE/Edge */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    /* Fade-right hint that more tabs exist off-screen */
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 2rem), transparent 100%);
    mask-image: linear-gradient(to right, black calc(100% - 2rem), transparent 100%);
}
.admin-tab-bar .tabs::-webkit-scrollbar { display: none; }
.admin-tab-bar .tab { flex-shrink: 0; }
@media (max-width: 640px) {
    .admin-tab-bar { gap: 0.5rem; }
    .admin-back-btn { margin-left: auto; }
}
.admin-back-btn {
    white-space: nowrap;
    flex-shrink: 0;
}
.admin-panel { max-width: 1100px; margin-top: 0; }
.contacts-panel {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow-card);
    margin: 0 auto 2rem;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
}

.nav-badge {
    display: inline-block;
    background: #dc2626;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    padding: 0.15rem 0.45rem;
    border-radius: 10px;
    vertical-align: middle;
    margin-left: 0.2rem;
}

.admin-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}
.admin-section:last-of-type { border-bottom: none; }
.admin-section h2 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.admin-empty {
    color: var(--text-muted);
    font-style: italic;
}

.toggle-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.toggle-option {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    background: var(--bg-card);
    flex: 1;
    min-width: 160px;
}
.toggle-option:has(input:checked) {
    border-color: var(--text-link);
    background: var(--badge-processing-bg);
}
.toggle-option input[type="radio"] { margin-right: 0.3rem; }
.toggle-option span { font-weight: 600; font-size: 0.9rem; }
.toggle-option small { color: var(--text-muted); font-size: 0.78rem; }

.action-cell {
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
.btn-danger:hover { background: #b91c1c; }

.inline-reset-form {
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

.input-sm {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-primary);
    width: 140px;
}

.badge-pending {
    display: inline-block;
    font-size: 0.7rem;
    background: #fef3c7;
    color: #92400e;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    margin-left: 0.3rem;
    vertical-align: middle;
}

.keyword-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.78rem;
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    line-height: 1.3;
}
.keyword-tag-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    padding: 0 0.1rem;
}
.keyword-tag-delete:hover { color: #dc2626; }

/* Prompt block textarea */
.prompt-block-textarea {
    width: 100%;
    min-height: 60px;
    padding: 0.5rem 0.6rem;
    font-size: 0.85rem;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-primary);
    resize: vertical;
}
.prompt-block-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Context assignment checkboxes */
.context-checkbox-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.context-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text-primary);
}
.context-checkbox-label input[type="checkbox"] {
    margin: 0;
}

/* Settings page */
.settings-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-light);
}
.settings-section:last-of-type { border-bottom: none; }
.settings-section h2 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.setting-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.setting-description {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0.15rem 0 0;
}

.radio-group {
    display: flex;
    gap: 0.75rem;
}
.radio-option {
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text-primary);
}
.radio-option input { margin-right: 0.2rem; }

/* Toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--btn-secondary-bg);
    border-radius: 24px;
    transition: background 0.2s;
}
.toggle-slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--color-primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

.settings-actions {
    margin-top: 1rem;
    text-align: right;
}
.settings-status { font-size: .875rem; margin-left: .5rem; }
.settings-status.hidden { display: none !important; }
.text-success { color: var(--success-color, #28a745); }
.text-danger  { color: var(--danger-color,  #dc3545); }
.text-muted   { color: var(--text-muted); }

/* Settings page layout */
.settings-page {
    max-width: 640px;
    margin: 3rem auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Top-level collapsible panels (.sc-panel) */
.sc-panel {
    background: var(--bg-card);
    border: var(--glass-border);
    border-radius: 10px;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    overflow: hidden;
}
.sc-panel-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1rem 1.5rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: background .15s;
}
.sc-panel-header:hover { background: var(--bg-hover, var(--border-light)); }
.sc-panel-header::-webkit-details-marker { display: none; }
details.sc-panel[open] > .sc-panel-header { border-bottom: 1px solid var(--border-color); }
.sc-panel-title { font-size: 1.25rem; font-weight: 700; flex: 1; color: var(--text-primary); }
.sc-panel-chevron { font-size: .65rem; color: var(--text-muted); transition: transform .2s; line-height: 1; }
details.sc-panel[open] > .sc-panel-header .sc-panel-chevron { transform: rotate(180deg); }
.sc-panel-body { padding: 1.5rem; }

/* Collapsible settings cards (.sc) */
.sc {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: .625rem;
    overflow: hidden;
}
.sc-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .8rem 1rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
    background: var(--bg-secondary);
    transition: background .15s;
}
.sc-header:hover { background: var(--bg-hover, var(--border-light)); }
.sc-header::-webkit-details-marker { display: none; }
.sc-title { font-weight: 600; font-size: .9375rem; flex: 1; color: var(--text-primary); }
.sc-desc  { font-size: .8rem; color: var(--text-muted); }
.sc-chevron { font-size: .65rem; color: var(--text-muted); transition: transform .2s; line-height: 1; }
details[open] > .sc-header .sc-chevron { transform: rotate(180deg); }
.sc-badge {
    font-size: .7rem;
    font-weight: 600;
    padding: .15rem .5rem;
    border-radius: 99px;
    letter-spacing: .02em;
    text-transform: uppercase;
}
.sc-badge-on  { background: rgba(40,167,69,.15); color: var(--success-color, #28a745); }
.sc-badge-off { background: var(--bg-secondary); color: var(--text-muted); border: 1px solid var(--border-color); }
.sc-body {
    padding: 1.25rem 1rem;
    border-top: 1px solid var(--border-color);
}
.sc-divider { border: none; border-top: 1px solid var(--border-light); margin: 1rem 0; }
.sc-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: 1.25rem;
}

/* Branding logo */
.nav-logo { height: 28px; width: auto; margin-right: 0.5rem; vertical-align: middle; }
.login-logo { display: block; max-width: 240px; max-height: 240px; margin: 0 auto 1rem; }

/* Login logo: light mode shows dark logo, dark mode shows light logo.
   If only one variant exists it always shows (only-of-type override). */
.login-logo-light { display: none; }
.login-logo-dark { display: block; }
[data-theme="dark"] .login-logo-light { display: block; }
[data-theme="dark"] .login-logo-dark { display: none; }
.login-logo:only-of-type { display: block; }

/* Branding settings */
.color-picker-group { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.color-picker-group label { font-size: 0.9rem; font-weight: 600; min-width: 120px; }
.color-picker-group input[type="color"] {
    width: 48px; height: 32px; border: 1px solid var(--border-color);
    border-radius: 4px; cursor: pointer; padding: 2px; background: var(--bg-input);
}
.color-picker-group .color-hex { font-size: 0.8rem; color: var(--text-muted); font-family: monospace; }
.logo-preview { max-width: 80px; max-height: 80px; border-radius: 6px; border: 1px solid var(--border-light); margin-bottom: 0.5rem; }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 0;
    margin-bottom: 0.75rem;
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
}
.pagination-info { font-size: 0.85rem; color: var(--text-secondary); white-space: nowrap; }
.pagination-btns { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; }
.pagination-btns .btn { min-width: 2.25rem; text-align: center; }
.pagination-ellipsis { padding: 0 0.25rem; color: var(--text-muted); font-size: 0.9rem; line-height: 2rem; }
@media (max-width: 600px) {
    .pagination { justify-content: center; }
    .pagination-info { width: 100%; text-align: center; }
}

/* Job History page */
.history-table .num-col { text-align: right; width: 5rem; }
.history-table td, .history-table th { vertical-align: middle; }
.history-date { font-size: 0.85rem; white-space: nowrap; }
.history-source { max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.85rem; color: var(--text-secondary); }
.history-err-badge {
    display: inline-block;
    margin-left: 0.3rem;
    font-size: 0.7rem;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    background: var(--badge-error-bg);
    color: #f87171;
    white-space: nowrap;
}
.history-expand-btn { padding: 0 0.3rem; font-size: 0.85rem; color: var(--text-muted); }
.history-expand-btn .chevron { transition: transform 0.15s ease; }
.history-orgs-row td { padding: 0; background: var(--bg-card-header); }
.history-orgs-body { padding: 0.75rem 1rem; }
.history-orgs-loading { color: var(--text-muted); font-size: 0.85rem; padding: 0.5rem 0; }
.history-orgs-table { font-size: 0.82rem; margin: 0; table-layout: fixed; width: 100%; }
.history-orgs-table th, .history-orgs-table td { padding: 0.4rem 0.65rem; vertical-align: middle; }
.history-orgs-table tbody tr:nth-child(odd) { background: var(--bg-card-header); }
.history-orgs-table tbody tr:hover { background: var(--bg-hover, rgba(255,255,255,0.04)); }
.history-orgs-name { width: 30%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.history-orgs-status { width: 6rem; text-align: center; white-space: nowrap; }
.history-orgs-table .num-col { width: 5.5rem; text-align: right; }
.history-orgs-errcol { width: auto; }
.history-orgs-err { font-size: 0.8rem; color: #f87171; cursor: help; }
.history-url-cell { max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-url { font-size: 0.8rem; color: var(--text-link); }
.history-err { font-size: 0.8rem; color: #f87171; }

/* Print stylesheet */
@media print {
    /* Hide interactive / non-content elements */
    nav, .breadcrumb, #form-section, #progress-area, #results-filter,
    #toggle-all-btn, #export-group, #new-search-btn,
    #toast-container, #empty-state, .copy-btn, .chevron,
    .btn, .sort-arrow, #glass-bg { display: none !important; }

    /* Reset page background and remove shadows */
    body, .container, #results-section, .org-card {
        background: #fff !important;
        color: #000 !important;
        box-shadow: none !important;
    }

    /* Show results section */
    #results-section { display: block !important; }

    /* Expand all collapsed cards */
    .org-card.collapsed .org-card-body { display: block !important; }
    .org-card { break-inside: avoid; margin-bottom: 0.75rem; border: 1px solid #ccc; }

    /* Summary card */
    #summary-card {
        display: block !important;
        border: 1px solid #ccc;
        background: #fff !important;
        color: #000 !important;
    }
    .summary-stat { color: #000 !important; }
    .summary-value { color: #000 !important; }

    /* Tables */
    .contacts-table { width: 100%; border-collapse: collapse; }
    .contacts-table th, .contacts-table td {
        border: 1px solid #ccc;
        padding: 4px 8px;
        color: #000 !important;
        background: #fff !important;
    }
    .contacts-table th { font-weight: 600; cursor: default; }

    /* Confidence bar — show as text only */
    .conf-bar-wrap { background: none !important; }
    .conf-bar-fill { display: none; }
    .conf-label { color: #000 !important; }

    /* Status badges */
    .badge { border: 1px solid #666; color: #000 !important; background: #fff !important; }

    /* Links */
    a { color: #000 !important; text-decoration: underline; }

    /* Page margins */
    @page { margin: 1cm; }
    .hs-btn { display: none; }
}

/* --- HubSpot CRM button --- */
.hs-btn {
    display: inline-block;
    padding: 3px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid #0091ae;
    background: #fff;
    color: #0091ae;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.hs-btn:hover:not(:disabled) {
    background: #0091ae;
    color: #fff;
}
.hs-btn:disabled {
    opacity: 0.6;
    cursor: default;
}
.hs-btn-sent {
    border-color: #2e7d32;
    color: #2e7d32;
}
.hs-btn-sent:hover:not(:disabled) {
    background: #2e7d32;
    color: #fff;
}
.hs-btn-error {
    border-color: #c62828;
    color: #c62828;
}
.hs-btn-error:hover:not(:disabled) {
    background: #c62828;
    color: #fff;
}

/* --- Vendor integration cards (API tab) --- */
.vendor-card,
.crm-integration-card {
    border: 1px solid var(--border-color, #ddd);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 12px;
    background: var(--card-bg, #fff);
}
.vendor-card-header,
.crm-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.vendor-card-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
}
.crm-logo-label {
    font-size: 1rem;
    font-weight: 700;
    color: #ff7a59;
}
.crm-status-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}
.badge-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}
.badge-muted {
    background: var(--bg-subtle, #f5f5f5);
    color: var(--text-muted, #888);
    border: 1px solid var(--border-color, #ddd);
}
.badge-warn {
    background: #fef9c3;
    color: #854d0e;
    border: 1px solid #fde68a;
}
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #ccc;
    border-radius: 24px;
    transition: background 0.2s;
}
.toggle-slider:before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: #0091ae; }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); }

/* --- API Settings collapsible sections --- */
.api-section {
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
}
.api-section > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-subtle, #f8fafc);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    user-select: none;
    list-style: none;
    border-bottom: 1px solid transparent;
    transition: background 0.15s;
}
.api-section > summary:hover { background: var(--bg-hover, #f1f5f9); }
.api-section[open] > summary { border-bottom-color: var(--border-light, #e2e8f0); }
.api-section > summary::-webkit-details-marker { display: none; }
.api-section > summary::after { display: none; }
.api-section-right {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}
.api-section-badges {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
}
.api-chevron {
    font-size: 0.85rem;
    color: var(--text-muted, #64748b);
    transition: transform 0.2s;
    flex-shrink: 0;
    margin-left: 0.15rem;
}
.api-section[open] .api-chevron { transform: rotate(-180deg); }
.api-section-body {
    padding: 1rem 1rem 0.5rem;
}
.api-sub-heading {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 1.25rem 0 0.4rem;
    color: var(--text-primary, #1e293b);
}
.api-add-provider {
    border: 1px dashed var(--border-color, #ddd);
    border-radius: 6px;
    padding: 10px 12px;
    background: var(--bg-subtle, #f9f9f9);
    margin-top: 0.5rem;
}
.api-add-provider > summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    list-style: none;
    user-select: none;
}
.api-add-provider > summary::-webkit-details-marker { display: none; }

/* API status badges */
.api-status-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 3px;
    letter-spacing: 0.02em;
    white-space: nowrap;
    line-height: 1.4;
}
/* Badge alias used in history table */
.badge-warning { background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }
/* Top-level vendor cards need more breathing room than the default 12px */
.inner-tab-panel > .vendor-card,
.tab-panel > .vendor-card { margin-bottom: 1.25rem; }

.api-badge-active  { background: #dcfce7; color: #166534; }
.api-badge-warn    { background: #fef9c3; color: #854d0e; }
.api-badge-dim     { background: #f1f5f9; color: #475569; }
.api-badge-none    { background: #f1f5f9; color: #94a3b8; font-style: italic; }

/* --- API badge legend panel --- */
.api-legend {
    background: var(--bg-card-header);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.82rem;
}
.api-legend-title {
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.api-legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1.25rem;
    align-items: center;
}
.api-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}
.api-test-result {
    font-size: 0.82rem;
    display: inline-block;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* ── Mobile / responsive pass: main app + admin UI ─────────────────────── */

/* ≤ 768px : tablet */
@media (max-width: 768px) {
    .auth-container { margin: 2rem auto; }
    .settings-page  { margin: 2rem auto; }
}

/* ≤ 640px : large phone / small tablet */
@media (max-width: 640px) {
    /* Reduce glass-card padding */
    .auth-container         { margin: 1rem auto; padding: 1.5rem 1.25rem; }
    #form-section           { padding: 1.5rem 1.25rem; }
    .contacts-panel         { padding: 1.5rem 1.25rem; }
    .sc-panel-body          { padding: 1rem 1.25rem; }
    .sc-body                { padding: 1rem 0.875rem; }
    .settings-page          { margin: 1rem auto; }

    /* Main tabs — scrollable (matches admin tab bar) */
    .tabs {
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
        -webkit-overflow-scrolling: touch;
        -webkit-mask-image: linear-gradient(to right, black calc(100% - 2rem), transparent 100%);
        mask-image:         linear-gradient(to right, black calc(100% - 2rem), transparent 100%);
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab { flex-shrink: 0; }

    /* Inner tabs — scrollable */
    .inner-tabs {
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
        -webkit-overflow-scrolling: touch;
    }
    .inner-tabs::-webkit-scrollbar { display: none; }
    .inner-tab { flex-shrink: 0; }

    /* Results / progress controls wrap */
    .results-actions      { flex-wrap: wrap; }
    .progress-actions     { flex-wrap: wrap; }
    .batch-confirm-actions { flex-direction: column; }

    /* Progress area tighter */
    #progress-area { padding: 0.5rem 0.75rem; }

    /* Summary card tighter */
    #summary-card { padding: 1rem; }

    /* Vendor cards less padding */
    .vendor-card,
    .crm-integration-card { padding: 12px 14px; }

    /* Toggle group stacks */
    .toggle-group   { flex-direction: column; }
    .toggle-option  { min-width: unset; }

    /* Admin panel max-width full on mobile */
    .admin-panel    { max-width: 100%; }
}

/* ≤ 480px : narrow phone */
@media (max-width: 480px) {
    /* Stack label + control in settings rows */
    .setting-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    /* Smaller tab labels */
    .tab      { padding: 0.45rem 0.65rem; font-size: 0.82rem; }
    .inner-tab { padding: 0.3rem 0.75rem; font-size: 0.82rem; }

    /* Summary stat values slightly smaller */
    .summary-value { font-size: 1.3rem; }

    /* Toast moves to bottom edge */
    .toast-container {
        top: auto;
        bottom: 1rem;
        right: 0.75rem;
        left: 0.75rem;
        width: auto;
    }
    .toast { max-width: 100%; }

    /* Auth containers full-bleed border-radius */
    .auth-container { border-radius: 6px; }

    /* Export group — keep inline but handle radius */
    .export-group { flex-wrap: nowrap; }

    /* Color picker labels shorter */
    .color-picker-group label { min-width: 90px; font-size: 0.85rem; }
}

/* =========================================================
   Dashboard widgets: activity feed + credit sparkline
   ========================================================= */
.dashboard-widgets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 1.25rem 0;
}
.dashboard-widget {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 10px;
    padding: .875rem 1rem;
}
.widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .5rem;
}
.widget-title { font-size: .85rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.widget-badge { font-size: .8rem; font-weight: 600; color: var(--color-primary, #2563eb); background: var(--color-primary-bg, #eff6ff); padding: .15rem .5rem; border-radius: 999px; }
.widget-body { font-size: .85rem; }
.widget-empty { color: var(--text-muted); font-size: .82rem; margin: .25rem 0 0; }

/* Recent jobs feed */
.job-feed-row { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--border, #e5e7eb); }
.job-feed-row:last-child { border-bottom: none; }
.job-feed-chip { font-size: .72rem; font-weight: 600; padding: .1rem .45rem; border-radius: 999px; white-space: nowrap; }
.chip-done    { background: #dcfce7; color: #166534; }
.chip-running { background: #dbeafe; color: #1e40af; }
.chip-error   { background: #fee2e2; color: #991b1b; }
.chip-pending { background: #f3f4f6; color: #6b7280; }
.chip-stopped { background: #fef3c7; color: #92400e; }
.job-feed-label { flex: 1; color: var(--text); font-size: .82rem; }
.job-feed-bar { width: 48px; height: 5px; background: var(--border, #e5e7eb); border-radius: 3px; overflow: hidden; }
.job-feed-fill { height: 100%; background: var(--color-primary, #2563eb); border-radius: 3px; }
.job-feed-time { font-size: .75rem; color: var(--text-muted); white-space: nowrap; }

/* Credit sparkline */
.credit-sparkline { display: block; width: 100%; height: 48px; margin-top: .25rem; }

/* =========================================================
   Contact quick-view drawer
   ========================================================= */
.contact-drawer-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 1100;
}
.contact-drawer-overlay.open { display: block; }

.contact-drawer {
    display: none;
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(380px, 92vw);
    background: var(--card-bg, #fff);
    border-left: 1px solid var(--border, #e5e7eb);
    box-shadow: -4px 0 24px rgba(0,0,0,.12);
    z-index: 1101;
    overflow-y: auto;
    padding: 1.25rem 1.25rem 2rem;
}
.contact-drawer.open { display: block; animation: drawerSlideIn .2s ease; }
@keyframes drawerSlideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.contact-drawer-close {
    float: right;
    background: none; border: none; cursor: pointer;
    font-size: 1.4rem; line-height: 1; color: var(--text-muted);
    padding: 0 .25rem; margin: -.25rem -.25rem 0 0;
}
.contact-drawer-close:hover { color: var(--text); }

.drawer-name { font-size: 1.15rem; font-weight: 700; margin: .5rem 0 .75rem; line-height: 1.3; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.drawer-meta { display: grid; grid-template-columns: auto 1fr; gap: .25rem .75rem; margin-bottom: .75rem; }
.drawer-field-label { font-size: .78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; align-self: center; }
.drawer-divider { border: none; border-top: 1px solid var(--border, #e5e7eb); margin: .5rem 0 .75rem; }
.drawer-contact-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; font-size: .9rem; flex-wrap: wrap; }
.drawer-icon { font-size: 1rem; color: var(--text-muted); flex-shrink: 0; }
.drawer-status-chip { font-size: .78rem; font-weight: 600; margin-left: auto; }
.drawer-confidence { display: flex; align-items: center; gap: .6rem; margin: .5rem 0; }
.drawer-source { margin-top: .75rem; }
.drawer-source-link { font-size: .82rem; color: var(--color-primary, #2563eb); text-decoration: none; }
.drawer-source-link:hover { text-decoration: underline; }
.drawer-crm { margin-top: .75rem; font-size: .82rem; }

/* CRM synced badge in name cell */
.crm-synced-badge { font-size: .7rem; font-weight: 700; color: #16a34a; background: #dcfce7; border-radius: 999px; padding: .05rem .3rem; margin-left: .3rem; vertical-align: middle; }

/* Make contact rows show pointer cursor */
tr.contact-row { cursor: pointer; }
tr.contact-row:hover { background: var(--hover-bg, #f9fafb); }

@media (max-width: 640px) {
    .dashboard-widgets { grid-template-columns: 1fr; }
}
