:root {
    --red: #dd3333;
    --red-dark: #a82323;
    --red-tint: #fdecea;
    --black: #222222;
    --gray-900: #333333;
    --gray-700: #555555;
    --gray-400: #999999;
    --gray-200: #e0e0e0;
    --gray-100: #f2f2f2;
    --gray-50: #f8f8f9;
    --white: #ffffff;
    --font-body: 'Open Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --font-heading: 'Lato', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--gray-50);
    color: var(--gray-900);
}

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

h1, h2, h3, .brand, .board-column-title, .lead-business { font-family: var(--font-heading); }

h1 { font-size: 1.6rem; font-weight: 900; margin: 0 0 0.5rem; }
.count-badge {
    display: inline-block; vertical-align: middle; color: var(--gray-700); font-weight: 700;
    font-size: 0.85rem; background: var(--gray-100); border-radius: 12px; padding: 0.15rem 0.65rem;
    margin-left: 0.4rem;
}
h2 { font-size: 1.1rem; font-weight: 700; margin: 1.5rem 0 0.5rem; }
h3 { font-size: 0.95rem; font-weight: 700; margin: 1rem 0 0.25rem; color: var(--gray-700); }

/* Topbar */
.topbar {
    background: var(--white);
    color: var(--black);
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0 1.5rem;
    height: 72px;
    border-bottom: 1px solid var(--gray-200);
}
.topbar .brand { display: flex; align-items: center; height: 100%; }
.topbar .brand-logo { height: 56px; display: block; }
.topbar nav { align-items: center; display: flex; }
.nav-toggle {
    display: flex; align-items: center; gap: 0.15rem; background: var(--white);
    border: 1px solid var(--gray-200); border-radius: 8px; padding: 3px;
}
.nav-toggle-btn {
    display: inline-block; padding: 0.45rem 0.9rem; font-size: 0.85rem; font-weight: 700;
    border-radius: 6px; color: var(--gray-900); border: 1px solid transparent;
}
.nav-toggle-btn:hover { text-decoration: none; background: var(--gray-50); }
.nav-toggle-btn.current { background: var(--white); border-color: var(--gray-200); box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.nav-toggle-btn.current:hover { background: var(--white); }
.nav-toggle-won { color: #1e8e3e; }
.nav-toggle-lost { color: var(--red); }
.nav-toggle-inactive { color: var(--gray-700); }
.topbar-right { display: flex; align-items: center; gap: 1.5rem; font-size: 0.85rem; color: var(--gray-700); margin-left: auto; }
.link-button {
    background: none; border: none; color: var(--gray-700); cursor: pointer;
    font-size: 0.85rem; padding: 0; text-decoration: underline;
}
.link-button:hover { color: var(--red); }
.topbar-link { color: var(--gray-700); font-size: 0.85rem; }
.topbar-link:hover { color: var(--red); }
.inline-form { display: inline; }

.nav-reports { color: var(--red); font-weight: 800; font-size: 0.95rem; font-family: var(--font-heading); }
.nav-reports:hover { color: var(--red-dark); text-decoration: none; }

.user-menu { position: relative; }
.user-menu-trigger {
    background: none; border: none; cursor: pointer; display: flex; align-items: center;
    gap: 0.35rem; font-size: 0.85rem; font-weight: 600; color: var(--black); font-family: var(--font-body);
    padding: 0.4rem 0;
}
.user-menu-dropdown {
    display: none; position: absolute; right: 0; top: calc(100% + 0.4rem);
    background: var(--white); border: 1px solid var(--gray-200); border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12); min-width: 170px; overflow: hidden; z-index: 30;
}
.user-menu-dropdown.open { display: block; }
.user-menu-dropdown a, .user-menu-dropdown button {
    display: block; width: 100%; text-align: left; background: none; border: none;
    padding: 0.65rem 0.9rem; font-size: 0.85rem; color: var(--black); cursor: pointer;
    font-family: var(--font-body);
}
.user-menu-dropdown a:hover, .user-menu-dropdown button:hover { background: var(--gray-100); color: var(--red); text-decoration: none; }
.user-menu-dropdown form { margin: 0; }
.user-menu-avatar {
    width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.user-menu-avatar-placeholder {
    display: inline-flex; align-items: center; justify-content: center; background: var(--red);
    color: var(--white); font-weight: 700; font-size: 0.75rem;
}

/* Profile */
.profile-panel { max-width: 480px; margin: 0 auto; text-align: center; }
.profile-photo {
    width: 96px; height: 96px; border-radius: 50%; object-fit: cover; margin: 0.5rem auto 1.25rem;
    display: block; border: 3px solid var(--gray-100);
}
.profile-photo-placeholder {
    display: flex; align-items: center; justify-content: center; background: var(--red);
    color: var(--white); font-weight: 800; font-size: 2.2rem; font-family: var(--font-heading);
}
.profile-form { text-align: left; }
.profile-form .btn { width: 100%; margin-top: 0.5rem; }
.profile-password-link { margin-top: 1.25rem; font-size: 0.88rem; }

main { padding: 1.5rem; max-width: 1900px; margin: 0 auto; }

/* Messages */
.confetti-overlay { position: fixed; inset: 0; pointer-events: none; z-index: 9999; overflow: hidden; }
.confetti-piece {
    position: absolute; line-height: 1; opacity: 0;
    animation-name: confetti-burst; animation-timing-function: cubic-bezier(0.15, 0.8, 0.3, 1);
    animation-fill-mode: forwards;
}
@keyframes confetti-burst {
    0% { transform: translate(0, 0) scale(0.4) rotate(0deg); opacity: 1; }
    18% { transform: translate(calc(var(--dx) * 0.35), calc(var(--dy) * 0.35)) scale(1.15) rotate(calc(var(--rot) * 0.35)); opacity: 1; }
    70% { transform: translate(var(--dx), var(--dy)) scale(1) rotate(var(--rot)); opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) scale(1) rotate(var(--rot)); opacity: 0; }
}

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: 0.6rem 1rem; border-radius: 6px; margin-bottom: 0.5rem; font-size: 0.9rem; }
.msg-success { background: #e6f4ea; color: #1e6b33; border: 1px solid #b7e0c3; }
.msg-error { background: var(--red-tint); color: var(--red-dark); border: 1px solid #f5c2bd; }

/* Buttons */
.btn {
    display: inline-block; background: var(--white); color: var(--black);
    border: 1px solid var(--gray-200); border-radius: 6px; padding: 0.55rem 1.1rem;
    font-size: 0.9rem; font-weight: 600; cursor: pointer; font-family: var(--font-body);
}
.btn:hover { background: var(--gray-100); text-decoration: none; }
.btn-primary { background: var(--red); color: var(--white); border-color: var(--red); }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); color: var(--white); }
.btn-icon { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.42rem 0.8rem; font-size: 0.82rem; }

