/* --------------------------------------------------------------------------
   CRM — admin shell, tables, charts.
   Written to stand on its own; Bootstrap only supplies the reset + grid.
   -------------------------------------------------------------------------- */

:root {
    --plane: #f5f6f8;
    --surface: #ffffff;
    --sidebar: #101828;
    --sidebar-hover: #1b2639;
    --sidebar-ink: #98a4b8;
    --sidebar-ink-on: #ffffff;

    --ink: #0f1729;
    --ink-2: #52596b;
    --ink-muted: #8b91a0;

    --line: #e6e8ed;
    --line-soft: #eef0f4;

    --accent: #2a78d6;
    --accent-soft: #eaf2fc;

    --ok: #0ca30c;
    --warn: #b57500;
    --danger: #d03b3b;
    --violet: #4a3aa7;

    --radius: 10px;
    --shadow: 0 1px 2px rgba(15, 23, 41, .06), 0 1px 3px rgba(15, 23, 41, .04);

    --sidebar-w: 248px;
    --topbar-h: 62px;
}

body {
    background: var(--plane);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ---------------------------------------------------------------- sidebar */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--sidebar);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .22s ease;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--topbar-h);
    padding: 0 20px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -.01em;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.sidebar__mark {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 13px;
}

.sidebar__label {
    padding: 20px 20px 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #5d6880;
}

.sidebar__nav {
    padding: 0 12px;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    color: var(--sidebar-ink);
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
}

.sidebar__link i {
    width: 18px;
    font-size: 14px;
    text-align: center;
}

.sidebar__link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-ink-on);
}

.sidebar__link.is-active {
    background: var(--accent);
    color: #fff;
}

.sidebar__foot {
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, .07);
}

.sidebar__logout {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--sidebar-ink);
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
}

.sidebar__logout i {
    width: 18px;
    font-size: 14px;
    text-align: center;
}

.sidebar__logout:hover {
    background: rgba(208, 59, 59, .16);
    color: #ff9c9c;
}

.sidebar__scrim {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 41, .45);
    z-index: 1035;
    display: none;
}

/* ------------------------------------------------------------------ shell */

.shell {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 28px;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}

.topbar__title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -.01em;
    margin: 0;
}

.topbar__sub {
    color: var(--ink-muted);
    font-size: 13px;
}

.topbar__toggle {
    display: none;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink-2);
}

/* ---------------------------------------------------------- account menu */

.user-menu {
    margin-left: auto;
    position: relative;
}

.user-menu__btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 4px 4px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--ink);
    font-size: 13px;
    font-weight: 500;
    transition: background .15s ease, border-color .15s ease;
}

.user-menu__btn:hover {
    background: #f1f3f6;
    border-color: var(--line);
}

.user-menu.is-open .user-menu__btn {
    background: #f1f3f6;
    border-color: var(--line);
}

.user-menu__caret {
    font-size: 10px;
    color: var(--ink-muted);
    transition: transform .18s ease;
}

.user-menu.is-open .user-menu__caret {
    transform: rotate(180deg);
}

.user-menu__panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 232px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(15, 23, 41, .12), 0 2px 6px rgba(15, 23, 41, .06);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity .15s ease, transform .15s ease, visibility .15s;
}

.user-menu.is-open .user-menu__panel {
    opacity: 1;
    visibility: visible;
    transform: none;
}

.user-menu__head {
    padding: 10px 12px 12px;
    border-bottom: 1px solid var(--line-soft);
    margin-bottom: 6px;
}

.user-menu__head-name {
    font-size: 13px;
    font-weight: 600;
}

.user-menu__head-mail {
    font-size: 12px;
    color: var(--ink-muted);
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu__item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 7px;
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
}

.user-menu__item i {
    width: 15px;
    font-size: 13px;
    text-align: center;
    color: var(--ink-muted);
}

.user-menu__item:hover {
    background: #f5f6f8;
    color: var(--ink);
}

.user-menu__item:hover i {
    color: var(--accent);
}

