
/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS Variables for Design System */
:root {
    /* Colors */
    --background: hsl(245, 35%, 98%);
    --foreground: hsl(210, 12%, 16%);
    --card: hsl(0, 0%, 100%);
    --card-foreground: hsl(210, 12%, 16%);
    --muted: hsl(220, 14%, 96%);
    --muted-foreground: hsl(215, 16%, 47%);
    --border: hsl(214.3, 31.8%, 91.4%);
    --input: hsl(214.3, 31.8%, 91.4%);
    
    /* Dashboard Colors */
    --dashboard-primary: hsl(217, 91%, 60%);
    --dashboard-secondary: hsl(142, 71%, 45%);
    --dashboard-accent: hsl(45, 100%, 51%);
    --dashboard-warning: hsl(25, 95%, 53%);
    --dashboard-success: hsl(142, 71%, 45%);
    --dashboard-danger: hsl(0, 84%, 60%);
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, hsl(217, 91%, 60%) 0%, hsl(230, 89%, 65%) 100%);
    --gradient-secondary: linear-gradient(135deg, hsl(142, 71%, 45%) 0%, hsl(158, 64%, 52%) 100%);
    --gradient-accent: linear-gradient(135deg, hsl(45, 100%, 51%) 0%, hsl(38, 92%, 50%) 100%);
    --gradient-card: linear-gradient(135deg, hsl(0, 0%, 100%) 0%, hsl(220, 14%, 96%) 100%);
    --gradient-background: linear-gradient(135deg, hsl(245, 35%, 98%) 0%, hsl(240, 15%, 95%) 50%, hsl(220, 14%, 96%) 100%);
    
    /* Shadows */
    --shadow-soft: 0 4px 6px -1px hsl(220, 14%, 96% / 0.1), 0 2px 4px -1px hsl(220, 14%, 96% / 0.06);
    --shadow-medium: 0 10px 15px -3px hsl(220, 14%, 96% / 0.1), 0 4px 6px -2px hsl(220, 14%, 96% / 0.05);
    --shadow-large: 0 25px 50px -12px hsl(220, 14%, 96% / 0.25);
    --shadow-glow: 0 0 40px hsl(217, 91%, 60% / 0.15);
    
    /* Transitions */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    
    /* Border Radius */
    --radius: 0.5rem;
}

/* Dark Mode Variables */
.dark {
    --background: hsl(210, 20%, 8%);
    --foreground: hsl(220, 14%, 96%);
    --card: hsl(215, 28%, 12%);
    --card-foreground: hsl(220, 14%, 96%);
    --muted: hsl(215, 20%, 16%);
    --muted-foreground: hsl(215, 16%, 47%);
    --border: hsl(217.2, 32.6%, 17.5%);
    --input: hsl(217.2, 32.6%, 17.5%);
    
    /* Gradients Dark Mode */
    --gradient-card: linear-gradient(135deg, hsl(215, 28%, 12%) 0%, hsl(215, 20%, 16%) 100%);
    --gradient-background: linear-gradient(135deg, hsl(210, 20%, 8%) 0%, hsl(215, 25%, 10%) 50%, hsl(215, 20%, 16%) 100%);
    
    /* Shadows Dark Mode */
    --shadow-soft: 0 4px 6px -1px hsl(0, 0%, 0% / 0.3), 0 2px 4px -1px hsl(0, 0%, 0% / 0.2);
    --shadow-medium: 0 10px 15px -3px hsl(0, 0%, 0% / 0.3), 0 4px 6px -2px hsl(0, 0%, 0% / 0.2);
    --shadow-large: 0 25px 50px -12px hsl(0, 0%, 0% / 0.5);
    --shadow-glow: 0 0 40px hsl(217, 91%, 60% / 0.25);
}

