* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: #eef3f8;
    color: #152033;
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.45;
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
}

a {
    color: #175cd3;
    text-decoration: none;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid #d8dee9;
    box-shadow: 0 8px 24px rgba(21, 32, 51, 0.06);
    backdrop-filter: blur(10px);
}

.brand-block {
    display: grid;
    gap: 2px;
}

.topbar h1 {
    margin: 0;
    font-size: 20px;
}

.brand-block span {
    color: #667085;
    font-size: 13px;
}

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

.nav-icon {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
}

.nav a,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 13px;
    border: 1px solid #c8d2e4;
    border-radius: 6px;
    background: #ffffff;
    color: #152033;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.nav a:hover,
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(21, 32, 51, 0.08);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn.primary {
    border-color: #1455c0;
    background: #1455c0;
    color: #ffffff;
}

.btn.danger {
    border-color: #c0392b;
    background: #c0392b;
    color: #ffffff;
}

.wrap {
    width: calc(100% - 24px);
    max-width: none;
    margin: 14px auto 28px;
}

.panel {
    margin-bottom: 18px;
    padding: 16px;
    background: #ffffff;
    border: 1px solid #d8dee9;
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(21, 32, 51, 0.06);
}

.panel h2 {
    margin: 0 0 14px;
    font-size: 18px;
}

.report-list-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.report-list-heading h2 {
    margin: 0;
}

.report-export-btn {
    width: 38px;
    min-width: 38px;
    padding: 0;
}

.report-export-btn svg {
    width: 18px;
    height: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}

.product-form {
    display: grid;
    gap: 12px;
}

.product-main-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.unit-grid {
    display: grid;
    grid-template-columns: minmax(180px, 1.1fr) 120px 145px 145px minmax(220px, 1.5fr) auto;
    gap: 10px;
    align-items: end;
    padding: 10px;
    border: 1px solid #e1e6f0;
    border-radius: 8px;
    background: #f8fafc;
}

.lot-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(150px, 1fr)) auto;
    gap: 10px;
    align-items: end;
    padding: 10px;
    border: 1px solid #e1e6f0;
    border-radius: 8px;
    background: #f8fafc;
}

.subhead {
    margin: 6px 0 0;
    font-size: 15px;
}

.optional-add {
    width: fit-content;
}

.optional-remove {
    min-height: 32px;
    padding: 6px 10px;
    align-self: end;
}

.lot-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
}

.lot-list span {
    padding: 5px 8px;
    border-radius: 6px;
    background: #eef2f8;
    color: #172033;
    font-size: 13px;
}

.import-detail {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.import-detail span {
    padding: 5px 8px;
    border-radius: 6px;
    background: #eef2f8;
    font-size: 13px;
}

.order-code {
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;
    border-radius: 999px;
    background: #eef2ff;
    color: #1455c0;
    font-weight: 900;
    white-space: nowrap;
}

.sale-order-row td {
    vertical-align: middle;
}

.sale-order-detail-row {
    background: #fff8e6 !important;
}

.sale-order-detail-row td {
    border-top: 1px dashed #f0c36a;
}

.sale-order-detail {
    display: grid;
    gap: 12px;
}

.sale-order-detail-head {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.sale-order-detail-head span {
    padding: 5px 9px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid #f0d391;
    font-size: 13px;
    font-weight: 800;
}

.sale-order-items {
    display: grid;
    gap: 8px;
}

.sale-order-item {
    display: grid;
    grid-template-columns: minmax(180px, 1.4fr) repeat(3, minmax(110px, .7fr));
    gap: 8px;
    align-items: center;
    padding: 10px;
    border: 1px solid #ead7a4;
    border-radius: 8px;
    background: #ffffff;
}

.sale-order-item small {
    grid-column: 1 / -1;
}

.detail-toggle {
    min-height: 30px;
    padding: 5px 8px;
    font-size: 12px;
}

.sale-order-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.print-order-btn {
    min-height: 30px;
    padding: 5px 8px;
    font-size: 12px;
    white-space: nowrap;
}

.report-filter {
    display: grid;
    grid-template-columns: 160px minmax(190px, 1fr) minmax(180px, 1fr) minmax(220px, 1.2fr) minmax(180px, 1fr) auto;
    gap: 12px;
    align-items: end;
}

select {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid #aeb8cc;
    border-radius: 6px;
    background: #ffffff;
    font: inherit;
    font-size: 16px;
}

.category-new-input {
    margin-top: 2px;
}

.report-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.report-card {
    display: grid;
    gap: 6px;
    padding: 14px;
    border: 1px solid #d8dee9;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 10px 22px rgba(21, 32, 51, 0.05);
}

.report-card span {
    color: #5b667a;
    font-size: 13px;
}

.report-card strong {
    font-size: 22px;
    color: #1455c0;
}

.tax-filter {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr)) auto;
    gap: 12px;
    align-items: end;
}

.tax-filter label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.tax-table-wrap {
    overflow-x: auto;
}

.report-tables {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}

.settings-form {
    display: grid;
    gap: 18px;
    max-width: 860px;
}

.settings-group {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 14px;
    border: 1px solid #d8dee9;
    border-radius: 8px;
    background: #fbfdff;
}

.settings-group legend {
    padding: 0 6px;
    color: #152033;
    font-weight: 800;
}

.settings-choice {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: flex-start;
    padding: 10px;
    border: 1px solid #e1e6f0;
    border-radius: 8px;
    background: #ffffff;
}

.settings-choice input {
    width: auto;
    min-height: auto;
    margin-top: 4px;
}

.settings-choice input[type="number"] {
    width: 120px;
    min-height: 40px;
}

.settings-choice span {
    display: grid;
    gap: 2px;
}

.settings-choice small {
    color: #667085;
    font-weight: 400;
}

.report-tables tbody tr:nth-child(odd) {
    background: #f8fbff;
}

.report-tables tbody tr:nth-child(even) {
    background: #eef6ff;
}

.report-tables tbody tr:hover {
    background: #e1efff;
}

.report-tables tbody tr[hidden] {
    display: none;
}

.report-tables tbody tr[id^="import-detail-"],
.report-tables tbody tr[id^="sale-detail-"] {
    background: #fff8e6;
}

.report-tables tbody tr[id^="import-detail-"] td,
.report-tables tbody tr[id^="sale-detail-"] td {
    border-top: 1px dashed #f0c36a;
}

.monthly-report-grid,
.report-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 18px;
}

.chart-panel {
    min-height: 320px;
}

.chart-panel-wide {
    grid-column: 1 / -1;
}

.chart-panel canvas {
    max-height: 260px;
}

.monthly-finance-panel canvas {
    max-height: 320px;
}

.chart-empty {
    display: grid;
    min-height: 180px;
    place-items: center;
    margin: 0;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.inventory-dashboard {
    display: grid;
    grid-template-columns: repeat(6, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.metric-card {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid #d8dee9;
    border-radius: 8px;
    background: #f8fafc;
}

.metric-card span {
    color: #5b667a;
    font-size: 12px;
    font-weight: 700;
}

.metric-card strong {
    color: #1455c0;
    font-size: 24px;
    line-height: 1;
}

.metric-card.warn strong {
    color: #a15c00;
}

.metric-card.danger strong {
    color: #b42318;
}

.inventory-tools {
    display: grid;
    grid-template-columns: minmax(320px, 1.6fr) minmax(190px, 0.8fr) minmax(170px, 0.7fr) 120px auto auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 8px;
    padding: 12px;
    border: 1px solid #e1e6f0;
    border-radius: 8px;
    background: #fbfcff;
}

.account-tools {
    display: grid;
    grid-template-columns: minmax(260px, 1.4fr) minmax(180px, 0.8fr) minmax(180px, 0.8fr) auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 8px;
    padding: 12px;
    border: 1px solid #e1e6f0;
    border-radius: 8px;
    background: #fbfcff;
}

.user-filter-result {
    min-height: 20px;
    margin: 0 0 12px;
}

.product-filter-result {
    min-height: 20px;
    margin: 0 0 12px;
}

.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 12px;
}

.pagination-controls span {
    min-width: 84px;
    color: #5b667a;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

.pagination-controls .btn.disabled {
    pointer-events: none;
    opacity: 0.55;
}

.report-pagination {
    margin: 12px 0 0;
}

.report-product-name {
    color: #0066cc;
}

.product-card {
    margin-bottom: 14px;
    padding: 16px;
    border: 1px solid #d8dee9;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 10px 22px rgba(21, 32, 51, 0.05);
}

.product-view-card {
    position: relative;
    overflow: hidden;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.product-view-card.is-editing {
    border-color: #1455c0;
    box-shadow: 0 14px 32px rgba(20, 85, 192, 0.12);
}

.product-view-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: #1455c0;
}

.product-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}

.product-title-block {
    display: grid;
    gap: 3px;
}

/* CUSTOM UI: Tên sản phẩm nhỏ lại (16px) và có màu xanh */
.product-title-block strong {
    font-size: 16px; 
    color: #0066cc; 
    font-weight: 500;
}

.product-card-actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.code-list-toggle,
.product-edit-toggle {
    min-width: 86px;
}

.product-summary {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    margin-bottom: 14px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
}

.product-summary span {
    display: grid;
    gap: 2px;
    flex: 0 0 auto;
    min-width: max-content;
    min-height: 46px;
    padding: 7px 9px;
    border: 1px solid #e1e6f0;
    border-radius: 8px;
    background: #f8fafc;
    color: #152033;
    font-size: 12px;
    line-height: 1.25;
    white-space: nowrap;
}

.product-summary strong {
    color: #5b667a;
    font-size: 11px;
}

.product-summary b {
    font-size: 13px;
}

.product-summary small {
    color: #0f8a4b;
    font-size: 10px;
    font-weight: 400;
}

.stock-summary {
    border-color: #9adfba !important;
    background: var(--success-soft) !important;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 9px;
    border: 1px solid #b8e4c8;
    border-radius: 999px;
    background: #e8f6ee;
    color: #17623a;
    font-size: 12px;
    font-weight: 800;
}

.status-badge.expiring {
    border-color: #f4d29d;
    background: #fff7e6;
    color: #8a4b00;
}

.status-badge.low {
    border-color: #f4d29d;
    background: #fff7e6;
    color: #8a4b00;
}

.status-badge.out {
    border-color: #f2b8b5;
    background: #fdeceb;
    color: #982b25;
}

.product-edit-form:not(.is-readonly) .product-summary {
    display: none;
}

.product-view-card:not(.is-editing) .product-delete-form {
    display: none;
}

/* Ẩn khối edit-actions ở chế độ xem */
.product-edit-form.is-readonly .product-main-grid,
.product-edit-form.is-readonly > .unit-grid,
.product-edit-form.is-readonly > .subhead,
.product-edit-form.is-readonly > .lot-grid,
.product-edit-form.is-readonly > .lot-list,
.product-edit-form.is-readonly .optional-add,
.product-edit-form.is-readonly .optional-remove,
.product-edit-form.is-readonly .edit-actions {
    display: none;
}

/* CUSTOM UI: Hiển thị các nút thao tác ngang hàng KHI VÀ CHỈ KHI đang ở chế độ sửa */
form.product-edit-form:not(.is-readonly) .edit-actions {
    display: flex;
    flex-wrap: wrap; /* Cho phép rớt dòng nếu mở trên Mobile */
    gap: 8px;
    align-items: center;
    margin-top: 16px;
}

.product-edit-form.is-readonly input:not([type="hidden"]),
.product-edit-form.is-readonly select,
.product-edit-form.is-readonly textarea {
    border-color: transparent;
    background: transparent;
    color: #152033;
    -webkit-text-fill-color: #152033;
    pointer-events: none;
}

.product-edit-toggle {
    flex: 0 0 auto;
}

.edit-cancel {
    min-width: 72px;
}

.history-list {
    display: grid;
    gap: 8px;
}

.history-item {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid #e1e6f0;
    border-radius: 8px;
    background: #fbfcff;
}

.history-action {
    display: inline-flex;
    justify-content: center;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef2f8;
    color: #344054;
    font-size: 12px;
    font-weight: 800;
}

.stock-warn {
    flex: 0 0 auto;
    padding: 5px 8px;
    border-radius: 6px;
    background: #fdeceb;
    color: #982b25;
    font-weight: 700;
}

.unit-code-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 10px;
    margin: 12px 0;
}

.unit-code-item {
    display: grid;
    gap: 5px;
    padding: 10px;
    border: 1px solid #e1e6f0;
    border-radius: 8px;
    background: #fbfcff;
}

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

.code-actions .btn {
    min-height: 30px;
    padding: 5px 8px;
    font-size: 12px;
}

.code-actions .code-download[data-kind="qr"] {
    border-color: #0f766e;
    background: #e6fffb;
    color: #0f514a;
}

.code-actions .code-download[data-kind="barcode"] {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
}

.code-actions .code-print[data-price="show"] {
    border-color: #d97706;
    background: #fffbeb;
    color: #92400e;
}

.code-actions .code-print[data-price="hide"] {
    border-color: #7c3aed;
    background: #f5f3ff;
    color: #5b21b6;
}

.code-actions .code-download:hover,
.code-actions .code-print:hover {
    filter: brightness(0.98);
}

.code-actions .code-print:not([data-price]) {
    display: none;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 700;
    font-size: 14px;
}

.unit-grid label {
    white-space: nowrap;
}

input {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid #bdc8da;
    border-radius: 6px;
    font: inherit;
    font-size: 16px;
    background: #ffffff;
}

input:focus,
select:focus {
    outline: 2px solid rgba(20, 85, 192, 0.18);
    border-color: #1455c0;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
}

th,
td {
    padding: 11px;
    border-bottom: 1px solid #e1e6f0;
    text-align: left;
    vertical-align: middle;
}

th {
    background: #f1f5fa;
    font-size: 14px;
    color: #344054;
}

tbody tr:hover {
    background: #f8fafc;
}

.code-box {
    display: grid;
    grid-template-columns: 120px 170px;
    gap: 12px;
    align-items: center;
}

.qr,
.barcode {
    min-height: 78px;
    padding: 6px;
    background: #ffffff;
    border: 1px solid #e1e6f0;
    border-radius: 6px;
}

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

.cart-actions,
.cart-empty-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 14px;
}

