/* ===== CSS RESET & VARIABLES ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.8);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-glass-hover: rgba(255, 255, 255, 0.06);
  --bg-input: rgba(255, 255, 255, 0.05);
  --bg-modal: rgba(10, 14, 26, 0.95);
  --accent-blue: #3b82f6;
  --accent-blue-glow: rgba(59, 130, 246, 0.3);
  --accent-purple: #8b5cf6;
  --accent-purple-glow: rgba(139, 92, 246, 0.3);
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.3);
  --accent-amber: #f59e0b;
  --accent-amber-glow: rgba(245, 158, 11, 0.3);
  --accent-rose: #f43f5e;
  --accent-rose-glow: rgba(244, 63, 94, 0.3);
  --accent-cyan: #06b6d4;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0a0e1a;
  --border-color: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --gradient-blue: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --gradient-emerald: linear-gradient(135deg, #10b981, #06b6d4);
  --gradient-amber: linear-gradient(135deg, #f59e0b, #ef4444);
  --gradient-rose: linear-gradient(135deg, #f43f5e, #ec4899);
  --gradient-bg: linear-gradient(135deg, #0a0e1a 0%, #111827 50%, #0f172a 100%);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow-blue: 0 0 20px rgba(59, 130, 246, 0.15);
  --shadow-glow-emerald: 0 0 20px rgba(16, 185, 129, 0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 14px; scroll-behavior: smooth; color-scheme: dark; }

select, select option, select optgroup {
  color-scheme: dark;
  background-color: #111827 !important;
  color: #f1f5f9 !important;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--gradient-bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

body::before {
  content: '';
  position: fixed;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle at 20% 50%, rgba(59, 130, 246, 0.05) 0%, transparent 50%),
              radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.05) 0%, transparent 50%),
              radial-gradient(circle at 50% 80%, rgba(16, 185, 129, 0.04) 0%, transparent 50%);
  animation: bgShift 20s ease-in-out infinite;
  z-index: -1; pointer-events: none;
}

@keyframes bgShift {
  0%, 100% { transform: translate(0, 0); }
  33% { transform: translate(-2%, 1%); }
  66% { transform: translate(1%, -2%); }
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ===== LOGIN SCREEN ===== */
.login-screen {
  position: fixed; inset: 0;
  background: var(--gradient-bg);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.login-screen.hidden { display: none; }

.login-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.5s ease;
}

.login-logo {
  text-align: center; margin-bottom: 32px;
}

.login-logo-icon {
  width: 64px; height: 64px;
  background: var(--gradient-blue);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 14px;
  box-shadow: var(--shadow-glow-blue);
  animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.login-logo h2 {
  font-size: 1.6rem; font-weight: 800;
  background: var(--gradient-blue);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-logo p {
  font-size: 0.85rem; color: var(--text-muted); margin-top: 4px;
}

.login-form .form-group {
  margin-bottom: 18px;
}

.login-form .form-group label {
  display: block; font-size: 0.8rem; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 6px;
}

.login-form .form-group input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text-primary);
  font-family: inherit; font-size: 0.9rem;
  outline: none;
  transition: all var(--transition-fast);
}

.login-form .form-group input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.login-error {
  background: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.82rem;
  color: var(--accent-rose);
  margin-bottom: 16px;
  display: none;
  align-items: center; gap: 8px;
}

.login-error.show { display: flex; }

.login-btn {
  width: 100%;
  padding: 13px;
  background: var(--gradient-blue);
  color: white;
  border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.9rem; font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-glow-blue);
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 30px rgba(59, 130, 246, 0.35);
}

.login-btn:active { transform: translateY(0); }

.login-hint {
  text-align: center;
  margin-top: 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.8;
}

.login-hint code {
  background: var(--bg-glass-hover);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
}

/* ===== LAYOUT ===== */
.app-container {
  display: flex; min-height: 100vh;
}

.app-container.hidden { display: none; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: 260px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-color);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  z-index: 100;
  transition: transform var(--transition-base);
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
  display: flex; align-items: center; gap: 12px;
}

.logo-icon {
  width: 40px; height: 40px;
  background: var(--gradient-blue);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  box-shadow: var(--shadow-glow-blue);
}

.logo-text h1 {
  font-size: 1.1rem; font-weight: 700;
  background: var(--gradient-blue);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; letter-spacing: -0.3px;
}

