/* ============================================
   DASHBOARD PAGE
   Matches the deliveries / order-import theme
   ============================================ */

/* Fix parent scroll — let browser handle scrolling */
.dashboard-container ~ *,
.dashboard-container {
    overflow: visible !important;
}

/* Override admin-home2.css parent constraints */
body:has(.dashboard-container) .container,
body:has(.dashboard-container) .content {
    overflow: visible !important;
    max-height: none !important;
    height: auto !important;
}

body:has(.dashboard-container) main {
    overflow: visible !important;
    max-height: none !important;
}

/* Fallback for browsers without :has() support */
.dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ---------------------------------------------------------
   STATS ROW
   --------------------------------------------------------- */
.dash-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.dash-stat-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    transition: box-shadow 0.2s;
}

.dash-stat-card label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin: 0;
}

.dash-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1a202c;
    line-height: 1.2;
}

.dash-stat-clickable {
    cursor: pointer;
}

.dash-stat-clickable:hover {
    box-shadow: 0 8px 30px rgba(0, 123, 255, 0.15);
}

.dash-stat-clickable .dash-stat-value {
    color: #007bff;
}

/* ---------------------------------------------------------
   MONTHLY GOAL
   --------------------------------------------------------- */
.dash-goal-bar {
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f0ff 100%);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.dash-goal-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
}

.dash-goal-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #4a5568;
}

.dash-goal-pct {
    font-size: 0.95rem;
    font-weight: 700;
    color: #007bff;
}

.dash-progress-track {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.dash-progress-fill {
    height: 100%;
    background: #007bff;
    border-radius: 8px;
    transition: width 0.5s ease;
}

/* ---------------------------------------------------------
   CARDS
   --------------------------------------------------------- */
.dash-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.dash-card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.dash-card-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #1a202c;
}

/* ---------------------------------------------------------
   ROUTES TABLE
   --------------------------------------------------------- */
.dash-table-wrapper {
    overflow-x: auto;
}

.dash-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.dash-table th,
.dash-table td {
    padding: 0.7rem 1rem;
    text-align: left;
    border-bottom: 1px solid #edf2f7;
}

.dash-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #4a5568;
    position: sticky;
    top: 0;
    z-index: 2;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

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

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

/* Revenue column */
.col-revenue {
    font-weight: 600;
    color: #2f855a;
    white-space: nowrap;
}

/* Complete column */
.pill-yes {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    background: #d1fae5;
    color: #065f46;
}

.pill-no {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    background: #fefcbf;
    color: #92400e;
}

/* Driver cell */
.cell-muted {
    color: #718096;
    font-size: 0.82rem;
}

/* Empty state */
.dash-empty {
    padding: 3rem 1.5rem;
    text-align: center;
    color: #718096;
}

.dash-empty .icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    display: block;
    opacity: 0.4;
}

.dash-empty .primary {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    color: #4a5568;
}

.dash-empty .secondary {
    font-size: 0.85rem;
}

/* ---------------------------------------------------------
   RESPONSIVE
   --------------------------------------------------------- */
@media (max-width: 768px) {
    .dashboard-container {
        padding: 1rem;
    }

    .dash-stats-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .dash-stat-card {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 1rem 1.25rem;
    }

    .dash-stat-value {
        font-size: 1.4rem;
    }

    .col-hide-mobile {
        display: none;
    }
}

/* ---------------------------------------------------------
   UNRESOLVED DELIVERIES SECTION
   --------------------------------------------------------- */
.unresolved-section {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
    border-radius: 16px;
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.unresolved-section.critical {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-color: #ef4444;
}

.unresolved-section.critical .unresolved-icon {
    background: #fee2e2;
    color: #dc2626;
}

.unresolved-section.critical .unresolved-title {
    color: #991b1b;
}

.unresolved-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    cursor: pointer;
}

.unresolved-header-left {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.unresolved-icon {
    width: 40px;
    height: 40px;
    background: #fef3c7;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.unresolved-icon svg {
    width: 22px;
    height: 22px;
    color: #d97706;
}

.unresolved-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #92400e;
    margin: 0 0 0.15rem 0;
}

