@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;1,600&display=swap");

:root {
    --crm-font: "Times New Roman", Times, serif;
    --crm-sidebar-bg: linear-gradient(165deg, #0f172a 0%, #1e293b 48%, #172554 100%);
    --crm-sidebar-text: #e2e8f0;
    --crm-sidebar-muted: #94a3b8;
    --crm-sidebar-border: rgba(148, 163, 184, 0.12);
    --crm-accent: #6366f1;
    --crm-accent-hover: #4f46e5;
    --crm-accent-soft: rgba(99, 102, 241, 0.15);
    --crm-accent-glow: rgba(99, 102, 241, 0.35);
    --crm-text: #0f172a;
    --crm-muted: #64748b;
    --crm-body-bg: #f1f5f9;
    --crm-card-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
    --crm-card-shadow-hover: 0 16px 48px rgba(15, 23, 42, 0.12);
    --crm-radius: 1rem;
    --crm-radius-sm: 0.65rem;
    --crm-success: #059669;
    --crm-warning: #d97706;
    --crm-danger: #dc2626;
    --crm-info: #2563eb;
}

/* ——— Base ——— */
body {
    font-family: var(--crm-font);
    color: var(--crm-text);
    background: var(--crm-body-bg);
    -webkit-font-smoothing: antialiased;
}

body.crm-app-body {
    min-height: 100vh;
}

/* ——— Auth (guest) ——— */
body.crm-auth-body {
    min-height: 100vh;
    background: radial-gradient(1200px 600px at 10% -10%, rgba(99, 102, 241, 0.35), transparent),
        radial-gradient(900px 500px at 100% 20%, rgba(14, 165, 233, 0.22), transparent),
        linear-gradient(160deg, #0f172a 0%, #1e1b4b 45%, #312e81 100%);
    font-family: var(--crm-font);
}

.crm-auth-shell {
    max-width: 440px;
}

.crm-auth-brand {
    color: #fff;
    text-shadow: 0 2px 24px rgba(99, 102, 241, 0.4);
}

.crm-auth-brand .crm-auth-emoji {
    font-size: 2.75rem;
    line-height: 1;
    display: block;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.25));
}

.crm-auth-card {
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--crm-radius);
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
    backdrop-filter: blur(12px);
}

.crm-auth-card .form-control {
    border-radius: var(--crm-radius-sm);
    border-color: #e2e8f0;
    padding: 0.65rem 0.9rem;
}

.crm-auth-card .form-control:focus {
    border-color: var(--crm-accent);
    box-shadow: 0 0 0 3px var(--crm-accent-soft);
}

.btn-crm-gradient {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 50%, #4338ca 100%);
    border: none;
    color: #fff !important;
    font-weight: 600;
    padding: 0.65rem 1.25rem;
    border-radius: var(--crm-radius-sm);
    box-shadow: 0 8px 24px var(--crm-accent-glow);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-crm-gradient:hover {
    color: #fff !important;
    transform: translateY(-1px);
    box-shadow: 0 12px 32px rgba(99, 102, 241, 0.45);
}

.btn-crm-gradient:active {
    transform: translateY(0);
}

.crm-auth-hint {
    color: rgba(226, 232, 240, 0.85);
    font-size: 0.875rem;
}

/* ——— App shell ——— */
.crm-sidebar {
    min-height: 100vh;
    background: var(--crm-sidebar-bg);
    border-right: 1px solid var(--crm-sidebar-border);
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.15);
}

.crm-sidebar .nav-link {
    color: var(--crm-sidebar-text);
    border-radius: var(--crm-radius-sm);
    padding: 0.55rem 0.85rem;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.crm-sidebar .nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.crm-sidebar .nav-link.active {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.35), rgba(99, 102, 241, 0.08));
    color: #fff;
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.35);
}

.crm-sidebar .text-muted {
    color: var(--crm-sidebar-muted) !important;
}

.crm-sidebar-brand-title {
    color: #fff;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-size: 1.05rem;
}

