:root {
  --app-sidebar-width: 284px;
  --app-radius-xs: 8px;
  --app-radius-sm: 12px;
  --app-radius: 16px;
  --app-radius-lg: 22px;
  --app-shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .04);
  --app-shadow: 0 14px 36px rgba(15, 23, 42, .08);
  --app-bg: #f5f7fb;
  --app-surface: rgba(255, 255, 255, .96);
  --app-surface-solid: #ffffff;
  --app-surface-soft: #f8fafc;
  --app-border: #e5eaf1;
  --app-border-strong: #d7dee8;
  --app-text: #172033;
  --app-muted: #697386;
  --app-primary: #4966f2;
  --app-primary-strong: #3853db;
  --app-primary-soft: rgba(73, 102, 242, .10);
  --app-success-soft: rgba(22, 163, 74, .10);
  --app-warning-soft: rgba(217, 119, 6, .10);
  --app-danger-soft: rgba(220, 38, 38, .09);
  --app-sidebar: #111827;
  --app-sidebar-soft: #192235;
  --app-sidebar-text: #cbd5e1;
  --app-sidebar-muted: #8290a7;
}

[data-bs-theme="dark"] {
  --app-bg: #0b1020;
  --app-surface: rgba(17, 24, 39, .96);
  --app-surface-solid: #111827;
  --app-surface-soft: #151e30;
  --app-border: #263247;
  --app-border-strong: #334155;
  --app-text: #edf2f7;
  --app-muted: #9ba8ba;
  --app-primary: #7c93ff;
  --app-primary-strong: #93a5ff;
  --app-primary-soft: rgba(124, 147, 255, .14);
  --app-success-soft: rgba(34, 197, 94, .13);
  --app-warning-soft: rgba(245, 158, 11, .13);
  --app-danger-soft: rgba(239, 68, 68, .12);
  --app-sidebar: #090e1b;
  --app-sidebar-soft: #121a2b;
  --app-sidebar-text: #d8e0ed;
  --app-sidebar-muted: #7f8ca3;
}

html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--app-text);
  background:
    radial-gradient(circle at 88% -10%, rgba(73, 102, 242, .08), transparent 28rem),
    var(--app-bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: .95rem;
  letter-spacing: -.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { text-underline-offset: 3px; }
::selection { background: rgba(73, 102, 242, .22); }

.app-shell { min-height: 100vh; }
.main-content {
  margin-left: var(--app-sidebar-width);
  width: auto;
  max-width: none;
  min-height: 100vh;
  padding: 30px clamp(22px, 3vw, 46px) 46px;
}
.content-frame { width: min(100%, 1660px); margin: 0 auto; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--app-sidebar-width);
  z-index: 1030;
  display: flex;
  flex-direction: column;
  padding: 20px 16px 18px;
  overflow-y: auto;
  background:
    radial-gradient(circle at 10% -10%, rgba(124, 147, 255, .18), transparent 18rem),
    linear-gradient(180deg, var(--app-sidebar) 0%, #0d1423 100%);
  border-right: 1px solid rgba(255, 255, 255, .055);
  color: var(--app-sidebar-text);
  box-shadow: 10px 0 35px rgba(2, 6, 23, .08);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 18px;
  margin-bottom: 8px;
  text-decoration: none;
  color: #fff;
}
.sidebar-brand:hover { color: #fff; }
.sidebar-brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: white;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -.04em;
  background: linear-gradient(145deg, #6f83ff, #405ee9);
  box-shadow: 0 9px 24px rgba(73, 102, 242, .36), inset 0 1px rgba(255,255,255,.25);
}
.sidebar-brand-name { display: block; font-size: 1.08rem; font-weight: 760; letter-spacing: -.025em; line-height: 1.1; }
.sidebar-brand-subtitle { display: block; color: var(--app-sidebar-muted); font-size: .73rem; margin-top: 4px; font-weight: 500; }

.nav-section { margin-top: 12px; }
.nav-section:first-child { margin-top: 0; }
.nav-section-title {
  padding: 0 11px 7px;
  color: var(--app-sidebar-muted);
  font-size: .68rem;
  font-weight: 760;
  letter-spacing: .095em;
  text-transform: uppercase;
}
.app-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 43px;
  margin: 2px 0;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--app-sidebar-text);
  font-size: .91rem;
  font-weight: 570;
  transition: color .16s ease, background-color .16s ease, border-color .16s ease, transform .16s ease;
}
.app-nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, .055);
  border-color: rgba(255,255,255,.045);
  transform: translateX(2px);
}
.app-nav-link.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(97, 120, 255, .24), rgba(74, 97, 221, .14));
  border-color: rgba(139, 157, 255, .18);
  box-shadow: inset 3px 0 0 #8094ff;
}
.app-nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 18px;
  color: #8f9db2;
  font-size: 1rem;
}
.app-nav-link.active .app-nav-icon,
.app-nav-link:hover .app-nav-icon { color: #b9c5ff; }

.sidebar-actions {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.075);
}
.sidebar-actions .btn {
  border-color: rgba(255,255,255,.12);
  color: var(--app-sidebar-text);
  background: rgba(255,255,255,.025);
}
.sidebar-actions .btn:hover { color: #fff; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.16); }
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 10px 2px;
  border-top: 1px solid rgba(255,255,255,.075);
}
.sidebar-user-avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: #dce4ff;
  background: rgba(124, 147, 255, .13);
  border: 1px solid rgba(150, 165, 255, .12);
  font-size: .78rem;
  font-weight: 800;
}
.sidebar-user-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #d7dfec; font-size: .78rem; font-weight: 600; }
.sidebar-user-role { color: var(--app-sidebar-muted); font-size: .68rem; margin-top: 2px; }

