/* Mafy Driver App - Fresh Structure */
:root {
    --primary-purple: #7C3AED;
    --primary-hover: #6D28D9;
    --bg-deep-blue: #0A192F; /* Solid Deep Blue */
    --pill-light: #F8FAFC; /* Light color for pills */
    --text-dark: #0F172A; /* Dark text for light pills */
    --text-light: #F8FAFC;
    --border-delivered: #22C55E;
    --border-returns: #EF4444; /* Solid Red for returns */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background-color: var(--bg-deep-blue);
    color: var(--text-light);
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Better for scrolling lists */
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    background: transparent;
    text-align: center;
}

.logo {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 8px;
    background: linear-gradient(to right, #A78BFA, #7C3AED);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.company-title {
    display: block;
    width: 100%;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: #F8FAFC;
    margin-bottom: 4px;
    letter-spacing: 0.05em;
}

p.subtitle {
    color: #94A3B8;
    margin-bottom: 32px;
    font-size: 1rem;
    font-weight: 500;
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 600;
    margin: 24px 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--glass-border);
}

.divider:not(:empty)::before {
    margin-right: 16px;
}

.divider:not(:empty)::after {
    margin-left: 16px;
}

.btn-manager-link {
    background: none;
    border: 1px solid rgba(167, 139, 250, 0.4);
    color: #A78BFA;
    padding: 12px;
    border-radius: 12px;
    width: 100%;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-manager-link:hover {
    background: rgba(167, 139, 250, 0.1);
    border-color: var(--primary-purple);
}

/* Desktop Only: Hide Manager Login and Divider on mobile/tablet */
@media screen and (max-width: 1024px) {
    #manager-portal-btn, .btn-manager-link, .divider {
        display: none !important;
    }
}

.input-group {
    margin-bottom: 20px;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #CBD5E1;
}

input {
    width: 100%;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    transition: all 0.3s ease;
}

input:focus {
    outline: none;
    border-color: var(--primary-purple);
    background: rgba(255, 255, 255, 0.05);
}

/* Large Purple Buttons for Mobile */
.btn-login {
    width: 100%;
    padding: 18px;
    background-color: var(--primary-purple);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 12px;
    box-shadow: 0 10px 15px -3px rgba(124, 58, 237, 0.3);
}

.btn-login:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(124, 58, 237, 0.4);
}

.btn-login:active {
    transform: translateY(0);
}

/* Simplified Container Base */
.master-route-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 8px; /* Zero waste side margins */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Specific Widths for different screen types */
.driver-width {
    max-width: 500px;
}

.dashboard-width {
    max-width: 1600px;
}

.header {
    margin-bottom: 24px;
    padding: 30px 10px 10px 10px;
}

.header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.header-title-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-logout-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(167, 139, 250, 0.1);
    border: 1px solid rgba(167, 139, 250, 0.4);
    border-radius: 12px;
    color: #A78BFA;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    margin-left: 10px;
}