.logo-text span {
  font-size: 0.75rem; color: var(--text-muted); font-weight: 400;
}

/* User Profile Section */
.sidebar-profile {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; gap: 12px;
}

.profile-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; font-weight: 700; color: white;
  flex-shrink: 0;
}

.profile-avatar.admin { background: var(--gradient-blue); }
.profile-avatar.user { background: var(--gradient-emerald); }

.profile-info { flex: 1; min-width: 0; }

.profile-name {
  font-size: 0.85rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.profile-role {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.profile-role.admin {
  background: rgba(59, 130, 246, 0.12); color: var(--accent-blue);
}

.profile-role.supervisor {
  background: rgba(139, 92, 246, 0.12); color: var(--accent-purple);
}

.profile-role.foreman {
  background: rgba(245, 158, 11, 0.12); color: var(--accent-amber);
}

.profile-role.operator, .profile-role.user {
  background: rgba(16, 185, 129, 0.12); color: var(--accent-emerald);
}

.profile-avatar.supervisor { background: var(--gradient-rose); }
.profile-avatar.foreman { background: linear-gradient(135deg, var(--accent-amber), #ef4444); }
.profile-avatar.operator { background: var(--gradient-emerald); }

.sidebar-nav {
  flex: 1; padding: 16px 12px; overflow-y: auto;
}

.nav-section { margin-bottom: 24px; }

.nav-section-title {
  font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--text-muted);
  padding: 0 12px; margin-bottom: 8px; font-weight: 600;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.9rem; font-weight: 500;
  position: relative; user-select: none;
}

.nav-item:hover {
  background: var(--bg-glass-hover); color: var(--text-primary);
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.1); color: var(--accent-blue);
}

.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px;
  background: var(--gradient-blue);
  border-radius: var(--radius-full);
}

.nav-item.hidden-nav { display: none; }

.nav-item i { font-size: 1.1rem; width: 22px; text-align: center; }

.nav-badge {
  margin-left: auto;
  background: var(--accent-rose); color: white;
  font-size: 0.65rem; padding: 2px 7px;
  border-radius: var(--radius-full); font-weight: 600;
  animation: pulseBadge 2s ease-in-out infinite;
}

@keyframes pulseBadge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
}

.logout-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-glass);
  color: var(--text-secondary);
  font-family: inherit; font-size: 0.82rem; font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.logout-btn:hover {
  background: rgba(244, 63, 94, 0.08);
  border-color: rgba(244, 63, 94, 0.2);
  color: var(--accent-rose);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1; margin-left: 260px;
  display: flex; flex-direction: column;
}

/* ===== HEADER ===== */
.top-header {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  gap: 12px;
}

.header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }

.menu-toggle {
  display: none;
  background: none; border: none;
  color: var(--text-secondary);
  font-size: 1.3rem; cursor: pointer;
  padding: 8px; border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.menu-toggle:hover { background: var(--bg-glass-hover); color: var(--text-primary); }

.page-title {
  font-size: 1.15rem; font-weight: 700; letter-spacing: -0.3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.page-title span {
  color: var(--text-muted); font-weight: 400; font-size: 0.8rem; margin-left: 8px;
}

.header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.header-search { position: relative; }

.header-search input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 8px 16px 8px 36px;
  color: var(--text-primary);
  font-family: inherit; font-size: 0.85rem;
  width: 220px;
  transition: all var(--transition-fast); outline: none;
}

.header-search input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  width: 280px;
}

.header-search input::placeholder { color: var(--text-muted); }

.header-search i {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); font-size: 0.85rem;
}

.header-time {
  color: var(--text-muted); font-size: 0.78rem; font-weight: 500;
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
}

/* ===== PAGE CONTENT ===== */
.page-content { padding: 24px; flex: 1; }

.page-view { display: none; animation: fadeIn 0.3s ease; }
.page-view.active { display: block; }

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

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative; overflow: hidden;
  transition: all var(--transition-base); cursor: default;
}

.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card::after {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card.blue::after { background: var(--gradient-blue); }
.stat-card.emerald::after { background: var(--gradient-emerald); }
.stat-card.amber::after { background: var(--gradient-amber); }
.stat-card.rose::after { background: var(--gradient-rose); }

.stat-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}

.stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}