/* Board */
.board-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.board-header h1 { flex-shrink: 0; }
.board-search { flex: 1; max-width: 340px; display: flex; align-items: center; gap: 0.6rem; }
.board-search input[type="search"] {
    width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--gray-200);
    border-radius: 6px; font-size: 0.85rem; font-family: var(--font-body);
}
.board-header-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; flex-wrap: wrap; }
.view-toggle { display: flex; border: 1px solid var(--gray-200); border-radius: 6px; overflow: hidden; flex-shrink: 0; }
.view-toggle-btn {
    display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0.9rem;
    font-size: 0.82rem; font-weight: 700; color: var(--gray-700); background: var(--white);
}
.view-toggle-btn svg { flex-shrink: 0; }
.view-toggle-btn:hover { background: var(--gray-100); text-decoration: none; }
.view-toggle-btn.active { background: var(--red-tint); color: var(--red); }
.view-toggle-btn.active:hover { background: var(--red-tint); }
.view-toggle-btn + .view-toggle-btn { border-left: 1px solid var(--gray-200); }

.lead-select-header, .lead-select-cell { width: 2rem; display: none; }
.lead-table.selecting .lead-select-header, .lead-table.selecting .lead-select-cell { display: table-cell; }
.lead-table tr.is-stale-row { border-left: 3px solid var(--red); }
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.3rem; }

