/* Dealership Management Styles */

.dealership-container {
    padding: 20px;
    background: #f8f9fa;
    min-height: calc(100vh - 60px);
}

/* Page Header */
.page-header {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.page-title {
    font-size: 28px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
}

.page-subtitle {
    color: #6c757d;
    margin: 8px 0 0 0;
    font-size: 14px;
}

/* Stats Cards */
.stats-cards {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.stat-card {
    background: white;
    border-radius: 8px;
    padding: 14px 20px;
    min-width: 110px;
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.stat-card.active-dealers {
    border-color: #10b981;
    background: linear-gradient(135deg, #10b98110 0%, #10b98105 100%);
}

.stat-card.in-review-dealers {
    border-color: #f59e0b;
    background: linear-gradient(135deg, #f59e0b10 0%, #f59e0b05 100%);
}

.stat-card.inactive-dealers {
    border-color: #6b7280;
    background: linear-gradient(135deg, #6b728010 0%, #6b728005 100%);
}

.stat-card.shutdown-dealers {
    border-color: #ef4444;
    background: linear-gradient(135deg, #ef444410 0%, #ef444405 100%);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.active-dealers .stat-value {
    color: #10b981;
}

.in-review-dealers .stat-value {
    color: #f59e0b;
}

.inactive-dealers .stat-value {
    color: #6b7280;
}

.shutdown-dealers .stat-value {
    color: #ef4444;
}

.stat-label {
    font-size: 11px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Filter Section */
.filter-section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

/* Search Input */
.search-wrapper {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-size: 14px;
}

.search-input {
    padding-left: 36px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    transition: all 0.3s ease;
}

.search-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Filter Dropdowns */
.form-select {
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    transition: all 0.3s ease;
}

.form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Flag Filter Checkboxes */
#riskFlaggedFilter,
#opportunityFlaggedFilter {
    cursor: pointer;
}

#riskFlaggedFilter:checked {
    background-color: #ef4444;
    border-color: #ef4444;
}

#opportunityFlaggedFilter:checked {
    background-color: #10b981;
    border-color: #10b981;
}

.form-check-label[for="riskFlaggedFilter"],
.form-check-label[for="opportunityFlaggedFilter"] {
    cursor: pointer;
    user-select: none;
    font-weight: 500;
    font-size: 13px;
}

/* Advanced Filters Toggle */
.advanced-filter-toggle {
    color: #445082;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.3s ease;
}

.advanced-filter-toggle:hover {
    color: #354066;
}

.advanced-filter-toggle i {
    transition: transform 0.3s ease;
}

.advanced-filter-toggle[aria-expanded="true"] i.fa-chevron-down {
    transform: rotate(180deg);
}

/* Table Section */
.table-section {
    background: white;
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
    overflow-x: auto;
}

/* Table Styles */
.dealership-table {
    margin: 0;
    table-layout: fixed;
}

.dealership-table thead {
    background: #f8f9fa;
    border-bottom: 2px solid #e5e7eb;
}

.dealership-table th {
    font-weight: 600;
    color: #374151;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 16px;
    white-space: nowrap;
}

/* Column Width Distribution for Visual Groups */
.dealership-table th:nth-child(1) { width: 8%; }  /* Dealer ID */
.dealership-table th:nth-child(2) { width: 24%; } /* Dealership Name */
.dealership-table th:nth-child(3) { width: 8%; }  /* Market */
.dealership-table th:nth-child(4) { width: 10%; } /* Type */
.dealership-table th:nth-child(5) { width: 12%; } /* Originations */
.dealership-table th:nth-child(6) { width: 15%; } /* Amount Funded */
.dealership-table th:nth-child(7) { width: 13%; } /* Avg Loan */
.dealership-table th:nth-child(8) { width: 10%; } /* Status */

/* Group Headers Visual Enhancement */
.dealership-table th:nth-child(1),
.dealership-table th:nth-child(2) {
    background: linear-gradient(to bottom, #f8f9fa, #f3f4f6);
}

.dealership-table th:nth-child(3),
.dealership-table th:nth-child(4) {
    background: linear-gradient(to bottom, #f9fafb, #f3f4f6);
}

.dealership-table th:nth-child(5),
.dealership-table th:nth-child(6),
.dealership-table th:nth-child(7) {
    background: linear-gradient(to bottom, #f7f9fc, #f3f4f6);
}

.dealership-table th:nth-child(8) {
    background: linear-gradient(to bottom, #f8f9fa, #f3f4f6);
}

/* Visual Grouping with Borders */
.dealership-table th:nth-child(2),
.dealership-table td:nth-child(2) {
    border-right: 1px solid #e5e7eb;
    padding-right: 24px;
}

.dealership-table th:nth-child(4),
.dealership-table td:nth-child(4) {
    border-right: 1px solid #e5e7eb;
    padding-right: 24px;
}

.dealership-table th:nth-child(7),
.dealership-table td:nth-child(7) {
    border-right: 1px solid #e5e7eb;
    padding-right: 24px;
}

/* Add left padding after borders for visual separation */
.dealership-table th:nth-child(3),
.dealership-table td:nth-child(3),
.dealership-table th:nth-child(5),
.dealership-table td:nth-child(5),
.dealership-table th:nth-child(8),
.dealership-table td:nth-child(8) {
    padding-left: 24px;
}

.dealership-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.3s ease;
}

.dealership-table th.sortable:hover {
    background-color: #e5e7eb;
}

.sort-icon {
    margin-left: 6px;
    font-size: 10px;
    color: #9ca3af;
}

.dealership-table th.sort-asc .sort-icon::before {
    content: "\f0de";
    color: #3b82f6;
}

.dealership-table th.sort-desc .sort-icon::before {
    content: "\f0dd";
    color: #3b82f6;
}

.dealership-table tbody tr {
    border-bottom: 1px solid #f3f4f6;
    transition: background-color 0.2s ease;
}

.dealership-table tbody tr:hover {
    background-color: #f9fafb;
}

.dealership-table td {
    padding: 14px 16px;
    color: #1f2937;
    font-size: 14px;
    vertical-align: middle;
}

/* Dealership Name Cell */
.dealership-name {
    font-weight: 600;
    color: #1f2937;
}

/* Flag Indicators */
.flag-indicator {
    display: inline-block;
    margin-right: 4px;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.flag-indicator i {
    font-size: 10px;
}

/* Risk Flag Indicator (red) */
.flag-indicator.flag-risk {
    color: #ef4444;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.flag-indicator.flag-risk:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    transform: scale(1.05);
}

/* Opportunity Flag Indicator (green) */
.flag-indicator.flag-opportunity {
    color: #10b981;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
}

.flag-indicator.flag-opportunity:hover {
    background: #d1fae5;
    border-color: #6ee7b7;
    transform: scale(1.05);
}

.dealer-id {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #6b7280;
}

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-badge.status-active {
    background-color: #d1fae5;
    color: #065f46;
}

.status-badge.status-in-review {
    background-color: #fef3c7;
    color: #92400e;
}

.status-badge.status-shutdown {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-badge.status-inactive {
    background-color: #f3f4f6;
    color: #6b7280;
}

/* Performance Metrics */
.metric-value {
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
}

.metric-high {
    color: #10b981;
    background: linear-gradient(90deg, transparent, rgba(16, 185, 129, 0.05));
    padding: 2px 8px;
    border-radius: 4px;
}

.metric-medium {
    color: #f59e0b;
    background: linear-gradient(90deg, transparent, rgba(245, 158, 11, 0.05));
    padding: 2px 8px;
    border-radius: 4px;
}

.metric-low {
    color: #ef4444;
    background: linear-gradient(90deg, transparent, rgba(239, 68, 68, 0.05));
    padding: 2px 8px;
    border-radius: 4px;
}

/* Action Buttons */
.btn-action {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.btn-edit-status {
    background: #445082;
    color: white;
    border: none;
}

.btn-edit-status:hover {
    background: #354066;
    transform: translateY(-1px);
}

/* Pagination Section */
.pagination-section {
    padding: 20px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 0 0 12px 12px;
}

.pagination-info {
    color: #6b7280;
    font-size: 14px;
}

.pagination {
    margin: 0;
}

.pagination .page-link {
    color: #445082;
    border: 1px solid #e5e7eb;
    margin: 0 2px;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 14px;
}

.pagination .page-item.active .page-link {
    background-color: #445082;
    border-color: #445082;
}

.pagination .page-link:hover {
    background-color: #f0f2f7;
    border-color: #445082;
}

/* Export Button */
#exportBtn {
    background: #10b981;
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

#exportBtn:hover {
    background: #059669;
    transform: translateY(-1px);
}

/* Clear Filters Button */
#clearFiltersBtn {
    border-color: #d1d5db;
    color: #6b7280;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

#clearFiltersBtn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #374151;
}

/* Modal Styles */
.modal-content {
    border-radius: 12px;
    border: none;
}

.modal-header {
    background: #f8f9fa;
    border-radius: 12px 12px 0 0;
    border-bottom: 1px solid #e5e7eb;
}

.current-status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
}

/* Empty State */
#emptyState {
    padding: 60px 20px;
}

#emptyState i {
    opacity: 0.3;
}

#emptyState h5 {
    color: #374151;
    margin-bottom: 8px;
}

/* Loading State */
#tableLoading {
    padding: 60px 20px;
}

/* Toast */
.toast {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Responsive Design */
@media (max-width: 768px) {
    .stats-cards {
        flex-direction: column;
        align-items: stretch;
    }

    .stat-card {
        min-width: auto;
    }

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

    .dealership-table {
        font-size: 12px;
    }

    .dealership-table th,
    .dealership-table td {
        padding: 10px 8px;
    }

    .pagination-section {
        padding: 16px;
    }

    .pagination-info {
        text-align: center;
        margin-bottom: 12px;
    }
}

/* History Button Styling */
.btn-view-history {
    background: #445082;
    color: white;
    border: none;
}

.btn-view-history:hover {
    background: #354066;
    transform: translateY(-1px);
}

/* Timeline Styling for Audit History */
.timeline {
    position: relative;
    padding: 0;
}

.timeline-item {
    position: relative;
    padding-left: 45px;
    margin-bottom: 25px;
}

.timeline-item:before {
    content: '';
    position: absolute;
    left: 15px;
    top: 30px;
    bottom: -25px;
    width: 2px;
    background: #e5e7eb;
}

.timeline-item.timeline-last:before {
    display: none;
}

.timeline-marker {
    position: absolute;
    left: 0;
    top: 5px;
}

.timeline-dot {
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid #9ca3af;
    border-radius: 50%;
    position: absolute;
    left: 10px;
    top: 5px;
}

.timeline-dot-primary {
    border-color: #445082;
    background: #445082;
}

.timeline-content {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 15px;
}

.timeline-header {
    margin-bottom: 10px;
}

.timeline-date {
    font-size: 13px;
    color: #6b7280;
    font-weight: 600;
}

.status-change {
    display: flex;
    align-items: center;
    margin: 10px 0;
}

.timeline-meta {
    font-size: 13px;
}

.timeline-reason {
    background: white;
    border-left: 3px solid #445082;
    padding: 8px 12px;
    margin-top: 10px;
    border-radius: 4px;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dealership-table tbody tr {
    animation: slideIn 0.3s ease;
}

/* Hover Effects */
.dealership-table tbody tr:hover td {
    background-color: #f9fafb;
}

.btn-action:active {
    transform: scale(0.95);
}

/* Number Formatting */
.number-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.currency {
    font-weight: 600;
}

/* Date Formatting */
.date-cell {
    color: #6b7280;
    font-size: 13px;
}

/* ========================================
   DEALERSHIP DETAILS MODAL STYLES
   ======================================== */

/* Dealership Link Styling */
.dealership-link {
    color: #445082;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    border-bottom: 1px solid transparent;
}

.dealership-link:hover {
    color: #354066;
    border-bottom-color: #354066;
}

.dealership-link:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(68, 80, 130, 0.2);
    border-radius: 2px;
}

/* Details Modal Structure */
#dealershipDetailsModal .modal-dialog {
    max-width: 1200px;
}

#dealershipDetailsModal .modal-content {
    border: none;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

#dealershipDetailsModal .modal-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #f3f4f6 100%);
    border-bottom: 1px solid #e5e7eb;
    padding: 20px 24px;
}

#dealershipDetailsModal .modal-footer {
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    padding: 16px 24px;
}

/* Details Header Section */
.details-header {
    background: linear-gradient(135deg, #f8f9fa 0%, white 100%);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.details-header h4 {
    color: #1f2937;
    font-weight: 700;
    font-size: 24px;
}

.details-header .text-muted {
    color: #6b7280;
    font-size: 14px;
}

/* Details Sections */
.details-section {
    background: #f9fafb;
    border-radius: 10px;
    padding: 18px;
    border: 1px solid #e5e7eb;
    transition: all 0.3s ease;
}

.details-section:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.section-title {
    color: #374151;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb;
}

.section-title i {
    color: #6b7280;
    font-size: 16px;
}

/* Info Items */
.info-item {
    margin-bottom: 12px;
}

.info-item label {
    display: block;
    color: #6b7280;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.info-item .fw-semibold {
    color: #1f2937;
    font-size: 14px;
}

/* Legacy metric styles removed - now using tabbed interface styles */

/* Editable Field Transitions */
#statusEdit,
#flagReasonEdit,
#reviewEdit,
#notesEdit {
    transition: all 0.3s ease;
}

#statusEdit:focus,
#flagReasonEdit:focus,
#reviewEdit:focus,
#notesEdit:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Notes Display */
.notes-content {
    background: white;
    border-radius: 6px;
    padding: 12px;
    min-height: 240px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    font-size: 14px;
    line-height: 1.6;
    color: #374151;
}

.notes-content:empty:before {
    content: 'No notes available';
    color: #9ca3af;
    font-style: italic;
}

/* Notes Edit Textarea */
#notesEdit {
    resize: vertical;
    min-height: 150px;
    max-height: 400px;
    font-size: 14px;
    line-height: 1.6;
}

/* Flag Edit Section */
#flagEdit .form-check {
    padding: 10px;
    background: #fef3c7;
    border-radius: 6px;
    border: 1px solid #fde68a;
    display: flex;
    align-items: center;
}