.stat-card.blue .stat-icon { background: rgba(59, 130, 246, 0.12); color: var(--accent-blue); }
.stat-card.emerald .stat-icon { background: rgba(16, 185, 129, 0.12); color: var(--accent-emerald); }
.stat-card.amber .stat-icon { background: rgba(245, 158, 11, 0.12); color: var(--accent-amber); }
.stat-card.rose .stat-icon { background: rgba(244, 63, 94, 0.12); color: var(--accent-rose); }

.stat-value {
  font-size: 1.8rem; font-weight: 800;
  letter-spacing: -1px; margin-bottom: 2px;
}

.stat-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }

/* ===== SECTION CARD ===== */
.section-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden; margin-bottom: 24px;
}

.section-header {
  padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap; gap: 10px;
}

.section-title {
  font-size: 0.95rem; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
}

.section-title i { color: var(--accent-blue); }

.section-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.82rem; font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  user-select: none; white-space: nowrap;
}

.btn-primary {
  background: var(--gradient-blue); color: white;
  box-shadow: var(--shadow-glow-blue);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 0 24px rgba(59, 130, 246, 0.3); }

.btn-success {
  background: var(--gradient-emerald); color: white;
  box-shadow: var(--shadow-glow-emerald);
}
.btn-success:hover { transform: translateY(-1px); box-shadow: 0 0 24px rgba(16, 185, 129, 0.3); }

.btn-danger { background: var(--accent-rose); color: white; }
.btn-danger:hover { transform: translateY(-1px); box-shadow: 0 0 24px rgba(244, 63, 94, 0.3); }

.btn-ghost {
  background: var(--bg-glass); color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.btn-ghost:hover {
  background: var(--bg-glass-hover); color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-sm { padding: 6px 12px; font-size: 0.78rem; }

.btn-icon {
  width: 34px; height: 34px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
}

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; }

thead th {
  background: rgba(255, 255, 255, 0.02);
  padding: 11px 14px;
  text-align: left; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-muted); font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap; cursor: pointer; user-select: none;
  transition: color var(--transition-fast);
}

thead th:hover { color: var(--text-secondary); }
thead th.sorted { color: var(--accent-blue); }

tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition-fast);
}

tbody tr:hover { background: var(--bg-glass-hover); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 11px 14px; font-size: 0.83rem;
  color: var(--text-secondary); white-space: nowrap;
}

.part-number {
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.78rem; color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.08);
  padding: 3px 8px; border-radius: var(--radius-sm);
}

.stock-status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--radius-full);
  font-size: 0.73rem; font-weight: 600;
}

.stock-status.ok { background: rgba(16, 185, 129, 0.12); color: var(--accent-emerald); }
.stock-status.low { background: rgba(245, 158, 11, 0.12); color: var(--accent-amber); }
.stock-status.critical { background: rgba(244, 63, 94, 0.12); color: var(--accent-rose); animation: pulseBadge 2s ease-in-out infinite; }
.stock-status.empty { background: rgba(100, 116, 139, 0.12); color: var(--text-muted); }

.stock-status::before {
  content: ''; width: 6px; height: 6px;
  border-radius: 50%; background: currentColor;
}

.category-tag {
  display: inline-flex; padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.73rem; font-weight: 500;
  background: rgba(139, 92, 246, 0.1); color: var(--accent-purple);
}

.action-btns { display: flex; gap: 4px; }
.action-btns .btn-icon { width: 30px; height: 30px; font-size: 0.8rem; }

/* ===== PAGINATION ===== */
.table-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap; gap: 10px;
}

.table-info { font-size: 0.78rem; color: var(--text-muted); }

.pagination { display: flex; align-items: center; gap: 4px; }

.pagination button {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-family: inherit; font-size: 0.8rem;
  transition: all var(--transition-fast);
}

.pagination button:hover:not(:disabled) {
  background: var(--bg-glass-hover); border-color: var(--border-hover);
}

.pagination button.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue); color: white;
}

.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--bg-modal);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 600px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

.modal.wide { max-width: 900px; }

.modal-header {
  padding: 20px 22px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 1.05rem; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
}

.modal-title i { color: var(--accent-blue); }

.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: none; background: var(--bg-glass);
  color: var(--text-secondary); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition-fast);
}

.modal-close:hover { background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); }

.modal-body { padding: 22px; overflow-y: auto; flex: 1; }

.modal-footer {
  padding: 14px 22px;
  display: flex; align-items: center; justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border-color);
}

