/* =====================================================================
   Vựa Gạo Sóc Trăng — POS Lite CSS
   Tối ưu cho điện thoại & Android WebView APK (safe-area, >=44px touch, 16px input)
   ===================================================================== */

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

html,
body {
    font-family: Arial, system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: #23201a;
    background: #fbf7ef;
    min-height: 100vh;
    line-height: 1.4;
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    overflow-x: hidden;
}

button,
a,
input,
select,
.prod-item,
.htab,
.pay-method-btn,
.quick-kg-btn,
.prod-cat-btn {
    touch-action: manipulation;
}

/* ── LOGIN ── */
.login-screen {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.login-box {
    width: 100%;
    max-width: 340px;
    background: #fff;
    border: 1px solid #e3dac6;
    border-radius: 12px;
    padding: 22px 18px;
    text-align: center;
    box-shadow: 0 4px 16px rgba(14, 74, 44, 0.08);
}

.login-logo {
    font-size: 48px;
    margin-bottom: 6px;
}

.login-title {
    font-size: 19px;
    font-weight: 700;
    color: #0e4a2c;
    margin-bottom: 2px;
}

.login-sub {
    font-size: 12.5px;
    color: #7b756a;
    margin-bottom: 14px;
}

.form-group {
    text-align: left;
    margin-bottom: 10px;
}

.form-group label,
.lite-lab {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #555;
}

.hint {
    font-size: 12px;
    color: #888;
    margin-top: 10px;
}

.error-msg {
    color: #b1402f;
    font-size: 13px;
    margin-top: 8px;
    font-weight: 600;
}

/* ── INPUTS (min 44px height, >= 16px prevents iOS zoom) ── */
.input {
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    font-size: 16px;
    border: 1px solid #cbd5c0;
    border-radius: 8px;
    background: #fff;
    color: #23201a;
    font-family: inherit;
}

.input:focus {
    border-color: #15603a;
    outline: none;
    box-shadow: 0 0 0 2px rgba(21, 96, 58, 0.14);
}

.input-sm {
    width: 110px;
    min-height: 40px;
    padding: 6px 8px;
    font-size: 16px;
    text-align: right;
}

select.input {
    -webkit-appearance: none;
    -moz-appearance: none;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%23555'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 10px center;
    padding-right: 30px;
}

/* ── BUTTONS ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    font-family: inherit;
    color: #fff;
    background: #888;
}

.btn:active {
    opacity: 0.85;
}

.btn-primary {
    background: #15603a;
}

.btn-danger {
    background: #b1402f;
}

.btn-lg {
    min-height: 48px;
    padding: 12px;
    font-size: 16px;
}

.btn-full {
    display: flex;
    width: 100%;
}

.btn-outline {
    background: #fff;
    color: #15603a;
    border: 1.5px solid #15603a;
}

/* ── HEADER (safe-area-inset-top) ── */
.header {
    background: #0e4a2c;
    color: #fff;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
}

.header-brand {
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
}

.header-tabs {
    display: flex;
    gap: 4px;
    flex: 1;
    justify-content: center;
}

.htab {
    flex: 1;
    max-width: 150px;
    min-height: 40px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    border: none;
    padding: 8px 10px;
    font-size: 13.5px;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

.htab.active {
    background: #fff;
    color: #0e4a2c;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    min-width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ── TAB CONTENT ── */
.tab-content {
    display: none;
    padding: 10px;
}

.tab-content.active {
    display: block;
}

#tab-banhang {
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}

#tab-tuyengiao {
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

/* ── STICKY CHECKOUT FOOTER ── */
.sale-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    border-top: 1px solid #e3dac6;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
    padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 90;
}

.sale-footer-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: none;
    border: none;
    padding: 2px 0;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}

.sale-footer-count {
    font-size: 12px;
    color: #7b756a;
}

.sale-footer-total {
    font-size: 18px;
    font-weight: 800;
    color: #15603a;
}

.sale-footer-btn {
    flex-shrink: 0;
    min-height: 46px;
    border: none;
    border-radius: 10px;
    background: #15603a;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    padding: 10px 18px;
    cursor: pointer;
    font-family: inherit;
}

