:root {
  --primary: #E23744;
  --bg-color: #FFF5F6;
  --text-dark: #333333;
  --text-light: #777777;
  --white: #FFFFFF;
  --border: #f0f0f0;
  --shadow: 0 4px 12px rgba(226, 55, 68, 0.1);
  --success: #10B981;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
body { background: var(--bg-color); color: var(--text-dark); min-height: 100vh; overflow-x: hidden; }

/* Router and Pages */
.page { display: none; min-height: 100vh; width: 100%; padding-bottom: 120px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.page.active { display: block; animation: fadeIn 0.3s ease-in-out; }

/* Custom Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop { 0% { transform: scale(0.9); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }

/* Headers */
header { background: var(--white); box-shadow: 0 2px 8px rgba(0,0,0,0.05); padding: calc(env(safe-area-inset-top, 25px) + 15px) 20px 15px 20px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; }
header h1, header h2 { color: var(--primary); font-size: 1.25rem; flex: 1; text-align: center; }
.back-btn { background: none; border: none; font-size: 1.5rem; color: var(--primary); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 5px; width: 40px; }
body.is-native-apk .back-btn, body.is-native-apk .web-only-feature { display: none !important; }
.menu-btn { background: none; border: none; color: var(--primary); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 5px; width: 40px; }
.header-actions { display: flex; gap: 8px; width: auto; align-items: center; justify-content: flex-end; }

/* Splash Screen */
#splashPage.active { display: flex; position: fixed; inset: 0; background: var(--primary); flex-direction: column; align-items: center; justify-content: center; z-index: 999; color: var(--white); }
#splashPage h1 { font-size: 2.2rem; margin-top: 20px; text-shadow: 1px 1px 4px rgba(0,0,0,0.2); animation: pop 0.5s ease-out; color: white; }
#splashPage img { width: 150px; border-radius: 50%; box-shadow: 0 4px 15px rgba(0,0,0,0.2); animation: pop 0.5s ease-out; background: white; padding: 10px; }

/* Buttons */
.btn { background: var(--primary); color: var(--white); border: none; padding: 12px 20px; border-radius: 8px; font-size: 1rem; font-weight: bold; width: 100%; cursor: pointer; transition: transform 0.1s; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn:active { transform: scale(0.96); }
.btn-secondary { background: var(--white); color: var(--text-dark); border: 1px solid #ddd; }
.btn-small { padding: 8px 12px; font-size: 0.9rem; width: auto; }
.btn-danger { background: var(--white); color: var(--primary); border: 1px solid var(--primary); }
.btn-edit { background: var(--white); color: #2563eb; border: 1px solid #2563eb; }
.btn-stop-milk { background: var(--white); color: #ea580c; border: 1px solid #ea580c; }
.btn-start-milk { background: var(--white); color: var(--success); border: 1px solid var(--success); }

/* Forms */
.form-container { padding: 20px; }
.form-group { margin-bottom: 20px; }
label { display: block; font-size: 0.9rem; color: var(--text-light); margin-bottom: 8px; font-weight: 600; }
input, select { width: 100%; padding: 14px; border: 1px solid #ccc; border-radius: 8px; font-size: 1rem; outline: none; transition: border 0.3s; background: var(--white); }
input:focus, select:focus { border: 1px solid var(--primary); box-shadow: 0 0 0 2px rgba(226, 55, 68, 0.1); }
.hint { font-size: 0.8rem; color: var(--text-light); margin-top: 5px; }

/* Home Grid layout */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; padding: 20px; }
.home-btn { aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; font-size: 1.1rem; border-radius: 16px; background: var(--white); color: var(--text-dark); border: none; box-shadow: var(--shadow); cursor: pointer; transition: transform 0.1s; font-weight: 600; text-align: center; }
.home-btn:active { transform: scale(0.95); background: var(--primary); color: var(--white); }
.home-btn:active svg { stroke: var(--white); }
.home-btn svg { width: 44px; height: 44px; stroke: var(--primary); stroke-width: 1.5; fill: none; }

/* Cards */
.card-list { padding: 15px; display: flex; flex-direction: column; gap: 15px; }
.card { background: var(--white); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); border-left: 4px solid var(--primary); display: flex; flex-direction: column; gap: 10px; }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.card-title { font-size: 1.2rem; font-weight: bold; color: var(--text-dark); margin-bottom: 4px; }
.card-subtitle { font-size: 0.9rem; color: var(--text-light); }
.card-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; }

.badge { background: #fee2e2; color: var(--primary); padding: 4px 8px; border-radius: 4px; font-size: 0.8rem; font-weight: bold; }


/* List rows for billing/daily */
.list-item { display: flex; justify-content: space-between; align-items: center; padding: 15px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.amount-text { color: var(--primary); font-weight: bold; font-size: 1.2rem; }
.absent-text { color: var(--primary); font-weight: bold; background: #fee2e2; padding: 4px 8px; border-radius: 4px; font-size: 0.85rem;}
.present-text { color: var(--success); font-weight: bold; background: #d1fae5; padding: 4px 8px; border-radius: 4px; font-size: 0.85rem;}

/* Modal Overlay */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.active { display: flex; animation: fadeIn 0.2s; }
.modal-content { background: var(--white); width: 100%; max-width: 400px; border-radius: 12px; padding: 20px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); }
.modal-title { font-size: 1.25rem; font-weight: bold; margin-bottom: 15px; color: var(--primary); }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }

/* Toast Notification */
.toast { position: fixed; bottom: calc(env(safe-area-inset-bottom, 0px) + 40px); top: auto; left: 50%; transform: translate(-50%, 20px); background: #222; color: var(--white); padding: 14px 24px; border-radius: 16px; font-size: 0.95rem; font-weight: 600; z-index: 100010; opacity: 0; transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease; pointer-events: none; box-shadow: 0 10px 25px -5px rgba(0,0,0,0.25); max-width: 90%; text-align: center; word-wrap: break-word; display: flex; align-items: center; justify-content: center; gap: 8px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-success { background: #10B981 !important; color: #ffffff !important; border-left: 4px solid #047857; }
.toast-error { background: #EF4444 !important; color: #ffffff !important; border-left: 4px solid #B91C1C; }
.toast-info { background: #3B82F6 !important; color: #ffffff !important; border-left: 4px solid #1D4ED8; }

.empty-state { padding: 40px 20px; text-align: center; color: var(--text-light); }
.empty-state svg { width: 64px; height: 64px; stroke: #ccc; fill: none; margin: 0 auto 15px; }

/* Dashboard specific */
.dash-stat { background: var(--primary); color: var(--white); padding: 20px; border-radius: 12px; margin: 20px; text-align: center; box-shadow: var(--shadow); }
.dash-stat h3 { font-size: 2rem; font-weight: 900; }
.dash-stat p { font-size: 0.9rem; opacity: 0.9; }

/* Flex utilities */
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.mt-4 { margin-top: 16px; }

/* Checklist Styles */
.checklist-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    background: white;
    border-radius: 12px;
    margin-bottom: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border-left: 4px solid var(--text-light);
}
.checklist-item.present { border-left-color: var(--success); }
.checklist-item.absent { border-left-color: var(--primary); }
.checklist-item.auto { background: #fffdfd; border-left-style: dashed; }

.checklist-info { flex: 1; }
.checklist-name { font-weight: 600; color: var(--text-dark); margin-bottom: 2px; }
.checklist-subtitle { font-size: 0.75rem; color: var(--text-light); }

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

.action-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: 0.2s;
}
.btn-tick { background: #f0fdf4; color: var(--success); }
.btn-tick:active { background: #dcfce7; }
.btn-cross { background: #fff1f2; color: var(--primary); }
.btn-cross:active { background: #fee2e2; }
.btn-auto { background: #fff1f2; color: var(--primary); font-size: 0.65rem; font-weight: 800; border: 1px solid #fee2e2; }
.btn-auto.active { background: var(--primary); color: white; border-color: var(--primary); }

.adj-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ddd;
    background: #f8f8f8;
    color: var(--text-dark);
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}
.adj-btn:active { background: #eee; transform: scale(0.9); }
.adj-plus { color: var(--success); }
.adj-minus { color: var(--primary); }

.qty-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    margin-left: 5px;
}
.qty-extra { background: #fee2e2; color: var(--primary); }
.qty-less { background: #ffedd5; color: #9a3412; }
.qty-exact { background: #f0fdf4; color: var(--success); }

.status-badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}
.status-present { background: #d1fae5; color: #065f46; }
.status-absent { background: #fee2e2; color: #991b1b; }
.stat-card { border-left-width: 4px; padding: 12px 15px; }

/* Swipe to Remove */
.checklist-wrapper {
    position: relative;
    margin-bottom: 10px;
    overflow: hidden;
    border-radius: 12px;
    background-color: #ef4444;
}
.swipe-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 20px;
    font-weight: bold;
    z-index: 0;
}
.checklist-wrapper .checklist-item {
    margin-bottom: 0;
    position: relative;
    z-index: 1;
    transition: transform 0.2s ease;
}
.checklist-item.swiping {
    transition: none;
}

/* Form Validation */
.input-error {
    border-color: #ef4444 !important;
    background-color: #fef2f2 !important;
}

.error-shake {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Custom Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.modal-overlay.show {
    display: flex;
    opacity: 1;
}
.modal-content {
    background: white;
    padding: 25px;
    border-radius: 16px;
    width: 85%;
    max-width: 350px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    transform: translateY(-150px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}
.modal-overlay.show .modal-content {
    transform: translateY(0);
    opacity: 1;
}

/* Modern Spinner */
.spinner-container {
    display: flex;
    justify-content: center;
    align-items: center;
}
.modern-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: spin 1s cubic-bezier(0.5, 0.1, 0.4, 0.9) infinite;
}

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

.list-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    color: #333;
}

.absent-text {
    color: #E23744;
    font-weight: bold;
}

.bill-table th, .bill-table td { border: 1px solid #000; padding: 6px; }
.absent-row { background: #fee2e2 !important; }
.highlight-blue { background: #e0f2fe !important; } /* Subtle blue for deviations */

#billPrintArea {
    background: #fff;
    padding: 20px;
    border: 1px solid #000;
    color: #000;
    font-family: 'Segoe UI', Arial, sans-serif;
    border-radius: 8px;
}

@media (max-width: 480px) {
    #billPreviewModal .modal-content {
        padding: 15px 8px 10px 8px !important;
        width: 98% !important;
        max-height: 95vh !important;
    }
    #billPrintArea {
        padding: 10px !important;
    }
    .bill-table {
        font-size: 0.72rem !important;
    }
    .bill-table th, .bill-table td {
        padding: 4px 2px !important;
    }
    #billPrintArea h1 {
        font-size: 1.1rem !important;
    }
    #billPrintArea h2 {
        font-size: 1.1rem !important;
    }
    #billPrintArea p {
        font-size: 0.75rem !important;
    }
}



@media print {
    body * { visibility: hidden; background: #fff !important; }
    #billPrintArea, #billPrintArea * { visibility: visible; }
    #billPrintArea {
        position: fixed;
        left: 50%;
        top: 30px;
        transform: translateX(-50%);
        width: 480px;
        max-width: 95%;
        margin: 0 auto;
        padding: 20px;
        border: 2px solid #000 !important;
        border-radius: 12px;
        box-shadow: none !important;
    }
}

.loader-overlay-fixed {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.96);
    z-index: 9999999 !important;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.loader-overlay-fixed .modern-spinner {
    border: 4px solid rgba(226, 55, 68, 0.15);
    border-top-color: var(--primary);
}
.loader-overlay-fixed.active {
    display: flex;
}

/* Sidebar Drawer */
.sidebar-overlay { 
    position: fixed; 
    inset: 0; 
    background: rgba(15, 23, 42, 0.4); 
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2000; 
    display: none; 
    opacity: 0; 
    transition: opacity 0.3s ease; 
}
.sidebar-overlay.active { display: block; opacity: 1; }

.sidebar { 
    position: fixed; 
    top: 0; 
    left: -290px; 
    width: 290px; 
    height: 100vh; 
    background: var(--white); 
    z-index: 2100; 
    transition: left 0.35s cubic-bezier(0.16, 1, 0.3, 1); 
    box-shadow: 15px 0 35px rgba(0, 0, 0, 0.08); 
    display: flex; 
    flex-direction: column; 
    border-radius: 0 24px 24px 0;
    overflow: hidden;
}
.sidebar.active { left: 0; }

.sidebar-header { 
    padding: 50px 24px 24px 24px; 
    background: linear-gradient(135deg, #e23744 0%, #f43f5e 100%); 
    color: white; 
    display: flex; 
    flex-direction: column; 
    gap: 12px; 
    border-radius: 0 0 24px 24px;
    box-shadow: 0 8px 20px rgba(226, 55, 68, 0.15);
    margin-bottom: 12px;
}
.sidebar-header .cow-icon { 
    font-size: 2.2rem; 
    width: 54px;
    height: 54px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
}
.sidebar-header h2 { 
    color: white; 
    font-size: 1.3rem; 
    font-weight: 800; 
    letter-spacing: -0.5px;
    margin: 0;
}

.sidebar-menu { 
    padding: 10px 0; 
    flex: 1; 
    overflow-y: auto; 
}

.sidebar-item { 
    display: flex; 
    align-items: center; 
    gap: 14px; 
    margin: 4px 14px;
    padding: 12px 16px; 
    color: #475569; 
    text-decoration: none; 
    font-weight: 600; 
    font-size: 0.95rem;
    cursor: pointer; 
    border-radius: 12px;
    transition: all 0.2s ease; 
}
.sidebar-item:active, .sidebar-item:hover { 
    background: #fff1f2; 
    color: #e23744; 
    transform: translateX(4px);
}
.sidebar-item svg { 
    width: 20px; 
    height: 20px; 
    stroke: currentColor; 
    stroke-width: 2; 
    fill: none; 
    opacity: 0.85; 
    transition: transform 0.2s ease;
}
.sidebar-item:active svg, .sidebar-item:hover svg {
    transform: scale(1.08);
}

.sidebar-item.logout-btn {
    background: #fef2f2;
    color: #e23744 !important;
    border: 1.5px dashed #fca5a5;
    margin-top: 15px;
    font-weight: 700;
}
.sidebar-item.logout-btn:active, .sidebar-item.logout-btn:hover {
    background: #ffe4e6;
    border-color: #f43f5e;
}
.sidebar-item.logout-btn svg {
    color: #e23744 !important;
}

.sidebar-footer { 
    padding: 20px; 
    border-top: 1px solid #f1f5f9; 
    font-size: 0.72rem; 
    color: #94a3b8; 
    text-align: center; 
    line-height: 1.4;
}

/* App Guide / Onboarding Tour */
.tour-highlight {
    position: relative !important;
    z-index: 10001 !important;
    pointer-events: auto !important;
    box-shadow: 0 0 0 4px var(--primary), 0 8px 30px rgba(0, 0, 0, 0.3) !important;
    background: var(--white) !important;
    transform: scale(1.04) !important;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

@keyframes bounceUpDown {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}
.animate-tour-bounce {
    animation: bounceUpDown 0.8s infinite ease-in-out;
}

/* PIN Lock keypad styling */
.keypad-btn:active {
    background: #e2e2e2 !important;
    transform: scale(0.92);
}
.pin-dot.filled {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    transform: scale(1.15);
}

/* Premium Authentication Screen Styling */
#appAuthModal {
    background: rgba(255, 245, 246, 0.75) !important;
    backdrop-filter: blur(15px) !important;
    -webkit-backdrop-filter: blur(15px) !important;
}

#appAuthModal .modal-content {
    background: rgba(255, 255, 255, 0.92) !important;
    border: 1px solid rgba(226, 55, 68, 0.15) !important;
    border-left: 5px solid var(--primary) !important;
    border-radius: 24px !important;
    box-shadow: 0 25px 50px -12px rgba(226, 55, 68, 0.15) !important;
    color: var(--text-dark) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    padding: 35px 25px !important;
    transform: scale(0.9) translateY(30px);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
}

#appAuthModal.show .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

#authRegisterForm {
    border-left-color: #2563eb !important;
    box-shadow: 0 25px 50px -12px rgba(37, 99, 235, 0.25) !important;
}

#authForgotForm {
    border-left-color: #ea580c !important;
    box-shadow: 0 25px 50px -12px rgba(234, 88, 12, 0.25) !important;
}

#appAuthModal h3 {
    font-weight: 800;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    font-size: 1.5rem;
    text-shadow: none !important;
}

#appAuthModal p {
    color: var(--text-light) !important;
    font-size: 0.85rem;
    margin-bottom: 25px;
}

#appAuthModal label {
    color: var(--text-light) !important;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

#appAuthModal input, #appAuthModal select {
    background: #ffffff !important;
    border: 2px solid #e2e8f0 !important;
    color: var(--text-dark) !important;
    border-radius: 14px !important;
    padding: 12px 16px !important;
    font-size: 1rem !important;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

#appAuthModal input:focus, #appAuthModal select:focus {
    border-color: #E63946 !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 4px rgba(230, 57, 70, 0.22), 0 8px 20px rgba(230, 57, 70, 0.15) !important;
    transform: translateY(-2px) scale(1.01) !important;
    animation: inputPulse 1.8s infinite alternate ease-in-out;
}

@keyframes inputPulse {
    0% {
        box-shadow: 0 0 0 4px rgba(230, 57, 70, 0.22), 0 4px 15px rgba(230, 57, 70, 0.12);
    }
    100% {
        box-shadow: 0 0 0 6px rgba(230, 57, 70, 0.35), 0 8px 24px rgba(230, 57, 70, 0.22);
    }
}

#authRegisterForm input:focus, #authRegisterForm select:focus {
    border-color: #2563eb !important;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.22), 0 8px 20px rgba(37, 99, 235, 0.15) !important;
}

#authForgotForm input:focus {
    border-color: #ea580c !important;
    box-shadow: 0 0 0 4px rgba(234, 88, 12, 0.22), 0 8px 20px rgba(234, 88, 12, 0.15) !important;
}

#appAuthModal select option {
    background: #ffffff !important;
    color: var(--text-dark) !important;
}

#appAuthModal .btn {
    background: linear-gradient(135deg, var(--primary), #ff5d7c) !important;
    border: none !important;
    border-radius: 12px !important;
    padding: 14px 20px !important;
    font-size: 1rem !important;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 8px 20px rgba(226, 55, 68, 0.3) !important;
    transition: all 0.3s ease !important;
}

#appAuthModal .btn:active {
    transform: scale(0.97) !important;
    box-shadow: 0 4px 10px rgba(226, 55, 68, 0.2) !important;
}

#authRegisterForm .btn {
    background: linear-gradient(135deg, #2563eb, #3b82f6) !important;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.3) !important;
}

#authForgotForm .btn {
    background: linear-gradient(135deg, #ea580c, #f97316) !important;
    box-shadow: 0 8px 20px rgba(234, 88, 12, 0.3) !important;
}

#appAuthModal .btn-secondary {
    background: #ffffff !important;
    color: var(--text-dark) !important;
    border: 1px solid #ddd !important;
    box-shadow: none !important;
}

#appAuthModal .btn-secondary:active {
    background: #f0f0f0 !important;
}

#appAuthModal a {
    transition: all 0.2s ease;
    opacity: 0.85;
}

/* ----------- Premium Light-Themed Modals ----------- */
/* Base modal overlay */
.modal-overlay {
  background: rgba(15, 23, 42, 0.4) !important; /* Soft Slate-900 overlay, clean and light */
  backdrop-filter: blur(6px) !important;
}
/* Base modal content */
.modal-content {
  background: #ffffff !important; /* Pure white card background */
  border: 1px solid #e2e8f0 !important; /* Subtle border */
  border-left: 5px solid var(--modal-accent, var(--primary)) !important;
  border-radius: 24px !important;
  padding: 25px 20px !important;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.15), 0 0 1px 0 rgba(0, 0, 0, 0.1) !important; /* Soft premium shadow */
  backdrop-filter: none !important;
  transform: scale(0.9) translateY(30px);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.16,1,0.3,1), opacity 0.4s ease;
}
.modal-overlay.show .modal-content {
  transform: scale(1) translateY(0);
  opacity: 1;
}
/* Accent colors per modal */
#appAuthModal .modal-content { --modal-accent: var(--primary); }
#loginSettingsModal .modal-content { --modal-accent: var(--primary); }
#dairySettingsModal .modal-content { --modal-accent: var(--primary); }
#customerNoticeModal .modal-content { --modal-accent: var(--primary); }
#customModal .modal-content { --modal-accent: var(--primary); }
#milkBreakdownModal .modal-content { --modal-accent: var(--primary); }
#billPreviewModal .modal-content { --modal-accent: var(--primary); }
#customerComplaintModal .modal-content { --modal-accent: var(--primary); }
#sellerComplaintsModal .modal-content { --modal-accent: var(--primary); }
#sellerProfileModal .modal-content { --modal-accent: var(--primary); }