/* ===== FORM ===== */
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full-width { grid-column: 1 / -1; }

.form-group label {
  font-size: 0.8rem; font-weight: 600; color: var(--text-secondary);
}

.form-group label .required { color: var(--accent-rose); }

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: inherit; font-size: 0.85rem;
  outline: none;
  transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group textarea { resize: vertical; min-height: 70px; }

.form-group select {
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-group select option {
  background-color: #111827 !important;
  color: #f1f5f9 !important;
  padding: 10px;
}

/* ===== UPLOAD AREA ===== */
.upload-area {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center; cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
}

.upload-area:hover, .upload-area.dragover {
  border-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.04);
}

.upload-area.dragover { transform: scale(1.01); }

.upload-icon {
  width: 56px; height: 56px;
  background: rgba(59, 130, 246, 0.08);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px; font-size: 1.4rem; color: var(--accent-blue);
}

.upload-area h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 4px; }
.upload-area p { font-size: 0.8rem; color: var(--text-muted); }

.upload-area input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}

.upload-preview { display: none; margin-top: 20px; }
.upload-preview.active { display: block; }

.upload-file-info {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.15);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.upload-file-info i { font-size: 1.4rem; color: var(--accent-emerald); }
.upload-file-info .file-details h4 { font-size: 0.83rem; font-weight: 600; }
.upload-file-info .file-details span { font-size: 0.73rem; color: var(--text-muted); }

.preview-table-wrapper {
  margin-top: 16px; max-height: 260px; overflow: auto;
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
}

.preview-table-wrapper table { font-size: 0.78rem; }
.preview-table-wrapper thead th {
  position: sticky; top: 0; background: var(--bg-secondary); z-index: 1;
}

/* ===== TRANSACTION BADGE ===== */
.txn-type {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--radius-full);
  font-size: 0.73rem; font-weight: 600;
}

.txn-type.in { background: rgba(16, 185, 129, 0.12); color: var(--accent-emerald); }
.txn-type.out { background: rgba(244, 63, 94, 0.12); color: var(--accent-rose); }
.txn-type.opname { background: rgba(59, 130, 246, 0.12); color: var(--accent-blue); }
.txn-type.adjust { background: rgba(245, 158, 11, 0.12); color: var(--accent-amber); }

/* ===== FILTER BAR ===== */
.filter-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.filter-bar select,
.filter-bar input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  color: var(--text-primary);
  font-family: inherit; font-size: 0.82rem;
  outline: none;
  transition: all var(--transition-fast);
}

.filter-bar select:focus,
.filter-bar input:focus { border-color: var(--accent-blue); }

.filter-bar select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px; cursor: pointer;
  color-scheme: dark;
}

.filter-bar select option {
  background-color: #111827 !important;
  color: #f1f5f9 !important;
  padding: 8px 12px;
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed; top: 20px; right: 20px;
  z-index: 2000;
  display: flex; flex-direction: column; gap: 10px;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.4s ease;
  min-width: 280px; max-width: 380px;
}

