: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-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 30px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}
.sidebar-user-info {
  overflow: hidden;
  min-width: 0;
}
.sidebar-user-name {
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  color: rgba(255,255,255,0.45);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
body.sidebar-collapsed .sidebar-user-info,
body.sidebar-collapsed .sidebar-user {
  justify-content: center;
}
body.sidebar-collapsed .sidebar-user-info {
  display: none;
}

.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: 3px;
  font-size: 0.92rem;
  white-space: nowrap;
  position: relative;
  border-left: 3px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 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;
  transform: translateX(2px);
}
.sidebar-nav .nav-link.active {
  background: linear-gradient(90deg, rgba(255,87,34,0.25), rgba(255,87,34,0.05));
  color: #fff;
  border-left-color: var(--brand);
  font-weight: 600;
}
.sidebar-nav .nav-link.active i {
  color: var(--brand);
}

.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;
}

/* ---------------- Topbar search ---------------- */
.topbar-search {
  max-width: 380px;
  position: relative;
}
.topbar-search-input {
  padding-left: 34px;
  background: #f4f6f9;
  border-color: #e7e9ee;
}
.topbar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #9aa1ac;
  z-index: 2;
}
.search-results-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  max-height: 360px;
  overflow-y: auto;
  z-index: 1050;
}
.search-results-dropdown.show { display: block; }
.search-results-dropdown a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: #333;
  text-decoration: none;
  font-size: 0.88rem;
  border-bottom: 1px solid #f0f1f4;
}
.search-results-dropdown a:hover { background: #f4f6f9; }
.search-results-dropdown .search-empty {
  padding: 14px;
  color: #999;
  font-size: 0.85rem;
  text-align: center;
}

/* ---------------- Notification bell ---------------- */
.topbar-bell {
  position: relative;
  font-size: 1.2rem;
  color: var(--dark);
  text-decoration: none;
  padding: 4px 6px;
}
.bell-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #e53935;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  border-radius: 50%;
  min-width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}
.notif-dropdown {
  width: 320px;
  max-height: 380px;
  overflow-y: auto;
}

@media (max-width: 767.98px) {
  .topbar-search { max-width: 160px; }
  .topbar-search-input::placeholder { font-size: 0.78rem; }
}

.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;
  display: block;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.stat-card-watermark {
  position: absolute;
  right: -10px;
  bottom: -14px;
  font-size: 4.2rem;
  opacity: 0.15;
  pointer-events: none;
}
.stat-card p, .stat-card h3 {
  position: relative;
  z-index: 1;
}
.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.18);
  color: #fff;
}
.stat-card h3 { margin: 0; font-weight: 700; }
.stat-card p { margin: 0; opacity: 0.9; }

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #43a047;
  margin-right: 5px;
  animation: livePulse 1.6s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.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); }
.bg-teal  { background: linear-gradient(135deg, #00897b, #00695c); }
.bg-orange{ background: linear-gradient(135deg, #fb8c00, #ef6c00); }

.report-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.report-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.12);
}
.report-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.4rem;
}

.dash-hero {
  background: linear-gradient(120deg, #1c2333, #333f5c);
  border-radius: 16px;
  padding: 28px 32px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.dash-hero h3, .dash-hero p { position: relative; z-index: 1; }
.dash-hero p.text-muted { color: rgba(255,255,255,0.65) !important; }
.dash-hero-icon {
  font-size: 6rem;
  color: rgba(255,255,255,0.08);
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
}
@media (max-width: 575.98px) {
  .dash-hero { padding: 20px; }
  .dash-hero-icon { font-size: 4rem; }
}

.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; }

.member-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.member-avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  text-transform: uppercase;
}

/* ============================================================
   Member portal navbar
   ============================================================ */
.portal-navbar {
  background: linear-gradient(120deg, #1c2333, #333f5c);
  padding: 14px 0;
}
.portal-navbar .navbar-brand {
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.portal-navbar .navbar-brand img {
  height: 28px;
  width: 28px;
  border-radius: 6px;
  background: #fff;
  padding: 2px;
  object-fit: contain;
}
.portal-nav-pills .nav-link {
  color: rgba(255,255,255,0.7);
  border-radius: 8px;
  padding: 8px 14px;
  margin: 0 2px;
  font-size: 0.92rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.portal-nav-pills .nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.portal-nav-pills .nav-link.active {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}
.portal-logout-btn {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
}
.portal-logout-btn:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

/* ============================================================
   Dark mode
   ============================================================ */
body.dark-mode {
  background-color: #14181f;
  color: #dfe3ea;
}
body.dark-mode .card,
body.dark-mode .topbar,
body.dark-mode .report-card {
  background-color: #1e2430;
  color: #dfe3ea;
}
body.dark-mode .card-header {
  background-color: #232a38 !important;
  color: #dfe3ea;
  border-color: #2c3444;
}
body.dark-mode .table {
  color: #dfe3ea;
}
body.dark-mode .table thead {
  background-color: #232a38;
  color: #dfe3ea;
}
body.dark-mode .table td,
body.dark-mode .table th {
  border-color: #2c3444;
}
body.dark-mode .form-control,
body.dark-mode .form-select {
  background-color: #232a38;
  color: #dfe3ea;
  border-color: #333d4f;
}
body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus {
  background-color: #232a38;
  color: #dfe3ea;
}
body.dark-mode .text-dark,
body.dark-mode .topbar-title,
body.dark-mode .toggle-btn,
body.dark-mode .topbar-bell,
body.dark-mode .topbar-user .dropdown-toggle,
body.dark-mode .toggle-btn i,
body.dark-mode .topbar-bell i,
body.dark-mode .topbar-user .dropdown-toggle i {
  color: #dfe3ea !important;
}
body.dark-mode .topbar-user-avatar {
  color: #fff !important;
}
body.dark-mode .topbar-search-input {
  background-color: #232a38;
  border-color: #333d4f;
  color: #dfe3ea;
}
body.dark-mode .toggle-btn:hover {
  background: #2c3444;
}
body.dark-mode .search-results-dropdown,
body.dark-mode .notif-dropdown,
body.dark-mode .dropdown-menu {
  background-color: #1e2430;
  color: #dfe3ea;
}
body.dark-mode .search-results-dropdown a,
body.dark-mode .dropdown-item {
  color: #dfe3ea;
}
body.dark-mode .search-results-dropdown a:hover,
body.dark-mode .dropdown-item:hover {
  background-color: #2c3444;
  color: #fff;
}
body.dark-mode .dropdown-header {
  color: #9aa1ac;
}
body.dark-mode .dropdown-divider {
  border-color: #333d4f;
}
body.dark-mode .text-muted {
  color: #9aa1ac !important;
}