#flagEdit .form-check-input {
    margin-right: 8px;
    margin-top: 0;
}

#flagEdit .form-check-label {
    margin-bottom: 0;
    display: flex;
    align-items: center;
}

#flagEdit .form-check-input:checked {
    background-color: #ef4444;
    border-color: #ef4444;
}

#flagReasonEdit {
    margin-top: 10px;
}

/* Status and Flag Badges in Details */
#detailsStatusBadge .badge,
#detailsFlagBadge .badge,
#detailsOpportunityBadge .badge {
    font-size: 12px;
    padding: 4px 10px;
    font-weight: 600;
}

#statusDisplay .badge {
    font-size: 14px;
    padding: 6px 12px;
}

/* View History Button */
#viewHistoryBtn {
    background: white;
    color: #445082;
    border: 2px solid #445082;
    font-weight: 600;
    transition: all 0.3s ease;
}

#viewHistoryBtn:hover {
    background: #445082;
    color: white;
    transform: translateY(-2px);
}

/* Save/Cancel Buttons - Edit button removed from header, now in Management tab */

/* Loading Spinner Enhancements */
#detailsLoading .spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3em;
}

/* Responsive Design for Details Modal */
@media (max-width: 992px) {
    #dealershipDetailsModal .modal-dialog {
        max-width: 100%;
        margin: 10px;
    }

    .details-header h4 {
        font-size: 20px;
    }

    .metric-large {
        font-size: 24px;
    }
}