/* Button styling inside modals */
.modal-content .btn {
  background: linear-gradient(135deg, var(--primary), #ff5d7c) !important;
  border: none !important;
  border-radius: 12px !important;
  padding: 14px 20px !important;
  font-size: 1rem !important;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 8px 20px rgba(226,55,68,0.25) !important;
  transition: all 0.3s ease !important;
  color: #ffffff !important;
}
.modal-content .btn:active {
  transform: scale(0.97) !important;
  box-shadow: 0 4px 10px rgba(226,55,68,0.15) !important;
}
.modal-content .btn-secondary {
  background: #f1f5f9 !important; /* Soft grey background */
  color: #334155 !important; /* Dark text */
  border: 1px solid #cbd5e1 !important; /* Slate-300 border */
  box-shadow: none !important;
}
.modal-content .btn-secondary:active {
  background: #cbd5e1 !important;
}
/* Title and text inside modals */
.modal-content h3 {
  color: var(--primary);
  font-weight: 800;
  margin-bottom: 15px;
  font-size: 1.5rem;
}
.modal-content p {
  color: #4b5563 !important; /* Slate-600 for high readability */
  font-size: 0.85rem !important;
  margin-bottom: 20px;
}
/* Ensure inputs, select lists, and textareas inside any modal adopt proper light styles */
.modal-content input,
.modal-content select,
.modal-content textarea {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important; /* Slate-300 border */
  color: #1e293b !important; /* Dark text */
  border-radius: 12px !important;
  padding: 12px 16px !important;
  font-size: 1rem !important;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1) !important;
}
.modal-content input::placeholder,
.modal-content textarea::placeholder {
  color: #94a3b8 !important;
}
.modal-content input:focus,
.modal-content select:focus,
.modal-content textarea:focus {
  border-color: var(--modal-accent) !important;
  background: #ffffff !important;
  box-shadow: 0 0 0 3px rgba(226,55,68,0.15) !important;
}
/* Close button for modals */
.modal-content .modal-close {
  position: absolute !important;
  top: 15px !important;
  right: 15px !important;
  background: none !important;
  border: none !important;
  font-size: 1.8rem !important;
  color: #64748b !important; /* Slate-500 */
  cursor: pointer !important;
  padding: 5px !important;
  line-height: 1 !important;
  z-index: 10 !important;
  transition: color 0.2s !important;
}
.modal-content .modal-close:hover {
  color: #334155 !important;
}