.crm-sidebar-emoji {
    font-size: 1.75rem;
    line-height: 1;
    margin-bottom: 0.35rem;
}

.crm-navbar {
    position: relative;
    z-index: 1040;
    background: rgba(255, 255, 255, 0.98);
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
}

/* Open menus must paint above dashboard cards / heroes (flex paint order + stacking). */
.crm-navbar .dropdown-menu {
    z-index: 1060 !important;
}

.crm-navbar .navbar-brand,
.crm-navbar .btn-light {
    font-family: var(--crm-font);
}

.crm-main-inner {
    max-width: none;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.crm-card {
    background: #fff;
    border: 1px solid #e8ecf1;
    border-radius: var(--crm-radius);
    box-shadow: var(--crm-card-shadow);
    transition: box-shadow 0.2s ease;
}

.crm-card:hover {
    box-shadow: var(--crm-card-shadow-hover);
}

/* ——— Dashboard ——— */
.crm-dash-hero {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 40%, #4338ca 100%);
    color: #fff;
    border-radius: var(--crm-radius);
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 16px 48px rgba(49, 46, 129, 0.35);
    position: relative;
    overflow: hidden;
}

.crm-dash-hero::after {
    content: "";
    position: absolute;
    top: -40%;
    right: -10%;
    width: 50%;
    height: 140%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.12), transparent 65%);
    pointer-events: none;
}

.crm-dash-hero h1 {
    font-weight: 700;
    letter-spacing: -0.03em;
    position: relative;
    z-index: 1;
}

.crm-dash-hero p {
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

.crm-section {
    margin-bottom: 2rem;
}

.crm-section-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
}

.crm-section-head .crm-section-emoji {
    font-size: 1.35rem;
    line-height: 1;
}

.crm-section-head h2 {
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--crm-muted);
    margin: 0;
}

.crm-kpi-card {
    display: block;
    text-decoration: none;
    color: inherit;
    border-radius: var(--crm-radius);
    padding: 1.15rem 1.25rem;
    border: 1px solid #e8ecf1;
    background: #fff;
    box-shadow: var(--crm-card-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.crm-kpi-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: var(--crm-radius) var(--crm-radius) 0 0;
    opacity: 0.95;
}

.crm-kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--crm-card-shadow-hover);
    color: inherit;
    border-color: #cbd5e1;
}

.crm-kpi-card .crm-kpi-emoji {
    font-size: 1.5rem;
    line-height: 1;
    margin-bottom: 0.35rem;
}

.crm-kpi-card .crm-kpi-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--crm-muted);
}

.crm-kpi-card .crm-kpi-value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.crm-kpi-card .crm-kpi-hint {
    font-size: 0.72rem;
    color: var(--crm-muted);
    margin-top: 0.35rem;
}