.cart-actions.secondary {
    margin-top: 8px;
}

.cart-empty-actions {
    justify-content: flex-start;
}

.notice {
    padding: 10px 12px;
    margin-bottom: 14px;
    border: 1px solid #b8e4c8;
    border-radius: 6px;
    background: #e8f6ee;
    color: #17623a;
}

.error {
    padding: 10px 12px;
    margin-bottom: 14px;
    border: 1px solid #f2b8b5;
    border-radius: 6px;
    background: #fdeceb;
    color: #982b25;
}

.scanner-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 18px;
}

.scan-app {
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    background: #101828;
}

.scan-app .topbar {
    height: 58px;
    padding: 10px max(14px, env(safe-area-inset-left)) 10px max(14px, env(safe-area-inset-right));
    background: #ffffff;
}

.scan-app .topbar h1 {
    font-size: 18px;
}

.scan-app .nav {
    gap: 6px;
}

.scan-app .nav a {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 13px;
}

.scan-app .wrap {
    width: 100%;
    min-height: calc(100dvh - 58px);
    margin: 0;
    padding: 12px;
    overflow: visible;
}

.scan-shell {
    min-height: calc(100dvh - 82px);
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 12px;
}

.scan-camera-panel,
.scan-cart-panel {
    min-height: 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: #ffffff;
}

.scan-camera-panel {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
    gap: 10px;
    padding: 12px;
}

.scan-cart-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    padding: 12px;
    overflow: visible;
}

.scan-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.scan-title h2 {
    margin: 0;
    font-size: 17px;
}

.scan-title span {
    flex: 0 0 auto;
    color: #5b667a;
    font-size: 13px;
}

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

.scan-mode-btn {
    min-height: 40px;
    border: 1px solid #c8d2e4;
    border-radius: 8px;
    background: #f7fafc;
    color: #344054;
    cursor: pointer;
    font-weight: 800;
}

.scan-mode-btn.active {
    border-color: #1455c0;
    background: #e7f0ff;
    color: #0647b8;
    box-shadow: inset 0 0 0 1px rgba(20, 85, 192, 0.16);
}

.reader-frame {
    position: relative;
    min-height: 0;
    overflow: hidden;
    border-radius: 8px;
    background: #111827;
}

#reader {
    width: 100%;
    height: 100%;
    min-height: 360px;
    overflow: hidden;
    border: 1px solid #d8dee9;
    border-radius: 8px;
    background: #111827;
}

#reader video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

.scan-corners {
    position: absolute;
    inset: 50%;
    width: min(340px, 86%);
    height: min(220px, 52%);
    transform: translate(-50%, -50%);
    border: 2px solid rgba(255, 255, 255, 0.88);
    border-radius: 8px;
    box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.22);
    pointer-events: none;
}

.scan-status {
    min-height: 42px;
    margin: 0;
    display: flex;
    align-items: center;
}

.scan-manual-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 86px;
    gap: 8px;
}

.scanner-gun-form {
    display: grid;
    gap: 6px;
    padding: 10px;
    border: 1px solid #b7d7ff;
    border-radius: 8px;
    background: #f4f9ff;
}

.scanner-gun-form label {
    font-size: 13px;
    color: #0647b8;
}

.scanner-gun-form input {
    min-height: 44px;
    border-color: #7fb3ff;
    font-size: 16px;
    font-weight: 800;
}

.scanner-gun-form small {
    color: #5b667a;
    font-size: 12px;
}

.scan-manual-form input,
.scan-manual-form button {
    min-height: 44px;
}

.scan-mode-camera .scanner-gun-form {
    display: none;
}

.scan-mode-scanner .reader-frame {
    display: none;
}

.scan-cart-panel #cart-preview {
    min-height: 0;
    overflow: visible;
}

.scan-cart-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding-top: 10px;
}

.scan-cart-actions .btn {
    width: 100%;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 18px;
    background: #eef3f8;
}

.login-box {
    width: min(420px, 100%);
    padding: 24px;
    border: 1px solid #d8dee9;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 18px 50px rgba(21, 32, 51, 0.12);
}

.login-box h1 {
    margin: 0 0 4px;
    font-size: 22px;
}

.login-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 110px;
    height: 55px;
    margin-bottom: 14px;
    border-radius: 8px;
    background: #1455c0;
    color: #ffffff;
    font-weight: 800;
}

.panel table {
    overflow: hidden;
    border: 1px solid #e1e6f0;
    border-radius: 8px;
}

.scan-app .topbar {
    position: static;
    box-shadow: none;
    backdrop-filter: none;
}

.login-box form,
.user-form {
    display: grid;
    gap: 12px;
}

.sso-login-button {
    display: flex;
    width: 100%;
    margin-top: 18px;
    justify-content: center;
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0;
    color: #64748b;
    font-size: 13px;
}

.login-divider::before,
.login-divider::after {
    content: "";
    height: 1px;
    flex: 1;
    background: #d8dee9;
}

.account-list {
    display: grid;
    gap: 10px;
}

.account-card {
    padding: 12px;
    border: 1px solid #d8dee9;
    border-radius: 8px;
    background: #ffffff;
}

.account-view {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(240px, auto) auto;
    gap: 12px;
    align-items: center;
}

.account-main {
    display: grid;
    gap: 3px;
}

.account-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
}

.account-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.account-root {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #eef2f8;
    color: #344054;
    font-size: 12px;
    font-weight: 800;
}

.account-edit-form {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    align-items: end;
}

.account-edit-actions {
    align-self: end;
}

.remember-line,
.table-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
}

.remember-line input,
.table-check input {
    width: auto;
    min-height: 0;
}

.user-form {
    grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
    align-items: end;
}

.scan-cart-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}

.scan-cart-row.just-updated {
    background: #e8f6ee;
}

.scan-cart-line {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.scan-cart-top {
    justify-content: space-between;
}

.scan-cart-bottom {
    display: grid;
    grid-template-columns: auto minmax(72px, 1fr) auto;
    justify-content: initial;
}

.scan-item-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.unit-price {
    flex: 0 0 auto;
    color: #5b667a;
    font-size: 13px;
}

.qty-stepper {
    display: grid;
    grid-template-columns: 30px 34px 30px;
    height: 32px;
    overflow: hidden;
    border: 1px solid #b8c2d6;
    border-radius: 6px;
    background: #ffffff;
}

.qty-btn,
.scan-qty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: #ffffff;
    color: #172033;
    font-weight: 700;
    font-size: 16px;
}

.qty-btn {
    cursor: pointer;
}

.qty-btn:first-child {
    border-right: 1px solid #d8dee9;
}

.qty-btn:last-child {
    border-left: 1px solid #d8dee9;
}

.scan-qty {
    color: #175cd3;
    font-size: 14px;
}

.line-total {
    margin-left: 0;
    color: #17623a;
    font-size: 14px;
    text-align: right;
    white-space: nowrap;
}

