:root {
  --font-base: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
  --color-bg: #f4f6fb;
  --color-surface: #ffffff;
  --color-muted: #4b5563;
  --color-strong: #0f172a;
  --color-primary: #2563eb;
  --color-primary-alt: #1d4ed8;
  --color-success: #10b981;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;
  --color-border: #e5e7eb;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-2xl: 24px;
  --shadow-sm: 0 6px 18px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 46px rgba(37, 99, 235, 0.16);
  --shadow-executive-lg: 0 24px 58px rgba(37, 99, 235, 0.2);
  --gradient-premium: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

* {
  box-sizing: border-box;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.hero-actions.hero-cta {
  align-items: stretch;
}

.btn-cta {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  min-width: 190px;
  padding: 0.85rem 1.2rem;
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-cta:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-cta .cta-sub {
  font-size: 0.85rem;
  opacity: 0.9;
}

.btn-cta.ghost {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  backdrop-filter: blur(6px);
}

/* Page Header Hero */
.page-header-hero {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border-radius: var(--radius-2xl);
  padding: 2rem 2.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.page-header-hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -30%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
  animation: spin 30s linear infinite;
}

.page-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.75rem;
  font-weight: 800;
  color: white;
  margin: 0 0 0.5rem;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.page-title i {
  color: rgba(255, 255, 255, 0.95);
}

.page-subtitle {
  color: rgba(255, 255, 255, 0.9);
  margin: 0;
}

.btn-hero-cta {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-hero-cta:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}

/* Labs Grid */
.labs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.lab-card {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: all 0.2s ease;
}

.lab-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.lab-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lab-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  display: grid;
  place-items: center;
  color: white;
  font-size: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.lab-status {
  display: flex;
  align-items: center;
}

.badge-status {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.badge-status.active {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}

.badge-status.inactive {
  background: rgba(107, 114, 128, 0.12);
  color: #4b5563;
}

.lab-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-strong);
  margin: 0;
}

.lab-code {
  font-size: 0.9rem;
  color: var(--color-muted);
  font-weight: 600;
}

.lab-description {
  color: var(--color-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lab-meta {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.lab-meta-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.lab-meta-item i {
  color: var(--color-primary);
  font-size: 1rem;
}

.lab-stats {
  display: flex;
  gap: 1rem;
}

.lab-stat {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--color-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.lab-stat i {
  color: var(--color-primary);
}

.lab-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: auto;
}

.lab-actions .btn {
  flex: 1;
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  gap: 2rem;
}

.spinner-container {
  position: relative;
  width: 100px;
  height: 100px;
}

.spinner-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 4px solid transparent;
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1.5s linear infinite;
}

.spinner-ring:nth-child(2) {
  border-top-color: var(--color-success);
  animation-delay: -0.5s;
}

.spinner-ring:nth-child(3) {
  border-top-color: var(--color-warning);
  animation-delay: -1s;
}

.spinner-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  color: var(--color-primary);
  animation: pulse 1.5s ease-in-out infinite;
}

.loading-text {
  color: var(--color-muted);
  font-size: 1.1rem;
  font-weight: 500;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@media (max-width: 768px) {
  .labs-grid {
    grid-template-columns: 1fr;
  }

  .page-header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .lab-actions {
    flex-direction: column;
  }

  .lab-actions .btn {
    width: 100%;
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-base);
  background: var(--color-bg);
  color: var(--color-strong);
  line-height: 1.6;
  direction: rtl;
}

a {
  text-decoration: none;
  color: inherit;
}

img {
  max-width: 100%;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--color-bg);
}

.sidebar {
  width: 250px;
  background: #0b1533;
  color: #e5e7eb;
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  align-self: flex-start;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0 0.5rem;
}

.brand {
  font-weight: 800;
  font-size: 1.1rem;
}

.brand-sub {
  font-size: 0.85rem;
  color: #cbd5e1;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0.75rem 0.5rem;
}

.sidebar-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  padding: 0.5rem 0.8rem 0.25rem;
  margin-top: 0.25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  color: #e5e7eb;
  transition: all 0.2s ease;
  font-weight: 600;
}

.sidebar-link i {
  font-size: 1.1rem;
}

.sidebar-link:hover,
.sidebar-link.active {
  background: rgba(37, 99, 235, 0.16);
  color: #fff;
  transform: translateX(-2px);
}

.sidebar-footer {
  margin-top: auto;
  padding: 0.75rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.8rem;
  color: #cbd5e1;
}

.badge-soft {
  display: inline-flex;
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: radial-gradient(circle at 20% 20%, rgba(37, 99, 235, 0.06), transparent 30%),
    radial-gradient(circle at 80% 0%, rgba(16, 185, 129, 0.08), transparent 28%),
    var(--color-bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(120deg, rgba(37, 99, 235, 0.12), rgba(37, 99, 235, 0.04)), var(--color-surface);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
  color: var(--color-primary);
}

.topbar-title-text {
  font-size: 1rem;
}

.topbar-subtitle {
  font-size: 0.85rem;
  color: var(--color-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.9rem;
  border-radius: 14px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
}

.user-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.user-name {
  font-weight: 700;
}

.user-role {
  font-size: 0.85rem;
  color: var(--color-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
}

.user-role:hover {
  color: var(--color-primary);
}

.user-role i {
  font-size: 0.9rem;
}

.ghost-btn {
  border: none;
  background: transparent;
  color: var(--color-primary);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
}

.content-shell {
  padding: 1.5rem;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
}

.card-surface,
.card,
.surface-card {
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.12), rgba(255, 255, 255, 0.92));
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(37, 99, 235, 0.22);
  position: relative;
  overflow: hidden;
}

.card::before,
.card-surface::before,
.surface-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(37, 99, 235, 0.16), transparent 32%),
    radial-gradient(circle at 80% 0%, rgba(16, 185, 129, 0.12), transparent 30%);
  opacity: 0.9;
  pointer-events: none;
}

.card > *,
.card-surface > *,
.surface-card > * {
  position: relative;
  z-index: 1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-weight: 700;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }

.btn-primary {
  background: var(--gradient-premium);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: #0f172a;
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.form-label {
  font-weight: 700;
  color: var(--color-strong);
  margin-bottom: 0.3rem;
}

.form-control,
.form-select {
  border-radius: 12px;
  border: 1.5px solid var(--color-border);
  background: #f8fafc;
  padding: 0.65rem 0.9rem;
  font-size: 0.95rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.16);
}

.table-modern {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-modern thead {
  background: var(--gradient-premium);
  color: #fff;
}

.table-modern th,
.table-modern td {
  padding: 0.85rem 0.75rem;
  text-align: right;
  border-bottom: 1px solid var(--color-border);
}

.table-modern tbody tr:hover {
  background: #f8fafc;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: rgba(79, 70, 229, 0.1);
  color: var(--color-primary);
  font-weight: 700;
  font-size: 0.85rem;
}

/* Auth + account management */
.auth-page {
  min-height: 100vh;
  background: radial-gradient(circle at 20% 20%, rgba(79, 70, 229, 0.08), transparent 35%),
    radial-gradient(circle at 80% 0%, rgba(16, 185, 129, 0.08), transparent 32%),
    var(--color-bg);
}

.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-card {
  width: min(960px, 100%);
  background: var(--color-surface);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-executive-lg);
  padding: 2.25rem;
  border: 1px solid var(--color-border);
}

.auth-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--gradient-premium);
  color: #fff;
  margin: 0 auto 0.75rem;
  box-shadow: var(--shadow-lg);
  font-size: 1.6rem;
}

