/* ================================
   GLOBAL
================================ */

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

:root {

    --navy: #102A43;
    --navy-dark: #071B2E;

    --green: #F47C20;
    --green-light: #FF9A3C;

    --yellow: #F47C20;
    --orange: #F47C20;
    --orange-light: #FF9A3C;

    --red: #C62828;

    --white: #FFFFFF;
    --background: #F5F7FA;

    --black: #1A1A1A;
    --gray: #777;

    --border: #E5E7EB;

}

body {

    font-family: "Poppins", sans-serif;

    background: var(--background);

    color: var(--black);

}


/* ================================
   SIDEBAR
================================ */

.sidebar {

    width: 260px;

    height: 100vh;

    background: linear-gradient(
        180deg,
        var(--navy),
        var(--navy-dark)
    );

    position: fixed;

    top: 0;
    left: 0;

    display: flex;

    flex-direction: column;

    padding: 25px 15px;

    transition: 0.3s ease;

    z-index: 1000;

}


/* ================================
   LOGO
================================ */

.logo-section {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 4px 18px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}

.brand-logo {
    display: block;
    width: min(215px, 100%);
    height: auto;
    object-fit: contain;
}



/* ================================
   MENU
================================ */

.menu {

    display: flex;

    flex-direction: column;

    gap: 10px;

}

.menu-btn {

    width: 100%;

    border: none;

    background: transparent;

    color: rgb(255, 255, 255);

    padding: 15px;

    border-radius: 10px;

    display: flex;

    align-items: center;

    gap: 15px;

    font-family: inherit;

    font-size: 14px;

    cursor: pointer;

    transition: 0.3s;

}

.menu-btn i {
    width: 9px;
    font-size: 17px;
    text-align: center;
    flex-shrink: 0;
}

.menu-btn:hover {

    background: rgba(255,255,255,0.12);

}

.menu-btn.active {

    background: var(--orange, #F47C20);

    color: #FFFFFF;

    font-weight: 600;

}


/* ================================
   EXIT
================================ */

.exit-section {

    margin-top: auto;

}

.exit-btn {

    color: #FFB4B4;

}

.exit-btn:hover {

    background: rgba(198,40,40,0.2);

    color: white;

}


/* ================================
   MAIN CONTENT
================================ */

.main-content {

    margin-left: 260px;

    min-height: 100vh;

    transition: 0.3s;

}


/* ================================
   TOPBAR
================================ */

.topbar {

    background: rgba(255, 255, 255, 0.404);

    padding: 5px 3px;

    display: flex;

    justify-content: space-between;

    align-items: center;

}

.left-header {

    display: flex;

    align-items: center;

    gap: 15px;

}

.topbar h1 {

    font-size: 22px;

    color: var(--navy);

}

.topbar p {

    font-size: 12px;

    color: var(--gray);

}

.menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--navy);
    color: white;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    cursor: pointer;
}


/* ================================
   PROFILE
================================ */

.profile-section {

    display: flex;

    align-items: center;

    gap: 25px;

}

.notification {

    position: relative;

    font-size: 20px;

    color: var(--navy);

}

.notification span {

    width: 8px;
    height: 8px;

    background: var(--red);

    border-radius: 50%;

    position: absolute;

    top: 0;
    right: -2px;

}

.profile {

    display: flex;

    align-items: center;

    gap: 10px;

}

.avatar {

    width: 42px;
    height: 42px;

    background: var(--green);

    color: white;

    border-radius: 50%;

    display: flex;

    align-items: center;

    justify-content: center;

    font-weight: bold;

}

.profile-info {

    display: flex;

    flex-direction: column;

}

.profile-info strong {

    font-size: 13px;

}

.profile-info small {

    font-size: 10px;

    color: var(--gray);

}


/* ================================
   DASHBOARD
================================ */

.dashboard {

    padding: 30px;

}


/* ================================
   STATS
================================ */

.stats-grid {

    display: grid;

    grid-template-columns:
        repeat(4, 1fr);

    gap: 20px;

}

.stat-card {

    background: white;

    padding: 22px;

    border-radius: 15px;

    display: flex;

    align-items: center;

    gap: 15px;

    box-shadow:
        0 5px 20px
        rgba(0,0,0,0.05);

    border: 1px solid var(--border);

}

.stat-icon {

    width: 55px;
    height: 55px;

    border-radius: 14px;

    display: flex;

    align-items: center;

    justify-content: center;

    font-size: 22px;

}


/* CARD COLORS */

.sales-card .stat-icon {

    background: #E8F0FE;

    color: var(--navy);

}

.transaction-card .stat-icon {

    background: #FFF5D6;

    color: var(--yellow);

}

.product-card .stat-icon {

    background: #E5F6EA;

    color: var(--green);

}

.profit-card .stat-icon {

    background: #FFE9E9;

    color: var(--red);

}


.stat-info {

    display: flex;

    flex-direction: column;

}

.stat-info span {

    font-size: 12px;

    color: var(--gray);

}

.stat-info h2 {

    font-size: 20px;

    color: var(--black);

}


/* ================================
   LOWER GRID
================================ */

.dashboard-grid {

    display: grid;

    grid-template-columns: 2fr 1fr;

    gap: 20px;

    margin-top: 25px;

}

.dashboard-card {

    background: white;

    border-radius: 15px;

    padding: 25px;

    border: 1px solid var(--border);

}


/* ================================
   CARD HEADER
================================ */

.card-header {

    display: flex;

    justify-content: space-between;

    align-items: center;

}

.card-header h2 {

    font-size: 17px;

    color: var(--navy);

}

.card-header p {

    font-size: 11px;

    color: var(--gray);

}

.view-btn {

    border: none;

    background: #EEF3FA;

    color: var(--navy);

    padding: 8px 15px;

    border-radius: 8px;

    font-family: inherit;

    cursor: pointer;

}


/* ================================
   EMPTY STATE
================================ */

.empty-state {

    min-height: 260px;

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

    text-align: center;

    color: var(--gray);

}

.empty-state i {

    font-size: 45px;

    color: #D1D5DB;

    margin-bottom: 15px;

}

.empty-state h3 {

    font-size: 16px;

    color: var(--black);

}

.empty-state p {

    font-size: 12px;

    margin-top: 5px;

}


/* ================================
   QUICK ACTIONS
================================ */

.action-buttons {

    display: flex;

    flex-direction: column;

    gap: 15px;

    margin-top: 20px;

}

.action-btn {

    border: none;

    padding: 15px;

    border-radius: 12px;

    display: flex;

    align-items: center;

    gap: 15px;

    cursor: pointer;

    font-family: inherit;

    transition: 0.3s;

}

.action-btn:hover {

    transform: translateY(-2px);

}

.action-btn i {

    font-size: 20px;

    width: 40px;

}

.action-btn span {

    display: flex;

    flex-direction: column;

    align-items: flex-start;

}

.action-btn strong {

    font-size: 13px;

}

.action-btn small {

    font-size: 10px;

}


/* ACTION COLORS */

.sale-action {

    background: #EAF0F9;

    color: var(--navy);

}

.product-action {

    background: #E9F7EE;

    color: var(--green);

}

.history-action {

    background: #FFF6DE;

    color: #A87500;

}


/* ================================
   TABLET
================================ */

@media (max-width: 1100px) {

    .stats-grid {

        grid-template-columns:
            repeat(2, 1fr);

    }

}


/* ================================
   MOBILE
================================ */

@media (max-width: 768px) {

    .sidebar {

        transform: translateX(-100%);

    }

    .sidebar.show {

        transform: translateX(0);

    }

    .main-content {

        margin-left: 0;

    }

    .menu-toggle {

        display: flex;

        align-items: center;

        justify-content: center;

    }

    .topbar {

        padding: 15px 20px;

    }

    .profile-info {

        display: none;

    }

    .profile-section {

        gap: 15px;

    }

    .dashboard {

        padding: 20px;

    }

    .dashboard-grid {

        grid-template-columns: 1fr;

    }

}


/* ================================
   SMALL MOBILE
================================ */

@media (max-width: 500px) {

    .stats-grid {

        grid-template-columns: 1fr;

    }

    .topbar h1 {

        font-size: 17px;

    }

    .topbar p {

        display: none;

    }

    .dashboard {

        padding: 15px;

    }

    .dashboard-card {

        padding: 18px;

    }

}