.btn-logout-icon:hover {
    background: rgba(124, 58, 237, 0.2);
    border-color: var(--primary-purple);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

.btn-logout-icon svg {
    display: block;
}

.logo-small {
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: 2px;
    background: linear-gradient(to right, #A78BFA, #7C3AED);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Brand Logo Structure Overrides */
.brand-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.brand-container .logo {
    margin-bottom: 0;
}

.brand-container-small {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.brand-container-small .logo-small {
    margin-bottom: 0;
}

.screen-title {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Master Route Search Bar */
.search-container {
    padding: 0 10px 20px 10px;
    display: block !important;
    min-height: 100px;
    position: relative;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
}

.search-input-wrapper svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94A3B8;
    pointer-events: none;
    z-index: 10;
}

.search-input-wrapper input {
    width: 100%;
    height: 65px;
    padding: 0 25px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px; /* Pill shape */
    color: var(--text-light);
    font-size: 1.2rem;
    font-weight: 700;
    transition: all 0.3s ease;
}

.search-input-wrapper input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-purple);
    outline: none;
}

.search-input-wrapper input:focus + svg {
    color: var(--primary-purple);
}

.store-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Custom Scrollbar */
.store-list::-webkit-scrollbar {
    width: 6px;
}
.store-list::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

/* Store Cards as Large Pills */
.store-card {
    width: 100%;
    margin: 0; /* Center with margins */
    padding: 20px 30px;
    text-align: left;
    background: var(--pill-light);
    border: none;
    border-radius: 999px; /* Match search bar pill shape */
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.4s ease forwards;
}

.store-card:hover {
    background: white;
    transform: translateY(-2px);
}

.store-card:active {
    transform: scale(0.98);
}

.store-name {
    font-size: 1.4rem;
    font-weight: 800; /* Bold as requested */
    color: var(--text-dark);
}

.store-address {
    font-size: 0.95rem;
    color: #475569;
    line-height: 1.4;
}

.store-arrow {
    color: var(--primary-purple);
    display: flex;
    align-items: center;
    background: white;
    padding: 10px;
    border-radius: 50%;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.loading-state {
    text-align: center;
    padding: 60px 40px;
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
}

@media (max-width: 480px) {
    .login-container, .master-route-container {
        width: calc(100% - 40px); /* 20px margin on each side */
        margin: 0 20px;
        padding: 0;
        display: flex;
        flex-direction: column;
        justify-content: center; /* Center vertically on mobile */
        height: auto;
        min-height: 100vh;
        border-radius: 0;
    }
    
    .login-container {
        margin-top: 60px;
        min-height: calc(100vh - 60px);
    }

    .btn-login {
        padding: 20px;
        font-size: 1.2rem;
    }
}

/* Store Details Screen */
.btn-back {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: #A78BFA;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 0;
    margin-bottom: 2px;
}

.product-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 16px 0 0 0;
    padding-bottom: 120px; /* Space for fixed footer */
}

.product-item {
    background: var(--pill-light);
    border-radius: 20px; /* 20px border radius for all corners */
    padding: 10px 15px; /* Compact padding */
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 0 12px 0; /* Full width within container */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.product-info {
    display: flex;
    flex-direction: column;
    max-width: 50%; /* Prevents long names from pushing inputs */
}

.product-name {
    font-weight: 800;
    color: var(--text-dark);
    font-size: 14px; /* Smaller font for mobile */
    line-height: 1.25;
    word-wrap: break-word; /* Allows wrapping for long names */
}

.product-price {
    font-size: 0.9rem;
    color: #475569;
    font-weight: 600;
}

.quantity-input-group {
    display: flex;
    gap: 6px; /* Tighter gap */
    align-items: center;
}

.input-field-wrapper {
    display: flex;
    flex-direction: row; /* Side by side in the pill */
    align-items: center;
    gap: 8px;
}

.input-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: #94A3B8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.product-qty-input {
    width: 45px; /* More compact width */
    height: 32px; /* More compact height */
    padding: 0 4px;
    background: white;
    border: 2px solid transparent; /* Default */
    border-radius: 8px;
    color: var(--text-dark);
    font-size: 1rem; /* Unified font size */
    font-weight: 700;
    text-align: center;
    transition: all 0.3s ease;
}

/* Specific border colors as requested */
.product-qty-input.delivered {
    border: 3px solid var(--border-delivered);
}

.product-qty-input.returns {
    border: 3px solid var(--border-returns);
}

.product-qty-input:focus {
    outline: none;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
}

.product-qty-input::-webkit-input-placeholder {
    font-size: 0.75rem;
    font-weight: 700;
    color: #94A3B8;
}

.product-qty-input::placeholder {
    font-size: 0.75rem;
    font-weight: 700;
    color: #94A3B8;
}

.actions-footer {
    display: grid;
    gap: 16px;
    padding: 20px;
    background: var(--bg-deep-blue);
    position: fixed; /* Improved reliability for mobile sticky effect */
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 500px; /* Match .driver-width */
    z-index: 100;
    box-shadow: 0 -15px 30px rgba(10, 25, 47, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}
/* Success Overlay */
.success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.success-card {
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    padding: 40px;
    border-radius: 32px;
    text-align: center;
    max-width: 320px;
    width: 100%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: modalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.8) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.success-icon {
    width: 80px;
    height: 80px;
    background: rgba(34, 197, 94, 0.1);
    border: 2px solid #22C55E;
    border-radius: 50%;
    color: #22C55E;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px auto;
}

.success-card h3 {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: #F8FAFC;
}

.success-card p {
    color: #94A3B8;
    margin-bottom: 24px;
}

/* Completion Badges */
.store-card.completed {
    border-color: rgba(34, 197, 94, 0.4);
    background: rgba(34, 197, 94, 0.05);
}

.store-card.completed .store-name {
    color: #4ADE80;
}

.badge-completed {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #4ADE80;
    background: rgba(74, 222, 128, 0.1);
    padding: 4px 10px;
    border-radius: 99px;
    margin-top: 4px;
}

.store-card-info {
    display: flex;
    flex-direction: column;
}

/* CRITICAL: Force Manager Dashboard to Full Width */
#manager-dashboard.master-route-container.dashboard-container {
    max-width: none !important;
    width: calc(100% - 80px) !important;
    margin: 10px auto !important;
    padding: 24px 16px 40px 16px !important;
    min-width: auto !important; /* Remove the min-width constraint to allow responsiveness */
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.28);
    overflow: hidden;
}

/* Driver Filter Bar */
.driver-filter-bar {
    display: flex;
    gap: 12px;
    padding: 5px 2px;
    margin: 24px 0 4px 0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.driver-filter-bar::-webkit-scrollbar {
    display: none;
}

.btn-filter {
    padding: 12px 24px;
    height: 45px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    color: #94A3B8;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-filter:hover {
    background: rgba(167, 139, 250, 0.1);
    border-color: rgba(167, 139, 250, 0.4);
    color: #A78BFA;
    transform: translateY(-2px);
}

.btn-filter.active {
    background: var(--primary-purple);
    border-color: var(--primary-purple);
    color: white;
    box-shadow: 0 10px 15px -3px rgba(124, 58, 237, 0.3);
}


.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}


/* Top Metrics Cards */
.top-metrics-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 24px;
    margin-bottom: 24px;
    width: 100%;
}