#appAuthModal a:hover {
    opacity: 1;
    text-shadow: 0 0 8px currentColor;
    transform: translateY(-1px);
}

#appAuthModal {
    background: #E63946 !important;
    backdrop-filter: none !important;
}

/* Explicit layout and styles for Bottom Navigation Bars (offline fallback) */
#adminBottomNav, #userBottomNav {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background-color: #ffffff !important;
    border-top: 1px solid #e2e8f0 !important;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.05) !important;
    z-index: 9999 !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    height: calc(60px + env(safe-area-inset-bottom, 0px)) !important;
    box-sizing: border-box !important;
    align-items: center !important;
    justify-content: space-around !important;
}

#adminBottomNav button, #userBottomNav button {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    padding: 6px 12px !important;
    height: 100% !important;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
}

#adminBottomNav button span, #userBottomNav button span {
    font-size: 10px !important;
    font-weight: 700 !important;
    margin-top: 2px !important;
    font-family: inherit !important;
}

#adminBottomNav button.text-gray-400, #userBottomNav button.text-gray-400 {
    color: #94a3b8 !important;
}
#adminBottomNav button.text-gray-400 svg, #userBottomNav button.text-gray-400 svg {
    stroke: #94a3b8 !important;
}

#adminBottomNav button.text-\[\#E63946\], #userBottomNav button.text-\[\#E63946\] {
    color: #E63946 !important;
}
#adminBottomNav button.text-\[\#E63946\] svg, #userBottomNav button.text-\[\#E63946\] svg {
    stroke: #E63946 !important;
}

