:root {
    /* Colors - Brightened the Primary for a less "dark" feel */
    --primary: #1e293b;
    --primary-light: #334155;
    --secondary: #2563eb;
    --accent: #60a5fa;
    --bg: #f8fafc;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    
    /* Variables for Consistency */
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

*, *::before, *::after { box-sizing: border-box; }

body { 
    margin: 0; 
    font-family: 'Inter', system-ui, -apple-system, sans-serif; 
    background: var(--bg); 
    color: var(--text-main); 
    font-size: 15px; 
    line-height: 1.45;
}

/* --- UTILITIES --- */
.hidden { display: none !important; }
.d-flex { display: flex; }
.gap-20 { gap: 20px; }
.flex-1 { flex: 1; } 
.flex-2 { flex: 2; }
.mb-10 { margin-bottom: 10px; }
.text-right { text-align: right !important; }
.font-weight-bold { font-weight: bold !important; }
.text-blue { color: #2563eb !important; }
.text-orange { color: #f59e0b !important; }
.text-green { color: #10b981 !important; }
.text-red { color: #ef4444 !important; }

*:focus-visible { outline: 3px solid #facc15 !important; outline-offset: 2px !important; }

/* --- LOGIN PAGE --- */
.login-bg { height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e293b 0%, #2563eb 100%); }
.login-card { background: white; width: 100%; max-width: 420px; padding: 40px; border-radius: 16px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); box-sizing: border-box; }
.login-header { text-align: center; margin-bottom: 30px; }
.login-header h2 { margin: 0; font-size: 28px; color: var(--text-main); font-weight: 800; }
.login-header p { margin: 5px 0 0 0; color: var(--text-muted); font-size: 16px; }

/* --- MAIN LAYOUT --- */
.app-container { display: flex; height: 100vh; overflow: hidden; background: var(--bg); }
aside { width: 240px; background: var(--primary); color: white; padding: 16px; display: flex; flex-direction: column; overflow-y: auto; transition: 0.3s; }
main { flex: 1; padding: 20px; overflow-y: auto; position: relative; }

/* Sidebar Typography */
#sys-title { font-size: 1.5rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; margin: 10px 0; color: white; }
#sys-logo { max-width: 100%; max-height: 80px; margin-bottom: 15px; border-radius: 8px; background: white; padding: 8px; box-sizing: border-box; object-fit: contain; }
#sys-user { font-size: 14px; margin-bottom: 20px; opacity: 0.8; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 15px; }
.sidebar-footer { margin-top: auto; padding-top: 15px; text-align: center; font-size: 11px; color: rgba(255,255,255,0.4); border-top: 1px solid rgba(255,255,255,0.1); }

/* --- COMPONENTS --- */
.card { background: white; padding: 18px 20px; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; border: 1px solid #e2e8f0; }
.input { width: 100%; padding: 10px 14px; margin-bottom: 12px; border: 2px solid #e2e8f0; border-radius: 8px; box-sizing: border-box; font-size: 15px; transition: all 0.2s; background: #fcfdfe; }
.input:focus { border-color: var(--secondary); background: white; outline: none; box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1); }
label { font-weight: 600; margin-bottom: 5px; display: block; color: #334155; font-size: 13px; }

/* --- BUTTONS & NAVS --- */
.btn { width: 100%; padding: 10px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; transition: 0.2s; font-size: 15px; }
.btn:disabled { opacity: 0.7; cursor: not-allowed; }
.btn-blue { background: var(--secondary); color: white; text-align: center; }
.btn-blue:hover:not(:disabled) { background: #1d4ed8; transform: translateY(-1px); }
.btn-green { background: var(--success); color: white; text-align: center; }
.btn-green:hover:not(:disabled) { background: #059669; }
.btn-red { background: var(--danger); color: white; text-align: center; }
.btn-red:hover:not(:disabled) { background: #dc2626; }
.btn-gray { background: #64748b; color: white; text-align: center; }

.nav-btn { width: 100%; padding: 12px 15px; text-align: left; background: none; border: none; color: white; cursor: pointer; border-radius: 8px; margin: 4px 0; font-size: 1rem; display: flex; align-items: center; transition: 0.2s; }
.nav-btn:hover { background: rgba(255,255,255,0.1); }
.nav-btn.active { background: var(--secondary); font-weight: 600; box-shadow: inset 4px 0 0 var(--accent); }

/* --- NEW REPORT SIDEBAR --- */
.report-group-title { font-size: 12px; text-transform: uppercase; color: var(--text-muted); font-weight: 800; margin: 15px 0 5px 5px; letter-spacing: 0.5px; }
.nav-btn-sub { width: 100%; text-align: left; background: none; border: none; padding: 8px 10px; margin-bottom: 2px; border-radius: 6px; color: var(--text-main); cursor: pointer; transition: 0.2s; font-size: 14px; }
.nav-btn-sub:hover { background: #e2e8f0; }
.nav-btn-sub.active { background: var(--secondary); color: white; font-weight: bold; }

/* --- BADGES (For Audits) --- */
.badge { padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 800; display: inline-block; text-transform: uppercase; letter-spacing: 0.5px;}
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-red { background: #fee2e2; color: #b91c1c; }

/* --- POS GRID & CONTROLS --- */
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 15px; }
.pos-card { background: white; border: 1px solid #e2e8f0; padding: 20px; border-radius: var(--radius); cursor: pointer; transition: 0.2s; text-align: center; display: flex; flex-direction: column; justify-content: center; min-height: 120px; }
.pos-card:hover { border-color: var(--secondary); transform: translateY(-3px); box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); }
.pos-card h4 { margin: 0 0 8px 0; font-size: 1.1rem; color: var(--text-main); }
.pos-card .price { font-size: 1.2rem; font-weight: 800; color: var(--success); }

/* --- TABLES --- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px; border-bottom: 1px solid #e2e8f0; }
th { background: #f8fafc; font-weight: 700; color: var(--text-muted); text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em; text-align: left;}
tbody tr:hover { background-color: #f1f5f9; }

/* --- CART & RECEIPT --- */
.cart-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid #f1f5f9; }
.cart-item-title { flex: 2; font-weight: 600; }
.cart-item-total { font-weight: 700; color: var(--text-main); }

/* --- AUTOCOMPLETE SEARCH DROPDOWN --- */
.purchase-search-area { position: relative; }
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--shadow);
}
.search-result-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
}
.search-result-item:hover {
    background-color: #f8fafc;
    color: var(--secondary);
}

@media (max-width: 768px) {
    aside { width: 70px; padding: 10px; }
    #sys-title, #sys-user, .nav-btn span, .sidebar-footer { display: none; }
    .pos-grid { grid-template-columns: 1fr 1fr; }
    .d-flex { flex-direction: column; }
}

/* --- PRINTING LOGIC --- */
#print-area { display: none; } 

.receipt-container { max-width: 320px; margin: auto; }

@media print {
    @page { margin: 15mm; size: A4; }
    body { background: white; margin: 0; font-size: 11pt; color: #000; }
    body * { visibility: hidden; }
    
    .hide-on-print { display: none !important; }
    
    #print-area, #print-area * { visibility: visible; }
    #print-area { 
        display: block !important; 
        position: absolute; 
        left: 0; 
        top: 0; 
        width: 100%; 
        padding: 0; 
        box-sizing: border-box;
    }
    
    /* De-congest Tables */
    .statement-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
    .statement-table th { 
        background: #f8fafc !important; 
        -webkit-print-color-adjust: exact; 
        print-color-adjust: exact; 
        font-size: 10pt !important;
        padding: 8px !important;
        border-bottom: 2px solid #cbd5e1;
    }
    .statement-table td { 
        font-size: 10pt !important; 
        padding: 8px !important; 
        line-height: 1.4;
        border-bottom: 1px solid #e2e8f0;
    }
    .statement-table tr { page-break-inside: avoid; } /* Prevents rows splitting across pages */
    
    .text-right { text-align: right !important; font-variant-numeric: tabular-nums; }
}
/* Scrollable Container Wrapper */
.scrollable-table-container {
    max-height: 360px; /* Keeps long lists from pushing the page out of view - adjust as needed */
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Sticky Header so column titles stay visible during scroll */
.scrollable-table-container table thead th {
    position: sticky;
    top: 0;
    background-color: #f8fafc; /* Adjust background to match theme */
    z-index: 2;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Smooth custom scrollbar (optional) */
.scrollable-table-container::-webkit-scrollbar {
    width: 6px;
}
.scrollable-table-container::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 4px;
}

/* --- TOAST NOTIFICATIONS --- */
/* Non-blocking alternative to alert() for routine confirmations - unlike alert(), this
   doesn't force the browser to drop out of fullscreen mode. */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast {
    background: var(--primary);
    color: white;
    padding: 14px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    font-size: 14px;
    font-weight: 600;
    max-width: 320px;
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.3s, transform 0.3s;
}
.toast-hide { opacity: 0; transform: translateX(20px); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

/* --- GENERAL POLISH --- */
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
.empty-state { padding: 24px 10px; text-align: center; color: var(--text-muted); font-size: 14px; }

/* --- DASHBOARD --- */
.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

.dash-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 15px;
}

.kpi-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-left: 4px solid var(--secondary);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 14px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08); }
.kpi-card .kpi-icon { font-size: 26px; line-height: 1; }
.kpi-card .kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 4px; }
.kpi-card .kpi-value { font-size: 20px; font-weight: 800; color: var(--text-main); }
.kpi-card.kpi-blue { border-left-color: var(--secondary); }
.kpi-card.kpi-green { border-left-color: var(--success); }
.kpi-card.kpi-red { border-left-color: var(--danger); }
.kpi-card.kpi-orange { border-left-color: #f59e0b; }

.dash-scroll-list {
    max-height: 280px;
    overflow-y: auto;
}
.dash-scroll-list::-webkit-scrollbar { width: 6px; }
.dash-scroll-list::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 4px; }

.dash-list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 4px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
}
.dash-list-row:last-child { border-bottom: none; }

@media (max-width: 768px) {
    .dash-kpi-grid { grid-template-columns: 1fr 1fr; }
    .dash-header { flex-direction: column; align-items: flex-start; }
}

/* ===== Page-level styles (moved from <style> in index.php head) ===== */
.report-tab-content { display: none; }
.report-tab-content.active { display: block; }
.statement-table { width: 100%; border-collapse: collapse; margin-top: 15px; background: white; }
.statement-table th, .statement-table td { padding: 12px; border-bottom: 1px solid #e2e8f0; text-align: left; }
.statement-table th { background: #f8fafc; font-weight: bold; }
.statement-table tr.total-row td { font-weight: bold; background: #f1f5f9; border-top: 2px solid #cbd5e1; }
.text-red { color: #ef4444; }
.text-green { color: #10b981; }
.text-blue { color: #2563eb; }
.text-orange { color: #f59e0b; }
.empty-state { text-align: center; color: #94a3b8; padding: 20px; font-style: italic; }
.debt-alert-banner { background: #fee2e2; color: #b91c1c; padding: 15px; border-radius: 8px; border: 1px solid #f87171; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-size: 14px; }
.debt-alert-banner:hover { background: #fecaca; }
.chart-container { position: relative; height: 300px; width: 100%; margin-top: 15px; }
.sum-card { background: white; border-radius: 8px; padding: 20px; flex: 1; border: 1px solid #e2e8f0; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.sum-card h4 { margin: 0 0 10px 0; color: #64748b; font-size: 14px; text-transform: uppercase; }
.sum-card span { font-size: 24px; font-weight: 800; }

/* ===== Add-Product "smart assist" styles (moved from index.php Inventory section) ===== */
/* Scoped styling for the Add Product "smart assist" card — namespaced
   under .sc- so it can't collide with anything in the main stylesheet. */
.sc-heading { margin: 18px 0 14px 0; font-size: 15px; font-weight: 700; color: #0f172a; letter-spacing: -0.01em; }
.sc-form { display: flex; flex-direction: column; gap: 10px; }
.sc-input { margin: 0 !important; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.sc-input:focus { border-color: #2563eb !important; box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.sc-label { font-size: 12px; color: #64748b; margin: 2px 0 0 0; }
.sc-hint { font-size: 11px; color: #94a3b8; margin: 0; }
.sc-submit { margin-top: 4px; }

.sc-assist {
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 12.5px;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    animation: sc-fade-in 0.15s ease;
}
.sc-assist.hidden { display: none; }
.sc-assist-warn { background: #fff7ed; border: 1px solid #fdba74; color: #9a3412; }
.sc-assist-smart { background: #eff6ff; border: 1px solid #93c5fd; color: #1e3a8a; }
.sc-assist-icon { font-size: 15px; line-height: 1.4; flex-shrink: 0; }
.sc-assist-body { flex: 1; }
.sc-assist-title { font-weight: 700; display: block; margin-bottom: 1px; }
.sc-assist-action {
    display: inline-block;
    margin-top: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    border: none;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.sc-assist-warn .sc-assist-action { background: #fdba74; color: #7c2d12; }
.sc-assist-smart .sc-assist-action { background: #93c5fd; color: #1e3a8a; }
.sc-assist-dismiss {
    background: none; border: none; cursor: pointer; color: inherit;
    opacity: 0.6; font-size: 13px; padding: 0 2px; flex-shrink: 0;
}
.sc-assist-dismiss:hover { opacity: 1; }
@keyframes sc-fade-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Responsive / compact fit overrides (was responsive-fit.css) — keep LAST ===== */
/* =====================================================================
   responsive-fit.css  —  load AFTER style.css and after the inline <style>
   in index.php (put the <link> just before </head>).
   Purpose: make the system fit normal laptop screens without browser zoom.
   Nothing in style.css needs to be deleted; this file only overrides.
   ===================================================================== */

/* ---------- 0. Root fixes (all screen sizes) ---------- */

/* 100vh is taller than the visible area on mobile/with toolbars; dvh is exact */
.app-container { height: 100vh; height: 100dvh; }

/* Flex children default to min-width:auto, so a wide table or input row
   refuses to shrink and pushes the page sideways. This is the #1 reason
   screens "don't fit". */
main, .d-flex > *, .flex-1, .flex-2, .reports-content { min-width: 0; }
aside { flex-shrink: 0; }
.input { min-width: 0; }
select.input { max-width: 100%; }

/* REPORTS MENU: the report buttons were inline-block, so the browser measured the
   menu as "a whole group of buttons on one line" (~820px) and gave it most of the
   screen. Block buttons + a fixed menu width gives the reports the remaining space. */
.nav-btn-sub { display: block; }
.reports-sidebar { flex: 0 0 240px; width: 240px; max-height: calc(100vh - 30px); max-height: calc(100dvh - 30px); overflow-y: auto; }
.reports-content { flex: 1 1 0; }

/* Any table wrapper scrolls sideways instead of breaking the layout */
.table-container,
.scrollable-table-container,
.reports-content .report-tab-content { overflow-x: auto; }

/* Report filter bar + summary cards: allow wrapping (they had no flex-wrap) */
#view-reports > .hide-on-print { flex-wrap: wrap; }
#view-reports > .hide-on-print .input { width: auto; max-width: 100%; }
.sum-card { min-width: 140px; }

/* Modal cards: .login-card has 40px padding meant for the login page */
.login-bg[id$="-modal"] .login-card,
.login-bg[id$="-modal"] form.login-card {
    padding: 22px;
    max-width: 96vw;
    max-height: 92vh;
    max-height: 92dvh;
    overflow-y: auto;
}

/* POS: right-hand bill panel scrolls inside itself instead of making the
   whole page taller than the screen */
#view-pos .d-flex > .card {
    position: sticky;
    top: 0;
    max-height: calc(100vh - 110px);
    max-height: calc(100dvh - 110px);
    overflow-y: auto;
}

/* ---------- 1. Laptops (≈1366px wide, or 1920px at 125–150% Windows scaling) ---------- */
@media (max-width: 1400px) {
    body { font-size: 14px; }
    aside { width: 210px; padding: 12px; }
    main { padding: 14px; }

    #top-title { font-size: 1.35rem; }
    #top-view { font-size: 12px; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.05rem; }

    .card { padding: 14px 16px; margin-bottom: 12px; }
    .input { padding: 8px 12px; margin-bottom: 10px; font-size: 14px; }
    .btn { padding: 9px; font-size: 14px; }
    label { font-size: 12px; margin-bottom: 4px; }

    th, td { padding: 8px; }
    .statement-table th, .statement-table td { padding: 8px 10px; font-size: 13px; }

    .nav-btn { padding: 9px 12px; margin: 2px 0; font-size: 0.95rem; }
    #sys-title { font-size: 1.2rem; margin: 6px 0; }
    #sys-logo { max-height: 56px; margin-bottom: 8px; padding: 6px; }
    #sys-user { margin-bottom: 12px; padding-bottom: 10px; font-size: 13px; }

    .gap-20 { gap: 14px; }
    .pos-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
    .pos-card { padding: 14px; min-height: 96px; }
    .pos-card h4 { font-size: 1rem; }
    .pos-card .price { font-size: 1.05rem; }

    .kpi-card { padding: 14px 16px; }
    .kpi-card .kpi-value { font-size: 18px; }
    .sum-card { padding: 14px; }
    .sum-card span { font-size: 20px; }
    .reports-sidebar { flex-basis: 210px; width: 210px; min-width: 0 !important; padding: 10px !important; }
    .nav-btn-sub { padding: 7px 10px; font-size: 13px; }
    .chart-container { height: 250px; }
}

/* ---------- 2. Short screens (laptops with ~720–800px of usable height) ---------- */
@media (max-height: 800px) {
    aside hr { margin: 6px 0 10px 0 !important; }
    #sys-logo { max-height: 44px; }
    .nav-btn { padding: 7px 12px; }
    .sidebar-footer { padding-top: 8px; font-size: 10px; }
    #pos-cart-items { max-height: 28vh !important; }
}

/* ---------- 3. Small laptops / tablets landscape ---------- */
@media (max-width: 1100px) {
    aside { width: 180px; }

    /* Side-by-side form + table screens stack vertically */
    .view-section.d-flex { flex-direction: column; }
    .view-section.d-flex > .flex-1,
    .view-section.d-flex > .flex-2 { flex: none; width: 100%; }

    /* Dashboard rows stack */
    #view-dashboard .d-flex { flex-direction: column; }

    /* Reports: menu goes on top instead of eating 240px on the left */
    #view-reports .d-flex { flex-direction: column; }
    #view-reports .reports-content { flex: none; width: 100%; }
    .reports-sidebar {
        position: static !important;
        flex: none !important;
        width: 100% !important;
        min-width: 0 !important;
        max-height: 200px;
        overflow-y: auto;
    }
}

/* ---------- 4. Tablets portrait (replaces the old 768px rule that hid every
        nav label — the label text AND emoji are inside <span>, so the menu
        showed up as empty buttons) ---------- */
@media (max-width: 900px) {
    aside { width: 150px; padding: 8px; }
    #sys-title, #sys-user { display: block; }
    .nav-btn span { display: inline; }
    .nav-btn { font-size: 0.85rem; padding: 8px; }
    .sidebar-footer { display: block; }
    .pos-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
    /* POS: bill panel goes below the product grid */
    #view-pos .d-flex { flex-direction: column; }
    #view-pos .d-flex > .card { position: static; max-height: none; }
}

/* ---------- 5. Phones: sidebar becomes a scrolling top bar ---------- */
@media (max-width: 600px) {
    .app-container { flex-direction: column; }
    aside {
        width: 100%;
        flex-direction: row;
        align-items: center;
        gap: 4px;
        padding: 6px;
        overflow-x: auto;
        overflow-y: hidden;
    }
    aside > #sys-logo, aside > #sys-title, aside > #sys-user,
    aside > hr, aside > .sidebar-footer { display: none !important; }
    #admin-nav { display: flex; gap: 4px; }
    .nav-btn { width: auto; white-space: nowrap; margin: 0; }
    aside > .nav-btn[data-view="password"] { margin-top: 0 !important; }
    main { padding: 10px; }
    .dash-kpi-grid { grid-template-columns: 1fr; }
}

/* ---------- 6. Printing: none of the above may affect printed reports ---------- */
@media print {
    .reports-content .report-tab-content,
    .table-container,
    .scrollable-table-container { overflow: visible !important; }
    #view-pos .d-flex > .card { position: static; max-height: none; }
}

/* =====================================================================
   RESPONSIVE POLISH + SUPPLIER PAYABLES LEDGER
   (appended last so it wins over the earlier rules; nothing above was removed)
   ===================================================================== */

/* ---------- Base safety nets for every screen ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img, svg, canvas, video { max-width: 100%; }
img { height: auto; }
main { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.btn { max-width: 100%; }
.btn-orange { background: #f59e0b; color: #fff; text-align: center; }
.btn-orange:hover:not(:disabled) { background: #d97706; }
.text-muted { color: #64748b !important; }

#view-suppliers .card { max-width: 100%; overflow-x: clip; }

/* Fluid tables: scroll sideways inside their card instead of stretching the page */
.table-container, .scrollable-table-container { max-width: 100%; -webkit-overflow-scrolling: touch; }

/* ---------- Supplier filters ---------- */
.sup-filter-bar {
    display: grid;
    /* wraps onto new lines as the card narrows, so nothing is ever clipped */
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    max-width: 100%;
    align-items: end;
    margin-bottom: 8px;
}
.sup-filter-field { min-width: 0; }
.sup-filter-search { grid-column: 1 / -1; }
.sup-filter-field input[type="date"] { min-width: 0; }
.sup-filter-field .input { margin-bottom: 0; }
.sup-filter-field label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #64748b; }
.sup-filter-reset .btn { width: 100%; padding: 10px 16px; }
.sup-filter-summary { font-size: 13px; color: #475569; margin: 6px 0 10px; }

/* ---------- Supplier ledger table ---------- */
.sup-ledger-scroll { max-height: min(70vh, 640px); overflow: auto; border: 1px solid #e2e8f0; border-radius: 6px; }
.sup-ledger-table { width: 100%; margin: 0; }
.sup-ledger-table thead th { position: sticky; top: 0; background: #f8fafc; z-index: 1; }
.sup-ledger-table td { vertical-align: top; }
.sup-col-name { width: 20%; }
.sup-col-ledger { width: 56%; }
.sup-col-actions { width: 24%; }
.sup-row:hover { background: transparent; }

.sup-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.sup-actions .btn,
.sup-inv-actions .btn { width: auto; padding: 5px 10px; font-size: 12px; white-space: nowrap; }

.sup-inv-box { background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 6px; }
.sup-inv-row {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 6px 14px; padding: 8px 10px; border-bottom: 1px solid #e2e8f0; font-size: 13px;
    border-left: 4px solid transparent;
}
.sup-inv-row:last-child { border-bottom: none; }
.sup-inv-row.is-uncleared { border-left-color: #ef4444; background: #fff; }
.sup-inv-row.is-cleared { border-left-color: #10b981; background: #f1f5f9; opacity: .9; }
.sup-inv-main { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; flex: 1 1 100%; min-width: 0; }
.sup-inv-date { font-weight: 700; color: #1e293b; white-space: nowrap; }
.sup-inv-no { color: #475569; overflow-wrap: anywhere; }
.sup-inv-amounts { display: flex; flex-wrap: wrap; gap: 2px 12px; color: #475569; flex: 1 1 100%; }
.sup-inv-actions { display: flex; flex-wrap: wrap; gap: 5px; flex: 1 1 100%; }

.sup-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.sup-badge-red { background: #fee2e2; color: #b91c1c; }
.sup-badge-orange { background: #ffedd5; color: #9a3412; }
.sup-badge-green { background: #d1fae5; color: #065f46; }
.sup-badge-blue { background: #dbeafe; color: #1e40af; }

/* ---------- Tablets / small laptops: Supplier view was the one screen that kept
   form + ledger side by side (its flex row is inside the section, not the section
   itself), so the ledger got squeezed. Stack it like the other screens. ---------- */
@media (max-width: 1100px) {
    #view-suppliers > .d-flex { flex-direction: column; }
    #view-suppliers > .d-flex > .flex-1,
    #view-suppliers > .d-flex > .flex-2 { flex: none; width: 100%; }
}

/* ---------- Phones: ledger rows become stacked cards ---------- */
@media (max-width: 700px) {

    .sup-ledger-scroll { max-height: none; border: none; overflow: visible; }
    .sup-ledger-table, .sup-ledger-table tbody, .sup-ledger-table tr, .sup-ledger-table td { display: block; width: 100% !important; }
    .sup-ledger-table thead { display: none; }
    .sup-ledger-table tr.sup-row { border: 1px solid #e2e8f0; border-radius: 10px; margin-bottom: 12px; padding: 4px 0; background: #fff; }
    .sup-ledger-table td { border-bottom: none; padding: 8px 12px; }
    .sup-ledger-table td[data-label]::before {
        content: attr(data-label); display: block; font-size: 10px; font-weight: 800;
        text-transform: uppercase; letter-spacing: .06em; color: #94a3b8; margin-bottom: 4px;
    }
    .sup-inv-row { flex-direction: column; align-items: stretch; }
    .sup-inv-main, .sup-inv-amounts { flex: none; }
    .sup-actions .btn, .sup-inv-actions .btn { flex: 1 1 auto; padding: 9px 10px; }
}

/* ---------- Phones: general fit ---------- */
@media (max-width: 600px) {
    /* the top nav bar must not take the page's height; main gets the rest and scrolls */
    .app-container { height: 100vh; height: 100dvh; }
    main { min-height: 0; flex: 1 1 auto; padding: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
    aside { flex: 0 0 auto; padding-top: calc(6px + env(safe-area-inset-top)); }
    h2 { font-size: 1.15rem; }
    .card { padding: 12px; }
    .gap-20 { gap: 10px; }

    /* 16px inputs stop iOS from zooming the page when a field is focused */
    .input, select.input, input.input, textarea.input { font-size: 16px; }

    .login-bg[id$="-modal"] .login-card,
    .login-bg[id$="-modal"] form.login-card { width: 96vw; padding: 14px; }
    .login-card { padding: 22px; }
    .pos-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .sum-card { min-width: 100%; }
    .chart-container { height: 220px; }
}

/* Touch screens: comfortable tap targets */
@media (pointer: coarse) {
    .btn, .nav-btn, .nav-btn-sub { min-height: 40px; }
    .input { min-height: 42px; }
}

/* Notched phones / landscape */
@supports (padding: max(0px)) {
    .app-container { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}

/* Small dialogs (payment, refund, credit) were inheriting the 96vw modal width and
   stretched across the whole screen. Keep them a readable, centred size. */
#redeem-modal .login-card, #refund-modal .login-card, #credit-modal .login-card,
#redeem-modal form.login-card, #refund-modal form.login-card, #credit-modal form.login-card {
    width: 100%; max-width: min(480px, 96vw);
}
.login-bg[id$="-modal"] { overflow-y: auto; padding: 12px; box-sizing: border-box; }
.login-bg[id$="-modal"] .login-card { margin: auto; }

/* Printing must be unaffected by the above */
@media print {
    .sup-ledger-scroll, .sup-inv-box { max-height: none !important; overflow: visible !important; }
}

/* ---------------------------------------------------------------------
   OPTIONAL quick stop-gap (same effect as your browser zoom, but built in).
   Un-comment ONE line if you want everything ~10% smaller regardless of
   the rules above. Works in Chrome, Edge, Safari and Firefox 126+.
   --------------------------------------------------------------------- */
/* html { zoom: 0.9; } */
