﻿*{box-sizing:border-box}
:root{--primary:#0a84ff;--primary-dark:#0668cc;--bg:#f5f7fb;--panel:#fff;--text:#172033;--muted:#718096;--border:#e5e9f0;--sidebar:#111827;--success:#16a34a;--danger:#dc2626}
body{margin:0;font-family:Inter,Segoe UI,Arial,sans-serif;background:var(--bg);color:var(--text)}
button,input{font:inherit}.app-shell{display:flex;min-height:100vh}.sidebar{width:245px;background:var(--sidebar);color:#fff;display:flex;flex-direction:column;padding:22px 14px;position:fixed;inset:0 auto 0 0}.brand{display:flex;align-items:center;gap:12px;padding:4px 10px 28px}.brand-mark{width:42px;height:42px;border-radius:11px;background:var(--primary);display:grid;place-items:center;font-size:22px;font-weight:800}.brand h1{margin:0;font-size:19px;letter-spacing:1px}.brand span{color:#9ca3af;font-size:12px}.nav{display:grid;gap:6px}.nav-item{border:0;background:transparent;color:#cbd5e1;text-align:left;padding:12px 14px;border-radius:9px;cursor:pointer;display:flex;align-items:center;gap:12px}.nav-item:hover,.nav-item.active{background:#1f2937;color:#fff}.nav-item.active{box-shadow:inset 3px 0 var(--primary)}.sidebar-bottom{margin-top:auto}.api-status{font-size:12px;color:#9ca3af;display:flex;align-items:center;gap:7px;padding:12px}.api-status span:first-child{width:8px;height:8px;border-radius:50%;background:#f59e0b}.logout-btn{width:100%;border:0;background:#1f2937;color:#e5e7eb;padding:11px;border-radius:8px;cursor:pointer}.main{margin-left:245px;width:calc(100% - 245px);min-height:100vh}.topbar{height:82px;background:#fff;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;padding:0 30px;position:sticky;top:0;z-index:5}.eyebrow{font-size:11px;color:var(--primary);font-weight:800;letter-spacing:1.2px}.topbar h2{margin:3px 0 0;font-size:24px}.user-box{display:flex;align-items:center;gap:10px}.user-box small{display:block;color:var(--muted)}.avatar{width:38px;height:38px;border-radius:50%;background:#e8f3ff;color:var(--primary);display:grid;place-items:center;font-weight:700}.page{display:none;padding:28px}.page.active{display:block}.welcome,.panel,.stat-card{background:var(--panel);border:1px solid var(--border);border-radius:14px}.welcome{padding:24px;display:flex;justify-content:space-between;align-items:center;margin-bottom:20px}.welcome h3,.panel h3,.page-toolbar h3{margin:0 0 5px}.welcome p,.panel p,.page-toolbar p{margin:0;color:var(--muted);font-size:14px}.primary{border:0;background:var(--primary);color:#fff;border-radius:8px;padding:11px 18px;cursor:pointer}.primary:hover{background:var(--primary-dark)}.stats-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:16px;margin-bottom:20px}.stat-card{padding:20px}.stat-card span{font-size:13px;color:var(--muted)}.stat-card strong{display:block;font-size:25px;margin:8px 0}.stat-card small{color:#9aa3b2}.content-grid{display:grid;grid-template-columns:1fr 1fr;gap:20px}.panel{padding:20px}.panel-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px}.link-btn{border:0;background:transparent;color:var(--primary);cursor:pointer}.overview-list{display:grid;gap:10px}.overview-list div{display:flex;justify-content:space-between;padding:13px;border-radius:8px;background:#f8fafc}.quick-actions{display:grid;grid-template-columns:1fr 1fr;gap:10px}.quick-actions button{border:1px solid var(--border);background:#fff;padding:14px;border-radius:8px;text-align:left;cursor:pointer}.page-toolbar{display:flex;justify-content:space-between;align-items:center;margin-bottom:18px}.page-toolbar input{width:320px;padding:11px 13px;border:1px solid var(--border);border-radius:8px;outline:0}.pos-layout{display:grid;grid-template-columns:1fr 360px;gap:18px}.pos-products{display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:14px}.product-card{background:#fff;border:1px solid var(--border);border-radius:12px;overflow:hidden;cursor:pointer}.product-card:hover{border-color:#a9d5ff;transform:translateY(-1px)}.product-card img{width:100%;height:130px;object-fit:contain;background:#f8fafc}.product-info{padding:13px}.product-info h4{margin:0 0 6px}.price{font-weight:800;color:var(--primary)}.stock{font-size:12px;color:var(--muted);margin-top:5px}.cart{height:fit-content;position:sticky;top:100px}.cart-items{display:grid;gap:10px;max-height:390px;overflow:auto}.cart-row{display:grid;grid-template-columns:1fr auto;gap:8px;padding-bottom:10px;border-bottom:1px solid var(--border)}.cart-row strong{font-size:14px}.cart-row small{display:block;color:var(--muted)}.qty-controls{display:flex;align-items:center;gap:7px}.qty-controls button{width:25px;height:25px;border:1px solid var(--border);background:#fff;border-radius:5px;cursor:pointer}.totals{border-top:1px solid var(--border);margin-top:15px;padding-top:14px;display:grid;gap:9px}.totals div{display:flex;justify-content:space-between}.totals .grand{font-size:18px;font-weight:800;padding-top:8px}.full{width:100%;margin-top:16px}.empty{padding:30px 5px;text-align:center;color:var(--muted)}.table-panel{padding:0;overflow:hidden}.table-wrap{overflow:auto}table{width:100%;border-collapse:collapse}th,td{padding:14px 16px;border-bottom:1px solid var(--border);text-align:left;font-size:13px}th{background:#f8fafc;color:#667085;font-size:12px;text-transform:uppercase}.location-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:12px}.location{background:#f8fafc;padding:15px;border-radius:10px}.location strong{display:block;font-size:20px}.placeholder{text-align:center;padding:70px}.toast{position:fixed;right:25px;bottom:25px;background:#111827;color:#fff;padding:12px 16px;border-radius:8px;display:none}.toast.show{display:block}@media(max-width:1000px){.stats-grid{grid-template-columns:repeat(2,1fr)}.content-grid,.pos-layout{grid-template-columns:1fr}.sidebar{width:210px}.main{margin-left:210px;width:calc(100% - 210px)}}@media(max-width:700px){.sidebar{position:static;width:100%;min-height:auto}.app-shell{display:block}.main{margin-left:0;width:100%}.nav{grid-template-columns:repeat(2,1fr)}.sidebar-bottom{margin-top:20px}.topbar{padding:0 16px}.page{padding:16px}.stats-grid{grid-template-columns:1fr}.welcome,.page-toolbar{display:block}.page-toolbar input{width:100%;margin-top:12px}}.product-location {
    margin-top: 6px;
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
}

.customer-debt-panel {
    margin-top: 16px;
    padding: 14px;
    border: 1px solid #f59e0b;
    border-radius: 10px;
    background: #fffbeb;
}

.customer-debt-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.customer-debt-header strong {
    font-size: 15px;
}

.customer-debt-header span {
    font-size: 12px;
    color: #92400e;
}

.customer-debt-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.customer-debt-grid label span {
    color: #dc2626;
}

@media (max-width: 700px) {
    .customer-debt-grid {
        grid-template-columns: 1fr;
    }
}/* ============================================================
   POS PRODUCT CARD — FINAL LAYOUT
   ============================================================ */
.pos-products{
    align-items:stretch;
}
.product-card{
    display:flex;
    flex-direction:column;
    min-height:390px;
    height:100%;
    box-sizing:border-box;
    transition:
        transform .15s ease,
        border-color .15s ease,
        box-shadow .15s ease;
}
.product-card:hover{
    border-color:#a9d5ff;
    transform:translateY(-2px);
    box-shadow:0 6px 18px rgba(15,23,42,.08);
}
.product-card > div:first-child{
    flex:0 0 150px;
    height:150px !important;
    display:flex;
    align-items:center;
    justify-content:center;
    overflow:hidden;
    background:#f8fafc;
}
.product-card > div:first-child img{
    width:100% !important;
    height:150px !important;
    object-fit:contain !important;
    display:block;
}
.product-info{
    flex:1;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:flex-start;
    text-align:center;
    padding:14px 12px 16px;
    box-sizing:border-box;
}
.product-info h4{
    width:100%;
    min-height:42px;
    margin:0 0 5px;
    display:flex;
    align-items:center;
    justify-content:center;
    text-align:center;
    font-size:15px;
    line-height:1.35;
    font-weight:700;
    color:var(--text);
}
.product-info small{
    width:100%;
    min-height:18px;
    display:flex;
    align-items:center;
    justify-content:center;
    text-align:center;
    color:#475569 !important;
    font-size:12px;
    font-weight:600;
}
.product-info .price{
    width:100%;
    margin-top:8px;
    text-align:center;
    color:var(--primary) !important;
    font-size:16px;
    line-height:1.3;
    font-weight:800;
}
.product-info .stock{
    width:100%;
    margin-top:5px;
    text-align:center;
    color:#475569 !important;
    font-size:12px;
    line-height:1.4;
    font-weight:600;
}
/* Location and expiry are generated with inline styles,
   so !important is required here. */
.product-info div[style]{
    width:100%;
    margin-top:6px !important;
    text-align:center !important;
    color:#475569 !important;
    font-size:12px !important;
    line-height:1.4;
    font-weight:500;
}
.product-info div[style] strong{
    color:#1e293b !important;
    font-weight:700;
}
.product-info .stock:has(+ div[style]){
    margin-bottom:1px;
}
/* Keep cards visually consistent even when names differ */
.product-card[data-product-id]{
    box-sizing:border-box;
}
/* Out-of-stock cards remain readable */
.product-card[style*="opacity"]{
    cursor:not-allowed;
}
@media(max-width:700px){
    .product-card{
        min-height:370px;
    }
    .product-card > div:first-child{
        flex-basis:140px;
        height:140px !important;
    }
    .product-card > div:first-child img{
        height:140px !important;
    }
}
/* ============================================================
   POS PRODUCT CARDS — COMPACT HEIGHT FIX
   ============================================================ */
.product-card{
    display:flex;
    flex-direction:column;
    height:auto;
    min-height:0;
    box-sizing:border-box;
}
.product-card > div:first-child{
    flex:0 0 130px;
    height:130px !important;
    display:flex;
    align-items:center;
    justify-content:center;
    overflow:hidden;
    background:#f8fafc;
}
.product-card > div:first-child img{
    width:100% !important;
    height:130px !important;
    object-fit:contain !important;
    display:block;
}
.product-info{
    flex:none;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:flex-start;
    text-align:center;
    padding:10px 10px 11px;
    box-sizing:border-box;
}
.product-info h4{
    width:100%;
    min-height:0;
    margin:0 0 4px;
    display:block;
    text-align:center;
    font-size:14px;
    line-height:1.3;
    font-weight:700;
    color:var(--text);
}
.product-info small{
    width:100%;
    min-height:0;
    display:block;
    text-align:center;
    color:#475569 !important;
    font-size:11px;
    line-height:1.3;
    font-weight:600;
}
.product-info .price{
    width:100%;
    margin-top:6px;
    text-align:center;
    color:var(--primary) !important;
    font-size:15px;
    line-height:1.3;
    font-weight:800;
}
.product-info .stock{
    width:100%;
    margin-top:4px;
    text-align:center;
    color:#475569 !important;
    font-size:11px;
    line-height:1.3;
    font-weight:600;
}
.product-info div[style]{
    width:100%;
    margin-top:4px !important;
    text-align:center !important;
    color:#475569 !important;
    font-size:11px !important;
    line-height:1.3;
    font-weight:500;
}
.product-info div[style] strong{
    color:#1e293b !important;
    font-weight:700;
}
@media(max-width:700px){
    .product-card > div:first-child{
        flex-basis:120px;
        height:120px !important;
    }
    .product-card > div:first-child img{
        height:120px !important;
    }
}
/* ============================================================
   PRODUCT MODAL + PRODUCT FORM LAYOUT
   ============================================================ */
.modal-overlay{
    position:fixed;
    inset:0;
    z-index:1000;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:20px;
    background:rgba(15,23,42,.55);
    overflow-y:auto;
}
.modal-card{
    width:min(100%, 900px);
    max-height:90vh;
    overflow-y:auto;
    background:#fff;
    border:1px solid var(--border);
    border-radius:14px;
    box-shadow:0 20px 50px rgba(15,23,42,.20);
}
.modal-header{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:15px;
    padding:20px;
    border-bottom:1px solid var(--border);
}
.modal-header h3{
    margin:0 0 4px;
}
.modal-header p{
    margin:0;
    color:var(--muted);
    font-size:13px;
}
.modal-close{
    border:0;
    background:transparent;
    color:var(--muted);
    font-size:24px;
    line-height:1;
    cursor:pointer;
    padding:2px 6px;
}
.product-form-grid{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:16px;
    padding:20px;
}
.form-group{
    display:flex;
    flex-direction:column;
    gap:7px;
    min-width:0;
}
.form-group label{
    font-size:13px;
    font-weight:600;
    color:var(--text);
}
.form-group input,
.form-group select,
.form-group textarea{
    width:100%;
    min-width:0;
    padding:10px 12px;
    border:1px solid var(--border);
    border-radius:8px;
    outline:0;
    background:#fff;
    color:var(--text);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus{
    border-color:var(--primary);
    box-shadow:0 0 0 3px rgba(10,132,255,.10);
}
#productUnitConversionSection{
    grid-column:1 / -1;
    padding:14px;
    border:1px solid var(--border);
    border-radius:10px;
    background:#f8fafc;
}
#productUnitConversionRows{
    display:grid;
    gap:8px;
}
.product-unit-row{
    padding:10px;
    border:1px solid var(--border);
    border-radius:9px;
    background:#fff;
}
.product-unit-row input{
    width:100%;
}
.modal-footer{
    display:flex;
    justify-content:flex-end;
    align-items:center;
    gap:10px;
    padding:16px 20px 20px;
    border-top:1px solid var(--border);
}
@media(max-width:700px){
    .modal-overlay{
        align-items:flex-start;
        padding:10px;
    }
    .modal-card{
        width:100%;
        max-height:95vh;
    }
    .product-form-grid{
        grid-template-columns:1fr;
        padding:14px;
        gap:12px;
    }
    #productUnitConversionSection{
        grid-column:auto;
    }
    .modal-header{
        padding:16px;
    }
    .modal-footer{
        padding:14px;
        flex-direction:column;
        align-items:stretch;
    }
}