#adminBottomNav svg, #userBottomNav svg {
    width: 20px !important;
    height: 20px !important;
}

/* Animated "Become a Seller" Pill Badge & Logo Animations */
.become-seller-animated-btn {
    background: linear-gradient(135deg, #fff0f2 0%, #ffe4e6 100%) !important;
    color: #E63946 !important;
    font-weight: 800 !important;
    font-size: 0.72rem !important;
    padding: 4px 10px !important;
    border-radius: 20px !important;
    border: 1.5px solid #fca5a5 !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    animation: pulseGlow 2.5s infinite ease-in-out !important;
    box-shadow: 0 2px 8px rgba(230, 57, 70, 0.15) !important;
    text-decoration: none !important;
    font-family: inherit !important;
}

.become-seller-animated-btn:hover {
    transform: scale(1.1) translateY(-1px) !important;
    background: linear-gradient(135deg, #E63946 0%, #d62839 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 6px 16px rgba(230, 57, 70, 0.4) !important;
    border-color: #E63946 !important;
}

.become-seller-animated-btn:active {
    transform: scale(0.95) !important;
}

@keyframes pulseGlow {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(230, 57, 70, 0.15);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 14px rgba(230, 57, 70, 0.45);
    }
}

/* Floating Cow Logo Animation */
.floating-cow-avatar {
    animation: floatCow 3.2s ease-in-out infinite !important;
    transition: transform 0.3s ease !important;
}

@keyframes floatCow {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-6px) rotate(3deg); }
}