.app-mobile-nav {
  background: rgba(12, 18, 31, .96) !important;
  border-bottom: 1px solid rgba(255,255,255,.07);
  backdrop-filter: blur(14px);
  box-shadow: 0 5px 24px rgba(2, 6, 23, .14);
}
.app-mobile-nav .navbar-brand { display: flex; align-items: center; gap: 9px; font-size: .98rem; }
.mobile-brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(145deg, #7085ff, #405ee9);
  font-size: .73rem;
  font-weight: 800;
}
#mobileNav.offcanvas { background: var(--app-sidebar); color: var(--app-sidebar-text); }
#mobileNav .offcanvas-header { border-bottom: 1px solid rgba(255,255,255,.07); }
#mobileNav .btn-close { filter: invert(1) grayscale(1); opacity: .8; }

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 24px;
}
.page-heading h1 {
  margin: 0;
  color: var(--app-text);
  font-size: clamp(1.55rem, 2.1vw, 2rem);
  font-weight: 770;
  letter-spacing: -.04em;
}
.page-heading p { margin: 7px 0 0; color: var(--app-muted); font-size: .95rem; line-height: 1.55; }

.card,
.metric-card,
.pair-card,
.participant-row,
.stats-grid > div {
  border: 1px solid var(--app-border) !important;
  background: var(--app-surface) !important;
  border-radius: var(--app-radius) !important;
  box-shadow: var(--app-shadow-sm);
}
.card { overflow: hidden; }
.card-header {
  min-height: 52px;
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--app-border);
  background: transparent !important;
  color: var(--app-text);
  font-weight: 680;
}
.card-body { padding: 18px; }
.card-footer { border-top-color: var(--app-border); background: var(--app-surface-soft); }

.metric-card {
  position: relative;
  padding: 18px 18px 17px !important;
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.metric-card::after {
  content: "";
  position: absolute;
  width: 82px;
  height: 82px;
  top: -37px;
  right: -31px;
  border-radius: 50%;
  background: var(--app-primary-soft);
  pointer-events: none;
}
.metric-link { color: var(--app-text) !important; text-decoration: none !important; }
.metric-link:hover { transform: translateY(-3px); box-shadow: var(--app-shadow); border-color: rgba(73, 102, 242, .24) !important; }
.metric-value { color: var(--app-text); font-size: 1.85rem; font-weight: 790; letter-spacing: -.045em; }
.metric-label { margin-top: 7px; color: var(--app-muted); font-size: .79rem; font-weight: 590; line-height: 1.35; }
.metric-accent { width: 4px !important; border-radius: 0 5px 5px 0; opacity: .85; }

.btn {
  min-height: 39px;
  border-radius: 10px;
  font-weight: 650;
  font-size: .88rem;
  padding: .48rem .85rem;
  box-shadow: none !important;
  transition: transform .14s ease, background-color .14s ease, border-color .14s ease, color .14s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--app-primary); border-color: var(--app-primary); }