.metric-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
    background: rgba(255, 255, 255, 0.08);
}

.metric-title {
    font-size: 0.85rem;
    font-weight: 800;
    color: #94A3B8;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 12px;
}

.metric-value {
    font-size: 2.2rem;
    font-weight: 800;
    font-family: monospace;
    color: #FFFFFF !important;
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.4);
}

.metric-value.text-white {
    color: #FFFFFF !important;
}

.metric-value.text-red {
    color: #FFFFFF !important; /* Enforce bright white as requested */
}

.metric-sub {
    font-size: 1.2rem;
    color: #94A3B8;
    font-weight: 600;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 99px;
    margin-top: 16px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: #22C55E;
    border-radius: 99px;
    transition: width 0.5s ease-in-out;
}

/* Charts Section */
.charts-container {
    display: grid;
    grid-template-columns: 1fr 2fr; /* Asymmetrical setup: Donut is smaller, Bar chart is wider */
    gap: 20px;
    margin-top: 24px;
    margin-bottom: 24px;
    width: 100%;
}

@media (max-width: 900px) {
    .charts-container {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
}

.chart-title {
    font-size: 1rem;
    font-weight: 800;
    color: #F8FAFC;
    margin-bottom: 16px;
    letter-spacing: 0.05em;
}

.chart-wrapper {
    position: relative;
    height: 300px;
    width: 100%;
    flex-grow: 1;
}

/* Dashboard Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 24px;
    padding-bottom: 24px;
}

.inventory-card {
    background: var(--pill-light);
    border-radius: 20px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: slideIn 0.4s ease forwards;
}

.inventory-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    background: white;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.card-metrics {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.metric-pill {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    border-radius: 99px;
    font-size: 0.85rem;
    font-weight: 700;
}

.metric-pill.delivered {
    background: rgba(34, 197, 94, 0.1);
    color: #166534;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.metric-pill.returns {
    background: rgba(239, 68, 68, 0.1);
    color: #991b1b;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.metric-pill.sales {
    background: rgba(124, 58, 237, 0.1);
    color: #5b21b6;
    border: 1px solid rgba(124, 58, 237, 0.2);
}

.metric-value {
    font-family: monospace;
    font-size: 1rem;
    font-weight: 800;
}

/* Sticky Header Wrapper */
.sticky-header-wrapper {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: white;
    padding-bottom: 20px;
}

/* Dashboard Search Bar & Historical Date Picker */
.dashboard-search-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    box-sizing: border-box;
    gap: 20px;
    background: transparent;
    padding: 12px 16px;
    border-radius: 16px;
    border: none !important;
    box-shadow: none !important;
}

#dashboard-store-search {
    min-width: 250px;
    max-width: 280px;
}

