* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f5f5; color: #333; }

.login-container { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.login-card { background: white; padding: 2.5rem; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.15); width: 100%; max-width: 400px; text-align: center; }
.login-card h1 { font-size: 2rem; color: #764ba2; margin-bottom: 0.25rem; }
.login-card .subtitle { color: #888; margin-bottom: 1.5rem; }

.field { margin-bottom: 1rem; }
.field input, .field select, .field textarea { width: 100%; padding: 0.75rem; border: 1px solid #ddd; border-radius: 8px; font-size: 1rem; transition: border-color 0.2s, box-shadow 0.2s; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: #764ba2; box-shadow: 0 0 0 3px rgba(118, 75, 162, 0.15); }
.field label { display: block; margin-bottom: 0.25rem; font-weight: 600; color: #555; }
.field textarea { resize: vertical; min-height: 80px; }

.btn-primary { padding: 0.75rem 1.5rem; background: #764ba2; color: white; border: none; border-radius: 8px; font-size: 1rem; cursor: pointer; transition: background 0.2s; }
.btn-primary:hover { background: #5a3d7a; }
.btn-primary:disabled { background: #b39ddb; cursor: not-allowed; }

.btn-secondary { padding: 0.5rem 1rem; background: #3498db; color: white; border: none; border-radius: 6px; cursor: pointer; transition: background 0.2s, transform 0.15s; }
.btn-secondary:hover { background: #2980b9; transform: translateY(-1px); }

.btn-danger { padding: 0.5rem 1rem; background: #e74c3c; color: white; border: none; border-radius: 6px; cursor: pointer; transition: background 0.2s, transform 0.15s; }
.btn-danger:hover { background: #c0392b; transform: translateY(-1px); }

.btn-success { padding: 0.5rem 1rem; background: #27ae60; color: white; border: none; border-radius: 6px; cursor: pointer; transition: background 0.2s, transform 0.15s; }
.btn-success:hover { background: #219a52; transform: translateY(-1px); }

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

.hidden { display: none !important; }
.error { color: #e74c3c; font-size: 0.875rem; margin-bottom: 0.75rem; }

.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: #2c3e50; color: white; padding: 1.5rem; display: flex; flex-direction: column; }
.sidebar-logo { max-width: 140px; margin-bottom: 1.5rem; display: block; border-radius: 8px; }
.sidebar h2 { margin-bottom: 2rem; font-size: 1.25rem; }
.login-logo { max-width: 100px; margin: 0 auto 0.5rem; display: block; border-radius: 8px; }
.sidebar nav a { display: block; padding: 0.5rem 0.75rem; color: #bdc3c7; text-decoration: none; border-radius: 6px; margin-bottom: 0.25rem; transition: all 0.2s; }
.sidebar nav a:hover, .sidebar nav a.active { background: #34495e; color: white; }
.sidebar nav hr { border-color: #34495e; margin: 1rem 0; }
.sidebar .spacer { flex: 1; }
.main-content { flex: 1; padding: 2rem; overflow-y: auto; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.main-content h1 { margin-bottom: 1.5rem; color: #2c3e50; }

table { width: 100%; border-collapse: collapse; background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.08); transition: box-shadow 0.2s; }
table:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
thead { background: #34495e; color: white; }
th, td { padding: 0.75rem 1rem; text-align: left; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { background: #2c3e50; }
.sort-indicator { font-size: 0.7rem; margin-left: 0.25rem; }
tbody tr:nth-child(even) { background: #f8f9fa; }
tbody tr:hover { background: #eef2f7; }

.header-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.header-actions h1 { margin-bottom: 0; }

form { background: white; padding: 1.5rem; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
form .field { margin-bottom: 1.25rem; }
form .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
.form-actions .btn-primary { flex: 1; padding: 0.85rem; font-size: 1.05rem; }
.form-actions .btn-secondary { flex: 1; padding: 0.85rem; font-size: 1.05rem; }

.search-bar { margin-bottom: 1rem; }
.search-bar input { width: 100%; max-width: 400px; padding: 0.5rem 0.75rem; border: 1px solid #ddd; border-radius: 6px; font-size: 0.925rem; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.kpi-card { background: white; padding: 1.25rem; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); text-align: center; transition: transform 0.2s, box-shadow 0.2s; }
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
.kpi-card h3 { font-size: 0.875rem; color: #888; margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-card .kpi-value { font-size: 1.75rem; font-weight: 700; color: #2c3e50; }
.kpi-card .kpi-value.positive { color: #27ae60; }
.kpi-card .kpi-value.negative { color: #e74c3c; }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 2rem; }
.chart-card { background: white; padding: 1rem; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.chart-card h3 { margin-bottom: 0.75rem; color: #555; }

.result-box { background: #f0f4fa; border: 2px solid #764ba2; border-radius: 10px; padding: 1.5rem; text-align: center; margin-top: 1rem; }
.result-box .result-label { font-size: 0.875rem; color: #888; margin-bottom: 0.25rem; }
.result-box .result-value { font-size: 2rem; font-weight: 700; color: #764ba2; }

.stock-badge { display: inline-block; padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.8rem; font-weight: 600; }
.stock-badge.normal { background: #e8f5e9; color: #2e7d32; }
.stock-badge.warning { background: #fff3e0; color: #e65100; }
.stock-badge.critical { background: #fce4ec; color: #c62828; }

.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center; }
.modal-overlay.active { display: flex; }
.modal { background: white; border-radius: 12px; padding: 2.5rem; width: 90%; max-width: 640px; max-height: 85vh; overflow-y: auto; }
.modal h2 { margin-bottom: 1.5rem; font-size: 1.35rem; }

#stockWarning { background: #fff3e0; border: 1px solid #ffcc02; color: #e65100; padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; display: none; }
#stockWarning.show { display: block; }
