:root {
    --ink: #1d2433;
    --muted: #667085;
    --line: #d9dee7;
    --panel: #ffffff;
    --bg: #f7f7fb;
    --primary: #3b22b9;
    --primary-dark: #2b188c;
    --primary-soft: #f0ecff;
    --nav: #ffffff;
    --danger: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

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

.topbar {
    align-items: stretch;
    background: var(--nav);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 18px;
    height: 100vh;
    justify-content: flex-start;
    left: 0;
    padding: 22px 10px;
    position: fixed;
    top: 0;
    width: 226px;
    z-index: 10;
}

.brand {
    align-items: center;
    color: var(--ink);
    display: flex;
    font-size: 20px;
    font-weight: 700;
    gap: 10px;
    padding: 0 16px 14px;
}

.brand-mark {
    align-items: center;
    background: #2fd17c;
    border: 1px solid #21a563;
    border-radius: 6px;
    color: #092b1a;
    display: inline-flex;
    font-size: 13px;
    height: 26px;
    justify-content: center;
    width: 32px;
}

nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

nav a {
    border-radius: 7px;
    color: #4f5665;
    display: block;
    font-weight: 600;
    padding: 11px 14px;
}

nav a:hover {
    background: #f4f1ff;
    color: var(--primary);
}

.container {
    margin-left: 226px;
    max-width: none;
    min-height: 100vh;
    padding: 0;
}

.page-heading {
    align-items: center;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 0;
    padding: 20px 30px;
}

.page-heading h1,
.page-heading p {
    margin: 0;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin: 24px 30px;
    padding: 22px;
}

.grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.stat {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.stat strong {
    display: block;
    font-size: 30px;
}

.pipeline-panel {
    border-left: 4px solid var(--primary);
}

.pipeline-header {
    align-items: flex-start;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 18px;
}

.pipeline-header h2,
.pipeline-header p {
    margin: 0;
}

.status-pill {
    background: var(--primary-soft);
    border: 1px solid #cfc4ff;
    border-radius: 999px;
    color: var(--primary-dark);
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.1;
    padding: 5px 8px;
    white-space: nowrap;
}

.pipeline-table-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.pipeline-table {
    table-layout: fixed;
    width: 100%;
}

.pipeline-table th {
    background: #f8fafc;
    color: #4f5665;
    font-size: 11px;
    line-height: 1.2;
    padding: 8px 6px;
    white-space: normal;
}

.pipeline-table td {
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    padding: 9px 6px;
    text-align: right;
    white-space: normal;
    word-break: normal;
}

.pipeline-table th:first-child,
.pipeline-table td:first-child,
.pipeline-table th:nth-child(2),
.pipeline-table td:nth-child(2),
.pipeline-table th:nth-child(7),
.pipeline-table td:nth-child(7),
.pipeline-table th:nth-child(9),
.pipeline-table td:nth-child(9) {
    text-align: left;
}

.pipeline-table td:nth-child(2),
.pipeline-table td:nth-child(7),
.pipeline-table td:nth-child(9) {
    font-size: 12px;
    white-space: normal;
}

.pipeline-table th:first-child,
.pipeline-table td:first-child {
    width: 8%;
}

.pipeline-table th:nth-child(2),
.pipeline-table td:nth-child(2),
.pipeline-table th:nth-child(10),
.pipeline-table td:nth-child(10) {
    width: 12%;
}

.pipeline-table th:nth-child(11),
.pipeline-table td:nth-child(11) {
    width: 6%;
}

.muted {
    color: var(--muted);
}

.danger {
    color: var(--danger);
    font-weight: 700;
}

label {
    display: block;
    font-weight: 700;
    margin: 14px 0 6px;
}

input,
select,
textarea,
button {
    border: 1px solid var(--line);
    border-radius: 6px;
    font: inherit;
    padding: 10px 12px;
    width: 100%;
}

input[type="file"] {
    background: #fff;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

select[multiple] {
    min-height: 96px;
}

.mini-upload-form {
    border-top: 1px solid var(--line);
    margin-top: 18px;
    padding-top: 14px;
}

.inline-upload {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 8px;
    padding: 10px;
}

.inline-upload button {
    margin-top: 10px;
}

.hidden-form {
    display: none;
}

input[type="checkbox"] {
    width: auto;
}

button,
.button {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    cursor: pointer;
    display: inline-block;
    font-weight: 700;
    margin-top: 16px;
    text-align: center;
    width: auto;
}

.button-primary {
    min-width: 180px;
    padding-left: 18px;
    padding-right: 18px;
}

button:hover,
.button:hover {
    background: var(--primary-dark);
}

.button.secondary {
    background: #ffffff;
    border-color: var(--line);
    color: var(--ink);
}

table {
    background: var(--panel);
    border-collapse: collapse;
    width: 100%;
}

.latest-captures-scroll {
    border: 1px solid var(--line);
    border-radius: 8px;
    max-height: 320px;
    overflow-y: auto;
}

.latest-captures-scroll table {
    border: 0;
}

.latest-captures-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px;
    text-align: left;
    vertical-align: top;
}

th {
    background: #fafafa;
    color: #616675;
    font-size: 13px;
    font-weight: 700;
    text-transform: none;
}

.actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.actions form {
    margin: 0;
}

.actions input,
.actions select {
    min-width: 140px;
    width: auto;
}

.actions button,
.actions .button {
    flex: 0 0 auto;
}

.lead-workspace {
    align-items: start;
    display: grid;
    gap: 0;
    grid-template-columns: 390px minmax(0, 1fr);
    transition: grid-template-columns 180ms ease;
}

.lead-workspace.filters-open {
    grid-template-columns: 390px minmax(0, 1fr);
}

.filter-rail,
.results-panel {
    background: var(--panel);
    border: 0;
    border-radius: 0;
    padding: 18px 24px;
}

.filter-rail {
    border-right: 1px solid var(--line);
    max-height: 100vh;
    min-height: 100vh;
    opacity: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    position: sticky;
    top: 0;
    transform: none;
    transition: opacity 180ms ease, transform 180ms ease;
    visibility: visible;
}

.filters-open .filter-rail {
    opacity: 1;
    transform: translateX(0);
    visibility: visible;
}

.filter-header {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    margin: -18px -18px 12px;
    padding: 12px 18px;
}

.filter-header strong {
    color: #303642;
    font-size: 16px;
}

.mode-tabs {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 20px;
    margin: 0 -24px 18px;
    padding: 0 24px;
}

.mode-tabs a {
    color: #596170;
    font-weight: 700;
    padding: 0 0 14px;
}

.mode-tabs a.active {
    border-bottom: 3px solid var(--primary);
    color: var(--primary);
}

.company-row .lead-main {
    align-items: flex-start;
}

.company-row .lead-main p:last-child {
    margin-top: 12px;
    max-width: 760px;
}

.icon-button {
    align-items: center;
    background: #f2f4f7;
    border-color: var(--line);
    color: var(--ink);
    display: inline-flex;
    height: 34px;
    justify-content: center;
    margin: 0;
    padding: 0;
    width: 34px;
}

.filter-rail textarea {
    min-height: 82px;
}

.check-row {
    align-items: center;
    display: flex;
    gap: 8px;
}

.results-toolbar {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    margin: -18px -24px 0;
    min-height: 68px;
    padding: 14px 24px;
}

.lead-row {
    align-items: start;
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(420px, 1.4fr) minmax(220px, .7fr) 310px;
    padding: 22px 0;
}

.lead-row .lead-meta:empty {
    display: none;
}

.lead-row:has(.lead-meta:empty) {
    grid-template-columns: minmax(520px, 1fr) 330px;
}

.lead-main {
    align-items: center;
    display: flex;
    gap: 12px;
    min-width: 0;
}

.lead-main h2 {
    font-size: 20px;
    margin: 0 0 4px;
}

.lead-main p {
    margin: 0;
}

.lead-title {
    color: var(--ink);
    font-weight: 700;
}

.lead-company {
    color: #344054;
}

.lead-avatar {
    align-items: center;
    background: #eee9ff;
    border: 1px solid #d9d0ff;
    border-radius: 50%;
    color: #075985;
    display: flex;
    flex: 0 0 42px;
    font-weight: 700;
    height: 42px;
    justify-content: center;
    width: 42px;
}

.lead-meta,
.lead-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.lead-meta span,
.pill,
.status-chip {
    background: #f2f4f7;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: #344054;
    display: inline-block;
    font-size: 13px;
    padding: 5px 9px;
}

.lead-actions {
    border-left: 1px solid var(--line);
    flex-direction: column;
    justify-content: flex-start;
    padding-left: 24px;
}

.lead-actions form {
    margin: 0;
}

.lead-actions button {
    margin-top: 0;
    min-width: 110px;
}

.lead-actions .button {
    margin-top: 0;
}

.lead-detail-panel {
    border-top: 1px solid var(--line);
    margin-top: 10px;
    padding-top: 18px;
}

.detail-heading {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 14px;
}

.detail-heading h2 {
    font-size: 20px;
    margin: 0 0 4px;
}

.detail-heading p {
    margin: 0;
}

.record-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.record-field {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
}

.record-field strong {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
}

.record-field span {
    display: block;
    overflow-wrap: anywhere;
}

.empty-state {
    color: var(--muted);
    padding: 48px 28px;
    text-align: center;
}

.pagination {
    align-items: center;
    border-top: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    margin: 0 -24px -18px;
    padding: 14px 24px;
}

.upload-row {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(260px, 1.2fr) minmax(180px, auto) minmax(260px, 1fr);
    padding: 16px 0;
}

.monitor-summary {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: 12px;
}

.upload-row p {
    margin: 4px 0 0;
}

.progress-wrap {
    min-width: 220px;
}

.progress-bar {
    background: #eef2f6;
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
}

.progress-bar span {
    background: var(--primary);
    display: block;
    height: 100%;
}

.flash {
    border-radius: 8px;
    margin-bottom: 18px;
    padding: 12px 14px;
}

.flash.success {
    background: #dcfce7;
    color: #166534;
}

.flash.error {
    background: #fee4e2;
    color: var(--danger);
}

@media (max-width: 720px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        height: auto;
        padding: 16px;
        position: static;
        width: auto;
    }

    .container {
        margin-left: 0;
        padding: 18px;
    }

    table {
        display: block;
        overflow-x: auto;
    }

    .page-heading,
    .lead-row,
    .upload-row {
        align-items: stretch;
        grid-template-columns: 1fr;
    }

    .page-heading {
        flex-direction: column;
    }

    .lead-workspace {
        grid-template-columns: 1fr;
    }

    .filter-rail {
        position: static;
    }

    .lead-actions {
        justify-content: flex-start;
    }
}

.app-admin {
    --bg: #f3f5f8;
    --primary: #1f2937;
    --primary-dark: #111827;
    --primary-soft: #eef2f7;
}

.app-admin .topbar {
    background: #111827;
    border-right-color: #1f2937;
}

.app-admin .brand,
.app-admin nav a {
    color: #e5e7eb;
}

.app-admin nav a:hover {
    background: #263244;
    color: #ffffff;
}

.app-admin .panel {
    margin: 20px 26px;
}

.app-admin table {
    font-size: 14px;
}

.app-admin th {
    background: #eef2f7;
}

.app-admin .page-heading {
    padding: 18px 26px;
}

.search-starter {
    margin: 44px auto;
    max-width: 980px;
    text-align: center;
}

.search-starter h2 {
    font-size: 30px;
    margin: 0 0 26px;
}

.starter-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
}