@media (max-width: 768px) {
    #dealershipDetailsModal .row > div {
        margin-bottom: 16px;
    }

    .details-section {
        margin-bottom: 12px;
    }

    .metric-card {
        padding: 12px;
    }

    .metric-large {
        font-size: 20px;
    }
}

/* Animation Classes */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

#detailsContent.show {
    animation: fadeInScale 0.3s ease-out;
}

/* Scrollbar Styling for Notes */
.notes-content::-webkit-scrollbar,
#notesEdit::-webkit-scrollbar {
    width: 6px;
}

.notes-content::-webkit-scrollbar-track,
#notesEdit::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 3px;
}

.notes-content::-webkit-scrollbar-thumb,
#notesEdit::-webkit-scrollbar-thumb {
    background: #9ca3af;
    border-radius: 3px;
}

.notes-content::-webkit-scrollbar-thumb:hover,
#notesEdit::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Status Display Enhancement */
#statusDisplay,
#flagDisplay {
    min-height: 32px;
    display: flex;
    align-items: center;
}

/* Date Display Enhancement */
#reviewDisplay:empty:before {
    content: 'Unavailable';
    color: #9ca3af;
    font-style: italic;
}

/* Custom Bootstrap Tooltip for Flag Indicators */
.flag-tooltip .tooltip-inner {
    max-width: 350px;
    text-align: left;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.5;
    background: #1f2937;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.flag-tooltip .tooltip-arrow::before {
    border-right-color: #1f2937;
}