.toast.removing { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn { from { opacity: 0; transform: translateX(60px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(60px); } }

.toast-icon {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem; flex-shrink: 0;
}

.toast.success .toast-icon { background: rgba(16, 185, 129, 0.12); color: var(--accent-emerald); }
.toast.error .toast-icon { background: rgba(244, 63, 94, 0.12); color: var(--accent-rose); }
.toast.warning .toast-icon { background: rgba(245, 158, 11, 0.12); color: var(--accent-amber); }
.toast.info .toast-icon { background: rgba(59, 130, 246, 0.12); color: var(--accent-blue); }

.toast-content h4 { font-size: 0.83rem; font-weight: 600; margin-bottom: 1px; }
.toast-content p { font-size: 0.76rem; color: var(--text-muted); }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 50px 20px; }
.empty-state i { font-size: 2.5rem; color: var(--text-muted); margin-bottom: 14px; opacity: 0.5; }
.empty-state h3 { font-size: 1rem; font-weight: 600; margin-bottom: 6px; }
.empty-state p { font-size: 0.83rem; color: var(--text-muted); max-width: 320px; margin: 0 auto; }

/* ===== CHARTS ===== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px; margin-bottom: 24px;
}

.chart-card {
  background: var(--bg-card); backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 20px;
}

.chart-card h3 {
  font-size: 0.9rem; font-weight: 700; margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
}

.chart-card h3 i { color: var(--accent-blue); }

.chart-area {
  height: 200px; display: flex; align-items: flex-end;
  gap: 6px; padding-top: 10px;
}

.chart-bar-group {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 6px;
}

.chart-bar {
  width: 100%; max-width: 40px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: all var(--transition-base);
  min-height: 4px; position: relative;
}

.chart-bar:hover { opacity: 0.8; transform: scaleY(1.02); transform-origin: bottom; }

.chart-bar-label {
  font-size: 0.6rem; color: var(--text-muted);
  text-align: center; white-space: nowrap;
}

.donut-container {
  display: flex; align-items: center; justify-content: center;
  gap: 24px; padding: 10px 0; flex-wrap: wrap;
}

.donut-chart { width: 140px; height: 140px; position: relative; }
.donut-chart svg { width: 100%; height: 100%; transform: rotate(-90deg); }

.donut-center {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%); text-align: center;
}

.donut-center .number { font-size: 1.6rem; font-weight: 800; letter-spacing: -1px; }
.donut-center .label { font-size: 0.65rem; color: var(--text-muted); }

.donut-legend { display: flex; flex-direction: column; gap: 8px; }

.legend-item { display: flex; align-items: center; gap: 10px; font-size: 0.8rem; }

.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.legend-value {
  color: var(--text-muted); margin-left: auto;
  font-weight: 600; padding-left: 12px;
}

/* ===== ALERT LIST ===== */
.alert-list { display: flex; flex-direction: column; gap: 8px; }

.alert-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--bg-glass);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--accent-amber);
  transition: all var(--transition-fast);
  flex-wrap: wrap;
}

.alert-item.critical { border-left-color: var(--accent-rose); }
.alert-item:hover { background: var(--bg-glass-hover); }

.alert-item-icon {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: rgba(245, 158, 11, 0.1); color: var(--accent-amber);
  font-size: 0.85rem; flex-shrink: 0;
}

.alert-item.critical .alert-item-icon {
  background: rgba(244, 63, 94, 0.1); color: var(--accent-rose);
}

.alert-item-info { flex: 1; min-width: 120px; }
.alert-item-info h4 { font-size: 0.83rem; font-weight: 600; }
.alert-item-info p { font-size: 0.73rem; color: var(--text-muted); }

.alert-item-stock { text-align: right; }
.alert-item-stock .current { font-size: 1rem; font-weight: 700; }
.alert-item-stock .min { font-size: 0.68rem; color: var(--text-muted); }

/* ===== CONFIRM DIALOG ===== */
.confirm-dialog { max-width: 420px; }

.confirm-dialog .modal-body { text-align: center; padding: 28px 22px; }

.confirm-dialog .confirm-icon {
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px; font-size: 1.4rem;
  background: rgba(244, 63, 94, 0.1); color: var(--accent-rose);
}

.confirm-dialog .confirm-text {
  font-size: 0.88rem; color: var(--text-secondary); margin-top: 6px;
}

/* ===== TXN DIRECTION ===== */
.txn-direction { display: flex; gap: 10px; margin-bottom: 16px; }

.txn-dir-btn {
  flex: 1; padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-glass);
  color: var(--text-secondary);
  cursor: pointer; text-align: center;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.txn-dir-btn:hover { border-color: var(--border-hover); }

.txn-dir-btn.active.in-btn {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.08); color: var(--accent-emerald);
}

.txn-dir-btn.active.out-btn {
  border-color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.08); color: var(--accent-rose);
}

.txn-dir-btn i { display: block; font-size: 1.2rem; margin-bottom: 4px; }
.txn-dir-btn span { font-size: 0.8rem; font-weight: 600; }

/* ===== USER MANAGEMENT ===== */
.user-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  background: var(--bg-glass);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: all var(--transition-fast);
}

.user-card:hover { border-color: var(--border-hover); background: var(--bg-glass-hover); }

.user-card-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: white; font-size: 0.9rem;
  flex-shrink: 0;
}

.user-card-info { flex: 1; min-width: 0; }
.user-card-info h4 {
  font-size: 0.88rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-card-info p { font-size: 0.76rem; color: var(--text-muted); }

.user-card-actions { display: flex; gap: 6px; flex-shrink: 0; }

.user-list { display: flex; flex-direction: column; gap: 10px; }

/* ===== SIDEBAR OVERLAY (MOBILE) ===== */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6); z-index: 99;
}

