:root {
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --green-50: #f0fdf4;
    --green-100: #dcfce7;
    --green-200: #bbf7d0;
    --green-700: #15803d;
    --red-50: #fef2f2;
    --red-100: #fee2e2;
    --red-200: #fecaca;
    --red-700: #b91c1c;
    --amber-100: #fef3c7;
    --amber-800: #92400e;
    --cyan-100: #cffafe;
    --cyan-700: #0e7490;
    --indigo-100: #e0e7ff;
    --indigo-700: #4338ca;
    --slate-100: #f1f5f9;
    --slate-700: #334155;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 18px 45px rgba(15, 23, 42, 0.12);
    --shadow-modal: 0 24px 70px rgba(15, 23, 42, 0.28);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
}

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

html {
    min-height: 100%;
    background: var(--gray-100);
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--gray-100);
    color: var(--gray-800);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body.modal-open {
    overflow: hidden;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    border: 0;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.hidden {
    display: none !important;
}

.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;
}

.noscript-message,
.offline-banner {
    width: 100%;
    padding: 0.8rem 1rem;
    text-align: center;
    font-size: 0.9rem;
}

.noscript-message {
    background: var(--red-700);
    color: var(--white);
}

.offline-banner {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--amber-100);
    color: var(--amber-800);
    border-bottom: 1px solid #fcd34d;
}

.page-shell {
    width: min(100%, 80rem);
    margin: 0 auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Authentication */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    background: var(--gray-50);
}