/* =========================
   SALE PAGE
========================= */

.pos-page{

    display: none;

    grid-template-columns:
        minmax(0, 1fr)
        380px;

    gap: 20px;

    padding: 30px;

    min-height: calc(100vh - 85px);

}


.pos-page.active {

    display: grid;

}


.sale-left {

    min-width: 0;

}


.sale-header {

    margin-bottom: 20px;

}


.sale-header h2 {

    color: var(--navy);

}


.sale-header p {

    font-size: 12px;

    color: var(--gray);

}


/* SEARCH */

.search-section {

    background: white;

    padding: 10px;

    border-radius: 12px;

    border: 1px solid var(--border);

    display: flex;

    align-items: center;

    gap: 10px;

}

.search-section i {

    padding-left: 10px;

    color: var(--navy);

}

.search-section input {

    flex: 1;

    border: none;

    outline: none;

    padding: 12px;

    font-family: inherit;

}

.search-section button {
    border: none;
    background: var(--navy);
    color: white;
    padding: 0 20px;
    border-radius: 8px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    font-family: inherit;
    font-size: 14px;
    font-weight: 500;

    cursor: pointer;
    height: 44px;
    min-width: 98px;
}


/* RESULTS */

.product-results {

    margin-top: 20px;

    display: grid;

    grid-template-columns:
        repeat(auto-fill, minmax(240px, 1fr));

    gap: 15px;

}


.search-empty {

    grid-column: 1 / -1;

    background: white;

    padding: 70px 20px;

    text-align: center;

    border-radius: 15px;

    color: var(--gray);

}


.search-empty i {

    font-size: 45px;

    color: var(--navy);

    opacity: .3;

}


.product-card {

    background: white;

    border-radius: 15px;

    padding: 18px;

    border: 1px solid var(--border);

    transition: .2s;

}


.product-card:hover {

    transform: translateY(-3px);

    box-shadow:
        0 8px 25px
        rgba(0,0,0,.08);

}


.product-card h3 {

    color: var(--navy);

    font-size: 15px;

}


.product-card .barcode {

    font-size: 10px;

    color: var(--gray);

    margin-top: 3px;

}


.stock-info {

    margin-top: 12px;

    font-size: 11px;

    color: var(--green);

    font-weight: 600;

}


/* QUANTITY */

.product-options {

    margin-top: 15px;

}


.product-options label {

    font-size: 11px;

    font-weight: 600;

}


.quantity-input {

    width: 100%;

    margin-top: 5px;

    padding: 10px;

    border: 1px solid var(--border);

    border-radius: 8px;

}


/* SALE TYPE */

.sale-type {

    display: grid;

    grid-template-columns: 1fr 1fr;

    gap: 8px;

    margin-top: 10px;

}


.sale-type label {

    cursor: pointer;

}


.sale-type input {

    display: none;

}


.sale-type span {

    display: block;

    text-align: center;

    padding: 9px;

    border: 1px solid var(--border);

    border-radius: 7px;

    font-size: 11px;

}


.sale-type input:checked + span {

    background: var(--navy);

    color: white;

    border-color: var(--navy);

}


.add-cart-btn {

    width: 100%;

    margin-top: 15px;

    padding: 11px;

    border: none;

    background: var(--green);

    color: white;

    border-radius: 8px;

    font-family: inherit;

    cursor: pointer;

}


/* CART */

.cart-panel {

    background: white;

    border-radius: 16px;

    border: 1px solid var(--border);

    display: flex;

    flex-direction: column;

    min-height: 540px;

}


.cart-header {

    padding: 20px;

    display: flex;

    justify-content: space-between;

    border-bottom: 1px solid var(--border);

}


.cart-header h2 {

    font-size: 16px;

    color: var(--navy);

}


.cart-header span {

    font-size: 10px;

    color: var(--gray);

}


.clear-cart {

    border: none;

    background: #FFE8E8;

    color: var(--red);

    padding: 7px 12px;

    border-radius: 6px;

    cursor: pointer;

}


.cart-items {

    flex: 1;

    padding: 15px;

    max-height: 190px;

    overflow-y: auto;

}


.cart-empty {

    text-align: center;

    padding: 50px 10px;

    color: var(--gray);
    

}


.cart-empty i {

    font-size: 35px;

    opacity: .3;

}


/* CART ITEM */

.cart-item {

    padding: 19px;

    border-bottom: 1px solid var(--border);

}


.cart-item-top {

    display: flex;

    justify-content: space-between;

    gap: 10px;

}


.cart-item h4 {

    font-size: 12px;

}


.cart-item small {

    font-size: 10px;

    color: var(--gray);

}


.cart-price {

    color: var(--green);

    font-weight: 700;

}


.remove-item {

    border: none;

    background: transparent;

    color: var(--red);

    cursor: pointer;

}


/* PAYMENT */

.payment-section {

    padding: 20px;

    border-top: 1px solid var(--border);

}


.summary-row {

    display: flex;

    justify-content: space-between;

    margin-bottom: 12px;

}


.summary-row span {

    font-size: 13px;

}


.summary-row strong {

    font-size: 18px;

    color: var(--navy);

}


.cash-input label {

    display: block;

    font-size: 11px;

    margin-bottom: 5px;

}


.cash-input input {

    width: 100%;

    padding: 12px;

    border: 1px solid var(--border);

    border-radius: 8px;

    font-family: inherit;

}


.change-row {

    margin-top: 15px;

}


.change-row strong {

    color: var(--green);

}


.pay-btn {

    width: 100%;

    margin-top: 10px;

    padding: 14px;

    background: var(--navy);

    color: white;

    border: none;

    border-radius: 9px;

    font-family: inherit;

    font-weight: 600;

    cursor: pointer;

}


.pay-btn:hover {

    background: var(--green);

}


/* =========================================================
   RECEIPT MODAL
   WEB PREVIEW MATCHES ANDROID ESC/POS AGENT
========================================================= */

/* RECEIPT */

.receipt-modal {

    position: fixed;

    inset: 0;

    background: rgba(0, 0, 0, .60);

    display: none;

    justify-content: center;

    align-items: center;

    z-index: 5000;

    padding: 10px;

}


.receipt-modal.show {

    display: flex;

}


/* MAIN PAYMENT SUCCESSFUL MODAL */

.receipt-box {

    width: 270px;

    max-width: calc(100vw - 20px);

    max-height: calc(100vh - 20px);

    background: #ffffff;

    border-radius: 6px;

    overflow: hidden;

    display: flex;

    flex-direction: column;

}


/* PAYMENT SUCCESSFUL */

.receipt-header {

    flex: 0 0 auto;

    padding: 8px 10px;

    background: var(--navy);

    color: #ffffff;

    display: flex;

    align-items: center;

    justify-content: space-between;

}


.receipt-header h2 {

    margin: 0;

    font-size: 11px;

    font-weight: 600;

}


.receipt-header button {

    border: none;

    background: transparent;

    color: #ffffff;

    font-size: 16px;

    line-height: 1;

    padding: 0;

    cursor: pointer;

}


/* ONLY RECEIPT AREA SCROLLS */

.receipt-scroll {

    flex: 1 1 auto;

    min-height: 0;

    overflow-y: auto;

    overflow-x: auto;

    background: #eeeeee;

    padding: 8px 5px;

    -webkit-overflow-scrolling: touch;

}


/* ACTUAL RECEIPT PAPER */

.receipt-paper {

    width: 252px;

    min-width: 252px;

    margin: 0 auto;

    padding: 10px 8px 14px;

    box-sizing: border-box;

    background: #ffffff;

    color: #111111;

}


/* STORE */

.receipt-store {

    text-align: center;

    border: none;

    padding: 0 0 5px;

}


.receipt-store h2 {

    margin: 0;

    font-family: "Courier New", monospace;

    font-size: 10px;

    font-weight: 700;

    line-height: 1.25;

    overflow-wrap: anywhere;

}


.receipt-store-address {

    margin-top: 2px;

    font-family: "Courier New", monospace;

    font-size: 8px;

    line-height: 1.25;

    white-space: pre-line;

    overflow-wrap: anywhere;

}


.receipt-official {

    margin-top: 3px;

    font-family: "Courier New", monospace;

    font-size: 8px;

    line-height: 1.25;

}


/* AGENT RECEIPT */