/* Base Styles */
body {
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background: var(--gradient-background);
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--foreground);
    line-height: 1.6;
}

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

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse-slow {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@keyframes gradient-shift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

.animate-slide-in-right {
    animation: slideInRight 0.6s ease-out;
}

.animate-pulse-slow {
    animation: pulse-slow 3s ease-in-out infinite;
}

.animate-gradient {
    background-size: 200% 200%;
    animation: gradient-shift 6s ease-in-out infinite;
}

/* Navigation */
.navbar {
    background: var(--gradient-card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand h1 {
    background: var(--gradient-primary);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.5rem;
    font-weight: 700;
}

.nav-controls {
    display: flex;
    gap: 0.5rem;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--foreground);
    cursor: pointer;
    transition: var(--transition-smooth);
    font-size: 0.875rem;
}

.nav-btn:hover {
    background: var(--dashboard-primary);
    color: white;
    border-color: var(--dashboard-primary);
}

/* Main Content */
#mainContent {
    min-height: calc(100vh - 80px);
}

.page {
    display: none;
    padding: 2rem;
}

.page.active {
    display: block;
}

/* Tighten spacing for Debt page header */
#debtPage.page { padding: 0 !important; }
#debtPage .container { padding: 0 !important; margin-top: 0 !important; }
#debtPage .page-header { padding: 0 !important; margin: 0 !important; }
#debtPage .page-header .header-content { margin: 0 !important; }
#debtPage .header-text h1 { margin: 0 0 .5rem 0 !important; }
#debtPage .header-text p { margin: 0 0 .75rem 0 !important; }
#debtPage .controls-section { margin-top: 0 !important; }

/* Tighten spacing for Drivers Manage page header */
#driversManagePage.page {
    padding: 0;
}
#driversManagePage .container {
    padding-top: 0;
}
#driversManagePage .page-header {
    margin: 0;
}
#driversManagePage .page-header .header-content {
    margin: 0;
}
#driversManagePage .header-text h1 {
    margin-top: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Page Header */
.page-header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInUp 0.6s ease-out;
}

.page-title {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
}

.page-description {
    font-size: 1.125rem;
    color: var(--muted-foreground);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--foreground);
    cursor: pointer;
    transition: var(--transition-smooth);
    font-size: 0.875rem;
}

.back-btn:hover {
    background: var(--dashboard-primary);
    color: white;
    border-color: var(--dashboard-primary);
}

.header-text h1 {
    font-size: 2rem;
    font-weight: 700;
    background: var(--gradient-primary);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.header-text p {
    color: var(--muted-foreground);
}

/* CTA Section */
.cta-section {
    display: flex;
    justify-content: center;
    margin-bottom: 3rem;
    gap: 1rem;
    animation: fadeInUp 0.6s ease-out;
    animation-delay: 0.2s;
}

.cta-button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem 3rem;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-glow);
}

.cta-button:hover {
    opacity: 0.9;
    transform: scale(1.05);
    box-shadow: var(--shadow-large);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: var(--gradient-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-medium);
    transition: var(--transition-smooth);
    animation: fadeInUp 0.6s ease-out;
}

.stat-card:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-large);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.stat-header h3 {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted-foreground);
}

.stat-header i {
    color: var(--dashboard-primary);
    width: 1.25rem;
    height: 1.25rem;
}

.stat-content .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dashboard-primary);
    margin-bottom: 0.25rem;
}

.stat-change {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.chart-card {
    background: var(--gradient-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-medium);
    animation: fadeInUp 0.6s ease-out;
}

.chart-header {
    margin-bottom: 1.5rem;
}

.chart-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.chart-header h3 i {
    color: var(--dashboard-primary);
    width: 1.25rem;
    height: 1.25rem;
}

.chart-header p {
    color: var(--muted-foreground);
    font-size: 0.875rem;
}

.chart-content {
    height: 320px;
    position: relative;
}

/* Bottom Grid */
.bottom-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1.5rem;
}

.recent-card {
    background: var(--gradient-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-medium);
    animation: fadeInUp 0.6s ease-out;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--foreground);
    cursor: pointer;
    transition: var(--transition-smooth);
    font-size: 0.875rem;
}

.export-btn:hover {
    background: var(--dashboard-accent);
    color: white;
    border-color: var(--dashboard-accent);
}

.recent-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--muted);
    border-radius: var(--radius);
    transition: var(--transition-smooth);
}

.recent-item:hover {
    background: var(--muted-foreground);
}

.recent-item-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.recent-avatar {
    width: 2.5rem;
    height: 2.5rem;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.125rem;
}