.scan-remove-btn {
    min-height: 32px;
    padding: 5px 8px;
    font-size: 12px;
}

.scan-cart-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0 0;
    border-top: 1px solid #e1e6f0;
    font-size: 15px;
}

.scan-cart-total strong {
    color: #17623a;
    font-size: 17px;
}

.cart-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #e1e6f0;
}

.muted {
    color: #5b667a;
}

@media (max-width: 760px) {
    .topbar,
    .form-grid,
    .scanner-layout {
        grid-template-columns: 1fr;
        display: grid;
    }

    .code-box {
        grid-template-columns: 1fr;
    }

    .product-main-grid,
    .unit-grid,
    .lot-grid,
    .inventory-dashboard,
    .inventory-tools,
    .account-tools,
    .report-filter,
    .monthly-report-grid,
    .report-chart-grid,
    .report-cards,
    .report-tables {
        grid-template-columns: 1fr;
    }

    .product-card-head {
        display: grid;
    }

    .history-item {
        grid-template-columns: 1fr;
    }

    .scan-app .topbar {
        display: flex;
        align-items: center;
        height: 54px;
        overflow-x: auto;
    }

    .scan-app .topbar h1 {
        flex: 0 0 auto;
    }

    .scan-app .nav {
        flex: 0 0 auto;
        flex-wrap: nowrap;
        margin-left: auto;
    }

    .scan-app .wrap {
        min-height: calc(100dvh - 54px);
        padding: 8px;
    }

    .scan-shell {
        display: grid;
        grid-template-rows: minmax(0, 1fr) auto;
        min-height: calc(100dvh - 70px);
        gap: 8px;
    }

    .scan-camera-panel {
        padding: 10px;
        gap: 8px;
    }

    .scan-title h2 {
        font-size: 16px;
    }

    .scan-title span {
        font-size: 12px;
    }

    #reader {
        min-height: 0;
    }

    .scan-cart-panel {
        padding: 10px;
    }

    .scan-cart-panel .cart-row {
        padding: 8px 0;
        font-size: 14px;
    }

    .scan-cart-row {
        gap: 5px;
    }

    .qty-stepper {
        grid-template-columns: 28px 32px 28px;
        height: 30px;
    }

    .line-total {
        font-size: 13px;
    }

    .scan-cart-total {
        padding-top: 8px;
        font-size: 14px;
    }

    .scan-cart-total strong {
        font-size: 16px;
    }

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

    .account-view,
    .account-edit-form {
        grid-template-columns: 1fr;
    }

    .account-meta {
        justify-content: flex-start;
    }

    .account-actions {
        justify-content: flex-start;
    }
}

/* Professional visual refresh */
:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --surface-tint: #edf6ff;
    --text: #111827;
    --muted: #64748b;
    --line: #dbe4ef;
    --line-strong: #c4d2e4;
    --primary: #0f6bff;
    --primary-dark: #0647b8;
    --primary-soft: #e7f0ff;
    --success: #0f8a4b;
    --success-soft: #e8f8ef;
    --warning: #b76a00;
    --warning-soft: #fff6df;
    --danger: #c8322b;
    --danger-soft: #fff0ee;
    --shadow-sm: 0 8px 20px rgba(15, 23, 42, 0.07);
    --shadow-md: 0 18px 42px rgba(15, 23, 42, 0.11);
    --radius: 8px;
}

html {
    scrollbar-color: #b9c7d8 transparent;
}

body {
    background:
        radial-gradient(circle at top left, rgba(15, 107, 255, 0.1), transparent 30rem),
        linear-gradient(180deg, #f7fbff 0%, var(--bg) 45%, #eef3f8 100%);
    color: var(--text);
    font-family: Inter, "Segoe UI", Roboto, Arial, Helvetica, sans-serif;
}

a {
    color: var(--primary-dark);
}

.topbar {
    min-height: 68px;
    padding: 12px 22px;
    border-bottom: 1px solid rgba(196, 210, 228, 0.75);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

.brand-block {
    position: relative;
    padding-left: 46px;
}

.brand-block::before {
    content: "HQD";
    position: absolute;
    left: 0;
    top: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    transform: translateY(-50%);
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), #00a3ff);
    color: #ffffff;
    font-size: 12px;
    font-weight: 900;
    box-shadow: 0 10px 18px rgba(15, 107, 255, 0.24);
}

.topbar h1 {
    color: #0f172a;
    font-size: 21px;
    line-height: 1.12;
}

.brand-block span,
.muted {
    color: var(--muted);
}

.nav {
    gap: 9px;
}

.nav a,
.btn {
    gap: 7px;
    min-height: 40px;
    border-color: var(--line-strong);
    border-radius: var(--radius);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    color: #172033;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.nav a::before {
    content: "";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 5px;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 18px 18px;
}

.nav a[href="index.php"]::before {
    background-image: url("data:image/svg+xml,%3Csvg%20width='18'%20height='18'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3E%3Cpath%20d='M21%208L12%203L3%208L12%2013L21%208Z'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linejoin='round'/%3E%3Cpath%20d='M3%208V16L12%2021L21%2016V8'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linejoin='round'/%3E%3Cpath%20d='M12%2013V21'%20stroke='%230647B8'%20stroke-width='2'/%3E%3C/svg%3E");
}

.nav a[href="scan.php"]::before {
    background-image: url("data:image/svg+xml,%3Csvg%20width='18'%20height='18'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3E%3Cpath%20d='M4%207V5C4%204.45%204.45%204%205%204H7'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linecap='round'/%3E%3Cpath%20d='M17%204H19C19.55%204%2020%204.45%2020%205V7'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linecap='round'/%3E%3Cpath%20d='M20%2017V19C20%2019.55%2019.55%2020%2019%2020H17'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linecap='round'/%3E%3Cpath%20d='M7%2020H5C4.45%2020%204%2019.55%204%2019V17'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linecap='round'/%3E%3Cpath%20d='M7%2012H17'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linecap='round'/%3E%3Cpath%20d='M8%208H9V16H8V8Z%20M12%208H13V16H12V8Z%20M16%208H17V16H16V8Z'%20fill='%230647B8'/%3E%3C/svg%3E");
}

.nav a[href^="cart.php"]::before {
    background-image: url("data:image/svg+xml,%3Csvg%20width='18'%20height='18'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3E%3Cpath%20d='M6%206H21L19%2014H8L6%206Z'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linejoin='round'/%3E%3Cpath%20d='M6%206L5.4%203.8C5.16%203.02%204.44%202.5%203.62%202.5H3'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linecap='round'/%3E%3Cpath%20d='M9%2019.5H9.01M18%2019.5H18.01'%20stroke='%230647B8'%20stroke-width='3'%20stroke-linecap='round'/%3E%3C/svg%3E");
}

.nav a[href="reports.php"]::before {
    background-image: url("data:image/svg+xml,%3Csvg%20width='18'%20height='18'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3E%3Cpath%20d='M4%2019V5'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linecap='round'/%3E%3Cpath%20d='M4%2019H20'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linecap='round'/%3E%3Cpath%20d='M8%2016V11'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linecap='round'/%3E%3Cpath%20d='M12%2016V8'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linecap='round'/%3E%3Cpath%20d='M16%2016V13'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linecap='round'/%3E%3C/svg%3E");
}

.nav a[href="users.php"]::before {
    background-image: url("data:image/svg+xml,%3Csvg%20width='18'%20height='18'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3E%3Cpath%20d='M16%2020C16%2017.8%2014.2%2016%2012%2016H7C4.8%2016%203%2017.8%203%2020'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linecap='round'/%3E%3Cpath%20d='M9.5%2012C11.43%2012%2013%2010.43%2013%208.5C13%206.57%2011.43%205%209.5%205C7.57%205%206%206.57%206%208.5C6%2010.43%207.57%2012%209.5%2012Z'%20stroke='%230647B8'%20stroke-width='2'/%3E%3Cpath%20d='M17%2011L19%2013L22%209'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3E%3C/svg%3E");
}

.nav a[href="settings.php"]::before {
    background-image: url("data:image/svg+xml,%3Csvg%20width='18'%20height='18'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle%20cx='12'%20cy='12'%20r='3'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3E%3Cpath%20d='M19.4%2015a1.65%201.65%200%200%200%20.33%201.82l.06.06a2%202%200%200%201%200%202.83%202%202%200%200%201-2.83%200l-.06-.06a1.65%201.65%200%200%200-1.82-.33%201.65%201.65%200%200%200-1%201.51V21a2%202%200%200%201-2%202%202%202%200%200%201-2-2v-.09A1.65%201.65%200%200%200%209%2019.4a1.65%201.65%200%200%200-1.82.33l-.06.06a2%202%200%200%201-2.83%200%202%202%200%200%201%200-2.83l.06-.06a1.65%201.65%200%200%200%20.33-1.82%201.65%201.65%200%200%200-1.51-1H3a2%202%200%200%201-2-2%202%202%200%200%201%202-2h.09A1.65%201.65%200%200%200%204.6%209a1.65%201.65%200%200%200-.33-1.82l-.06-.06a2%202%200%200%201%200-2.83%202%202%200%200%201%202.83%200l.06.06a1.65%201.65%200%200%200%201.82.33H9a1.65%201.65%200%200%200%201-1.51V3a2%202%200%200%201%202-2%202%202%200%200%201%202%202v.09a1.65%201.65%200%200%200%201%201.51%201.65%201.65%200%200%200%201.82-.33l.06-.06a2%202%200%200%201%202.83%200%202%202%200%200%201%200%202.83l-.06.06a1.65%201.65%200%200%200-.33%201.82V9a1.65%201.65%200%200%200%201.51%201H21a2%202%200%200%201%202%202%202%202%200%200%201-2%202h-.09a1.65%201.65%200%200%200-1.51%201z'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3E%3C/svg%3E");
}

.nav a[href="logout.php"]::before {
    background-image: url("data:image/svg+xml,%3Csvg%20width='18'%20height='18'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3E%3Cpath%20d='M14%207L19%2012L14%2017'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3E%3Cpath%20d='M19%2012H9'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linecap='round'/%3E%3Cpath%20d='M10%204H6C5.45%204%205%204.45%205%205V19C5%2019.55%205.45%2020%206%2020H10'%20stroke='%230647B8'%20stroke-width='2'%20stroke-linecap='round'/%3E%3C/svg%3E");
}

.nav a:hover,
.btn:hover {
    border-color: rgba(15, 107, 255, 0.42);
    background: #ffffff;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.1);
}

.btn.primary {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--primary) 0%, #00a3ff 100%);
    color: #ffffff;
    box-shadow: 0 12px 24px rgba(15, 107, 255, 0.22);
}