.agent-receipt {

    width: 42ch;

    max-width: 100%;

    margin: 0 auto;

    font-family: "Courier New", monospace;

    font-size: 8px;

    line-height: 1.35;

    color: #111111;

}


/* DIVIDER */

.agent-divider {

    width: 100%;

    white-space: pre;

    overflow: hidden;

    font-family: "Courier New", monospace;

    font-size: 8px;

    line-height: 1.35;

}


/* RECEIPT # / DATE */

.agent-meta {
    width: 42ch !important;
    max-width: 100% !important;
    text-align: left !important;
    margin: 1px 0 !important;
    padding: 0 !important;
    margin-left: 0 !important;
    font-family: "Courier New", Courier, monospace !important;
    font-size: 9px !important;
    line-height: 1.25 !important;
    white-space: pre !important;
    overflow: hidden !important;
}


/* ITEM HEADER */

.agent-item-header {

    width: 100%;

    white-space: pre;

    overflow: hidden;

    font-family: "Courier New", monospace;

    font-size: 7px;

    line-height: 1.4;

}


/* PRODUCTS */

.agent-items {

    width: 100%;

    margin: 0;

    padding: 0;

    white-space: pre-wrap;

    overflow-wrap: anywhere;

    font-family: "Courier New", monospace;

    font-size: 7px;

    line-height: 1.5;

}


/* TOTALS */

.agent-total-line {

    width: 100%;

    white-space: pre;

    overflow: hidden;

    font-family: "Courier New", monospace;

    font-size: 8px;

    line-height: 1.5;

}


.agent-grand-total {

    font-weight: 700;

}


/* FOOTER */

.agent-footer {

    width: 100%;

    text-align: center;

    font-family: "Courier New", monospace;

    font-size: 8px;

    line-height: 1.5;

}


/* BUTTONS STAY FIXED */

.receipt-buttons {

    flex: 0 0 auto;

    padding: 7px;

    display: grid;

    grid-template-columns: 1fr 1fr;

    gap: 6px;

    background: #ffffff;

    border-top: 1px solid #dddddd;

}


.receipt-buttons button {

    min-height: 32px;

    padding: 7px 5px;

    border: none;

    border-radius: 5px;

    font-family: inherit;

    font-size: 9px;

    cursor: pointer;

}


#printReceipt {

    background: var(--navy);

    color: #ffffff;

}


#newSaleBtn {

    background: var(--green);

    color: #ffffff;

}


/* =========================================================
   SMALL SCREEN
========================================================= */

@media (max-width: 500px) {

    .receipt-modal {

        padding: 8px;

    }


    .receipt-box {

        max-height: calc(100vh - 16px);

        border-radius: 10px;

    }


    .receipt-scroll {

        padding: 12px 6px;

    }


    .receipt-paper {
        width: 42ch;
        max-width: 100%;
        margin: 0 auto;

        padding: 10px 8px 14px;

        background: #ffffff;
        color: #111111;

        box-shadow: 0 2px 8px rgba(0,0,0,.10);

        box-sizing: border-box;
    }


    .receipt-buttons {

        padding: 10px;

    }


    .receipt-buttons button {

        font-size: 12px;

    }

}


/* MOBILE */

@media (max-width: 1000px) {

    .pos-page {

        grid-template-columns: 1fr;

    }

}


@media (max-width: 768px) {

    .pos-page {

        padding: 15px;

    }

}


@media print {

    @page {
        size: 58mm auto;
        margin: 0;
    }

    html,
    body {
        width: 80mm !important;
        min-width: 80mm !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }

    body * {
        visibility: hidden;
    }

    #receiptContent,
    #receiptContent * {
        visibility: visible;
    }

    #receiptContent {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 80mm !important;
        max-width: 80mm !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        padding: 6mm !important;
        overflow: hidden !important;
        background: #fff !important;
        color: #000 !important;
        font-family: "Courier New", Courier, monospace !important;
        font-size: 12px !important;
        line-height: 1.35 !important;
    }

    #receiptContent .receipt-store,
    #receiptContent .receipt-item,
    #receiptContent .receipt-total {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    #receiptContent .receipt-item {
        display: flex !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        gap: 8px !important;
        white-space: normal !important;
    }

    #receiptContent .receipt-item > span {
        min-width: 0 !important;
        flex: 1 1 auto !important;
        overflow-wrap: anywhere !important;
    }

    #receiptContent .receipt-item > strong {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
    }

    #receiptContent .receipt-store h2 {
        margin: 0 !important;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
        font-size: 16px !important;
        line-height: 1.2 !important;
    }

    #receiptContent .receipt-store p {
        margin: 2px 0 0 !important;
        font-size: 12px !important;
    }

    #receiptContent #receiptDetails > p {
        max-width: 100% !important;
        overflow-wrap: anywhere !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    #receiptContent .receipt-total {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

}

/* =========================
   SCROLLABLE PRODUCT RESULTS
========================= */

.product-results {
    flex: 1;

    min-height: 0;

    overflow-y: auto;

    overflow-x: hidden;

    padding-right: 8px;
}

/* Chrome / Edge / Safari */

.product-results::-webkit-scrollbar {
    width: 8px;
}

.product-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.product-results::-webkit-scrollbar-thumb {
    background: #102A43;
    border-radius: 10px;
}

.product-results::-webkit-scrollbar-thumb:hover {
    background: #0B2033;
}


/* Firefox */

.product-results {
    scrollbar-width: thin;
    scrollbar-color: #102A43 #f1f1f1;
}

.sale-left {
    display: flex;
    flex-direction: column;

    height: calc(100vh - 110px);

    min-height: 0;

    overflow: hidden;
}

/* =========================
   SIDEBAR COLLAPSE
========================= */

.sidebar {
    transition:
        width 0.3s ease,
        transform 0.3s ease;
}


.main-content {
    transition:
        margin-left 0.3s ease;
}


/* CLOSED SIDEBAR */

body.sidebar-collapsed .sidebar {

    width: 78px;

}


/* HIDE TEXT */

body.sidebar-collapsed .sidebar .logo-text,

body.sidebar-collapsed .sidebar .menu-btn span {

    opacity: 0;

    visibility: hidden;

    width: 0;

}
body.sidebar-collapsed .sidebar .logo-icon {
    display: none;
}

body.sidebar-collapsed .sidebar .brand-logo {
    display: none;
}


/* CENTER ICONS */

body.sidebar-collapsed .sidebar .menu-btn {
    justify-content: center;
    align-items: center;
    padding: 0;
    width: 48px;
    height: 48px;
    margin: 0 auto;
}


body.sidebar-collapsed .sidebar .logo-section {

    justify-content: center;

}


body.sidebar-collapsed .main-content {

    margin-left: 78px;

}

/* =========================
   HISTORY PAGE
========================= */

.history-page {

    display: none;

    padding: 25px;

    min-height: calc(100vh - 70px);

}


.history-page.active {

    display: block;

}


.history-container {

    background: #ffffff;

    border-radius: 14px;

    padding: 22px;

    box-shadow:
        0 4px 20px rgba(0,0,0,0.06);

}


.history-header {

    display: flex;

    justify-content: space-between;

    align-items: center;

    margin-bottom: 20px;

}


.history-header h2 {

    color: #102A43;

    margin: 0;

}


.history-header p {

    color: #777;

    margin-top: 5px;

}


.refresh-history-btn {

    border: none;

    background: #102A43;

    color: white;

    padding: 10px 16px;

    border-radius: 8px;

    cursor: pointer;

}


.history-search {

    display: flex;

    align-items: center;

    gap: 10px;

    border: 1px solid #ddd;

    padding: 10px 15px;

    border-radius: 8px;

    margin-bottom: 20px;

}


.history-search input {

    border: none;

    outline: none;

    width: 100%;

    font-family: inherit;

}


.history-table-wrapper {

    overflow-x: auto;

}


.history-table {

    width: 100%;

    border-collapse: collapse;

}


.history-table th {

    background: #102A43;

    color: white;

    padding: 14px;

    text-align: left;

}


.history-table td {

    padding: 14px;

    border-bottom: 1px solid #eee;

}


.history-table tr:hover {

    background: #f8f9fb;

}


.amount-total {

    font-weight: 600;

    color: #102A43;

}


.profit-amount {

    color: #D96500;

    font-weight: 600;

}


.view-sale-btn {

    border: none;

    background: #F47C20;

    padding: 8px 12px;

    border-radius: 6px;

    cursor: pointer;

    color: #111;

}