.starter-card {
    align-items: center;
    background: #fafafa;
    border: 1px solid #f1f1f1;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    padding: 18px 20px;
    text-align: left;
}

.starter-card strong,
.starter-card span {
    display: block;
}

.starter-card strong {
    color: #111827;
    font-size: 16px;
}

.starter-card .button {
    margin: 0;
}

.list-toolbar {
    align-items: center;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 16px;
    justify-content: space-between;
    padding: 18px 30px;
}

.list-tabs {
    display: flex;
    gap: 24px;
}

.list-tabs span {
    color: var(--primary);
    border-bottom: 3px solid var(--primary);
    font-weight: 700;
    padding-bottom: 17px;
}

.list-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.list-actions input {
    min-width: min(360px, 100%);
}

.container > h1,
.container > h2 {
    margin: 0;
    padding: 24px 30px 0;
}

.admin-stats {
    margin: 22px 26px 0;
}

.lead-actions input {
    max-width: 150px;
    padding: 8px 10px;
}

.lead-actions input,
.lead-actions button,
.lead-actions .button {
    font-size: 14px;
}

.filter-rail button[type="submit"] {
    font-size: 17px;
    padding: 13px 16px;
    width: 100%;
}

.filter-rail input,
.filter-rail select,
.filter-rail textarea {
    background: #fff;
}

