/* --- 1. THEME VARIABLES --- */
:root {
    --primary: #6200ee;
    --primary-variant: #3700b3;
    --secondary: #03dac5;
    --background: #f8f9fa;
    --surface: #ffffff;
    --error: #cf6679;
    --text-primary: #212121;
    --text-secondary: #757575;
    --border: #e0e0e0;
    --shadow: rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
    :root {
        --background: #121212;
        --surface: #1e1e1e;
        --text-primary: #ffffff;
        --text-secondary: #b0b0b0;
        --border: #333333;
        --shadow: rgba(0, 0, 0, 0.4);
    }
}

/* --- 2. GLOBAL STYLES --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.2s ease;
}

body {
    padding: calc(env(safe-area-inset-top) + 20px) 20px 40px;
    max-width: 500px;
    margin: auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
}

/* --- 3. COMPONENTS --- */
.card {
    overflow: hidden;
    background: var(--surface);
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 4px 20px var(--shadow);
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

/* Grand Total Section (Glassmorphism) */
.total-card {
    position: relative;
    color: white;
    border: none;
    padding: 30px 20px;
    text-align: center;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(12px);
    transition: all 0.3s ease;
}

/* Dynamic Themes injected by JS */
.total-card.revenue-theme {
    background: linear-gradient(180deg, rgba(3,218,197,0.08) 0%, rgba(0,0,0,0) 100%);
    border: 1px solid rgba(3, 218, 197, 0.3);
}
.total-card.revenue-theme #grandTotal, .total-card.revenue-theme .currency {
    color: #03dac5;
    text-shadow: 0 0 15px rgba(3,218,197,0.3);
}

.total-card.expense-theme {
    background: linear-gradient(135deg, rgba(207, 102, 121, 0.12), rgba(207, 102, 121, 0.02));
    border: 1px solid rgba(207, 102, 121, 0.3);
}
.total-card.expense-theme #grandTotal, .total-card.expense-theme .currency {
    color: #cf6679;
    text-shadow: 0 0 12px rgba(207, 102, 121, 0.4);
}


.label-text {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
    opacity: 0.85;
}

.amount-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.currency {
    font-size: 1.5rem;
    font-weight: 400;
    align-self: flex-start;
    margin-top: 4px;
}

#grandTotal {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1px;
}

.eye-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.eye-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* --- 4. FORMS & INPUTS --- */
label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 4px;
    display: block;
}

input:not([type="hidden"]), select, textarea {
    display: block;
    width: 100%;
    padding: 14px;
    margin-bottom: 16px;
    box-sizing: border-box;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 16px; /* Prevents auto-zoom on iOS */
    outline: none;
}

input:focus {
    border-color: var(--primary);
}

button {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(98, 0, 238, 0.2);
    transition: all 0.2s ease;
}

button:active {
    transform: scale(0.97);
}

.secondary-btn {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    box-shadow: none;
    margin-top: 10px;
}

.secondary-btn:hover {
    background: rgba(98, 0, 238, 0.1) !important;
}

/* --- 5. SALES LIST ITEMS --- */
.sale-item {
    background: var(--surface);
    padding: 16px;
    border-radius: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-left: 5px solid #03dac5;
    box-shadow: 0 2px 8px var(--shadow);
    position: relative;
}

.sale-item strong {
    font-size: 1.1rem;
    display: block;
}

.payment-tag {
    font-size: 0.65rem;
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 700;
}

/* --- 6. CONTEXT MENU --- */
.menu-content {
    display: none;
    position: absolute;
    right: 10px;
    top: 50px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    z-index: 100;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    overflow: hidden;
    min-width: 140px;
}

.menu-content button {
    background: none;
    color: var(--text-primary);
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    text-align: left;
    box-shadow: none;
}

.menu-content button:last-child { border-bottom: none; }
.show { display: block; animation: fadeIn 0.2s ease; }

/* --- 7. UTILITIES (Toast, Print, Deletion) --- */
.toast {
    visibility: hidden;
    min-width: 280px;
    background-color: var(--secondary);
    color: #000;
    text-align: center;
    border-radius: 50px; /* Pill shape */
    padding: 14px;
    position: fixed;
    z-index: 10001;
    left: 50%;
    bottom: 40px;
    transform: translateX(-50%);
    font-weight: 700;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.toast.show {
    visibility: visible;
    animation: slideUpIn 0.4s forwards, slideDownOut 0.4s 2.6s forwards;
}

.danger-btn {
    background-color: var(--error);
    margin-top: 40px;
    margin-bottom: 60px;
    color: white;
}

.edit-banner {
    background: #ff9800;
    color: white;
    padding: 10px;
    text-align: center;
    font-weight: bold;
    border-radius: 8px 8px 0 0;
    display: none;
}

/* --- 8. PRINTING --- */
.print-only { display: none; }

@media print {
    body * { display: none !important; }
    #print-section, #print-section * { display: block !important; }
    .print-only { 
        display: block !important; 
        padding: 40px; 
        color: black; 
        background: white; 
        font-family: 'Courier', monospace;
    }
    .line { display: flex; justify-content: space-between; margin: 10px 0; border-bottom: 1px dashed #ccc; }
}

/* --- 9. ANIMATIONS --- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUpIn { from { bottom: 0; opacity: 0; } to { bottom: 40px; opacity: 1; } }
@keyframes slideDownOut { from { bottom: 40px; opacity: 1; } to { bottom: 0; opacity: 0; } }

.login-container {
    position: fixed;
    inset: 0;
    background: var(--background);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
#pinInput {
    text-align: center;
    font-size: 24px;
    letter-spacing: 8px;
    margin-top: 20px;
}

/* Fix date inputs overflowing on mobile */
input[type="date"] {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* Make filter row wrap nicely */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-row input,
.filter-row select {
  flex: 1 1 140px;
  min-width: 0;
}
/* Fix filter date inputs overflow */
#filterCard input,
#filterCard select {
  width: 100%;
  box-sizing: border-box;
}
/* FINAL FILTER MOBILE FIXES */
#filterCard {
  overflow: hidden;
}

.filter-date-row {
  display: flex;
  gap: 10px;
}

.filter-date-row > div {
  flex: 1;
}

/* ===============================
   🔧 iOS DATE INPUT OVERFLOW FIX
================================ */

input[type="date"] {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box;
  display: block;
  -webkit-appearance: none;
  appearance: none;
}

/* Prevent Safari from forcing internal width */
input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
}

input[type="date"]::-webkit-datetime-edit {
  padding: 0;
}

/* 🔧 Fix flex overflow for inputs on iOS */

.filter-date-row > div {
  min-width: 0;
}

.filter-date-row input,
.filter-date-row select {
  width: 100%;
  max-width: 100%;
}


/* ===============================
   NEW: PROFESSIONAL ITEM ROWS (TWO-LINE)
================================ */