/* Sparkle Bounce Animation */
.sparkle-icon {
    display: inline-block;
    animation: sparkleSpin 2s infinite ease-in-out;
}

@keyframes sparkleSpin {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.25) rotate(15deg); }
}

/* --- OFFLINE BANNER AND PORTRAIT LOCK OVERLAY --- */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    text-align: center;
    padding: 12px 16px;
    font-size: 0.9rem;
    font-weight: 700;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.3);
    animation: slideDown 0.3s ease-out forwards;
}


@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

/* Pull to Refresh Indicator Styles */
.ptr-indicator {
    position: absolute;
    top: 0px; /* Offset managed dynamically via JS */
    left: 50%;
    transform: translate(-50%, -100px) scale(0);
    width: 42px;
    height: 42px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000; /* Ensure it is above headers */
    transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.15s ease, box-shadow 0.2s ease;
    opacity: 0;
    pointer-events: none; /* Let drag events pass through */
}

.ptr-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #E63946;
    border-radius: 50%;
    transform: rotate(0deg);
    transition: transform 0.05s linear;
}

.ptr-indicator.refreshing .ptr-spinner {
    animation: ptr-spin 0.8s linear infinite;
}

@keyframes ptr-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


/* Header Icon Buttons */
.header-icon-btn {
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s ease, box-shadow 0.2s ease !important;
    outline: none;
}
.header-icon-btn:active {
    transform: scale(0.92) !important;
    background-color: #fee2e2 !important;
}


