/* Tối ưu trải nghiệm Mobile & Thực địa Ngoài trời nắng */
* {
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

body {
    background-color: #f8fafc;
    color: #0f172a;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    touch-action: manipulation;
    user-select: none;
    font-variant-numeric: tabular-nums;
}

/* Đảm bảo toàn bộ số liệu không bị nhảy giật chiều ngang */
.tabular-nums,
.grid-cell,
.numpad-btn,
#calc-bags,
#calc-tare,
#calc-net,
#calc-money,
#display-price-val,
#display-impurity-val {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ================= Ô NHẬP LIỆU LƯỚI CÂN ================= */
.grid-cell {
    width: 100%;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f172a;
    background-color: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 10px;
    transition: transform 0.1s ease, border-color 0.1s ease, box-shadow 0.1s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    position: relative;
}

/* Ô trống - Nhìn rõ dưới ánh nắng chói */
.grid-cell:empty {
    background-color: #f8fafc;
    border: 1.5px dashed #94a3b8;
}

.grid-cell:empty::after {
    content: "Bao " attr(data-index);
    color: #64748b;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: -0.2px;
}

/* Ô đang được chọn (Active) - Nổi bật cực đại */
.cell-active {
    border-color: #2563eb !important;
    border-width: 2.5px !important;
    border-style: solid !important;
    background-color: #eff6ff !important;
    transform: scale(1.06);
    z-index: 15;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25), 0 6px 16px rgba(37, 99, 235, 0.3) !important;
    color: #1d4ed8 !important;
}

.cell-active:empty::after {
    content: "";
}

/* Cảnh báo bao lúa có số ký bất thường (<35kg hoặc >75kg) */
.cell-warning {
    border-color: #f59e0b !important;
    background-color: #fffbeb !important;
    color: #b45309 !important;
    position: relative;
}

.cell-warning::before {
    content: "!";
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 9px;
    font-weight: 900;
    background-color: #f59e0b;
    color: white;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Box Giá & Trừ bao lúa khi được chọn */
.field-active {
    border-color: #2563eb !important;
    border-width: 2.5px !important;
    background-color: #eff6ff !important;
    transform: scale(1.03);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25), 0 8px 20px rgba(37, 99, 235, 0.15) !important;
    z-index: 20;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.btn-press:active {
    transform: scale(0.95);
    opacity: 0.9;
}

/* ================= BÀN PHÍM SỐ CƠ HỌC NỔI 3D ================= */
.numpad-btn {
    height: 44px;
    border-radius: 10px;
    font-size: 1.35rem;
    font-weight: 700;
    background-color: #ffffff;
    color: #0f172a;
    border: 1.5px solid #cbd5e1;
    box-shadow: 0 2.5px 0 #cbd5e1, 0 3px 5px rgba(0, 0, 0, 0.03);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.05s ease, box-shadow 0.05s ease, background-color 0.05s ease;
    cursor: pointer;
}

.numpad-btn:active {
    transform: translateY(2.5px);
    box-shadow: 0 0 0 transparent, 0 1px 2px rgba(0, 0, 0, 0.05);
    background-color: #e2e8f0;
}

.numpad-del {
    background-color: #fef2f2;
    color: #dc2626;
    border-color: #fca5a5;
    box-shadow: 0 2.5px 0 #fca5a5, 0 3px 5px rgba(220, 38, 38, 0.08);
}

.numpad-del:active {
    background-color: #fee2e2;
    transform: translateY(2.5px);
    box-shadow: 0 0 0 transparent;
}

.numpad-next {
    background-color: #2563eb;
    color: white;
    border-color: #1d4ed8;
    box-shadow: 0 2.5px 0 #1e40af, 0 4px 8px rgba(37, 99, 235, 0.3);
}

.numpad-next:active {
    background-color: #1d4ed8;
    transform: translateY(2.5px);
    box-shadow: 0 0 0 transparent;
}

/* Hiệu ứng ẩn hiện bàn phím */
.keyboard-wrapper {
    transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease-in-out, margin-top 0.25s ease-in-out;
    overflow: hidden;
}

.keyboard-open {
    max-height: 200px;
    opacity: 1;
    margin-top: 0.15rem;
}

.keyboard-closed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

/* Toast thông báo sao chép Zalo mượt mà */
.toast-notice {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-60px);
    background: #0f172a;
    color: #ffffff;
    padding: 10px 18px;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    z-index: 200;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.toast-notice.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Home UI Enhancements */
.nav-item.active div {
    background-color: #eff6ff;
    color: #2563eb;
    transform: translateY(-2px);
}

.nav-item.active span {
    color: #2563eb;
    font-weight: 800;
}

.trip-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.trip-card:active {
    transform: scale(0.98);
}

.trip-card .icon-box {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

#view-home {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.glass-effect {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Settings Enhancements */
#modal-settings-content button:active {
    transform: scale(0.96);
}

#modal-settings-content input:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.settings-group-title {
    position: relative;
    padding-left: 12px;
}

.settings-group-title::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 14px;
    background-color: #2563eb;
    border-radius: 2px;
}

/* ================= UPDATE NOTIFICATION PROMPT ================= */
.update-prompt {
    position: fixed;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%) translateY(120px);
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1.5px solid rgba(59, 130, 246, 0.4);
    color: #ffffff;
    padding: 10px 12px 10px 16px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 25px rgba(37, 99, 235, 0.2);
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 120;
    max-width: calc(100vw - 28px);
}

.update-prompt.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.update-prompt-text {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #f8fafc;
}

.update-prompt-btn {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    border: none;
    padding: 7px 15px;
    border-radius: 10px;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
    transition: transform 0.15s ease, opacity 0.15s ease;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.update-prompt-btn:hover {
    transform: scale(1.04);
}

.update-prompt-btn:active {
    transform: scale(0.96);
}

.update-prompt-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.update-prompt-close:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}