/* Ensure tooltips appear above other elements */
.tooltip {
    z-index: 1080;
}

/* ===== NEW L1M Performance Styles ===== */

/* Performance Divider */
.performance-divider {
    border: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, #e5e7eb, transparent);
    opacity: 0.6;
}

/* L1M Performance Section - Same size as L12M with subtle distinction */
.performance-l1m {
    background: rgba(249, 250, 251, 0.7) !important;
    border: 1px solid rgba(229, 231, 235, 0.9) !important;
    transition: all 0.3s ease;
}

.performance-l1m:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.performance-l1m .section-title {
    font-size: 14px;
    color: #374151;
}

/* L1M Metric Cards - Same styling as L12M */
.metric-card-compact {
    background: white;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid #e5e7eb;
    text-align: center;
    transition: all 0.3s ease;
}

.metric-card-compact:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.metric-value-with-trend {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
}

.metric-medium {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
    font-family: 'SF Mono', 'Monaco', monospace;
}

.metric-sublabel-compact {
    font-size: 11px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* ===== Trend Indicators & Percentage Changes ===== */

/* Trend Indicators for L1M Metrics */
.trend-indicator {
    font-size: 12px;
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', monospace;
    transition: color 0.3s ease;
}

.trend-positive {
    color: #10b981;
}

.trend-negative {
    color: #ef4444;
}

.trend-neutral {
    color: #6b7280;
}

.trend-na {
    color: #9ca3af;
    font-style: italic;
    font-weight: 400;
}

/* Risk Metrics Value Row */
.metric-value-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
}