/* ============================================================
   HAGIOS LOGIN SCREEN — MODERN PROFESSIONAL DESIGN
   ============================================================ */
.login-screen{
    position:fixed;
    inset:0;
    z-index:9999;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:24px;
    background:
        radial-gradient(circle at 15% 20%, rgba(10,132,255,.22), transparent 32%),
        radial-gradient(circle at 85% 80%, rgba(6,104,204,.18), transparent 34%),
        linear-gradient(135deg,#07111f 0%,#0d1b2e 48%,#10243d 100%);
    overflow:auto;
}
.login-screen::before{
    content:"";
    position:absolute;
    inset:0;
    background:
        linear-gradient(
            135deg,
            rgba(255,255,255,.035) 25%,
            transparent 25%
        );
    background-size:42px 42px;
    opacity:.35;
    pointer-events:none;
}
.login-card{
    position:relative;
    width:min(100%,430px);
    padding:38px;
    border:1px solid rgba(255,255,255,.13);
    border-radius:24px;
    background:rgba(255,255,255,.97);
    box-shadow:
        0 30px 80px rgba(0,0,0,.35),
        0 8px 30px rgba(0,0,0,.18);
    backdrop-filter:blur(18px);
    -webkit-backdrop-filter:blur(18px);
}
.login-brand{
    display:flex;
    align-items:center;
    gap:14px;
    margin-bottom:34px;
}
.login-brand-mark{
    width:54px;
    height:54px;
    flex:0 0 54px;
    display:grid;
    place-items:center;
    border-radius:15px;
    background:linear-gradient(
        135deg,
        var(--primary),
        var(--primary-dark)
    );
    color:#fff;
    font-size:27px;
    font-weight:900;
    letter-spacing:-1px;
    box-shadow:0 10px 24px rgba(10,132,255,.28);
}
.login-brand h1{
    margin:0;
    color:#111827;
    font-size:22px;
    line-height:1;
    letter-spacing:2px;
    font-weight:900;
}
.login-brand span{
    display:block;
    margin-top:6px;
    color:#64748b;
    font-size:12px;
    font-weight:600;
    letter-spacing:.4px;
}
.login-heading{
    margin-bottom:24px;
}
.login-heading h2{
    margin:0 0 7px;
    color:#172033;
    font-size:28px;
    line-height:1.2;
    font-weight:800;
    letter-spacing:-.5px;
}
.login-heading p{
    margin:0;
    color:#718096;
    font-size:14px;
    line-height:1.5;
}
#loginForm{
    display:grid;
    gap:17px;
}
#loginForm label{
    display:grid;
    gap:8px;
    color:#344054;
    font-size:13px;
    font-weight:700;
}
#loginForm input{
    width:100%;
    height:50px;
    padding:0 15px;
    border:1px solid #d8dee8;
    border-radius:11px;
    outline:none;
    background:#f8fafc;
    color:#172033;
    font-size:15px;
    transition:
        border-color .18s ease,
        box-shadow .18s ease,
        background .18s ease;
}
#loginForm input::placeholder{
    color:#98a2b3;
}
#loginForm input:hover{
    border-color:#b9c3d1;
    background:#fff;
}
#loginForm input:focus{
    border-color:var(--primary);
    background:#fff;
    box-shadow:
        0 0 0 4px rgba(10,132,255,.11);
}
.login-error{
    min-height:20px;
    margin-top:-3px;
    color:#dc2626;
    font-size:13px;
    line-height:1.45;
    font-weight:600;
}
.login-submit{
    width:100%;
    height:52px;
    margin-top:2px;
    border-radius:11px;
    background:linear-gradient(
        135deg,
        var(--primary),
        var(--primary-dark)
    );
    box-shadow:0 8px 20px rgba(10,132,255,.22);
    font-size:15px;
    font-weight:800;
    letter-spacing:.2px;
    transition:
        transform .15s ease,
        box-shadow .15s ease,
        filter .15s ease;
}
.login-submit:hover{
    background:linear-gradient(
        135deg,
        var(--primary),
        var(--primary-dark)
    );
    transform:translateY(-1px);
    box-shadow:0 11px 25px rgba(10,132,255,.30);
}
.login-submit:active{
    transform:translateY(0);
}
.login-submit:disabled{
    cursor:not-allowed;
    opacity:.7;
    transform:none;
    box-shadow:none;
}
.login-status{
    display:flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    margin-top:22px;
    padding-top:18px;
    border-top:1px solid #edf0f4;
    color:#718096;
    font-size:12px;
    font-weight:600;
    text-align:center;
}
#loginStatusDot{
    width:8px;
    height:8px;
    flex:0 0 8px;
    border-radius:50%;
    background:#f59e0b;
    box-shadow:0 0 0 4px rgba(245,158,11,.10);
}
@media(max-width:520px){
    .login-screen{
        padding:16px;
    }
    .login-card{
        padding:28px 22px;
        border-radius:20px;
    }
    .login-brand{
        margin-bottom:28px;
    }
    .login-heading h2{
        font-size:25px;
    }
    .login-brand-mark{
        width:50px;
        height:50px;
        flex-basis:50px;
    }
}
@media(max-height:650px){
    .login-screen{
        align-items:flex-start;
        padding-top:20px;
        padding-bottom:20px;
    }
}
/* Login logo image sizing */
.login-brand-mark img{
    width:38px;
    height:38px;
    display:block;
    object-fit:contain;
    border-radius:8px;
}
/* ============================================================
   APP SHELL / PAGE VIEWPORT FIX — 2026-09-09
   Prevent pages from pushing the application outside viewport.
   Wide tables remain scrollable inside their table wrappers.
   ============================================================ */
