:root {
    --ink: #172026;
    --muted: #637083;
    --line: #dbe3ec;
    --surface: #ffffff;
    --soft: #f5f8fb;
    --primary: #146c94;
    --primary-dark: #0d4d68;
    --accent: #f2a541;
    --good: #198754;
    --warn: #b7791f;
    --danger: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    overflow-x: hidden;
    background:
        radial-gradient(circle at top left, rgba(20, 108, 148, 0.12), transparent 32rem),
        linear-gradient(180deg, #f8fbfd 0%, #edf3f7 100%);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

a,
button,
input,
select,
textarea {
    max-width: 100%;
}

.app-navbar {
    background: #102a3a;
    box-shadow: 0 12px 35px rgba(16, 42, 58, 0.18);
}

.navbar-brand,
.app-navbar .nav-link {
    color: #fff;
}

.app-navbar .nav-link {
    opacity: 0.78;
    border-radius: 6px;
    padding-inline: 0.9rem;
}

.app-navbar .nav-link:hover,
.app-navbar .nav-link.active {
    color: #fff;
    opacity: 1;
    background: rgba(255, 255, 255, 0.12);
}

.navbar-toggler {
    border-color: rgba(255, 255, 255, 0.35);
}

.navbar-toggler-icon {
    filter: invert(1);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.7rem;
    height: 2.2rem;
    margin-right: 0.55rem;
    border-radius: 7px;
    color: #102a3a;
    background: var(--accent);
    font-weight: 800;
    letter-spacing: 0;
}

.page-shell {
    min-height: calc(100vh - 64px);
}

.dashboard-hero,
.content-panel,
.scanner-panel,
.login-panel {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(219, 227, 236, 0.95);
    border-radius: 8px;
    box-shadow: 0 18px 55px rgba(23, 32, 38, 0.08);
}

.dashboard-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: clamp(1.2rem, 3vw, 2.2rem);
    overflow: hidden;
    border-left: 6px solid var(--accent);
}

.eyebrow {
    margin: 0 0 0.35rem;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    color: var(--ink);
    font-weight: 800;
    letter-spacing: 0;
}

h1 {
    font-size: clamp(1.8rem, 4vw, 3.2rem);
}

h2 {
    font-size: 1.35rem;
}

.hero-copy,
.panel-head p {
    max-width: 52rem;
    margin: 0.45rem 0 0;
    color: var(--muted);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.stat-card {
    padding: 1.15rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-weight: 700;
    font-size: 0.85rem;
}

.stat-card strong {
    display: block;
    margin-top: 0.45rem;
    color: var(--primary-dark);
    font-size: 2rem;
    line-height: 1;
}

.content-panel,
.scanner-panel {
    padding: clamp(1rem, 2.2vw, 1.6rem);
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.2rem;
}

.lead-table {
    min-width: 760px;
    margin-bottom: 0;
}

.lead-table th {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0;
    border-bottom: 1px solid var(--line);
}

.lead-title {
    font-weight: 800;
}

.lead-subtitle {
    color: var(--muted);
    font-size: 0.92rem;
}

.lead-table a,
.mobile-lead-card a,
.mobile-lead-card dd,
.mobile-lead-address p {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.mobile-lead-list {
    display: none !important;
}

.status-pill {
    display: inline-flex;
    min-width: 5.75rem;
    justify-content: center;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--primary-dark);
    background: #e8f3f8;
}

.status-follow-up {
    color: var(--warn);
    background: #fff4df;
}

.status-converted {
    color: var(--good);
    background: #e8f7ef;
}

.status-not-interested {
    color: var(--danger);
    background: #fdebea;
}

.followup-pill {
    display: inline-flex;
    max-width: 12rem;
    padding: 0.32rem 0.58rem;
    color: #49320c;
    background: #fff4df;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
}

.btn {
    border-radius: 6px;
    font-weight: 750;
}

.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-dark);
    --bs-btn-hover-border-color: var(--primary-dark);
}

.btn-outline-primary {
    --bs-btn-color: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary);
    --bs-btn-hover-border-color: var(--primary);
}

.form-control,
.form-select {
    min-height: 2.8rem;
    border-color: var(--line);
    border-radius: 6px;
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(20, 108, 148, 0.55);
    box-shadow: 0 0 0 0.2rem rgba(20, 108, 148, 0.15);
}