/* Metric Changes for Risk Metrics */
.metric-change {
    font-size: 13px;
    font-weight: 500;
    font-family: 'SF Mono', 'Monaco', monospace;
}

.metric-change-positive {
    color: #10b981;
}

.metric-change-negative {
    color: #ef4444;
}

.metric-change-neutral {
    color: #6b7280;
}

.metric-change-na {
    color: #9ca3af;
    font-style: italic;
    font-weight: 400;
}

/* ===== Responsive Adjustments ===== */

@media (max-width: 1400px) {
    .metric-medium {
        font-size: 24px;
    }

    .trend-indicator {
        font-size: 11px;
    }

    .metric-change {
        font-size: 12px;
    }
}

@media (max-width: 1200px) {
    .metric-value-with-trend {
        flex-direction: column;
        align-items: center;
        gap: 2px;
    }

    .metric-value-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
}

/* ===== Smooth Transitions ===== */

.trend-indicator,
.metric-change {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-2px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced Color Gradients for Better Visual Hierarchy */
.trend-positive:hover,
.metric-change-positive:hover {
    color: #059669;
    text-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
}

.trend-negative:hover,
.metric-change-negative:hover {
    color: #dc2626;
    text-shadow: 0 0 8px rgba(239, 68, 68, 0.3);
}

/* Analytics icon links removed - no longer needed in redesigned modal */

/* ===== Modal Navigation Styles ===== */

/* Navigation Container */
.modal-navigation {
    display: flex;
    align-items: center;
}

/* Navigation Button Group */
.modal-navigation .btn-group {
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.5);
    padding: 2px;
}

/* Navigation Buttons */
#modalNavPrevious,
#modalNavNext {
    padding: 6px 12px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid #e5e7eb;
    background: white;
    color: #374151;
    transition: all 0.2s ease;
    position: relative;
}

#modalNavPrevious:hover:not(:disabled),
#modalNavNext:hover:not(:disabled) {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-color: #3b82f6;
    color: white;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

#modalNavPrevious:active:not(:disabled),
#modalNavNext:active:not(:disabled) {
    transform: scale(0.98);
}

/* Buttons are never disabled, but show subtle difference at boundaries */
#modalNavPrevious.at-boundary,
#modalNavNext.at-boundary {
    opacity: 0.7;
    background: #fafafa;
}

/* Position Indicator */
#modalNavInfo {
    background: white !important;
    border: 1px solid #e5e7eb !important;
    color: #6b7280 !important;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 16px;
    cursor: default !important;
    min-width: 80px;
}

#modalNavInfo span {
    font-family: 'SF Mono', 'Monaco', monospace;
}