html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}
.app-shell {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}
.main {
    min-width: 0;
    max-width: calc(100% - 245px);
    overflow-x: hidden;
}
.topbar {
    min-width: 0;
    max-width: 100%;
}
.page {
    min-width: 0;
    max-width: 100%;
}
.page.active {
    width: 100%;
}
.page > *,
.content-grid > *,
.pos-layout > *,
.stats-grid > *,
.page-toolbar > *,
.welcome > * {
    min-width: 0;
}
.table-wrap {
    max-width: 100%;
    overflow-x: auto;
}
@media (max-width: 1000px) {
    .main {
        max-width: calc(100% - 210px);
    }
}
@media (max-width: 700px) {
    .main {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }
    .page {
        width: 100%;
        max-width: 100%;
    }
}
/* ============================================================
   APP SHELL CORRECTION — 2026-09-09
   Sidebar is fixed; main content occupies the remaining viewport.
   ============================================================ */
.app-shell {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
}
.sidebar {
    width: 245px;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
}
.main {
    margin-left: 245px;
    width: auto;
    max-width: none;
    min-width: 0;
    min-height: 100vh;
    overflow-x: hidden;
}
.topbar {
    width: 100%;
    min-width: 0;
}
.page {
    width: 100%;
    max-width: none;
    min-width: 0;
}
@media (max-width: 1000px) {
    .sidebar {
        width: 210px;
    }
    .main {
        margin-left: 210px;
        width: auto;
        max-width: none;
    }
}
@media (max-width: 700px) {
    .app-shell {
        display: block;
    }
    .sidebar {
        position: static;
        width: 100%;
        min-height: auto;
    }
    .main {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }
}
/* ============================================================
   MOBILE LAYOUT FIX — 2026-09-09
   Keep desktop/laptop layout unchanged.
   On phones, sidebar becomes a compact horizontal navigation.
   ============================================================ */