.history-loading {

    text-align: center;

    padding: 40px !important;

    color: #777;

}

@media (max-width: 768px) {

    .sidebar {

        transform:
            translateX(-100%);

        width: 260px !important;

    }


    .sidebar.show {

        transform:
            translateX(0);

    }


    .main-content {

        margin-left: 0 !important;

    }


    body.sidebar-collapsed .sidebar {

        transform:
            translateX(-100%);

    }

}

/* =========================================
   HISTORY - THERMAL RECEIPT STYLE
========================================= */

.history-receipts {
    display: flex;
    flex-direction: column;
    gap: 24px;
}


.history-date-group {
    display: flex;
    flex-direction: column;
    gap: 14px;
}


.history-date-title {
    display: flex;
    align-items: center;
    gap: 10px;

    color: #102A43;
    font-weight: 700;
    font-size: 16px;

    padding: 12px 14px;

    background: #f4f7fb;

    border-left: 4px solid #F47C20;

    border-radius: 10px;
}


.history-date-title small {
    margin-left: auto;

    color: #666;

    font-weight: 500;

    font-size: 12px;
}


/* RECEIPT GRID */

.receipt-copy-grid {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 5px !important;
    align-items: start;
}


/* RECEIPT PAPER */

.history-receipt-card {

    position: relative;

    width: 100%;

    box-sizing: border-box;

    background: #fff;

    border: 1px solid #ddd;

    border-radius: 4px;

    padding: 22px 20px 24px;

    box-shadow:
        0 5px 18px rgba(0,0,0,.07);

    color: #111;

    font-family:
        "Courier New",
        Courier,
        monospace;

    overflow: hidden;
}


/* SMALL TOP RECEIPT EDGE */

.history-receipt-card::before {

    content: "";

    position: absolute;

    top: 0;
    left: 0;
    right: 0;

    height: 3px;

    background: #102A43;
}


/* PRINT BUTTON */

.print-history-receipt {

    position: absolute;

    top: 14px;
    right: 14px;

    width: 36px;
    height: 36px;

    border: 0;

    border-radius: 8px;

    background: #F47C20;

    color: #111;

    cursor: pointer;

    z-index: 2;
}


.print-history-receipt:hover {
    filter: brightness(.95);
}


/* STORE HEADER */

.history-paper-header {

    text-align: center;

    padding-top: 4px;

    padding-bottom: 4px;
}


.history-store-name {

    font-size: 19px;

    font-weight: 800;

    letter-spacing: .3px;

    margin-bottom: 5px;
}


.history-store-address {

    font-size: 12px;

    line-height: 1.5;

    margin-bottom: 18px;
}


.history-official {

    display: inline-block;

    font-size: 13px;

    font-weight: 800;

    letter-spacing: 1px;

    padding: 5px 12px;

    border-top: 1px dashed #888;

    border-bottom: 1px dashed #888;
}


/* RECEIPT INFORMATION */

.history-receipt-info {

    margin-top: 18px;

    display: flex;

    flex-direction: column;

    gap: 7px;

    font-size: 12px;
}


.history-receipt-info div {

    display: grid;

    grid-template-columns: 82px 1fr;

    gap: 5px;

    align-items: start;
}


.history-receipt-info span {
    color: #555;
}


.history-receipt-info strong {

    font-weight: 700;

    word-break: break-word;
}


/* DIVIDER */

.history-receipt-divider {

    border-top:
        1px dashed #999;

    margin: 14px 0;
}


/* ITEM HEADER */

.history-item-header {

    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        34px
        65px
        72px;

    column-gap: 5px;

    align-items: center;

    font-size: 11px;

    font-weight: 800;
}


.item-col-name {
    text-align: left;
}


.item-col-qty,
.item-col-price,
.item-col-amount {
    text-align: right;
}


/* ITEMS */

.history-receipt-items {

    display: flex;

    flex-direction: column;

    gap: 8px;
}


.history-item-row {

    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        34px
        65px
        72px;

    column-gap: 5px;

    align-items: start;

    font-size: 11px;

    line-height: 1.45;
}


.history-item-main {

    min-width: 0;
}


.history-item-name {

    font-weight: 600;

    overflow-wrap: break-word;

    word-break: normal;
}


.history-item-type {

    margin-top: 2px;

    font-size: 9px;

    color: #777;

    letter-spacing: .2px;
}


.history-item-qty,
.history-item-price,
.history-item-amount {

    text-align: right;

    white-space: nowrap;
}


.history-item-amount {
    font-weight: 700;
}


/* SUMMARY */

.history-receipt-summary {

    display: flex;

    flex-direction: column;

    gap: 7px;

    font-size: 12px;
}


.history-receipt-summary div {

    display: flex;

    justify-content: space-between;

    gap: 12px;
}


.history-receipt-summary span {
    color: #555;
}


.history-receipt-summary strong {
    white-space: nowrap;
}


.history-total-row {

    font-size: 14px;

    font-weight: 800;

    color: #102A43;

    margin-top: 2px;
}


.history-total-row span {
    color: #102A43;
}


/* FOOTER */

.history-paper-footer {

    display: flex;

    flex-direction: column;

    align-items: center;

    text-align: center;

    gap: 4px;

    margin-top: 17px;

    font-size: 12px;
}


.history-paper-footer strong {
    font-size: 15px;
}


.history-paper-footer span {
    font-size: 11px;
}


.history-paper-footer small {

    margin-top: 7px;

    color: #D96500;

    font-size: 11px;
}


.history-paper-footer i {
    margin-right: 3px;
}


/* NO ITEMS */

.history-no-items {

    text-align: center;

    color: #777;

    font-size: 12px;

    padding: 12px 0;
}


/* LOADING */

.history-loading {

    text-align: center;

    padding: 50px 20px;

    color: #777;
}


.history-loading i {

    display: block;

    font-size: 24px;

    margin-bottom: 10px;

    color: #102A43;
}
    /* TABLET - 3 RECEIPTS PER ROW */

    @media (min-width: 641px) and (max-width: 1100px) {

        .receipt-copy-grid {
            display: grid !important;
            grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
            gap: 14px !important;
            align-items: start;
        }

    }

/* MOBILE */

@media (max-width: 640px) {

    .history-page {
        padding: 14px;
    }


    .history-container {
        padding: 14px;
    }


    .history-header {

        align-items: flex-start;

        gap: 12px;
    }


    .history-header h2 {
        font-size: 20px;
    }


    .history-header p {
        font-size: 12px;
    }


    .refresh-history-btn {

        padding: 9px 11px;

        font-size: 0;
    }


    .refresh-history-btn i {
        font-size: 14px;
    }


    .receipt-copy-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 14px !important;
        align-items: start;
    }


    .history-date-title {

        align-items: flex-start;

        flex-wrap: wrap;
    }


    .history-date-title small {

        width: 100%;

        margin-left: 26px;
    }


    .history-receipt-card {

        padding:
            20px 14px 22px;
    }


    .print-history-receipt {

        top: 11px;
        right: 11px;
    }


    .history-store-name {
        font-size: 17px;
    }


    .history-store-address {
        font-size: 11px;
    }


    .history-item-header,
    .history-item-row {

        grid-template-columns:
            minmax(0, 1fr)
            30px
            58px
            65px;

        column-gap: 4px;
    }


    .history-item-name {
        font-size: 10px;
    }


    .history-item-type {
        font-size: 8px;
    }


    .history-receipt-info {
        font-size: 11px;
    }
}

/* =========================================
   DEVICE ACCESS GATE
========================================= */

.device-access-gate {
    position: fixed;

    inset: 0;

    width: 100%;
    height: 100%;

    display: flex;

    align-items: center;
    justify-content: center;

    padding: 20px;

    background:
        linear-gradient(
            135deg,
            #0B2033,
            #123b2b
        );

    z-index: 999999;

    transition:
        opacity .4s ease,
        visibility .4s ease;
}


.device-access-gate.hidden {
    opacity: 0;

    visibility: hidden;

    pointer-events: none;
}


.device-access-card {
    width: 100%;

    max-width: 460px;

    background: #ffffff;

    border-radius: 22px;

    padding: 40px 30px;

    text-align: center;

    box-shadow:
        0 25px 70px
        rgba(0, 0, 0, .35);
}


