/* IT68 Scanner - Clean Pastel Theme */
:root {
    --bg: #f8fbff;
    --bg-soft: #eef6ff;
    --surface: #ffffff;
    --surface-soft: #f5f8ff;
    --text: #0f172a;
    --text-soft: #334155;
    --text-muted: #64748b;
    --line: #dbe7f3;
    --line-blue: #bfdbfe;
    --line-pink: #fbcfe8;
    --line-green: #bbf7d0;
    --line-violet: #ddd6fe;
    --brand: #2563eb;
    --brand-soft: #dbeafe;
    --pink: #db2777;
    --pink-soft: #fce7f3;
    --green: #15803d;
    --green-soft: #dcfce7;
    --amber: #b45309;
    --amber-soft: #fef3c7;
    --red: #b91c1c;
    --red-soft: #fee2e2;
    --violet: #6d28d9;
    --violet-soft: #ede9fe;
    --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
    --focus: 0 0 0 3px rgba(37, 99, 235, 0.22);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    font-family: "Segoe UI", Tahoma, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(219, 234, 254, 0.9), transparent 34%),
        linear-gradient(135deg, var(--bg) 0%, var(--bg-soft) 100%) !important;
    color: var(--text) !important;
}

body,
button,
input,
select,
textarea {
    font-family: "Segoe UI", Tahoma, sans-serif;
}

.container,
.login-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 12px;
    overflow: hidden;
    color: var(--text) !important;
}

.header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0 10px;
    border-bottom: 1px solid var(--line) !important;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.header h1,
.login-title {
    color: var(--text) !important;
    font-weight: 800;
    letter-spacing: 0;
}

.header h1 {
    font-size: 1.1rem;
}

.header .user-info,
.latest-header,
.recent-header,
.history-title,
.form-group label,
.form-row label,
.result-label,
.stock-label,
.product-info,
.order-info,
.order-date,
.product-info-label {
    color: var(--text-muted) !important;
}

.back-btn,
.logout-btn {
    border: 1px solid var(--line-blue) !important;
    background: var(--surface) !important;
    color: var(--brand) !important;
    box-shadow: var(--shadow);
}

.back-btn {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.back-btn:focus,
.back-btn:hover,
.menu-item:focus,
.product-item:focus,
.order-item:focus,
.btn:focus,
.btn-login:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none !important;
    box-shadow: var(--focus) !important;
}

.menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    flex: 1;
    align-content: start;
    overflow-y: auto;
}

.menu-item,
.product-item,
.order-item,
.result-box,
.product-box,
.product-info-box,
.stock-info,
.latest-item,
.recent-item,
.history-item,
.modal-content,
.bill-input-card,
.session-info,
.diag,
.result {
    background: var(--surface) !important;
    border: 1px solid var(--line) !important;
    color: var(--text) !important;
    box-shadow: var(--shadow);
}

.menu-item {
    border-radius: 12px;
    padding: 15px 10px;
    min-height: 92px;
    text-align: center;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.15s, border-color 0.15s, background-color 0.15s;
    touch-action: manipulation;
    user-select: none;
}

