:root {
    --bg: #f8fafc;
    --sidebar-w: 260px;
    --primary: #10b981;
    --primary-light: #ecfdf5;
    --primary-dark: #059669;
    --blue: #3b82f6;
    --orange: #f59e0b;
    --purple: #8b5cf6;
    --red: #ef4444;
    --text: #0f172a;
    --muted: #64748b;
    --white: #ffffff;
    --border: rgba(0, 0, 0, 0.05);
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius: 16px;
    --radius-sm: 10px;
}

html, body {
    overflow-x: hidden !important;
    max-width: 100vw;
    width: 100%;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.glass {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.app-container { display:flex; min-height:100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-w);
    background: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100%;
    z-index: 200;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.02);
}

.sidebar-header {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    gap: 10px;
}

.brand-icon { font-size: 26px; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1)); }

.brand-name {
    font-size: 19px;
    font-weight: 850;
    color: var(--secondary);
    flex: 1;
    letter-spacing: -0.02em;
}
.brand-name span { color: var(--primary); }

.menu-btn {
    background: none; border: none;
    font-size: 22px; cursor: pointer; color: var(--muted);
    display: none;
}

.nav-links { 
    list-style: none; 
    padding: 10px 0; 
    flex: 1; 
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}
.nav-links::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.nav-links li { margin: 2px 10px; }

.nav-links li a {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    text-decoration: none;
    color: var(--muted);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13.5px;
    gap: 10px;
    transition: all 0.3s ease;
}

.nav-links li a:hover { 
    background: var(--primary-light); 
    color: var(--primary);
    transform: translateX(4px);
}

.nav-links li.active a {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 6px 10px -3px rgba(16, 185, 129, 0.3);
}

.nav-icon { font-size: 17px; min-width: 20px; text-align: center; }

.profile-preview {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: rgba(var(--primary-rgb), 0.02);
}
.name { font-weight: 700; font-size: 14px; color: var(--secondary); }
.job { font-size: 13px; color: var(--muted); margin-top: 4px; font-weight: 500; }

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    min-width: 0; /* Prevents flexbox blow-out causing horizontal scroll */
    margin-left: var(--sidebar-w);
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: all 0.4s ease;
}

header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 15px; }
.header-left h1 { font-size: 20px; font-weight: 850; color: var(--secondary); letter-spacing: -0.02em; }
.header-left .subtitle { font-size: 13px; color: var(--muted); font-weight: 500; }
.header-right { display: flex; align-items: center; gap: 16px; }

.hamburger-btn {
    background: none; border: none;
    font-size: 24px; cursor: pointer; color: var(--muted);
    display: none;
}

.year-badge {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 700;
    border: 1px solid rgba(var(--primary-rgb), 0.2);
}

.avatar-circle {
    min-width: 44px;
    max-width: 320px;
    height: 44px;
    padding: 0 16px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2);
    transition: all 0.3s ease;
}

.avatar-circle span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar-circle:hover {
    transform: scale(1.02);
}

/* ===== PAGES ===== */
.page-view { display: none; padding: 24px 28px; animation: fadeUp 0.35s ease; }
.page-view.active { display: block; }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== DASHBOARD ===== */
.overview-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.card {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.card:hover { 
    transform: translateY(-5px); 
    box-shadow: 0 15px 20px -5px rgba(0, 0, 0, 0.08);
}

.card-icon { 
    font-size: 32px; 
    width: 54px;
    height: 54px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-info h3 { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.card-info h2 { font-size: 28px; font-weight: 850; margin: 4px 0 2px; color: var(--secondary); }
.card-sub { font-size: 12px; color: var(--muted); font-weight: 500; }

/* ===== PANEL ===== */
.panel { 
    padding: 24px 28px; 
    margin-bottom: 24px;
}
.panel-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid rgba(16, 185, 129, 0.1); /* Primary RGB */
}
.panel-header h2 { font-size: 18px; font-weight: 850; color: var(--secondary); letter-spacing: -0.01em; }

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 32px;
}

/* Stock Dashboard Grid */
.stock-grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 32px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
}

.stock-grid-header h3 {
    font-size: 18px;
    font-weight: 850;
    color: var(--secondary);
}