.device-access-icon {
    width: 75px;
    height: 75px;

    margin:
        0 auto 20px;

    display: flex;

    align-items: center;
    justify-content: center;

    border-radius: 20px;

    background: #0B2033;

    color: #F47C20;

    font-size: 32px;
}


.device-access-card h2 {
    margin: 0;

    color: #0B2033;

    font-size: 24px;
}


.device-access-message {
    margin:
        12px 0 25px;

    color: #666;

    line-height: 1.6;
}


.device-info-box {
    display: flex;

    align-items: center;

    gap: 14px;

    padding: 16px;

    text-align: left;

    border-radius: 14px;

    background: #f5f7fa;

    border:
        1px solid
        #e1e6eb;
}


.device-info-icon {
    width: 45px;
    height: 45px;

    display: flex;

    align-items: center;
    justify-content: center;

    border-radius: 12px;

    background: #0B2033;

    color: #ffffff;
}


.device-info-box small {
    display: block;

    color: #777;

    font-size: 10px;

    margin-bottom: 4px;

    letter-spacing: 1px;
}


.device-info-box strong {
    display: block;

    color: #111;

    font-size: 14px;
}


.device-status {
    display: flex;

    align-items: center;
    justify-content: center;

    gap: 10px;

    margin-top: 22px;

    padding: 14px;

    border-radius: 12px;

    background: #fff8df;

    color: #8a6500;

    font-weight: 600;
}


.device-status.allowed {
    background: #e7f7ed;

    color: #14733c;
}


.device-status.denied {
    background: #fdeaea;

    color: #b42318;
}


.device-access-note {
    margin-top: 20px;

    font-size: 12px;

    color: #888;
}


/* MOBILE */

@media (
    max-width: 500px
) {

    .device-access-card {
        padding:
            30px 20px;
    }


    .device-access-card h2 {
        font-size: 21px;
    }

}
/* =========================================================
   RESPONSIVE POS UI — ADDITIVE OVERRIDE
   Keeps all existing functions intact.
   Tablet/mobile: off-canvas navigation + two-pane Sale view.
========================================================= */

@media (max-width: 900px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .sidebar {
        width: 260px !important;
        max-width: 86vw;
        transform: translateX(-105%) !important;
        box-shadow: 12px 0 30px rgba(0,0,0,.18);
        z-index: 5000;
    }

    .sidebar.show {
        transform: translateX(0) !important;
    }

    .main-content,
    body.sidebar-collapsed .main-content {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        min-width: 0 !important;
    }

    .menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        flex: 0 0 44px;
    }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 900;
        min-height: 70px;
    }

    /* Keep Sale split into left working area + right Selected Products. */
    
    .pos-page.active {
        display: grid !important;
        grid-template-columns: minmax(0, 1.16fr) minmax(250px, .84fr) !important;
        gap: 12px !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        min-height: calc(100vh - 70px) !important;
        height: calc(100vh - 70px) !important;
        padding: 14px !important;
        overflow: hidden !important;
    }

    .sale-left,
    .cart-panel {
        min-width: 0 !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
    }

    .sale-left {
        overflow: hidden !important;
    }

    .product-results {
        min-width: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    .cart-panel {
        overflow: hidden !important;
    }

    .cart-items {
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    .cart-header,
    .payment-section {
        flex-shrink: 0;
    }

    /* Prevent long product names/text from forcing the pane wider. */
    .product-card,
    .product-card * {
        max-width: 100%;
    }

    .product-card h3,
    .product-card p,
    .cart-item strong,
    .cart-item span {
        overflow-wrap: anywhere;
        word-break: break-word;
    }
}

@media (max-width: 600px) {
    .topbar {
        padding: 10px 12px !important;
        min-height: 62px;
    }

    .menu-toggle {
        width: 42px;
        height: 42px;
        flex-basis: 42px;
    }

    
    .pos-page.active {
        grid-template-columns: minmax(0, 1.12fr) minmax(145px, .88fr) !important;
        gap: 8px !important;
        padding: 8px !important;
        min-height: calc(100vh - 62px) !important;
        height: calc(100vh - 62px) !important;
    }

    .sale-header {
        margin-bottom: 9px !important;
    }

    .sale-header h2 {
        font-size: 18px !important;
    }

    .sale-header p {
        font-size: 10px !important;
        line-height: 1.35;
    }

    .search-section {
        margin-top: 7px !important;
    }

    .search-section input {
        min-width: 0 !important;
        font-size: 11px !important;
    }

    .search-section button {
        padding: 9px 8px !important;
        font-size: 10px !important;
    }

    .search-section button i {
        margin-right: 0 !important;
    }

    .cart-header {
        padding: 10px !important;
        gap: 6px !important;
    }

    .cart-header h2 {
        font-size: 13px !important;
        line-height: 1.2;
    }

    .cart-header span {
        font-size: 8px !important;
    }

    .clear-cart {
        padding: 7px 8px !important;
        font-size: 9px !important;
    }

    .cart-items {
        padding: 7px !important;
    }

    .cart-item {
        padding: 8px !important;
    }

    .cart-item strong {
        font-size: 10px !important;
    }

    .cart-item span,
    .cart-item small {
        font-size: 9px !important;
    }

    .payment-section {
        padding: 9px !important;
    }

    .summary-row {
        font-size: 11px !important;
    }

    .summary-row strong {
        font-size: 14px !important;
    }

    .cash-input label {
        font-size: 9px !important;
    }

    .cash-input input {
        font-size: 11px !important;
        padding: 8px !important;
    }
}

@media (max-width: 380px) {
    
    .pos-page.active {
        grid-template-columns: minmax(0, 1.08fr) minmax(132px, .92fr) !important;
        gap: 6px !important;
        padding: 6px !important;
    }

    .search-section button {
        font-size: 0 !important;
        width: 38px !important;
        padding: 8px !important;
    }

    .search-section button i {
        font-size: 13px !important;
        margin: 0 !important;
    }

    .cart-header h2 {
        font-size: 12px !important;
    }

    .cart-header span {
        display: none !important;
    }
}


/* =========================
   SETTINGS / THEME
========================= */

.settings-page {
    display: none !important;
    width: 100%;
    min-height: calc(100vh - 70px);
    box-sizing: border-box;
    padding: 30px;
}

.settings-page.active {
    display: block !important;
}

.settings-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

.settings-header {
    margin-bottom: 22px;
}

.settings-header h2 {
    margin: 0;
    font-size: 30px;
    color: var(--navy);
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-header p {
    margin: 7px 0 0;
    font-size: 14px;
    color: var(--gray);
}

.settings-card {
    width: 100%;
    box-sizing: border-box;

    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 15px;

    padding: 24px;

    display: flex;
    align-items: center;
    gap: 16px;

    box-shadow: 0 5px 20px rgba(0,0,0,.05);
}

.settings-card-icon {
    width: 48px;
    height: 48px;

    border-radius: 12px;

    background: #eef3fa;
    color: var(--navy);

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 20px;

    flex: 0 0 48px;
}

.settings-card-info {
    display: flex;
    flex-direction: column;
    gap: 5px;

    flex: 1;
    min-width: 0;
}

.settings-card-info strong {
    font-size: 16px;
    color: var(--black);
}

.settings-card-info span {
    font-size: 13px;
    color: var(--gray);
}

.theme-switch {
    border: 0;
    background: transparent;

    display: flex;
    align-items: center;
    gap: 9px;

    cursor: pointer;

    font-family: inherit;
    font-weight: 600;

    color: var(--navy);

    padding: 5px;

    flex-shrink: 0;
}

.theme-switch-track {
    width: 50px;
    height: 28px;

    border-radius: 999px;

    background: #d1d5db;

    padding: 3px;

    display: block;

    transition: .2s;
}

.theme-switch-knob {
    display: block;

    width: 22px;
    height: 22px;

    background: #ffffff;

    border-radius: 50%;

    box-shadow: 0 1px 4px rgba(0,0,0,.2);

    transition: .2s;
}

.theme-switch.on .theme-switch-track {
    background: #102A43;
}

.theme-switch.on .theme-switch-knob {
    transform: translateX(22px);
}


/* =========================
   DARK MODE
========================= */

body.dark-mode {
    --background: #0f172a;
    --black: #e5e7eb;
    --gray: #a7b0bf;
    --border: #334155;

    color: var(--black);
    background: var(--background);
}

body.dark-mode .main-content {
    background: #0f172a;
}

body.dark-mode .topbar {
    background: #111827 !important;
    border-color: #263244 !important;
}

body.dark-mode .history-container,
body.dark-mode .settings-card {
    background: #111827 !important;
    border-color: #334155 !important;
    color: #e5e7eb;
}

body.dark-mode .settings-card-info strong {
    color: #e5e7eb;
}

body.dark-mode .settings-card-info span {
    color: #a7b0bf;
}

body.dark-mode .settings-card-icon {
    background: #1e293b;
    color: #93c5fd;
}

body.dark-mode .theme-switch {
    color: #93c5fd;
}


/* =========================
   TABLET
========================= */

@media (max-width: 900px) {

    .settings-page {
        padding: 24px 20px;
    }

    .settings-container {
        max-width: 100%;
    }

    .settings-header h2 {
        font-size: 26px;
    }

    .settings-card {
        padding: 20px;
    }

}


/* =========================
   MOBILE
========================= */

@media (max-width: 600px) {

    .settings-page {
        padding: 18px 12px;
        min-height: calc(100vh - 62px);
    }

    .settings-header {
        margin-bottom: 16px;
    }

    .settings-header h2 {
        font-size: 22px;
    }

    .settings-header p {
        font-size: 12px;
    }

    .settings-card {
        padding: 17px;

        display: grid;
        grid-template-columns: 48px minmax(0, 1fr);
        gap: 12px;
    }

    .settings-card-info {
        min-width: 0;
    }

    .settings-card-info strong {
        font-size: 15px;
    }

    .settings-card-info span {
        font-size: 11px;
        line-height: 1.4;
    }

    .theme-switch {
        grid-column: 1 / -1;
        width: 100%;

        justify-content: space-between;

        padding: 10px 0 0;

        border-top: 1px solid var(--border);
        margin-top: 4px;
    }

}


/* =========================
   SMALL PHONE
========================= */

@media (max-width: 380px) {

    .settings-page {
        padding: 14px 10px;
    }

    .settings-card {
        padding: 14px;
    }

    .settings-header h2 {
        font-size: 20px;
    }

}

/* =========================================
   SETTINGS THEME TOGGLE - FIXED
========================================= */

.theme-switch {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.theme-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.theme-switch-track {
    position: relative;
    display: block;
    width: 52px;
    height: 30px;
    padding: 3px;
    background: #d1d5db;
    border-radius: 999px;
    transition: .25s ease;
}

.theme-switch-knob {
    display: block;
    width: 24px;
    height: 24px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,.20);
    transition: .25s ease;
}

/* DARK / ON */
.theme-switch:has(input:checked) .theme-switch-track {
    background: var(--navy);
}

.theme-switch:has(input:checked) .theme-switch-knob {
    transform: translateX(22px);
}

/* MOBILE */
@media (max-width: 600px) {

    .settings-card {
        display: grid;
        grid-template-columns: 48px 1fr;
        gap: 12px;
    }

    .theme-switch {
        grid-column: 1 / -1;
        width: 100%;
        justify-content: space-between;
        padding-top: 12px;
        border-top: 1px solid var(--border);
        margin-top: 4px;
    }

}


/* =========================================================
   FINAL WEB RECEIPT OVERRIDES
   MATCH PRINT AGENT DESIGN
   ========================================================= */

#receiptContent {
    font-family: "Courier New", Courier, monospace !important;
    font-size: 9px !important;
    line-height: 1.25 !important;
    background: #ffffff !important;
    color: #000000 !important;
}

#receiptContent .receipt-scroll,
#receiptContent .receipt-paper {
    box-sizing: border-box;
}

