:root {
  --primary: #0d6efd;
  --primary-dark: #0b5ed7;
  --primary-light: rgba(13, 110, 253, 0.1);
  --page: #f6f7fb;
  --card-bg: #ffffff;
  --sidebar-bg: #ffffff;
  --sidebar-width: 260px;
  --header-height: 64px;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border-color: #e5e7eb;
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.25s ease;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 12px 30px rgba(16, 24, 40, 0.08);
}

/* Reset & base */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  min-height: 100svh;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--text-primary);
}

/* ========== LOGIN CARD ========== */
body:has(#loginCard[style*="block"]),
body:not(:has(.app-container[style*="flex"])) {
  display: grid;
  place-items: center;
}

.card {
  width: 100%;
  max-width: 420px;
  padding: 32px 28px 36px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: fade-in 0.45s ease both;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.logo {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--primary);
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* Form */
.field { position: relative; margin-bottom: 14px; }

.field input {
  width: 100%;
  padding: 14px 44px 14px 14px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: #f9fafb;
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.field input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px var(--primary-light);
}

.toggle-password {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 8px;
}

.toggle-password:hover { color: var(--primary); }

/* Button */
.btn {
  width: 100%;
  padding: 14px;
  margin-top: 6px;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--transition), transform 0.05s ease;
}

.btn:hover,
.btn:focus-visible { background: var(--primary-dark); }
.btn:active { transform: translateY(1px); }

/* Messages */
#message {
  margin-top: 14px;
  font-size: 0.93rem;
  font-weight: 500;
  min-height: 1.2em;
}

.error { color: #d52731; }
.success { color: #269f53; }

/* ========== APP CONTAINER ========== */
.app-container {
  display: flex;
  min-height: 100svh;
  width: 100%;
}

/* ========== SIDEBAR ========== */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateX(-100%);
}

.sidebar.open {
  transform: translateX(0);
  box-shadow: var(--shadow-lg);
}

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.1rem;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.brand-text {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.sidebar-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: none;
  background: #f3f4f6;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.sidebar-close:hover {
  background: #e5e7eb;
  color: var(--text-primary);
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-list {
  list-style: none;
}

.nav-item {
  margin-bottom: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-link i {
  width: 20px;
  font-size: 1.1rem;
  text-align: center;
}

.nav-link:hover {
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
  color: #6366f1;
  transform: translateX(4px);
}

.nav-link.active {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.nav-link.active i {
  color: #fff;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: #fef2f2;
  color: #dc2626;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition);
}

.logout-btn:hover {
  background: #fee2e2;
}

.logout-btn:active {
  transform: translateY(1px);
}

.logout-btn i {
  font-size: 1rem;
}

/* Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ========== MAIN CONTENT ========== */
.main-content {
  flex: 1;
  margin-left: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.menu-toggle {
  position: fixed;
  top: 20px;
  left: 20px;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border: none;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 1.3rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
}

.menu-toggle:hover {
  background: #fff;
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.3);
  color: #6366f1;
}

.menu-toggle:active {
  transform: scale(0.95);
}


.content-area {
  flex: 1;
  padding: 24px;
  padding-top: 16px;
}

.welcome-message {
  background: #fff;
  padding: 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.welcome-message h2 {
  color: var(--text-primary);
  margin-bottom: 8px;
}

.welcome-message p {
  color: var(--text-secondary);
}

@media (max-width: 768px) {
  .menu-toggle {
    top: 16px;
    left: 16px;
    width: 46px;
    height: 46px;
    font-size: 1.2rem;
  }
  
  .content-area {
    padding: 16px;
  }
}
@media (max-width: 480px) {
  .card {
    margin: 16px;
    padding: 24px 20px;
  }
  
  .sidebar {
    width: 100%;
  }
  
  .brand-text {
    font-size: 1rem;
  }
}



/* External Link Icon */
.external-link {
  position: relative;
}

.external-icon {
  font-size: 0.7rem !important;
  margin-left: auto;
  opacity: 0.5;
}

.external-link:hover .external-icon {
  opacity: 1;
}


/* ========== 404 PAGE ========== */
.page-404 {
  position: fixed;
  inset: 0;
  min-height: 100vh;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite;
  z-index: 9999;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.error-404-container {
  text-align: center;
  max-width: 480px;
  width: 100%;
  padding: 48px 40px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  box-shadow: 
    0 25px 50px -12px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.1);
  animation: floatIn 0.6s ease-out;
}

@keyframes floatIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.error-404-icon {
  width: 120px;
  height: 120px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 28px;
  box-shadow: 
    0 10px 30px rgba(251, 191, 36, 0.3),
    inset 0 -4px 8px rgba(0, 0, 0, 0.05);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.error-404-icon i {
  font-size: 3.5rem;
  color: #d97706;
}

.error-404-code {
  font-size: 6rem;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  letter-spacing: -4px;
}

.error-404-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.error-404-message {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 12px;
  line-height: 1.7;
  padding: 0 10px;
}

.error-404-contact {
  color: #6366f1;
  font-size: 0.95rem;
  margin-bottom: 28px;
  font-weight: 500;
  padding: 12px 20px;
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
  border-radius: 12px;
  display: inline-block;
}

.error-404-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 32px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 4px 15px rgba(99, 102, 241, 0.4),
    0 0 0 0 rgba(99, 102, 241, 0.4);
  text-decoration: none;
}

.error-404-btn:hover {
  transform: translateY(-3px);
  box-shadow: 
    0 8px 25px rgba(99, 102, 241, 0.5),
    0 0 0 4px rgba(99, 102, 241, 0.15);
}

.error-404-btn:active {
  transform: translateY(-1px);
}

.error-404-btn i {
  transition: transform 0.3s ease;
}

.error-404-btn:hover i {
  transform: translateX(-4px);
}

/* Logout button for 404 page */
.error-404-logout {
  display: block;
  margin-top: 16px;
  padding: 12px 24px;
  background: transparent;
  color: var(--text-muted);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
}

.error-404-logout:hover {
  border-color: #dc2626;
  color: #dc2626;
  background: #fef2f2;
}

@media (max-width: 480px) {
  .error-404-container {
    padding: 36px 24px;
    margin: 16px;
  }
  
  .error-404-code {
    font-size: 4.5rem;
    letter-spacing: -2px;
  }
  
  .error-404-icon {
    width: 100px;
    height: 100px;
  }
  
  .error-404-icon i {
    font-size: 2.8rem;
  }
  
  .error-404-title {
    font-size: 1.3rem;
  }
  
  .error-404-btn {
    width: 100%;
    justify-content: center;
  }
  
  .error-404-logout {
    width: 100%;
  }
}