.auth-card {
    width: min(100%, 28rem);
    padding: 2rem;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.brand-block {
    text-align: center;
}

.brand-block h1 {
    margin: 0;
    color: var(--gray-900);
    font-size: clamp(1.8rem, 5vw, 2.15rem);
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.brand-block p {
    margin: 0.55rem 0 0;
    color: var(--gray-600);
    font-size: 0.9rem;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem;
    margin-top: 2rem;
    padding: 0.25rem;
    background: var(--gray-100);
    border-radius: var(--radius-md);
}

.auth-tab {
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--gray-600);
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
}

.auth-tab:hover {
    color: var(--gray-900);
}

.auth-tab.is-active {
    background: var(--white);
    color: var(--blue-700);
    box-shadow: var(--shadow-sm);
}

.auth-form {
    display: grid;
    gap: 1.25rem;
    margin-top: 1.5rem;
}

.stacked-fields {
    overflow: hidden;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.field-group + .field-group {
    border-top: 1px solid var(--gray-300);
}

.stacked-fields input {
    width: 100%;
    min-height: 3rem;
    padding: 0.75rem 0.85rem;
    border: 0;
    outline: 0;
    color: var(--gray-900);
    background: var(--white);
}

.stacked-fields input::placeholder,
textarea::placeholder,
.search-input::placeholder {
    color: var(--gray-500);
}

.stacked-fields input:focus {
    box-shadow: inset 0 0 0 2px var(--blue-500);
}

.form-help {
    margin: -0.15rem 0 0;
    text-align: center;
    color: var(--gray-500);
    font-size: 0.78rem;
    line-height: 1.45;
}

/* Buttons and messages */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.55rem;
    padding: 0.62rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.button:focus-visible,
.button-link:focus-visible,
.auth-tab:focus-visible,
.modal-close:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(59, 130, 246, 0.28);
    outline-offset: 2px;
}

.button-primary {
    background: var(--blue-600);
    border-color: var(--blue-600);
    color: var(--white);
}

.button-primary:hover:not(:disabled) {
    background: var(--blue-700);
    border-color: var(--blue-700);
}

.button-secondary {
    background: var(--white);
    border-color: var(--gray-300);
    color: var(--gray-700);
}

.button-secondary:hover:not(:disabled) {
    background: var(--gray-50);
}

.button-full {
    width: 100%;
    min-height: 3rem;
}

.button-small {
    width: 100%;
    min-height: 2.2rem;
    padding: 0.52rem 0.72rem;
    font-size: 0.75rem;
}

.button-link {
    padding: 0.35rem 0;
    background: transparent;
    color: var(--gray-500);
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
}

.button-link:hover {
    color: var(--gray-800);
}

.message {
    padding: 0.75rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

.message-error {
    background: var(--red-50);
    border-color: var(--red-200);
    color: var(--red-700);
}

.message-success {
    background: var(--green-50);
    border-color: var(--green-200);
    color: var(--green-700);
}

.auth-form .message {
    text-align: center;
}

/* Dashboard */
.dashboard {
    min-height: 100vh;
}

.top-nav {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
}

.nav-inner {
    min-height: 4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 0.7rem;
    padding-bottom: 0.7rem;
}

.nav-brand {
    color: var(--gray-800);
    font-size: 1.22rem;
    font-weight: 600;
    white-space: nowrap;
}

.nav-brand-primary {
    color: var(--blue-600);
    font-weight: 800;
}

.nav-account {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.account-details {
    text-align: right;
}

.account-email {
    color: var(--gray-700);
    font-size: 0.875rem;
    font-weight: 600;
}

.account-access {
    color: var(--gray-500);
    font-size: 0.75rem;
}

.workspace {
    padding-top: 2rem;
    padding-bottom: 2rem;
}

.workspace-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.workspace-header h2 {
    margin: 0;
    color: var(--gray-900);
    font-size: 1.55rem;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.workspace-header p {
    margin: 0.4rem 0 0;
    color: var(--gray-600);
    font-size: 0.9rem;
}

.lead-count {
    color: var(--gray-600);
    font-size: 0.875rem;
    font-weight: 700;
    white-space: nowrap;
}

.panel,
.table-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.search-panel {
    margin-bottom: 1.5rem;
    padding: 1rem;
}

.search-form {
    display: flex;
    gap: 0.75rem;
}

.search-input,
.field-block select,
.field-block textarea {
    width: 100%;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--gray-900);
}

.search-input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 2.55rem;
    padding: 0.62rem 0.8rem;
}

.search-input:focus,
.field-block select:focus,
.field-block textarea:focus {
    border-color: var(--blue-500);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

.workspace-message {
    margin-bottom: 1.5rem;
}

/* Lead table */
.table-card {
    overflow: hidden;
}

.table-scroll {
    overflow-x: auto;
}

.lead-table {
    width: 100%;
    min-width: 66rem;
    border-collapse: collapse;
}

.lead-table thead {
    background: var(--gray-50);
}

.lead-table th {
    padding: 0.78rem 1.25rem;
    color: var(--gray-600);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.055em;
    text-align: left;
    text-transform: uppercase;
}

.lead-table td {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-200);
    color: var(--gray-700);
    font-size: 0.875rem;
    vertical-align: top;
}

.lead-table tbody tr:hover {
    background: var(--gray-50);
}

.align-right,
.action-cell {
    text-align: right !important;
}

.business-cell,
.text-cell {
    max-width: 18rem;
}

.address-cell {
    max-width: 24rem;
}

.nowrap-cell,
.action-cell {
    white-space: nowrap;
}

.business-name {
    color: var(--gray-900);
    font-weight: 700;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    margin-top: 0.5rem;
    padding: 0.22rem 0.62rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    white-space: nowrap;
}

.status-new {
    background: var(--gray-100);
    color: var(--gray-700);
}

.status-researching {
    background: var(--blue-100);
    color: var(--blue-700);
}

.status-ready {
    background: var(--indigo-100);
    color: var(--indigo-700);
}

.status-contacted {
    background: var(--cyan-100);
    color: var(--cyan-700);
}

.status-follow-up {
    background: var(--amber-100);
    color: var(--amber-800);
}

.status-converted {
    background: var(--green-100);
    color: var(--green-700);
}

.status-not-interested {
    background: var(--red-100);
    color: var(--red-700);
}

.status-not-fit {
    background: var(--slate-100);
    color: var(--slate-700);
}

.action-buttons {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
}

.empty-table-cell {
    padding: 3rem 1.25rem !important;
    color: var(--gray-500) !important;
    text-align: center;
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
}

.page-summary {
    color: var(--gray-600);
    font-size: 0.875rem;
}

.pagination-actions {
    display: flex;
    gap: 0.5rem;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    overflow-y: auto;
    background: rgba(17, 24, 39, 0.62);
}

.modal-card {
    width: min(100%, 36rem);
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-eyebrow {
    margin: 0;
    color: var(--blue-600);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.modal-header h3 {
    margin: 0.22rem 0 0;
    color: var(--gray-900);
    font-size: 1.25rem;
    line-height: 1.25;
}

.modal-subtitle {
    margin: 0.3rem 0 0;
    color: var(--gray-500);
    font-size: 0.875rem;
}

.modal-close {
    min-width: 2.3rem;
    min-height: 2.3rem;
    padding: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--gray-400);
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.modal-form {
    display: grid;
    gap: 1.25rem;
    padding: 1.5rem;
}

.field-block label {
    display: block;
    color: var(--gray-700);
    font-size: 0.875rem;
    font-weight: 700;
}

.field-block select {
    min-height: 2.65rem;
    margin-top: 0.5rem;
    padding: 0.6rem 0.75rem;
}

.field-block textarea {
    min-height: 9.5rem;
    margin-top: 0.5rem;
    padding: 0.75rem;
    resize: vertical;
}

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

.field-label-row span {
    color: var(--gray-500);
    font-size: 0.75rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--gray-100);
}

@media (min-width: 640px) {
    .page-shell {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }

    .auth-card {
        padding: 2.5rem;
    }
}

@media (min-width: 1024px) {
    .page-shell {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

@media (max-width: 700px) {
    .account-details {
        display: none;
    }

    .workspace-header,
    .pagination-bar {
        align-items: flex-start;
        flex-direction: column;
    }

    .search-form {
        flex-direction: column;
    }

    .search-form .button {
        width: 100%;
    }

    .pagination-actions {
        width: 100%;
    }

    .pagination-actions .button {
        flex: 1 1 0;
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-actions .button {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}