.recent-details h4 {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.recent-details p {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.recent-stats {
    text-align: left;
}

.recent-stats .weight {
    font-weight: 500;
    color: var(--dashboard-secondary);
}

.recent-stats .revenue {
    font-size: 0.875rem;
    color: var(--dashboard-accent);
}

/* Controls Grid */
.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.control-card {
    background: var(--gradient-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-medium);
}

.control-header {
    margin-bottom: 1rem;
}

.control-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
}

.control-header h3 i {
    color: var(--dashboard-primary);
    width: 1.25rem;
    height: 1.25rem;
}

.control-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Manage search input */
#manageSearch {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--foreground);
    font-family: inherit;
}
#manageSearch:focus {
    outline: none;
    border-color: var(--dashboard-primary);
    box-shadow: 0 0 0 2px hsla(217, 91%, 60%, .2);
}

.control-content label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground);
}

.badge-ton {
    background: var(--gradient-secondary);
    color: #fff;
    padding: .25rem .5rem;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 700;
    min-width: 48px;
    text-align: center;
}

.price-input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.price-input-group input {
    width: 90px;
    text-align: center;
    font-weight: 700;
    color: var(--dashboard-accent);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    background: var(--card);
    box-shadow: var(--shadow-soft);
}

/* Make price inputs read-only style for non-admin (via disabled attribute) */
.price-input-group input[disabled] {
    opacity: .7;
    cursor: not-allowed;
    background: var(--muted);
}

.btn-ton-save {
    padding: 0.5rem 0.9rem;
    border: none;
    border-radius: var(--radius);
    background: var(--gradient-primary);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-soft);
}

.btn-ton-save:hover { opacity: .9; transform: translateY(-1px); }

.price-input-group span {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.add-driver-btn,
.export-data-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 1rem;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.add-driver-btn:hover,
.export-data-btn:hover {
    opacity: 0.9;
}

.export-data-btn {
    background: transparent;
    color: var(--foreground);
    border: 1px solid var(--border);
}

.export-data-btn:hover {
    background: var(--dashboard-accent);
    color: white;
    border-color: var(--dashboard-accent);
}

/* Filters Section */
.filters-section {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem;
    background: var(--gradient-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    margin-bottom: 2rem;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground);
    white-space: nowrap;
}

.filter-group input {
    width: 150px;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--foreground);
    font-size: 0.875rem;
}

.filter-group select {
    width: 150px;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--foreground);
    font-size: 0.875rem;
}

.filter-group input:focus {
    outline: none;
    border-color: var(--dashboard-primary);
    box-shadow: 0 0 0 2px var(--dashboard-primary) / 0.2;
}

/* Tables */
.table-container {
    background: var(--gradient-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-medium);
    overflow: hidden;
    margin-bottom: 2rem;
}

.drivers-table {
    width: 100%;
    border-collapse: collapse;
}

.drivers-table thead {
    background: var(--gradient-primary);
}

.drivers-table th {
    padding: 1rem;
    text-align: center;
    color: white;
    font-weight: 700;
    font-size: 0.875rem;
}

/* Keep header checkbox style consistent with row checkboxes */
.drivers-table thead th input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 6px;
    background: var(--card);
    display: inline-grid;
    place-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}
.drivers-table thead th input[type="checkbox"]::before {
    content: '';
    width: 10px;
    height: 10px;
    transform: scale(0);
    transition: var(--transition-smooth);
    border-radius: 4px;
    background: #fff; /* visible on gradient header */
}
.drivers-table thead th input[type="checkbox"]:checked::before {
    transform: scale(1);
}

