/* =========================================================
   FLOWCRM - BUSINESS CRM DASHBOARD
========================================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f7f5;
    color: #1f2937;
    line-height: 1.5;
}

a {
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

:root {
    --bg: #f4f7f5;
    --surface: #ffffff;
    --surface-soft: #f8faf9;
    --sidebar: #10241c;
    --sidebar-soft: #173126;
    --primary: #1f7a55;
    --primary-dark: #155d40;
    --primary-soft: #e7f4ed;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #dde6e1;
    --success: #2d8a5e;
    --warning: #c58a20;
    --danger: #c84b4b;
    --blue: #3f6ecf;
    --purple: #7a5dc7;
}


/* =========================================================
   LAYOUT
========================================================= */

.crm-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px 1fr;
}

.crm-sidebar {
    min-height: 100vh;
    background: var(--sidebar);
    padding: 26px 18px;

    display: flex;
    flex-direction: column;

    position: sticky;
    top: 0;
    align-self: start;
}


/* =========================================================
   BRAND
========================================================= */

.crm-brand {
    display: flex;
    align-items: center;
    gap: 12px;

    padding: 0 8px 24px;

    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.crm-brand-icon {
    width: 42px;
    height: 42px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 10px;

    background: var(--primary);
    color: #ffffff;

    font-size: 18px;
}

.crm-brand>div:last-child {
    display: flex;
    flex-direction: column;
}

.crm-brand-name {
    color: #ffffff;
    font-size: 18px;
    font-weight: 700;
}

.crm-brand-subtitle {
    color: #9fb7ab;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.7px;
}


/* =========================================================
   SIDEBAR NAVIGATION
========================================================= */

.crm-nav {
    display: flex;
    flex-direction: column;

    gap: 5px;

    margin-top: 24px;
}

.nav-section-label {
    color: #718f80;

    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;

    margin: 18px 10px 7px;
}

.crm-nav a {
    display: flex;
    align-items: center;

    gap: 12px;

    padding: 11px 12px;

    border-radius: 8px;

    color: #c3d2cb;

    font-size: 13px;
    font-weight: 600;

    transition: 0.2s ease;
}

.crm-nav a i {
    width: 18px;
}

.crm-nav a:hover,
.crm-nav a.active {
    background: var(--sidebar-soft);
    color: #ffffff;
}

.crm-nav a.active {
    border-left: 3px solid #49b884;
}


/* =========================================================
   SIDEBAR USER
========================================================= */

.sidebar-bottom {
    margin-top: auto;
    padding-top: 24px;
}

.user-card {
    display: flex;
    align-items: center;

    gap: 10px;

    padding: 12px;

    border-radius: 10px;

    background: rgba(255, 255, 255, 0.06);
}

.user-avatar {
    width: 36px;
    height: 36px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    border-radius: 50%;

    background: var(--primary);
    color: #ffffff;

    font-size: 11px;
    font-weight: 800;
}

.user-card strong {
    display: block;

    color: #ffffff;

    font-size: 12px;
}

.user-card span {
    color: #91aa9e;

    font-size: 10px;
}


/* =========================================================
   MAIN
========================================================= */

.crm-main {
    min-width: 0;
    padding: 38px;
}


/* =========================================================
   TOPBAR
========================================================= */

.crm-topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    gap: 30px;

    margin-bottom: 30px;
}

.page-label {
    color: var(--primary);

    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.5px;

    margin-bottom: 7px;
}

.crm-topbar h1 {
    font-size: 34px;
    line-height: 1.1;

    margin-bottom: 7px;
}

.crm-topbar>div:first-child>p:last-child {
    color: var(--muted);

    font-size: 13px;
}

.topbar-actions {
    display: flex;
    align-items: center;

    gap: 10px;
}

.search-box {
    position: relative;
}

.search-box i {
    position: absolute;

    left: 13px;
    top: 50%;

    transform: translateY(-50%);

    color: #8c9a93;
}

.search-box input {
    width: 220px;

    padding: 10px 12px 10px 36px;

    border: 1px solid var(--border);
    border-radius: 8px;

    background: #ffffff;

    outline: none;

    font-size: 13px;
}

.search-box input:focus {
    border-color: var(--primary);

    box-shadow: 0 0 0 3px rgba(31, 122, 85, 0.08);
}