.lead-select { display: none; margin-bottom: 0.4rem; }
#board-grid.selecting .lead-select { display: block; }
.lead-select input { width: 16px; height: 16px; cursor: pointer; }

.bulk-bar {
    display: none; align-items: center; gap: 1rem; position: sticky; bottom: 0.75rem;
    background: var(--black); color: var(--white); padding: 0.75rem 1.25rem;
    border-radius: 8px; margin-top: 1rem; box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}
.bulk-bar.visible { display: flex; }
.bulk-bar select { padding: 0.45rem 0.6rem; border-radius: 6px; border: none; font-family: var(--font-body); }
.bulk-bar #bulk-count { font-weight: 700; font-size: 0.85rem; }
.board-column {
    background: var(--white); border: 1px solid var(--gray-200); border-radius: 8px;
    min-width: 0; display: flex; flex-direction: column;
    max-height: calc(100vh - 160px); overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.board-column-header {
    color: var(--gray-900); background: var(--white); padding: 0.7rem 1rem;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 3px solid var(--red);
}
.board-column-title { font-weight: 700; font-size: 0.92rem; color: var(--gray-900); }
.board-column-header .count {
    color: var(--gray-700); font-weight: 700; font-size: 0.72rem; background: var(--gray-100);
    border-radius: 10px; padding: 0.1rem 0.5rem; margin-left: 0.4rem;
}
.board-column-totals { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }
.board-column-total { font-size: 0.78rem; color: var(--gray-700); font-weight: 700; white-space: nowrap; }
.board-column-total-recurring { display: inline-flex; align-items: center; gap: 0.25rem; color: #1e8e3e; }
.board-column-body { background: var(--gray-100); padding: 0.65rem; overflow-y: auto; flex: 1; }
.board-column-body.drag-over { background: var(--red-tint); }

.lead-card {
    background: var(--white); border: 1px solid var(--gray-200); border-radius: 8px;
    padding: 0.7rem 0.8rem; margin-bottom: 0.65rem; cursor: grab;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03); transition: box-shadow 0.15s, border-color 0.15s;
}
.lead-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.07); border-color: var(--gray-400); }
.lead-card.dragging { opacity: 0.4; }
.lead-card.is-stale { border-left: 3px solid var(--red); }
.lead-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; }
.lead-business { font-weight: 700; font-size: 1rem; line-height: 1.25; color: var(--gray-900); }
.lead-value-pills { display: flex; flex-direction: column; align-items: flex-end; gap: 0.1rem; flex-shrink: 0; }
.value-pill {
    background: none; color: var(--gray-900); font-size: 0.85rem; font-weight: 700;
    padding: 0; white-space: nowrap; flex-shrink: 0; text-align: right;
}
.value-pill-recurring { color: #1e8e3e; font-weight: 600; font-size: 0.78rem; }
.lead-name { color: var(--gray-700); font-weight: 500; font-size: 0.87rem; margin-top: 0.1rem; }
.lead-contact-line { color: var(--gray-700); font-size: 0.8rem; margin-top: 0.1rem; }
.lead-contact-line .card-link { color: var(--gray-700); }
.lead-contact-line .card-link:hover { color: var(--red); }
.lead-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.45rem 0; }
.tag {
    display: inline-block; font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 10px;
    background: var(--gray-100); color: var(--gray-700); font-weight: 600;
    border: 1px solid var(--gray-200);
}
.tag-project { background: var(--gray-100); color: var(--gray-700); border-color: var(--gray-200); }
.tag-stale { background: var(--red); color: var(--white); border-color: var(--red); }
.lead-activity { margin-top: 0.5rem; padding-top: 0.45rem; border-top: 1px solid var(--gray-100); }
.lead-activity-label { font-size: 0.72rem; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 0.25rem; }
.lead-activity-line { font-size: 0.78rem; color: var(--gray-700); line-height: 1.4; }
.lead-activity-date { font-weight: 600; color: var(--gray-400); }
.empty-column { color: var(--gray-400); font-size: 0.85rem; text-align: center; padding: 1rem 0; }