#dashboard-date-picker {
    min-width: 150px;
    max-width: 220px;
}

.date-is-today {
    border-color: #1E3A8A !important;
    color: #1E3A8A !important;
    background: rgba(30, 58, 138, 0.05) !important;
}

.date-is-today::-webkit-calendar-picker-indicator {
    /* CSS filter trick to turn the native calendar SVG icon Deep Royal Blue */
    filter: invert(18%) sepia(45%) saturate(3015%) hue-rotate(200deg) brightness(96%) contrast(97%) !important;
    opacity: 1;
}

.dashboard-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

.toolbar-pill {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: #E2E8F0;
    padding: 12px 18px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toolbar-pill:hover {
    transform: translateY(-1px);
    border-color: rgba(167, 139, 250, 0.35);
    background: rgba(167, 139, 250, 0.08);
}

.toolbar-pill.active {
    background: rgba(124, 58, 237, 0.95);
    border-color: rgba(124, 58, 237, 0.8);
    color: white;
    box-shadow: 0 10px 24px rgba(124, 58, 237, 0.18);
}

.pill-search-input {
    flex-shrink: 0;
    width: auto;
    background: var(--pill-light);
    border: 2px solid transparent;
    border-radius: 99px;
    padding: 8px 12px;
    height: 45px;
    color: var(--text-dark);
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.dashboard-date-picker {
    cursor: pointer;
}

.pill-search-input:hover {
    border-color: rgba(124, 58, 237, 0.4);
}

.dashboard-date-picker::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 1; /* Fully visible */
    transform: scale(1.2); /* Make the icon larger */
    filter: invert(18%) sepia(45%) saturate(3015%) hue-rotate(200deg) brightness(96%) contrast(97%); /* Blue icon */
    transition: all 0.2s ease;
}

.dashboard-date-picker::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
    transform: scale(1.35);
}

.pill-search-input:focus {
    outline: none;
    background: white;
    border-color: var(--primary-purple);
    box-shadow: 0 10px 15px -3px rgba(124, 58, 237, 0.1);
}

.health-card {
    background: white;
    border: 2px solid var(--primary-purple);
    border-style: dashed;
}

.health-label {
    font-size: 0.75rem;
    font-weight: 800;
    color: #94A3B8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.health-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--primary-purple);
}

.health-status {
    font-size: 0.85rem;
    font-weight: 700;
    margin-top: 8px;
}

.warning-red {
    color: #ef4444 !important;
}

.item-qty {
    font-weight: 800;
    color: #7C3AED;
    margin-right: 4px;
}

@media (max-width: 600px) {
    .delivery-table {
        font-size: 0.8rem;
    }
    .delivery-table th, .delivery-table td {
        padding: 12px 8px;
    }
}

/* Route Health Warning Banner */
.route-health-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: linear-gradient(to right, #78350f, #92400e);
    border: 1px solid rgba(251, 191, 36, 0.3);
    padding: 14px;
    border-radius: 16px;
    margin-bottom: 24px;
    color: #fcd34d;
    font-weight: 700;
    font-size: 0.95rem;
    animation: pulseGlow 3s infinite ease-in-out;
}

.route-health-banner svg {
    flex-shrink: 0;
}

@keyframes pulseGlow {
    0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.2); }
    50% { box-shadow: 0 0 20px 0 rgba(251, 191, 36, 0.4); }
    100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.2); }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    border-left: 4px solid var(--primary-purple);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    font-weight: 700;
    font-size: 0.9rem;
    animation: toastIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    pointer-events: auto;
    min-width: 280px;
    text-align: center;
}