.btn-primary:hover { background: var(--app-primary-strong); border-color: var(--app-primary-strong); }
.btn-outline-primary { color: var(--app-primary); border-color: rgba(73,102,242,.34); }
.btn-outline-primary:hover { color: #fff; background: var(--app-primary); border-color: var(--app-primary); }
.btn-sm { min-height: 33px; border-radius: 9px; padding: .34rem .64rem; font-size: .8rem; }
.btn-group > .btn { border-radius: 9px; }

.form-label { margin-bottom: 6px; color: var(--app-text); font-size: .79rem; font-weight: 680; }
.form-text, .text-secondary, .text-body-secondary { color: var(--app-muted) !important; }
.form-control,
.form-select,
.input-group-text {
  min-height: 42px;
  border-color: var(--app-border-strong);
  border-radius: 10px;
  background-color: var(--app-surface-solid);
  color: var(--app-text);
  font-size: .9rem;
  box-shadow: none !important;
  transition: border-color .14s ease, box-shadow .14s ease, background-color .14s ease;
}
.form-control:hover, .form-select:hover { border-color: #c4ccd8; }
.form-control:focus, .form-select:focus {
  border-color: rgba(73, 102, 242, .65);
  box-shadow: 0 0 0 3px rgba(73, 102, 242, .12) !important;
  background-color: var(--app-surface-solid);
}
.form-check-input { border-color: var(--app-border-strong); box-shadow: none !important; }
.form-check-input:checked { background-color: var(--app-primary); border-color: var(--app-primary); }
.form-switch .form-check-input { width: 2.35em; height: 1.22em; }
textarea.form-control { min-height: 110px; }

.table-responsive { scrollbar-width: thin; scrollbar-color: var(--app-border-strong) transparent; }
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--app-text);
  --bs-table-hover-bg: var(--app-primary-soft);
  --bs-table-hover-color: var(--app-text);
  margin-bottom: 0;
}
.table > :not(caption) > * > * { padding: .78rem .9rem; border-bottom-color: var(--app-border); vertical-align: middle; }
.table thead th {
  color: var(--app-muted);
  background: var(--app-surface-soft);
  border-bottom: 1px solid var(--app-border-strong);
  font-size: .69rem;
  font-weight: 780;
  letter-spacing: .05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.table tbody tr:last-child > * { border-bottom: 0; }
.table tbody td { font-size: .87rem; }
.table a.fw-semibold, .table .fw-semibold a { color: var(--app-text); }
.table a.fw-semibold:hover, .table .fw-semibold a:hover { color: var(--app-primary); }

.badge {
  border-radius: 999px;
  padding: .38em .66em;
  font-size: .69rem;
  font-weight: 720;
  letter-spacing: .01em;
}
.text-bg-primary { background-color: var(--app-primary) !important; }
.text-bg-success { color: #13763b !important; background: #dcfce7 !important; }
.text-bg-warning { color: #8a4d08 !important; background: #fef3c7 !important; }
.text-bg-danger { color: #a61b1b !important; background: #fee2e2 !important; }
.text-bg-secondary { color: #475569 !important; background: #e9eef5 !important; }
[data-bs-theme="dark"] .text-bg-success { color: #9ae6b4 !important; background: rgba(34,197,94,.16) !important; }
[data-bs-theme="dark"] .text-bg-warning { color: #fbd38d !important; background: rgba(245,158,11,.16) !important; }
[data-bs-theme="dark"] .text-bg-danger { color: #feb2b2 !important; background: rgba(239,68,68,.17) !important; }
[data-bs-theme="dark"] .text-bg-secondary { color: #cbd5e1 !important; background: rgba(148,163,184,.16) !important; }

.alert {
  border: 1px solid var(--app-border);
  border-radius: 13px;
  box-shadow: var(--app-shadow-sm);
  font-size: .88rem;
}
.alert-success { background: var(--app-success-soft); border-color: rgba(22,163,74,.18); color: inherit; }
.alert-warning { background: var(--app-warning-soft); border-color: rgba(217,119,6,.20); color: inherit; }
.alert-danger { background: var(--app-danger-soft); border-color: rgba(220,38,38,.20); color: inherit; }
.alert-info { background: var(--app-primary-soft); border-color: rgba(73,102,242,.18); color: inherit; }

.progress { overflow: hidden; border-radius: 999px; background: var(--app-border); }
.progress-bar { border-radius: 999px; }
.dashboard-progress { height: 7px !important; }
.dashboard-progress-lg { height: 10px !important; }
.dashboard-empty-chart { border-color: var(--app-border) !important; background: var(--app-surface-soft) !important; border-radius: 14px !important; }

.list-group-item {
  padding: 13px 18px;
  border-color: var(--app-border);
  background: transparent;
  color: var(--app-text);
}
.list-group-item-action:hover { background: var(--app-primary-soft); color: var(--app-text); }

.dropdown-menu {
  border: 1px solid var(--app-border);
  border-radius: 12px;
  padding: 6px;
  background: var(--app-surface-solid);
  box-shadow: var(--app-shadow);
}
.dropdown-item { border-radius: 8px; padding: .48rem .65rem; font-size: .86rem; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--app-primary-soft); color: var(--app-text); }

.participant-row, .pair-card, .stats-grid > div { box-shadow: none; }
.participant-row:hover { border-color: rgba(73,102,242,.36) !important; background: var(--app-primary-soft) !important; }
.pair-accepted { border-color: rgba(22,163,74,.38) !important; background: var(--app-success-soft) !important; }
.volunteer-combobox-menu {
  border: 1px solid var(--app-border) !important;
  border-radius: 12px !important;
  background: var(--app-surface-solid) !important;
  box-shadow: var(--app-shadow) !important;
  padding: 5px !important;
}
.volunteer-combobox-option { border-radius: 8px !important; }
.volunteer-combobox-option:hover, .volunteer-combobox-option.is-active { background: var(--app-primary-soft) !important; }

.auth-shell {
  min-height: 100vh;
  padding: 28px 18px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 15% 10%, rgba(73,102,242,.18), transparent 25rem),
    radial-gradient(circle at 88% 88%, rgba(94,234,212,.10), transparent 24rem),
    var(--app-bg);
}
.auth-stage { width: min(100%, 460px); }
.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin-bottom: 18px;
  color: var(--app-text);
  text-decoration: none;
  font-size: 1.08rem;
  font-weight: 780;
  letter-spacing: -.03em;
}
.auth-brand:hover { color: var(--app-text); }
.auth-brand .sidebar-brand-mark { width: 38px; height: 38px; border-radius: 12px; }
.auth-card {
  width: 100% !important;
  border-radius: var(--app-radius-lg) !important;
  box-shadow: 0 24px 70px rgba(15,23,42,.12) !important;
}
.auth-card .card-body { padding: clamp(24px, 4vw, 36px) !important; }
.auth-card h1 { font-weight: 790; letter-spacing: -.04em; }

.modal-content, .offcanvas { border-color: var(--app-border); background: var(--app-surface-solid); }
.modal-content { border-radius: 18px; box-shadow: var(--app-shadow); }

code {
  padding: .15em .38em;
  border-radius: 6px;
  background: var(--app-surface-soft);
  color: var(--app-primary);
}

[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .metric-card,
[data-bs-theme="dark"] .pair-card,
[data-bs-theme="dark"] .participant-row,
[data-bs-theme="dark"] .stats-grid > div { box-shadow: 0 1px 0 rgba(255,255,255,.02); }
[data-bs-theme="dark"] .form-control:hover,
[data-bs-theme="dark"] .form-select:hover { border-color: #44516a; }

@media (max-width: 1199.98px) {
  :root { --app-sidebar-width: 258px; }
  .main-content { padding-left: 28px; padding-right: 28px; }
}

@media (max-width: 991.98px) {
  .main-content { margin-left: 0; padding: 22px 16px 36px; }
  .content-frame { width: 100%; }
  .page-heading { margin-bottom: 18px; }
  #mobileNav .offcanvas-body { padding: 14px; }
  #mobileNav .nav-section-title { padding-left: 10px; }
  #mobileNav .sidebar-actions { margin-top: 18px; }
}

@media (max-width: 767.98px) {
  body { font-size: .92rem; }
  .page-heading { flex-direction: column; align-items: stretch; gap: 13px; }
  .page-heading > .d-flex { width: 100%; }
  .page-heading > .d-flex .btn { flex: 1 1 auto; }
  .card-header { padding: 13px 14px; }
  .card-body { padding: 15px; }
  .table > :not(caption) > * > * { padding: .68rem .75rem; }
  .metric-card { padding: 15px !important; }
}

@media (max-width: 575.98px) {
  .main-content { padding: 18px 11px 30px; }
  .page-heading h1 { font-size: 1.48rem; }
  .btn { min-height: 38px; }
  .auth-shell { padding: 18px 12px; }
  .auth-card .card-body { padding: 24px 20px !important; }
}