@media (max-width: 700px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }
    .app-shell {
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    .sidebar {
        position: relative;
        left: auto;
        top: auto;
        bottom: auto;
        width: 100%;
        max-width: 100%;
        min-height: auto;
        height: auto;
        display: block;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
    }
    .sidebar .nav {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        width: max-content;
        min-width: 100%;
        overflow: visible;
    }
    .sidebar .nav-item {
        flex: 0 0 auto;
        white-space: nowrap;
    }
    .sidebar-bottom {
        display: none;
    }
    .main {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: hidden;
    }
    .topbar {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    .page {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    .page.active {
        width: 100%;
    }
    .page > *,
    .content-grid > *,
    .pos-layout > *,
    .stats-grid > *,
    .page-toolbar > *,
    .welcome > * {
        min-width: 0;
        max-width: 100%;
    }
    .table-wrap {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
    }
}
/* ============================================================
   FINAL LAPTOP VIEWPORT FIX — 2026-09-09
   Correct box sizing and make sidebar/main occupy exact viewport.
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
}
html,
body {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}
.app-shell {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0;
}
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 245px;
    height: 100vh;
    margin: 0;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
}
.main {
    margin-left: 245px;
    width: calc(100% - 245px);
    max-width: calc(100% - 245px);
    min-width: 0;
    min-height: 100vh;
    box-sizing: border-box;
    overflow-x: hidden;
}
.topbar {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.page {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow-x: hidden;
}
.page.active {
    width: 100%;
    max-width: 100%;
}
.content-grid,
.pos-layout,
.stats-grid,
.page-toolbar,
.welcome {
    max-width: 100%;
    min-width: 0;
}
.content-grid > *,
.pos-layout > *,
.stats-grid > *,
.page-toolbar > *,
.welcome > * {
    min-width: 0;
    max-width: 100%;
}
.table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
}
@media (max-width: 1000px) {
    .sidebar {
        width: 210px;
    }
    .main {
        margin-left: 210px;
        width: calc(100% - 210px);
        max-width: calc(100% - 210px);
    }
}
@media (max-width: 700px) {
    .sidebar {
        position: relative;
        left: auto;
        top: auto;
        bottom: auto;
        width: 100%;
        height: auto;
        min-height: auto;
        overflow-x: auto;
        overflow-y: hidden;
    }
    .main {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }
}
/* ============================================================
   MOBILE NAVIGATION GRID FIX — 2026-09-09
   Keep all laptop/desktop layout unchanged.
   ============================================================ */
@media (max-width: 700px) {
    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        min-height: 0;
        overflow: visible;
        padding: 14px 10px;
    }
    .sidebar .brand {
        margin-bottom: 12px;
    }
    .sidebar .nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        width: 100%;
        min-width: 0;
        overflow: visible;
    }
    .sidebar .nav-item {
        width: 100%;
        min-width: 0;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        padding: 10px 8px;
        white-space: normal;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 13px;
        line-height: 1.2;
    }
    .sidebar .nav-item span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .sidebar-bottom {
        display: block;
        margin-top: 12px;
    }
    .main {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: hidden;
    }
    .topbar {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding: 12px 14px;
    }
    .page {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding: 14px;
        overflow-x: hidden;
    }
    .page.active {
        display: block;
        width: 100%;
    }
}
/* ============================================================
   MOBILE PAGE OVERFLOW FIX — 2026-09-09
   Prevent individual page controls from making the phone
   viewport wider than the screen.
   ============================================================ */