.drivers-table td {
    padding: 1rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

/* Notes column: keep layout intact and truncate with ellipsis */
.drivers-table td:nth-child(13) .text-muted {
    display: inline-block;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

/* Emphasize key columns */
.drivers-table td.col-strong {
    font-weight: 700;
    color: var(--foreground);
}

.drivers-table tbody tr:hover {
    background: var(--muted);
}

/* Make trip rows feel clickable */
.drivers-table tr.trip-row {
    cursor: pointer;
}

/* Highlight specific debt rows when navigated from drivers table */
#debtTableBody tr.highlight-debt {
    outline: 2px solid var(--dashboard-primary);
    box-shadow: 0 0 0 3px hsla(217, 91%, 60%, 0.2) inset;
}

/* Paid/Unpaid row states */
.row-paid {
    background: hsla(0, 84%, 60%, 0.12) !important;
}

.row-unpaid {
    background: hsla(142, 71%, 45%, 0.12) !important;
}

/* Pretty checkboxes */
input[type="checkbox"].select-driver {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 6px;
    background: var(--card);
    display: inline-grid;
    place-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}

input[type="checkbox"].select-driver:hover {
    border-color: var(--dashboard-primary);
    box-shadow: 0 0 0 3px hsla(217, 91%, 60%, 0.15);
}

input[type="checkbox"].select-driver::before {
    content: '';
    width: 10px;
    height: 10px;
    transform: scale(0);
    transition: var(--transition-smooth);
    border-radius: 4px;
    background: var(--dashboard-primary);
}

input[type="checkbox"].select-driver:checked::before {
    transform: scale(1);
}

.drivers-table .weight {
    font-weight: 700;
    color: var(--dashboard-secondary);
}

.drivers-table .total {
    font-weight: 700;
    color: hsl(217, 30%, 25%);
}
.text-fare {
    color: hsl(217, 30%, 25%);
}

.drivers-table .advance {
    font-weight: 700;
    color: var(--dashboard-warning);
}

.drivers-table .net {
    font-weight: 700;
    color: var(--dashboard-success);
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--foreground);
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.icon-btn i {
    width: 18px;
    height: 18px;
}

.action-btn:hover {
    background: var(--dashboard-primary);
    color: white;
    border-color: var(--dashboard-primary);
}

.action-btn.delete:hover {
    background: var(--dashboard-danger);
    border-color: var(--dashboard-danger);
}

/* Visibility and contrast for Paid/Unpaid buttons */
.btn-paid {
    border-color: var(--dashboard-danger);
    color: var(--dashboard-danger);
}
.btn-unpaid {
    border-color: var(--dashboard-success);
    color: var(--dashboard-success);
}
.bg-success { background: var(--dashboard-success) !important; }
.bg-danger { background: var(--dashboard-danger) !important; }
.text-white { color: #fff !important; }

.btn-paid.bg-danger,
.btn-unpaid.bg-success {
    border-color: transparent;
}

/* Totals Table */
.totals-container {
    background: linear-gradient(135deg, hsl(152, 60%, 96%) 0%, hsl(160, 60%, 94%) 100%);
    border: 1px solid hsl(155, 30%, 85%);
    border-radius: var(--radius);
    box-shadow: var(--shadow-medium);
    overflow: hidden;
}

.totals-table {
    width: 100%;
    border-collapse: collapse;
}

.totals-table thead {
    background: linear-gradient(135deg, hsl(152, 55%, 45%) 0%, hsl(158, 55%, 48%) 100%);
}

.totals-table th {
    padding: 1rem;
    text-align: center;
    color: white;
    font-weight: 700;
    font-size: 0.875rem;
}

/* Dark mode: ensure totals table text is black for readability */
.dark .totals-table th,
.dark .totals-table td {
    color: #000 !important;
}

/* Dark mode: make fare column (الأجرة) text white in data table */
.dark .drivers-table th:nth-child(8),
.dark .drivers-table td:nth-child(8) {
    color: #fff !important;
}

.totals-table td {
    padding: 1rem;
    text-align: center;
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--foreground);
}

.totals-table .weight {
    color: var(--dashboard-secondary);
}

.totals-table .total {
    color: var(--dashboard-accent);
}

.totals-table .advance {
    color: var(--dashboard-warning);
}

.totals-table .net {
    color: var(--dashboard-success);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeInUp 0.3s ease-out;
}

/* Ensure edit trip modal consistent */
#editTripModal .modal-content { max-width: 500px; }

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-large);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideInRight 0.3s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--card);
    z-index: 10;
    border-radius: var(--radius) var(--radius) 0 0;
}

.modal-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-header h2 i {
    color: var(--dashboard-primary);
    width: 1.5rem;
    height: 1.5rem;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--muted-foreground);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius);
    transition: var(--transition-smooth);
}

.close-btn:hover {
    background: var(--muted);
    color: var(--foreground);
}

.modal-body {
    padding: 1.5rem;
}

/* Delete confirm modal tweaks */
#deleteConfirmModal .modal-content {
    max-width: 420px;
}
#deleteConfirmModal .modal-body p {
    margin-bottom: 1rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--foreground);
}