.sale-footer-btn:disabled {
    opacity: 0.6;
}

.sale-footer.is-empty .sale-footer-btn {
    opacity: 0.55;
}

/* ── KPI ── */
.kpi-row {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.kpi {
    flex: 1;
    min-width: 0;
    background: #fff;
    border: 1px solid #e3dac6;
    border-radius: 10px;
    padding: 8px 6px;
    text-align: center;
}

.kpi-lab {
    display: block;
    font-size: 10.5px;
    color: #7b756a;
    text-transform: uppercase;
}

.kpi-val {
    display: block;
    font-size: 15px;
    font-weight: 800;
    color: #15603a;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-red {
    color: #b1402f;
}

/* ── SECTION ── */
.section {
    background: #fff;
    border: 1px solid #e3dac6;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
}

.section-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #0e4a2c;
    margin-bottom: 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid #e3dac6;
}

.section-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid #e3dac6;
}

.section-title-row .section-title {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.section-count {
    font-weight: 600;
    color: #7b756a;
    font-size: 12.5px;
    margin-left: 4px;
}

.row-2 {
    display: flex;
    gap: 8px;
}

.row-2 > * {
    flex: 1;
    min-width: 0;
}

/* ── CUSTOMER SEARCH ── */
.cust-search-row-lite {
    display: flex;
    gap: 8px;
    align-items: center;
}

.cust-search-row-lite .input {
    flex: 1;
    min-width: 0;
}

.cust-le-btn {
    flex-shrink: 0;
    padding: 0 12px;
    font-size: 13px;
}

.cust-results-lite {
    margin-top: 6px;
    border: 1px solid #d5ccb8;
    border-radius: 8px;
    background: #fff;
    max-height: 240px;
    overflow-y: auto;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.cust-res-item {
    display: block;
    width: 100%;
    text-align: left;
    background: #fff;
    border: none;
    border-bottom: 1px solid #f2ede0;
    padding: 10px 12px;
    cursor: pointer;
    font-family: inherit;
}

.cust-res-item:last-child {
    border-bottom: none;
}

.cust-res-item:active {
    background: #eef5f0;
}

.cust-res-top {
    font-size: 14px;
    color: #1f2937;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.cust-res-meta {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.cust-res-empty {
    padding: 12px;
    text-align: center;
    font-size: 13px;
    color: #7b756a;
}

.cust-si-badge {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 10.5px;
    font-weight: 700;
}

.cust-debt-warn {
    background: #fee2e2;
    color: #b91c1c;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 11px;
    font-weight: 700;
}

.cust-chosen {
    margin-top: 8px;
    padding: 8px 10px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    font-size: 13px;
    color: #0e4a2c;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.cust-clear-btn {
    background: none;
    border: none;
    color: #b1402f;
    font-size: 18px;
    cursor: pointer;
    min-width: 36px;
    min-height: 36px;
    flex-shrink: 0;
}

/* ── PRODUCT CATEGORIES & LIST (natural page scroll, zero nested trap) ── */
.prod-cats {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0 4px;
    scrollbar-width: none;
}

.prod-cats::-webkit-scrollbar {
    display: none;
}

.prod-cat-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 36px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid #d5ccb8;
    background: #fbf7ef;
    color: #4b5563;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.prod-cat-btn.active {
    background: #15603a;
    color: #fff;
    border-color: #15603a;
}

.prod-list {
    margin-top: 6px;
}

.prod-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    min-height: 52px;
    padding: 10px 8px;
    border-bottom: 1px solid #f0ebdb;
    cursor: pointer;
    font-size: 14px;
}

.prod-item:last-child {
    border-bottom: none;
}

.prod-item:active {
    background: #eef5f0;
}

.prod-main {
    flex: 1;
    min-width: 0;
}

.prod-name {
    font-weight: 700;
    color: #1f2937;
    word-break: break-word;
}