.stock-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}

.mini-stock-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px 12px;
    text-align: center;
    transition: all 0.3s ease;
}

.mini-stock-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: var(--primary);
}

.mini-stock-card h4 {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
}

.mini-stock-card h2 {
    font-size: 16px;
    color: var(--blue);
    font-weight: 800;
}

.mini-stock-card.low-stock h2 {
    color: var(--red);
}

@media (max-width: 1200px) { .stock-dashboard-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 768px) { .stock-dashboard-grid { grid-template-columns: repeat(2, 1fr); } }

.quick-actions { display: flex; flex-direction: column; gap: 16px; }

.feature-list { list-style: none; }
.feature-list li {
    display: flex; align-items: flex-start;
    gap: 12px; padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    font-weight: 500;
}

.fl-icon { font-size: 18px; min-width: 24px; color: var(--primary); }

.norms-scroll-container {
    max-height: 500px;
    overflow-y: auto;
    border: 2px solid var(--border);
    border-radius: 16px;
}

.norms-table { width: 100%; border-collapse: collapse; }
.norms-table th { position: sticky; top: 0; z-index: 10; font-size: 13px; padding: 14px; background: var(--primary); color: white; }
.norms-table td { padding: 12px 14px; font-size: 14px; border-bottom: 1px solid var(--border); }
.no-m { margin: 0 !important; width: 100px !important; }
.input-unit-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.unit-label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 13px;
    min-width: 24px;
}
.unit-select-dropdown {
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid var(--border, #cbd5e1);
    background: #ffffff;
    font-weight: 600;
    font-size: 13px;
    color: #334155;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}
.unit-select-dropdown:hover {
    border-color: var(--primary, #10b981);
}
.unit-select-dropdown:focus {
    border-color: var(--primary, #10b981);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

/* Stock Types Color Coding */
.stock-type-borrow { background-color: #f0fdf4 !important; }
.stock-type-return { background-color: #fef2f2 !important; }

.form-row-top {
    display: flex; gap: 24px; align-items: flex-end;
    margin-bottom: 32px; flex-wrap: wrap;
}

.split-forms {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-bottom: 32px;
}

.form-section {
    background: #fafbfc;
    border: 2px solid var(--border);
    border-radius: 20px;
    padding: 24px;
}

.section-title {
    font-size: 15px; font-weight: 850;
    margin-bottom: 16px; padding-bottom: 10px;
    border-bottom: 2px solid;
}
.blue-title { color: var(--blue); border-color: rgba(59, 130, 246, 0.2); }
.green-title { color: var(--primary); border-color: rgba(16, 185, 129, 0.2); }

.ingredient-calc {
    margin-top: 20px; padding: 20px;
    background: rgba(var(--primary-rgb), 0.05);
    border-radius: 16px;
    border: 1px solid rgba(var(--primary-rgb), 0.1);
}
.ingredient-calc h4 { font-size: 14px; color: var(--primary-dark); margin-bottom: 12px; font-weight: 700; }

.calc-row {
    display: flex; justify-content: space-between;
    font-size: 14px; padding: 6px 0;
    border-bottom: 1px solid rgba(16, 185, 129, 0.1);
}
.calc-row:last-child { border: none; }
.calc-val { font-weight: 800; color: var(--primary-dark); }

.action-btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; padding: 12px 20px; border-radius: 12px;
    border: none; font-size: 14px; font-weight: 700;
    cursor: pointer; transition: all 0.3s ease; width: 100%;
    font-family: inherit;
}
.action-btn.primary {
    background: var(--primary); color: white;
    box-shadow: 0 8px 12px -3px rgba(16, 185, 129, 0.3);
}
.action-btn.primary:hover { 
    background: var(--primary-dark); 
    transform: translateY(-2px); 
    box-shadow: 0 15px 20px -5px rgba(16, 185, 129, 0.4);
}
.action-btn.secondary {
    background: var(--white); color: var(--secondary);
    border: 2px solid var(--border);
}
.action-btn.secondary:hover { background: var(--bg-light); border-color: rgba(0,0,0,0.1); }

/* ===== FORMS ===== */
.stylish-input {
    padding: 10px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    background: var(--white);
    transition: all 0.3s ease;
    outline: none;
    font-family: inherit;
    color: var(--text);
    width: 100%;
    box-sizing: border-box;
}
.stylish-input:focus { 
    border-color: var(--primary); 
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1); 
    background: white;
}

.input-group {
    margin-bottom: 20px;
    width: 100%;
}
.input-group label { 
    display: block; 
    margin-bottom: 8px; 
    font-size: 14px; 
    font-weight: 600; 
    color: var(--secondary); 
}

.total-bar {
    display: flex; gap: 40px; flex-wrap: wrap;
    padding: 24px 32px;
    margin-bottom: 32px;
    background: rgba(var(--primary-rgb), 0.05);
    border: 1px solid rgba(var(--primary-rgb), 0.1);
    font-weight: 700;
    color: var(--primary-dark);
}

.form-actions { display: flex; gap: 12px; justify-content: flex-end; }
.form-actions .action-btn { width: auto; padding: 12px 24px; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; width: 100%; max-width: 100%; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
    background: var(--primary);
    color: white; padding: 12px 14px;
    text-align: left; font-weight: 600;
    font-size: 13px;
}
thead th:first-child { border-radius: 8px 0 0 0; }
thead th:last-child { border-radius: 0 8px 0 0; }
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.15s; }
tbody tr:hover { background: #f8fffe; }
tbody td { padding: 11px 14px; }

/* ===== MENU REGISTER ===== */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}
.menu-actions-cell {
    grid-column: span 2;
    background: rgba(255,255,255,0.4);
    border: 1.5px dashed var(--border);
    border-radius: 12px;
}
.menu-day {
    border: 1.5px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    text-align: center;
}
.day-label { padding: 10px; font-weight: 600; text-align: center; font-size: 14px; }
.menu-input {
    width: 100%;
    border: 1.5px solid transparent;
    border-radius: 8px;
    padding: 12px 10px;
    font-size: 14px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.4);
    text-align: center;
    color: var(--secondary);
    font-family: inherit;
    transition: all 0.2s ease;
    cursor: text;
}
.menu-input:hover {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(0, 0, 0, 0.1);
}
.menu-input:focus { 
    outline: none; 
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.menu-ing-choices {
    padding: 8px;
    background: rgba(0,0,0,0.03);
    border-top: 1px solid rgba(0,0,0,0.05);
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    font-size: 11px;
    text-align: left;
    max-height: 450px;
    overflow-y: auto;
}
.menu-ing-choices label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.menu-ing-choices input { cursor: pointer; }

.mini-ing-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    padding: 10px;
    background: rgba(0,0,0,0.03);
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.05);
}
.mini-ing-grid label {
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    background: #fff;
    padding: 3px 6px;
    border-radius: 4px;
    border: 1px solid #eee;
}
.mini-ing-grid input { cursor: pointer; }
.mini-ing-grid label.active { background: var(--primary-light); border-color: var(--primary); }

.monday { background: #3498db; color: #fff; }
.tuesday { background: #9b59b6; }
.wednesday { background: #27ae60; }
.thursday { background: #795548; color: #fff; }
.friday { background: #607d8b; color: #fff; }
.saturday { background: #673ab7; color: #fff; }

.day-menu { padding: 14px 8px; font-size: 13px; line-height: 1.6; }

.info-note {
    background: rgba(255,255,255,0.4);
    border-radius: 8px;
    padding: 12px;
    font-size: 13px;
    color: #666;
    margin-top: 10px;
}

/* ============================================================
   🖨️ PRINT STYLES - Hides everything except the Bill
   ============================================================ */
@media print {
    @page { margin: 10mm; size: auto; }

    /* Hide ALL UI chrome, modals, and non-billing pages */
    .sidebar, 
    header, 
    .nav-links, 
    .profile-preview, 
    .bill-form, 
    .panel-header,
    .action-btn,
    .info-note,
    .modal-overlay,
    #pdf-preview-modal,
    .page-view:not(#view-billing) {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        overflow: hidden !important;
    }

    /* Reset ALL containers to prevent blank page overflow */
    *, *::before, *::after {
        box-shadow: none !important;
    }
    body, html {
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
    }
    .app-container, .main-content {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
    }

    /* Target the bill section specifically */
    #view-billing {
        display: block !important;
        visibility: visible !important;
        position: static !important;
        background: white !important;
        border: none !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        animation: none !important;
    }
    #view-billing .panel,
    #view-billing .panel.glass {
        display: block !important;
        background: white !important;
        border: none !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        backdrop-filter: none !important;
    }
    #bill-output {
        display: block !important;
        visibility: visible !important;
        position: static !important;
        background: white !important;
        border: none !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    /* Print header styling */
    .bill-print-header { 
        display: block !important; 
        text-align: center;
        border-bottom: 2px solid #000;
        margin-bottom: 15px;
        padding-bottom: 10px;
    }

    /* Table styling for paper */
    .bill-table {
        width: 100% !important;
        border-collapse: collapse !important;
        margin-top: 10px !important;
        table-layout: auto !important;
    }
    .bill-table th, .bill-table td {
        border: 1px solid #000 !important;
        padding: 8px 10px !important;
        font-size: 13px !important;
        color: #000 !important;
        white-space: nowrap !important;
    }
    .bill-table th { 
        background-color: #eee !important; 
        -webkit-print-color-adjust: exact; 
        print-color-adjust: exact;
        font-weight: 600 !important;
    }
}

/* ===== STOCK ===== */
.stock-form { margin-bottom: 20px; }
.stock-form h4 { margin-bottom: 14px; color: var(--text); }
.stock-inputs {
    display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap;
}
.stock-inputs .input-group { margin-bottom: 0; }

/* ===== REPORTS ===== */
.report-selector { margin-bottom: 24px; display: flex; align-items: center; gap: 14px; font-weight: 500; }

.report-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.report-card {
    background: white; border: 1.5px solid var(--border);
    border-radius: 10px; padding: 18px 14px; text-align: center;
}
.report-card h4 { font-size: 13px; font-weight: 600; color: var(--muted); }
.report-card p { font-size: 12px; color: #aaa; margin: 4px 0; }
.report-card h2 { font-size: 24px; font-weight: 700; color: var(--primary); }

/* ===== BILL ===== */
.bill-form { margin-bottom: 20px; }
.bill-output { padding: 20px; background: #f9f9f9; border-radius: 10px; }
.bill-output h3 { margin-bottom: 16px; font-size: 16px; }
.bill-table { width: 100%; border-collapse: collapse; }
.bill-table th, .bill-table td { padding: 10px 14px; border: 1px solid var(--border); font-size: 14px; }
.bill-table th { background: var(--primary); color: white; }

/* ===== SETTINGS ===== */
.settings-form { max-width: 700px; }
.settings-group { margin-bottom: 28px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.settings-group h4 { font-size: 15px; font-weight: 700; margin-bottom: 16px; color: var(--primary); }
.norms-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

/* ===== TOAST ===== */
.toast {
    position: fixed; bottom: -80px; right: 24px;
    background: var(--primary); color: white;
    padding: 14px 22px; border-radius: 10px;
    font-size: 14px; font-weight: 600;
    box-shadow: 0 8px 24px rgba(39,174,96,0.35);
    transition: bottom 0.4s cubic-bezier(0.68,-0.55,0.27,1.55);
    z-index: 9999;
}
.toast.show { bottom: 24px; }

/* ===== SIDEBAR OVERLAY BACKDROP ===== */
.sidebar-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 190;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 1024px) {
    :root { --sidebar-w: 0px; }
    .sidebar { transform: translateX(-100%); width: 270px; visibility: hidden; }
    .sidebar.open { transform: translateX(0); visibility: visible; }
    .main-content { margin-left: 0; }
    .hamburger-btn { display: block; }
    .header-left h1 { font-size: 18px; }
    .overview-cards { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .split-forms { grid-template-columns: 1fr; }
    .page-view { padding: 14px 16px; }
    .panel { padding: 16px; }
    .stock-dashboard-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 768px) {
    /* Hide trial/license badge in header on mobile layout */
    #license-badge-container { display: none !important; }
    
    /* Prevent iOS auto-zoom on inputs */
    input, select, textarea { font-size: 15px !important; }
    
    /* Touch scrolling for tables */
    .table-responsive, .norms-scroll-container, .pdf-preview-container {
        -webkit-overflow-scrolling: touch;
        border-radius: var(--radius-sm);
    }
}

@media (max-width: 600px) {
    /* Prevent page-wide horizontal scroll & white margin */
    html, body, .app-container, .main-content {
        overflow-x: hidden !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    .page-view {
        padding: 14px 12px !important;
        max-width: 100% !important;
        overflow-x: hidden;
    }
    .overview-cards { grid-template-columns: 1fr; }

    header {
        padding: 10px 12px !important;
        max-width: 100% !important;
        overflow: hidden;
    }

    .header-left {
        gap: 8px !important;
        min-width: 0;
        flex: 1;
        overflow: hidden;
    }

    .header-left h1 {
        font-size: 15px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-left .subtitle {
        font-size: 11px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Live Stock Inventory Header stack on mobile */
    .stock-grid-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 6px !important;
        margin-top: 20px !important;
    }

    .stock-grid-header h3 {
        font-size: 15px !important;
    }

    .stock-grid-header .year-badge {
        font-size: 11px !important;
        padding: 4px 10px !important;
    }

    /* Backup & Security Buttons responsive grid */
    .backup-btn-grid {
        grid-template-columns: 1fr !important;
        min-width: 0 !important;
        width: 100% !important;
    }

    .overview-cards { grid-template-columns: 1fr; }
    .header-right { gap: 6px !important; flex-shrink: 0; }
    .header-right > div { margin-right: 0 !important; }
    .header-right .year-badge { display: none; }
    .header-right div[style*="width: 140px"] {
        width: 38px !important;
        padding: 0 !important;
        overflow: hidden;
    }
    .header-right div[style*="width: 140px"] span:nth-child(2) {
        display: none !important;
    }
    .total-bar { gap: 12px; padding: 14px; font-size: 12px; }
    .form-actions { flex-direction: column; gap: 8px; }
    .form-actions .action-btn { width: 100% !important; }
    .menu-grid { grid-template-columns: 1fr; }
    .menu-actions-cell { grid-column: span 1; }
    .stock-dashboard-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .card-info h2 { font-size: 24px; }
    .card-icon { font-size: 28px; width: 44px; height: 44px; }
    .form-row-top { flex-direction: column; align-items: stretch; gap: 12px; }
    .form-row-top .input-group { width: 100% !important; }
    .form-row-top .action-btn { width: 100% !important; margin-top: 5px; }
    
    /* Panel flex rows stack on mobile */
    .settings-group div[style*="flex-wrap: nowrap"],
    .panel div[style*="flex-wrap: wrap"] { 
        flex-direction: column !important; 
        align-items: stretch !important;
        gap: 12px !important; 
    }
    .settings-group div[style*="flex-wrap: nowrap"] .input-group,
    .panel div[style*="flex-wrap: wrap"] .action-btn { 
        width: 100% !important; 
        margin: 0 !important; 
    }
    
    /* Settings Grid */
    .norms-grid { grid-template-columns: 1fr; }
}

/* ===== CUSTOM MODAL OVERLAY ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.modal-box {
    background: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: var(--radius);
    width: 90%;
    max-width: 480px;
    padding: 28px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}
.modal-overlay.active .modal-box {
    transform: translateY(0);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}
.modal-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--muted);
    transition: color 0.2s;
    line-height: 1;
}
.modal-close-btn:hover {
    color: var(--red);
}
.modal-body {
    margin-bottom: 24px;
}
.modal-body .input-group {
    margin-bottom: 16px;
}
.modal-body .input-group:last-child {
    margin-bottom: 0;
}
.modal-body label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}
.modal-footer .action-btn {
    width: auto;
    padding: 10px 20px;
    height: auto;
}


/* Week Filter Buttons */
.filter-group {
    display: flex;
    gap: 8px;
    background: #f1f5f9;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    flex-wrap: wrap;
}

.filter-btn {
    background: transparent;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    background: #e2e8f0;
    color: #334155;
}

.filter-btn.active {
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border: 1px solid #cbd5e1;
}
