:root {
    --surface: #ffffff;
    --muted: #667085;
    --line: #e4e7ec;
    --ink: #101828;
    --accent: #0f766e;
    --warn: #b54708;
}

body {
    background: #f7f9fb;
    color: var(--ink);
    font-size: 14px;
}

.app-navbar {
    background: #1f2429;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    min-height: 62px;
    box-shadow: 0 10px 24px rgba(16, 24, 40, .10);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 230px;
    letter-spacing: 0;
    white-space: nowrap;
}

.brand-mark {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #0f766e;
    color: #fff;
    font-size: 17px;
}

.brand-logo {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-text {
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 700;
}

.app-nav {
    gap: 4px;
    align-items: center;
}

.app-nav .nav-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    padding: 8px 10px;
    border-radius: 8px;
    color: rgba(255, 255, 255, .70);
    font-weight: 600;
    line-height: 1;
}

.app-nav .nav-link i {
    font-size: 16px;
    line-height: 1;
}

.app-nav .nav-link:hover,
.app-nav .nav-link:focus {
    color: #fff;
    background: rgba(255, 255, 255, .08);
}

.app-nav .nav-link.active,
.app-nav .show > .nav-link {
    color: #fff;
    background: #30363d;
}

.app-menu {
    min-width: 220px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 40px rgba(16, 24, 40, .18);
}

.app-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 7px;
    padding: 9px 10px;
    font-weight: 600;
}

.app-menu .dropdown-item i {
    width: 18px;
    color: #475467;
}

.app-menu .dropdown-item.active,
.app-menu .dropdown-item:active {
    background: #e6f4f1;
    color: #0f5f59;
}

.user-menu {
    flex: 0 0 auto;
}

.user-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    border: 1px solid rgba(255, 255, 255, .28);
    color: #fff;
    background: transparent;
    font-weight: 700;
    max-width: 190px;
}

.user-button span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-button:hover,
.user-button:focus {
    color: #fff;
    background: rgba(255, 255, 255, .08);
}

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    min-height: 110px;
}