.icon-button {
    width: 40px;
    height: 40px;

    position: relative;

    border: 1px solid var(--border);
    border-radius: 8px;

    background: #ffffff;
    color: #53615a;

    cursor: pointer;
}

.notification-dot {
    position: absolute;

    width: 7px;
    height: 7px;

    top: 8px;
    right: 8px;

    border-radius: 50%;

    background: #e05b5b;

    border: 2px solid #ffffff;
}

.primary-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    gap: 8px;

    padding: 10px 15px;

    border: none;
    border-radius: 8px;

    background: var(--primary);
    color: #ffffff;

    font-size: 13px;
    font-weight: 700;

    cursor: pointer;

    transition: 0.2s ease;
}

.primary-action-btn:hover {
    background: var(--primary-dark);
}


/* =========================================================
   STATS
========================================================= */

.crm-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));

    gap: 16px;

    margin-bottom: 24px;
}

.crm-stat-card {
    padding: 20px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 12px;
}

.stat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 10px;

    margin-bottom: 12px;
}

.stat-top>span {
    color: var(--muted);

    font-size: 12px;
    font-weight: 600;
}

.stat-icon {
    width: 34px;
    height: 34px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 8px;

    font-size: 13px;
}

.customers-icon {
    background: #e9f4ff;
    color: var(--blue);
}

.leads-icon {
    background: var(--primary-soft);
    color: var(--primary);
}

.pipeline-icon {
    background: #fff5df;
    color: var(--warning);
}

.conversion-icon {
    background: #f1ecff;
    color: var(--purple);
}

.crm-stat-card>strong {
    display: block;

    color: var(--text);

    font-size: 28px;
    line-height: 1;

    margin-bottom: 8px;
}

.crm-stat-card small {
    color: var(--muted);

    font-size: 10px;
}

.crm-stat-card small i {
    color: var(--success);
}


/* =========================================================
   DASHBOARD GRIDS
========================================================= */

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.5fr 0.8fr;

    gap: 20px;

    margin-bottom: 20px;
}

.secondary-grid {
    grid-template-columns: 1.45fr 0.75fr;
}

.dashboard-card {
    min-width: 0;

    padding: 22px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 12px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    gap: 15px;

    margin-bottom: 22px;
}

.card-label {
    color: var(--primary);

    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1.2px;

    margin-bottom: 5px;
}

.card-header h2 {
    font-size: 19px;
}

.card-header a {
    color: var(--primary);

    font-size: 11px;
    font-weight: 700;
}

.card-header select {
    padding: 8px 10px;

    border: 1px solid var(--border);
    border-radius: 7px;

    background: #ffffff;

    color: var(--muted);

    font-size: 11px;
}


/* =========================================================
   SALES CHART
========================================================= */

.sales-chart {
    height: 220px;

    display: flex;
    align-items: flex-end;
    justify-content: space-between;

    gap: 12px;

    padding: 18px 10px 0;

    border-bottom: 1px solid var(--border);

    background:
        linear-gradient(to top,
            rgba(221, 230, 225, 0.5) 1px,
            transparent 1px);

    background-size: 100% 25%;
}

.chart-column {
    flex: 1;
    height: 100%;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;

    gap: 8px;
}

.chart-bar {
    width: 70%;
    max-width: 42px;

    min-height: 20px;

    border-radius: 7px 7px 2px 2px;

    background: linear-gradient(to top,
            var(--primary-dark),
            #58b889);

    transition: 0.25s ease;
}

.chart-bar:hover {
    opacity: 0.86;
}

.chart-column span {
    color: var(--muted);
    font-size: 10px;
}

.sales-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);

    gap: 18px;

    margin-top: 20px;
}

.sales-summary div {
    padding-right: 12px;
}

.sales-summary span {
    display: block;

    color: var(--muted);

    font-size: 10px;

    margin-bottom: 3px;
}

.sales-summary strong {
    font-size: 17px;
}


/* =========================================================
   PIPELINE SUMMARY
========================================================= */

.pipeline-summary-list {
    display: flex;
    flex-direction: column;

    gap: 12px;
}

.pipeline-summary-item {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 15px;

    padding: 13px 0;

    border-bottom: 1px solid #edf1ef;
}

.pipeline-summary-item:last-child {
    border-bottom: none;
}

