/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    font-size: 14px;
    color: #1e293b;
    background: #f1f5f9;
    height: 100%;
}

/* === Utility Classes === */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.5px;
}

.page-subtitle {
    font-size: 14px;
    color: #64748b;
    margin-top: 4px;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn-primary {
    background: #1d4ed8;
    color: #ffffff;
}

.btn-primary:hover { background: #1e40af; }

.btn-secondary {
    background: #ffffff;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover { background: #f8fafc; border-color: #cbd5e1; }

.btn-sm { padding: 5px 12px; font-size: 13px; }

/* === Cards === */
.card {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

/* === Table === */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    border-bottom: 2px solid #e2e8f0;
    background: #f8fafc;
    position: sticky;
    top: 0;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background 0.1s ease;
    cursor: pointer;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

/* === Type Badges === */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-gc { background: #dbeafe; color: #1e40af; }
.badge-po { background: #dcfce7; color: #166534; }
.badge-arch { background: #fae8ff; color: #86198f; }
.badge-builder { background: #ffedd5; color: #9a3412; }
.badge-vendor { background: #e0e7ff; color: #3730a3; }
.badge-developer { background: #f0fdf4; color: #15803d; }
.badge-pm { background: #fef3c7; color: #92400e; }
.badge-designer { background: #fce7f3; color: #9d174d; }
.badge-other { background: #f1f5f9; color: #475569; }

/* === Search === */
.search-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.search-input {
    flex: 1;
    max-width: 400px;
    padding: 9px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease;
    background: #ffffff;
}

.search-input:focus { border-color: #1d4ed8; box-shadow: 0 0 0 3px rgba(29,78,216,0.1); }

/* === Filter Chips === */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.chip {
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #475569;
    transition: all 0.15s ease;
}

.chip:hover { border-color: #1d4ed8; color: #1d4ed8; }
.chip.active { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }

/* === Stats Row === */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 16px 20px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #0f172a;
}

.stat-label {
    font-size: 13px;
    color: #64748b;
    margin-top: 4px;
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #94a3b8;
}

.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state-text { font-size: 16px; }

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* === Tabs === */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 24px;
}

.tab-item {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s ease;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.tab-item:hover { color: #1d4ed8; }
.tab-item.active { color: #1d4ed8; border-bottom-color: #1d4ed8; font-weight: 600; }

/* === Forms === */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    margin-bottom: 4px;
}

.form-control, .form-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    color: #1e293b;
    background: #ffffff;
    outline: none;
    transition: border-color 0.15s ease;
}

.form-control:focus, .form-select:focus {
    border-color: #1d4ed8;
    box-shadow: 0 0 0 3px rgba(29,78,216,0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

/* === Section Headers === */
.section-title {
    font-size: 16px;
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f1f5f9;
}

/* === Multi-select chips === */
.multi-select {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    min-height: 40px;
    background: #fff;
}

.multi-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 500;
}

.multi-chip-remove {
    cursor: pointer;
    font-size: 14px;
    color: #93c5fd;
    margin-left: 2px;
}

.multi-chip-remove:hover { color: #dc2626; }

/* === Inline add === */
.inline-add {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 6px;
}

.inline-add input {
    flex: 1;
    padding: 5px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
}

/* === Back link === */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #64748b;
    text-decoration: none;
    margin-bottom: 16px;
}

.back-link:hover { color: #1d4ed8; }

/* === Toast / Save bar === */
.save-bar {
    position: sticky;
    bottom: 0;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    padding: 12px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    z-index: 10;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
}

/* === Contact card === */
.contact-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 8px;
}

.contact-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #eff6ff;
    color: #1d4ed8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.contact-info { flex: 1; }
.contact-name { font-weight: 600; font-size: 14px; }
.contact-role { font-size: 12px; color: #64748b; }
.contact-detail { font-size: 12px; color: #94a3b8; }

/* === Sidebar SVG Icons === */
.nav-svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item .nav-svg { width: 20px; height: 20px; }
svg.nav-svg { width: 20px !important; height: 20px !important; max-width: 20px; max-height: 20px; }


.nav-label { font-size: 15px; font-weight: 500; white-space: nowrap; }


/* === Sidebar Global Styles === */
.cp-app { display: flex; height: 100vh; overflow: hidden; }

.cp-sidebar {
    width: 220px; background: #1a2332; color: #8899aa;
    display: flex; flex-direction: column; flex-shrink: 0;
}

.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 20px; border-bottom: 1px solid #2a3544;
}
.brand-icon {
    width: 32px; height: 32px; border-radius: 8px;
    background: #3b82f6; color: #fff; font-weight: 800; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
}
.brand-text { font-size: 17px; font-weight: 700; color: #fff; }

.nav-scroll { flex: 1; overflow-y: auto; padding: 8px 0; display: flex; flex-direction: column; }
.sidebar-footer { border-top: 1px solid #2a3544; padding: 8px 0; }

.sidebar-link {
    display: flex !important; align-items: center; gap: 12px;
    padding: 9px 20px; color: #8899aa !important; text-decoration: none !important;
    font-size: 14px; font-weight: 500; transition: all 0.1s;
}
.sidebar-link:hover { background: #232f3e; color: #d1dbe6 !important; }
.sidebar-link.active, a.sidebar-link.active { background: #2563eb; color: #fff !important; }

.sl-icon {
    width: 24px; height: 24px; border-radius: 6px;
    background: rgba(255,255,255,0.08); color: inherit;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.sl-text { white-space: nowrap; }

.cp-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.cp-topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 32px; background: #fff;
    border-bottom: 1px solid #e2e8f0; min-height: 52px; flex-shrink: 0;
}
.page-context { font-size: 15px; font-weight: 600; color: #0f172a; }
.user-info { font-size: 14px; color: #64748b; }

.cp-content { flex: 1; overflow-y: auto; padding: 28px 32px; }

/* === CRM KPI Cards === */
.crm-kpi-card {
    color: #fff;
    padding: 16px 20px;
    border-radius: 10px;
}
.crm-kpi-label {
    font-size: 12px;
    opacity: 0.8;
}
.crm-kpi-value {
    font-size: 22px;
    font-weight: 700;
}

/* === Company Detail Fields === */
.detail-label {
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    margin-bottom: 2px;
}
.detail-value {
    font-size: 14px;
    color: #1e293b;
    margin-bottom: 12px;
}

/* === Nav Group (expandable sidebar) === */
.nav-group {
    display: flex !important;
    flex-direction: column !important;
}

.nav-group-toggle {
    display: flex !important;
    align-items: center;
    gap: 12px;
    padding: 9px 20px;
    color: #8899aa !important;
    font-size: 14px;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: all 0.1s;
}
.nav-group-toggle:hover {
    background: #232f3e;
    color: #d1dbe6 !important;
}

.nav-chevron {
    margin-left: auto;
    font-size: 12px;
    transition: transform 0.15s ease;
}
.nav-chevron.open {
    transform: rotate(90deg);
}

.nav-group-items {
    display: flex !important;
    flex-direction: column !important;
}

.sidebar-sublink {
    display: block !important;
    padding: 7px 20px 7px 56px;
    color: #8899aa !important;
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.1s;
}
.sidebar-sublink:hover {
    background: #232f3e;
    color: #d1dbe6 !important;
}
.sidebar-sublink.active {
    color: #60a5fa !important;
}

/* === Sidebar Toggle (hamburger) === */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1001;
    background: #1a2332;
    color: #fff;
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.sidebar-overlay {
    display: none;
}

/* === Responsive === */
@media (max-width: 768px) {
    .sidebar-toggle {
        display: flex;
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 99;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s;
    }
    .sidebar-overlay.open {
        opacity: 1;
        pointer-events: auto;
    }

    .cp-sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        z-index: 100;
        width: 240px;
        transition: left 0.2s ease;
    }
    .cp-sidebar.open {
        left: 0;
    }

    .cp-topbar {
        padding-left: 56px;
    }

    .cp-content {
        padding: 16px;
    }

    .page-title { font-size: 20px; }

    .form-row, .form-row-3 {
        grid-template-columns: 1fr;
    }

    .tab-bar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }
    .tab-item {
        white-space: nowrap;
        min-height: 44px;
    }

    .data-table thead { display: none; }
    .data-table tbody tr {
        display: block;
        padding: 12px;
        border-bottom: 1px solid #e2e8f0;
        margin-bottom: 8px;
        background: #fff;
        border-radius: 8px;
    }
    .data-table td {
        display: block;
        padding: 4px 0;
        border: none;
        font-size: 13px;
    }
    .data-table td:first-child {
        font-weight: 600;
        font-size: 14px;
    }

    .btn, .chip, .tab-item {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .stats-row {
        grid-template-columns: 1fr 1fr !important;
    }
}

@media (max-width: 480px) {
    .stats-row {
        grid-template-columns: 1fr !important;
    }

    .page-title { font-size: 18px; }
    .stat-value { font-size: 22px; }
    .crm-kpi-value { font-size: 18px; }
}

/* Typeahead */
.typeahead-wrapper { position: relative; display: block; width: 100%; }
.typeahead-input {
    width: 100% !important; padding: 8px 12px; border: 1px solid #e2e8f0; border-radius: 6px;
    font-size: 13px; background: #fff; outline: none; box-sizing: border-box;
}
.typeahead-input:focus { border-color: #1d4ed8; box-shadow: 0 0 0 2px rgba(29,78,216,0.15); }
.typeahead-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); max-height: 200px; overflow-y: auto;
}
.typeahead-item {
    padding: 8px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid #f1f5f9;
}
.typeahead-item:hover { background: #eff6ff; }
.typeahead-item:last-child { border-bottom: none; }
.typeahead-selected {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; border: 1px solid #e2e8f0; border-radius: 6px;
    background: #f0f9ff; font-size: 13px; font-weight: 600; color: #1d4ed8;
}
.typeahead-clear {
    background: none; border: none; font-size: 16px; cursor: pointer; color: #94a3b8;
    padding: 0 0 0 8px; line-height: 1;
}
.typeahead-clear:hover { color: #dc2626; }

/* Project map */
#project-map { height: 250px; border-radius: 8px; }

/* Hide number input spinners */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}