.btn-proposal {
    display: inline-flex; align-items: center; gap: 0.35rem; background: var(--white);
    color: var(--red); font-size: 0.72rem; font-weight: 700; padding: 0.28rem 0.6rem;
    border: 1px solid var(--red); border-radius: 5px; text-transform: uppercase; letter-spacing: 0.02em;
}
.btn-proposal:hover { background: var(--red-tint); color: var(--red-dark); border-color: var(--red-dark); text-decoration: none; }
.lead-proposal-row { margin-top: 0.5rem; }

/* Lead detail */
.back-link { display: inline-block; margin-bottom: 0.75rem; font-size: 0.9rem; font-weight: 600; }

.lead-header-bar { margin-bottom: 1.25rem; }
.lead-badges { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.badge {
    display: inline-block; background: var(--white); border: 1px solid var(--gray-200);
    color: var(--gray-900); font-size: 0.78rem; font-weight: 700; padding: 0.3rem 0.75rem;
    border-radius: 20px;
}
.badge-value { background: var(--gray-100); color: var(--gray-900); border-color: var(--gray-200); }
.badge-recurring { background: #e6f4ea; color: #1e7e34; border-color: #b7e0c3; }
.badge-accent { background: var(--red-tint); color: var(--red-dark); border-color: #f5c2bd; }

.lead-detail-grid {
    display: grid; grid-template-columns: 460px 1fr; gap: 1.25rem; align-items: start;
}
@media (max-width: 1000px) {
    .lead-detail-grid { grid-template-columns: 1fr; }
}
.lead-col-left { display: flex; flex-direction: column; gap: 1.25rem; }
.lead-col-right { min-width: 0; }

.panel {
    background: var(--white); border: 1px solid var(--gray-200); border-radius: 10px;
    padding: 1.25rem 1.4rem; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.panel h2 { margin: 0; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gray-700); }
.panel > h2 { margin-bottom: 0.9rem; border-bottom: 2px solid var(--red); padding-bottom: 0.5rem; }
.panel-header-row { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid var(--red); padding-bottom: 0.5rem; margin-bottom: 0.9rem; }
.panel-header-row h2 { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
.btn-link {
    background: none; border: none; color: var(--red); font-size: 0.82rem; font-weight: 700;
    cursor: pointer; padding: 0; font-family: var(--font-body);
}
.btn-link:hover { color: var(--red-dark); text-decoration: underline; }
.delete-lead-form { margin-top: 0.9rem; padding-top: 0.75rem; border-top: 1px solid var(--gray-200); }
.btn-link-danger { color: var(--gray-400); }
.btn-link-danger:hover { color: var(--red); }
.activity-panel { min-height: 100%; }

.ci-business { font-weight: 800; font-size: 1.1rem; font-family: var(--font-heading); color: var(--black); }
.ci-name { font-size: 0.95rem; color: var(--gray-700); font-weight: 600; margin-bottom: 0.6rem; }
.ci-line { font-size: 0.9rem; color: var(--gray-900); margin-top: 0.35rem; line-height: 1.4; }
.ci-line a { color: var(--gray-900); }
.ci-line a:hover { color: var(--red); }
.ci-line a.btn-proposal { color: var(--red); }
.ci-line a.btn-proposal:hover { color: var(--red-dark); }
.ci-empty { color: var(--gray-400); font-style: italic; }

.contact-form { display: none; }
.contact-form.is-editing { display: block; }
.contact-form-actions { display: flex; gap: 0.5rem; }
.contact-form-actions .btn { flex: 1; }

.detail-list { display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 0.9rem; font-size: 0.9rem; margin: 0 0 1rem; }
.detail-list dt { color: var(--gray-400); font-weight: 600; }
.detail-list dd { margin: 0; color: var(--gray-900); }

.quick-link { margin-top: 0.75rem; font-size: 0.85rem; }

.stage-form { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.stage-form select { padding: 0.5rem; border-radius: 6px; border: 1px solid var(--gray-200); font-family: var(--font-body); flex: 1; min-width: 0; }

.note-form textarea,
.note-form input:not([type="checkbox"]),
.contact-form input:not([type="checkbox"]),
.lead-create-form input:not([type="checkbox"]),
.lead-create-form select,
.profile-form input:not([type="checkbox"]) {
    width: 100%; padding: 0.55rem; border: 1px solid var(--gray-200);
    border-radius: 6px; font-family: var(--font-body); font-size: 0.9rem;
}
.note-form input[type="checkbox"], .lead-create-form input[type="checkbox"], .contact-form input[type="checkbox"],
.profile-form input[type="checkbox"] {
    width: auto; margin-right: 0.4rem; vertical-align: middle;
}
.contact-form ul { list-style: none; padding: 0; margin: 0; }
.contact-form ul li { margin-bottom: 0.3rem; }
.contact-form ul li label { display: inline; font-weight: 400; color: var(--gray-900); }
.note-form p, .contact-form p, .lead-create-form p, .profile-form p { margin: 0.6rem 0; }
.note-form label, .contact-form label, .lead-create-form label, .profile-form label {
    font-size: 0.8rem; color: var(--gray-700); font-weight: 600; display: block; margin-bottom: 0.25rem;
}
.note-form p:has(input[type="checkbox"]) label,
.lead-create-form p:has(input[type="checkbox"]) label,
.profile-form p:has(input[type="checkbox"]) label {
    display: inline; margin-bottom: 0;
}
.contact-form { margin-bottom: 0; }
.contact-form .btn { margin-top: 0.4rem; width: 100%; }

.activity-panel .note-form { border-bottom: 1px solid var(--gray-200); padding-bottom: 1.1rem; margin-bottom: 1.1rem; }

.notes-list { display: flex; flex-direction: column; }
.note { border-bottom: 1px solid var(--gray-200); padding: 0.85rem 0; }
.note:last-child { border-bottom: none; }
.note.pinned { background: var(--red-tint); border-left: 3px solid var(--red); padding-left: 0.75rem; }
.note-meta { font-size: 0.75rem; color: var(--gray-400); margin-bottom: 0.3rem; }
.note-body { font-size: 0.9rem; line-height: 1.5; }
.empty-state { color: var(--gray-400); }

/* Tables */
.lead-table { width: 100%; border-collapse: collapse; background: var(--white); border-radius: 8px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.03); border: 1px solid var(--gray-200); }
.lead-table th { text-align: left; background: var(--white); color: var(--gray-900); padding: 0.65rem 0.9rem; font-size: 0.78rem; font-weight: 700; border-bottom: 3px solid var(--red); }
.lead-table td { padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--gray-200); font-size: 0.88rem; }
.lead-table tr.clickable-row { cursor: pointer; }
.lead-table tr.clickable-row:hover { background: var(--gray-100); }
.lost-reason-form select {
    padding: 0.35rem 0.5rem; border-radius: 6px; border: 1px solid var(--gray-200);
    font-family: var(--font-body); font-size: 0.85rem; background: var(--white);
}

/* Login */
.login-box { max-width: 340px; margin: 4rem auto; background: var(--white); border: 1px solid var(--gray-200); border-radius: 10px; padding: 2rem; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.login-box h1 { color: var(--red); text-align: center; margin-bottom: 1.5rem; }
.login-box input { width: 100%; padding: 0.55rem; border: 1px solid var(--gray-200); border-radius: 6px; font-family: var(--font-body); }
.login-box p { margin: 0.75rem 0; }
.login-box label { font-size: 0.85rem; color: var(--gray-700); font-weight: 600; display: block; margin-bottom: 0.2rem; }

/* Reports */
.reports-subtitle { color: var(--gray-700); margin: -0.5rem 0 1.5rem; font-size: 0.92rem; }
.digest-recipient-list { margin-bottom: 1rem; }
.digest-recipient-row {
    display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
    padding: 0.6rem 0; border-bottom: 1px solid var(--gray-100); font-size: 0.9rem;
}
.digest-recipient-row:last-child { border-bottom: none; }
.digest-add-form { display: flex; gap: 0.6rem; }
.digest-add-form input[type="email"] {
    flex: 1; padding: 0.55rem 0.75rem; border: 1px solid var(--gray-200); border-radius: 6px;
    font-family: var(--font-body); font-size: 0.88rem;
}
.report-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem;
    margin-bottom: 1.25rem;
}
.report-grid-wide { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.report-card {
    background: var(--white); border: 1px solid var(--gray-200); border-radius: 10px;
    padding: 1.25rem 1.4rem; box-shadow: 0 1px 3px rgba(0,0,0,0.05); border-top: 3px solid var(--red);
}
.report-card-label { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gray-700); }
.report-card-number { font-family: var(--font-heading); font-weight: 900; font-size: 2.2rem; color: var(--black); margin-top: 0.3rem; }
.report-card-unit { font-size: 1rem; font-weight: 600; color: var(--gray-400); margin-left: 0.3rem; }
.report-card-sub { font-size: 0.8rem; color: var(--gray-400); margin-top: 0.3rem; }
.report-card-number-secondary { font-family: var(--font-heading); font-weight: 800; font-size: 1.3rem; color: var(--gray-700); margin-top: 0.25rem; }
.report-card-number-secondary .report-card-unit { font-size: 0.85rem; }
.report-card-list { padding-bottom: 0.6rem; }
.report-table { width: 100%; border-collapse: collapse; margin-top: 0.8rem; }
.report-table td { padding: 0.45rem 0; border-bottom: 1px solid var(--gray-100); font-size: 0.88rem; }
.report-table-count { text-align: right; font-weight: 700; color: var(--black); }
.report-table-empty { color: var(--gray-400); font-style: italic; text-align: center; padding: 1rem 0; }
.report-card-full { grid-column: 1 / -1; }
.source-perf-table th {
    text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em;
    color: var(--gray-400); padding-bottom: 0.4rem; border-bottom: 1px solid var(--gray-200);
}
.source-perf-table th:not(:first-child), .source-perf-table td:not(:first-child) { text-align: right; }

.analytics-filters { margin-bottom: 1.25rem; }
.analytics-filters-row { display: flex; flex-wrap: wrap; align-items: end; gap: 0.9rem; }
.analytics-filters-row label {
    display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.78rem;
    font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--gray-700);
}
.analytics-filters-row input, .analytics-filters-row select {
    padding: 0.5rem 0.65rem; border: 1px solid var(--gray-200); border-radius: 6px;
    font-family: var(--font-body); font-size: 0.88rem; font-weight: 400; text-transform: none;
}
.analytics-chart {
    display: flex; align-items: flex-end; gap: 0.6rem; height: 160px; padding-top: 1rem;
    border-bottom: 1px solid var(--gray-200);
}
.analytics-bar-col { display: flex; flex-direction: column; align-items: center; flex: 1; height: 100%; justify-content: flex-end; }
.analytics-bar {
    width: 100%; max-width: 42px; background: var(--gray-200); border-radius: 4px 4px 0 0;
    position: relative; min-height: 2px; display: flex; align-items: flex-end;
}
.analytics-bar-won { width: 100%; background: var(--red); border-radius: 4px 4px 0 0; opacity: 0.85; }
.analytics-bar-label { font-size: 0.68rem; color: var(--gray-400); margin-top: 0.4rem; white-space: nowrap; }

.reports-section-head { margin-bottom: 0.9rem; }
.reports-section-title { font-family: var(--font-heading); font-weight: 900; font-size: 1.3rem; margin: 0 0 0.15rem; }

.viz-root {
    --chart-1: #2a78d6; /* Total Leads */
    --chart-2: #eb6834; /* Qualified+ */
    --chart-3: #1baf7a; /* Won */
    --chart-4: #e34948; /* Lost */
}

.analytics-legend { display: flex; flex-wrap: wrap; gap: 1.1rem; margin: 0.9rem 0 0.6rem; }
.analytics-legend-item { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: var(--gray-700); }
.analytics-legend-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.analytics-linechart-wrap { width: 100%; }
.analytics-linechart { width: 100%; height: auto; overflow: visible; }
.analytics-axis-line { stroke: var(--gray-200); stroke-width: 1; }
.analytics-axis-label { font-size: 10px; fill: var(--gray-400); font-family: var(--font-body); }
.analytics-zebra { fill: var(--gray-50); }
.analytics-linechart-xlabels {
    display: flex; justify-content: space-between; margin-top: 0.35rem; padding: 0 10px;
    font-size: 0.68rem; color: var(--gray-400);
}

.analytics-table-toggle { margin-top: 1rem; }
.analytics-table-toggle summary {
    cursor: pointer; font-size: 0.8rem; font-weight: 700; color: var(--gray-700);
    text-transform: uppercase; letter-spacing: 0.03em;
}
.analytics-table-toggle table { margin-top: 0.7rem; }

.analytics-note-excerpt { color: var(--gray-700); font-size: 0.82rem; max-width: 280px; }

.report-table-drilldown { font-size: 0.75rem; color: var(--red); margin-left: 0.4rem; white-space: nowrap; }

/* Sortable source-performance table: zebra rows + an offset tint on the outcome-metric columns */
.sortable-table th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
.sortable-table th[data-sort]:hover { color: var(--red); }
.sortable-table th.sort-asc::after { content: '\25B2'; font-size: 0.62em; margin-left: 0.35em; color: var(--gray-400); }
.sortable-table th.sort-desc::after { content: '\25BC'; font-size: 0.62em; margin-left: 0.35em; color: var(--gray-400); }
.sortable-table tbody tr:nth-child(even) { background: var(--gray-50); }
.sortable-table tbody tr:nth-child(odd) .outcome-col { background: var(--gray-50); }
.sortable-table tbody tr:nth-child(even) .outcome-col { background: var(--gray-100); }

.report-grid-secondary { display: flex; flex-wrap: wrap; gap: 1rem; margin: 0.75rem 0 1.5rem; }
.report-card-mini {
    display: flex; align-items: baseline; gap: 0.5rem; padding: 0.65rem 1rem;
    background: var(--white); border-radius: 6px; border: 1px solid var(--gray-200);
}
.report-card-mini-label { font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--gray-700); }
.report-card-mini-number { font-size: 1.15rem; font-weight: 900; color: var(--red); }
.report-card-mini-sub { font-size: 0.78rem; color: var(--gray-700); }

/* Duplicate-lead warning */
.dup-warning {
    background: #fff8e1; border: 1px solid #f0d98c; color: #7a5c00;
    padding: 0.9rem 1.1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.88rem;
}
.dup-warning ul { margin: 0.5rem 0 0; padding-left: 1.2rem; }
.dup-warning a { font-weight: 700; }

/* Activity log / audit trail */
.activity-log-list { display: flex; flex-direction: column; }
.activity-entry {
    display: flex; justify-content: space-between; gap: 1rem; padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-100); font-size: 0.82rem;
}
.activity-entry:last-child { border-bottom: none; }
.activity-entry-detail { color: var(--gray-900); }
.activity-entry-meta { color: var(--gray-400); white-space: nowrap; flex-shrink: 0; }