.toast.success { border-left-color: #22c55e; }
.toast.error { border-left-color: #ef4444; }
.toast.warning { border-left-color: #f59e0b; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast.fade-out {
    animation: toastOut 0.3s ease forwards;
}

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

/* Glassmorphism Modal */
.glass-modal {
    background: rgba(15, 23, 42, 0.7) !important;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#manager-passcode:focus {
    border-color: var(--primary-purple) !important;
    background: rgba(255, 255, 255, 0.1) !important;
}

/* Professional Triple-Stack Ledger */
.triple-stack {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0;
    text-align: center;
    min-width: 40px;
}

.stack-delivered {
    color: #006400;
    font-weight: bold;
    font-size: 0.9rem;
}

.stack-returns {
    color: #8b0000;
    font-size: 0.9rem;
    font-weight: normal;
    opacity: 0.9;
}

.separator {
    margin: 0 1px;
    color: black;
    font-weight: bold;
}

.stack-total {
    color: black;
    font-weight: bold;
    font-size: 0.9rem;
    border-top: none;
    margin-top: 2px;
    padding-top: 0;
    letter-spacing: normal;
}

.dimmed {
    opacity: 0.5 !important;
}

.ledger-table {
    min-width: 100%;
    width: max-content;
    border-collapse: collapse;
    border-spacing: 0;
    border-radius: 0;
    overflow: hidden;
}

.ledger-table th, .ledger-table td {
    padding: 7px 2px;
    border: 1px solid #ddd;
    text-align: center;
    vertical-align: middle;
    min-width: 45px;
}

.ledger-table th {
    background: #f8f9fa;
    color: black;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: none;
    letter-spacing: normal;
    border-bottom: 1px solid #ddd;
}

/* Adds a dotted line and a 'help' cursor to headers with a custom tooltip */
.ledger-table th[data-tooltip] {
    position: relative;
    cursor: help;
    text-decoration: underline dotted #94A3B8;
    text-underline-offset: 4px;
}

/* Custom tooltip text box */
.ledger-table th[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 100%; /* Positions it below the header to prevent clipping */
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    padding: 6px 10px;
    background-color: #000000;
    color: #FFFFFF;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

/* Little triangle pointer */
.ledger-table th[data-tooltip]::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: transparent transparent #000000 transparent;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 1000;
}

/* Show on hover */
.ledger-table th[data-tooltip]:hover::after,
.ledger-table th[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
}

.ledger-row:nth-child(odd) {
    background: white;
    color: black;
}

.ledger-row:nth-child(even) {
    background: #f9f9f9;
    color: black;
}

.ledger-row:hover {
    background: #f1f5f9;
}

.ledger-row:hover .store-name-cell {
    background: #f1f5f9 !important;
}

/* Sticky Column 1: Store Name (Left) */
.store-name-cell {
    position: sticky;
    left: 0;
    z-index: 15;
    background: inherit !important; 
    min-width: 140px;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
    padding-left: 6px;
    border-right: 1px solid #ddd;
    color: black !important;
}


/* Ensure Headers are even stickier */
#ledger-head th {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #f8f9fa;
}

#ledger-head th.store-name-cell {
    z-index: 25; /* Highest priority */
}

.ledger-container {
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 72vh;
    margin-top: 30px;
    border-radius: 0;
    border: 1px solid #ddd;
    background: white;
}

.ledger-table td {
    text-align: center;
    vertical-align: middle;
}

/* Sticky Bottom: DAILY TOTALS */
.totals-row td {
    position: sticky;
    bottom: 0;
    z-index: 15;
    background: #e0e0e0 !important;
    border-top: 1px solid #ddd;
    font-weight: bold;
}

.totals-sticky-cell {
    z-index: 30 !important; /* Stay above side sticky and bottom sticky */
}

/* Specific label color for the Grand Totals row to stand out */
.totals-row .stack-delivered { color: #006400; } /* Dark Green */
.totals-row .stack-returns { color: #8b0000; } /* Dark Red */

.summary-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start !important;
    text-align: left !important;
    padding-left: 4px;
    min-width: 110px;
    gap: 2px;
}

.stack-label {
    display: inline-block;
    width: 32px;
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: normal;
    opacity: 1;
    color: black;
    margin-right: 4px;
}

.balance-line {
    border-top: 1px solid #ddd !important;
    color: black !important;
    text-shadow: none;
}

/* ==========================================================================
   MANAGER DASHBOARD - WHITE THEME OVERRIDES
   ========================================================================== */

body.theme-white {
    background-color: #FFFFFF;
}

#manager-dashboard.master-route-container.dashboard-container {
    background: #FFFFFF !important;
    border: none;
    box-shadow: none;
    border-radius: 8px;
    color: #0F172A;
}

#manager-dashboard .header {
    background: #FFFFFF;
}

#manager-dashboard .screen-title {
    color: #334155;
}

#manager-dashboard .logo-small {
    background: none;
    -webkit-text-fill-color: #334155;
    color: #334155;
}

#manager-dashboard .dashboard-logo-icon {
    stroke: #334155;
}

/* Top Metrics Cards */
#manager-dashboard .metric-card {
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    padding: 32px;
}