.user-menu__item--danger {
    color: var(--danger);
}

.user-menu__item--danger i {
    color: var(--danger);
}

.user-menu__item--danger:hover {
    background: #fdeaea;
    color: #b32f2f;
}

.user-menu__item--danger:hover i {
    color: #b32f2f;
}

.user-menu__sep {
    height: 1px;
    background: var(--line-soft);
    margin: 6px 0;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 600;
}

.page {
    padding: 26px 28px 40px;
}

/* ------------------------------------------------------------------- card */

.card-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-panel__head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line-soft);
}

.card-panel__title {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.card-panel__note {
    font-size: 12px;
    color: var(--ink-muted);
    margin-left: auto;
}

.card-panel__body {
    padding: 18px 20px;
}

/* -------------------------------------------------------------- stat tile */

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    height: 100%;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.stat__icon {
    width: 40px;
    height: 40px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    font-size: 15px;
    flex: none;
}

.stat__icon--blue {
    background: var(--accent-soft);
    color: var(--accent);
}

.stat__icon--green {
    background: #e6f6e6;
    color: #0a7d0a;
}

.stat__icon--amber {
    background: #fdf3e0;
    color: var(--warn);
}

.stat__icon--violet {
    background: #eeecf9;
    color: var(--violet);
}

.stat__label {
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-muted);
    letter-spacing: .01em;
}

.stat__value {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -.02em;
    line-height: 1.25;
}

/* ----------------------------------------------------------------- charts */

.chart-box {
    position: relative;
    height: 300px;
}

/* ----------------------------------------------------------------- badges */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.pill--not-contacted {
    background: #fdf3e0;
    color: #8a5a00;
}

.pill--contacted {
    background: #e6f6e6;
    color: #0a7d0a;
}

/* ------------------------------------------------------------------ table */

.lead-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    color: var(--ink);
}

.lead-name:hover {
    color: var(--accent);
}

.lead-name__sub {
    font-size: 12px;
    color: var(--ink-muted);
    font-weight: 400;
}

.icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink-2);
    display: inline-grid;
    place-items: center;
    font-size: 12px;
    transition: all .15s ease;
}

.icon-btn:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

.icon-btn--call:hover {
    border-color: var(--ok);
    background: #e6f6e6;
    color: #0a7d0a;
}

.actions {
    display: flex;
    gap: 6px;
}

/* DataTables — flatten it into the panel above */

table.dataTable {
    border-collapse: separate !important;
    border-spacing: 0;
    margin: 0 !important;
    width: 100% !important;
}