.agent-receipt {
    width: 42ch !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    font-family: "Courier New", Courier, monospace !important;
    font-size: 9px !important;
    line-height: 1.25 !important;
    text-align: left;
    color: #000000 !important;
}

.agent-store {
    width: 100% !important;
    text-align: center !important;
    margin: 0 !important;
    padding: 0 !important;
}

.agent-store-name,
.agent-store-address,
.agent-official {
    width: 100% !important;
    text-align: center !important;
    font-family: "Courier New", Courier, monospace !important;
}

.agent-store-name {
    font-size: 10px !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.agent-store-address {
    font-size: 9px !important;
    font-weight: 400 !important;
    line-height: 1.25 !important;
    margin: 2px 0 0 !important;
    padding: 0 !important;
    white-space: pre-line !important;
    overflow-wrap: anywhere !important;
}

.agent-official {
    font-size: 9px !important;
    font-weight: 400 !important;
    line-height: 1.25 !important;
    margin: 2px 0 !important;
    padding: 0 !important;
}

.agent-divider {
    width: 100% !important;
    font-family: "Courier New", Courier, monospace !important;
    font-size: 9px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-align: left !important;
    margin: 4px 0 !important;
    padding: 0 !important;
}

.agent-meta {
    width: 42ch !important;
    max-width: 100% !important;
    text-align: left !important;
    font-family: "Courier New", Courier, monospace !important;
    font-size: 9px !important;
    line-height: 1.25 !important;
    white-space: pre !important;
    overflow: hidden !important;
    margin: 1px 0 !important;
    padding: right !important;
}

.agent-item-header,
.agent-items,
.agent-total-line {
    font-family: "Courier New", Courier, monospace !important;
    font-size: 9px !important;
    line-height: 1.25 !important;
    text-align: left !important;
}

.agent-item-header {
    width: 42ch !important;
    max-width: 100% !important;
    white-space: pre !important;
    overflow: hidden !important;
    margin: 0 0 2px 0 !important;
    padding: 0 !important;
}

.agent-items {
    width: 42ch !important;
    max-width: 100% !important;
    white-space: pre-wrap !important;
    overflow-wrap: anywhere !important;
    margin: 0 !important;
    padding: 0 !important;
}

.agent-total-line {
    width: 42ch !important;
    max-width: 100% !important;
    white-space: pre !important;
    overflow: hidden !important;
    margin: 1px 0 !important;
    padding: 0 !important;
}

.agent-grand-total {
    font-weight: 700 !important;
}

.agent-footer {
    width: 100% !important;
    text-align: center !important;
    font-family: "Courier New", Courier, monospace !important;
    font-size: 9px !important;
    line-height: 1.25 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Keep receipt body scrollable while action buttons stay fixed. */
.receipt-box {
    max-height: calc(100vh - 20px) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.receipt-scroll {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
}

.receipt-buttons {
    flex: 0 0 auto !important;
}

/* 58mm browser-print target */
@media print {
    @page {
        size: 58mm auto;
        margin: 0;
    }

    html,
    body {
        width: 58mm !important;
        min-width: 58mm !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
    }

    #receiptContent {
        width: 58mm !important;
        max-width: 58mm !important;
        min-width: 0 !important;
        padding: 3mm !important;
        margin: 0 !important;
        font-size: 9px !important;
        line-height: 1.25 !important;
        overflow: hidden !important;
    }

    #receiptContent .agent-receipt {
        width: 42ch !important;
        max-width: 100% !important;
        margin: 0 auto !important;
    }
}

/* =========================================
   KG PRODUCT / CUSTOM KG
========================================= */

.kg-quantity-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kg-quantity-box .quantity-input {
    flex: 1;
}

.kg-unit {
    font-size: 13px;
    font-weight: 600;
    color: #102A43;
}

.custom-kg-box {
    display: none;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid #dfe3e8;
    border-radius: 9px;
    background: #f8fafc;
}

.custom-kg-box label {
    display: block;
    margin-bottom: 6px;
    color: #374151;
    font-size: 11px;
    font-weight: 600;
}

.custom-kg-input {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 10px;
    border: 1px solid #dfe3e8;
    border-radius: 7px;
    outline: none;
    font-family: inherit;
    font-size: 13px;
}

.custom-kg-input:focus {
    border-color: #102A43;
}

.custom-kg-result {
    margin-top: 7px;
    color: #102A43;
    font-size: 12px;
    font-weight: 600;
}

/* =========================================================
   CASHIER FULLSCREEN BUTTON
   ========================================================= */

.fullscreen-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.fullscreen-btn {
    border: none;
    background: rgba(255, 255, 255, 0.404);
    color: #640512a4;

    padding: 10px 14px;

    border-radius: 8px;

    font-family: inherit;
    font-size: 13px;
    font-weight: 600;

    cursor: pointer;

    white-space: nowrap;

    transition: 0.2s ease;
}

.fullscreen-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.fullscreen-btn.hidden {
    display: none !important;
}


/* FULLSCREEN MODE */

:fullscreen {
    background: #ffffff;
}

:fullscreen .topbar {
    position: relative;
}


/* MOBILE */

@media (max-width: 600px) {

    .fullscreen-btn {
        padding: 9px 10px;
        font-size: 12px;
    }

    .fullscreen-controls {
        gap: 5px;
    }

}
/* DEVICE PRODUCTS MANAGEMENT */
#productsPage{padding:22px}.device-products-wrap{width:100%;max-width:1400px;margin:0 auto}.device-products-header{display:flex;justify-content:space-between;align-items:flex-start;gap:18px;margin-bottom:18px}.device-products-header h2{margin:0;font-size:25px}.device-products-header p{margin:6px 0 8px;color:#6b7280}.device-products-device{display:inline-flex;padding:7px 11px;border-radius:999px;background:#eef6ff;color:#175a9a;font-weight:700;font-size:12px}.device-products-actions{display:flex;gap:8px;flex-wrap:wrap}.device-product-action{border:1px solid #d6dce4;background:#fff;color:#263445;border-radius:10px;padding:10px 13px;font-weight:800;cursor:pointer}.device-product-action.primary{background:#D96500;color:#fff;border-color:#D96500}.device-product-action.import{background:#1F4E79;color:#fff;border-color:#1F4E79}.device-products-toolbar{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:12px}.device-products-search{display:flex;align-items:center;gap:9px;background:#fff;border:1px solid #d7dee7;border-radius:11px;padding:0 12px;flex:1;max-width:560px}.device-products-search input{border:0;outline:0;width:100%;min-height:44px;background:transparent}.device-products-count{font-weight:800;color:#657180;font-size:13px}.device-products-status{min-height:0;margin-bottom:10px}.device-products-status.show{padding:10px 12px;border-radius:10px;font-weight:700;background:#eaf7ef;color:#17623d}.device-products-status.error{background:#fff0f0;color:#a12323}.device-products-table-card{background:#fff;border:1px solid #dce3ea;border-radius:14px;overflow:hidden}.device-products-table-scroll{overflow:auto}.device-products-table{width:100%;border-collapse:collapse;min-width:900px}.device-products-table th,.device-products-table td{padding:12px 13px;border-bottom:1px solid #edf0f3;text-align:left;font-size:13px}.device-products-table th{background:#f7f9fb;color:#53606e;font-size:12px;text-transform:uppercase}.device-products-empty{text-align:center!important;padding:35px!important;color:#7a8591}.device-product-actions{display:flex;gap:6px}.device-product-mini{border:0;border-radius:8px;padding:7px 9px;font-weight:800;cursor:pointer}.device-product-mini.edit{background:#fff1dd;color:#8a5000}.device-product-mini.delete{background:#ffe8e8;color:#a21f1f}.device-products-import-note{margin-top:10px;color:#74808d;font-size:12px}.device-product-edit-modal{position:fixed;inset:0;background:rgba(10,22,38,.56);display:none;align-items:center;justify-content:center;padding:18px;z-index:5000}.device-product-edit-modal.show{display:flex}.device-product-edit-card{background:#fff;border-radius:16px;width:min(760px,100%);max-height:90vh;overflow:auto;padding:20px}.device-product-edit-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:15px}.device-product-edit-head h3{margin:0}.device-product-close{border:0;background:#eef1f4;border-radius:9px;width:38px;height:38px;cursor:pointer}.device-product-form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}.device-product-form-grid .full{grid-column:1/-1}.device-product-form-grid label{display:block;font-size:12px;font-weight:800;margin-bottom:6px}.device-product-form-grid input,.device-product-form-grid select{width:100%;min-height:43px;border:1px solid #cfd8e1;border-radius:9px;padding:9px 10px}.device-product-edit-footer{display:flex;justify-content:flex-end;gap:8px;margin-top:16px}.device-product-edit-footer button{border:0;border-radius:9px;padding:10px 15px;font-weight:800;cursor:pointer}.device-product-edit-footer .cancel{background:#edf0f3}.device-product-edit-footer .save{background:#D96500;color:#fff}@media(max-width:800px){.device-products-header,.device-products-toolbar{flex-direction:column;align-items:stretch}.device-products-actions{width:100%}.device-product-action{flex:1}.device-product-form-grid{grid-template-columns:1fr}.device-product-form-grid .full{grid-column:auto}}

/* Device Products - refined layout */
#productsPage {
  padding: 26px;
  background: #f5f7fa;
}
#productsPage .device-products-wrap {
  max-width: 1500px;
  margin: 0 auto;
}
#productsPage .device-products-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 24px;
  margin-bottom: 16px;
  background: #fff;
  border: 1px solid #e3e8ee;
  border-radius: 16px;
  box-shadow: 0 3px 12px rgba(20, 32, 48, .05);
}
#productsPage .device-products-header > div:first-child {
  min-width: 0;
}
#productsPage .device-products-header h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: #17212b;
  font-size: 24px;
  line-height: 1.2;
}
#productsPage .device-products-header h2 i { font-size: 20px; }
#productsPage .device-products-header p {
  margin: 6px 0 10px;
  color: #718096;
  font-size: 13px;
}
#productsPage .device-products-device {
  padding: 6px 10px;
  border: 1px solid #d7e7f8;
  background: #f1f7fd;
  color: #245b89;
  font-size: 11px;
  letter-spacing: .1px;
}
#productsPage .device-products-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 8px;
  flex: 0 0 auto;
  min-width: 390px;
}
#productsPage .device-product-action {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
#productsPage .device-product-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(20,32,48,.08);
}
#productsPage .device-product-action.primary { box-shadow: 0 3px 8px rgba(22,131,75,.16); }
#productsPage .device-product-action.import { background: #1F4E79; border-color: #1F4E79; }
#productsPage .device-products-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 12px;
  background: #fff;
  border: 1px solid #e3e8ee;
  border-radius: 13px;
}
#productsPage .device-products-search {
  max-width: none;
  height: 44px;
  flex: 1;
  border-color: #d8e0e8;
  border-radius: 10px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.02);
}
#productsPage .device-products-search i { color: #7b8794; }
#productsPage .device-products-search input { font-size: 13px; }
#productsPage .device-products-count {
  flex: 0 0 auto;
  min-width: 86px;
  text-align: right;
  color: #64748b;
  font-size: 12px;
}
#productsPage .device-products-table-card {
  border-radius: 15px;
  border-color: #e0e6ec;
  box-shadow: 0 3px 12px rgba(20,32,48,.04);
}
#productsPage .device-products-table th {
  padding: 13px 14px;
  background: #f7f9fb;
  color: #64748b;
  font-size: 11px;
  letter-spacing: .35px;
}
#productsPage .device-products-table td {
  padding: 13px 14px;
  color: #334155;
  vertical-align: middle;
}
#productsPage .device-products-table tbody tr:hover { background: #fafcfe; }
#productsPage .device-product-actions {
  justify-content: flex-start;
  flex-wrap: nowrap;
}
#productsPage .device-product-mini {
  min-width: 34px;
  height: 34px;
  padding: 7px 9px;
  border: 1px solid transparent;
  transition: transform .15s ease, box-shadow .15s ease;
}
#productsPage .device-product-mini:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(20,32,48,.08);
}
#productsPage .device-product-mini.edit { border-color: #f2d39e; }
#productsPage .device-product-mini.delete { border-color: #f2c4c4; }
#productsPage .device-products-import-note {
  padding: 8px 3px 0;
  color: #7a8794;
}
@media (max-width: 1050px) {
  #productsPage .device-products-header { align-items: stretch; flex-direction: column; }
  #productsPage .device-products-actions { min-width: 0; width: 100%; }
}
@media (max-width: 620px) {
  #productsPage { padding: 14px; }
  #productsPage .device-products-header { padding: 18px; }
  #productsPage .device-products-actions { grid-template-columns: 1fr; }
  #productsPage .device-products-toolbar { align-items: stretch; flex-direction: column; }
  #productsPage .device-products-count { text-align: left; }
}