.sidebar-overlay.active { display: block; }

/* ===== RESPONSIVE & MOBILE ENHANCEMENTS ===== */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; width: 100%; }
  .menu-toggle { display: flex; }
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  html { font-size: 13.5px; }

  .top-header { padding: 12px 16px; gap: 8px; }
  .page-content { padding: 14px; }

  .header-search { display: none; }
  .header-time { display: none; }
  .page-title { font-size: 1.05rem; }
  .page-title span { display: none; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.4rem; }
  .stat-header { margin-bottom: 8px; }

  .section-card { border-radius: var(--radius-md); margin-bottom: 16px; }
  .section-header { padding: 12px 14px; flex-direction: column; align-items: flex-start; gap: 10px; }
  .section-actions { width: 100%; display: flex; gap: 8px; }
  .section-actions .btn { flex: 1; justify-content: center; padding: 10px 12px; }

  .filter-bar { padding: 10px 14px; flex-direction: column; gap: 8px; }
  .filter-bar select,
  .filter-bar input { width: 100%; min-height: 40px; }

  .table-wrapper {
    margin: 0;
    border-radius: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: inset 0 0 8px rgba(0,0,0,0.2);
  }

  table { min-width: 650px; }
  thead th { padding: 10px 12px; font-size: 0.72rem; }
  tbody td { padding: 10px 12px; font-size: 0.82rem; }

  .action-btns .btn-icon { width: 34px; height: 34px; font-size: 0.9rem; }

  .table-footer { padding: 12px 14px; flex-direction: column; gap: 10px; align-items: center; }
  .pagination button { width: 36px; height: 36px; font-size: 0.88rem; }

  .form-grid { grid-template-columns: 1fr; gap: 12px; }

  .modal-overlay { padding: 10px; align-items: flex-end; }
  .modal {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 88vh;
    width: 100%;
  }
  .modal-header { padding: 16px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; }

  .charts-grid { grid-template-columns: 1fr; gap: 12px; }
  .chart-area { height: 170px; }

  .toast-container { left: 12px; right: 12px; top: 12px; }
  .toast { min-width: auto; width: 100%; }

  .user-card { padding: 12px; flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  
  .btn { padding: 10px 14px; min-height: 40px; }
  
  .login-card { padding: 24px 20px; border-radius: var(--radius-lg); }
  .login-logo h2 { font-size: 1.4rem; }
  
  .txn-direction { flex-direction: column; gap: 8px; }
  .txn-dir-btn { padding: 10px; }

  .alert-item { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; }
  .alert-item-stock { text-align: left; width: 100%; display: flex; justify-content: space-between; align-items: center; }
  
  .donut-container { gap: 16px; }
  .donut-chart { width: 120px; height: 120px; }
}

.light-theme {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-glass: rgba(0, 0, 0, 0.03);
  --bg-glass-hover: rgba(0, 0, 0, 0.06);
  --bg-input: rgba(0, 0, 0, 0.05);
  --bg-modal: rgba(255, 255, 255, 0.98);
  --accent-blue: #2563eb;
  --accent-blue-glow: rgba(37, 99, 235, 0.15);
  --accent-purple: #7c3aed;
  --accent-purple-glow: rgba(124, 58, 237, 0.15);
  --accent-emerald: #059669;
  --accent-emerald-glow: rgba(5, 150, 105, 0.15);
  --accent-amber: #d97706;
  --accent-amber-glow: rgba(217, 119, 6, 0.15);
  --accent-rose: #e11d48;
  --accent-rose-glow: rgba(225, 29, 72, 0.15);
  --accent-cyan: #0891b2;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
  --border-color: rgba(0, 0, 0, 0.12);
  --border-hover: rgba(0, 0, 0, 0.2);
  --gradient-blue: linear-gradient(135deg, #2563eb, #7c3aed);
  --gradient-emerald: linear-gradient(135deg, #059669, #0891b2);
  --gradient-amber: linear-gradient(135deg, #d97706, #ea580c);
  --gradient-rose: linear-gradient(135deg, #e11d48, #db2777);
  --gradient-bg: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-glow-blue: 0 0 20px rgba(37, 99, 235, 0.08);
  --shadow-glow-emerald: 0 0 20px rgba(5, 150, 105, 0.08);
}
