/*
 * Floating Infotech CRM theme (section 31).
 *
 * Built on Bootstrap 5 variables rather than alongside them, so components picked up from
 * Bootstrap inherit the palette instead of fighting it.
 */

:root {
    /* Navy sidebar, white content. */
    --crm-sidebar-bg: #0f1e3d;
    --crm-sidebar-bg-hover: #1b2f57;
    --crm-sidebar-bg-active: #2563eb;
    --crm-sidebar-text: #aebad3;
    --crm-sidebar-text-active: #ffffff;
    --crm-sidebar-heading: #64748b;
    --crm-sidebar-width: 256px;
    --crm-sidebar-width-collapsed: 72px;

    --crm-topbar-height: 62px;
    --crm-content-bg: #f4f6fb;

    /* Status language: green good, red overdue, orange warning. */
    --crm-success: #16a34a;
    --crm-danger: #dc2626;
    --crm-warning: #ea580c;
    --crm-info: #0891b2;
    --crm-primary: #2563eb;

    --crm-border: #e2e8f0;
    --crm-muted: #64748b;

    --crm-card-shadow: 0 1px 2px rgba(15, 30, 61, .06), 0 2px 8px rgba(15, 30, 61, .04);
    --crm-card-shadow-hover: 0 4px 12px rgba(15, 30, 61, .10);
    --crm-radius: .625rem;
}

body {
    background-color: var(--crm-content-bg);
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: .9rem;
    color: #1e293b;
}

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

.crm-shell {
    display: flex;
    min-height: 100vh;
}

.crm-sidebar {
    width: var(--crm-sidebar-width);
    flex: 0 0 var(--crm-sidebar-width);
    background: var(--crm-sidebar-bg);
    color: var(--crm-sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    transition: transform .2s ease, width .2s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Thin scrollbar so the nav does not gain a chunky grey bar on Windows. */
.crm-sidebar::-webkit-scrollbar { width: 6px; }
.crm-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }

.crm-sidebar__brand {
    display: flex;
    align-items: center;
    gap: .625rem;
    height: var(--crm-topbar-height);
    padding: 0 1.125rem;
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: .01em;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    white-space: nowrap;
}

.crm-sidebar__brand i { font-size: 1.35rem; color: #60a5fa; }

.crm-sidebar__nav { padding: .75rem 0 2rem; }

.crm-sidebar__heading {
    padding: 1rem 1.125rem .375rem;
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--crm-sidebar-heading);
}

.crm-nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .5rem 1.125rem;
    color: var(--crm-sidebar-text);
    text-decoration: none;
    font-size: .875rem;
    border-left: 3px solid transparent;
    white-space: nowrap;
    transition: background-color .12s ease, color .12s ease;
}

.crm-nav-link i { font-size: 1.05rem; width: 1.25rem; text-align: center; flex: 0 0 auto; }

.crm-nav-link:hover { background: var(--crm-sidebar-bg-hover); color: #fff; }

.crm-nav-link.active {
    background: var(--crm-sidebar-bg-hover);
    color: var(--crm-sidebar-text-active);
    border-left-color: var(--crm-sidebar-bg-active);
    font-weight: 500;
}

.crm-nav-link .badge { margin-left: auto; font-size: .65rem; }

/* ----------------------------------------------------------------- main */

.crm-main {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: var(--crm-sidebar-width);
    display: flex;
    flex-direction: column;
    transition: margin-left .2s ease;
}

.crm-topbar {
    height: var(--crm-topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--crm-border);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.crm-topbar__search {
    flex: 1 1 auto;
    max-width: 460px;
    position: relative;
}

.crm-topbar__search input {
    padding-left: 2.25rem;
    background: var(--crm-content-bg);
    border-color: transparent;
}

.crm-topbar__search input:focus {
    background: #fff;
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .12);
}

.crm-topbar__search i {
    position: absolute;
    left: .75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--crm-muted);
    pointer-events: none;
}

.crm-content { padding: 1.25rem; flex: 1 1 auto; }