.item-row-container {
    background: rgba(255, 255, 255, 0.05);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.item-main-row {
    display: flex;
    flex-direction: column; 
    gap: 12px;
}

.item-details-row {
    display: flex;
    gap: 10px;
    align-items: flex-end; 
}

.row-name, .row-price, .row-qty {
    background: rgba(0, 0, 0, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    padding: 8px 12px !important;
    border-radius: 8px !important;
    height: 42px !important; 
    margin-bottom: 0 !important;
}

.prof-delete-btn {
    background: rgba(207, 102, 121, 0.1) !important;
    color: #cf6679 !important;
    border: 1px solid #cf6679 !important;
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer;
    padding: 0 !important;
    margin-bottom: 0 !important;
    transition: 0.2s;
}

.prof-delete-btn:hover {
    background: #cf6679 !important;
    color: white !important;
}

.tax-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    min-width: 40px;
    height: auto; 
}

.tax-container label {
    margin-bottom: 6px !important;
    font-size: 9px;
}

.row-taxable {
    margin: 0 !important;
    width: 18px;
    height: 18px;
    accent-color: #bb86fc;
    cursor: pointer;
}

.row-desc {
    width: 100%;
    font-size: 0.85em;
    background: transparent !important;
    color: rgba(255, 255, 255, 0.8) !important;
    border-radius: 4px;
    margin-top: 12px !important; 
    border: 1px dashed rgba(255, 255, 255, 0.15) !important;
    padding: 8px !important;
    margin-bottom: 0 !important;
}

.sale-summary {
    margin-top: 20px;
    padding: 15px;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    border: 1px solid rgba(187, 134, 252, 0.2); 
}

/* ===============================
   NEW: DASHBOARD UI
================================ */

/* Side-by-Side Summary Cards */
.financial-summary {
    display: flex;
    gap: 15px;
    margin-bottom: 12px;
}

.summary-box {
    flex: 1;
    padding: 25px 15px;
    border-radius: 16px;
    text-align: center;
    color: white;
    box-shadow: 0 8px 20px var(--shadow);
}

.summary-box .label-text {
    display: block;
    margin-bottom: 2px;
    font-size: 0.75rem;
    letter-spacing: 1.5px;
    opacity: 0.8;
}

.summary-box .amount {
    margin: 2px 0; 
    line-height: 1.1;
}

.summary-box.revenue, .summary-box.expenses {
    padding: 5px 12px; 
}

.summary-box.revenue {
    background: linear-gradient(135deg, #6200ee, #9c27b0);
}

.summary-box.expenses {
    background: linear-gradient(135deg, #cf6679, #b00020);
}

.summary-box .amount {
    font-size: 2rem;
    font-weight: 800;
    margin-top: 5px;
    letter-spacing: -0.5px;
}

/* Quick Action Buttons */
.quick-actions {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 10px;
    border-radius: 16px;
    font-size: 1rem;
    background: var(--surface);
    border: 2px solid var(--border);
    color: var(--text-primary);
    box-shadow: 0 4px 12px var(--shadow);
}

.action-btn.sale-action {
    color: var(--primary);
    border-color: rgba(98, 0, 238, 0.3);
}

.action-btn.expense-action {
    color: var(--error);
    border-color: rgba(207, 102, 121, 0.3);
}

.history-btn {
    width: 100%;
    margin-top: 10px !important;
}

/* ===============================
   NEW: POPUP MODALS
================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: flex-end; /* Slides up from the bottom on mobile */
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    margin-bottom: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.hidden .modal-content {
    transform: translateY(100%);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.close-btn {
    background: transparent;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 1.5rem;
    box-shadow: none;
    border-radius: 50%;
}

.close-btn:hover {
    background: rgba(0,0,0,0.05);
}
/* ===============================
   PREMIUM SaaS UI OVERRIDES
================================ */

/* 🔥 Glassmorphism Metric Cards (Base) */
.summary-box {
    padding: 20px 15px;
    border-radius: 16px;
    text-align: center;
    color: white;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

/* 🔥 Net Profit Card (Deep Purple Glass) */
.summary-box.profit, .summary-box.net-profit {
    background: linear-gradient(135deg, rgba(187, 134, 252, 0.12), rgba(0, 0, 0, 0.2)) !important;
    border: 1px solid rgba(187, 134, 252, 0.3) !important;
}

.summary-box.profit .amount, .summary-box.net-profit .amount { 
    color: #bb86fc !important;
    font-size: 2.5rem !important; 
    font-weight: 700 !important;
    text-shadow: 0 0 15px rgba(187, 134, 252, 0.4) !important;
}


/* 🔥 Revenue Card (Green) */
.summary-box.revenue {
    background: linear-gradient(180deg, rgba(3,218,197,0.05) 0%, rgba(0,0,0,0) 100%);
    border: 1px solid rgba(3, 218, 197, 0.3);
}
.summary-box.revenue .amount { 
    color: #03dac5; 
    font-size: 1.5rem; 
    font-weight: 700;
    text-shadow: 0 0 15px rgba(3,218,197,0.3); 
}

/* 🔥 Expenses Card (Red) */
.summary-box.expenses {
    background: linear-gradient(135deg, rgba(207, 102, 121, 0.12), rgba(207, 102, 121, 0.02));
    border: 1px solid rgba(207, 102, 121, 0.3);
}
.summary-box.expenses .amount { 
    color: #cf6679; 
    font-size: 1.5rem; 
    font-weight: 700;
    text-shadow: 0 0 12px rgba(207, 102, 121, 0.4); 
}

/* 🔥 UPGRADED: Button Hierarchy */
/* Primary Action Buttons (Log Sale / Log Expense) */
.action-btn {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
    border: 1px solid rgba(255, 255, 255, 0.25) !important; 
    color: white !important; 
    font-weight: 600;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

/* Secondary Action Buttons (History) */
.secondary-btn {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
    border: 1px solid rgba(255, 255, 255, 0.1) !important; 
    color: rgba(255, 255, 255, 0.7) !important; 
    font-weight: 500;
    backdrop-filter: blur(4px);
    box-shadow: none;
    transition: all 0.2s ease;
}

/* 🌟 Universal Button Hover & Active Effects */
.action-btn:hover, .secondary-btn:hover {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.06));
    transform: translateY(-2px); 
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3); 
    border-color: rgba(255, 255, 255, 0.4) !important;
    color: white !important;
}

.action-btn:active, .secondary-btn:active {
    transform: scale(0.97);
    background: rgba(255, 255, 255, 0.1);
}

/* Sign Out Button */
.sign-out-link {
    display: block;
    text-align: center;
    margin: 35px auto 0;
    padding: 10px 20px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.05); 
    border: 1px solid rgba(255, 255, 255, 0.1); 
    border-radius: 8px;
    width: fit-content; 
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.sign-out-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}
/* ===============================
   🔹 COLOR-CODED APP BUTTONS
================================ */

/* Revenue Button (Green Tint) */
.action-btn.revenue-btn {
    border-color: rgba(3, 218, 197, 0.3) !important;
    color: #03dac5 !important;
    background: linear-gradient(180deg, rgba(3, 218, 197, 0.08), rgba(0, 0, 0, 0));
}
.action-btn.revenue-btn:hover {
    background: linear-gradient(180deg, rgba(3, 218, 197, 0.15), rgba(3, 218, 197, 0.05));
    box-shadow: 0 8px 20px rgba(3, 218, 197, 0.2);
}

/* Expense Button (Red Tint) */
.action-btn.expense-btn {
    border-color: rgba(207, 102, 121, 0.3) !important;
    color: #cf6679 !important;
    background: linear-gradient(180deg, rgba(207, 102, 121, 0.08), rgba(0, 0, 0, 0));
}
.action-btn.expense-btn:hover {
    background: linear-gradient(180deg, rgba(207, 102, 121, 0.15), rgba(207, 102, 121, 0.05));
    box-shadow: 0 8px 20px rgba(207, 102, 121, 0.2);
}


/* ===============================
   🔥 NATIVE LIGHT THEME FIXES
================================ */
@media (prefers-color-scheme: light) {
    /* 1. Fix the main month and any hardcoded white inline text */
    #dashboardMonthDisplay, 
    .dashboard-header-text, 
    .month-label, 
    p[style*="color: white"], 
    div[style*="color: white"],
    p[style*="rgba(255,255,255"], 
    div[style*="rgba(255,255,255"],
    p[style*="rgba(255, 255, 255"], 
    div[style*="rgba(255, 255, 255"] {
        color: var(--text-primary) !important;
    }

    /* 2. Fix the Metric Card Titles (Net Profit, Revenue, etc.) */
    .summary-box {
        color: var(--text-primary) !important;
        background: var(--surface) !important;
        border: 1px solid var(--border) !important;
        box-shadow: 0 4px 15px var(--shadow) !important;
    }
    
    .summary-box .label-text {
        color: var(--text-secondary) !important;
    }

    /* Keep the amounts colorful in light mode */
    .summary-box.profit .amount, .summary-box.net-profit .amount { color: var(--primary) !important; text-shadow: none !important; }
    .summary-box.revenue .amount { color: var(--secondary) !important; text-shadow: none !important; }
    .summary-box.expenses .amount { color: var(--error) !important; text-shadow: none !important; }

    /* 3. Fix the Action Buttons (Log Revenue, History, Sign Out) */
    .action-btn {
        background: var(--surface) !important;
        color: var(--text-primary) !important;
        border: 1px solid var(--border) !important;
        box-shadow: 0 2px 8px var(--shadow) !important;
    }

    .action-btn.revenue-btn {
        color: var(--secondary) !important;
        border-color: rgba(3, 218, 197, 0.4) !important;
        background: rgba(3, 218, 197, 0.05) !important;
    }

    .action-btn.expense-btn {
        color: var(--error) !important;
        border-color: rgba(207, 102, 121, 0.4) !important;
        background: rgba(207, 102, 121, 0.05) !important;
    }

    /* Fix invisible History & P&L Buttons */
    .secondary-btn {
        background: var(--surface) !important;
        color: var(--text-secondary) !important;
        border: 1px solid var(--border) !important;
    }

    /* Fix invisible Sign Out Button */
    .sign-out-link {
        background: var(--surface) !important;
        color: var(--text-secondary) !important;
        border: 1px solid var(--border) !important;
    }
    /* 4. Fix the Month Picker & Header Text */
    input[type="month"],
    #dashboardMonth {
        color: var(--text-primary) !important;
        background-color: var(--surface) !important; /* 🔥 Restores the solid white box */
        border: 2px solid var(--border) !important;  /* 🔥 Restores the gray outline */
        border-radius: 12px !important;              /* Keeps the rounded corners */
    }

    /* Target the "Tap to change month" label specifically */
    div[style*="font-size: 0.75rem"],
    div[style*="font-size: 0.65rem"],
    div[style*="letter-spacing"] {
        color: var(--text-secondary) !important;
    }
    /* 5. Bulletproof Month Label Fix (No HTML changes needed!) */
    label[for="dashboardMonth"] {
        color: var(--text-secondary) !important;
    }
    /* 6. Fix Modal Inputs & Item Rows */
    .item-row-container {
        background: var(--surface) !important;
        border: 1px solid var(--border) !important;
        box-shadow: 0 2px 8px var(--shadow) !important;
    }

    /* Force the text and borders to be dark gray instead of white */
    .row-name, .row-price, .row-qty, .row-desc {
        background: var(--background) !important;
        border: 1px solid var(--border) !important;
        color: var(--text-primary) !important;
    }

    /* Fix the placeholder text (like "What are you selling?") */
    .row-name::placeholder, .row-price::placeholder, .row-qty::placeholder, .row-desc::placeholder {
        color: var(--text-secondary) !important;
    }

    /* Fix the Subtotal/Total Summary box at the bottom */
    .sale-summary {
        background: var(--surface) !important;
        border: 1px solid var(--border) !important;
        color: var(--text-primary) !important;
        box-shadow: 0 2px 8px var(--shadow) !important;
    }
    
    .sale-summary span {
        color: var(--text-primary) !important;
    }

    /* Ensure the Grand Total amount still pops with your primary purple */
    #liveTotal {
        color: var(--primary) !important;
    }
    #liveExpenseTotal {
        color: var(--error) !important;
    }
    /* 7. Fix History Page Total Card & Buttons */
    .total-card {
        background: var(--surface) !important;
        border: 1px solid var(--border) !important;
        box-shadow: 0 4px 15px var(--shadow) !important;
        color: var(--text-primary) !important;
    }

    /* Fix the invisible "Month Sales Total" text */
    .total-card .label-text,
    #totalLabel {
        color: var(--text-secondary) !important;
    }

    /* Strip the glowing dark-mode shadows but keep the money colorful */
    .total-card.revenue-theme #grandTotal, 
    .total-card.revenue-theme .currency {
        color: var(--secondary) !important;
        text-shadow: none !important;
    }

    .total-card.expense-theme #grandTotal, 
    .total-card.expense-theme .currency {
        color: var(--error) !important;
        text-shadow: none !important;
    }

    /* Fix the invisible Eye Icon button */
    .eye-btn {
        background: var(--background) !important;
        color: var(--text-secondary) !important;
        border: 1px solid var(--border) !important;
    }
    /* Fix contrast for the Net Profit card labels in Light Theme */
    .summary-box.profit .label-text, 
    .summary-box.net-profit .label-text,
    #dashProfitChange span {
        color: var(--text-secondary) !important;
        font-weight: 600 !important;
    }
    
    /* Ensure the negative margin percentage stays boldly red */
    #dashProfitChange span span {
        font-weight: 700 !important;
    }
    /* 8. Fix Category Manager in Light Theme */
    #categoryManagerList div {
        background: var(--surface) !important;
        border: 1px solid var(--border) !important;
        box-shadow: 0 2px 8px var(--shadow) !important;
    }

    /* Fix the Category Name (The bold one at the top) */
    #categoryManagerList input[style*="font-weight: bold"] {
        color: var(--primary) !important;
        border-bottom-color: var(--border) !important;
    }

    /* Fix the Subcategory Inputs (The ones with the arrows) */
    #categoryManagerList input:not([style*="font-weight: bold"]) {
        background: var(--background) !important;
        border: 1px solid var(--border) !important;
        color: var(--text-primary) !important;
    }

    /* Fix the tiny "Delete" and "X" buttons */
    #categoryManagerList button {
        opacity: 0.8;
    }
    
    #categoryManagerList button:hover {
        opacity: 1;
    }

    /* Make the "+ Add Sub" button look like a real button */
    #categoryManagerList .secondary-btn {
        background: var(--background) !important;
        color: var(--text-primary) !important;
        border: 1px solid var(--border) !important;
    }
}
/* ========================================================================= */
/* --- 10. REFACTORED INLINE STYLES (Extracted from HTML Safely)           --- */
/* ========================================================================= */