/* Date range inline group */
.date-range-group {
    display: flex;
    gap: 0.75rem;
    align-items: end;
    padding: 0.5rem 0.75rem;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.date-range-group .filter-group {
    margin-bottom: 0;
}

.required {
    color: var(--dashboard-danger);
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--foreground);
    font-size: 0.875rem;
    transition: var(--transition-smooth);
}

/* Combo group for searchable select */
.combo-group {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: .5rem;
}

.combo-group input[type="text"] {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--foreground);
}

/* Larger textarea for trip notes */
.textarea-lg {
    min-height: 120px;
    resize: vertical;
}

/* Select-all checkbox alignment */
th input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

/* Make totals toggle look clickable */
#toggleTotalsBtn {
    border-color: var(--dashboard-primary);
}
#toggleTotalsBtn:hover {
    background: var(--dashboard-primary);
    color: #fff;
}

.bg-advance-highlight {
    background: hsla(142, 71%, 45%, 0.15) !important;
    border-color: hsla(142, 71%, 45%, 0.4) !important;
}

.form-group input:focus {
    outline: none;
    border-color: var(--dashboard-primary);
    box-shadow: 0 0 0 2px var(--dashboard-primary) / 0.2;
}

.form-group input[type="number"] {
    text-align: center;
    width: 140px;
}

.error-message {
    color: var(--dashboard-danger);
    font-size: 0.875rem;
    text-align: center;
    background: var(--dashboard-danger) / 0.1;
    padding: 0.75rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: none;
}