@media (max-width: 700px) {
    /* Every page-level flex toolbar must be allowed to shrink/wrap */
    .page-toolbar {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        display: flex;
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 10px;
        box-sizing: border-box;
    }
    .page-toolbar > * {
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }
    /* Remove desktop search width on phones */
    .page-toolbar input {
        width: 100%;
        max-width: 100%;
        min-width: 0 !important;
        box-sizing: border-box;
    }
    /* Inline flex containers inside pages */
    .page [style*="display:flex"] {
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
        flex-wrap: wrap;
    }
    /* Inline minimum widths that are too large for phone screens */
    .page [style*="min-width:250px"],
    .page [style*="min-width:240px"],
    .page [style*="min-width:160px"] {
        min-width: 0 !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }
    /* Returns invoice search */
    #returnInvoiceSearch {
        width: 100%;
        max-width: 100%;
        min-width: 0 !important;
        box-sizing: border-box;
    }
    /* Debt search */
    #debtSearch {
        width: 100%;
        max-width: 100%;
        min-width: 0 !important;
        box-sizing: border-box;
    }
    /* Reports selector */
    #reportStockType {
        max-width: 100%;
        min-width: 0 !important;
        box-sizing: border-box;
    }
    /* Returns date */
    #dailyRefundsDate {
        max-width: 100%;
        min-width: 0 !important;
        box-sizing: border-box;
    }
    /* Keep panels themselves inside the phone viewport */
    .page .panel,
    .page .table-panel,
    .page .stat-card,
    .page .welcome {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
    /* Grid children must be shrinkable */
    .page .content-grid > *,
    .page .pos-layout > *,
    .page .stats-grid > *,
    .page .location-grid > * {
        min-width: 0;
        max-width: 100%;
    }
    /* Tables may scroll internally, never the whole page */
    .page .table-wrap {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: auto;
        box-sizing: border-box;
    }
    /* Prevent long text from expanding a page */
    .page h1,
    .page h2,
    .page h3,
    .page h4,
    .page p,
    .page label,
    .page span,
    .page strong {
        overflow-wrap: anywhere;
    }
}
/* ============================================================
   COMPACT MOBILE NAVIGATION FIX — 2026-09-09
   Keep desktop/laptop unchanged.
   On phones, navigation becomes one compact horizontal row.
   ============================================================ */