table.dataTable thead th {
    white-space: nowrap;
    background: #fafbfc;
    border-bottom: 1px solid var(--line) !important;
    border-top: 1px solid var(--line-soft);
    color: var(--ink-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 11px 20px !important;
    white-space: nowrap;
}

table.dataTable tbody td {
    white-space: nowrap;
    padding: 12px 20px !important;
    border-bottom: 1px solid var(--line-soft) !important;
    vertical-align: middle;
    color: var(--ink-2);
}

table.dataTable tbody tr:last-child td {
    border-bottom: 0 !important;
}

table.dataTable tbody tr:hover td {
    background: #fafbfc;
}

table.dataTable td.dt-type-numeric {
    font-variant-numeric: tabular-nums;
}

/* The table scrolls sideways on narrow screens; the controls above and below
   stay put. */
.dt-container .dt-layout-table {
    overflow-x: auto;
}

/* Flex items refuse to shrink below their content by default, which would let a
   wide table stretch the whole card. These two let the scroll box do its job. */
.dt-container .dt-layout-table,
.dt-container .dt-layout-table>.dt-layout-cell {
    min-width: 0;
}

.dt-container .dt-layout-row {
    padding: 14px 20px;
    align-items: center;
}

.dt-container .dt-layout-row:first-child {
    border-bottom: 1px solid var(--line-soft);
}

.dt-container .dt-layout-row:last-child {
    border-top: 1px solid var(--line-soft);
}

.dt-container .dt-search input,
.dt-container .dt-length select {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 11px;
    font-size: 13px;
    outline: none;
    background: #fff;
    color: var(--ink);
}

.dt-container .dt-search input {
    min-width: 240px;
}

.dt-container .dt-search input:focus,
.dt-container .dt-length select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.dt-container .dt-search label,
.dt-container .dt-length label,
.dt-container .dt-info {
    color: var(--ink-muted);
    font-size: 13px;
}

/* Every pager button is the same 32px square, so the active one reads as a
   highlight rather than as a wider block. */
.dt-container .dt-paging .dt-paging-button {
    min-width: 32px;
    height: 32px;
    padding: 0 9px !important;
    margin: 0 2px !important;
    border: 1px solid transparent !important;
    border-radius: 8px !important;
    background: transparent !important;
    color: var(--ink-2) !important;
    font-size: 13px;
    font-weight: 500;
    line-height: 30px;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.dt-container .dt-paging .dt-paging-button.previous,
.dt-container .dt-paging .dt-paging-button.next {
    font-size: 17px;
}

.dt-container .dt-paging .dt-paging-button:hover {
    background: #f1f3f6 !important;
    border-color: var(--line) !important;
    color: var(--ink) !important;
}

.dt-container .dt-paging .dt-paging-button.current,
.dt-container .dt-paging .dt-paging-button.current:hover {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: #fff !important;
    box-shadow: 0 2px 6px -2px rgba(42, 120, 214, .6);
}

.dt-container .dt-paging .dt-paging-button.disabled,
.dt-container .dt-paging .dt-paging-button.disabled:hover {
    background: transparent !important;
    border-color: transparent !important;
    color: #b9bec9 !important;
    cursor: default;
}

/* ------------------------------------------------------------ lead detail */

.detail-hero {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 22px 24px;
}

.detail-hero__avatar {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: var(--accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 19px;
    font-weight: 600;
    flex: none;
}

.detail-hero__name {
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -.02em;
    margin: 0 0 4px;
}

.detail-hero__meta {
    color: var(--ink-muted);
    font-size: 13px;
}

.detail-hero__actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

.btn-solid,
.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    transition: all .15s ease;
}

.btn-solid {
    background: var(--accent);
    color: #fff;
}

.btn-solid:hover {
    background: #1f66bd;
    color: #fff;
}

.btn-ghost {
    background: #fff;
    border-color: var(--line);
    color: var(--ink-2);
}

.btn-ghost:hover {
    border-color: #cfd4de;
    background: #fafbfc;
    color: var(--ink);
}

.field-list {
    display: grid;
    gap: 2px;
}

.field {
    display: flex;
    gap: 16px;
    padding: 11px 0;
    border-bottom: 1px solid var(--line-soft);
}

.field:last-child {
    border-bottom: 0;
}

.field__key {
    width: 150px;
    flex: none;
    color: var(--ink-muted);
    font-size: 13px;
}

.field__val {
    color: var(--ink);
    font-size: 13px;
}

.field__val a:hover {
    color: var(--accent);
}

.note-body {
    color: var(--ink-2);
    line-height: 1.65;
    font-size: 13px;
    margin: 0;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--ink-muted);
    font-size: 13px;
    margin-bottom: 14px;
}

.back-link:hover {
    color: var(--accent);
}

/* ------------------------------------------------------------ login page */

.auth {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 24px;
    background: #eef1f6;
    overflow: hidden;
}

/* A soft accent glow behind the card, so the page isn't a flat grey field. */
.auth::before {
    content: "";
    position: absolute;
    top: -220px;
    left: 50%;
    width: 760px;
    height: 620px;
    transform: translateX(-50%);
    background: radial-gradient(closest-side, rgba(42, 120, 214, .20), rgba(42, 120, 214, 0));
    pointer-events: none;
}

.auth::after {
    content: "";
    position: absolute;
    inset: auto 0 -260px 0;
    height: 520px;
    background: radial-gradient(closest-side, rgba(15, 23, 41, .07), rgba(15, 23, 41, 0));
    pointer-events: none;
}

.auth__card {
    position: relative;
    width: 100%;
    max-width: 404px;
    padding: 36px 34px 32px;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: 16px;
    box-shadow:
        0 1px 2px rgba(15, 23, 41, .04),
        0 12px 32px -8px rgba(15, 23, 41, .14),
        0 32px 64px -24px rgba(15, 23, 41, .16);
}

.auth__brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -.02em;
    margin-bottom: 24px;
}