/* PRODUCTS PAGE - FULL WIDTH LAYOUT
   The shared .pos-page grid is designed for the Sale split layout.
   Products should use the entire content area instead of occupying only
   the left grid column and leaving an empty right column. */
#productsPage.active {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    grid-template-columns: none !important;
}

#productsPage .device-products-wrap {
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box;
}

#productsPage .device-products-header,
#productsPage .device-products-toolbar,
#productsPage .device-products-table-card {
    width: 100%;
    box-sizing: border-box;
}

#productsPage .device-products-header {
    min-height: 128px;
}

#productsPage .device-products-table-scroll {
    width: 100%;
}

#productsPage .device-products-table {
    min-width: 980px;
}

#productsPage .device-products-table th:first-child,
#productsPage .device-products-table td:first-child { width: 17%; }
#productsPage .device-products-table th:nth-child(2),
#productsPage .device-products-table td:nth-child(2) { width: 24%; }
#productsPage .device-products-table th:nth-child(3),
#productsPage .device-products-table td:nth-child(3),
#productsPage .device-products-table th:nth-child(4),
#productsPage .device-products-table td:nth-child(4) { width: 13%; }
#productsPage .device-products-table th:nth-child(5),
#productsPage .device-products-table td:nth-child(5),
#productsPage .device-products-table th:nth-child(6),
#productsPage .device-products-table td:nth-child(6) { width: 12%; }
#productsPage .device-products-table th:last-child,
#productsPage .device-products-table td:last-child { width: 130px; }

