* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f0f2f5; color: #1a1a2e; min-height: 100vh; }

/* Login */
.login-container { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: #fff; padding: 2.5rem; border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,.1); width: 100%; max-width: 380px; }
.login-box h1 { font-size: 1.5rem; margin-bottom: .25rem; }
.login-box p { color: #666; margin-bottom: 1.5rem; font-size: .9rem; }
.login-box label { display: block; font-weight: 600; margin-bottom: .25rem; font-size: .85rem; }
.login-box input { width: 100%; padding: .6rem .75rem; border: 1px solid #d0d5dd; border-radius: 8px; font-size: .95rem; margin-bottom: 1rem; }
.login-box input:focus { outline: none; border-color: #4361ee; box-shadow: 0 0 0 3px rgba(67,97,238,.15); }
.login-box button { width: 100%; padding: .7rem; background: #4361ee; color: #fff; border: none; border-radius: 8px; font-size: 1rem; font-weight: 600; cursor: pointer; }
.login-box button:hover { background: #3a56d4; }
.login-error { color: #e74c3c; font-size: .85rem; margin-bottom: .75rem; display: none; }

/* Top bar */
.topbar { background: #fff; padding: .75rem 1.25rem; display: flex; align-items: center; gap: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,.08); position: sticky; top: 0; z-index: 100; }
.topbar h1 { font-size: 1.1rem; white-space: nowrap; }
.topbar select, .topbar button { padding: .4rem .75rem; border: 1px solid #d0d5dd; border-radius: 6px; font-size: .85rem; background: #fff; cursor: pointer; }
.topbar .spacer { flex: 1; }
.topbar .btn-logout { background: #e74c3c; color: #fff; border: none; }
.topbar .btn-logout:hover { background: #c0392b; }
.topbar .btn-add-dept { background: #27ae60; color: #fff; border: none; }

/* Mode banner */
.mode-banner { padding: .5rem; text-align: center; font-size: 1.4rem; font-weight: 800; letter-spacing: 2px; transition: background .3s, color .3s; user-select: none; cursor: pointer; }
.mode-banner.add { background: #27ae60; color: #fff; }
.mode-banner.remove { background: #e74c3c; color: #fff; }

/* Scan bar */
.scan-bar { max-width: 1000px; margin: 0 auto; padding: .5rem 1rem 0; }
.scan-bar input { width: 100%; padding: .75rem 1rem; font-size: 1.1rem; border: 2px solid #4361ee; border-radius: 8px; outline: none; background: #fff; }
.scan-bar input:focus { box-shadow: 0 0 0 3px rgba(67,97,238,.25); }

/* Main content */
.app-container { display: none; }
.content { max-width: 1000px; margin: 0 auto; padding: .5rem 1rem; }

/* Action bar */
.action-bar { display: flex; gap: .5rem; margin-bottom: .5rem; flex-wrap: wrap; }
.action-bar button { padding: .45rem .9rem; border: 1px solid #d0d5dd; border-radius: 6px; font-size: .85rem; background: #fff; cursor: pointer; }
.action-bar button:hover { background: #f5f5f5; }
.action-bar .btn-primary { background: #4361ee; color: #fff; border: none; }
.action-bar .btn-primary:hover { background: #3a56d4; }

/* Stock table */
.stock-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.stock-table th { background: #f8f9fa; text-align: left; padding: .35rem .6rem; font-size: .75rem; text-transform: uppercase; color: #666; border-bottom: 2px solid #e9ecef; }
.stock-table td { padding: .3rem .6rem; border-bottom: 1px solid #f0f0f0; font-size: .85rem; }
.stock-table tr:hover { background: #f8f9ff; }
.stock-table .barcode-cell { color: #aaa; font-size: .75rem; font-family: monospace; }
.stock-table .qty { font-weight: 700; font-size: 1rem; min-width: 40px; text-align: center; }
.stock-table .qty.zero { color: #e74c3c; }
.stock-table .qty.negative { color: #e74c3c; }
.stock-table .actions { white-space: nowrap; }
.stock-table .actions button { padding: .15rem .4rem; border: 1px solid #d0d5dd; border-radius: 4px; font-size: .72rem; background: #fff; cursor: pointer; margin-right: .2rem; }
.stock-table .actions .btn-del { color: #e74c3c; border-color: #e74c3c; }
.stock-table .actions .btn-del:hover { background: #e74c3c; color: #fff; }
.empty-state { text-align: center; padding: 1.5rem 1rem; color: #999; }
.empty-state p { font-size: 1.1rem; margin-bottom: .5rem; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal { background: #fff; border-radius: 12px; padding: 1.75rem; width: 90%; max-width: 420px; box-shadow: 0 8px 32px rgba(0,0,0,.2); }
.modal h2 { font-size: 1.2rem; margin-bottom: 1rem; }
.modal label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .2rem; margin-top: .75rem; }
.modal input, .modal select { width: 100%; padding: .5rem .65rem; border: 1px solid #d0d5dd; border-radius: 6px; font-size: .9rem; }
.modal input:focus, .modal select:focus { outline: none; border-color: #4361ee; box-shadow: 0 0 0 3px rgba(67,97,238,.15); }
.modal-buttons { display: flex; gap: .5rem; margin-top: 1.25rem; justify-content: flex-end; }
.modal-buttons button { padding: .5rem 1.1rem; border: 1px solid #d0d5dd; border-radius: 6px; font-size: .9rem; cursor: pointer; background: #fff; }
.modal-buttons .btn-primary { background: #4361ee; color: #fff; border: none; }
.modal-buttons .btn-danger { background: #e74c3c; color: #fff; border: none; }

/* Toast */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 300; display: flex; flex-direction: column; gap: .5rem; }
.toast { padding: .65rem 1rem; border-radius: 8px; color: #fff; font-size: .9rem; font-weight: 500; animation: slideIn .3s ease; box-shadow: 0 4px 12px rgba(0,0,0,.15); max-width: 380px; }
.toast.success { background: #27ae60; }
.toast.error { background: #e74c3c; }
.toast.info { background: #4361ee; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Admin panel */
.admin-panel { margin-top: 2rem; background: #fff; border-radius: 8px; padding: 1.25rem; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.admin-panel h2 { font-size: 1.1rem; margin-bottom: 1rem; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th { text-align: left; padding: .5rem; font-size: .8rem; text-transform: uppercase; color: #666; border-bottom: 2px solid #e9ecef; }
.admin-table td { padding: .5rem; border-bottom: 1px solid #f0f0f0; font-size: .87rem; }
.admin-table .actions button { padding: .2rem .5rem; border: 1px solid #d0d5dd; border-radius: 4px; font-size: .78rem; background: #fff; cursor: pointer; margin-right: .25rem; }
.btn-view { color: #4361ee; border-color: #4361ee !important; }
.btn-view:hover { background: #4361ee !important; color: #fff !important; }

/* Inline edit */
.inline-edit { border: 1px solid #4361ee !important; border-radius: 4px; padding: .2rem .4rem; font-size: .9rem; width: 100%; background: #f8f9ff; }

/* Print */
@media print {
    .topbar, .mode-banner, .scan-bar, .action-bar, .admin-panel, .toast-container, .actions { display: none !important; }
    .stock-table { box-shadow: none; }
    body { background: #fff; }
}

/* Responsive */
@media (max-width: 600px) {
    .topbar { flex-wrap: wrap; }
    .topbar h1 { width: 100%; }
    .mode-banner { font-size: 1.5rem; }
    .stock-table { font-size: .82rem; }
    .modal { width: 95%; padding: 1.25rem; }
}