.stat .label {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.stat .value {
    font-size: 24px;
    font-weight: 700;
    margin-top: 8px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.panel-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.panel-body {
    padding: 16px;
}

.table thead th {
    color: #475467;
    font-size: 12px;
    text-transform: uppercase;
    background: #f9fafb;
}

.form-error {
    color: #b42318;
    font-size: 12px;
    margin-top: 4px;
}

.required::after {
    content: " *";
    color: #b42318;
}

.badge-soft {
    background: #ecfdf3;
    color: #067647;
}

.product-thumb {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.item-scan-input {
    font-weight: 600;
}

.invoice-service-entry {
    max-width: 760px;
}

.invoice-form .line-quantity-heading,
.invoice-form .line-quantity-cell {
    display: none;
}

.invoice-form .invoice-lines input,
.invoice-form .invoice-lines select {
    min-width: 0;
}

.action-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.invoice-lines input,
.invoice-lines select {
    min-width: 110px;
}

.invoice-lines,
.pos-lines {
    position: relative;
    margin-bottom: 0;
}

.invoice-lines tbody tr,
.pos-lines tbody tr {
    position: relative;
}

.invoice-lines tbody tr:has(.searchable-combobox.open),
.pos-lines tbody tr:has(.searchable-combobox.open) {
    z-index: 1080;
}

.billing-form .table-responsive,
.pos-form .table-responsive {
    overflow: visible;
}

.billing-form .panel-body,
.pos-form .panel-body,
.panel:has(.searchable-combobox.open),
.panel-body:has(.searchable-combobox.open) {
    overflow: visible;
}

.searchable-combobox {
    position: relative;
    min-width: 180px;
    z-index: 1;
}

.searchable-combobox.open {
    z-index: 1090;
}

.searchable-combobox select {
    display: none !important;
}

.searchable-trigger {
    width: 100%;
    min-height: 38px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fff;
    padding: 6px 34px 6px 12px;
    text-align: left;
    position: relative;
}

.searchable-trigger::after {
    content: "";
    position: absolute;
    right: 12px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid #667085;
    border-bottom: 2px solid #667085;
    transform: translateY(-70%) rotate(45deg);
}

.searchable-menu {
    display: none;
    position: fixed;
    z-index: 2050;
    left: 0;
    top: 0;
    width: 240px;
    background: #fff;
    border: 1px solid #cfd4dc;
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(16, 24, 40, .18);
    padding: 8px;
}

.searchable-combobox.open .searchable-menu {
    display: block;
}

.searchable-options {
    max-height: 220px;
    overflow: auto;
    margin-top: 6px;
}

.searchable-option {
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
}

.searchable-option:hover,
.searchable-option.active {
    background: #eef4ff;
}

.print-document {
    width: 210mm;
    max-width: calc(100vw - 48px);
    margin: 32px auto;
    background: #fff;
    border: 1px solid var(--line);
    padding: 32px;
    box-sizing: border-box;
}

.print-header {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 2px solid #101828;
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.print-header > div:first-child {
    min-width: 0;
}

.print-header > div:last-child {
    flex: 0 0 52mm;
    overflow-wrap: anywhere;
}

.print-company-block {
    display: block;
}

.print-company-logo {
    display: block;
    width: 82px;
    max-height: 82px;
    object-fit: contain;
    margin-bottom: 10px;
}

.company-logo-preview {
    max-width: 180px;
    max-height: 80px;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 6px;
    background: #fff;
}

.verify-qr {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 22px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    page-break-inside: avoid;
}

.verify-qr img {
    width: 104px;
    height: 104px;
}

@media print {
    @page {
        size: A4;
        margin: 10mm;
    }

    .navbar,
    .no-print,
    .toast-container,
    .btn {
        display: none !important;
    }

    body {
        background: #fff;
        margin: 0;
        font-size: 11pt;
    }

    main.container-fluid {
        padding: 0 !important;
    }

    .print-document {
        border: 0;
        margin: 0;
        width: auto;
        max-width: none;
        padding: 7mm;
        box-sizing: border-box;
    }

    .panel {
        border: 0;
        margin: 0;
        width: auto;
        max-width: none;
        padding: 0;
    }

    .print-document .table {
        width: 100%;
        margin-bottom: 12px;
    }

    .print-document .table th,
    .print-document .table td {
        padding: 6px 7px;
        vertical-align: top;
    }

    .print-document .h3 {
        font-size: 20pt;
    }

    .print-header {
        gap: 12mm;
    }
}

@media (max-width: 1199.98px) {
    .app-brand {
        min-width: 0;
        max-width: calc(100vw - 92px);
    }

    .app-nav {
        align-items: stretch;
        gap: 2px;
        padding-top: 12px;
    }

    .app-nav .nav-link {
        width: 100%;
        justify-content: flex-start;
    }

    .user-menu {
        margin-top: 10px;
    }

    .user-button {
        width: 100%;
        justify-content: space-between;
        max-width: none;
    }
}

@media (min-width: 1200px) {
    .app-navbar .container-fluid {
        gap: 12px;
    }

    .app-navbar .navbar-collapse {
        min-width: 0;
    }
}

.pos-shell {
    height: calc(100vh - 92px);
    min-height: 560px;
    margin: -16px;
    background: #d5dbe4;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.pos-toolbar {
    min-height: 42px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #48546a;
    font-size: 15px;
}

.pos-toolbar-actions {
    display: flex;
    gap: 8px;
}

.pos-stage {
    padding: 12px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.pos-form {
    height: 100%;
    min-height: 0;
}

.pos-main {
    display: grid;
    grid-template-columns: minmax(620px, 1.32fr) minmax(420px, .95fr);
    gap: 12px;
    height: 100%;
    min-height: 0;
}

.pos-cart,
.pos-products {
    min-width: 0;
}

.pos-cart {
    background: #fff;
    border-radius: 7px;
    padding: 16px;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.pos-entry-row {
    display: grid;
    grid-template-columns: minmax(240px, .42fr) minmax(340px, 1fr);
    gap: 14px;
}

.pos-client-box,
.pos-scan-box {
    display: flex;
    align-items: stretch;
}

.pos-client-box > i,
.pos-scan-box > i {
    width: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #d6dbe3;
    background: #f8fafc;
    color: #596579;
}

.pos-client-box .searchable-combobox {
    flex: 1;
}

.pos-client-box .searchable-trigger,
.pos-scan-box .form-control {
    border-radius: 0;
    min-height: 42px;
}

.pos-scan-box .form-control {
    flex: 1;
    font-size: 16px;
}

.pos-scan-add {
    border-radius: 0;
    width: 48px;
}

.pos-cart-table-wrap {
    flex: 1 1 auto;
    height: 0;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    max-height: none;
    min-height: 120px;
    overscroll-behavior: contain;
}

.pos-cart-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.pos-cart-table th:nth-child(1),
.pos-cart-table td:nth-child(1) {
    width: 24%;
}

.pos-cart-table th:nth-child(2),
.pos-cart-table td:nth-child(2) {
    width: 15%;
}

.pos-cart-table th:nth-child(3),
.pos-cart-table td:nth-child(3),
.pos-cart-table th:nth-child(4),
.pos-cart-table td:nth-child(4),
.pos-cart-table th:nth-child(5),
.pos-cart-table td:nth-child(5) {
    width: 10%;
}

.pos-cart-table th:nth-child(6),
.pos-cart-table td:nth-child(6) {
    width: 11%;
}

.pos-cart-table th:nth-child(7),
.pos-cart-table td:nth-child(7) {
    width: 13%;
}

.pos-cart-table th:nth-child(8),
.pos-cart-table td:nth-child(8) {
    width: 7%;
}

.pos-cart-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #f5f6f8;
    color: #4c5872;
    font-size: 13px;
    text-transform: none;
    border-bottom: 1px solid #e4e7ec;
}

.pos-cart-table tbody td {
    vertical-align: top;
    background: #fff;
    padding: 8px 6px;
}

.pos-cart-table .form-control,
.pos-cart-table .form-select,
.pos-cart-table .searchable-trigger {
    min-width: 0;
    min-height: 38px;
    padding: 6px 8px;
    font-size: 14px;
}

.pos-cart-table tbody tr {
    border-bottom: 1px solid #edf0f4;
}

.pos-line-text {
    display: block;
    min-height: 38px;
    padding: 7px 0;
    color: #111827;
    line-height: 1.25;
    word-break: break-word;
}

.pos-item-display {
    font-weight: 700;
}

.pos-line-label:empty {
    display: none;
}

.pos-qty-stepper {
    display: grid;
    grid-template-columns: 34px minmax(42px, 1fr) 34px;
}

.pos-qty-stepper .btn,
.pos-qty-display {
    border-radius: 0;
}

.pos-qty-display {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    border-top: 1px solid #dee2e6;
    border-bottom: 1px solid #dee2e6;
    font-weight: 700;
}

.pos-line-total {
    background: #fff;
    font-weight: 700;
}

.pos-service-line .pos-qty-stepper {
    display: none;
}

.pos-summary-strip {
    flex: 0 0 auto;
    margin-top: 0;
    border-top: 1px solid #eef1f5;
    padding: 12px 4px 8px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    color: #4d5871;
    font-size: 15px;
}

.pos-payment-row {
    flex: 0 0 auto;
    border-top: 1px solid #eef1f5;
    padding-top: 10px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.pos-payment-select {
    width: 170px;
}

.pos-reference-input {
    width: 220px;
}

.pos-cash-tendered,
.pos-change-returned {
    width: 160px;
}

.pos-payable {
    color: #475467;
    font-size: 16px;
    white-space: nowrap;
}

.pos-payable strong {
    color: #16a34a;
    font-size: 24px;
}

.pos-action-row {
    flex: 0 0 auto;
    padding-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pos-products {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
    height: 100%;
}

.pos-category-filter {
    max-width: 360px;
    min-height: 44px;
}

.pos-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
    gap: 12px;
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow: auto;
    padding: 0 4px 8px 0;
    align-content: start;
}

.pos-product-tile {
    border: 0;
    background: #fff;
    border-radius: 4px;
    min-height: 132px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: inset 0 0 0 1px #dfe3ea;
    cursor: pointer;
}

.pos-product-tile:hover,
.pos-product-tile:focus {
    box-shadow: inset 0 0 0 2px #0d6efd, 0 8px 18px rgba(16, 24, 40, .14);
}

.pos-product-image {
    width: 68px;
    height: 58px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eef3f6;
    color: #a0a9b5;
    overflow: hidden;
}

.pos-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pos-product-name {
    max-width: 100%;
    color: #6a6f78;
    font-weight: 700;
    text-align: center;
    line-height: 1.15;
    min-height: 32px;
    overflow: hidden;
}

.pos-product-price {
    color: #d92d20;
    font-weight: 800;
}

.pos-calculator-display {
    text-align: right;
    font-size: 24px;
    font-weight: 800;
}

.pos-calculator-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.pos-calculator-grid .btn {
    min-height: 42px;
    font-weight: 700;
}

.pos-calc-equals {
    grid-column: span 2;
}

.pagination-wrap {
    display: flex;
    justify-content: flex-end;
    padding-top: 12px;
}

.pagination .page-link {
    color: #344054;
    border-color: var(--line);
}

.pagination .page-item.active .page-link {
    background: #1f2429;
    border-color: #1f2429;
}

.log-details {
    max-width: 360px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 1180px) {
    .pos-shell {
        height: auto;
        min-height: calc(100vh - 92px);
        overflow: visible;
    }

    .pos-stage {
        overflow: visible;
    }

    .pos-form {
        height: auto;
    }

    .pos-main {
        grid-template-columns: 1fr;
        height: auto;
    }

    .pos-cart {
        height: auto;
        min-height: auto;
    }

    .pos-cart-table-wrap {
        height: auto;
        max-height: 420px;
    }
}

@media (max-width: 760px) {
    .pos-entry-row,
    .pos-summary-strip {
        grid-template-columns: 1fr;
    }

    .pos-payment-row {
        display: grid;
        grid-template-columns: 1fr;
    }

    .pos-payment-select,
    .pos-reference-input {
        width: 100%;
    }
}