.auth-title {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 800;
}

.auth-subtitle {
  margin: 0.35rem 0 0;
  color: var(--color-muted);
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.auth-panel {
  background: #f8fafc;
  border-radius: var(--radius-xl, 18px);
  padding: 1.25rem;
  border: 1px solid var(--color-border);
}

.auth-links {
  display: grid;
  gap: 0.75rem;
}

.auth-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  color: var(--color-primary);
  font-weight: 700;
  transition: all 0.2s ease;
}

.auth-link:hover {
  background: rgba(79, 70, 229, 0.08);
  color: #4338ca;
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--color-muted);
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--color-border);
}

.form-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.account-management-container {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.account-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--color-border);
}

.account-main-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 2rem;
  font-weight: 800;
  margin: 0 0 0.35rem;
}

.account-main-title i {
  color: var(--color-primary);
}

.account-subtitle {
  margin: 0;
  color: var(--color-muted);
}

.account-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
}

.account-sidebar {
  background: var(--color-surface);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  position: sticky;
  top: 1.5rem;
  height: fit-content;
}

.account-content {
  background: var(--color-surface);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}

.manage-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  margin-bottom: 0.4rem;
  transition: all 0.2s ease;
  color: var(--color-muted);
  font-weight: 600;
}

.manage-nav .nav-link:hover {
  background: rgba(79, 70, 229, 0.08);
  color: var(--color-primary);
  transform: translateX(-2px);
}

