:root {
  --brand: #ff5722;
  --brand-dark: #e64a19;
  --dark: #1c2333;
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 72px;
  --topbar-height: 60px;
}

body {
  background-color: #f4f6f9;
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
  margin: 0;
}

/* ============================================================
   App shell layout: fixed left sidebar + main content area
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------------- Sidebar ---------------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--dark);
  color: #fff;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.2s ease, transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  color: #fff;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
  flex-shrink: 0;
}
.sidebar-brand img {
  height: 32px;
  width: 32px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  padding: 2px;
}
.sidebar-brand .brand-text {
  font-weight: 700;
  font-size: 1.05rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  padding: 12px 10px 24px;
  flex: 1;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,0.75);
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 2px;
  font-size: 0.92rem;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-nav .nav-link i {
  font-size: 1.05rem;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}
.sidebar-nav .nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.sidebar-nav .nav-link.active {
  background: var(--brand);
  color: #fff;
}

.nav-section-label {
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.35);
  padding: 16px 12px 6px;
  white-space: nowrap;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1030;
}

/* ---------------- Main content area ---------------- */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease;
}

.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e7e9ee;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.toggle-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--dark);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
}
.toggle-btn:hover {
  background: #f0f1f4;
}

.topbar-title {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--dark);
  flex: 1;
}

.topbar-user {
  white-space: nowrap;
}
.topbar-user .dropdown-toggle {
  color: var(--dark);
  text-decoration: none;
  font-size: 0.95rem;
}

.content-area {
  flex: 1;
}

/* ============================================================
   Desktop: collapse to a slim icon-only rail
   ============================================================ */
@media (min-width: 992px) {
  body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
  }
  body.sidebar-collapsed .sidebar .brand-text,
  body.sidebar-collapsed .sidebar .nav-link span,
  body.sidebar-collapsed .sidebar .nav-section-label {
    display: none;
  }
  body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 18px 8px;
  }
  body.sidebar-collapsed .sidebar-nav .nav-link {
    justify-content: center;
    padding: 12px 8px;
  }
  body.sidebar-collapsed .main-wrapper {
    margin-left: var(--sidebar-collapsed-width);
  }
}

/* ============================================================
   Mobile / tablet: off-canvas sidebar, full-width content
   ============================================================ */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }
  .sidebar .brand-text,
  .sidebar .nav-link span,
  .sidebar .nav-section-label {
    display: block;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.25);
  }
  body.sidebar-open .sidebar-backdrop {
    display: block;
  }
  .main-wrapper {
    margin-left: 0 !important;
  }
  .topbar-title {
    font-size: 0.95rem;
  }
}

/* ============================================================
   Existing component styles
   ============================================================ */
.card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

.stat-card {
  border-radius: 14px;
  color: #fff;
  padding: 1.25rem 1.5rem;
}
.stat-card h3 { margin: 0; font-weight: 700; }
.stat-card p { margin: 0; opacity: 0.9; }

.bg-brand { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); }
.bg-blue  { background: linear-gradient(135deg, #2196f3, #1565c0); }
.bg-green { background: linear-gradient(135deg, #43a047, #2e7d32); }
.bg-purple{ background: linear-gradient(135deg, #7e57c2, #5e35b1); }

.btn-brand {
  background-color: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-brand:hover {
  background-color: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1c2333, #333f5c);
}

.login-card {
  width: 380px;
  border-radius: 14px;
  overflow: hidden;
}

.table thead {
  background-color: #eef1f5;
}

.badge-active { background-color: #43a047; }
.badge-expired { background-color: #e53935; }
.badge-inactive { background-color: #757575; }