.menu-item:nth-child(4n + 1) {
    border-color: var(--line-blue) !important;
    background: linear-gradient(180deg, #ffffff, #eff6ff) !important;
}

.menu-item:nth-child(4n + 2) {
    border-color: var(--line-violet) !important;
    background: linear-gradient(180deg, #ffffff, #f5f3ff) !important;
}

.menu-item:nth-child(4n + 3) {
    border-color: var(--line-pink) !important;
    background: linear-gradient(180deg, #ffffff, #fdf2f8) !important;
}

.menu-item:nth-child(4n + 4) {
    border-color: var(--line-green) !important;
    background: linear-gradient(180deg, #ffffff, #f0fdf4) !important;
}

.menu-item:hover {
    transform: translateY(-1px);
    border-color: var(--brand) !important;
}

.menu-item:active {
    transform: scale(0.98);
}

.menu-item i {
    font-size: 2rem;
}

.menu-icon-3d {
    width: 54px;
    height: 54px;
    object-fit: contain;
    display: block;
    margin-bottom: 2px;
}

.menu-item span {
    color: var(--text) !important;
    font-size: 0.92rem;
    font-weight: 700;
}

.footer {
    margin-top: 10px;
    text-align: center;
    flex-shrink: 0;
}

.logout-btn {
    display: inline-block;
    color: var(--red) !important;
    border-color: #fecaca !important;
    background: var(--red-soft) !important;
    padding: 10px 25px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 800;
    touch-action: manipulation;
    user-select: none;
}

.form-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    align-items: stretch;
}

.form-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.form-row label {
    width: 80px;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.form-group {
    width: 100%;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.form-group label {
    display: block;
    font-size: 1rem;
    margin-bottom: 6px;
    font-weight: 700;
}

.form-row input,
.form-group input,
.search-input,
.cat-select,
input,
select,
textarea {
    background: var(--surface) !important;
    border: 2px solid var(--line-blue) !important;
    color: var(--text) !important;
    border-radius: 12px;
    outline: none;
}

.form-row input,
.form-group input {
    width: 100%;
    padding: 14px;
    font-size: 1.1rem;
}

.form-row input[readonly],
.form-group input[readonly] {
    background: var(--surface-soft) !important;
    color: var(--text-muted) !important;
}

input::placeholder,
textarea::placeholder {
    color: #94a3b8 !important;
    opacity: 1;
}

.form-row input.found,
.form-group input.found {
    border-color: #86efac !important;
    background: var(--green-soft) !important;
}

.btn,
.btn-login,
.action-btn {
    border: 1px solid transparent !important;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 800;
    letter-spacing: 0;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.btn {
    flex: 1;
    padding: 14px;
    font-size: 1.05rem;
}

.btn-primary,
.btn-login,
.btn-withdraw,
.bill-submit-btn,
#btnSave,
#btnAdd,
#btnPrint {
    background: linear-gradient(135deg, #f9a8d4, #fbcfe8) !important;
    border-color: #f9a8d4 !important;
    color: #831843 !important;
}

.btn-secondary,
.btn-print,
.order-list-btn {
    background: linear-gradient(135deg, #bfdbfe, #e0f2fe) !important;
    border-color: #93c5fd !important;
    color: #1e3a8a !important;
}

.btn:disabled,
.btn[disabled],
button:disabled {
    opacity: 0.58 !important;
    cursor: not-allowed !important;
    filter: grayscale(0.15);
}

.action-buttons {
    display: flex;
    gap: 10px;
    padding-top: 10px;
    flex-shrink: 0;
}

.status-msg,
.error,
.warn {
    text-align: center;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--line) !important;
}

.status-msg.success,
.ok {
    background: var(--green-soft) !important;
    border-color: var(--line-green) !important;
    color: var(--green) !important;
}

.status-msg.error,
.error,
.err {
    background: var(--red-soft) !important;
    border-color: #fecaca !important;
    color: var(--red) !important;
}

.warn {
    background: var(--amber-soft) !important;
    border-color: #fde68a !important;
    color: var(--amber) !important;
}

.result-row,
.modal-row,
.order-actions-row {
    border-color: var(--line) !important;
}

.result-value,
.product-info-value,
.product-barcode,
.modal-title,
.stock-value,
.product-name,
.order-id,
.bill-badge,
.latest-name {
    color: var(--brand) !important;
}

.stock-info,
.session-info {
    background: var(--amber-soft) !important;
    border-color: #fde68a !important;
    color: var(--amber) !important;
}

.stock-value {
    color: var(--amber) !important;
}

.product-box {
    background: var(--green-soft) !important;
    border-color: var(--line-green) !important;
}

.product-box .name {
    color: var(--green) !important;
}

.bill-badge,
.dept-badge,
.stock-badge {
    background: var(--brand-soft) !important;
    border: 1px solid var(--line-blue) !important;
    color: var(--brand) !important;
}

.limit-badge,
.order-status.status-wait {
    background: var(--amber-soft) !important;
    border: 1px solid #fde68a !important;
    color: var(--amber) !important;
}

.order-status.status-ok {
    background: var(--green-soft) !important;
    border: 1px solid var(--line-green) !important;
    color: var(--green) !important;
}

.modal {
    background: rgba(15, 23, 42, 0.28) !important;
    backdrop-filter: blur(4px);
}

.history-section,
.history {
    flex: 1;
    min-height: 150px;
    max-height: 220px;
    overflow-y: auto;
}

.empty-state {
    min-height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px 12px;
    color: var(--text-muted) !important;
    text-align: center;
    font-size: 1rem;
    line-height: 1.45;
}

.empty-state i {
    font-size: 2.8rem !important;
    color: var(--text-muted) !important;
}

.empty-state p {
    margin: 0;
    font-weight: 600;
}

.history-item,
.recent-item,
.latest-item,
.product-item,
.order-item {
    border-radius: 12px;
}

.recent-item.in,
.latest-item {
    border-color: var(--line-green) !important;
}

.recent-item.out {
    border-color: #fecaca !important;
}

.recent-item.in::after {
    background: #86efac !important;
}

.recent-item.out::after {
    background: #fca5a5 !important;
}

.recent-name {
    color: var(--text) !important;
}

.recent-meta,
.latest-meta {
    color: var(--text-muted) !important;
}

.qty-input {
    font-size: 1.5rem !important;
    text-align: center;
    padding: 18px !important;
}

.no-result,
.no-orders,
.waiting-screen,
.version {
    color: var(--text-muted) !important;
}

.btn-icon-del,
button[onclick*="delete"],
button[onclick*="clearQueue"] {
    color: var(--red) !important;
}

/* Map legacy inline colors to the clean theme without touching behavior. */
[style*="#fff"],
[style*="white"] {
    color: var(--text) !important;
}

[style*="#94a3b8"],
[style*="#64748b"],
[style*="#cbd5e1"],
[style*="#e2e8f0"],
[style*="#d1fae5"] {
    color: var(--text-muted) !important;
}

[style*="#00cec9"],
[style*="#60a5fa"],
[style*="#74b9ff"],
[style*="#0984e3"] {
    color: var(--brand) !important;
}

[style*="#f472b6"],
[style*="#ec4899"],
[style*="#db2777"],
[style*="#6c5ce7"],
[style*="#a78bfa"],
[style*="#8b5cf6"] {
    color: var(--pink) !important;
}

[style*="#4ade80"],
[style*="#22c55e"],
[style*="#34d399"],
[style*="#00b894"] {
    color: var(--green) !important;
}

[style*="#fbbf24"],
[style*="#f59e0b"],
[style*="#fab1a0"] {
    color: var(--amber) !important;
}

[style*="#f87171"],
[style*="#ef4444"],
[style*="#ff6b6b"] {
    color: var(--red) !important;
}

[style*="background: rgba(255,255,255,0.05)"],
[style*="background:rgba(255,255,255,0.05)"],
[style*="background: rgba(255, 255, 255, 0.05)"],
[style*="background: rgba(255, 255, 255, 0.08)"],
[style*="background: rgba(255, 255, 255, 0.1)"],
[style*="background: rgba(255, 255, 255, 0.12)"],
[style*="background: rgba(255, 255, 255, 0.15)"],
[style*="background:#1e293b"],
[style*="background: #1e293b"] {
    background: var(--surface) !important;
}

[style*="border:1px solid #334155"],
[style*="border: 1px solid rgba(255, 255, 255, 0.1)"],
[style*="border: 1px solid rgba(255, 255, 255, 0.2)"],
[style*="border:2px dashed #334155"],
[style*="border: 2px solid rgba(255, 255, 255, 0.2)"],
[style*="border-top: 1px solid rgba(255,255,255,0.1)"],
[style*="border-top: 1px solid rgba(255, 255, 255, 0.1)"] {
    border-color: var(--line) !important;
}

.login-container {
    justify-content: center;
    align-items: center;
    padding: 18px;
    gap: 0;
}

.logo {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    border-radius: 18px;
    background: linear-gradient(135deg, #fff7ed, #fed7aa);
    border: 1px solid #fdba74;
    box-shadow: var(--shadow);
    font-size: 2.1rem;
    overflow: hidden;
}

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

.header-logo {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    object-fit: contain;
    flex-shrink: 0;
    vertical-align: middle;
    margin-right: 6px;
}

.item-logo {
    width: 18px;
    height: 18px;
    object-fit: contain;
    vertical-align: -3px;
    margin-right: 4px;
}

.login-title {
    font-size: 1.5rem;
    margin-bottom: 18px;
    text-align: center;
}

.login-container form {
    width: min(100%, 400px) !important;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid var(--line-blue);
    border-radius: 16px;
    padding: 18px 16px 16px;
    box-shadow: var(--shadow);
}

.login-container .form-group {
    margin-bottom: 14px;
    width: min(100%, 320px);
    margin-left: auto;
    margin-right: auto;
}

.login-container .form-group label {
    color: var(--text-soft) !important;
    font-size: 0.95rem;
    margin-bottom: 7px;
}

.login-container .form-group input {
    width: 100%;
    height: 52px;
    padding: 12px 14px;
    border-width: 1px !important;
    border-color: var(--line-blue) !important;
    box-shadow: none;
}

.login-container .form-group input:focus {
    border-color: var(--brand) !important;
    box-shadow: var(--focus) !important;
}

.btn-login {
    width: min(100%, 320px);
    min-height: 54px;
    padding: 14px 16px;
    font-size: 1.05rem;
    margin: 4px auto 0;
    background: linear-gradient(135deg, #bfdbfe, #e0f2fe) !important;
    border-color: #93c5fd !important;
    color: #1e3a8a !important;
}

.login-container .error {
    width: min(100%, 400px);
    margin-bottom: 12px;
}

.pin-login-form {
    width: min(100%, 400px) !important;
}

.pin-section {
    text-align: center;
    margin-bottom: 14px;
}

.pin-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-soft) !important;
    margin-bottom: 12px;
}

.pin-dots {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
}

.pin-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--line-blue);
    background: #fff;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.pin-dot.filled {
    background: linear-gradient(135deg, #2563eb, #38bdf8);
    border-color: #2563eb;
    transform: scale(1.08);
}

.pin-dot.error {
    border-color: #dc2626;
    background: rgba(220, 38, 38, 0.15);
    animation: pinShake 0.4s ease;
}

@keyframes pinShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.pin-hint {
    font-size: 0.8rem;
    color: var(--text-muted) !important;
    min-height: 1.1rem;
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 300px;
    margin: 0 auto 14px;
}

.numpad-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    font-size: 1.3rem;
    font-weight: 700;
    color: #1e3a8a;
    background: #fff;
    border: 1px solid var(--line-blue);
    border-radius: 12px;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    transition: background 0.12s, transform 0.1s;
    box-shadow: var(--shadow);
}

.numpad-btn:hover:not(:disabled) {
    background: #eff6ff;
    border-color: #93c5fd;
}

.numpad-btn:active:not(:disabled) {
    transform: scale(0.96);
}

.numpad-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.numpad-btn.action {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
}

.numpad-btn.action-danger {
    color: #dc2626;
}

.login-container .alert.error {
    background: rgba(220, 38, 38, 0.08);
    border: 1px solid rgba(220, 38, 38, 0.25);
    color: #b91c1c;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.9rem;
    margin-bottom: 12px;
    width: 100%;
}

.version {
    position: absolute;
    bottom: 15px;
    font-size: 0.8rem;
}

@media screen and (max-width: 500px) {
    html,
    body,
    .container,
    .login-container {
        width: 100% !important;
        height: 100% !important;
    }
}