.manage-nav .nav-link.active {
  background: var(--gradient-premium);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.manage-nav .nav-link i {
  font-size: 1.2rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.surface-card {
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.12), rgba(255, 255, 255, 0.92));
  border-radius: 14px;
  padding: 1rem;
  border: 1px solid rgba(37, 99, 235, 0.22);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.surface-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(37, 99, 235, 0.16), transparent 32%),
    radial-gradient(circle at 80% 0%, rgba(16, 185, 129, 0.12), transparent 30%);
  opacity: 0.9;
  pointer-events: none;
}

.surface-card > * {
  position: relative;
  z-index: 1;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.12);
  color: #0f766e;
  font-weight: 700;
}

.table-compact {
  width: 100%;
  border-collapse: collapse;
}

.table-compact th,
.table-compact td {
  padding: 0.65rem;
  border-bottom: 1px solid var(--color-border);
  text-align: right;
}

@media (max-width: 992px) {
  .auth-card {
    padding: 1.5rem;
  }

  .account-shell {
    grid-template-columns: 1fr;
  }

  .account-sidebar {
    position: static;
  }
}

@media (max-width: 992px) {
  .sidebar {
    width: 220px;
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(0);
  }
  .main-area {
    margin-right: 220px;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 768px) {
  /* Hide the checkbox */
  .mobile-menu-checkbox {
    display: none;
  }
  
  .sidebar {
    position: fixed;
    transform: translateX(-110%);
    transition: transform 0.3s ease;
    z-index: 1001;
  }
  
  /* Show sidebar when checkbox is checked */
  .mobile-menu-checkbox:checked ~ .sidebar {
    transform: translateX(0);
  }
  
  .main-area {
    margin-right: 0;
  }
  
  .content-shell {
    padding: 1rem;
  }
  
  .mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--color-strong);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    margin-left: 0.5rem;
  }
  
  .mobile-menu-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
  }
  
  .mobile-menu-toggle i {
    font-size: 1.5rem;
  }
  
  .mobile-menu-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
  }
  
  .mobile-menu-close:hover {
    background: rgba(255, 255, 255, 0.2);
  }
  
  .mobile-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
  }
  
  /* Show overlay when checkbox is checked */
  .mobile-menu-checkbox:checked ~ .mobile-menu-overlay {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }
  
  .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  
  .topbar-title {
    flex: 1;
  }
  
  .topbar-subtitle {
    display: none;
  }
  
  .user-pill {
    flex-wrap: wrap;
  }
  
  .user-meta {
    display: none;
  }
  
  /* Close menu when clicking a link */
  .sidebar-link {
    position: relative;
  }
  
  .sidebar-link::after {
    content: '';
    position: absolute;
    inset: 0;
  }
}

/* Hide hamburger on desktop */
@media (min-width: 769px) {
  .mobile-menu-checkbox {
    display: none;
  }
  
  .mobile-menu-toggle {
    display: none;
  }
  
  .mobile-menu-close {
    display: none;
  }
  
  .mobile-menu-overlay {
    display: none !important;
  }
}