/* Global Utilities */
.hidden-strict { display: none !important; position: absolute !important; visibility: hidden !important; width: 0 !important; height: 0 !important; padding: 0 !important; margin: 0 !important; border: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.w-100 { width: 100%; }
.flex-1 { flex: 1; }
.flex-none { flex: none; width: auto; }
.m-0 { margin: 0 !important; }
.mt-0 { margin-top: 0; }
.mt-5 { margin-top: 5px; }
.mt-10 { margin-top: 10px; }
.mt-15 { margin-top: 15px; }
.mt-20 { margin-top: 20px; }
.mb-5 { margin-bottom: 5px; }
.mb-8 { margin-bottom: 8px; }
.mb-10 { margin-bottom: 10px; }
.mb-12 { margin-bottom: 12px; }
.mb-15 { margin-bottom: 15px; }
.mb-20 { margin-bottom: 20px; }
.mb-25 { margin-bottom: 25px; }
.my-15 { margin-top: 15px; margin-bottom: 15px; }
.my-20 { margin-top: 20px; margin-bottom: 20px; }
.my-30 { margin-top: 30px; margin-bottom: 30px; }
.p-12 { padding: 12px; }
.mr-6 { margin-right: 6px; }
.font-bold { font-weight: bold; }
.overflow-x-auto { overflow-x: auto; }
.divider-light { opacity: 0.1; }

/* Colors & Theming */
.text-purple { color: #bb86fc; }
.text-teal { color: #03dac5; }
.text-red { color: #cf6679; }
.text-orange { color: #ff9800; }
.text-stripe { color: #635bff; }
.text-gray { color: var(--text-secondary); }
.text-default { color: var(--text-primary); }

.bg-purple { background: #bb86fc; }
.bg-teal { background: #03dac5; }
.bg-red { background: #cf6679; }
.bg-stripe { background: #635bff; }
.btn-bg-red { background: var(--error); }

.bg-purple-light { background: rgba(187, 134, 252, 0.05); }
.bg-teal-light { background: rgba(3, 218, 197, 0.05); }
.bg-gray-light { background: rgba(128, 128, 128, 0.1); }

.border-purple { border: 1px dashed #bb86fc; }
.border-teal { border: 1px solid #03dac5; }
.border-stripe { border: 1px solid #635bff; }
.border-default { border: 1px solid var(--border); }
.border-purple-light { border-color: rgba(187, 134, 252, 0.4); }
.border-teal-light { border-color: rgba(3, 218, 197, 0.4); }
.border-red-light { border-color: rgba(207, 102, 121, 0.4); }
.border-orange-light { border-color: rgba(255, 152, 0, 0.4); }
.border-stripe-light { border-color: rgba(99, 91, 255, 0.4); }

.border-purple-dashed { border: 1px dashed #bb86fc; }
.border-teal-dashed { border: 1px dashed var(--secondary); }
.border-red-dashed { border: 1px dashed #cf6679; }

.border-left-purple { border-left: 4px solid #bb86fc; }
.border-left-orange { border-left: 4px solid #ff9800; }
.border-left-teal { border-left: 4px solid #03dac5; }
.border-left-red { border-left: 4px solid #cf6679; }

.shadow-teal { box-shadow: 0 10px 30px rgba(3, 218, 197, 0.2); }
.shadow-stripe { box-shadow: 0 10px 30px rgba(99, 91, 255, 0.2); }

/* Login Screen */
.login-card-custom { width: 100%; max-width: 350px; }

/* Admin Panel */
.admin-panel-custom { background: rgba(255, 152, 0, 0.1); border: 1px solid #ff9800; margin-bottom: 20px; }
.admin-label { color: #ff9800; font-weight: bold; font-size: 0.85rem; }
.admin-select { margin-bottom: 10px; background: var(--surface); }
.admin-wipe-btn { color: var(--error); font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; cursor: pointer; opacity: 0.7; }

/* Dashboard View */
.dashboard-welcome { text-align: center; margin-top: 10px; margin-bottom: 25px; font-size: 1.4rem; color: var(--text-primary); font-weight: 600; }
.dash-main-btn-container { display: flex; gap: 15px; margin-bottom: 25px; }
.dash-main-btn { flex: 1.2; margin: 0; padding: 20px 10px; font-size: 1.1rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; border-radius: 16px; }
.dash-main-btn.btn-purple { background: #bb86fc; color: #000; box-shadow: 0 4px 15px rgba(187, 134, 252, 0.3); }
.dash-main-btn.btn-teal { flex: 1; font-size: 1rem; border-color: rgba(3, 218, 197, 0.4); color: #03dac5; background: rgba(3, 218, 197, 0.05); }
.dash-month-container { margin-bottom: 20px; padding: 0 2px; }
.dash-month-label { display: block; text-align: center; font-size: 0.75rem; color: rgba(255,255,255,0.4); letter-spacing: 1.5px; margin-bottom: 8px; text-transform: uppercase; }
.dash-month-input { -webkit-appearance: none; appearance: none; min-width: 0; width: 100%; max-width: 100%; box-sizing: border-box; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.1); color: rgba(255,255,255,0.9); padding: 10px 15px; border-radius: 12px; font-family: inherit; font-size: 1rem; text-align: center; outline: none; display: block; }
.dash-change-subtext { font-size: 0.8rem; margin-top: 4px; margin-bottom: 2px; }
.dash-count-subtext { font-size: 0.7rem; color: rgba(255,255,255,0.4); font-weight: 500; }

/* Dashboard Snapshot & Net Profit Cards */
.snapshot-wrapper { display: flex; flex-direction: column; gap: 12px; margin-bottom: 15px; }
.snapshot-card { padding: 15px 15px 10px 15px; margin: 0; }
.snapshot-header { font-size: 0.65rem; font-weight: 700; letter-spacing: 1px; color: var(--text-secondary); margin-bottom: 10px; text-align: center; text-transform: uppercase; }
.snapshot-bars-container { display: flex; align-items: flex-end; justify-content: space-around; height: 75px; padding-bottom: 5px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.snapshot-bar-col { display: flex; flex-direction: column; align-items: center; width: 28%; height: 100%; justify-content: flex-end; }
.snapshot-val { font-size: 0.65rem; font-weight: bold; color: var(--text-primary); margin-bottom: 4px; }
.snapshot-bar { width: 100%; max-width: 30px; height: 2%; border-radius: 4px 4px 0 0; transition: height 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.snapshot-labels { display: flex; justify-content: space-around; margin-top: 4px; padding: 0 5px; }
.snapshot-labels span { font-size: 0.65rem; color: var(--text-secondary); width: 28%; text-align: center; }
.snapshot-footer { text-align: center; margin-top: 8px; font-size: 0.65rem; color: var(--text-secondary); display: flex; align-items: center; justify-content: center; gap: 4px; }
.net-profit-card { text-align: center; padding: 20px 15px; margin: 0; background: rgba(187, 134, 252, 0.03); }
.net-profit-title { font-size: 0.75rem; font-weight: 700; letter-spacing: 1.5px; color: var(--text-secondary); margin-bottom: 5px; }
.net-profit-amount { font-size: 2.4rem; font-weight: 800; color: #bb86fc; margin-bottom: 5px; line-height: 1; }
.net-profit-change { font-size: 0.85rem; }

/* Action Grid & Utility Cards */
.history-actions-container { display: flex; gap: 15px; margin-bottom: 20px; }
.history-action-btn { flex: 1; margin: 0; padding: 12px 10px; font-size: 0.85rem; font-weight: bold; letter-spacing: 0.5px; display: flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; }
.btn-teal-outline { border-color: rgba(3, 218, 197, 0.4); color: #03dac5; background: rgba(3, 218, 197, 0.05); }
.btn-red-outline { border-color: rgba(207, 102, 121, 0.4); color: #cf6679; background: rgba(207, 102, 121, 0.05); }
.quick-actions-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 15px; }
.grid-action-btn { padding: 12px 5px; margin: 0; font-size: 0.75rem; flex-direction: column; align-items: center; justify-content: center; gap: 8px; height: 100%; border-radius: 12px; }
.grid-action-text { text-align: center; line-height: 1.2; }
.utility-cards-container { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 15px; margin-bottom: 5px; }
.utility-card-btn { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 15px 10px; background: var(--surface); border-radius: 12px; cursor: pointer; font-weight: 600; font-size: 0.9rem; transition: 0.2s; }
.util-purple { border: 1px solid rgba(187, 134, 252, 0.3); color: #bb86fc; }
.util-teal { border: 1px solid rgba(3, 218, 197, 0.3); color: #03dac5; }
.account-actions-container { display: flex; gap: 15px; width: 100%; margin-top: 10px; align-items: stretch; }
.account-settings-btn { flex: 1; font-size: 0.85rem; margin: 0; padding: 15px 10px; display: flex; justify-content: center; align-items: center; }

/* History & Filters */
.svg-fixed { min-width: 20px; min-height: 20px; flex-shrink: 0; }
.history-header-row { display: flex; justify-content: space-between; align-items: center; margin-top: 30px; }
.sync-status-text { font-size: 11px; opacity: 0.6; cursor: pointer; }
.filter-toggle-btn { margin: 15px 0; }
.filter-reset-btn { color: var(--error); border-color: var(--error); margin-top: 0; }
.filter-export-btn { color: var(--secondary); border-color: var(--secondary); margin-top: 0; }
.filter-download-btn { background: #03dac5; color: black; margin-top: 10px; width: 100%; }
.bulk-delete-container { margin-top: 15px; border-top: 1px dashed rgba(207, 102, 121, 0.3); padding-top: 15px; }
.bulk-delete-btn { width: 100%; color: #cf6679; border-color: rgba(207, 102, 121, 0.4); background: rgba(207, 102, 121, 0.05); margin-top: 0; display: flex; align-items: center; justify-content: center; gap: 8px; }

/* Modals General */
.form-modal-card { margin: 0; border-radius: 16px 16px 0 0; min-height: 50vh; }
.add-item-btn-purple { width: 100%; margin: 10px 0; border: 1px dashed #6200ee; }
.add-item-btn-red { width: 100%; margin: 10px 0; border: 1px dashed #cf6679; color: #cf6679; }
.tax-payment-row { display: flex; gap: 12px; margin-top: 10px; }
.summary-box-style { margin-top: 20px; padding: 15px; background: rgba(0,0,0,0.2); border-radius: 8px; }
.summary-row-sub { display: flex; justify-content: space-between; margin-bottom: 5px; }
.summary-row-total { display: flex; justify-content: space-between; font-weight: bold; }
.file-upload-input { width: 100%; padding: 10px; background: rgba(255,255,255,0.05); border: 1px dashed var(--border); border-radius: 8px; color: var(--text-primary); }

/* Data Sync Modal */
.data-sync-card { max-width: 400px; margin: 20vh auto; text-align: center; position: relative; border-radius: 16px; }
.sync-close-btn { position: absolute; top: 15px; right: 20px; font-size: 1.5rem; cursor: pointer; color: var(--text-secondary); }
.sync-title { margin-top: 10px; color: #ffb74d; }
.sync-desc { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 25px; }
.sync-import-label { display: flex; align-items: center; justify-content: center; cursor: pointer; margin-bottom: 15px; background: rgba(3, 218, 197, 0.1); color: #03dac5; border: 1px solid #03dac5; padding: 12px; border-radius: 8px; }
.sync-export-btn { width: 100%; margin: 0; color: #ffb74d; border: 1px dashed rgba(255, 183, 77, 0.4); background: rgba(255, 183, 77, 0.05); padding: 12px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.sync-icon { font-size: 1.4rem; margin-right: 10px; }
.sync-btn-text { font-weight: bold; letter-spacing: 0.5px; }

/* Expense Specific */
.upload-status-text { font-size: 0.8em; color: #03dac5; margin-top: 5px; }
.existing-receipt-box { margin-top: 15px; }
.receipt-inner-box { padding: 10px 15px; background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 8px; display: flex; align-items: center; justify-content: space-between; width: 100%; box-sizing: border-box; }
.receipt-link-wrapper { display: flex; align-items: center; gap: 8px; }
.receipt-icon { color: var(--text-secondary); opacity: 0.8; flex-shrink: 0; }
.receipt-link { color: #03dac5; text-decoration: none; font-weight: 500; font-size: 0.9em; letter-spacing: 0.5px; white-space: nowrap; }
.receipt-delete-btn { margin: 0 !important; height: 38px !important; width: 38px !important; min-width: 38px !important; }

/* Shared View Styles (Reports, Inventory) */
.view-section { padding-bottom: 80px; }
.centered-max-width { max-width: 800px; margin: 0 auto; }
.btn-back-small { padding: 8px 16px; font-size: 0.9rem; width: auto; }

/* Client Reports */
.reports-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.reports-date-card { margin-bottom: 20px; border-top: 4px solid #bb86fc; }
.reports-date-title { margin-top: 0; font-size: 1.1rem; margin-bottom: 15px; }
.report-section-title { margin-top: 0; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 10px; }

/* Inventory */
.inventory-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 10px; }
.inventory-title { margin: 0; color: #03dac5; font-size: 1.4rem; text-align: center; flex: 1; }
.btn-add-inv { padding: 8px 12px; margin: 0; background: #03dac5; color: #000; font-size: 0.85rem; font-weight: bold; width: auto; }
.inventory-search-row { display: flex; justify-content: space-between; margin-bottom: 15px; gap: 10px; }
.inventory-search-input { flex: 1; padding: 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.2); color: var(--text-primary); font-size: 0.95rem; outline: none; }
.inv-modal-card { max-width: 350px; width: 90%; margin: auto; max-height: 70dvh; overflow-y: auto; position: relative; border-radius: 16px; }
.inv-highlight-label { color: #03dac5; font-weight: bold; }
.inv-highlight-input { border-color: rgba(3, 218, 197, 0.4); }
.inv-helper-text { font-size: 0.75rem; color: var(--text-secondary); margin-top: 5px; margin-bottom: 0; }
.inv-section-title { margin-top: 0; margin-bottom: 15px; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.5px; }
.inv-select-purple { width: 100%; border-color: rgba(187, 134, 252, 0.4); }
.inv-action-row { display: flex; gap: 10px; }
.inv-delete-btn { flex: 1; margin: 0; color: #cf6679; border-color: rgba(207, 102, 121, 0.4); background: rgba(207, 102, 121, 0.05); }
.inv-save-btn { flex: 1.5; margin: 0; background: #03dac5; color: #000; }
.inv-label-red { color: #cf6679; font-size: 0.8rem; text-transform: uppercase; }
.inv-label-purple { color: #bb86fc; font-size: 0.8rem; text-transform: uppercase; }
.inv-create-btn { width: 100%; background: #03dac5; color: #000; }

/* POS (Register) View */
.pos-main-container { 
    display: flex;
    position: fixed; 
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0; 
    background: var(--background); 
    z-index: 9999; 
    flex-direction: column; 
}
.pos-top-bar { display: flex; justify-content: space-between; align-items: center; padding: calc(15px + env(safe-area-inset-top)) 20px 15px 20px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.pos-top-left { display: flex; align-items: center; gap: 15px; }
.pos-exit-btn { margin: 0; padding: 8px 15px; font-size: 0.9rem; }
.pos-title { margin: 0; color: #bb86fc; font-size: 1.2rem; letter-spacing: 1px; }

/* Responsive POS layout */
.pos-wrapper { 
    display: flex; 
    flex: 1; 
    overflow: hidden; 
    flex-direction: row; 
}
.pos-left { 
    flex: 1.3; 
    display: flex; 
    flex-direction: column; 
    border-right: 1px solid var(--border); 
    background: var(--background); 
    overflow: hidden; 
}
.pos-right { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    background: var(--surface); 
    overflow: hidden; 
}

/* 🔥 BULLETPROOF MOBILE STACKING */
@media screen and (max-width: 850px) {
    .pos-wrapper { 
        flex-direction: column !important; 
    }
    .pos-left { 
        flex: 1 !important; /* Allow the product grid to shrink when the cart grows */
        border-right: none !important; 
    }
    .pos-right { 
        flex: none !important; /* Managed dynamically by JavaScript */
        height: 45%; /* Default starting size */
    }
}

.pos-cat-bar { display: flex; gap: 10px; padding: 12px 15px; overflow-x: auto; white-space: nowrap; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.pos-cat-btn.active { background: rgba(187, 134, 252, 0.2); color: #bb86fc; border: 1px solid #bb86fc; padding: 8px 16px; border-radius: 20px; font-size: 0.85rem; font-weight: bold; }
.pos-cat-btn.inactive { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); padding: 8px 16px; border-radius: 20px; font-size: 0.85rem; }
.pos-product-grid { flex: 1; overflow-y: auto; padding: 15px; display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; align-content: flex-start; }
.pos-product-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 15px 10px; text-align: center; cursor: pointer; box-shadow: 0 4px 10px var(--shadow); }
.pos-product-name { font-weight: 700; font-size: 0.9rem; margin-bottom: 8px; color: var(--text-primary); line-height: 1.2; }
.pos-product-price { color: #03dac5; font-weight: 900; font-size: 1.1rem; }
.pos-product-stock { font-size: 0.7rem; color: var(--text-secondary); margin-top: 5px; }

.pos-cart-list { flex: 1; overflow-y: auto; padding: 15px; display: flex; flex-direction: column; gap: 10px; }
.pos-empty-cart { text-align: center; color: var(--text-secondary); margin-top: 30px; font-size: 0.9rem; font-weight: 500; }
.pos-checkout-panel { padding: 15px 20px 5px 20px; background: var(--background); border-top: 1px solid var(--border); flex-shrink: 0; }
.pos-summary-row { display: flex; justify-content: space-between; margin-bottom: 6px; color: var(--text-secondary); font-size: 0.85rem; }
.pos-total-row { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 15px; }
.pos-total-label { font-size: 1rem; font-weight: bold; color: var(--text-primary); }
.pos-total-amount { font-size: 1.8rem; font-weight: 900; color: #64b5f6; line-height: 1; }
.pos-action-row { display: flex; gap: 10px; }
.pos-cash-btn { flex: 1; margin: 0; padding: 16px; font-size: 1.1rem; font-weight: 800; background: #03dac5; color: #000; border-radius: 12px; }
.pos-card-btn { flex: 1; margin: 0; padding: 16px; font-size: 1.1rem; font-weight: 800; border-color: #bb86fc; color: #bb86fc; background: rgba(187, 134, 252, 0.05); border-radius: 12px; }

.pos-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.8); z-index: 10000; justify-content: center; align-items: center; padding: 20px; display: flex; }
.pos-modal-card { width: 100%; max-width: 350px; text-align: center; border-radius: 16px; background: var(--surface); }
.pos-modal-title { margin-top: 0; }
.pos-modal-total { font-size: 1.5rem; font-weight: bold; margin-bottom: 15px; color: var(--text-primary); }
.pos-tender-label { color: var(--text-secondary); font-size: 0.85rem; display: block; margin-bottom: 8px; }
.pos-tender-input-row { display: flex; gap: 10px; margin-bottom: 15px; }
.pos-tender-input { flex: 1; min-width: 0; font-size: 1.8rem; text-align: center; font-weight: bold; box-sizing: border-box; margin: 0; background: var(--background); color: var(--text-primary); border: 2px solid var(--border); border-radius: 8px;}
.pos-exact-btn { flex: 0 0 auto; width: auto; margin: 0; padding: 0 20px; font-weight: 800; color: #64b5f6; border-color: #64b5f6; background: rgba(100, 181, 246, 0.1); font-size: 1.1rem; border-radius: 8px; }
.pos-change-row { font-size: 1.2rem; margin-bottom: 20px; color: #bb86fc; font-weight: bold; }
.pos-stripe-header { display: flex; align-items: center; justify-content: center; gap: 8px; }
.pos-stripe-helper { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0; margin-bottom: 20px; }
.pos-qr-container { background: #fff; padding: 15px; border-radius: 12px; margin-bottom: 20px; display: inline-block; border: 1px solid var(--border); }
.pos-qr-img { width: 200px; height: 200px; display: block; }

/* Settings View */
.settings-section-title { margin-top: 0; margin-bottom: 5px; }
.settings-helper-text { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 20px; }
.settings-helper-sub { font-size: 0.75rem; color: var(--text-secondary); margin-top: 5px; margin-bottom: 0; }
.settings-highlight-orange { color: #ff9800; font-weight: bold; }
.settings-logo-container { margin-top: 15px; padding: 10px; background: rgba(0,0,0,0.2); border-radius: 8px; text-align: center; }
.settings-logo-label { font-size: 0.75rem; margin-bottom: 10px; margin-top: 0; color: var(--text-secondary); }
.settings-logo-img { max-height: 80px; border-radius: 8px; margin-bottom: 15px; display: block; margin-left: auto; margin-right: auto; }
.settings-logo-remove-btn { border-color: rgba(207, 102, 121, 0.4); color: #cf6679; padding: 8px 16px; font-size: 0.8rem; margin: 0 auto; display: flex; align-items: center; justify-content: center; width: fit-content; }
.settings-integration-box { background: rgba(255,255,255,0.03); padding: 15px; border-radius: 8px; border: 1px dashed var(--border); }
.settings-webhook-box { padding: 10px; border-radius: 8px; }
.settings-webhook-label { font-size: 0.75rem; margin-bottom: 5px; }
.settings-webhook-input { font-size: 0.8rem; background: transparent; border: none; padding: 0; color: var(--text-primary); user-select: all; }
.settings-fee-row { display: flex; gap: 10px; margin-top: 10px; }
.settings-manager-select { width: 100%; padding: 12px; background: var(--surface); color: var(--text-primary); border: 1px solid var(--border); border-radius: 8px; font-weight: bold; font-size: 1rem; appearance: none; }
.settings-manager-actions { display: flex; gap: 10px; margin-bottom: 20px; }
.settings-add-btn { flex: 1; margin: 0; padding: 10px 5px; font-size: 0.75rem; }
.settings-trash-btn { flex: 1; margin: 0; padding: 10px 5px; font-size: 0.75rem; border: none; }
.settings-payment-list { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 15px; }
.settings-contacts-row { display: flex; gap: 15px; margin-bottom: 20px; }
.settings-contact-title { font-size: 0.85rem; margin-bottom: 10px; text-transform: uppercase; }
.settings-contact-list { max-height: 250px; overflow-y: auto; margin-bottom: 10px; }
.settings-contact-btn { font-size: 0.75rem; padding: 10px; margin-top: 0; }

/* Advanced Reports View */
.reports-main-title { margin: 0; color: var(--primary); }
.reports-spacer { width: 70px; }
.reports-card-title { margin-top: 0; margin-bottom: 15px; font-size: 1rem; }
.reports-period-box { padding: 12px; border-radius: 8px; margin-bottom: 15px; }
.reports-period-label { font-weight: bold; font-size: 0.8rem; display: block; margin-bottom: 8px; }
.reports-date-input { width: 100%; font-size: 0.9rem; padding: 8px; border-radius: 6px; background: var(--surface); color: var(--text-primary); }
.reports-compare-stack { display: flex; flex-direction: column; gap: 15px; margin-bottom: 15px; }
.reports-helper-text { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0; margin-bottom: 10px; }

.pos-wrapper { 
    display: flex; 
    flex: 1; 
    overflow: hidden; 
    flex-direction: row; 
}

.pos-left { 
    flex: 1.3; 
    display: flex; 
    flex-direction: column; 
    border-right: 1px solid rgba(255,255,255,0.05); 
    background: rgba(0,0,0,0.1); 
    overflow: hidden; 
}

.pos-right { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    background: var(--surface); 
    overflow: hidden; 
}

/* --- POS TOP BAR --- */
.pos-top-bar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-top: max(12px, env(safe-area-inset-top)); /* Dynamic Island Fix */
    padding-right: 15px;
    padding-bottom: 12px;
    padding-left: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    background: var(--background);
    min-height: 64px;
    box-sizing: border-box;
}

.pos-exit-btn {
    position: relative;
    z-index: 10;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--text-primary);
    border-radius: 20px;
    padding: 0 14px;
    height: 36px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0;
    width: max-content;
    flex-shrink: 0;
}

.pos-customer-wrapper {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    width: max-content;
    min-width: 160px;
    max-width: 50vw;
}

.pos-customer-select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--text-primary);
    padding: 0 35px 0 15px;
    height: 36px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    outline: none;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.pos-customer-chevron {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}
/* --- POS DRAGGABLE BOTTOM SHEET --- */
.pos-bottom-sheet {
    display: flex;
    flex-direction: column;
    flex: 1; /* Naturally fills its container */
    background: var(--surface);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    /* 🔥 REMOVED: position: fixed and bottom: 0. We are using native Flexbox now! */
}

/* Drag Handle */
.pos-drag-handle-wrapper {
    width: 100%;
    height: 35px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: ns-resize;
    touch-action: none;
    flex-shrink: 0;
}

.pos-drag-pill {
    width: 40px;
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

/* Cart List Area */
.pos-cart-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 15px;
    min-height: 0;
}

/* Totals & Payment Section */
.pos-totals-panel {
    padding: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    background: var(--background);
}

/* 🔥 FIX 3: Add this new rule so your products don't get hidden behind the closed cart */
#posProductGrid {
    padding-bottom: 250px; 
}

.pos-empty-cart {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 30px;
    font-size: 0.9rem;
    font-weight: 500;
}


.pos-totals-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.pos-grand-total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 1.4rem;
    font-weight: 900;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    padding-top: 12px;
    color: var(--text-primary);
}

/* Payment Buttons */
.pos-payment-buttons {
    display: flex;
    gap: 10px;
}

.pos-pay-cash-btn {
    background: #64b5f6;
    color: #000;
    border: none;
    height: 50px;
    font-size: 1.1rem;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    flex: 1;
    transition: 0.2s;
}

.pos-pay-card-btn {
    background: #2a2a2a;
    color: #fff;
    border: 1px solid #444;
    height: 50px;
    font-size: 1.1rem;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    flex: 1;
    transition: 0.2s;
}

/* ===============================
   🔹 DASHBOARD UNIFIED STYLES (APP STORE LOOK)
================================ */

/* 1. Perfect Grid Spacing */
.dashboard-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
}

/* Flexible Row */
.dashboard-grid-4 {
    display: flex; /* Changed from grid to flex */
    gap: 12px;
    margin-top: 0;
    margin-bottom: 12px;
    width: 100%;
}

/* 2-Column Grid (Now perfectly aligns with the 4-grid above it!) */
.dashboard-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 0;
    margin-bottom: 24px;
}

/* 2. Elevated Native Buttons */

/* Main Action: POS View (Solid Brand Blue) */
.btn-dash-primary {
    width: 100%;
    background: #64b5f6 !important;
    color: #000 !important;
    padding: 30px 20px !important; /* Restored to original large size */
    font-size: 1.2rem !important; /* Restored to original large text */
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border-radius: 14px;
    border: none;
    box-shadow: 0 4px 15px rgba(100, 181, 246, 0.3) !important; /* Blue base shadow */
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

/* FIX: This overrides the sneaky purple hover glow */
.btn-dash-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(100, 181, 246, 0.5) !important; /* Blue hover glow */
}

.btn-dash-primary:active {
    transform: scale(0.97);
    background: #42a5f5 !important;
}

/* Secondary Action: Financial Dashboard */
.btn-dash-secondary {
    width: 100%;
    background: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
    padding: 28px 20px !important; /* Restored to original large size */
    font-size: 1.2rem !important; /* Restored to original large text */
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-radius: 14px;
    border: none !important;
    box-shadow: none !important; /* Ensures no leftover shadows */
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-dash-secondary:hover {
    background: rgba(255, 255, 255, 0.12) !important;
}

.btn-dash-secondary:active {
    background: rgba(255, 255, 255, 0.16) !important;
}

/* The 4-Grid Buttons (Inventory, Services, etc.) */
.utility-card-btn {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important; 
    border: none !important; 
    border-radius: 14px;
    padding: 16px 4px;
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    box-shadow: none;
    transition: background 0.2s;
}

/* Makes all the icons inside the 4-grid your brand blue */
.utility-card-btn svg {
    color: #64b5f6 !important; 
    width: 24px;
    height: 24px;
}

.utility-card-btn:active {
    background: rgba(255, 255, 255, 0.12) !important;
}

/* Bottom Row: Settings */
.btn-outline-neutral {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #ffffff;
    border-radius: 14px;
    padding: 16px;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: none !important; /* KILLS THE PURPLE GLOW */
}

/* Bottom Row: Sign Out */
.btn-outline-danger {
    width: 100%;
    background: rgba(207, 102, 121, 0.1); 
    border: none;
    color: #cf6679; 
    border-radius: 14px;
    padding: 16px;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: none !important; /* KILLS THE PURPLE GLOW */
}

/* ===============================
   ☀️ LIGHT THEME OVERRIDES FOR NATIVE BUTTONS
================================ */
@media (prefers-color-scheme: light) {
    
    /* Secondary Action: Financial Dashboard */
    .btn-dash-secondary {
        background: #ffffff !important; /* Crisp solid white */
        border: 1px solid rgba(0, 0, 0, 0.08) !important; /* Subtle border */
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important; /* Native soft shadow */
        color: #000000 !important;
    }
    .btn-dash-secondary:active {
        background: #f2f2f7 !important;
    }

    /* The 4-Grid Buttons (Inventory, Services, etc.) */
    .utility-card-btn {
        background: #ffffff !important;
        border: 1px solid rgba(0, 0, 0, 0.08) !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
        color: #000000 !important;
    }
    .utility-card-btn:active {
        background: #f2f2f7 !important;
    }
    .utility-card-btn svg {
        color: #42a5f5 !important; /* Richer blue to pop against white */
    }

    /* Bottom Row: Settings */
    .btn-outline-neutral {
        background: #ffffff !important;
        border: 1px solid rgba(0, 0, 0, 0.08) !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
        color: #000000 !important;
    }
    .btn-outline-neutral:active {
        background: #f2f2f7 !important;
    }

    /* Bottom Row: Sign Out */
    .btn-outline-danger {
        background: rgba(207, 102, 121, 0.1) !important; 
        border: 1px solid rgba(207, 102, 121, 0.2) !important;
        box-shadow: none !important; 
        color: #d32f2f !important; /* Darker, more readable red */
    }

    /* Main POS Button */
    .btn-dash-primary {
        box-shadow: 0 4px 12px rgba(100, 181, 246, 0.4) !important;
    }
    .btn-dash-primary:hover {
        box-shadow: 0 6px 16px rgba(100, 181, 246, 0.5) !important;
    }
}

/* ===============================
    FINANCIAL DASHBOARD OVERRIDE
================================ */

/* 1. Month Selector */
.dash-month-input {
    background: rgba(255, 255, 255, 0.08) !important;
    border: none !important;
    color: #ffffff !important;
    border-radius: 14px !important;
    padding: 14px 15px !important;
    font-size: 1.1rem !important;
    font-weight: 600 !important;
    box-shadow: none !important;
}

/* 2. Unified Card Surfaces (Snapshot, Net Profit, Summary Boxes) */
.snapshot-card, 
.net-profit-card, 
.summary-box {
    background: rgba(255, 255, 255, 0.08) !important;
    border: none !important;
    border-radius: 16px !important;
    box-shadow: none !important;
    backdrop-filter: none !important; 
    margin-bottom: 0 !important; /* 🔥 FIX: Removed the extra margin causing the huge gaps */
}

/* Un-squish the Revenue/Expense boxes AND add color tints */
.summary-box.revenue {
    background: rgba(3, 218, 197, 0.1) !important; /* Soft Teal background */
    border: 1px solid rgba(3, 218, 197, 0.2) !important; /* Subtle Teal border */
    padding: 20px 15px !important; 
}

.summary-box.expenses {
    background: rgba(207, 102, 121, 0.1) !important; /* Soft Red background */
    border: 1px solid rgba(207, 102, 121, 0.2) !important; /* Subtle Red border */
    padding: 20px 15px !important; 
}

/* Make sure the text pops nicely against the dark cards */
.summary-box.revenue .amount { text-shadow: none !important; color: #03dac5 !important; }
.summary-box.expenses .amount { text-shadow: none !important; color: #cf6679 !important; }

/* Adds a glowing shadow to the Net Profit Number! */
.net-profit-amount { 
    text-shadow: 0 0 15px currentColor !important; 
}

/* 3. Action Buttons (Add Revenue / Add Expense) */
.action-btn {
    background: rgba(255, 255, 255, 0.08) !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 14px !important;
    padding: 20px 10px !important;
    transition: background 0.2s ease !important;
}

.action-btn:active {
    background: rgba(255, 255, 255, 0.12) !important;
    transform: scale(0.97) !important;
}

/* Just color the text/icons, not the background */
.action-btn.revenue-btn { color: #03dac5 !important; }
.action-btn.expense-btn { color: #cf6679 !important; }

/* 4. History Buttons (Bottom Row) */
.history-action-btn {
    background: rgba(255, 255, 255, 0.08) !important;
    border: none !important;
    border-radius: 14px !important;
    box-shadow: none !important;
    padding: 16px 10px !important;
}
.history-action-btn:active {
    background: rgba(255, 255, 255, 0.12) !important;
}

.btn-teal-outline { color: #03dac5 !important; }
.btn-red-outline { color: #cf6679 !important; }

/* 5. Consistent Spacing */
.financial-summary, 
.quick-actions, 
.history-actions-container {
    gap: 12px !important;
}


/* ===============================
   ☀️ FINANCIAL DASHBOARD LIGHT MODE & VISIBILITY FIXES
================================ */
@media (prefers-color-scheme: light) {
    /* 1. Make all cards and buttons solid white with native Apple shadow */
    .dash-month-input,
    .snapshot-card, 
    .net-profit-card, 
    .summary-box,
    .action-btn,
    .history-action-btn {
        background: #ffffff !important;
        border: 1px solid rgba(0, 0, 0, 0.08) !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
        color: #000000 !important;
    }

    /* 2. Active states for buttons in light mode */
    .action-btn:active,
    .history-action-btn:active {
        background: #f2f2f7 !important;
    }

    /* 3. General Elements & Outlines */
    .dash-month-input { color: #000000 !important; }
    .btn-teal-outline { color: #00bfa5 !important; }
    .btn-red-outline { color: #d32f2f !important; }
    
    /* 4. Turn off the glow on Net Profit so it remains readable */
    .net-profit-amount {
        text-shadow: none !important;
    }

    /* 5. Fix the invisible white text inside the boxes */
    .dash-count-subtext,
    .dash-change-subtext,
    .summary-box .label-text {
        color: var(--text-secondary) !important; /* Forces it to be dark gray */
        font-weight: 700 !important;
        opacity: 1 !important; /* Removes the fade so it's crisp and legible */
    }

    /* 6. Richer, darker Teal for Revenue (Readable on white) */
    .summary-box.revenue .amount,
    .action-btn.revenue-btn,
    .action-btn.revenue-btn svg {
        color: #00897b !important; /* A crisp, readable Material Teal */
    }

    /* Makes the Expenses amount and Add Expense button the EXACT same red */
    .summary-box.expenses .amount,
    .action-btn.expense-btn,
    .action-btn.expense-btn svg {
        color: #d32f2f !important; /* A crisp, readable Material Red */
    }
    .summary-box.expenses {
        background: rgba(198, 40, 40, 0.08) !important;
        border: 1px solid rgba(198, 40, 40, 0.25) !important;
    }
}

/* ===============================
    DASHBOARD SPACING & GLOW FIXES
================================ */

/* Un-squishes the Revenue and Expense boxes */
.summary-box.revenue, 
.summary-box.expenses {
    padding: 20px 15px !important; 
}

/* 3. Dynamic Red/Purple Glow for Net Profit */
/* JavaScript changes the text color, so 'currentColor' makes the glow match perfectly */
.net-profit-amount {
    text-shadow: 0 0 15px currentColor !important;
}

/* 4. Turn off the glow in Light Mode so it stays readable on a white background */
@media (prefers-color-scheme: light) {
    .net-profit-amount {
        text-shadow: none !important;
    }
}

/* ===============================
    QUICK EXPENSE BUTTON STYLES
================================ */

/* Main Action: Quick Expense (Solid Red) */
.btn-dash-expense {
    width: 100%;
    background: #cf6679 !important; /* Premium App Store Pink/Red */
    color: #fff !important;
    font-size: 1.15rem !important; 
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    border: none;
    box-shadow: 0 4px 15px rgba(207, 102, 121, 0.3) !important;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.btn-dash-expense:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(207, 102, 121, 0.5) !important;
}

.btn-dash-expense:active {
    transform: scale(0.97);
    background: #b00020 !important;
}

/* Light Theme Override */
@media (prefers-color-scheme: light) {
    .btn-dash-expense {
        background: #d32f2f !important; /* Richer, darker red for white backgrounds */
        box-shadow: 0 4px 12px rgba(211, 47, 47, 0.3) !important;
    }
    .btn-dash-expense:hover {
        box-shadow: 0 6px 16px rgba(211, 47, 47, 0.4) !important;
    }
}

/* ===============================
   🎛️ COMPACT LEDGER CONTROLS
================================ */
.ledger-compact-btn {
    background: rgba(255, 255, 255, 0.05); /* Very subtle dark mode background */
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 12px 8px;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s;
    box-shadow: none !important; 
}

.ledger-compact-btn:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3) !important; 
}

.ledger-compact-btn:active {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(0.97);
}

/* Light Mode Adaptations */
@media (prefers-color-scheme: light) {
    .ledger-compact-btn {
        background: #ffffff;
        border: 1px solid rgba(0, 0, 0, 0.08);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
    }
    .ledger-compact-btn:active {
        background: #f2f2f7;
    }
    .ledger-compact-btn.text-teal { color: #00796b !important; }
    .ledger-compact-btn.text-red { color: #c62828 !important; }
}

/* ===============================
   ️ ADMIN PANEL GOD MODE (DYNAMIC)
================================ */
#adminPanel.admin-god-mode {
    position: relative !important;
    z-index: 99999 !important; 
}
/* ===============================
   POS DRAG PILL LIGHT MODE FIX
================================ */
@media (prefers-color-scheme: light) {
    .pos-drag-pill {
        background: rgba(0, 0, 0, 0.2) !important;
    }
}

/* ===============================
    FULL-SCREEN LANDING PAGE FIX
================================ */
#landing-page {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--background);
    z-index: 10000;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Makes scrolling smooth on iPhones */
}
.pricing-grid {
    display: flex;
    flex-direction: column;
    gap: 35px; /* Gives plenty of breathing room between cards */
    max-width: 400px;
    margin: 0 auto;
}

.pricing-card {
    padding: 30px 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: visible !important; 
}

.pricing-card ul li {
    position: relative;
}

.pricing-card ul li::before {
    content: '✓';
    position: absolute;
    left: -25px;
    color: #64b5f6;
    font-weight: 900;
}