.pipeline-summary-item>div {
    display: flex;
    align-items: center;

    gap: 10px;
}

.pipeline-color {
    width: 9px;
    height: 34px;

    border-radius: 999px;
}

.pipeline-color.new-lead {
    background: #4f89dd;
}

.pipeline-color.contacted {
    background: #48a979;
}

.pipeline-color.proposal {
    background: #d4a137;
}

.pipeline-color.negotiation {
    background: #8a68c7;
}

.pipeline-summary-item strong {
    font-size: 12px;
}

.pipeline-summary-item small {
    display: block;

    color: var(--muted);

    font-size: 9px;
}


/* =========================================================
   TABLES
========================================================= */

.crm-table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.crm-table {
    width: 100%;

    border-collapse: collapse;

    min-width: 670px;
}

.crm-table th {
    text-align: left;

    color: #8b9690;

    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.6px;

    padding: 9px 10px;

    border-bottom: 1px solid var(--border);
}

.crm-table td {
    padding: 13px 10px;

    border-bottom: 1px solid #edf1ef;

    color: #48534e;

    font-size: 11px;

    vertical-align: middle;
}

.person-cell {
    display: flex;
    align-items: center;

    gap: 10px;
}

.table-avatar {
    width: 34px;
    height: 34px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    border-radius: 50%;

    background: #e8f1ec;

    color: var(--primary);

    font-size: 10px;
    font-weight: 800;
}

.person-cell strong {
    display: block;

    color: var(--text);

    font-size: 11px;
}

.person-cell small {
    display: block;

    color: #8c9691;

    font-size: 9px;

    margin-top: 2px;
}


/* =========================================================
   STATUS
========================================================= */

.crm-status {
    display: inline-flex;

    padding: 4px 7px;

    border-radius: 999px;

    font-size: 9px;
    font-weight: 700;
}

.crm-status.new {
    background: #e8f1ff;
    color: #4270bb;
}

.crm-status.contacted {
    background: #e8f5ee;
    color: #2f8258;
}

.crm-status.proposal {
    background: #fff3da;
    color: #9d6c18;
}


/* =========================================================
   ACTIVITY
========================================================= */

.activity-list {
    display: flex;
    flex-direction: column;

    gap: 15px;
}

.activity-item {
    display: flex;

    gap: 11px;
}

.activity-icon {
    width: 34px;
    height: 34px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    border-radius: 9px;

    background: var(--primary-soft);
    color: var(--primary);

    font-size: 11px;
}

.activity-item p {
    color: #47534d;

    font-size: 11px;
    line-height: 1.5;
}

.activity-item span {
    color: #8d9792;

    font-size: 9px;
}


/* =========================================================
   QUICK ACTIONS
========================================================= */

.quick-actions-section {
    margin-top: 25px;
}

.section-heading {
    margin-bottom: 14px;
}

.section-heading h2 {
    font-size: 20px;
}

.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));

    gap: 14px;
}

.quick-action-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;

    gap: 12px;

    padding: 17px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 11px;

    color: var(--text);

    transition: 0.2s ease;
}

.quick-action-card:hover {
    border-color: #b6cec1;

    transform: translateY(-2px);

    box-shadow: 0 7px 18px rgba(30, 65, 49, 0.05);
}

.quick-action-card>i:first-child {
    width: 38px;
    height: 38px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 9px;

    background: var(--primary-soft);
    color: var(--primary);
}

.quick-action-card strong {
    display: block;

    font-size: 12px;
}

.quick-action-card span {
    color: var(--muted);

    font-size: 9px;
}

.quick-action-card>i:last-child {
    color: #9aa69f;

    font-size: 11px;
}


/* =========================================================
   MODAL
========================================================= */

.crm-modal {
    display: none;

    position: fixed;
    inset: 0;

    z-index: 2000;

    align-items: center;
    justify-content: center;

    padding: 20px;
}

.crm-modal.open {
    display: flex;
}

.crm-modal-overlay {
    position: absolute;
    inset: 0;

    background: rgba(12, 25, 20, 0.55);

    backdrop-filter: blur(2px);
}

.crm-modal-card {
    position: relative;
    z-index: 2;

    width: 100%;
    max-width: 580px;

    padding: 26px;

    border-radius: 14px;

    background: #ffffff;

    box-shadow: 0 30px 80px rgba(16, 36, 28, 0.18);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    gap: 15px;

    margin-bottom: 23px;
}