.error-message.show {
    display: block;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.time-badge {
    background: var(--gradient-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: .4rem .8rem;
    font-weight: 700;
    color: var(--muted-foreground);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.chips .chip {
    background: var(--gradient-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: .25rem .6rem;
    font-size: .85rem;
    box-shadow: var(--shadow-soft);
}

.btn-primary,
.btn-secondary {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
}

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

.btn-primary:hover {
    opacity: 0.9;
}

.btn-secondary {
    background: transparent;
    color: var(--foreground);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--muted);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-medium);
    color: white;
    font-weight: 500;
    animation: slideInRight 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 300px;
}

.toast.success {
    background: var(--dashboard-success);
}

.toast.error {
    background: var(--dashboard-danger);
}

.toast.warning {
    background: var(--dashboard-warning);
}

.toast.info {
    background: var(--dashboard-primary);
}

/* Searchable Select Styles */
.searchable-select {
    position: relative;
}

.searchable-select input[type="text"] {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    font-size: 0.9rem;
    transition: var(--transition-smooth);
    background: var(--card);
    color: var(--foreground);
}

.searchable-select input[type="text"]:focus {
    outline: none;
    border-color: var(--dashboard-primary);
    box-shadow: 0 0 0 3px var(--dashboard-primary) / 0.1;
}

.searchable-select select {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    font-size: 0.9rem;
    transition: var(--transition-smooth);
    background: var(--card);
    color: var(--foreground);
    max-height: 200px;
    overflow-y: auto;
}

.searchable-select select:focus {
    outline: none;
    border-color: var(--dashboard-primary);
    box-shadow: 0 0 0 3px var(--dashboard-primary) / 0.1;
}

.searchable-select option {
    padding: 0.5rem;
    background: var(--card);
    color: var(--foreground);
}

.searchable-select option:hover {
    background: var(--muted);
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-container {
        padding: 1rem;
    }
    
    .page {
        padding: 1rem;
    }
    
    .page-title {
        font-size: 2rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .bottom-grid {
        grid-template-columns: 1fr;
    }
    
    .controls-grid {
        grid-template-columns: 1fr;
    }
    
    .filters-section {
        flex-direction: column;
    }
    
    .filter-group {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .filter-group input {
        width: 100%;
    }
    
    .drivers-table {
        font-size: 0.75rem;
    }
    
    .drivers-table th,
    .drivers-table td {
        padding: 0.5rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .toast-container {
        top: 1rem;
        right: 1rem;
        left: 1rem;
    }
    
    .toast {
        min-width: auto;
    }
    .combo-group {
        grid-template-columns: 1fr;
    }
    .drivers-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Make all tables scrollable on mobile */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table-container table {
        min-width: 720px;
    }

    /* Tighter cells on small screens */
    .drivers-table th,
    .drivers-table td,
    .totals-table th,
    .totals-table td {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .cta-button {
        padding: 1rem 2rem;
        font-size: 1rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .chart-content {
        height: 250px;
    }
    
    .form-actions {
        flex-direction: column;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.font-bold {
    font-weight: 700;
}

.font-medium {
    font-weight: 500;
}

.text-sm {
    font-size: 0.875rem;
}

.text-lg {
    font-size: 1.125rem;
}

.text-xl {
    font-size: 1.25rem;
}

.text-2xl {
    font-size: 1.5rem;
}

.text-3xl {
    font-size: 1.875rem;
}

.text-4xl {
    font-size: 2.25rem;
}

.mb-1 {
    margin-bottom: 0.25rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-3 {
    margin-bottom: 0.75rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mb-6 {
    margin-bottom: 1.5rem;
}

.mb-8 {
    margin-bottom: 2rem;
}

.mt-1 {
    margin-top: 0.25rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 0.75rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mt-6 {
    margin-top: 1.5rem;
}

.mt-8 {
    margin-top: 2rem;
}

.p-1 {
    padding: 0.25rem;
}

.p-2 {
    padding: 0.5rem;
}

.p-3 {
    padding: 0.75rem;
}

.p-4 {
    padding: 1rem;
}

.p-6 {
    padding: 1.5rem;
}

.p-8 {
    padding: 2rem;
}

.rounded {
    border-radius: var(--radius);
}

.rounded-lg {
    border-radius: 0.5rem;
}

.rounded-xl {
    border-radius: 0.75rem;
}

.rounded-2xl {
    border-radius: 1rem;
}

.shadow {
    box-shadow: var(--shadow-soft);
}

.shadow-md {
    box-shadow: var(--shadow-medium);
}

.shadow-lg {
    box-shadow: var(--shadow-large);
}

.border {
    border: 1px solid var(--border);
}

.border-0 {
    border: none;
}

.bg-primary {
    background: var(--dashboard-primary);
}

.bg-secondary {
    background: var(--dashboard-secondary);
}

.bg-accent {
    background: var(--dashboard-accent);
}

.bg-success {
    background: var(--dashboard-success);
}

.bg-warning {
    background: var(--dashboard-warning);
}

.bg-danger {
    background: var(--dashboard-danger);
}

.text-primary {
    color: var(--dashboard-primary);
}

.text-secondary {
    color: var(--dashboard-secondary);
}

.text-accent {
    color: var(--dashboard-accent);
}

.text-success {
    color: var(--dashboard-success);
}

.text-warning {
    color: var(--dashboard-warning);
}

.text-danger {
    color: var(--dashboard-danger);
}

.text-muted {
    color: var(--muted-foreground);
}

.cursor-pointer {
    cursor: pointer;
}

.transition {
    transition: var(--transition-smooth);
}

.hover\:scale-105:hover {
    transform: scale(1.05);
}

.hover\:opacity-90:hover {
    opacity: 0.9;
}

.focus\:outline-none:focus {
    outline: none;
}

.focus\:ring-2:focus {
    box-shadow: 0 0 0 2px var(--dashboard-primary) / 0.2;
}

.focus\:border-primary:focus {
    border-color: var(--dashboard-primary);
}

/* Time Input Group Styles */
.time-input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.time-input-group input[type="datetime-local"] {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--input);
    color: var(--foreground);
    font-family: inherit;
}

.time-input-group input[type="datetime-local"]:focus {
    outline: none;
    border-color: var(--dashboard-primary);
    box-shadow: 0 0 0 2px var(--dashboard-primary) / 0.2;
}

/* Header Content Styles */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.header-text {
    flex: 1;
}

.company-name-header {
    text-align: right;
}

.company-name-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dashboard-primary);
    margin: 0;
    background: var(--gradient-primary);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Clickable Stat Card */
.stat-card[onclick] {
    transition: all 0.3s ease;
}

.stat-card[onclick]:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.stat-card[onclick]:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

/* Responsive Design for Time Input */
@media (max-width: 768px) {
    .time-input-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .company-name-header {
        text-align: left;
    }
}


