@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
    --crm-bg: #f4f7fb;
    --crm-surface: #ffffff;
    --crm-surface-muted: #f8fafc;
    --crm-border: #dbe3ef;
    --crm-border-strong: #c7d3e5;
    --crm-text: #102033;
    --crm-text-soft: #5f7188;
    --crm-accent: #2057d8;
    --crm-accent-soft: #eef4ff;
    --crm-success: #1b7f51;
    --crm-warning: #b56b00;
    --crm-danger: #b83a3a;
    --crm-shadow: 0 10px 30px rgba(16, 32, 51, 0.06);
    --crm-radius: 14px;
    --crm-sidebar-width: 248px;
}

body {
    background: linear-gradient(180deg, #f7f9fc 0%, #edf3fb 100%);
    color: var(--crm-text);
    font-family: 'Manrope', sans-serif;
    font-size: 0.875rem;
    line-height: 1.45;
}

a {
    text-decoration: none;
}

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

.crm-sidebar {
    background: #0f1f35;
    color: #d6e2f5;
    min-height: 100vh;
    width: var(--crm-sidebar-width);
    position: fixed;
    inset: 0 auto 0 0;
    padding: 1.15rem 0.85rem;
    overflow-y: auto;
}

.crm-sidebar-brand {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 1rem;
    padding-bottom: 0.85rem;
}

.crm-sidebar-title {
    color: #fff;
    font-size: 0.98rem;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.crm-sidebar-subtitle {
    color: #8fa6c8;
    font-size: 0.73rem;
    margin-top: 0.2rem;
}

.crm-nav-group {
    margin-top: 1.05rem;
}

.crm-nav-heading {
    color: #8fa6c8;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin-bottom: 0.45rem;
    text-transform: uppercase;
}

.crm-nav-link {
    align-items: center;
    border-radius: 12px;
    color: #d6e2f5;
    display: flex;
    font-size: 0.84rem;
    font-weight: 600;
    margin-bottom: 0.18rem;
    padding: 0.6rem 0.78rem;
}

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

.crm-main {
    margin-left: var(--crm-sidebar-width);
    padding: 1.15rem;
}

.crm-topbar {
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(219, 227, 239, 0.8);
    border-radius: calc(var(--crm-radius) + 2px);
    box-shadow: var(--crm-shadow);
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.15rem;
    padding: 0.85rem 1rem;
}

.crm-page-title {
    font-size: 1.12rem;
    font-weight: 800;
    margin: 0;
    line-height: 1.2;
}

.crm-page-subtitle {
    color: var(--crm-text-soft);
    font-size: 0.78rem;
    margin-top: 0.18rem;
}

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

.crm-panel-header {
    align-items: center;
    border-bottom: 1px solid var(--crm-border);
    display: flex;
    justify-content: space-between;
    padding: 0.82rem 0.95rem;
}

.crm-panel-title {
    font-size: 0.88rem;
    font-weight: 800;
    margin: 0;
    line-height: 1.25;
}

.crm-panel-body {
    padding: 0.9rem 0.95rem;
}

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

.crm-stat-card {
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    padding: 0.85rem 0.95rem;
}

.crm-stat-label {
    color: var(--crm-text-soft);
    font-size: 0.72rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
}

.crm-stat-value {
    font-size: 1.28rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 0.12rem;
}

.crm-stat-meta {
    color: var(--crm-text-soft);
    font-size: 0.76rem;
}

.crm-toolbar {
    align-items: flex-end;
    display: flex;
    gap: 0.7rem;
    justify-content: space-between;
    margin-bottom: 0.85rem;
}

.crm-toolbar .form-label {
    color: var(--crm-text-soft);
    font-size: 0.72rem;
    font-weight: 700;
    margin-bottom: 0.28rem;
}

.crm-tabs {
    border-bottom: 1px solid var(--crm-border);
    gap: 0.3rem;
}

.crm-tabs .nav-link {
    border: 1px solid transparent;
    border-radius: 12px 12px 0 0;
    color: var(--crm-text-soft);
    font-weight: 700;
    padding: 0.58rem 0.85rem;
    font-size: 0.83rem;
}

.crm-tabs .nav-link:hover {
    border-color: transparent;
    color: var(--crm-text);
}

.crm-tabs .nav-link.active {
    background: var(--crm-surface);
    border-color: var(--crm-border) var(--crm-border) var(--crm-surface);
    color: var(--crm-text);
}

.crm-form-section + .crm-form-section {
    margin-top: 1rem;
}

.crm-form-section-title {
    border-bottom: 1px solid var(--crm-border);
    font-size: 0.8rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    padding-bottom: 0.45rem;
    text-transform: uppercase;
}

.crm-adjustment-input {
    display: grid;
    gap: 0.55rem;
    grid-template-columns: 110px minmax(0, 1fr);
}

.crm-form-section-header {
    align-items: flex-end;
    border-bottom: 1px solid var(--crm-border);
    display: flex;
    gap: 0.8rem;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.55rem;
}

.crm-form-section-header .crm-form-section-title {
    border-bottom: 0;
    margin-bottom: 0;
    padding-bottom: 0;
}

.crm-line-item-toolbar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    justify-content: flex-end;
}

.crm-line-item-toolbar .form-select {
    min-width: 104px;
    width: auto;
}

.crm-line-item-card {
    overflow: hidden;
}

.crm-line-item-header {
    align-items: center;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.crm-line-item-title {
    font-size: 0.8rem;
    font-weight: 800;
}

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

.crm-table thead th {
    border-bottom: 1px solid var(--crm-border-strong);
    color: var(--crm-text-soft);
    font-size: 0.67rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    padding: 0.7rem 0.72rem;
    text-transform: uppercase;
    white-space: nowrap;
}

.crm-table tbody td {
    border-bottom: 1px solid var(--crm-border);
    padding: 0.72rem 0.72rem;
    vertical-align: top;
    font-size: 0.82rem;
}

.crm-table tbody tr:last-child td {
    border-bottom: 0;
}

.crm-muted {
    color: var(--crm-text-soft);
}

.crm-kpi-row {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
}

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

.crm-kanban-column {
    background: var(--crm-surface-muted);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    min-height: 14rem;
    padding: 0.65rem;
}

.crm-kanban-head {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.6rem;
}

.crm-kanban-card {
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: 12px;
    cursor: grab;
    margin-bottom: 0.6rem;
    padding: 0.72rem;
}

.crm-kanban-card:last-child {
    margin-bottom: 0;
}

.crm-grid-2,
.crm-grid-3 {
    display: grid;
    gap: 0.85rem;
}

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

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

.crm-meta-list {
    display: grid;
    gap: 0.7rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.crm-meta-item-label {
    color: var(--crm-text-soft);
    font-size: 0.68rem;
    font-weight: 700;
    margin-bottom: 0.12rem;
    text-transform: uppercase;
}

.crm-meta-item-value {
    font-weight: 700;
    font-size: 0.82rem;
}

.crm-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-left: 0.4rem;
    position: relative;
}

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

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

.crm-timeline-item::before {
    background: var(--crm-accent);
    border: 3px solid #fff;
    border-radius: 999px;
    box-shadow: 0 0 0 1px var(--crm-border);
    content: '';
    height: 11px;
    left: -0.08rem;
    position: absolute;
    top: 0.4rem;
    width: 11px;
}

.crm-empty {
    color: var(--crm-text-soft);
    padding: 1.5rem 0.8rem;
    text-align: center;
    font-size: 0.82rem;
}

.crm-actions {
    display: flex;
    gap: 0.4rem;
    justify-content: flex-end;
}

.crm-schedule-grid {
    display: grid;
    gap: 0.85rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.crm-schedule-card {
    background: var(--crm-surface-muted);
    border: 1px solid var(--crm-border);
    border-radius: 12px;
    min-width: 0;
    padding: 0.82rem;
}

.crm-schedule-card-header {
    margin-bottom: 0.7rem;
}

.crm-form-stack {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    min-width: 0;
}

.crm-form-grid {
    display: grid;
    gap: 0.7rem;
    min-width: 0;
}

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

.crm-form-span-2 {
    grid-column: span 2;
}

.crm-form-grid .form-control,
.crm-form-grid .form-select {
    min-width: 0;
    width: 100%;
}

.crm-form-grid textarea.form-control {
    min-height: 96px;
    resize: vertical;
}

.crm-client-shell .crm-sidebar {
    background: #13243d;
}

.crm-mobile-toggle {
    display: none;
}

.badge {
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.35rem 0.55rem;
}

.table-responsive {
    border-radius: 0 0 var(--crm-radius) var(--crm-radius);
}

.form-control,
.form-select {
    border-color: var(--crm-border-strong);
    border-radius: 12px;
    font-size: 0.84rem;
    min-height: 37px;
    padding: 0.46rem 0.72rem;
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(32, 87, 216, 0.45);
    box-shadow: 0 0 0 0.18rem rgba(32, 87, 216, 0.12);
}

.btn {
    border-radius: 12px;
    font-size: 0.84rem;
    font-weight: 700;
    min-height: 37px;
    padding-inline: 0.82rem;
    padding-top: 0.42rem;
    padding-bottom: 0.42rem;
}

.btn-primary {
    background: var(--crm-accent);
    border-color: var(--crm-accent);
}

.btn-outline-secondary {
    border-color: var(--crm-border-strong);
    color: var(--crm-text);
}

.crm-table-actions {
    align-items: center;
    display: flex;
    gap: 0.35rem;
}

.crm-settings-master-form {
    align-items: center;
    display: grid;
    gap: 0.55rem;
}

.crm-settings-master-form > div {
    min-width: 0;
}

.crm-settings-master-form .form-control,
.crm-settings-master-form .form-select {
    min-width: 0;
    width: 100%;
}

.crm-settings-master-form--lead-status {
    grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr) minmax(100px, 0.85fr) 84px minmax(170px, 1.2fr) 108px;
}

.crm-settings-master-form--service-category {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.95fr) 110px minmax(0, 1.35fr) 108px;
}

.crm-settings-master-form--ticket-category {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.95fr) 92px 120px 108px;
}