.modal-header h2 {
    font-size: 22px;
}

.modal-close-btn {
    width: 34px;
    height: 34px;

    border: none;
    border-radius: 8px;

    background: #f2f5f3;
    color: #65726b;

    cursor: pointer;
}

.modal-close-btn:hover {
    background: #e8eeea;
}


/* =========================================================
   FORMS
========================================================= */

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));

    gap: 15px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;

    margin-bottom: 6px;

    color: #445049;

    font-size: 11px;
    font-weight: 700;
}

.form-group input,
.form-group select {
    width: 100%;

    padding: 10px 11px;

    border: 1px solid var(--border);
    border-radius: 8px;

    background: #ffffff;

    color: var(--text);

    outline: none;

    font-size: 12px;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);

    box-shadow: 0 0 0 3px rgba(31, 122, 85, 0.08);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;

    gap: 9px;

    margin-top: 8px;
}

.secondary-modal-btn {
    padding: 10px 14px;

    border: 1px solid var(--border);
    border-radius: 8px;

    background: #ffffff;
    color: #56645d;

    cursor: pointer;
}


/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 1150px) {

    .crm-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-grid,
    .secondary-grid {
        grid-template-columns: 1fr;
    }

}


@media (max-width: 900px) {

    .crm-layout {
        grid-template-columns: 1fr;
    }

    .crm-sidebar {
        min-height: auto;

        position: static;
    }

    .crm-nav {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .nav-section-label {
        display: none;
    }

    .sidebar-bottom {
        margin-top: 20px;
    }

    .crm-main {
        padding: 28px 20px;
    }

}


@media (max-width: 760px) {

    .crm-topbar {
        flex-direction: column;
    }

    .topbar-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .search-box {
        flex: 1 1 100%;
    }

    .search-box input {
        width: 100%;
    }

    .crm-stats {
        grid-template-columns: 1fr;
    }

    .quick-actions-grid {
        grid-template-columns: 1fr;
    }

    .sales-summary {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

}


@media (max-width: 560px) {

    .crm-main {
        padding: 22px 14px;
    }

    .crm-nav {
        grid-template-columns: 1fr 1fr;
    }

    .crm-topbar h1 {
        font-size: 28px;
    }

    .primary-action-btn {
        width: 100%;
    }

    .icon-button {
        display: none;
    }

    .dashboard-card {
        padding: 18px;
    }

    .sales-chart {
        gap: 6px;
    }

}

/* =========================================================
   EXTRA CRM STATES
========================================================= */

.crm-status.negotiation {
    background: #f0ebff;
    color: #7457b7;
}

.crm-status.won {
    background: #e6f6ec;
    color: #26764d;
}

.crm-status.lost {
    background: #ffeded;
    color: #b84242;
}

.table-empty-state {
    padding: 35px 10px;

    text-align: center;

    color: #89958f;

    font-size: 12px;
}

/* =========================================================
   LEADS PAGE
========================================================= */

.leads-management-card {
    margin-top: 5px;
}

.leads-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;

    gap: 20px;

    margin-bottom: 22px;
}

.leads-toolbar h2 {
    font-size: 20px;
}

.lead-filter-controls select {
    padding: 9px 12px;

    border: 1px solid var(--border);
    border-radius: 8px;

    background: #ffffff;
    color: #56645d;

    outline: none;

    font-size: 11px;
}

.inline-status-select {
    min-width: 105px;

    padding: 6px 8px;

    border: 1px solid var(--border);
    border-radius: 7px;

    background: #ffffff;
    color: #4b5851;

    font-size: 10px;

    cursor: pointer;
}

.lead-action-buttons {
    display: flex;

    gap: 6px;
}

.lead-action-buttons button {
    width: 29px;
    height: 29px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: none;
    border-radius: 7px;

    cursor: pointer;
}

.lead-edit-btn {
    background: var(--primary-soft);
    color: var(--primary);
}

.lead-delete-btn {
    background: #ffeded;
    color: #b84242;
}

.lead-empty-state {
    min-height: 260px;

    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    text-align: center;
}

.lead-empty-state i {
    margin-bottom: 13px;

    color: #a5b1ab;

    font-size: 32px;
}

.lead-empty-state h3 {
    margin-bottom: 5px;

    font-size: 16px;
}

.lead-empty-state p {
    color: var(--muted);

    font-size: 11px;
}

@media (max-width: 700px) {

    .leads-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .lead-filter-controls,
    .lead-filter-controls select {
        width: 100%;
    }

}

/* =========================================================
   CUSTOMERS PAGE
========================================================= */

.customer-management-card {
    margin-top: 5px;
}

.customer-status {
    display: inline-flex;

    padding: 5px 8px;

    border-radius: 999px;

    font-size: 9px;
    font-weight: 700;
}

.customer-status.active {
    background: #e6f6ec;
    color: #26764d;
}

.customer-status.inactive {
    background: #f1f3f2;
    color: #69756f;
}

/* =========================================================
   SALES PIPELINE PAGE
========================================================= */

.pipeline-section {
    width: 100%;

    overflow-x: auto;

    padding-bottom: 15px;
}

.pipeline-board {
    min-width: 1250px;

    display: grid;
    grid-template-columns: repeat(5, minmax(220px, 1fr));

    gap: 14px;
}

.pipeline-column {
    min-height: 600px;

    padding: 14px;

    background: #eef3f0;

    border: 1px solid var(--border);
    border-radius: 12px;

    transition: 0.2s ease;
}

.pipeline-column.drag-over {
    background: #e0efe7;

    border-color: var(--primary);
}

.pipeline-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 10px;

    margin-bottom: 5px;
}