.unresolved-subtitle {
    font-size: 0.8rem;
    color: #a16207;
    margin: 0;
}

.unresolved-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.unresolved-summary-pills {
    display: flex;
    gap: 0.5rem;
}

.summary-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.7);
    color: #78350f;
}

.summary-pill.pill-incomplete {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

.summary-pill.pill-held {
    background: rgba(59, 130, 246, 0.15);
    color: #2563eb;
}

.summary-pill.pill-transit {
    background: rgba(168, 85, 247, 0.15);
    color: #7c3aed;
}

.unresolved-toggle {
    background: rgba(255, 255, 255, 0.5);
    border: none;
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

.unresolved-toggle:hover {
    background: rgba(255, 255, 255, 0.8);
}

.unresolved-toggle .toggle-icon {
    width: 18px;
    height: 18px;
    color: #92400e;
    transition: transform 0.2s;
}

.unresolved-toggle.expanded .toggle-icon {
    transform: rotate(180deg);
}

/* Content area */
.unresolved-content {
    background: #fff;
    border-top: 1px solid rgba(245, 158, 11, 0.3);
}

.unresolved-filters {
    display: flex;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    overflow-x: auto;
}

.filter-btn {
    padding: 0.4rem 0.85rem;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    background: #fff;
    font-size: 0.75rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

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

.filter-btn.active {
    background: #1e293b;
    border-color: #1e293b;
    color: #fff;
}

/* Table */
.unresolved-table-wrapper {
    overflow-x: auto;
    max-height: 320px;
    overflow-y: auto;
}

.unresolved-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.unresolved-table th,
.unresolved-table td {
    padding: 0.6rem 0.875rem;
    text-align: left;
    border-bottom: 1px solid #edf2f7;
}

.unresolved-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #4a5568;
    position: sticky;
    top: 0;
    z-index: 2;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

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

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

.unresolved-table tbody tr.row-critical {
    background: #fef2f2;
}

.unresolved-table tbody tr.row-critical:hover {
    background: #fee2e2;
}

/* Date cell with age indicator */
.date-cell {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.date-value {
    font-weight: 500;
    color: #1a202c;
}

.date-age {
    font-size: 0.68rem;
    color: #718096;
}

.date-age.age-critical {
    color: #dc2626;
    font-weight: 600;
}

/* Status pills */
.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 12px;
    font-size: 0.68rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-incomplete {
    background: #fee2e2;
    color: #dc2626;
}

.status-held_at_depot {
    background: #dbeafe;
    color: #2563eb;
}

.status-in_transit {
    background: #ede9fe;
    color: #7c3aed;
}

.status-on_incomplete_route {
    background: #fef3c7;
    color: #d97706;
}

/* Value column */
.value-cell {
    font-weight: 500;
    color: #2f855a;
    white-space: nowrap;
}

.value-cell.unbilled {
    color: #dc2626;
}

/* Footer */
.unresolved-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.unresolved-count {
    font-size: 0.78rem;
    color: #64748b;
}

.unresolved-view-all {
    font-size: 0.78rem;
    font-weight: 600;
    color: #007bff;
    text-decoration: none;
    transition: color 0.15s;
}

.unresolved-view-all:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* Empty state */
.unresolved-empty {
    padding: 2rem 1.25rem;
    text-align: center;
    color: #64748b;
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 768px) {
    .unresolved-header {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .unresolved-header-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .unresolved-summary-pills {
        flex-wrap: wrap;
    }
    
    .summary-pill {
        font-size: 0.68rem;
        padding: 0.25rem 0.5rem;
    }
    
    .unresolved-filters {
        padding: 0.75rem 1rem;
    }
    
    .unresolved-table-wrapper {
        max-height: 260px;
    }

    .unresolved-footer {
        padding: 0.75rem 1.25rem;
        background: #f8fafc;
        border-top: 1px solid #e2e8f0;
        text-align: center;
    }

}