/* Removed tooltip CSS since we're using aria-label for accessibility */

/* Mobile Responsive */
@media (max-width: 768px) {
    .modal-navigation .btn-group {
        padding: 1px;
    }

    #modalNavPrevious,
    #modalNavNext {
        padding: 4px 8px;
        font-size: 13px;
    }

    #modalNavInfo {
        min-width: 60px;
        padding: 4px 8px;
        font-size: 12px;
    }
}

/* Animation for navigation transition */
@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.modal-navigating-next #detailsContent {
    animation: slideInFromRight 0.3s ease-out;
}

.modal-navigating-prev #detailsContent {
    animation: slideInFromLeft 0.3s ease-out;
}

/* Unsaved Changes Modal Styling */
#unsavedChangesModal .modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

#unsavedChangesModal .modal-header {
    border-bottom: 1px solid #e5e7eb;
    padding: 20px 24px;
}

#unsavedChangesModal .modal-body {
    padding: 24px;
}

#unsavedChangesModal .modal-footer {
    border-top: 1px solid #e5e7eb;
    padding: 16px 24px;
    gap: 8px;
}

/* ========================================
   REDESIGNED TABBED MODAL STYLES
   ======================================== */

/* Details Header Meta (Simplified) */
.details-header-meta {
    font-size: 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.details-header-meta .badge {
    font-size: 12px;
    padding: 4px 10px;
}

/* Tab Navigation */
.details-tabs {
    border-bottom: 2px solid #e5e7eb;
}

.details-tabs .nav-link {
    color: #6b7280;
    font-weight: 500;
    font-size: 14px;
    padding: 12px 20px;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
}

.details-tabs .nav-link:hover {
    color: #374151;
    background: #f9fafb;
    border-color: transparent;
}

.details-tabs .nav-link.active {
    color: #445082;
    font-weight: 600;
    background: transparent;
    border-color: #445082;
}

.details-tabs .nav-link i {
    opacity: 0.7;
}

.details-tabs .nav-link.active i {
    opacity: 1;
}

/* ===== OVERVIEW TAB STYLES ===== */

/* Volume Performance Cards */
.volume-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    height: 100%;
    transition: all 0.2s ease;
}

.volume-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.volume-period {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f3f4f6;
}

.volume-metric-primary {
    font-size: 32px;
    font-weight: 800;
    color: #1f2937;
    font-family: 'SF Mono', 'Monaco', monospace;
    line-height: 1;
}

.volume-metric-secondary {
    font-size: 18px;
    font-weight: 700;
    font-family: 'SF Mono', 'Monaco', monospace;
    margin-top: 8px;
}

.volume-metric-tertiary {
    font-size: 16px;
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', monospace;
    margin-top: 8px;
}

.volume-sublabel {
    font-size: 11px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 2px;
}

.volume-change {
    font-size: 13px;
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', monospace;
    margin-top: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

.volume-change.positive {
    color: #059669;
    background: #ecfdf5;
}

.volume-change.negative {
    color: #dc2626;
    background: #fef2f2;
}

.volume-change.neutral {
    color: #6b7280;
    background: #f3f4f6;
}

/* Risk Metrics Grid */
.risk-metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.risk-metric-item {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
}

.risk-metric-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    margin-bottom: 8px;
}

.risk-metric-value {
    font-size: 24px;
    font-weight: 800;
    color: #1f2937;
    font-family: 'SF Mono', 'Monaco', monospace;
    margin-bottom: 8px;
}

.risk-metric-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.risk-metric-change {
    font-size: 12px;
    font-weight: 500;
    font-family: 'SF Mono', 'Monaco', monospace;
}

.risk-metric-change.positive {
    color: #059669;
}

.risk-metric-change.negative {
    color: #dc2626;
}

.risk-metric-change.neutral {
    color: #6b7280;
}

.risk-metric-comparison {
    font-size: 11px;
    color: #6b7280;
}

.risk-metric-comparison.better {
    color: #059669;
}

.risk-metric-comparison.worse {
    color: #dc2626;
}

/* Classification Grid */
.classification-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.classification-item {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px;
}

.classification-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #9ca3af;
    margin-bottom: 4px;
}

.classification-value {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

/* ===== PIPELINE TAB STYLES ===== */

/* Funnel Container */
.funnel-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 20px 0;
}