#manager-dashboard .metric-title {
    color: #475569;
}

#manager-dashboard .metric-value {
    color: #1E3A8A !important;
    text-shadow: none;
    font-size: 1.8rem;
    font-weight: 700;
}

/* Return Rate % and Return Value to Maroon/Brown */
#manager-dashboard .metric-card:nth-child(3) .metric-value,
#manager-dashboard .metric-card:nth-child(4) .metric-value {
    color: #7C2D12 !important;
}

#manager-dashboard .metric-sub {
    color: #64748B;
}

/* Charts & Sections */
#manager-dashboard .chart-card {
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    box-shadow: none;
    padding: 0;
}

#manager-dashboard .chart-title {
    color: #FFFFFF;
    background: #1E3A8A;
    margin: 0;
    padding: 16px 24px;
    border-radius: 8px 8px 0 0;
}

#manager-dashboard .chart-wrapper {
    padding: 24px;
}

/* Buttons */
#manager-dashboard .btn-filter,
#manager-dashboard .toolbar-pill,
#manager-dashboard .btn-logout-icon,
#manager-dashboard .btn-login {
    background: #1E3A8A;
    color: #FFFFFF;
    border: 1px solid #1E3A8A;
    border-radius: 8px;
}

#manager-dashboard .btn-filter:hover,
#manager-dashboard .toolbar-pill:hover,
#manager-dashboard .btn-logout-icon:hover {
    background: #2563EB; /* Lightens up slightly on hover */
    border-color: #2563EB;
}

#manager-dashboard .btn-filter.active,
#manager-dashboard .toolbar-pill.active {
    background: #EFF6FF; /* Very Light Blue / Bright White */
    color: #1E3A8A; /* Deep Royal Blue text */
    border-color: #1E3A8A;
    box-shadow: 0 4px 10px rgba(30, 58, 138, 0.2); /* Subtle pressed shadow */
}

/* Search & Date Picker */
#manager-dashboard .dashboard-search-container {
    background: transparent;
    border: none !important;
    border-radius: 8px;
    box-shadow: none !important;
}

#manager-dashboard .pill-search-input {
    background: #FFFFFF;
    border: 1px solid #CBD5E1;
    color: #0F172A;
    border-radius: 8px;
    box-shadow: none;
}

#manager-dashboard .pill-search-input:focus {
    border-color: #1E3A8A;
}

/* Ledger Table */
#manager-dashboard .ledger-container {
    border: 1px solid #E2E8F0;
    border-radius: 8px;
}

#manager-dashboard .ledger-table {
    background: #FFFFFF;
    color: #0F172A;
}

#manager-dashboard .ledger-table th {
    background: #f8f9fa;
    color: #0F172A;
    border-bottom: 2px solid #CBD5E1;
}

#manager-dashboard .ledger-row:nth-child(odd),
#manager-dashboard .ledger-row:nth-child(even) {
    background: #FFFFFF;
    color: #0F172A;
}

#manager-dashboard .ledger-row:hover {
    background: #F1F5F9;
}

/* Z-Index and Solid Background for Sticky columns */
#manager-dashboard .store-name-cell {
    background: #FFFFFF !important;
    color: #0F172A !important;
    z-index: 25 !important;
}

#manager-dashboard .ledger-row:hover .store-name-cell {
    background: #F1F5F9 !important;
}

#manager-dashboard #ledger-head th.store-name-cell {
    z-index: 30 !important;
    background: #f8f9fa !important;
}

/* Footer Totals (Grand Totals Bar) */
#manager-dashboard .totals-row td {
    background: #1E3A8A !important;
    color: #FFFFFF !important;
    border-top: 2px solid #1E3A8A;
}

#manager-dashboard .totals-row .store-name-cell {
    background: #1E3A8A !important;
    color: #FFFFFF !important;
}

#manager-dashboard .totals-row .stack-delivered,
#manager-dashboard .totals-row .stack-returns,
#manager-dashboard .totals-row .separator {
    color: #FFFFFF !important;
    font-weight: 700;
}

#manager-dashboard .dashboard-footer-summary {
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    box-shadow: none;
}

#manager-dashboard .summary-label {
    color: #475569;
}

#manager-dashboard .summary-value,
#manager-dashboard .summary-value.highlight,
#manager-dashboard .summary-value.credit-red {
    color: #0F172A;
}
