* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: Arial, sans-serif;
    background: #f4f6f8;
    color: #17202a;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
    border: 0;
    border-radius: 9px;
    padding: 10px 13px;
}

button:disabled {
    opacity: .55;
    cursor: not-allowed;
}

input,
select,
textarea {
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #64748b;
    box-shadow: 0 0 0 2px #e5e7eb;
}


/* =========================================================
   APP
   ========================================================= */

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


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

.side {
    position: fixed;
    inset: 0 auto 0 0;
    width: 235px;
    background: #111827;
    color: #fff;
    padding: 18px 12px;
    z-index: 50;
}

.brand {
    font-size: 21px;
    font-weight: 800;
    padding: 8px 10px 20px;
}

.brand small {
    display: block;
    color: #9ca3af;
    font-size: 10px;
    margin-top: 4px;
}

.nav button {
    display: block;
    width: 100%;
    background: none;
    color: #cbd5e1;
    text-align: left;
    margin: 3px 0;
}

.nav button.active,
.nav button:hover {
    background: #1f2937;
    color: #fff;
}

.nav .new {
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    padding: 3px 6px;
    border-radius: 99px;
    margin-left: 5px;
}


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

.main {
    margin-left: 235px;
    width: calc(100% - 235px);
    padding: 20px;
}

.top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.top h1 {
    margin: 0;
}

.clock {
    color: #64748b;
    font-size: 13px;
}


/* =========================================================
   PAGES
   ========================================================= */

.page {
    display: none;
}

.page.active {
    display: block;
}


/* =========================================================
   CARDS
   ========================================================= */

.cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.card,
.panel {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 12px #0000000b;
}

.card {
    padding: 18px;
}

.label {
    color: #64748b;
    font-size: 13px;
}

.value {
    font-size: 25px;
    font-weight: 800;
    margin-top: 7px;
}


/* =========================================================
   POS
   ========================================================= */

.posgrid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    gap: 16px;
}

.search {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.search input {
    flex: 1;
}

.search input,
.toolbar input,
.form input,
.form select,
.modal input,
.modal select,
.modal textarea,
.creditbox input,
.creditbox textarea,
#creditorSearch {
    width: 100%;
    padding: 11px;
    border: 1px solid #dbe1e8;
    border-radius: 9px;
}

.cats {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    margin-bottom: 13px;
    padding-bottom: 2px;
}

.cats button {
    white-space: nowrap;
    background: #eef2f7;
}

.cats button.active {
    background: #111827;
    color: #fff;
}