.crm-kpi--pending::before {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}
.crm-kpi--verified::before {
    background: linear-gradient(90deg, #10b981, #34d399);
}
.crm-kpi--rejected::before {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.crm-kpi--processing::before {
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
}
.crm-kpi--retention::before {
    background: linear-gradient(90deg, #059669, #10b981);
}
.crm-kpi--earlyexit::before {
    background: linear-gradient(90deg, #db2777, #f472b6);
}
.crm-kpi--dropped::before {
    background: linear-gradient(90deg, #6366f1, #818cf8);
}

.crm-pay-panel {
    border-radius: var(--crm-radius);
    border: 1px solid #e8ecf1;
    background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
    box-shadow: var(--crm-card-shadow);
    overflow: hidden;
}

.crm-pay-panel-head {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.12), rgba(14, 165, 233, 0.08));
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e8ecf1;
}

.crm-pay-stat {
    padding: 1rem 1.25rem;
    border-radius: var(--crm-radius-sm);
    background: #fff;
    border: 1px solid #f1f5f9;
    height: 100%;
}

.crm-pay-stat .label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--crm-muted);
}

.crm-pay-stat .value {
    font-size: 1.35rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.stat-tile {
    border-radius: var(--crm-radius);
    padding: 1.25rem;
    border: 1px solid #e8ecf1;
    border-left: 4px solid transparent;
}

.stat-tile h3 {
    font-size: 1.75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.notification-dropdown {
    width: min(100vw - 2rem, 380px);
    max-height: 420px;
    overflow-y: auto;
}

@media (max-width: 576px) {
    .notification-dropdown {
        width: calc(100vw - 1rem);
        left: 0.5rem !important;
        right: auto !important;
    }
}

.notification-item {
    border-bottom: 1px solid #eef1f4;
    transition: background 0.15s ease;
}

.notification-item:hover {
    background: #f8fafc;
}

.notification-item.unread {
    background: #eff6ff;
}

.notification-item.unread:hover {
    background: #e0edfc;
}

.table-crm thead th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--crm-muted);
    border-bottom-width: 1px;
    font-weight: 600;
}

.crm-pin-boxes {
    max-width: 11rem;
}

.crm-pin-box {
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    font-size: 1.35rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
    border-radius: var(--crm-radius-sm);
    border: 2px solid #e2e8f0;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.crm-pin-box:focus {
    border-color: var(--crm-accent);
    box-shadow: 0 0 0 3px var(--crm-accent-soft);
}

@media (min-width: 576px) {
    .crm-pin-box {
        width: 3rem;
        height: 3rem;
        font-size: 1.5rem;
    }

    .crm-pin-boxes {
        max-width: 12.5rem;
    }
}

/* Status badges */
.crm-badge {
    display: inline-block;
    padding: 0.28rem 0.55rem;
    border-radius: 0.375rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: capitalize;
    line-height: 1.2;
}

.crm-badge--pending {
    background: #fef3c7;
    color: #92400e;
}

.crm-badge--verified {
    background: #d1fae5;
    color: #065f46;
}

.crm-badge--rejected {
    background: #fee2e2;
    color: #991b1b;
}

.crm-badge--dropped {
    background: #e0e7ff;
    color: #3730a3;
}

.crm-badge--completed {
    background: #dbeafe;
    color: #1e40af;
}

.crm-badge--active {
    background: #d1fae5;
    color: #047857;
}

.crm-badge--exit {
    background: #fce7f3;
    color: #9d174d;
}

tr.crm-row-status-pending td {
    background: rgba(254, 243, 199, 0.35);
}

tr.crm-row-status-verified td {
    background: rgba(209, 250, 229, 0.35);
}

tr.crm-row-status-rejected td {
    background: rgba(254, 226, 226, 0.35);
}

tr.crm-row-status-dropped td {
    /* clear red so Dropped reads as a negative outcome at a glance */
    background: rgba(252, 165, 165, 0.55);
}

tr.crm-row-status-completed td {
    background: rgba(219, 234, 254, 0.35);
}

tr.crm-row-status-active td {
    /* deeper emerald so Active is visually distinct from Verified's pale mint */
    background: rgba(110, 231, 183, 0.55);
}

tr.crm-row-status-exit td {
    background: rgba(252, 231, 243, 0.45);
}

.crm-card-joiner-status-pending {
    border-left: 4px solid #f59e0b;
    background: linear-gradient(90deg, rgba(254, 243, 199, 0.25) 0%, #fff 12%);
}

.crm-card-joiner-status-verified {
    border-left: 4px solid #10b981;
    background: linear-gradient(90deg, rgba(209, 250, 229, 0.25) 0%, #fff 12%);
}

.crm-card-joiner-status-rejected {
    border-left: 4px solid #ef4444;
    background: linear-gradient(90deg, rgba(254, 226, 226, 0.25) 0%, #fff 12%);
}

.crm-card-joiner-status-dropped {
    border-left: 4px solid #dc2626;
    background: linear-gradient(90deg, rgba(252, 165, 165, 0.55) 0%, #fff 18%);
}

.crm-card-joiner-status-completed {
    border-left: 4px solid #3b82f6;
    background: linear-gradient(90deg, rgba(219, 234, 254, 0.35) 0%, #fff 12%);
}

.crm-card-joiner-status-active {
    border-left: 4px solid #047857;
    background: linear-gradient(90deg, rgba(110, 231, 183, 0.55) 0%, #fff 18%);
}

.crm-card-joiner-status-exit {
    border-left: 4px solid #db2777;
    background: linear-gradient(90deg, rgba(252, 231, 243, 0.4) 0%, #fff 12%);
}

.stat-tile--pending {
    background: #fffbeb;
    border-left-color: #f59e0b;
}

.stat-tile--verified {
    background: #ecfdf5;
    border-left-color: #10b981;
}

.stat-tile--rejected {
    background: #fef2f2;
    border-left-color: #ef4444;
}

.stat-tile--dropped {
    background: #eef2ff;
    border-left-color: #6366f1;
}

.stat-tile--neutral {
    background: #f8fafc;
    border-left-color: #94a3b8;
}

.stat-tile--active {
    background: #ecfdf5;
    border-left-color: #059669;
}

.stat-tile--completed {
    background: #eff6ff;
    border-left-color: #2563eb;
}

.stat-tile--exit {
    background: #fdf2f8;
    border-left-color: #db2777;
}

.ts-sm .ts-control,
.ts-sm .ts-wrapper.single .ts-control {
    min-height: calc(1.5em + 0.5rem + 2px);
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Bootstrap tweaks */
.btn-primary {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    border-color: #4f46e5;
    font-weight: 600;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4f46e5, #4338ca);
    border-color: #4338ca;
}

.alert {
    border-radius: var(--crm-radius-sm);
}

/* Inner page titles */
.crm-page-head {
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

/* List pages: tables span full content width inside the scroll/card area */
.crm-data-scroll .table {
    width: 100%;
    max-width: 100%;
}

/* ——— Desktop (lg+): viewport-height shell, data-only scroll ——— */
@media (min-width: 992px) {
    html.crm-app-html,
    html.crm-app-html body.crm-app-body {
        height: 100%;
        overflow: hidden;
    }

    .container-fluid > .row.g-0 {
        min-height: 100vh;
        max-height: 100vh;
    }

    .crm-app-main-col {
        min-height: 0;
        max-height: 100vh;
        overflow: hidden;
        position: relative;
    }

    .crm-app-main-col > .crm-navbar {
        z-index: 1040;
    }

    .crm-app-main {
        position: relative;
        z-index: 0;
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .crm-app-main-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .crm-page-frame {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .crm-page-sticky {
        flex-shrink: 0;
    }

    .crm-page-frame > .crm-page-head {
        margin-bottom: 0.65rem;
        padding-bottom: 0.5rem;
    }

    .crm-data-scroll {
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
        align-self: stretch;
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .crm-data-scroll .table {
        margin-bottom: 0;
    }

    .crm-data-scroll .table thead th {
        position: sticky;
        top: 0;
        z-index: 3;
        box-shadow: inset 0 -1px 0 #dee2e6;
    }

    .crm-data-scroll .table thead.table-light th {
        background-color: #f8f9fa;
    }

    .crm-data-scroll.crm-card {
        border: 1px solid #e8ecf1;
        border-radius: var(--crm-radius);
        box-shadow: var(--crm-card-shadow);
    }

    /* Dashboard: fit viewport, optional small scroll only inside pay table */
    .crm-app-main-body--dashboard {
        overflow: hidden;
    }

    .crm-dash-fit {
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 0;
        overflow: hidden;
        gap: 0.4rem;
    }

    .crm-dash-fit .crm-dash-hero {
        margin-bottom: 0 !important;
        padding: 0.55rem 1rem !important;
        flex-shrink: 0;
    }

    .crm-dash-fit .crm-dash-hero h1 {
        font-size: 1.05rem !important;
        margin-bottom: 0.15rem !important;
    }

    .crm-dash-fit .crm-dash-hero p {
        font-size: 0.75rem !important;
    }

    .crm-dash-fit .crm-section {
        margin-bottom: 0 !important;
        flex-shrink: 0;
    }

    .crm-dash-fit .crm-dash-pay-section {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .crm-dash-fit .crm-dash-pay-section .crm-section-head {
        flex-shrink: 0;
    }

    .crm-dash-fit .crm-section-head {
        margin-bottom: 0.35rem;
        padding-bottom: 0.25rem;
    }

    .crm-dash-fit .crm-section-head h2 {
        font-size: 0.78rem !important;
    }

    .crm-dash-fit .crm-section > .text-muted.small.mb-3 {
        display: none;
    }

    .crm-dash-fit .row.g-3 {
        --bs-gutter-y: 0.35rem;
        --bs-gutter-x: 0.35rem;
    }

    .crm-dash-fit .crm-kpi-card {
        padding: 0.45rem 0.65rem;
    }

    .crm-dash-fit .crm-kpi-emoji {
        font-size: 1.1rem;
        margin-bottom: 0.1rem;
    }

    .crm-dash-fit .crm-kpi-value {
        font-size: 1.2rem !important;
    }

    .crm-dash-fit .crm-kpi-hint {
        display: none;
    }

    .crm-dash-fit .crm-pay-panel {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .crm-dash-fit .crm-pay-panel-head {
        padding: 0.5rem 0.85rem !important;
        flex-shrink: 0;
    }

    .crm-dash-fit .crm-pay-panel > .p-3,
    .crm-dash-fit .crm-pay-panel > .p-md-4 {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        padding: 0.6rem !important;
    }

    .crm-dash-fit .crm-pay-panel .row.g-3.mb-4,
    .crm-dash-fit .crm-pay-panel .row.g-3.mb-3 {
        margin-bottom: 0.35rem !important;
        flex-shrink: 0;
    }

    .crm-dash-fit .crm-pay-stat {
        padding: 0.45rem 0.55rem;
    }

    .crm-dash-fit .crm-pay-stat .value {
        font-size: 1.05rem !important;
    }

    .crm-dash-fit .crm-pay-panel .small.text-muted.mb-2,
    .crm-dash-fit .crm-pay-panel > div > p.small {
        flex-shrink: 0;
        margin-bottom: 0.25rem !important;
        font-size: 0.68rem !important;
    }

    .crm-dash-fit .crm-dash-pay-table-wrap {
        flex: 1 1 auto;
        min-height: 0;
        overflow: auto;
        border: 1px solid #e8ecf1;
        border-radius: var(--crm-radius-sm);
        background: #fff;
    }

    .crm-dash-fit .crm-dash-pay-table-wrap .table {
        margin-bottom: 0;
    }

    .crm-dash-fit .crm-dash-pay-table-wrap thead th {
        position: sticky;
        top: 0;
        z-index: 2;
        background: #f8f9fa;
        box-shadow: inset 0 -1px 0 #dee2e6;
    }

    .crm-dash-fit .crm-dash-quick-card {
        flex-shrink: 0;
        padding: 0.45rem 0.65rem !important;
        margin-bottom: 0 !important;
    }

    .crm-dash-fit .crm-dash-quick-card .btn {
        padding: 0.2rem 0.5rem;
        font-size: 0.75rem;
    }

    .crm-dash-fit .crm-dash-freelancer-extra {
        flex-shrink: 0;
    }
}

/* Tablet / phone: natural document scroll */
@media (max-width: 991.98px) {
    html.crm-app-html,
    html.crm-app-html body.crm-app-body {
        height: auto;
        overflow-x: hidden;
    }

    .container-fluid > .row.g-0 {
        min-height: auto;
        max-height: none;
    }

    .crm-app-main-col {
        max-height: none;
    }

    .crm-app-main {
        display: block;
        overflow: visible;
        min-height: auto;
    }

    .crm-app-main-body {
        display: block;
        overflow: visible;
        min-height: auto;
    }

    .crm-page-frame {
        display: block;
        overflow: visible;
        min-height: auto;
    }

    .crm-data-scroll {
        overflow: visible !important;
        max-height: none !important;
    }
}