.funnel-stage {
    flex: 1;
    max-width: 220px;
}

.funnel-arrow {
    color: #d1d5db;
    font-size: 24px;
    padding: 0 16px;
}

.funnel-box {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 24px 20px;
    text-align: center;
    transition: all 0.2s ease;
}

.funnel-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.funnel-submissions {
    border-color: #60a5fa;
    background: linear-gradient(135deg, #eff6ff 0%, white 100%);
}

.funnel-qualified {
    border-color: #fbbf24;
    background: linear-gradient(135deg, #fffbeb 0%, white 100%);
}

.funnel-funded {
    border-color: #34d399;
    background: linear-gradient(135deg, #ecfdf5 0%, white 100%);
}

.funnel-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    margin-bottom: 8px;
}

.funnel-value {
    font-size: 36px;
    font-weight: 800;
    color: #1f2937;
    font-family: 'SF Mono', 'Monaco', monospace;
    line-height: 1;
}

.funnel-change {
    font-size: 13px;
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', monospace;
    margin-top: 8px;
}

.funnel-change.positive {
    color: #059669;
}

.funnel-change.negative {
    color: #dc2626;
}

.funnel-change.neutral {
    color: #6b7280;
}

/* Conversion Cards */
.conversion-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    height: 100%;
}

.conversion-label {
    font-size: 14px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 4px;
}

.conversion-formula {
    font-size: 11px;
    color: #9ca3af;
    margin-bottom: 16px;
}

.conversion-value {
    font-size: 42px;
    font-weight: 800;
    color: #1f2937;
    font-family: 'SF Mono', 'Monaco', monospace;
    line-height: 1;
}

.conversion-change {
    font-size: 14px;
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', monospace;
    margin-top: 8px;
}

.conversion-change.positive {
    color: #059669;
}

.conversion-change.negative {
    color: #dc2626;
}

.conversion-change.neutral {
    color: #6b7280;
}

/* ===== BENCHMARKS TAB STYLES ===== */

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

.benchmark-table thead th {
    background: #f9fafb;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #374151;
    padding: 14px 16px;
    border-bottom: 2px solid #e5e7eb;
}

.benchmark-table tbody td {
    padding: 16px;
    vertical-align: middle;
}

.benchmark-metric-name {
    font-weight: 600;
    color: #374151;
}

.benchmark-value {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
    font-family: 'SF Mono', 'Monaco', monospace;
}

.benchmark-value.na {
    color: #9ca3af;
    font-weight: 400;
}

.benchmark-change {
    font-size: 12px;
    font-weight: 500;
    font-family: 'SF Mono', 'Monaco', monospace;
    margin-top: 4px;
}

.benchmark-change.positive {
    color: #059669;
}

.benchmark-change.negative {
    color: #dc2626;
}

.benchmark-change.neutral {
    color: #9ca3af;
}

.benchmark-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 12px;
    color: #6b7280;
}

.benchmark-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== MANAGEMENT TAB STYLES ===== */

.management-actions {
    display: flex;
    justify-content: flex-start;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

#detailsSaveBtn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    font-weight: 600;
    padding: 10px 24px;
}

#detailsSaveBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

#detailsSaveBtn:disabled {
    opacity: 0.6;
    transform: none;
    box-shadow: none;
}

#detailsCancelBtn {
    background: #6b7280;
    border: none;
    font-weight: 500;
    padding: 10px 20px;
}

#detailsCancelBtn:hover {
    background: #4b5563;
}

/* Flag Sections in Management Tab */
.flag-section {
    position: relative;
}

.flag-section-risk {
    border-left: 3px solid #ef4444;
}

.flag-section-opportunity {
    border-left: 3px solid #10b981;
}

/* Flag Reason Containers */
#flagReasonContainer {
    margin-left: 24px;
    padding-left: 16px;
    border-left: 2px solid #fecaca;
}

#opportunityReasonContainer {
    margin-left: 24px;
    padding-left: 16px;
    border-left: 2px solid #a7f3d0;
}

/* Opportunity flag checkbox styling */
#opportunityCheckEdit:checked {
    background-color: #10b981;
    border-color: #10b981;
}

#opportunityReasonEdit {
    margin-top: 10px;
}

/* Notes Textarea in Management */
#managementPane #notesEdit {
    min-height: 150px;
    resize: vertical;
}