.btn.primary:hover {
    border-color: var(--primary-dark);
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}

.btn.danger {
    border-color: var(--danger);
    background: linear-gradient(135deg, var(--danger) 0%, #f05245 100%);
    color: #ffffff;
    box-shadow: 0 12px 24px rgba(200, 50, 43, 0.18);
}

.wrap {
    width: calc(100% - 36px);
    margin-top: 18px;
}

.panel,
.product-card,
.report-card,
.account-card,
.login-box {
    border-color: rgba(196, 210, 228, 0.88);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow-sm);
}

.panel {
    padding: 18px;
}

.panel h2,
.scan-title h2,
.login-box h1 {
    color: #0f172a;
    letter-spacing: 0;
}

.form-grid,
.product-form,
.report-filter,
.user-form,
.account-edit-form {
    gap: 14px;
}

.unit-grid,
.lot-grid,
.inventory-tools,
.history-item,
.unit-code-item,
.product-summary span {
    border-color: var(--line);
    background: linear-gradient(180deg, #fbfdff 0%, var(--surface-soft) 100%);
}

label {
    color: #243044;
}

input,
select {
    min-height: 42px;
    border-color: var(--line-strong);
    border-radius: var(--radius);
    color: var(--text);
    background: #ffffff;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}

input:focus,
select:focus {
    outline: 3px solid rgba(15, 107, 255, 0.15);
    border-color: var(--primary);
    box-shadow: 0 0 0 1px rgba(15, 107, 255, 0.1);
}

.inventory-dashboard {
    gap: 12px;
}

.metric-card,
.report-card {
    position: relative;
    overflow: hidden;
    background: linear-gradient(145deg, #ffffff 0%, #f6fbff 100%);
}

.metric-card::before,
.report-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--primary);
}

.metric-card span,
.report-card span,
.product-summary strong {
    color: var(--muted);
}

.metric-card strong,
.report-card strong {
    color: var(--primary);
}

.metric-card.warn::before {
    background: var(--warning);
}

.metric-card.warn strong {
    color: var(--warning);
}

.metric-card.danger::before {
    background: var(--danger);
}

.metric-card.danger strong {
    color: var(--danger);
}

.product-view-card::before {
    background: linear-gradient(180deg, var(--primary), #00a3ff);
}

.product-view-card.is-editing {
    border-color: rgba(15, 107, 255, 0.55);
    box-shadow: 0 18px 40px rgba(15, 107, 255, 0.14);
}

.status-badge,
.account-root,
.history-action {
    border-radius: 999px;
}

.status-badge {
    border-color: #9adfba;
    background: var(--success-soft);
    color: var(--success);
}

.status-badge.expiring,
.status-badge.low {
    border-color: #f5cf84;
    background: var(--warning-soft);
    color: var(--warning);
}

.status-badge.out {
    border-color: #f4b4ae;
    background: var(--danger-soft);
    color: var(--danger);
}

table {
    border-spacing: 0;
}

th {
    background: linear-gradient(180deg, #eef5ff 0%, #e7eef8 100%);
    color: #263449;
    font-weight: 800;
}

td,
th {
    border-bottom-color: var(--line);
}

tbody tr:hover {
    background: #f4f9ff;
}

.notice,
.error {
    border-radius: var(--radius);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.notice {
    border-color: #9adfba;
    background: var(--success-soft);
    color: var(--success);
}

.error {
    border-color: #f4b4ae;
    background: var(--danger-soft);
    color: var(--danger);
}

.code-box {
    align-items: stretch;
}

.qr,
.barcode {
    border-color: var(--line);
    border-radius: var(--radius);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.login-page {
    background:
        radial-gradient(circle at 20% 15%, rgba(0, 163, 255, 0.22), transparent 22rem),
        radial-gradient(circle at 85% 85%, rgba(15, 138, 75, 0.16), transparent 20rem),
        linear-gradient(135deg, #edf6ff 0%, #f7fbff 48%, #eef3f8 100%);
}

.login-box {
    padding: 28px;
    box-shadow: var(--shadow-md);
}

.login-mark {
    background: linear-gradient(135deg, var(--primary), #00a3ff);
    box-shadow: 0 14px 28px rgba(15, 107, 255, 0.25);
}

.scan-app {
    background:
        radial-gradient(circle at top left, rgba(15, 107, 255, 0.24), transparent 28rem),
        linear-gradient(135deg, #0b1220 0%, #111827 48%, #162033 100%);
}

.scan-app .topbar {
    background: rgba(255, 255, 255, 0.96);
}

.scan-camera-panel,
.scan-cart-panel {
    border-color: rgba(255, 255, 255, 0.16);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.22);
}

.reader-frame,
#reader {
    border-radius: var(--radius);
}

#reader {
    border-color: rgba(255, 255, 255, 0.12);
}

.scan-corners {
    border-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.28), 0 0 32px rgba(0, 163, 255, 0.3);
}

.scan-corners::before {
    content: "";
    position: absolute;
    left: 8%;
    right: 8%;
    top: 50%;
    height: 2px;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 0 14px rgba(0, 163, 255, 0.55);
}

.scan-cart-row {
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
}

.scan-cart-row.just-updated {
    border-color: #9adfba;
    background: var(--success-soft);
}

.qty-stepper {
    border-color: var(--line-strong);
    border-radius: var(--radius);
}

.qty-btn:hover {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.scan-qty,
.line-total,
.scan-cart-total strong {
    color: var(--success);
}

@media (max-width: 760px) {
    .topbar {
        padding: 10px 12px;
    }

    .brand-block {
        padding-left: 40px;
    }

    .brand-block::before {
        width: 32px;
        height: 32px;
    }

    .wrap {
        width: calc(100% - 20px);
        margin-top: 12px;
    }

    .nav a,
    .btn {
        min-height: 38px;
    }

    .panel {
        padding: 14px;
    }
}

/* Interface upgrade layer */
.nav a.active {
    border-color: rgba(15, 107, 255, 0.7);
    background: var(--primary-soft);
    color: var(--primary-dark);
    box-shadow: 0 10px 22px rgba(15, 107, 255, 0.12);
}

.nav-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--primary);
    color: #ffffff;
    font-size: 12px;
    line-height: 1;
}

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.section-heading h2 {
    margin-bottom: 4px;
}

.section-heading p {
    margin: 0;
}

.cart-grand-total {
    flex: 0 0 auto;
    min-width: 190px;
    padding: 12px 14px;
    border: 1px solid #9adfba;
    border-radius: var(--radius);
    background: var(--success-soft);
    color: var(--success);
    font-size: 22px;
    line-height: 1;
    text-align: right;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
}

.table-wrap table {
    min-width: 720px;
}

.cart-table-wrap input[type="number"] {
    max-width: 110px;
}

.cart-table-wrap td:last-child,
.cart-table-wrap th:last-child {
    text-align: right;
}

.scan-title.compact h2 {
    font-size: 18px;
}

.scan-cart-actions .btn:last-child {
    min-height: 48px;
    font-size: 15px;
}

.scan-manual-form .btn {
    min-width: 96px;
}

.account-meta .status-badge {
    min-height: 28px;
}

@media (max-width: 760px) {
    .topbar {
        align-items: stretch;
        gap: 10px;
    }

    .nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 2px;
        scrollbar-width: thin;
    }

    .nav a {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .section-heading {
        display: grid;
        gap: 10px;
    }

    .cart-grand-total {
        width: 100%;
        min-width: 0;
        text-align: left;
    }

    .cart-table-wrap {
        border: 0;
        background: transparent;
    }

    .cart-table-wrap table,
    .cart-table-wrap thead,
    .cart-table-wrap tbody,
    .cart-table-wrap tfoot,
    .cart-table-wrap tr,
    .cart-table-wrap td,
    .cart-table-wrap th {
        display: block;
        min-width: 0;
        width: 100%;
    }

    .cart-table-wrap thead {
        display: none;
    }

    .cart-table-wrap tbody {
        display: grid;
        gap: 10px;
    }

    .cart-table-wrap tbody tr {
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: #ffffff;
        box-shadow: var(--shadow-sm);
    }

    .cart-table-wrap td {
        display: grid;
        grid-template-columns: 100px minmax(0, 1fr);
        gap: 10px;
        padding: 8px 0;
        border: 0;
    }

    .cart-table-wrap td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        font-weight: 800;
    }

    .cart-table-wrap input[type="number"] {
        max-width: none;
    }

    .cart-table-wrap tfoot {
        margin-top: 12px;
        padding: 12px;
        border: 1px solid #9adfba;
        border-radius: var(--radius);
        background: var(--success-soft);
    }

    .cart-table-wrap tfoot tr {
        display: grid;
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .cart-table-wrap tfoot th {
        padding: 0;
        border: 0;
        background: transparent;
        color: var(--success);
        text-align: left;
    }

    .cart-actions,
    .cart-actions.secondary,
    .cart-empty-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .cart-actions .btn,
    .cart-empty-actions .btn,
    .cart-actions form {
        width: 100%;
    }

    .cart-actions form .btn {
        width: 100%;
    }
}

/* Mobile app experience */
@media (max-width: 760px) {
    body {
        min-height: 100dvh;
        padding-bottom: calc(82px + env(safe-area-inset-bottom));
        background: linear-gradient(180deg, #f7fbff 0%, #eef4fb 100%);
    }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 40;
        display: block;
        min-height: 58px;
        padding: max(10px, env(safe-area-inset-top)) 14px 10px;
        border-bottom: 1px solid rgba(196, 210, 228, 0.8);
        border-radius: 0 0 14px 14px;
        box-shadow: 0 10px 26px rgba(15, 23, 42, 0.1);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    .brand-block {
        min-height: 38px;
        padding-left: 44px;
        align-content: center;
    }

    .brand-block::before {
        width: 34px;
        height: 34px;
    }

    .topbar h1 {
        max-width: calc(100vw - 72px);
        overflow: hidden;
        font-size: 18px;
        line-height: 1.15;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .brand-block span {
        max-width: calc(100vw - 72px);
        overflow: hidden;
        font-size: 12px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .topbar .nav {
        position: fixed;
        inset: auto 10px max(10px, env(safe-area-inset-bottom)) 10px;
        z-index: 60;
        display: grid;
        grid-auto-columns: minmax(74px, 1fr);
        grid-auto-flow: column;
        gap: 6px;
        max-width: 620px;
        margin: 0 auto;
        padding: 8px;
        overflow-x: auto;
        border: 1px solid rgba(196, 210, 228, 0.9);
        border-radius: 18px;
        background: rgba(255, 255, 255, 0.96);
        box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        scrollbar-width: none;
    }

    .topbar .nav::-webkit-scrollbar {
        display: none;
    }

    .topbar .nav a {
        position: relative;
        display: grid;
        grid-template-rows: 22px auto;
        justify-items: center;
        gap: 3px;
        min-height: 54px;
        min-width: 72px;
        padding: 6px 5px;
        border: 0;
        border-radius: 13px;
        background: transparent;
        color: #475569;
        box-shadow: none;
        font-size: 11px;
        line-height: 1.15;
        text-align: center;
        white-space: normal;
    }

    .topbar .nav a::before {
        width: 22px;
        height: 22px;
        background-size: 22px 22px;
    }

    .topbar .nav a.active {
        background: var(--primary-soft);
        color: var(--primary-dark);
        box-shadow: none;
    }

    .topbar .nav a:hover {
        transform: none;
        box-shadow: none;
    }

    .nav-count {
        position: absolute;
        top: 4px;
        right: 7px;
        min-width: 19px;
        height: 19px;
        padding: 0 5px;
        font-size: 11px;
    }

    .wrap {
        width: 100%;
        margin: 0;
        padding: 12px 10px 10px;
    }

    .panel,
    .product-card,
    .account-card,
    .report-card,
    .login-box {
        border-radius: 12px;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    }

    .panel {
        margin-bottom: 12px;
        padding: 14px;
    }

    .panel h2 {
        font-size: 17px;
    }

    .btn,
    input,
    select {
        min-height: 46px;
        border-radius: 10px;
    }

    .btn {
        padding: 10px 13px;
        font-size: 15px;
    }

    .btn.primary {
        box-shadow: 0 12px 26px rgba(15, 107, 255, 0.22);
    }

    .inventory-dashboard,
    .report-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .metric-card,
    .report-card {
        min-height: 92px;
        padding: 13px;
        border-radius: 12px;
    }

    .metric-card strong,
    .report-card strong {
        font-size: 22px;
    }

    .inventory-tools,
    .account-tools,
    .form-grid,
    .product-main-grid,
    .unit-grid,
    .lot-grid,
    .report-filter,
    .user-form,
    .account-edit-form {
        gap: 10px;
    }

    .product-card-head {
        gap: 10px;
    }

    .product-card-actions,
    .account-actions,
    .actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }

    .product-card-actions .btn,
    .account-actions .btn,
    .actions .btn {
        width: 100%;
    }

    .product-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .product-summary span {
        min-height: 46px;
        border-radius: 8px;
    }

    .history-item {
        border-radius: 12px;
    }

    .table-wrap {
        border-radius: 12px;
    }

    .scan-app {
        padding-bottom: calc(88px + env(safe-area-inset-bottom));
        background: #0f172a;
    }

    .scan-app .topbar {
        position: sticky;
        height: auto;
        min-height: 58px;
        padding: max(10px, env(safe-area-inset-top)) 14px 10px;
        overflow: visible;
    }

    .scan-app .wrap {
        min-height: auto;
        padding: 10px;
    }

    .scan-shell {
        min-height: auto;
        grid-template-rows: auto auto;
        gap: 10px;
    }

    .scan-camera-panel,
    .scan-cart-panel {
        border-radius: 14px;
        box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
    }

    .scan-camera-panel {
        min-height: calc(100dvh - 330px);
    }

    .reader-frame {
        min-height: 280px;
    }

    #reader {
        min-height: 280px;
    }

    .scan-corners {
        width: min(520px, 94%);
        height: min(260px, 62%);
    }

    .scan-title {
        align-items: flex-start;
    }

    .scan-title h2,
    .scan-title.compact h2 {
        font-size: 17px;
    }

    .scan-manual-form {
        grid-template-columns: minmax(0, 1fr) 96px;
    }

    .scan-cart-panel {
        position: relative;
        max-height: none;
    }

    .scan-cart-panel #cart-preview {
        display: grid;
        gap: 8px;
    }

    .scan-cart-row {
        border-radius: 12px;
    }

    .scan-cart-bottom {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .qty-stepper {
        grid-template-columns: 38px 42px 38px;
        height: 38px;
        border-radius: 10px;
    }

    .scan-cart-total {
        position: sticky;
        bottom: 0;
        margin-top: 10px;
        padding: 12px;
        border: 1px solid #9adfba;
        border-radius: 12px;
        background: var(--success-soft);
    }

    .scan-cart-total strong {
        font-size: 20px;
    }

    .scan-cart-actions {
        grid-template-columns: 0.8fr 1.2fr;
    }

    .scan-cart-actions .btn {
        min-height: 52px;
        border-radius: 12px;
    }
}

@media (max-width: 420px) {
    .topbar .nav {
        grid-auto-columns: minmax(68px, 1fr);
    }

    .topbar .nav a {
        min-width: 68px;
        font-size: 10.5px;
    }

    .inventory-dashboard,
    .report-cards,
    .product-summary {
        grid-template-columns: 1fr;
    }

    .product-card-actions,
    .account-actions,
    .actions,
    .scan-cart-actions {
        grid-template-columns: 1fr;
    }
}

/* Report KPI cards */
.report-cards {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 10px;
}

.report-card {
    min-width: 0;
    padding: 12px;
}

.report-card span {
    font-size: 12px;
}

.report-card strong {
    overflow-wrap: anywhere;
    font-size: clamp(16px, 1.25vw, 20px);
}

@media (max-width: 1100px) {
    .report-cards {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .report-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 420px) {
    .report-cards {
        grid-template-columns: 1fr;
    }
}

/* Softer typography */
:root {
    --text: #273244;
    --muted: #718096;
    --heading: #182235;
}

body {
    color: var(--text);
    font-weight: 400;
}

.topbar h1 {
    color: var(--heading);
    font-size: 18px;
    font-weight: 600;
}

.panel h2,
.scan-title h2,
.login-box h1,
.section-heading h2 {
    color: var(--heading);
    font-size: 16px;
    font-weight: 600;
}

.nav a,
.btn {
    color: #2f3b4f;
    font-weight: 500;
}

label,
th,
.settings-group legend,
.settings-choice strong,
.account-main strong,
.scan-item-name {
    color: #243044;
    font-weight: 500;
}

/* CUSTOM UI: Tên sản phẩm nhỏ lại (16px) và có màu xanh dương */
.product-title-block strong {
    font-size: 16px;
    color: #0066cc;
    font-weight: 500;
}

td,
input,
select,
.cart-row,
.history-item,
.account-card,
.product-summary b {
    color: var(--text);
    font-weight: 400;
}

th {
    font-weight: 500;
}

.metric-card strong,
.report-card strong {
    font-weight: 600;
}

.status-badge,
.history-action,
.account-root {
    font-weight: 600;
}

@media (max-width: 760px) {
    .topbar h1 {
        font-size: 16px;
    }

    .panel h2,
    .scan-title h2,
    .login-box h1,
    .section-heading h2 {
        font-size: 15px;
    }
}

.panel h2 {
    margin-bottom: 12px;
    color: #0f172a;
    font-size: 16px;
    font-weight: 700;
}

.user-form label,
.account-edit-form label,
.product-form label,
.report-filter label,
.settings-form label,
table th {
    color: #0f172a;
    font-size: 13px;
    font-weight: 700;
}

.account-main strong,
.history-list strong,
.scan-item-name {
    color: #273244;
    font-weight: 500;
}

.nav a,
.btn {
    font-weight: 500;
}

.product-form label,
.user-form label,
.account-edit-form label,
.account-tools label,
.report-filter label,
.settings-form label,
.scan-manual-form label,
.scanner-gun-form label {
    gap: 8px;
    color: #0f172a;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
}

.product-form input,
.product-form select,
.user-form input,
.user-form select,
.account-edit-form input,
.account-edit-form select,
.account-tools input,
.account-tools select,
.report-filter input,
.report-filter select,
.settings-form input,
.settings-form select {
    color: #1f2937;
    font-size: 15px;
    font-weight: 400;
}

.subhead {
    margin-top: 18px;
    color: #223047;
    font-size: 15px;
    font-weight: 600;
}

.unit-grid label {
    color: #0f172a;
    font-size: 12px;
    font-weight: 700;
}

/* CUSTOM UI: Màu đen cho các tiêu đề (Tên, SKU, Ngành hàng) ở lưới chính */
.barcode-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.barcode-scan-trigger {
    min-width: 66px;
    min-height: 42px;
    padding-inline: 10px;
}

.barcode-scan-modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(15, 23, 42, 0.58);
}

.barcode-scan-dialog {
    width: min(680px, 100%);
    max-height: calc(100vh - 36px);
    display: grid;
    gap: 12px;
    overflow: auto;
    padding: 16px;
    border: 1px solid #d8dee9;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.barcode-scan-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.barcode-scan-head h2 {
    margin: 0 0 4px;
    font-size: 17px;
}

.barcode-scan-head p {
    margin: 0;
}

.barcode-reader-frame {
    position: relative;
    overflow: hidden;
    min-height: 260px;
    border: 1px solid #c8d2e4;
    border-radius: 8px;
    background: #0f172a;
}

#product-barcode-reader {
    width: 100%;
    min-height: 260px;
}

#product-barcode-reader video {
    width: 100% !important;
    min-height: 260px;
    object-fit: cover;
}

@media (max-width: 640px) {
    .barcode-scan-modal {
        padding: 10px;
    }

    .barcode-scan-head {
        display: grid;
    }

    .barcode-scan-close {
        width: 100%;
    }

    .barcode-input-row {
        grid-template-columns: 1fr;
    }

    .barcode-scan-trigger {
        width: 100%;
    }
}

.product-main-grid > label {
    color: #000000 !important;
}

/* CUSTOM UI: Hiển thị các nút thao tác ngang hàng KHI VÀ CHỈ KHI đang ở chế độ sửa */
form.product-edit-form:not(.is-readonly) .edit-actions {
    display: flex;
    flex-wrap: wrap; /* Cho phép rớt dòng nếu mở trên Mobile */
    gap: 8px;
    align-items: center;
    margin-top: 16px;
}
.product-title-block strong {
    color: #1455c0;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.15;
}

/* CUSTOM UI v3: Danh sách user chia theo cột */
.account-list-columns {
    gap: 8px;
}

.account-header,
.account-row {
    display: grid;
    grid-template-columns: minmax(130px, 1fr) minmax(180px, 1.4fr) minmax(120px, 0.9fr) minmax(150px, 1fr) minmax(120px, 0.8fr) minmax(110px, auto);
    gap: 12px;
    align-items: center;
}

.account-header {
    padding: 10px 12px;
    border: 1px solid var(--line, #dbe4ef);
    border-radius: 8px;
    background: #f1f5fa;
    color: #344054;
    font-size: 13px;
    font-weight: 800;
}

.account-card .account-row {
    grid-template-columns: minmax(130px, 1fr) minmax(180px, 1.4fr) minmax(120px, 0.9fr) minmax(150px, 1fr) minmax(120px, 0.8fr) minmax(110px, auto);
}

.account-cell {
    min-width: 0;
}

.account-username strong,
.account-main strong {
    color: #0f8a4b !important;
    font-weight: 800;
}

.account-fullname,
.account-role {
    color: #152033;
    font-weight: 600;
}

.account-actions.account-cell {
    justify-content: flex-end;
}

@media (max-width: 760px) {
    .account-header {
        display: none;
    }

    .account-card .account-row,
    .account-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .account-cell {
        display: grid;
        grid-template-columns: 98px minmax(0, 1fr);
        gap: 8px;
        align-items: center;
    }

    .account-cell::before {
        content: attr(data-label);
        color: #64748b;
        font-size: 12px;
        font-weight: 800;
    }

    .account-actions.account-cell {
        grid-template-columns: 98px minmax(0, 1fr);
        justify-content: initial;
    }

    .account-actions.account-cell::after {
        content: "";
        display: none;
    }

    .account-actions.account-cell .btn {
        width: auto;
        justify-self: start;
    }
}

/* CUSTOM UI v4: Tên hàng hoá ở index giống phong cách reports.php */
.product-title-block .index-product-name,
.product-title-block strong.report-product-name.index-product-name {
    color: #0066cc !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
}


/* CUSTOM UI v6: Làm nổi bật riêng khối Danh sách tài khoản, không đổi kiểu chữ */
.account-list-panel {
    position: relative;
    border-color: #9ec5ff !important;
    background: linear-gradient(180deg, #f8fbff 0%, #ffffff 46%, #ffffff 100%) !important;
    box-shadow: 0 16px 36px rgba(15, 107, 255, 0.12) !important;
}

.account-list-panel::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    border-radius: 8px 0 0 8px;
    background: linear-gradient(180deg, var(--primary, #0f6bff), #00a3ff);
}

.account-list-panel > h2 {
    margin: 0 0 14px;
    padding: 10px 12px 10px 14px;
    border: 1px solid #b7d7ff;
    border-left: 4px solid var(--primary, #0f6bff);
    border-radius: 8px;
    background: linear-gradient(180deg, #edf6ff 0%, #e7f0ff 100%);
    color: inherit;
}

.account-list-panel .account-tools {
    border-color: #b7d7ff !important;
    background: #f4f9ff !important;
}

.account-list-panel .user-filter-result {
    padding: 7px 10px;
    border-radius: 8px;
    background: #f8fbff;
}

.account-list-panel .account-header {
    border-color: #b7d7ff !important;
    background: linear-gradient(180deg, #eaf3ff 0%, #dfeeff 100%) !important;
}

.account-list-panel .account-card {
    border-color: #b7d7ff !important;
    background: #ffffff !important;
    box-shadow: 0 8px 18px rgba(15, 107, 255, 0.08) !important;
}

.account-list-panel .account-card:hover {
    border-color: var(--primary, #0f6bff) !important;
    background: #f8fbff !important;
}

.account-list-panel .account-card .account-row {
    padding: 2px 0;
}

@media (max-width: 760px) {
    .account-list-panel::before {
        width: 4px;
        border-radius: 12px 0 0 12px;
    }

    .account-list-panel > h2 {
        padding: 10px 12px;
        border-radius: 10px;
    }
}

/* CUSTOM UI v7: Làm tiêu đề "Danh sách tài khoản" nổi bật rõ hơn */
.account-list-panel > h2 {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    margin: -4px -4px 16px;
    padding: 12px 16px;
    border: 1px solid #7fb3ff !important;
    border-left: 6px solid var(--primary, #0f6bff) !important;
    border-radius: 10px !important;
    background: linear-gradient(180deg, #dcecff 0%, #eef6ff 100%) !important;
    color: #0f172a !important;
    box-shadow: 0 8px 20px rgba(15, 107, 255, 0.12) !important;
}

.account-list-panel > h2::before {
    content: "";
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    border-radius: 7px;
    background-color: var(--primary, #0f6bff);
    background-image: url("data:image/svg+xml,%3Csvg%20width='22'%20height='22'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3E%3Cpath%20d='M16%2020C16%2017.8%2014.2%2016%2012%2016H7C4.8%2016%203%2017.8%203%2020'%20stroke='white'%20stroke-width='2'%20stroke-linecap='round'/%3E%3Cpath%20d='M9.5%2012C11.43%2012%2013%2010.43%2013%208.5C13%206.57%2011.43%205%209.5%205C7.57%205%206%206.57%206%208.5C6%2010.43%207.57%2012%209.5%2012Z'%20stroke='white'%20stroke-width='2'/%3E%3Cpath%20d='M17%2011H22'%20stroke='white'%20stroke-width='2'%20stroke-linecap='round'/%3E%3Cpath%20d='M19.5%208.5V13.5'%20stroke='white'%20stroke-width='2'%20stroke-linecap='round'/%3E%3C/svg%3E");
    background-position: center;
    background-repeat: no-repeat;
    background-size: 18px 18px;
    box-shadow: 0 8px 16px rgba(15, 107, 255, 0.24);
}

.account-list-panel > h2::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    margin-left: 8px;
    background: linear-gradient(90deg, rgba(15, 107, 255, 0.35), transparent);
}

@media (max-width: 760px) {
    .account-list-panel > h2 {
        min-height: 44px;
        margin: -2px -2px 14px;
        padding: 11px 13px;
    }

    .account-list-panel > h2::after {
        display: none;
    }
}

/* CUSTOM UI v8: Bỏ viền xanh dọc bên trái của khối Danh sách tài khoản */
.account-list-panel::before {
    display: none !important;
}

.account-list-panel > h2 {
    border-left: 1px solid #7fb3ff !important;
}

.cart-session-panel {
    display: grid;
    gap: 12px;
}

.cart-session-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.cart-session-head h2 {
    margin: 0 0 4px;
    font-size: 16px;
}

.cart-session-head p {
    margin: 0;
}

.cart-session-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cart-session-tabs form,
.cart-session-head form {
    margin: 0;
}

.cart-session-tabs .btn {
    gap: 7px;
}

@media (max-width: 640px) {
    .cart-session-head {
        display: grid;
    }

    .cart-session-head form,
    .cart-session-head .btn {
        width: 100%;
    }
}


/* CUSTOM UI v9: Sửa khoảng trắng dư dưới menu ở trang Quét mã mobile */
@media (max-width: 760px) {
    body.scan-app {
        height: 100dvh !important;
        min-height: 100dvh !important;
        padding-bottom: 0 !important;
        overflow: hidden !important;
        background: #0f172a !important;
    }

    body.scan-app .topbar {
        position: static !important;
        display: block !important;
        height: 0 !important;
        min-height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        overflow: visible !important;
    }

    body.scan-app .brand-block {
        display: none !important;
    }

    body.scan-app .topbar .nav {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        z-index: 999 !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 4px 8px max(4px, env(safe-area-inset-bottom)) !important;
        border-left: 0 !important;
        border-right: 0 !important;
        border-bottom: 0 !important;
        border-radius: 16px 16px 0 0 !important;
        background: rgba(255, 255, 255, 0.98) !important;
        box-shadow: 0 -8px 26px rgba(15, 23, 42, 0.16) !important;
    }

    body.scan-app .topbar .nav a {
        min-height: 50px !important;
        padding: 4px 5px !important;
    }

    body.scan-app .wrap {
        height: 100dvh !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 10px 10px 66px !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        background: transparent !important;
    }

    body.scan-app .scan-shell {
        min-height: 0 !important;
        margin-bottom: 0 !important;
    }

    body.scan-app .scan-cart-session-compact {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
    }
}


/* CUSTOM UI v10: Đồng bộ khung mã vạch lớn giống mẫu EAN-13 */
.code-box {
    grid-template-columns: 120px minmax(220px, 260px) !important;
    align-items: stretch !important;
}

.code-box .barcode {
    width: 100% !important;
    height: 88px !important;
    min-height: 88px !important;
    padding: 6px !important;
    background: #ffffff !important;
    overflow: visible !important;
}

.code-box .qr {
    min-height: 88px !important;
}

@media (max-width: 760px) {
    .code-box {
        grid-template-columns: 1fr !important;
    }

    .code-box .barcode,
    .code-box .qr {
        width: 100% !important;
        max-width: none !important;
    }
}

@media (max-width: 760px) {
    .sale-order-item {
        grid-template-columns: 1fr;
    }

    .sale-order-detail-head {
        align-items: flex-start;
    }

    .sale-order-table-wrap table {
        min-width: 860px;
    }
}


/* Quick cart: keep 3 action buttons in one row, including "Thanh toán & in". */
.scan-cart-actions.scan-cart-actions-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.scan-cart-actions.scan-cart-actions-3 .btn {
    min-width: 0;
    min-height: 48px;
    padding-left: 6px;
    padding-right: 6px;
    text-align: center;
    white-space: normal;
    line-height: 1.15;
}

.scan-cart-actions.scan-cart-actions-3 .quick-checkout-print {
    font-size: 13px;
}

@media (max-width: 760px) {
    .scan-cart-actions.scan-cart-actions-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }

    .scan-cart-actions.scan-cart-actions-3 .btn {
        min-height: 50px;
        padding: 7px 4px;
        border-radius: 10px;
        font-size: 12px;
    }
}

@media (max-width: 420px) {
    .scan-cart-actions.scan-cart-actions-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .scan-cart-actions.scan-cart-actions-3 .btn {
        font-size: 11.5px;
    }
}

/* v6: Giữ 3 nút giỏ nhanh cùng một hàng, chữ không xuống dòng trên mobile. */
.scan-cart-actions.scan-cart-actions-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px;
}

.scan-cart-actions.scan-cart-actions-3 .btn {
    min-width: 0;
    min-height: 40px;
    height: 40px;
    padding: 5px 4px;
    border-radius: 9px;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: clip;
}

.scan-cart-actions.scan-cart-actions-3 .quick-checkout-print {
    font-size: 11px;
    letter-spacing: -0.2px;
}

@media (max-width: 760px) {
    .scan-cart-actions.scan-cart-actions-3 {
        gap: 5px;
    }

    .scan-cart-actions.scan-cart-actions-3 .btn {
        min-height: 38px;
        height: 38px;
        padding: 4px 3px;
        border-radius: 8px;
        font-size: 11.5px;
    }

    .scan-cart-actions.scan-cart-actions-3 .quick-checkout-print {
        font-size: 10.5px;
        letter-spacing: -0.35px;
    }
}

@media (max-width: 360px) {
    .scan-cart-actions.scan-cart-actions-3 {
        gap: 4px;
    }

    .scan-cart-actions.scan-cart-actions-3 .btn {
        min-height: 36px;
        height: 36px;
        padding-left: 2px;
        padding-right: 2px;
        font-size: 10.5px;
    }

    .scan-cart-actions.scan-cart-actions-3 .quick-checkout-print {
        font-size: 9.8px;
        letter-spacing: -0.45px;
    }
}


/* v10: Chuẩn hoá icon menu Khai thuế và thêm giao diện phân quyền nhân viên. */
.nav a[href="tax.php"]::before {
    background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2718%27%20height%3D%2718%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%3E%3Cpath%20d%3D%27M5%204H19C19.55%204%2020%204.45%2020%205V19C20%2019.55%2019.55%2020%2019%2020H5C4.45%2020%204%2019.55%204%2019V5C4%204.45%204.45%204%205%204Z%27%20stroke%3D%27%230647B8%27%20stroke-width%3D%272%27%20stroke-linejoin%3D%27round%27%2F%3E%3Cpath%20d%3D%27M8%208H16%27%20stroke%3D%27%230647B8%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%2F%3E%3Cpath%20d%3D%27M8%2012H8.01M12%2012H12.01M16%2012H16.01M8%2016H8.01M12%2016H12.01M16%2016H16.01%27%20stroke%3D%27%230647B8%27%20stroke-width%3D%272.4%27%20stroke-linecap%3D%27round%27%2F%3E%3C%2Fsvg%3E");
}

.settings-hint {
    margin: 0 0 4px;
    color: #667085;
    font-size: 13px;
}

.permission-table {
    display: grid;
    gap: 8px;
}

.permission-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(130px, 170px) minmax(130px, 170px);
    gap: 8px;
    align-items: stretch;
}

.permission-row > div,
.permission-check {
    min-height: 46px;
    padding: 10px;
    border: 1px solid #e1e6f0;
    border-radius: 10px;
    background: #ffffff;
}

.permission-head > div {
    min-height: auto;
    border-color: #c8d7ee;
    background: #eef6ff;
    color: #0f47a1;
    font-size: 13px;
    font-weight: 800;
    text-align: center;
}

.permission-head > div:first-child {
    text-align: left;
}

.permission-feature {
    display: grid;
    gap: 3px;
}

.permission-feature strong {
    color: #152033;
    font-size: 13px;
}

.permission-feature small {
    color: #667085;
    font-size: 12px;
}

.permission-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #243044;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.permission-check input {
    width: 18px;
    min-height: 18px;
    margin: 0;
}

@media (max-width: 760px) {
    .permission-row {
        grid-template-columns: 1fr 1fr;
    }

    .permission-head {
        display: none;
    }

    .permission-feature {
        grid-column: 1 / -1;
    }

    .permission-check {
        justify-content: flex-start;
    }
}

.alert {
    margin: 12px 0;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #d8dee9;
    font-weight: 700;
}

.alert.success {
    border-color: #9adfba;
    background: #e8f8ef;
    color: #0f8a4b;
}

.alert.error {
    border-color: #f4b4ae;
    background: #fff0ee;
    color: #c8322b;
}

.tax-check {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 8px !important;
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid #d8dee9;
    border-radius: 12px;
    background: #ffffff;
}

.tax-check input {
    min-height: auto;
    width: 18px;
    height: 18px;
}

.tax-deduction-form {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(160px, 220px) auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 14px;
}

.tax-deduction-form label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.compact-card {
    min-width: 210px;
    margin: 0;
}

.compact-card strong {
    font-size: 20px;
}

.tax-print-form {
    display: none;
}

.tax-print-header {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 18px;
    text-align: center;
}

.tax-print-header div {
    display: grid;
    gap: 4px;
}

.tax-print-header p,
.tax-print-note {
    margin: 0;
    color: #475569;
}

.tax-print-form h1 {
    margin: 8px 0 10px;
    text-align: center;
    font-size: 22px;
}

.tax-print-info,
.tax-print-summary {
    width: 100%;
    margin-top: 14px;
    border-collapse: collapse;
}

.tax-print-info th,
.tax-print-info td,
.tax-print-summary th,
.tax-print-summary td {
    padding: 8px 10px;
    border: 1px solid #1f2937;
    text-align: left;
    vertical-align: top;
}

.tax-print-info th,
.tax-print-summary th,
.tax-print-total td {
    font-weight: 700;
}

.tax-print-signatures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 48px;
    margin-top: 42px;
    text-align: center;
}

.tax-print-signatures div {
    display: grid;
    min-height: 120px;
    align-content: start;
    gap: 6px;
}

.tax-print-signatures span {
    color: #475569;
}

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

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

    .topbar,
    .wrap > *:not(.tax-print-form) {
        display: none !important;
    }

    .wrap {
        display: block !important;
        width: auto !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .tax-print-form {
        position: static;
        display: block !important;
        width: auto;
        max-width: 100%;
        margin: 0;
        padding: 4mm;
        color: #111827;
        font-size: 12px;
        line-height: 1.35;
        background: #ffffff;
        page-break-after: avoid;
        break-after: avoid;
    }

    .tax-print-form h1 {
        font-size: 18px;
    }

    .tax-print-info th,
    .tax-print-info td,
    .tax-print-summary th,
    .tax-print-summary td {
        padding: 6px 8px;
    }

    .tax-print-signatures {
        margin-top: 28px;
    }

    .tax-print-signatures div {
        min-height: 80px;
    }
}

@media (max-width: 760px) {
    .tax-deduction-form {
        grid-template-columns: 1fr;
    }

    .compact-card {
        width: 100%;
    }
}

/* v11: Bố cục thiết lập 2 cột, cấu hình lưu trữ, sao lưu và khôi phục dữ liệu. */
.settings-panel .settings-form {
    max-width: none;
    grid-template-columns: repeat(2, minmax(300px, 1fr));
    align-items: start;
}

.settings-panel .permission-settings,
.settings-panel .settings-actions {
    grid-column: 1 / -1;
}

.database-settings,
.backup-settings {
    align-self: stretch;
}

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

.db-config-grid label,
.restore-form {
    display: grid;
    gap: 6px;
}

.db-config-grid label span {
    color: #243044;
    font-size: 13px;
    font-weight: 800;
}

.db-config-grid input,
.restore-form input[type="file"] {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid #cfd8e8;
    border-radius: 10px;
    background: #ffffff;
    color: #152033;
    font: inherit;
}

.db-config-grid input[readonly] {
    background: #eef6ff;
    color: #0f47a1;
    font-weight: 800;
}

.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.tax-book-actions {
    gap: 6px;
    align-items: flex-start;
}

.tax-book-actions .btn {
    min-height: 30px;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.1;
}

.backup-status {
    padding: 10px 12px;
    border: 1px dashed #b9c8de;
    border-radius: 10px;
    background: #f7fbff;
    color: #243044;
    font-size: 13px;
}

.backup-status strong {
    color: #152033;
}

.settings-backup-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(300px, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.settings-backup-card {
    display: grid;
    gap: 10px;
    padding: 16px;
    border: 1px solid #d8dee9;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
}

.settings-backup-card h3,
.settings-backup-card p {
    margin: 0;
}

.settings-backup-card h3 {
    color: #152033;
    font-size: 16px;
}

.settings-backup-card p {
    color: #667085;
    font-size: 13px;
}

.btn.danger {
    border-color: #dc2626;
    background: #dc2626;
    color: #ffffff;
}

@media (max-width: 980px) {
    .settings-panel .settings-form,
    .settings-backup-panel {
        grid-template-columns: 1fr;
    }

    .db-config-grid {
        grid-template-columns: 1fr;
    }
}

/* v12: Nút sửa lỗi cơ sở dữ liệu và log tiến trình cài đặt/sửa dữ liệu. */
.settings-backup-panel {
    grid-template-columns: repeat(3, minmax(260px, 1fr));
}

.repair-card {
    border-color: #b7cdf5;
    background: linear-gradient(180deg, #ffffff 0%, #eef6ff 100%);
}

.install-notice {
    border-left: 4px solid #f59e0b;
}

.database-repair-log {
    margin-top: 18px;
    padding: 16px;
    border: 1px solid #d8dee9;
    border-radius: 12px;
    background: #0f172a;
    color: #e5eefc;
}

.database-repair-log h3 {
    margin: 0 0 12px;
    color: #ffffff;
    font-size: 16px;
}

.database-repair-log ol {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.database-repair-log li {
    display: grid;
    grid-template-columns: 86px 1fr;
    gap: 10px;
    align-items: start;
    padding: 9px 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
}

.database-repair-log li span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.04em;
}

.database-repair-log li p {
    margin: 0;
    color: #e5eefc;
    font-size: 13px;
}

.database-repair-log .repair-log-ok span {
    background: #16a34a;
    color: #ffffff;
}

.database-repair-log .repair-log-fix span,
.database-repair-log .repair-log-install span {
    background: #1455c0;
    color: #ffffff;
}

.database-repair-log .repair-log-warn span {
    background: #f59e0b;
    color: #111827;
}

.database-repair-log .repair-log-error span {
    background: #dc2626;
    color: #ffffff;
}

@media (max-width: 1180px) {
    .settings-backup-panel {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .database-repair-log li {
        grid-template-columns: 1fr;
    }
}

/* v13: Cân lại trang Thiết lập để không còn khoảng trống lớn giữa hai cột. */
.settings-panel .settings-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    max-width: none;
}

.settings-balanced-layout {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
    gap: 18px;
    align-items: start;
}

.settings-column {
    display: grid;
    gap: 18px;
    align-content: start;
}

.settings-column .settings-group {
    margin: 0;
}

.settings-panel .permission-settings,
.settings-panel .settings-actions {
    grid-column: auto;
}

@media (max-width: 980px) {
    .settings-balanced-layout {
        grid-template-columns: 1fr;
    }
}

/* v14: Hỏi sao lưu/chuyển dữ liệu khi đổi JSON ↔ MySQL. */
.storage-migration-choice {
    border-color: #bfdbfe;
    background: #eff6ff;
}

.migration-log {
    border-color: #93c5fd;
}

.storage-split-status {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 14px 0 8px;
}

.storage-status-card {
    border: 1px solid var(--border, #d8dee9);
    border-radius: 14px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.58);
}

.storage-status-card.active {
    border-color: rgba(37, 99, 235, 0.55);
    box-shadow: 0 8px 22px rgba(37, 99, 235, 0.10);
}

.storage-status-title {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}

.storage-status-title span {
    font-size: 12px;
    border-radius: 999px;
    padding: 3px 8px;
    background: rgba(15, 23, 42, 0.08);
    white-space: nowrap;
}

.storage-status-card.active .storage-status-title span {
    background: rgba(37, 99, 235, 0.12);
    color: #1d4ed8;
}

.storage-status-card p {
    margin: 0 0 4px;
    font-size: 13px;
}

.storage-status-card small {
    display: block;
    color: var(--muted, #64748b);
    word-break: break-word;
}

.storage-mini-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 9px;
}

.storage-mini-stats span {
    font-size: 12px;
    border-radius: 999px;
    padding: 4px 8px;
    background: rgba(15, 23, 42, 0.06);
}

.storage-switch-note {
    margin-top: 10px;
}

@media (max-width: 720px) {
    .storage-split-status {
        grid-template-columns: 1fr;
    }
}


.db-password-box {
    display: grid;
    gap: 6px;
}

.db-password-box > span {
    color: #243044;
    font-size: 13px;
    font-weight: 800;
}

.db-password-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.db-password-row input {
    flex: 1 1 auto;
    min-width: 0;
}

.db-password-row input:disabled {
    background: #eef3fb;
    color: #667085;
    -webkit-text-fill-color: #667085;
    cursor: not-allowed;
}

.db-password-edit-btn {
    min-height: 42px;
    white-space: nowrap;
    padding-left: 14px;
    padding-right: 14px;
}

.db-password-note {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    line-height: 1.35;
}

.db-password-note.ok {
    color: #166534;
}

.db-password-note.warn {
    color: #b45309;
}

/* v21: danh sách backup JSON trên host, chỉ giữ 5 bản gần nhất. */
.host-backup-card {
    align-content: start;
}

.host-backup-list {
    display: grid;
    gap: 8px;
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid #e2e8f0;
}

.host-backup-list h4 {
    margin: 0;
    color: #152033;
    font-size: 14px;
}

.host-backup-list ul {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.host-backup-list li {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    padding: 9px 10px;
    border: 1px solid #dbe5f2;
    border-radius: 10px;
    background: #ffffff;
}

.host-backup-list strong,
.host-backup-list small {
    display: block;
    word-break: break-word;
}

.host-backup-list strong {
    color: #152033;
    font-size: 13px;
}

.host-backup-list small {
    margin-top: 3px;
    color: #667085;
    font-size: 12px;
}

.host-backup-list form {
    flex: 0 0 auto;
}

.btn.small {
    min-height: 34px;
    padding: 7px 12px;
    font-size: 13px;
}

.warning-text {
    color: #b45309 !important;
}

@media (max-width: 720px) {
    .host-backup-list li {
        align-items: stretch;
        flex-direction: column;
    }

    .host-backup-list form,
    .host-backup-list .btn {
        width: 100%;
    }
}

/* v22: Nút xoá trắng kho JSON/MySQL nhưng vẫn giữ đúng cấu trúc dữ liệu. */
.storage-status-tools {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.storage-clear-btn {
    min-height: 26px;
    padding: 4px 9px;
    font-size: 12px;
    line-height: 1.1;
    border-radius: 999px;
}

@media (max-width: 520px) {
    .storage-status-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .storage-status-tools {
        justify-content: flex-start;
    }
}

/* v23: Gộp nút sửa lỗi vào khối sao lưu, bỏ cột trống và không kéo cao khối khôi phục. */
.settings-backup-panel {
    grid-template-columns: repeat(2, minmax(300px, 1fr));
    align-items: start;
}

.settings-backup-card {
    align-self: start;
}

.backup-action-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.backup-action-row .inline-actions {
    margin: 0;
}

.backup-action-row .btn {
    white-space: nowrap;
}

@media (max-width: 980px) {
    .settings-backup-panel {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    .backup-action-row,
    .backup-action-row .inline-actions,
    .backup-action-row .btn {
        width: 100%;
    }
}

/* Compact product list: keep SKU, actions and stats in one tight row. */
.product-view-card {
    margin-bottom: 8px;
    padding: 10px 14px 8px;
}

.product-view-card .product-card-head {
    align-items: center;
    gap: 10px;
    margin-bottom: 7px;
}

.product-view-card .product-title-block {
    display: flex;
    align-items: baseline;
    min-width: 0;
    gap: 10px;
}

.product-view-card .index-product-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-view-card .product-title-block .muted {
    flex: 0 0 auto;
    font-size: 13px;
    line-height: 1.25;
    white-space: nowrap;
}

.product-view-card .product-card-actions {
    align-items: center;
    gap: 6px;
}

.product-view-card .status-badge,
.product-view-card .product-card-actions .btn {
    height: 30px;
    min-height: 30px;
    padding: 4px 10px;
    border-radius: 7px;
    font-size: 13px;
    line-height: 1;
}

.product-view-card .code-list-toggle,
.product-view-card .product-edit-toggle {
    min-width: 78px;
}

.product-view-card .product-summary {
    gap: 6px;
    margin-bottom: 6px;
}

.product-view-card .product-summary span {
    min-height: 39px;
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 13px;
}

.product-view-card .product-summary strong {
    font-size: 13px;
}

.product-view-card .product-summary b {
    font-size: 13px;
}

.product-view-card .product-summary small {
    font-size: 13px;
    font-weight: 400;
}

.tax-deduction-top,
section.panel:has(.tax-deduction-form) .section-heading .compact-card {
    display: none;
}

/* v25: Checkbox nhập hàng không hóa đơn đặt theo từng lô hàng. */
.lot-expiry-field {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.lot-field-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 16px;
}

.lot-title-text {
    color: #0f172a;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.lot-no-invoice-check {
    display: inline-flex !important;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    width: auto;
    min-width: 0;
    min-height: 0;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    color: #334155;
    font-size: 11px !important;
    font-weight: 700 !important;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.lot-no-invoice-check input[type="checkbox"] {
    width: 13px;
    min-width: 13px;
    height: 13px;
    min-height: 13px;
    padding: 0;
    margin: 0;
    border-radius: 3px;
    cursor: pointer;
    accent-color: #1455c0;
}

.lot-no-invoice-check.is-checked {
    color: #8a4b00;
}

.unit-grid .optional-remove,
.lot-grid .optional-remove {
    min-width: 54px;
    height: 38px;
    min-height: 38px;
    padding: 6px 10px;
    align-self: end;
    justify-self: end;
}

@media (max-width: 720px) {
    .lot-field-head {
        flex-wrap: wrap;
    }

    .unit-grid .optional-remove,
    .lot-grid .optional-remove {
        width: 100%;
        justify-self: stretch;
    }
}


/* Lịch sử thay đổi hàng hóa: hiện chi tiết giá, số lượng, lô */
.history-item {
    grid-template-columns: 92px minmax(0, 1fr) auto;
    align-items: start;
}

.history-main {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.history-detail {
    display: block;
    color: #475467;
    font-size: 12px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.history-meta {
    white-space: nowrap;
    padding-top: 2px;
}

@media (max-width: 760px) {
    .history-item {
        grid-template-columns: 1fr;
    }

    .history-meta {
        white-space: normal;
    }
}

/* v2 tax mobile: hoàn thiện bố cục khai thuế trên điện thoại */
body.tax-page .tax-filter {
    grid-template-columns: repeat(4, minmax(170px, 1fr)) auto;
}

body.tax-page .tax-filter .btn,
body.tax-page .tax-deduction-form .btn {
    min-height: 40px;
    white-space: nowrap;
}

body.tax-page .tax-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
}

body.tax-page .tax-table-wrap table {
    min-width: max-content;
}

body.tax-page .tax-book-preview .inline-actions,
body.tax-page .section-heading .inline-actions {
    justify-content: flex-end;
}

body.tax-page .section-heading .inline-actions .btn {
    white-space: nowrap;
}

@media (max-width: 980px) {
    body.tax-page .tax-filter {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body.tax-page .tax-filter .btn {
        width: 100%;
    }
}

@media (max-width: 760px) {
    body.tax-page .wrap {
        width: 100%;
        margin-top: 8px;
        padding: 0 8px 22px;
    }

    body.tax-page .panel {
        padding: 12px;
        border-radius: 12px;
    }

    body.tax-page .section-heading {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    body.tax-page .section-heading h2 {
        font-size: 16px;
    }

    body.tax-page .section-heading .inline-actions,
    body.tax-page .tax-book-preview .inline-actions {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
        gap: 8px;
    }

    body.tax-page .section-heading .inline-actions .btn,
    body.tax-page .tax-book-preview .inline-actions .btn {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    body.tax-page .tax-filter,
    body.tax-page .tax-deduction-form {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    body.tax-page .tax-filter label,
    body.tax-page .tax-deduction-form label {
        gap: 5px;
        font-size: 13px;
    }

    body.tax-page .tax-filter input,
    body.tax-page .tax-filter select,
    body.tax-page .tax-deduction-form input,
    body.tax-page .tax-deduction-form select {
        min-height: 42px;
        font-size: 16px;
    }

    body.tax-page .tax-filter .btn,
    body.tax-page .tax-deduction-form .btn {
        width: 100%;
        justify-content: center;
    }

    body.tax-page .report-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin-bottom: 12px;
    }

    body.tax-page .report-card {
        min-width: 0;
        padding: 10px;
        border-radius: 10px;
    }

    body.tax-page .report-card span {
        font-size: 11px;
        line-height: 1.25;
    }

    body.tax-page .report-card strong {
        font-size: clamp(15px, 4vw, 18px);
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    body.tax-page .compact-card {
        width: 100%;
        min-width: 0;
    }

    body.tax-page .tax-table-wrap {
        margin-left: -2px;
        padding-bottom: 6px;
    }

    body.tax-page .tax-table-wrap table {
        font-size: 13px;
    }

    body.tax-page .tax-table-wrap th,
    body.tax-page .tax-table-wrap td {
        padding: 8px 10px;
        white-space: nowrap;
    }

    body.tax-page .tax-table-wrap td:first-child,
    body.tax-page .tax-table-wrap th:first-child {
        white-space: normal;
        min-width: 170px;
    }
}

@media (max-width: 360px) {
    body.tax-page .report-cards {
        grid-template-columns: 1fr;
    }
}