.crm-settings-master-form--priority {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.95fr) 100px 84px 120px 108px;
}

.crm-settings-master-flags {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    min-width: 0;
}

.crm-settings-master-flags .form-check {
    margin-bottom: 0;
}

.crm-settings-master-actions {
    display: flex;
    justify-content: flex-end;
}

.crm-settings-master-actions .btn {
    min-width: 86px;
}

.crm-pill {
    background: var(--crm-accent-soft);
    border-radius: 999px;
    color: var(--crm-accent);
    display: inline-flex;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.32rem 0.6rem;
}

.accordion-item {
    border: 1px solid var(--crm-border);
}

.accordion-button {
    background: var(--crm-surface);
    color: var(--crm-text);
    font-weight: 700;
    font-size: 0.84rem;
}

.accordion-button:not(.collapsed) {
    background: var(--crm-accent-soft);
    box-shadow: none;
    color: var(--crm-text);
}

.accordion-button:focus {
    box-shadow: none;
}

.crm-login-shell {
    align-items: center;
    background: radial-gradient(circle at top left, #dbe8ff 0%, #f3f6fb 42%, #edf3fb 100%);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 1.1rem;
}

.crm-login-card {
    max-width: 392px;
    width: 100%;
}

.table {
    font-size: 0.83rem;
}

.form-label,
.form-text,
.alert,
.dropdown-item,
.nav-link,
.accordion-body,
.list-group-item {
    font-size: 0.82rem;
}

.alert {
    padding: 0.7rem 0.85rem;
}

.crm-panel .display-5,
.crm-panel .display-6,
.crm-panel h1,
.crm-panel h2,
.crm-panel h3,
.crm-panel h4 {
    line-height: 1.2;
}

@media (max-width: 1200px) {
    .crm-stat-grid,
    .crm-kanban,
    .crm-grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 991px) {
    .crm-sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 1040;
    }

    .crm-sidebar.is-open {
        transform: translateX(0);
    }

    .crm-main {
        margin-left: 0;
        padding: 0.9rem;
    }

    .crm-mobile-toggle {
        display: inline-flex;
    }

    .crm-topbar {
        padding: 0.78rem 0.9rem;
    }

    .crm-grid-2,
    .crm-meta-list,
    .crm-stat-grid,
    .crm-kanban,
    .crm-grid-3,
    .crm-schedule-grid,
    .crm-form-grid-2,
    .crm-adjustment-input,
    .crm-settings-master-form--lead-status,
    .crm-settings-master-form--service-category,
    .crm-settings-master-form--ticket-category,
    .crm-settings-master-form--priority {
        grid-template-columns: 1fr;
    }

    .crm-form-section-header,
    .crm-line-item-header {
        align-items: stretch;
        flex-direction: column;
    }

    .crm-line-item-toolbar {
        justify-content: flex-start;
    }

    .crm-line-item-toolbar .form-select {
        width: 100%;
    }

    .crm-form-span-2 {
        grid-column: auto;
    }

    .crm-settings-master-actions .btn {
        width: 100%;
    }
}