.scan-layout {
    display: grid;
    grid-template-columns: minmax(320px, 0.95fr) minmax(0, 1.25fr);
    gap: 1rem;
    align-items: start;
}

.camera-frame {
    position: relative;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #0f1720;
    border-radius: 8px;
    border: 1px solid #0f1720;
}

.camera-frame video,
.captured-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-placeholder {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    gap: 0.35rem;
    padding: 1.5rem;
    text-align: center;
    color: #c8d6df;
}

.camera-placeholder strong {
    color: #fff;
    font-size: 1.25rem;
}

.scanner-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.7rem;
    margin-top: 1rem;
}

.ocr-status {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-top: 1rem;
    padding: 0.75rem 0.9rem;
    color: var(--primary-dark);
    background: #e8f3f8;
    border-radius: 6px;
    font-weight: 750;
}

.scan-review-hint {
    margin-bottom: 1rem;
    padding: 0.8rem 0.95rem;
    color: #49320c;
    background: #fff4df;
    border: 1px solid #f3d79b;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 700;
}

.scan-success-modal .modal-body {
    padding: 1.5rem;
}

.scan-checkmark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 4rem;
    height: 4rem;
    margin-bottom: 0.8rem;
    color: #fff;
    background: var(--good);
    border-radius: 999px;
    font-size: 2rem;
    font-weight: 900;
}

.scan-success-modal h2 {
    font-size: 1.35rem;
}

.scan-success-modal p {
    color: var(--muted);
}

.lead-form .form-label {
    color: #344252;
    font-weight: 750;
}

.raw-ocr pre {
    max-height: 210px;
    margin-top: 0.8rem;
    padding: 1rem;
    overflow: auto;
    color: #d8e9f2;
    background: #102a3a;
    border-radius: 8px;
    white-space: pre-wrap;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.8rem;
    margin-top: 1.25rem;
}

.card-preview {
    max-width: 520px;
    padding: 0.75rem;
    margin: 0 0 1.2rem;
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.card-preview img {
    display: block;
    width: 100%;
    border-radius: 6px;
}

.login-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 1rem;
}

.login-wrap {
    width: min(100%, 460px);
}

.login-panel {
    padding: clamp(1.3rem, 5vw, 2rem);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1.4rem;
}

.login-brand h1 {
    font-size: 1.8rem;
}

.login-brand p,
.login-hint {
    margin: 0;
    color: var(--muted);
}

.login-hint {
    margin-top: 1rem;
    font-size: 0.88rem;
}

@media (max-width: 991.98px) {
    .dashboard-hero,
    .panel-head {
        align-items: stretch;
        flex-direction: column;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .scan-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767.98px) {
    .lead-table-wrap,
    .desktop-lead-table {
        display: none !important;
    }

    .mobile-lead-list {
        display: grid !important;
        gap: 0.75rem;
    }

    .mobile-empty-state,
    .mobile-lead-card {
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
    }

    .mobile-empty-state {
        padding: 1.4rem 1rem;
        color: var(--muted);
        text-align: center;
    }

    .mobile-lead-card {
        padding: 0.85rem;
    }

    .mobile-lead-head {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 0.75rem;
    }

    .mobile-lead-head h3 {
        margin: 0;
        font-size: 1rem;
        font-weight: 850;
        line-height: 1.25;
    }

    .mobile-lead-head p {
        margin: 0.15rem 0 0;
        color: var(--muted);
        font-size: 0.82rem;
        line-height: 1.35;
    }

    .mobile-lead-head .status-pill {
        flex: 0 0 auto;
        min-width: auto;
        padding: 0.28rem 0.55rem;
        font-size: 0.68rem;
        white-space: nowrap;
    }

    .mobile-lead-role {
        margin-top: 0.55rem;
        padding: 0.45rem 0.55rem;
        color: #344252;
        background: var(--soft);
        border-radius: 6px;
        font-size: 0.8rem;
        font-weight: 750;
    }

    .mobile-lead-details {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.5rem;
        margin: 0.75rem 0 0;
    }

    .mobile-lead-details div {
        display: grid;
        grid-template-columns: 4.6rem minmax(0, 1fr);
        gap: 0.6rem;
        align-items: baseline;
        padding-bottom: 0.45rem;
        border-bottom: 1px solid #edf2f6;
    }

    .mobile-lead-details dt,
    .mobile-lead-address span {
        color: var(--muted);
        font-size: 0.7rem;
        font-weight: 850;
        text-transform: uppercase;
    }

    .mobile-lead-details dd {
        margin: 0;
        color: var(--ink);
        font-size: 0.86rem;
        text-align: right;
    }

    .mobile-lead-compact {
        margin-top: 0.65rem;
    }

    .mobile-followup-form {
        margin-top: 0.75rem;
        padding: 0.7rem;
        background: #f7fafc;
        border: 1px solid #edf2f6;
        border-radius: 8px;
    }

    .mobile-followup-form label {
        display: block;
        margin-bottom: 0.4rem;
        color: var(--muted);
        font-size: 0.72rem;
        font-weight: 850;
        text-transform: uppercase;
    }

    .mobile-followup-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 4.2rem;
        gap: 0.45rem;
    }

    .mobile-followup-row .form-select,
    .mobile-followup-row .btn,
    .mobile-followup-date {
        min-height: 2.25rem;
        font-size: 0.82rem;
    }

    .mobile-followup-date {
        margin-top: 0.45rem;
    }

    .followup-track {
        height: 0.38rem;
        margin-top: 0.55rem;
        overflow: hidden;
        background: #e1eaf0;
        border-radius: 999px;
    }

    .followup-track span {
        display: block;
        height: 100%;
        background: linear-gradient(90deg, var(--accent), var(--primary));
        border-radius: inherit;
    }

    .mobile-view-more {
        width: 100%;
        margin-top: 0.75rem;
        min-height: 2.35rem;
    }

    .mobile-lead-more {
        padding-top: 0.2rem;
    }

    .mobile-lead-address {
        margin-top: 0.75rem;
        padding: 0.65rem;
        background: #f7fafc;
        border-radius: 6px;
    }

    .mobile-lead-address p {
        margin: 0.25rem 0 0;
        color: #344252;
        font-size: 0.84rem;
        line-height: 1.4;
    }

    .mobile-edit-btn {
        width: 100%;
        margin-top: 0.8rem;
        min-height: 2.35rem;
    }
}