.prod-stock {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.prod-stock.low {
    color: #d97706;
    font-weight: 700;
}

.prod-stock.out {
    color: #b1402f;
    font-weight: 700;
}

.prod-badge {
    display: inline-block;
    background: #15603a;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
    margin-left: 6px;
}

.prod-price {
    color: #15603a;
    font-weight: 700;
    font-size: 13.5px;
    white-space: nowrap;
}

/* ── CART (2-row mobile cards + quick kg chips) ── */
.cart-list {
    margin-bottom: 8px;
}

.cart-clear-btn {
    background: none;
    border: none;
    color: #b1402f;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    min-height: 36px;
    padding: 0 6px;
}

.cart-item-card {
    padding: 10px 0;
    border-bottom: 1px solid #eee7d5;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cart-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.cart-item-name {
    font-weight: 700;
    font-size: 14.5px;
    color: #1f2937;
    flex: 1;
}

.cart-item-remove {
    color: #b1402f;
    cursor: pointer;
    font-size: 18px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid #f2cbc4;
    background: #fff5f5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cart-item-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.cart-item-stepper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cart-step-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 8px;
    border: 1px solid #15603a;
    background: #fff;
    color: #15603a;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}

.cart-step-btn:active {
    background: #e8f0e4;
}

.cart-item-qty-inp {
    width: 64px;
    min-height: 40px;
    text-align: center;
    padding: 4px;
    border: 1px solid #cbd5c0;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
}

.cart-price-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: flex-end;
    min-width: 150px;
}

.cart-item-price-inp {
    width: 88px;
    min-height: 40px;
    text-align: right;
    padding: 4px 6px;
    border: 1px solid #cbd5c0;
    border-radius: 6px;
    font-size: 16px;
    font-family: inherit;
}

.cart-item-price {
    color: #15603a;
    font-weight: 800;
    font-size: 14.5px;
    min-width: 72px;
    text-align: right;
    white-space: nowrap;
}

.cart-quick-kgs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.quick-kg-btn {
    min-height: 36px;
    padding: 0 11px;
    border-radius: 8px;
    border: 1px solid #cbd5c0;
    background: #f5f9f6;
    color: #15603a;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

.quick-kg-btn.active {
    background: #15603a;
    color: #fff;
    border-color: #15603a;
}

.cart-summary {
    border-top: 1px solid #e3dac6;
    padding-top: 8px;
}

.cart-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 14px;
}

.cart-total {
    font-weight: 800;
    font-size: 16px;
    color: #15603a;
    border-top: 2px solid #e3dac6;
    padding-top: 8px;
    margin-top: 4px;
}

.empty-msg {
    text-align: center;
    color: #888;
    padding: 18px 12px;
    font-size: 13.5px;
}

/* ── PAYMENT 1-TAP BUTTONS ── */
.pay-method-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.pay-method-btn {
    min-height: 44px;
    padding: 6px 4px;
    border-radius: 8px;
    border: 1px solid #cbd5c0;
    background: #fbf7ef;
    color: #374151;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    text-align: center;
}

.pay-method-btn.active {
    background: #15603a;
    color: #fff;
    border-color: #15603a;
}

/* ── TUYẾN GIAO ── */
.tg-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.tg-date-inp {
    flex: 1;
    min-width: 0;
}

.tg-all-chk {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    min-height: 44px;
    padding: 0 4px;
    cursor: pointer;
}

.tg-all-chk input {
    width: 20px;
    height: 20px;
}

.tg-refresh-btn {
    flex: 0 0 46px;
    min-height: 44px;
    border: none;
    border-radius: 8px;
    background: #15603a;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
}

.tg-filter-row {
    margin-bottom: 8px;
}

.tg-summary {
    background: #fff;
    border: 1px solid #e3dac6;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
}

.tg-summary-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #555;
    margin-bottom: 6px;
    flex-wrap: wrap;
    gap: 4px;
}

.tg-summary-count b {
    color: #15603a;
    font-size: 14px;
}

.tg-summary-collect b {
    font-size: 14px;
}

.tg-progress-track {
    background: #f0ebdb;
    border-radius: 6px;
    height: 8px;
    overflow: hidden;
}

.tg-progress-fill {
    background: #15603a;
    height: 100%;
    border-radius: 6px;
    transition: width 0.25s;
}

.tg-prep-box {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-left: 4px solid #15603a;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
}

.tg-prep-hd {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 700;
    color: #0e4a2c;
    margin-bottom: 6px;
}

