/* ===================== SIDEBAR ===================== */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--gray-200);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform .25s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--gray-100);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 13px;
    letter-spacing: -0.5px;
    overflow: hidden;
}

/* ===== OrderFlow CSS Logo ===== */
.of-logo {
    position: relative;
    width: 24px;
    height: 24px;
}

/* The box/package shape */
.of-box {
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2.2px solid white;
    border-radius: 3px;
    top: 2px;
    left: 1px;
}

/* Box cross lines (package tape) */
.of-box::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    width: 0;
    height: calc(100% + 2px);
    border-left: 1.5px solid rgba(255, 255, 255, 0.5);
}

.of-box::after {
    content: '';
    position: absolute;
    left: -1px;
    top: 50%;
    width: calc(100% + 2px);
    height: 0;
    border-top: 1.5px solid rgba(255, 255, 255, 0.5);
}

/* The flow arrow */
.of-arrow {
    position: absolute;
    bottom: 1px;
    right: 0;
    width: 12px;
    height: 12px;
}

/* Arrow curved tail */
.of-arrow::before {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 0;
    width: 8px;
    height: 6px;
    border: 2px solid white;
    border-top: none;
    border-left: none;
    border-radius: 0 0 6px 0;
}

/* Arrow head (triangle) */
.of-arrow::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 5px solid white;
    transform: rotate(45deg);
}

/* Sidebar variant — smaller */
.of-logo-sidebar {
    width: 20px;
    height: 20px;
}

.of-logo-sidebar .of-box {
    width: 12px;
    height: 12px;
    border-width: 2px;
    border-radius: 2.5px;
    top: 1px;
    left: 0;
}

.of-logo-sidebar .of-arrow {
    width: 10px;
    height: 10px;
    bottom: 0;
    right: 0;
}

.of-logo-sidebar .of-arrow::before {
    width: 6px;
    height: 5px;
    border-width: 1.8px;
    bottom: 3px;
}

.of-logo-sidebar .of-arrow::after {
    border-left-width: 3.5px;
    border-right-width: 3.5px;
    border-bottom-width: 4.5px;
}

/* Splash core variant — tiny */
.of-logo-sm {
    width: 14px;
    height: 14px;
}

.of-logo-sm .of-box {
    width: 8px;
    height: 8px;
    border-width: 1.5px;
    border-radius: 2px;
    top: 0;
    left: 0;
}

.of-logo-sm .of-box::before {
    border-left-width: 1px;
}

.of-logo-sm .of-box::after {
    border-top-width: 1px;
}

.of-logo-sm .of-arrow {
    width: 8px;
    height: 8px;
    bottom: 0;
    right: -1px;
}

.of-logo-sm .of-arrow::before {
    width: 5px;
    height: 4px;
    border-width: 1.5px;
    bottom: 2px;
}

.of-logo-sm .of-arrow::after {
    border-left-width: 2.5px;
    border-right-width: 2.5px;
    border-bottom-width: 3px;
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-800);
    letter-spacing: -0.5px;
}

.logo-text span {
    color: var(--primary-600);
}

.sidebar-nav {
    padding: 12px;
    flex: 1;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 6px;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--gray-400);
    padding: 8px 12px 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    user-select: none;
}

.nav-section-title:hover {
    color: var(--primary-600);
    background: var(--primary-50);
}

.nav-chevron {
    font-size: 9px;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--gray-300);
}

/* Chevron rotation handled by JS via .collapsed-section class */

/* Collapsible items container */
.nav-section-items {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease;
    opacity: 1;
}

.nav-section-items.collapsed {
    max-height: 0;
    opacity: 0;
}

/* Chevron rotation when collapsed */
.nav-section.collapsed-section .nav-chevron {
    transform: rotate(-90deg);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--gray-600);
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
    transition: all .15s;
    margin-bottom: 1px;
}

.nav-item:hover {
    background: var(--primary-50);
    color: var(--primary-700);
}

.nav-item.active {
    background: var(--primary-100);
    color: var(--primary-700);
    font-weight: 600;
}

.nav-icon {
    width: 18px;
    text-align: center;
    font-size: 14px;
    color: var(--gray-400);
    flex-shrink: 0;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
    color: var(--primary-600);
}

.nav-label {
    flex: 1;
}

.nav-badge {
    background: var(--primary-500);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
}

/* ===================== MAIN ===================== */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: calc(100% - var(--sidebar-w));
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--gray-200);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.3px;
}

.topbar-subtitle {
    font-size: 12px;
    color: var(--gray-400);
    font-weight: 500;
    margin-top: -2px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.last-sync-info {
    font-size: 11px;
    color: var(--gray-400);
    font-weight: 500;
}

.mobile-menu-btn {
    display: none;
}

/* ===================== BUTTONS ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 12px;
    border: none;
    cursor: pointer;
    transition: all .2s;
    font-family: inherit;
    white-space: nowrap;
}

.btn i {
    font-size: 12px;
}

.btn-primary {
    background: var(--primary-600);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-700);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background: white;
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
}

.btn-outline:hover {
    border-color: var(--primary-300);
    color: var(--primary-600);
    background: var(--primary-50);
}

.btn-success {
    background: var(--emerald-600);
    color: white;
}

.btn-success:hover {
    background: var(--emerald-700);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 11px;
}

.btn.syncing {
    opacity: .6;
    pointer-events: none;
}

.btn.syncing i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* CS Leads Quick Date Chips */
.cs-leads-chip {
    padding: 5px 14px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-500);
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.cs-leads-chip:hover {
    color: var(--primary-600);
    background: var(--primary-50);
}
.cs-leads-chip.active {
    color: #fff;
    background: var(--primary-600);
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(79,70,229,0.25);
}