/* ===== VARIABLES ===== */
:root {
    --primary: #2563eb; --primary-dark: #1d4ed8; --primary-light: #dbeafe;
    --danger: #dc2626; --danger-light: #fee2e2;
    --success: #16a34a; --success-light: #dcfce7;
    --warning: #f59e0b; --warning-light: #fef3c7;
    --info: #0891b2; --info-light: #cffafe;
    --gray-50: #f9fafb; --gray-100: #f3f4f6; --gray-200: #e5e7eb; --gray-300: #d1d5db;
    --gray-400: #9ca3af; --gray-500: #6b7280; --gray-600: #4b5563; --gray-700: #374151;
    --gray-800: #1f2937; --gray-900: #111827;
    --radius: 12px; --radius-sm: 8px; --radius-xs: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08); --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; background: #eef2f7; color: var(--gray-800); line-height: 1.6; min-height: 100vh; }
a { color: var(--primary); text-decoration: none; }

/* ===== TOPBAR ===== */
.topbar { background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%); padding: 0 28px; height: 60px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 12px rgba(0,0,0,0.15); }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-left h1 { font-size: 17px; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 8px; }
.topbar-left .back-btn { width: 36px; height: 36px; border-radius: var(--radius-xs); border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.1); display: flex; align-items: center; justify-content: center; cursor: pointer; color: #fff; transition: all .2s; }
.topbar-left .back-btn:hover { background: rgba(255,255,255,0.2); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar .user-info { font-size: 13px; color: #94a3b8; }
.topbar .user-info strong { color: #e2e8f0; }
.topbar .btn-outline { border-color: rgba(255,255,255,0.2); color: #e2e8f0; background: rgba(255,255,255,0.08); }
.topbar .btn-outline:hover { background: rgba(255,255,255,0.18); }

/* ===== CONTAINER ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 28px; }
.container-wide { max-width: 1400px; margin: 0 auto; padding: 28px; }

/* ===== STATS GRID ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 20px; display: flex; align-items: center; gap: 16px; transition: all .2s; text-decoration: none; color: inherit; border-left: 4px solid var(--gray-200); box-shadow: var(--shadow); }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card.stat-instock { border-left-color: var(--success); }
.stat-card.stat-exported { border-left-color: var(--danger); }
.stat-card.stat-transferring { border-left-color: var(--warning); }
.stat-card.stat-total { border-left-color: var(--primary); }
.stat-card .stat-icon { width: 48px; height: 48px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-card.stat-instock .stat-icon { background: var(--success-light); color: var(--success); }
.stat-card.stat-exported .stat-icon { background: var(--danger-light); color: var(--danger); }
.stat-card.stat-transferring .stat-icon { background: var(--warning-light); color: var(--warning); }
.stat-card.stat-total .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.yellow { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.cyan { background: var(--info-light); color: var(--info); }
.stat-info { flex: 1; }
.stat-info .stat-value { font-size: 26px; font-weight: 800; color: var(--gray-900); line-height: 1.2; }
.stat-info .stat-label { font-size: 13px; color: var(--gray-500); margin-top: 2px; font-weight: 500; }

/* ===== MENU GRID ===== */
.menu-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.menu-item { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 28px 16px; background: #fff; border: 1.5px solid var(--gray-200); border-radius: var(--radius); text-decoration: none; color: var(--gray-600); transition: all .25s; cursor: pointer; box-shadow: var(--shadow); }
.menu-item:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-3px); box-shadow: 0 8px 25px rgba(37,99,235,0.15); }
.menu-item .icon { width: 56px; height: 56px; background: var(--gray-100); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; transition: all .25s; }
.menu-item:hover .icon { background: var(--primary-light); color: var(--primary); }
.menu-item .icon i, .menu-item .icon svg { width: 26px; height: 26px; }
.menu-item .label { font-size: 13px; font-weight: 600; text-align: center; }

/* ===== CARDS ===== */
.card { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; color: var(--gray-800); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--gray-100); }
.card-header h2 { font-size: 16px; font-weight: 700; color: var(--gray-900); display: flex; align-items: center; gap: 8px; }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; border: none; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; transition: all .2s; white-space: nowrap; }
.btn i, .btn svg { width: 16px; height: 16px; }
.btn-primary { background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,0.3); }
.btn-primary:hover { background: linear-gradient(135deg, #1d4ed8, #1e40af); box-shadow: 0 4px 16px rgba(37,99,235,0.4); transform: translateY(-1px); }
.btn-success { background: linear-gradient(135deg, #16a34a, #15803d); color: #fff; box-shadow: 0 2px 8px rgba(22,163,74,0.3); }
.btn-success:hover { background: #15803d; }
.btn-danger { background: linear-gradient(135deg, #dc2626, #b91c1c); color: #fff; box-shadow: 0 2px 8px rgba(220,38,38,0.3); }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: #fff; color: var(--gray-700); border: 1.5px solid var(--gray-200); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px 14px; border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm); font-size: 14px; color: var(--gray-800); background: #fff; transition: all .2s; outline: none; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); background: #fff; }
.form-group select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; cursor: pointer; }

/* ===== FILTER BAR ===== */
.filter-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-bar .search-box { position: relative; flex: 1; min-width: 220px; }
.filter-bar .search-box input { width: 100%; padding: 9px 14px 9px 38px; border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm); font-size: 14px; background: #fff; transition: all .2s; outline: none; }
.filter-bar .search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.filter-bar .search-box .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--gray-400); pointer-events: none; }
.filter-bar select { padding: 9px 36px 9px 14px; border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm); font-size: 14px; background: #fff; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; cursor: pointer; outline: none; min-width: 160px; transition: all .2s; }
.filter-bar select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }

/* ===== TABLES ===== */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--gray-200); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead { background: #f8fafc; }
th { padding: 12px 16px; text-align: left; font-weight: 600; color: #475569; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; border-bottom: 2px solid var(--gray-200); }
td { padding: 10px 16px; border-bottom: 1px solid var(--gray-100); color: var(--gray-700); }
tr:hover { background: #f8fafc; }
.table-empty { text-align: center; padding: 40px 16px; color: var(--gray-400); }
.card .table-wrapper { margin: 0 -24px -24px; border: none; border-top: 1px solid var(--gray-200); border-radius: 0 0 var(--radius) var(--radius); }

/* ===== BADGES ===== */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-green, .badge-instock { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-yellow, .badge-transferring { background: #fef3c7; color: #b45309; }
.badge-blue { background: #dbeafe; color: #2563eb; }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }

/* ===== TABS ===== */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--gray-200); margin-bottom: 20px; }
.tab-btn { padding: 10px 20px; border: none; background: none; font-size: 14px; font-weight: 600; color: var(--gray-500); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .2s; display: flex; align-items: center; gap: 6px; }
.tab-btn:hover { color: var(--gray-700); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== LOGIN ===== */
.login-wrapper { min-height: 100vh; display: flex; align-items: stretch; }
.login-brand { flex: 1; background: linear-gradient(135deg, #0f172a 0%, #1e40af 50%, #2563eb 100%); display: flex; flex-direction: column; justify-content: center; padding: 60px 50px; color: #fff; position: relative; overflow: hidden; }
.login-brand::before { content: ''; position: absolute; top: -50%; right: -50%; width: 100%; height: 200%; background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 70%); }
.login-brand .brand-icon { width: 56px; height: 56px; background: rgba(255,255,255,0.15); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; margin-bottom: 24px; }
.login-brand h1 { font-size: 28px; font-weight: 700; margin-bottom: 12px; }
.login-brand p { font-size: 15px; opacity: 0.85; line-height: 1.7; max-width: 380px; }
.login-form-side { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 60px 80px; background: #fff; }
.login-form-side h2 { font-size: 22px; font-weight: 700; color: var(--gray-900); margin-bottom: 6px; }
.login-form-side .subtitle { font-size: 14px; color: var(--gray-500); margin-bottom: 32px; }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; opacity: 0; visibility: hidden; transition: all .3s; }
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal { background: #fff; border-radius: var(--radius); padding: 24px; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); transform: translateY(20px); transition: transform .3s; }
.modal-overlay.active .modal { transform: translateY(0); }
.modal h3 { font-size: 17px; font-weight: 700; margin-bottom: 20px; color: var(--gray-900); display: flex; align-items: center; gap: 8px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--gray-100); }

/* ===== TOAST ===== */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: var(--radius-sm); color: #fff; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 10px; box-shadow: 0 8px 30px rgba(0,0,0,0.2); animation: slideIn .3s ease; min-width: 280px; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== ALERTS ===== */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; font-weight: 500; }
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #fca5a5; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #86efac; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fcd34d; }

/* ===== PRODUCT CARD ===== */
.product-card { border: 1.5px solid var(--gray-200); border-radius: var(--radius); padding: 20px; background: #fff; }
.product-card .product-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--gray-100); }
.product-card .product-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.product-card .product-field label { font-size: 12px; color: var(--gray-500); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.product-card .product-field .value { font-size: 14px; color: var(--gray-800); font-weight: 500; margin-top: 2px; }

/* ===== SCANNER ===== */
.scanner-area { border: 2px dashed var(--gray-300); border-radius: var(--radius); padding: 40px; text-align: center; background: var(--gray-50); margin-bottom: 16px; }

/* ===== QUANTITY ===== */
.quantity-wrapper { display: flex; align-items: center; border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm); overflow: hidden; width: fit-content; background: #fff; }
.quantity-wrapper:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.quantity-wrapper button { width: 38px; height: 38px; border: none; background: var(--gray-50); color: var(--gray-600); font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.quantity-wrapper button:hover { background: var(--primary-light); color: var(--primary); }
.quantity-wrapper input { width: 60px; height: 38px; border: none; border-left: 1px solid var(--gray-200); border-right: 1px solid var(--gray-200); text-align: center; font-size: 15px; font-weight: 600; outline: none; -moz-appearance: textfield; }
.quantity-wrapper input::-webkit-outer-spin-button, .quantity-wrapper input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ===== SERIAL COUNT ===== */
.serial-count { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; background: var(--primary-light); color: var(--primary); border-radius: 20px; font-size: 13px; font-weight: 600; }

/* ===== LOADING / EMPTY ===== */
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--gray-400); gap: 10px; }
.spinner { width: 20px; height: 20px; border: 2.5px solid var(--gray-200); border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 48px 24px; color: var(--gray-400); }
.empty-state i, .empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.5; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } .menu-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px) { .login-wrapper { flex-direction: column; } .login-brand { padding: 40px 24px; flex: none; } .login-form-side { padding: 32px 24px; max-width: 100%; } .stats-grid { grid-template-columns: 1fr 1fr; } .menu-grid { grid-template-columns: repeat(2, 1fr); } .container, .container-wide { padding: 16px; } .filter-bar { flex-direction: column; align-items: stretch; } .filter-bar select { min-width: 100%; } .product-card .product-grid { grid-template-columns: 1fr; } }
@media (max-width: 480px) { .stats-grid { grid-template-columns: 1fr; } .menu-grid { grid-template-columns: 1fr 1fr; } .topbar { padding: 0 12px; } }


/* Prevent iOS zoom on input focus */
@media (max-width: 768px) {
    input, select, textarea { font-size: 16px !important; }
    .topbar { padding: 0 16px; height: 54px; }
    .topbar-left h1 { font-size: 15px; }
    .topbar .user-info { display: none; }
    .container, .container-wide { padding: 16px; }
    .card { padding: 16px; }
    .card .table-wrapper { margin: 0 -16px -16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
    .stat-card { padding: 14px; gap: 12px; }
    .stat-info .stat-value { font-size: 22px; }
    .menu-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
    .menu-item { padding: 18px 10px; }
    .menu-item .icon { width: 44px; height: 44px; }
    .menu-item .icon i, .menu-item .icon svg { width: 22px; height: 22px; }
    .menu-item .label { font-size: 12px; }
    .filter-bar { gap: 8px; }
    .filter-bar select { min-width: 100%; }
    .modal { padding: 20px; margin: 16px; }
    .product-card .product-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .menu-grid { grid-template-columns: 1fr 1fr; }
}

/* Menu card colors */
.menu-item:nth-child(1) .icon { background: #fee2e2; color: #ef4444; }
.menu-item:nth-child(2) .icon { background: #dbeafe; color: #2563eb; }
.menu-item:nth-child(3) .icon { background: #d1fae5; color: #10b981; }
.menu-item:nth-child(4) .icon { background: #fef3c7; color: #f59e0b; }
.menu-item:nth-child(5) .icon { background: #ede9fe; color: #8b5cf6; }
.menu-item:nth-child(6) .icon { background: #fce7f3; color: #ec4899; }
.menu-item:nth-child(7) .icon { background: #e0f2fe; color: #0ea5e9; }
.menu-item:hover { transform: translateY(-4px); box-shadow: 0 8px 25px rgba(0,0,0,0.1); }
.menu-item .icon { transition: all 0.3s ease; }
.menu-item:hover .icon { transform: scale(1.1); }