.crm-page-title { font-size: 1.25rem; font-weight: 600; margin: 0; }

.crm-page-subtitle { font-size: .82rem; color: var(--crm-muted); margin: .125rem 0 0; }

/* ----------------------------------------------------------------- cards */

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

.crm-card__header {
    padding: .875rem 1.125rem;
    border-bottom: 1px solid var(--crm-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.crm-card__title { font-size: .92rem; font-weight: 600; margin: 0; }

.crm-card__body { padding: 1.125rem; }

/* KPI tile. The accent bar down the left is what distinguishes one metric family
   from another at a glance on a dashboard of a dozen tiles. */
.crm-kpi {
    background: #fff;
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    box-shadow: var(--crm-card-shadow);
    padding: .875rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: .875rem;
    height: 100%;
    border-left: 3px solid var(--crm-primary);
    transition: box-shadow .15s ease, transform .15s ease;
}

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

.crm-kpi__icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: .5rem;
    display: grid;
    place-items: center;
    font-size: 1.05rem;
    flex: 0 0 auto;
    background: rgba(37, 99, 235, .1);
    color: var(--crm-primary);
}

.crm-kpi__label {
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--crm-muted);
    margin: 0;
}

.crm-kpi__value { font-size: 1.35rem; font-weight: 600; line-height: 1.2; margin: .125rem 0 0; }

.crm-kpi__meta { font-size: .72rem; color: var(--crm-muted); margin: .125rem 0 0; }

.crm-kpi--success { border-left-color: var(--crm-success); }
.crm-kpi--success .crm-kpi__icon { background: rgba(22, 163, 74, .1); color: var(--crm-success); }

.crm-kpi--danger { border-left-color: var(--crm-danger); }
.crm-kpi--danger .crm-kpi__icon { background: rgba(220, 38, 38, .1); color: var(--crm-danger); }

.crm-kpi--warning { border-left-color: var(--crm-warning); }
.crm-kpi--warning .crm-kpi__icon { background: rgba(234, 88, 12, .1); color: var(--crm-warning); }

.crm-kpi--info { border-left-color: var(--crm-info); }
.crm-kpi--info .crm-kpi__icon { background: rgba(8, 145, 178, .1); color: var(--crm-info); }

/* ------------------------------------------------------------- urgency */

/* Section 9: overdue in red, today in orange, everything else neutral.
   Applied as a left edge on the row rather than a full background wash, so a grid of
   mostly-overdue rows stays readable. */
.crm-row--overdue { border-left: 3px solid var(--crm-danger); background-color: rgba(220, 38, 38, .04); }
.crm-row--today { border-left: 3px solid var(--crm-warning); background-color: rgba(234, 88, 12, .04); }
.crm-row--tomorrow { border-left: 3px solid var(--crm-info); }

.crm-date--overdue { color: var(--crm-danger); font-weight: 600; }
.crm-date--today { color: var(--crm-warning); font-weight: 600; }

/* --------------------------------------------------------------- tables */

.crm-table { font-size: .84rem; margin-bottom: 0; }

.crm-table > thead > tr > th {
    background: #f8fafc;
    border-bottom: 1px solid var(--crm-border);
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--crm-muted);
    white-space: nowrap;
    padding: .625rem .75rem;
}

.crm-table > tbody > tr > td { padding: .625rem .75rem; vertical-align: middle; }