.products {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.product {
    border: 1px solid #e3e7ec;
    background: #fff;
    text-align: left;
    padding: 11px;
    border-radius: 12px;
    transition: .15s;
}

.product:hover {
    border-color: #111827;
    transform: translateY(-1px);
}

.product img,
.ph {
    width: 100%;
    height: 105px;
    object-fit: cover;
    border-radius: 8px;
}

.ph {
    background: #eef2f7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
}

.pname {
    font-weight: 700;
    margin-top: 8px;
}

.price {
    margin-top: 3px;
}

.stock {
    font-size: 12px;
    color: #64748b;
    margin-top: 3px;
}


/* =========================================================
   CART
   ========================================================= */

.cart {
    position: sticky;
    top: 20px;
}

.cart h2 {
    margin: 0 0 10px;
}

.cartitems {
    min-height: 180px;
    max-height: 350px;
    overflow: auto;
}

.cartrow {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid #edf0f3;
}

.cartname {
    font-weight: 700;
}

.qty {
    display: flex;
    gap: 5px;
    align-items: center;
    margin-top: 5px;
}

.qty button {
    padding: 4px 8px;
    background: #eef2f7;
}

.summary {
    border-top: 1px solid #e5e7eb;
    margin-top: 10px;
    padding-top: 10px;
}

.sumrow {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin: 7px 0;
}

.total {
    font-size: 22px;
    font-weight: 800;
}

.discount-input {
    width: 110px !important;
    padding: 7px !important;
}


/* =========================================================
   BUTTONS
   ========================================================= */

.primary {
    background: #111827;
    color: #fff;
}

.success {
    background: #16834b;
    color: #fff;
}

.danger {
    background: #dc3545;
    color: #fff;
}

.muted {
    background: #e9eef3;
    color: #17202a;
}

.creditBtn {
    background: #7c3aed;
    color: #fff;
}

.payBtn {
    background: #16a34a;
    color: #fff;
}

.ewallet {
    background: #7c3aed;
    color: #fff;
}

.cardBtn {
    background: #2563eb;
    color: #fff;
}

.full {
    width: 100%;
}

.clear-btn {
    margin-top: 7px;
}

.paymentBtns {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 12px;
}


/* =========================================================
   TOOLBAR
   ========================================================= */

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.toolbar .left,
.toolbar .right {
    display: flex;
    gap: 8px;
}


/* =========================================================
   TABLE
   ========================================================= */

.tablewrap {
    overflow: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 11px 9px;
    border-bottom: 1px solid #e8ebef;
    text-align: left;
    font-size: 14px;
    white-space: nowrap;
}

.table th {
    color: #64748b;
    font-size: 12px;
}


/* =========================================================
   STATUS
   ========================================================= */

.badge {
    padding: 4px 8px;
    border-radius: 99px;
    font-size: 11px;
}

.low {
    background: #fff0f0;
    color: #b42318;
}

.ok {
    background: #e9f8ef;
    color: #167647;
}

.status-low {
    color: #dc2626;
    font-weight: 700;
}

.status-ok {
    color: #16834b;
    font-weight: 700;
}

.unpaid {
    color: #dc2626;
    font-weight: 700;
}

.paid {
    color: #16834b;
    font-weight: 700;
}


/* =========================================================
   FORMS
   ========================================================= */

.form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form label,
.modal label,
.creditbox label {
    display: block;
    color: #64748b;
    font-size: 12px;
    margin: 0 0 5px;
}

.fullrow {
    grid-column: 1 / -1;
}


/* =========================================================
   MODAL
   ========================================================= */

.modalbg {
    display: none;
    position: fixed;
    z-index: 100;
    inset: 0;
    background: #0008;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modalbg.show {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: 15px;
    width: min(560px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
}

.modal h2 {
    margin-top: 0;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}


/* =========================================================
   CREDIT
   ========================================================= */

.creditbox {
    margin-top: 12px;
    border: 1px solid #e3d5ff;
    background: #fbf8ff;
    padding: 14px;
    border-radius: 12px;
}

.credit-layout {
    display: grid;
    grid-template-columns: 330px 1fr 280px;
    gap: 14px;
}

.credit-list {
    max-height: 500px;
    overflow: auto;
}

.credit-person {
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    border-radius: 10px;
}

.credit-person:hover,
.credit-person.selected {
    background: #f4f0ff;
}

.credit-person .name {
    font-weight: 700;
}

.credit-person .balance {
    float: right;
    color: #dc2626;
    font-weight: 800;
}

.credit-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 12px 0;
}

.mini {
    background: #f7f8fa;
    border-radius: 10px;
    padding: 10px;
    text-align: center;
}

.mini b {
    display: block;
    font-size: 18px;
    margin-top: 3px;
}

.credit-history {
    max-height: 450px;
    overflow: auto;
}


/* =========================================================
   RECEIPT
   ========================================================= */

.receipt {
    font-family: monospace;
    width: 300px;
    max-width: 100%;
    margin: auto;
}

.receipt h2 {
    text-align: center;
}

.rline {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}


/* =========================================================
   MISC
   ========================================================= */

.empty {
    text-align: center;
    color: #94a3b8;
    padding: 35px;
}

.notice {
    padding: 12px;
    background: #fff7df;
    border-radius: 10px;
    color: #7a5a00;
    margin-bottom: 12px;
}

.small-notice {
    margin-top: 10px;
    margin-bottom: 0;
}

.hidden {
    display: none !important;
}

.mt16 {
    margin-top: 16px;
}

.no-margin {
    margin: 0;
}


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

@media (max-width: 1100px) {

    .cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .products {
        grid-template-columns: repeat(3, 1fr);
    }

    .posgrid {
        grid-template-columns: 1fr;
    }

    .cart {
        position: static;
    }

    .credit-layout {
        grid-template-columns: 1fr;
    }

}


@media (max-width: 700px) {

    .side {
        width: 68px;
    }

    .brand {
        font-size: 0;
    }

    .brand small {
        display: none;
    }

    .nav button {
        font-size: 0;
        text-align: center;
        padding: 12px 4px;
    }

    .nav button:first-letter {
        font-size: 18px;
    }

    .main {
        margin-left: 68px;
        width: calc(100% - 68px);
        padding: 12px;
    }

    .products {
        grid-template-columns: repeat(2, 1fr);
    }

    .form {
        grid-template-columns: 1fr;
    }

    .cards {
        grid-template-columns: 1fr 1fr;
    }

    .paymentBtns {
        grid-template-columns: 1fr 1fr;
    }

    .toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar .left,
    .toolbar .right {
        width: 100%;
    }

}


@media (max-width: 450px) {

    .cards {
        grid-template-columns: 1fr;
    }

    .products {
        grid-template-columns: 1fr 1fr;
        gap: 7px;
    }

    .paymentBtns {
        grid-template-columns: 1fr;
    }

    .modalbg {
        padding: 10px;
    }

    .modal {
        padding: 15px;
    }

}

/* =========================================================
   AUTH / USER / PERMISSIONS
   ========================================================= */

.top-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.current-user {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
}

.logout-btn {
    padding: 8px 11px;
}

.permission-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
    margin-bottom: 10px;
    padding-top: 14px;
    border-top: 1px solid #e5e7eb;
}