.filter-rail label {
    color: #303642;
    font-weight: 700;
}

.filter-rail .check-row {
    font-weight: 600;
}

.results-panel {
    min-height: 100vh;
}

.results-toolbar strong {
    font-size: 17px;
}

.app-admin .stat strong {
    font-size: 22px;
}

.app-admin .actions .button,
.app-admin .actions button {
    margin-top: 0;
}

.app-admin .panel:first-of-type {
    margin-top: 20px;
}

.app-admin td,
.app-admin th {
    padding: 12px 10px;
}

.app-admin .status-chip,
.app-admin .pill {
    border-radius: 6px;
}

.approval-batch-actions {
    margin-bottom: 18px;
}

.lead-actions {
    row-gap: 12px;
}

.contact-signal {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: 24px minmax(0, 1fr) auto;
    width: 100%;
}

.contact-signal span {
    align-items: center;
    background: #f3f4f6;
    border-radius: 999px;
    color: #6b7280;
    display: inline-flex;
    height: 24px;
    justify-content: center;
    width: 24px;
}

.contact-signal strong {
    color: #6b7280;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.contact-signal form {
    margin: 0;
}

.contact-signal button {
    background: #f4f0ff;
    border-color: #f4f0ff;
    color: var(--primary);
    margin: 0;
    padding: 7px 12px;
}