.auth__mark {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, #4a92e8, var(--accent));
    color: #fff;
    font-size: 16px;
    box-shadow: 0 4px 12px -2px rgba(42, 120, 214, .5);
}

.auth__title {
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -.02em;
    text-align: center;
    margin: 0 0 6px;
}

.auth__subtitle {
    color: var(--ink-muted);
    font-size: 13px;
    text-align: center;
    margin: 0 0 26px;
}

.auth__note {
    position: relative;
    margin: 0;
    text-align: center;
    color: var(--ink-muted);
    font-size: 12.5px;
}

.form-field {
    margin-bottom: 16px;
}

.form-field__label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
}

.form-field__wrap {
    position: relative;
}

.form-field__icon {
    position: absolute;
    top: 50%;
    left: 13px;
    transform: translateY(-50%);
    font-size: 13px;
    color: var(--ink-muted);
    pointer-events: none;
}

.form-field__input {
    width: 100%;
    padding: 12px 13px 12px 40px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fafbfc;
    color: var(--ink);
    font-size: 14px;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.form-field__input.has-toggle {
    padding-right: 40px;
}

.form-field__input::placeholder {
    color: #b3b8c4;
}

.form-field__input:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-field__wrap:focus-within .form-field__icon {
    color: var(--accent);
}

.form-field__toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--ink-muted);
    font-size: 13px;
}

.form-field__toggle:hover {
    background: #f1f3f6;
    color: var(--ink-2);
}

.auth__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 4px 0 22px;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink-2);
    font-size: 13px;
    cursor: pointer;
}

.check input {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
}

.auth__link {
    color: var(--accent);
    font-size: 13px;
    font-weight: 500;
}

.auth__link:hover {
    color: #1f66bd;
    text-decoration: underline;
}

.auth__submit {
    width: 100%;
    justify-content: center;
    padding: 12px 15px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 600;
    background: linear-gradient(160deg, #3d88e0, var(--accent));
    box-shadow: 0 4px 12px -3px rgba(42, 120, 214, .55);
}

.auth__submit:hover {
    background: linear-gradient(160deg, #3480dc, #1f66bd);
    box-shadow: 0 6px 16px -3px rgba(42, 120, 214, .6);
}

.auth__submit:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px -3px rgba(42, 120, 214, .55);
}

/* ----------------------------------------------------------------- mobile */

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.is-open {
        transform: none;
    }

    .sidebar.is-open~.sidebar__scrim {
        display: block;
    }

    .shell {
        margin-left: 0;
    }

    .topbar__toggle {
        display: grid;
        place-items: center;
    }

    .topbar,
    .page {
        padding-left: 16px;
        padding-right: 16px;
    }

    .topbar__sub {
        display: none;
    }

    .user-menu__name,
    .user-menu__caret {
        display: none;
    }

    .user-menu__btn {
        padding: 4px;
    }

    table.dataTable {
        min-width: 760px;
    }

    .dt-container .dt-layout-row {
        padding: 12px 16px;
    }

    /* Stack the search / length / paging controls instead of centring them. */
    .dt-container .dt-layout-cell {
        width: 100%;
        justify-content: flex-start;
    }

    .dt-container .dt-search input {
        width: 100%;
        min-width: 0;
    }

    table.dataTable thead th,
    table.dataTable tbody td {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .detail-hero {
        flex-wrap: wrap;
    }

    .detail-hero__actions {
        margin-left: 0;
        width: 100%;
    }

    .field {
        flex-direction: column;
        gap: 3px;
    }

    .field__key {
        width: auto;
    }
}