/* ==========================================
   BACKGROUND SCROLL LOCK & STYLISH BILL PREVIEW
   ========================================== */
body.modal-open {
    overflow: hidden !important;
    touch-action: none !important;
}

/* Custom Sleek Scrollbar */
#billScrollContainer::-webkit-scrollbar {
    width: 6px;
}
#billScrollContainer::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 8px;
}
#billScrollContainer::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 8px;
    border: 1px solid #f1f5f9;
}
#billScrollContainer::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Stylish Modern Bill Modal - Compact & Responsive */
#billPreviewModal {
    z-index: 10005 !important;
}
#billPreviewModal .modal-content {
    border-radius: 20px !important;
    border: 1.5px solid rgba(226, 55, 68, 0.2) !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3), 0 0 30px rgba(226, 55, 68, 0.1) !important;
    background: #ffffff !important;
    max-width: 430px !important;
    width: 93% !important;
    max-height: 88vh !important;
    padding: 14px 12px 12px 12px !important;
    box-sizing: border-box !important;
}

#billPrintArea {
    background: #ffffff !important;
    padding: 10px 8px !important;
    border: 1.5px solid #e2e8f0 !important;
    color: #0f172a !important;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif !important;
    border-radius: 14px !important;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.03) !important;
}

.bill-table th {
    background: #1e293b !important;
    color: #ffffff !important;
    font-weight: 800 !important;
    font-size: 11px !important;
    letter-spacing: 0.2px !important;
    border: 1px solid #334155 !important;
    padding: 5px 2px !important;
}

.bill-table td {
    border: 1px solid #e2e8f0 !important;
    color: #1e293b !important;
    font-size: 11.5px !important;
    font-weight: 600 !important;
    padding: 4px 2px !important;
}

.bill-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.bill-table tbody tr:hover {
    background: #f1f5f9;
}