.permission-header h3 {
    margin: 0 0 3px;
}

.muted-text {
    color: #64748b;
    font-size: 12px;
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.permission-item,
.check-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    background: #f8fafc;
    cursor: pointer;
}

.permission-item input,
.check-row input {
    width: 17px;
    height: 17px;
    accent-color: #111827;
}

.full-access-row {
    background: #eef2ff;
    border-color: #c7d2fe;
}

.employee-modal {
    width: min(680px, 100%);
}

.access-list {
    max-width: 520px;
}

.access-badge {
    display: inline-block;
    margin: 2px 3px 2px 0;
    padding: 3px 7px;
    border-radius: 99px;
    background: #eef2f7;
    font-size: 11px;
}

.user-active {
    color: #16834b;
    font-weight: 700;
}

.user-inactive {
    color: #dc2626;
    font-weight: 700;
}

.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #f4f6f8;
}

.login-card {
    width: min(430px, 100%);
    background: #fff;
    padding: 28px;
    border-radius: 16px;
    box-shadow: 0 5px 30px #00000012;
}

.login-card h1 {
    margin-top: 0;
}

.login-card label {
    display: block;
    color: #64748b;
    font-size: 12px;
    margin: 12px 0 5px;
}

.login-card input {
    width: 100%;
    padding: 12px;
    border: 1px solid #dbe1e8;
    border-radius: 9px;
}

.login-card button {
    margin-top: 15px;
    width: 100%;
}

.login-error {
    color: #dc2626;
    background: #fff1f2;
    border-radius: 8px;
    padding: 9px;
    margin-top: 10px;
    font-size: 13px;
}

.login-help {
    color: #64748b;
    font-size: 12px;
    margin-top: 12px;
}

@media (max-width: 900px) {
    .permission-grid {
        grid-template-columns: 1fr;
    }
    .top-right {
        flex-wrap: wrap;
        justify-content: flex-end;
    }
}


/* =========================================================
   REPORT BREAKDOWN
   ========================================================= */
.report-select {
    min-width: 180px;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
}

.report-summary {
    margin: 4px 0 14px;
    padding: 11px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f8fafc;
}