.crm-table > tbody > tr:hover { background-color: #f8fafc; }

.crm-table .text-end, .crm-table th.text-end { text-align: right; }

/* Money reads much faster when the digits line up. */
.crm-num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

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

.crm-badge {
    display: inline-block;
    padding: .2rem .5rem;
    border-radius: 1rem;
    font-size: .7rem;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
}

.crm-badge--new { background: rgba(37, 99, 235, .12); color: #1d4ed8; }
.crm-badge--progress { background: rgba(234, 88, 12, .12); color: #c2410c; }
.crm-badge--won { background: rgba(22, 163, 74, .12); color: #15803d; }
.crm-badge--lost { background: rgba(220, 38, 38, .12); color: #b91c1c; }
.crm-badge--hold { background: rgba(100, 116, 139, .14); color: #475569; }

/* -------------------------------------------------------------- progress */

.crm-progress { height: .45rem; border-radius: 1rem; background: #eef2f7; }

.crm-progress .progress-bar { border-radius: 1rem; }

.crm-target-row { display: flex; justify-content: space-between; font-size: .78rem; margin-bottom: .25rem; }

/* -------------------------------------------------------------- timeline */

.crm-timeline { position: relative; padding-left: 1.75rem; }

.crm-timeline::before {
    content: "";
    position: absolute;
    left: .5rem;
    top: .35rem;
    bottom: .35rem;
    width: 2px;
    background: var(--crm-border);
}

.crm-timeline__item { position: relative; padding-bottom: 1.1rem; }

.crm-timeline__dot {
    position: absolute;
    left: -1.75rem;
    top: .1rem;
    width: 1.125rem;
    height: 1.125rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: .6rem;
    color: #fff;
    background: var(--crm-muted);
}

.crm-timeline__time { font-size: .72rem; color: var(--crm-muted); }

.crm-timeline__title { font-size: .85rem; font-weight: 600; margin: 0; }

.crm-timeline__body { font-size: .8rem; color: #475569; margin: .125rem 0 0; }

/* ------------------------------------------------------------- checklist */

.crm-checklist__item {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .4rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.crm-checklist__item:last-child { border-bottom: 0; }

.crm-checklist__item label { margin: 0; font-size: .84rem; cursor: pointer; flex: 1; }

.crm-checklist__item input:checked + label { color: var(--crm-muted); text-decoration: line-through; }

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

.crm-login {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #0f1e3d 0%, #1e3a8a 100%);
    padding: 1.5rem;
}

.crm-login__card {
    width: 100%;
    max-width: 410px;
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 20px 45px rgba(0, 0, 0, .25);
    padding: 2.25rem;
}

/* ------------------------------------------------------------ utilities */

.crm-empty { text-align: center; padding: 2.5rem 1rem; color: var(--crm-muted); }

.crm-empty i { font-size: 2.25rem; opacity: .35; display: block; margin-bottom: .625rem; }

.crm-chart { position: relative; width: 100%; }

.crm-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    object-fit: cover;
    background: var(--crm-primary);
    color: #fff;
    display: inline-grid;
    place-items: center;
    font-size: .75rem;
    font-weight: 600;
}

.crm-notification-item { padding: .625rem .875rem; border-bottom: 1px solid #f1f5f9; }
.crm-notification-item.unread { background: rgba(37, 99, 235, .04); }

/* ------------------------------------------------------------ responsive */

/* The sidebar slides away below the large breakpoint and is opened by the hamburger,
   which is what makes the CRM usable on a tablet and a phone (section 1). */
@media (max-width: 991.98px) {
    .crm-sidebar { transform: translateX(-100%); }
    .crm-sidebar.is-open { transform: translateX(0); box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
    .crm-main { margin-left: 0; }

    .crm-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 30, 61, .45);
        z-index: 1035;
    }
}

@media (max-width: 575.98px) {
    .crm-content { padding: .875rem; }
    .crm-kpi__value { font-size: 1.15rem; }
    .crm-topbar { padding: 0 .75rem; gap: .5rem; }
}

@media print {
    .crm-sidebar, .crm-topbar, .crm-no-print { display: none !important; }
    .crm-main { margin-left: 0; }
    .crm-card { box-shadow: none; border-color: #ccc; }
}

/* ------------------------------------------------------------- org chart */

/* Nesting is drawn with an indent and a guide line rather than absolute positioning, so the
   chart survives any depth and still reads on a phone. */
.org-children {
    margin-left: 1.1rem;
    padding-left: .9rem;
    border-left: 2px solid var(--crm-border);
}

.org-node > .d-flex { border-bottom: 1px dashed transparent; }

.org-node > .d-flex:hover { border-bottom-color: var(--crm-border); }