@media (max-width: 700px) {
    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        min-height: 0;
        padding: 10px 8px;
        overflow-x: hidden;
        overflow-y: visible;
    }
    /* Keep the brand compact */
    .sidebar .brand {
        padding: 2px 6px 10px;
        margin: 0;
    }
    .sidebar .brand-mark {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    .sidebar .brand h1 {
        font-size: 16px;
    }
    .sidebar .brand span {
        font-size: 10px;
    }
    /*
       ONE horizontal navigation row.
       This prevents the sidebar from becoming five rows tall.
    */
    .sidebar .nav {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        width: 100%;
        min-width: 0;
        gap: 6px;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 2px 0 6px;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }
    .sidebar .nav-item {
        flex: 0 0 auto;
        width: auto;
        min-width: max-content;
        max-width: none;
        padding: 9px 11px;
        display: flex;
        align-items: center;
        justify-content: center;
        white-space: nowrap;
        font-size: 12px;
        line-height: 1.2;
        overflow: visible;
        text-overflow: clip;
    }
    .sidebar .nav-item span {
        overflow: visible;
        text-overflow: clip;
        white-space: nowrap;
    }
    /*
       Keep the status/logout area compact instead of creating
       a large empty sidebar section.
    */
    .sidebar-bottom {
        margin-top: 6px;
        padding-top: 0;
    }
    .api-status {
        padding: 5px 6px;
        font-size: 11px;
    }
    .logout-btn {
        padding: 8px;
        font-size: 12px;
    }
    /*
       Main content starts immediately after the compact nav.
    */
    .main {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: hidden;
    }
    .topbar {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding: 10px 14px;
    }
    .page {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding: 14px;
        overflow-x: hidden;
    }
    .page.active {
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: hidden;
    }
}
/* ============================================================
   MOBILE NAVIGATION CLEANUP — 2026-09-09
   Compact wrapped navigation for phones.
   ============================================================ */
@media (max-width: 700px) {
    .app-shell {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }
    .sidebar {
        position: relative !important;
        left: auto !important;
        top: auto !important;
        bottom: auto !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        max-width: 100% !important;
        padding: 10px 8px !important;
        overflow: visible !important;
        box-sizing: border-box !important;
    }
    .sidebar .brand {
        width: 100%;
        margin: 0 0 8px 0;
        padding: 2px 6px 8px;
    }
    .sidebar .nav {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 6px !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        overflow: visible !important;
        padding: 0 !important;
    }
    .sidebar .nav-item {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        height: auto !important;
        padding: 9px 8px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 7px !important;
        white-space: normal !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
        font-size: 12px !important;
        line-height: 1.2 !important;
    }
    .sidebar .nav-item span {
        min-width: 0 !important;
        max-width: 100% !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: normal !important;
    }
    .sidebar-bottom {
        display: block !important;
        width: 100% !important;
        margin-top: 8px !important;
    }
    .main {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    .topbar {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        padding: 10px 12px !important;
    }
    .page {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
        padding: 12px !important;
    }
    .page.active {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
    }
}