.contact-signal button:hover {
    background: #e9ddff;
}

.add-list-button {
    margin-top: 4px;
    width: 100%;
}

.panel > h1:first-child,
.panel > h2:first-child {
    margin-top: 0;
}

.panel form + .muted,
.panel table + .actions {
    margin-top: 14px;
}

.status-chip {
    white-space: nowrap;
}

td .button,
td button {
    margin-top: 0;
}

td input,
td select {
    max-width: 100%;
}

.app-admin .actions input,
.app-admin .actions select {
    max-width: 210px;
}

.user-plan-form {
    align-items: center;
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(120px, 1fr) minmax(140px, 1fr) minmax(130px, 1fr) auto;
}

.user-plan-form input,
.user-plan-form select {
    min-width: 0;
    width: 100%;
}

.user-plan-form button {
    margin-top: 0;
}

.list-name-form {
    align-items: center;
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(180px, 1fr) auto;
}

.list-name-form input {
    min-width: 0;
}

@media (max-width: 720px) {
    .results-toolbar,
    .list-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .list-actions,
    .actions {
        align-items: stretch;
    }

    .actions input,
    .actions select,
    .actions button,
    .actions .button,
    .list-actions input,
    .list-actions button {
        width: 100%;
    }

    .user-plan-form,
    .list-name-form {
        grid-template-columns: 1fr;
    }
}
