:root {
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --topbar-height: 56px;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #0ea5e9;
    --content-bg: #f4f6f9;
    --brand: #0ea5e9;
}

html,
body {
    height: 100%;
}

body.app-body {
    background: var(--content-bg);
    font-family: "Source Sans 3", "Segoe UI", sans-serif;
    min-height: 100vh;
}

.wrapper {
    min-height: 100vh;
}

.main-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #cbd5e1;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease, transform 0.2s ease;
    overflow: hidden;
}

.brand-link {
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    color: #fff !important;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-weight: 700;
    letter-spacing: 0.02em;
}

.brand-text {
    flex: 1;
    min-width: 0;
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--brand);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0 1.5rem;
}

.nav-sidebar,
.nav-sidebar .nav {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    width: 100%;
}

.nav-sidebar .nav-item {
    display: block;
    width: 100%;
}

.nav-sidebar .nav-header {
    display: block;
    width: 100%;
    padding: 0.85rem 1.15rem 0.35rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
}

.nav-sidebar .nav-link {
    color: #cbd5e1;
    display: flex;
    align-items: center;
    width: 100%;
    gap: 0.7rem;
    padding: 0.55rem 1.15rem;
    border-radius: 0;
    font-size: 0.92rem;
}

.nav-sidebar .nav-link span {
    flex: 1;
    min-width: 0;
}

.nav-sidebar .nav-link i {
    width: 1.25rem;
    text-align: center;
    font-size: 1rem;
}

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

.nav-sidebar .nav-link.active {
    background: rgba(14, 165, 233, 0.18);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--sidebar-active);
}

.nav-sidebar .nav-link .bi-chevron-down {
    margin-left: auto;
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.nav-sidebar .nav-link[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

.nav-treeview {
    background: rgba(0, 0, 0, 0.18);
    list-style: none;
    padding: 0.25rem 0;
    margin: 0;
    width: 100%;
    flex-direction: column;
    flex-wrap: nowrap;
}

.nav-treeview.collapse:not(.show) {
    display: none;
}

.nav-treeview.show,
.nav-treeview.collapsing {
    display: flex;
}

.nav-treeview .nav-link {
    padding-left: 2.85rem;
    font-size: 0.88rem;
}

.main-header {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 1030;
}

.content-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.2s ease;
}

.content-header {
    padding: 1.1rem 1.25rem 0.25rem;
}

.content {
    padding: 0.75rem 1.25rem 2rem;
}

.app-card {
    background: #fff;
    border: 0;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.04);
}

.stat-card .stat-label {
    color: #64748b;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #0f172a;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: #0f172a;
    text-decoration: none;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #e0f2fe;
    color: #0369a1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.breadcrumb {
    background: transparent;
    padding: 0;
    margin: 0;
    font-size: 0.86rem;
}

.sidebar-overlay {
    display: none;
}

body.sidebar-collapsed .main-sidebar {
    width: var(--sidebar-collapsed);
}

body.sidebar-collapsed .content-wrapper {
    margin-left: var(--sidebar-collapsed);
}

body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-sidebar .nav-link span,
body.sidebar-collapsed .nav-sidebar .nav-header,
body.sidebar-collapsed .nav-sidebar .bi-chevron-down {
    display: none;
}

body.sidebar-collapsed .nav-treeview {
    display: none !important;
}

body.sidebar-collapsed .nav-sidebar .nav-link {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.auth-screen {
    min-height: 100vh;
    background: linear-gradient(160deg, #0f172a 0%, #1e293b 55%, #0ea5e9 160%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin-bottom: 1.25rem;
}

.brand-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
    background: #fff;
    padding: 2px;
    flex-shrink: 0;
}

.auth-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 8px;
    background: #f8fafc;
    padding: 4px;
}

.upload-panel .preview-box {
    min-height: 120px;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.upload-panel .preview-box-sm {
    min-height: 72px;
    max-width: 120px;
}

.preview-image {
    max-height: 110px;
    max-width: 100%;
    object-fit: contain;
}

.preview-placeholder {
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
}

.preview-placeholder i {
    font-size: 1.4rem;
}

.settings-form .nav-tabs .nav-link {
    color: #64748b;
}

.settings-form .nav-tabs .nav-link.active {
    font-weight: 600;
    color: #0f172a;
}

.permission-group {
    padding: 1rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.permission-group:first-child {
    padding-top: 0;
}

.permission-group:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.kanban-board {
    display: flex;
    gap: 0.85rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    align-items: flex-start;
}

.kanban-column {
    flex: 0 0 260px;
    background: #eef2f6;
    border-radius: 10px;
    min-height: 280px;
    display: flex;
    flex-direction: column;
}

.kanban-column.is-drop-target {
    outline: 2px dashed #0ea5e9;
}

.kanban-column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0.85rem 0.4rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.kanban-cards {
    padding: 0.4rem 0.65rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    min-height: 180px;
}

.kanban-card {
    background: #fff;
    border-radius: 8px;
    padding: 0.75rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    cursor: grab;
}

.kanban-card.is-dragging {
    opacity: 0.55;
}

.kanban-card-title {
    font-weight: 600;
    color: #0f172a;
    text-decoration: none;
}

.kanban-empty {
    padding: 1rem 0.25rem;
    text-align: center;
}

.kanban-col-new .kanban-column-header { color: #475569; }
.kanban-col-contacted .kanban-column-header { color: #0369a1; }
.kanban-col-proposal .kanban-column-header { color: #0f766e; }
.kanban-col-negotiation .kanban-column-header { color: #7c3aed; }
.kanban-col-won .kanban-column-header { color: #15803d; }
.kanban-col-lost .kanban-column-header { color: #57534e; }

.chart-wrap {
    position: relative;
    height: 280px;
}

.chart-wrap-sm {
    height: 240px;
}

.kanban-card .js-open-task {
    font-weight: 600;
    color: #0f172a;
    text-decoration: none;
}

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

    .content-wrapper,
    body.sidebar-collapsed .content-wrapper {
        margin-left: 0;
    }

    body.sidebar-open .main-sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 1035;
    }

    body.sidebar-collapsed .brand-text,
    body.sidebar-collapsed .nav-sidebar .nav-link span,
    body.sidebar-collapsed .nav-sidebar .nav-header,
    body.sidebar-collapsed .nav-sidebar .bi-chevron-down {
        display: inline;
    }

    body.sidebar-collapsed .nav-treeview {
        display: block !important;
    }

    body.sidebar-collapsed .nav-sidebar .nav-link {
        justify-content: flex-start;
        padding: 0.55rem 1.15rem;
    }
}
