:root {
    --primary: #2563eb;
    --primary-soft: #eff6ff;
    --bg-body: #f1f5f9;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-light: #e2e8f0;
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
}

.container {
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 4.5rem 1.5rem 4.5rem;
    transition: all 0.3s ease;
}

/* Fullscreen handling */
:fullscreen .container,
:-webkit-full-screen .container,
:-moz-full-screen .container,
:-ms-fullscreen .container,
.is-fullscreen {
    max-width: 100% !important;
    width: 100% !important;
    min-height: 100vh;
    padding: 2rem;
    background-color: var(--bg-body);
}

body:fullscreen {
    background-color: var(--bg-body);
}

/* Header */
.dashboard-header { margin-bottom: 2rem; }
/* Header */
.dashboard-header { margin-bottom: 2rem; }
.header-content { 
    display: grid; 
    grid-template-columns: 1fr auto 1fr; /* Logo - Clock - Actions */
    align-items: center; 
}

.logo { display: flex; align-items: center; gap: 0.5rem; }
.logo i { font-size: 1.5rem; color: var(--primary); background: white; padding: 0.4rem; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.logo h1 { font-family: 'Outfit', sans-serif; font-size: 1.5rem; font-weight: 800; color: var(--text-main); letter-spacing: -0.025em; line-height: 1; }





/* Centered Global Loading Overlay */
.fetching-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: overlayFadeIn 0.3s ease;
}

.overlay-content {
    background: white;
    padding: 1.5rem 2.5rem;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--border-light);
}

.overlay-content i {
    font-size: 2rem;
    color: var(--primary);
}

.overlay-content span {
    font-weight: 700;
    color: var(--text-main);
    font-size: 1rem;
    font-family: 'Outfit', sans-serif;
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

#clock-time {
    font-size: clamp(2rem, 6vw, 3rem);
    font-weight: 800;
    line-height: 1;
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    letter-spacing: 0.05em;
}

#clock-date {
    font-size: clamp(0.75rem, 1.2vw, 1.125rem);
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 0.25rem;
}

.header-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
}

/* Icons */
.btn-icon {
    background: white;
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn-icon:hover {
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.1);
}

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

/* Buttons */

/* Action Bar */
.action-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

/* Table Card */
.glass-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 1.5rem;
    background: #f8fafc; /* Subtle background for table separation */
}

/* Logistics Table Wrapper */
.logistics-table-wrapper {
    background: white;
    border-radius: 10px;
    border: 1px solid var(--border-light);
    overflow: hidden;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.table-header-custom {
    padding: 1rem 1.5rem;
    background: #fff;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: center;
    align-items: center;
}

.header-title-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logistics-logo {
    height: 32px;
    width: auto;
    object-fit: contain;
}

.fallback-icon {
    font-size: 1.5rem;
    color: var(--primary);
}

.table-header-custom h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.table-container {
    overflow-x: auto;
    position: relative;
}

table {
    width: 100%;
    border-collapse: collapse;
    /* Fluid typography: small on mobile, grows significantly on large screens */
    font-size: clamp(0.8125rem, 1.8vw, 2.75rem);
    table-layout: auto;
}

/* Nested Headers */
th {
    padding: 0.75rem 0.5rem;
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    border: 1px solid var(--border-light);
}

.group-header {
    background: #f1f5f9;
    color: var(--text-main);
    font-size: clamp(1rem, 1.5vw, 2.25rem);
    padding: 0.5rem;
}

.sub-header {
    font-size: 1rem;
    background: #f8fafc;
}

/* Fixed Column */
.sticky-col {
    position: sticky;
    left: 0;
    background: white;
    z-index: 10;
    width: auto;
    min-width: clamp(100px, 15vw, 200px);
    border-right: 2px solid var(--border-light);
}

tr:hover .sticky-col { background: #fdfdfd; }

/* Total Row Styling */
.total-row {
    background-color: #ecfdf5; /* Light green/mint for total */
    border-bottom: 2px solid var(--border-light);
}

.total-row td, .total-row th {
    /* color: #047857 !important; Darker green text */
    font-weight: 800;
    padding: 1rem 0.5rem;
    font-size: 1rem;
    background: #f8fafc;
    color: var(--text-muted);
}

.total-row .sticky-col {
    background-color: #ecfdf5; /* Sticky column needs bg match */
    color: #047857;
}

.green-col {
    background-color: #ecfdf5; /* Sticky column needs bg match */
    color: #047857;
}

/* Cell Content */
td {
    padding: 0.5rem;
    border: 1px solid var(--border-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Zebra Striping */
tbody tr:nth-child(even) {
    background-color: #f8fafc;
}

tbody tr:nth-child(even) .sticky-col {
    background-color: #f8fafc;
}

.store-name { display: block; font-weight: 700; color: var(--text-main); }
.store-id-sub { font-size: 0.65rem; color: var(--text-muted); }

.count-active {
    font-weight: 700;
    color: var(--text-main);
}

.font-bold { font-weight: 800; color: var(--text-main); }

/* Buttons */
.btn {
    padding: 0.4rem 1rem;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

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

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-error { color: #ef4444; }

.dashboard-footer { padding: 2rem; text-align: center; color: var(--text-muted); font-size: 0.75rem; }

/* Warehouse Badge */
.warehouse-badge {
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border: 1px solid var(--border-light);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.warehouse-badge i {
    color: var(--primary);
    font-size: 0.9rem;
}

/* Responsive Styles */
@media (max-width: 1024px) {
    .header-content {
        grid-template-columns: 1fr auto;
        gap: 1.5rem;
    }
    .center-clock {
        grid-column: 1 / span 2;
        order: 3;
        margin-top: 1rem;
    }
    
    .container {
        padding: clamp(1rem, 3vw, 1.5rem);
    }
}

@media (max-width: 768px) {
    .container { 
        padding: 0.75rem; 
    }

    /* Header Stack */
    .dashboard-header { margin-bottom: 1.5rem; }
    .header-content { 
        display: flex;
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .logo { 
        justify-content: center; 
        width: 100%;
    }
    
    .header-actions {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Clock adjustments */
    .center-clock {
        margin-top: 0;
        width: 100%;
    }
    
    /* Action Bar */
    .action-bar {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.5rem !important;
        margin-bottom: 1rem;
    }

    .action-bar > div {
        justify-content: center;
        width: 100%;
        text-align: center;
    }
    
    #refresh-btn {
        width: 100%;
    }

    /* Tables */
    .logistics-table-wrapper {
        border-radius: 8px;
        margin-bottom: 1rem;
    }

    .table-header-custom {
        padding: 0.5rem;
        flex-direction: column;
        gap: 0.25rem;
        text-align: center;
    }

    th, td {
        padding: clamp(0.25rem, 1vw, 0.5rem);
    }

    .warehouse-badge {
        flex-grow: 1;
        justify-content: center;
        padding: 0.4rem 0.75rem;
    }
}

@media (max-width: 480px) {
    .logo h1 { font-size: 1.1rem; }
    
    .btn-icon {
        width: 34px;
        height: 34px;
        border-radius: 8px;
    }
    
    .warehouse-badge {
        font-size: 0.75rem;
    }
}
