* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --sidebar-bg: #1e293b;
  --sidebar-hover: #3b82f6;
  --main-bg: #f3f4f6;
  --card-bg: #ffffff;
  --text-dark: #1e293b;
  --text-muted: #64748b;
  --border-color: #334155;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--main-bg);
  color: var(--text-dark);
}

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 250px;
  height: 100vh;
  background: var(--sidebar-bg);
  color: #fff;
  padding: 1.5rem;
  overflow-y: auto;
}

.brand {
  font-size: 1.5rem;
  font-weight: bold;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.menu a {
  display: block;
  padding: 0.75rem 1rem;
  color: #cbd5e1;
  text-decoration: none;
  border-radius: 0.5rem;
  transition: all 0.3s;
}

.menu a:hover,
.menu a.active {
  background: var(--sidebar-hover);
  color: #fff;
}

.menu a.logout {
  margin-top: 2rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}

/* Main Content */
.main {
  margin-left: 250px;
  padding: 2rem;
  min-height: 100vh;
}

.header {
  background: var(--card-bg);
  padding: 1.5rem 2rem;
  border-radius: 0.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.header h2 {
  color: var(--text-dark);
  font-size: 1.5rem;
}

/* Cards Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card h3 {
  color: var(--text-dark);
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.card p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.data-table th,
.data-table td {
  padding: 1rem;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
}

.data-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-dark);
}

.data-table tr:hover {
  background: #f8fafc;
}

/* Forms */
input, select, textarea {
  width: 100%;
  padding: 0.75rem;
  margin: 0.5rem 0;
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
  font-size: 0.9rem;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--sidebar-hover);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Buttons */
.btn {
  display: inline-block;
  background: var(--sidebar-hover);
  color: #fff;
  padding: 0.6rem 1.25rem;
  text-decoration: none;
  border-radius: 0.375rem;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.3s;
}

.btn:hover {
  background: #2563eb;
}

.btn.secondary {
  background: #64748b;
}

.btn.secondary:hover {
  background: #475569;
}

.btn.danger {
  background: #ef4444;
}

.btn.danger:hover {
  background: #dc2626;
}

/* Module Header */
.module-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.module-header h2 {
  color: var(--text-dark);
}

/* Login Page */
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-page .card {
  max-width: 400px;
  width: 100%;
  padding: 2rem;
}

.login-page h2 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--text-dark);
}

.login-page button {
  width: 100%;
  margin-top: 1rem;
}

/* Alerts */
.error {
  background: #fee2e2;
  color: #dc2626;
  padding: 0.75rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
  border-left: 4px solid #dc2626;
}

.success {
  background: #d1fae5;
  color: #059669;
  padding: 0.75rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
  border-left: 4px solid #059669;
}

/* Utility */
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }
  
  .main {
    margin-left: 0;
  }
  
  .grid {
    grid-template-columns: 1fr;
  }
}

/* ========== MODAL STYLES ========== */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0; top: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
}
.modal-content {
  background: #fff;
  padding: 1.5rem;
  border-radius: 0.5rem;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  animation: slideDown 0.3s ease;
}
@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e2e8f0;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #64748b;
}
.modal-close:hover { color: #1e293b; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
}

/* ========== TOAST NOTIFICATIONS ========== */
.toast {
  display: none;
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 1rem 1.5rem;
  border-radius: 0.5rem;
  color: #fff;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 2000;
  animation: slideIn 0.3s ease;
}
.toast.success { background: #059669; }
.toast.error { background: #dc2626; }
@keyframes slideIn {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsive modal */
@media (max-width: 600px) {
  .modal-content { width: 95%; padding: 1rem; }
  .toast { right: 1rem; left: 1rem; bottom: 1rem; }
}

/* ========== MOBILE RESPONSIVE OVERRIDES ========== */
@media (max-width: 768px) {
  /* Sidebar becomes off-canvas */
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    box-shadow: 2px 0 10px rgba(0,0,0,0.3);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  
  /* Remove left margin, full-width content */
  .main {
    margin-left: 0 !important;
    padding: 1rem;
  }
  
  /* Stack cards vertically */
  .grid {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }
  
  /* Horizontal scroll for tables */
  .data-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Modal adjustments */
  .modal-content {
    width: 95% !important;
    max-height: 85vh;
    margin: 1rem auto;
  }
  
  /* Module header spacing */
  .module-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  
  /* Show mobile toggle */
  .mobile-toggle {
    display: block !important;
  }
  
  /* Overlay when sidebar is open */
  body.sidebar-open::after {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
  }
}

/* Desktop: hide mobile toggle */
.mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  margin-left: auto;
}