@media (max-width: 1050px) {
    #productsPage .device-products-header {
        min-height: auto;
    }
}


/* =========================================
   DEVICE PIN GATE
========================================= */
.device-pin-modal {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 24, 49, .62);
  backdrop-filter: blur(4px);
}
.device-pin-modal.show { display: flex; }
.device-pin-box {
  width: min(430px, 100%);
  background: #fff;
  border-radius: 20px;
  padding: 28px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(8, 24, 49, .28);
  animation: devicePinIn .18s ease-out;
}
.device-pin-icon {
  width: 52px; height: 52px; margin: 0 auto 12px;
  display:flex; align-items:center; justify-content:center;
  border-radius: 15px; background:#eef4ff; color:#102A43; font-size:22px;
}
.device-pin-box h2 { margin:0 0 7px; color:#102a43; font-size:21px; }
.device-pin-box p { margin:0 auto 20px; color:#718096; font-size:13px; line-height:1.5; max-width:330px; }
.device-pin-inputs { display:flex; justify-content:center; gap:9px; margin: 4px 0 14px; }
.device-pin-input {
  width: 48px; height: 58px; text-align:center; font-size:24px; font-weight:800;
  border:1px solid #d5dce6; border-radius:12px; outline:none; color:#102a43;
  background:#fbfcfe; box-sizing:border-box;
}
.device-pin-input:focus { border-color:#102A43; box-shadow:0 0 0 4px rgba(10,47,107,.10); background:#fff; }
.device-pin-status { min-height:20px; margin:8px 0 8px; font-size:12px; font-weight:600; color:#d33; }
.device-pin-status.success { color:#15803d; }
.device-pin-actions { display:flex; gap:10px; margin-top:14px; }
.device-pin-actions button { flex:1; min-height:44px; border:0; border-radius:11px; font:inherit; font-weight:700; cursor:pointer; }
.device-pin-cancel { background:#edf1f5; color:#344054; }
.device-pin-submit { background:#102A43; color:#fff; }
.device-pin-submit:disabled { opacity:.7; cursor:wait; }
@keyframes devicePinIn { from { opacity:0; transform:translateY(8px) scale(.98); } to { opacity:1; transform:none; } }
@media (max-width:520px) {
  .device-pin-box { padding:22px 16px; }
  .device-pin-inputs { gap:6px; }
  .device-pin-input { width:43px; height:54px; }
}

/* =========================================================
   SALE PAGE - MOBILE RESPONSIVE FIX
   Prevents the two-pane Sale layout from becoming too narrow
   on phones while keeping the desktop/tablet layout unchanged.
========================================================= */
@media (max-width: 700px) {
    #salePage.pos-page.active {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: calc(100vh - 62px) !important;
        padding: 10px !important;
        gap: 12px !important;
        overflow: visible !important;
    }

    #salePage .sale-left {
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    #salePage .sale-header {
        margin-bottom: 10px !important;
    }

    #salePage .sale-header h2 {
        font-size: 20px !important;
        line-height: 1.2;
    }

    #salePage .sale-header p {
        font-size: 11px !important;
        line-height: 1.4;
    }

    #salePage .search-section {
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box;
        gap: 6px !important;
    }

    #salePage .search-section i {
        padding-left: 5px !important;
        flex: 0 0 auto;
    }

    #salePage .search-section input {
        min-width: 0 !important;
        width: 100% !important;
        padding: 10px 6px !important;
        font-size: 12px !important;
    }

    #salePage .search-section button {
        flex: 0 0 auto;
        min-width: 74px !important;
        width: auto !important;
        height: 40px !important;
        padding: 0 11px !important;
        font-size: 11px !important;
    }

    #salePage .product-results {
        width: 100% !important;
        min-width: 0 !important;
        max-height: 48vh !important;
        margin-top: 10px !important;
        padding-right: 2px;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 10px !important;
    }

    #salePage .product-card {
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box;
        padding: 14px !important;
        border-radius: 12px;
    }

    #salePage .product-card h3 {
        font-size: 14px !important;
        line-height: 1.3;
    }

    #salePage .product-card .barcode,
    #salePage .product-card .stock-info {
        font-size: 10px !important;
    }

    #salePage .product-options {
        margin-top: 10px !important;
    }

    #salePage .sale-type {
        gap: 6px !important;
    }

    #salePage .sale-type span {
        padding: 8px 6px !important;
        font-size: 10px !important;
    }

    #salePage .quantity-input {
        box-sizing: border-box;
        padding: 9px !important;
    }

    #salePage .add-cart-btn {
        margin-top: 10px !important;
        padding: 10px !important;
        font-size: 12px !important;
    }

    #salePage .cart-panel {
        width: 100% !important;
        height: 430px !important;
        min-height: 430px !important;
        max-height: 430px !important;
        flex: 0 0 430px !important;
        box-sizing: border-box;
        overflow: hidden !important;
        border-radius: 14px;
    }

    #salePage .cart-header {
        padding: 12px !important;
    }

    #salePage .cart-header h2 {
        font-size: 14px !important;
    }

    #salePage .cart-header span {
        font-size: 9px !important;
    }

    #salePage .clear-cart {
        padding: 7px 10px !important;
        font-size: 10px !important;
    }

    #salePage .cart-items {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow-y: auto !important;
        padding: 8px !important;
    }

    #salePage .cart-item {
        padding: 11px !important;
    }

    #salePage .payment-section {
        flex: 0 0 auto !important;
        padding: 11px !important;
    }

    #salePage .summary-row {
        margin-bottom: 8px !important;
    }

    #salePage .summary-row span {
        font-size: 11px !important;
    }

    #salePage .summary-row strong {
        font-size: 15px !important;
    }

    #salePage .cash-input label {
        font-size: 9px !important;
    }

    #salePage .cash-input input {
        box-sizing: border-box;
        padding: 9px !important;
        font-size: 11px !important;
    }

    #salePage .pay-btn {
        width: 100% !important;
        min-height: 40px !important;
    }
}

@media (max-width: 380px) {
    #salePage.pos-page.active {
        padding: 8px !important;
        gap: 10px !important;
    }

    #salePage .search-section button {
        min-width: 42px !important;
        width: 42px !important;
        padding: 0 !important;
        font-size: 0 !important;
    }

    #salePage .search-section button i {
        margin: 0 !important;
        font-size: 13px !important;
    }

    #salePage .product-results {
        max-height: 44vh !important;
    }

    #salePage .cart-panel {
        height: 400px !important;
        min-height: 400px !important;
        max-height: 400px !important;
        flex-basis: 400px !important;
    }
}


/* =========================================
   TG-POS BRANDING
========================================= */
.brand-logo {
    max-height: 92px;
}

@media (max-width: 768px) {
    .logo-section {
        padding: 6px 2px 14px;
        margin-bottom: 14px;
    }

    .brand-logo {
        width: min(190px, 100%);
        max-height: 82px;
    }
}

@media (max-width: 380px) {
    .brand-logo {
        width: min(170px, 100%);
    }
}