.tg-prep-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tg-prep-chip {
    background: #fff;
    border: 1px solid #cce7d4;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12.5px;
    color: #1f2937;
}

.tg-card {
    background: #fff;
    border: 1px solid #e3dac6;
    border-left: 5px solid #b8b8b8;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
}

.tg-card.st-cho_xu_ly {
    border-left-color: #c78a12;
}

.tg-card.st-dang_giao {
    border-left-color: #1f6fb2;
}

.tg-card.st-da_giao {
    border-left-color: #15603a;
}

.tg-card.st-huy {
    border-left-color: #b1402f;
}

.tg-card.tg-done {
    opacity: 0.72;
    background: #f8f5ec;
}

.tg-num {
    display: inline-block;
    background: #15603a;
    color: #fff;
    width: 24px;
    height: 24px;
    text-align: center;
    line-height: 24px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.tg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.tg-header-info {
    flex: 1;
    min-width: 0;
}

.tg-name {
    font-weight: 700;
    font-size: 15px;
    display: block;
}

.tg-code {
    font-size: 12px;
    color: #6b7280;
    display: block;
}

.tg-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
}

.tg-badge.st-cho_xu_ly {
    background: #fbe9c6;
    color: #8a5d0a;
}

.tg-badge.st-dang_giao {
    background: #dcebf9;
    color: #1f6fb2;
}

.tg-badge.st-da_giao {
    background: #e8f0e4;
    color: #15603a;
}

.tg-badge.st-huy {
    background: #fbe2dd;
    color: #b1402f;
}

.tg-contact-row {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.tg-icon-btn {
    flex: 1;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 6px;
    border: 1px solid #15603a;
    border-radius: 8px;
    background: #fff;
    color: #15603a;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    font-family: inherit;
}

.tg-zalo-btn {
    border-color: #0284c7;
    color: #0284c7;
}

.tg-addr-text {
    font-size: 13px;
    color: #374151;
    margin-bottom: 6px;
    display: block;
}

.tg-items {
    margin: 4px 0 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.tg-item-line {
    display: inline-block;
    background: #e8f0e4;
    color: #15603a;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
}

.tg-amount {
    font-weight: 700;
    color: #15603a;
}

.tg-money-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.tg-paid-tag {
    font-size: 12px;
    font-weight: 700;
    color: #15603a;
}

.tg-collect-box {
    margin-top: 6px;
    background: #fee2e2;
    border-radius: 8px;
    padding: 7px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tg-collect-lab {
    font-size: 12.5px;
    color: #8a3a2a;
    font-weight: 700;
}

.tg-collect-val {
    font-size: 16px;
    font-weight: 800;
    color: #b1402f;
}

.tg-note {
    font-size: 12px;
    color: #6b7280;
    margin-top: 5px;
}

.tg-actions {
    margin-top: 10px;
}

.tg-btn-row {
    display: flex;
    gap: 8px;
}

.tg-btn-row .tg-btn-done {
    flex: 1;
}

.tg-btn-done {
    display: block;
    width: 100%;
    min-height: 46px;
    padding: 10px 8px;
    font-size: 14px;
    font-weight: 800;
    border: none;
    border-radius: 8px;
    background: #15603a;
    color: #fff;
    cursor: pointer;
    font-family: inherit;
}

.tg-btn-ck {
    background: #0284c7;
}

.tg-btn-done:disabled {
    opacity: 0.6;
}

.tg-actions-secondary {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.tg-btn-secondary {
    flex: 1;
    min-height: 40px;
    padding: 8px 6px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    border: 1px solid #cbd5c0;
    background: #fff;
    color: #374151;
}

.tg-btn-full {
    display: block;
    width: 100%;
}

.tg-btn-secondary.tg-btn-cancel {
    border-color: #e3b3a8;
    color: #b1402f;
}

/* ── TOAST (top-center so it never collides with sticky footer) ── */
.toast {
    position: fixed;
    top: calc(56px + env(safe-area-inset-top, 0px));
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
    background: #1a2420;
    color: #fff;
    padding: 9px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    max-width: calc(100vw - 24px);
    width: max-content;
    text-align: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}

.toast.show {
    opacity: 1;
}