@media (max-width: 575.98px) {
    body {
        background: linear-gradient(180deg, #f8fbfd 0%, #edf3f7 100%);
    }

    .app-navbar .container-fluid {
        min-height: 54px;
    }

    .brand-mark {
        width: 2.15rem;
        height: 1.85rem;
        margin-right: 0.45rem;
        font-size: 0.88rem;
    }

    .navbar-brand {
        font-size: 1rem;
    }

    .dashboard-page {
        padding-top: 1.25rem !important;
        padding-bottom: 1.25rem !important;
    }

    .dashboard-hero {
        gap: 0.8rem;
        padding: 1rem 1rem 1rem 0.95rem;
        border-left-width: 4px;
    }

    .dashboard-hero .btn {
        min-height: 2.65rem;
        padding-block: 0.45rem;
        font-size: 1rem;
    }

    .hero-copy {
        font-size: 0.9rem;
        line-height: 1.45;
    }

    .eyebrow {
        margin-bottom: 0.25rem;
        font-size: 0.68rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.65rem;
        margin-top: 0.85rem !important;
    }

    .stat-card {
        min-height: 5.35rem;
        padding: 0.85rem;
    }

    .stat-card span {
        min-height: 2.1rem;
        font-size: 0.76rem;
        line-height: 1.3;
    }

    .stat-card strong {
        margin-top: 0.2rem;
        font-size: 1.65rem;
    }

    .content-panel,
    .scanner-panel {
        padding: 0.9rem;
    }

    .leads-panel {
        margin-top: 0.85rem !important;
    }

    .panel-head {
        gap: 0.7rem;
        margin-bottom: 0.9rem;
    }

    .panel-head h2 {
        font-size: 1.15rem;
    }

    .panel-head p {
        font-size: 0.86rem;
        line-height: 1.45;
    }

    .panel-head .btn {
        min-height: 2.55rem;
    }

    .lead-filter-form {
        margin-bottom: 0.85rem !important;
    }

    .lead-filter-form .form-control,
    .lead-filter-form .form-select,
    .lead-filter-form .btn {
        min-height: 2.4rem;
        font-size: 0.86rem;
    }

    .lead-filter-form .col-8 {
        width: 58%;
    }

    .lead-filter-form .col-4 {
        width: 42%;
    }

    .scanner-actions {
        grid-template-columns: 1fr;
    }

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

    .form-actions .btn {
        width: 100%;
    }

    h1 {
        font-size: 1.8rem;
    }
}