.pipeline-column-header>div {
    display: flex;
    align-items: center;

    gap: 7px;
}

.pipeline-column-header strong {
    font-size: 12px;
}

.pipeline-column-header>span {
    min-width: 24px;
    height: 24px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 999px;

    background: #ffffff;

    color: #67736d;

    font-size: 9px;
    font-weight: 700;
}

.pipeline-stage-dot {
    width: 8px;
    height: 8px;

    border-radius: 50%;
}

.stage-new {
    background: #4f89dd;
}

.stage-contacted {
    background: #48a979;
}

.stage-proposal {
    background: #d4a137;
}

.stage-negotiation {
    background: #8a68c7;
}

.stage-won {
    background: #2d8a5e;
}

.pipeline-column-value {
    margin-bottom: 14px;

    color: #7b8781;

    font-size: 10px;
}

.pipeline-cards {
    display: flex;
    flex-direction: column;

    gap: 10px;
}

.pipeline-card {
    padding: 14px;

    background: #ffffff;

    border: 1px solid #dce5e0;
    border-radius: 10px;

    cursor: grab;

    transition: 0.2s ease;
}

.pipeline-card:hover {
    border-color: #b9cdc2;

    transform: translateY(-1px);

    box-shadow: 0 6px 14px rgba(20, 60, 42, 0.05);
}

.pipeline-card.dragging {
    opacity: 0.45;
}

.pipeline-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 10px;

    margin-bottom: 11px;
}

.pipeline-menu-btn {
    width: 26px;
    height: 26px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: none;
    border-radius: 6px;

    background: #f2f5f3;

    color: #7b8781;

    cursor: pointer;
}

.pipeline-card-content strong {
    display: block;

    font-size: 12px;

    margin-bottom: 2px;
}

.pipeline-card-content span {
    color: var(--muted);

    font-size: 10px;
}

.pipeline-card-value {
    margin: 15px 0;

    color: var(--primary);

    font-size: 17px;
    font-weight: 800;
}

.pipeline-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 8px;

    padding-top: 10px;

    border-top: 1px solid #edf1ef;
}

.pipeline-card-footer>span {
    display: flex;
    align-items: center;

    gap: 5px;

    color: #839089;

    font-size: 8px;
}

.pipeline-status-select {
    max-width: 105px;

    padding: 5px 6px;

    border: 1px solid var(--border);
    border-radius: 6px;

    background: #ffffff;

    color: #53615a;

    font-size: 8px;

    cursor: pointer;
}

.pipeline-empty {
    padding: 24px 10px;

    border: 1px dashed #cad7d0;
    border-radius: 8px;

    color: #91a099;

    text-align: center;

    font-size: 9px;
}

@media (max-width: 900px) {

    .pipeline-board {
        min-width: 1100px;
    }

}