/* Mobile view - Show only Dealership Name, Market, and Status */
@media (max-width: 768px) {
    /* Hide Dealer ID (1st), Type (4th), Originations (5th), Amount Funded (6th), Avg Loan (7th) columns */
    .dealership-table thead th:nth-child(1),
    .dealership-table tbody td:nth-child(1),
    .dealership-table thead th:nth-child(4),
    .dealership-table tbody td:nth-child(4),
    .dealership-table thead th:nth-child(5),
    .dealership-table tbody td:nth-child(5),
    .dealership-table thead th:nth-child(6),
    .dealership-table tbody td:nth-child(6),
    .dealership-table thead th:nth-child(7),
    .dealership-table tbody td:nth-child(7) {
        display: none;
    }

    /* Center the items per page selector on mobile */
    .pagination-section .row > .col-md-4:last-child {
        text-align: center !important;
        margin-top: 12px;
    }

    /* Fix cramped modal header on mobile */
    #dealershipDetailsModal .modal-header {
        padding: 12px 16px;
    }

    #dealershipDetailsModal .modal-title {
        font-size: 16px;
    }

    #dealershipDetailsModal .modal-navigation {
        margin-left: auto;
        margin-right: 8px;
    }

    #dealershipDetailsModal .modal-navigation .btn-sm {
        padding: 4px 8px;
        font-size: 12px;
    }

    /* Improve modal details header spacing on mobile */
    #dealershipDetailsModal .details-header {
        padding-bottom: 16px;
        margin-bottom: 16px;
    }

    #dealershipDetailsModal .details-header h4 {
        font-size: 18px;
        margin-bottom: 8px;
    }

    #dealershipDetailsModal .details-header .text-muted {
        font-size: 13px;
        line-height: 1.6;
    }

    #dealershipDetailsModal .details-header .text-muted > span {
        display: block;
        margin-bottom: 4px;
    }

    /* Make Edit Details button full width on mobile */
    #detailsEditBtn {
        width: 100%;
        margin-top: 12px;
    }

    /* Put flag badge on same line as status badge on mobile */
    #dealershipDetailsModal #detailsFlagBadge {
        display: inline-block;
        margin-left: 8px;
        margin-top: 0;
    }

    #dealershipDetailsModal #detailsStatusBadge {
        display: inline-block;
    }

    /* ===== TABBED MODAL MOBILE STYLES ===== */

    /* Tab Navigation - Horizontal scroll */
    .details-tabs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .details-tabs::-webkit-scrollbar {
        display: none;
    }

    .details-tabs .nav-item {
        flex-shrink: 0;
    }

    .details-tabs .nav-link {
        padding: 10px 16px;
        font-size: 13px;
        white-space: nowrap;
    }

    /* Volume Cards - Stack vertically */
    #overviewPane .volume-card {
        margin-bottom: 12px;
    }

    .volume-metric-primary {
        font-size: 28px;
    }

    .volume-metric-secondary {
        font-size: 16px;
    }

    /* Risk Metrics Grid - Single column */
    .risk-metrics-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .risk-metric-value {
        font-size: 20px;
    }

    /* Classification Grid - Single column */
    .classification-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    /* Pipeline Funnel - Vertical layout */
    .funnel-container {
        flex-direction: column;
        gap: 0;
    }

    .funnel-stage {
        max-width: 100%;
        width: 100%;
    }

    .funnel-arrow {
        transform: rotate(90deg);
        padding: 12px 0;
    }

    .funnel-box {
        padding: 20px 16px;
    }

    .funnel-value {
        font-size: 28px;
    }

    /* Conversion Cards */
    .conversion-card {
        margin-bottom: 12px;
    }

    .conversion-value {
        font-size: 32px;
    }

    /* Benchmark Table - Smaller text */
    .benchmark-table thead th {
        font-size: 10px;
        padding: 10px 8px;
    }

    .benchmark-table tbody td {
        padding: 12px 8px;
    }

    .benchmark-value {
        font-size: 14px;
    }

    .benchmark-change {
        font-size: 10px;
    }

    .benchmark-legend {
        flex-direction: column;
        gap: 8px;
    }

    /* Management Actions */
    .management-actions {
        flex-direction: column;
        gap: 8px;
    }

    .management-actions button {
        width: 100%;
    }

    #detailsCancelBtn {
        margin-left: 0 !important;
    }
}