:root {
  --app-sidebar-width: 256px;
  --app-sidebar-bg: linear-gradient(180deg, #f9fbfd 0%, #f2f7fb 100%);
  --app-sidebar-border: rgba(148, 163, 184, 0.24);
  --app-shell-border: rgba(148, 163, 184, 0.18);
  --app-sidebar-text: #17324a;
  --app-sidebar-muted: #6f8193;
  --app-sidebar-link-hover: rgba(15, 98, 173, 0.08);
  --app-sidebar-link-active: linear-gradient(135deg, rgba(15, 98, 173, 0.18) 0%, rgba(18, 122, 111, 0.12) 100%);
  --app-sidebar-link-active-border: rgba(15, 98, 173, 0.18);
  --app-sidebar-icon-bg: linear-gradient(180deg, rgba(15, 98, 173, 0.08) 0%, rgba(18, 122, 111, 0.12) 100%);

  /* Design tokens shared across base.css and site.css */
  --bg: #f8fafc;
  --sidebar-bg: #0f3559;
  --sidebar-bg-soft: #154775;
  --panel: #ffffff;
  --text: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0f62ad;
  --brand-strong: #0a4d8c;
  --warn: #b45309;
  --danger: #b42318;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --surface-subtle: #f1f5f9;
  --text-strong: #27425d;
  --text-soft: #48607a;
  --border-soft: #dbe6f2;
  --border-mid: #d6e4f1;
  --border-strong: #c9d8e8;
  --focus-ring: 0 0 0 3px rgba(15, 98, 173, 0.15);
  --focus-ring-strong: 0 0 0 0.25rem rgba(15, 98, 173, 0.25);
  --table-cell-padding-x: 16px;
  --table-cell-padding-y: 12px;
  --table-cell-padding-compact-x: 10px;
  --table-cell-padding-compact-y: 8px;
  --table-head-bg: linear-gradient(180deg, #fbfdff 0%, #eef5fb 100%);
  --table-head-text: #5f7387;
  --table-row-hover: #fbfdff;
  --table-edit-bg: rgba(255, 255, 255, 0.88);
  --table-edit-cell-bg: #f8fafc;
  --table-edit-cell-hover-bg: #ffffff;
  --field-control-height: 46px;
  --help-trigger-size: 1.25rem;
  --help-trigger-border: #b8cfe2;
  --help-trigger-text: #56738f;
  --help-trigger-bg: linear-gradient(180deg, #ffffff 0%, #f1f7fc 100%);
}

.app-fixed-sidebar {
  width: var(--app-sidebar-width);
  background: var(--app-sidebar-bg);
  color: var(--app-sidebar-text);
  border-right: 1px solid var(--app-sidebar-border);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.06);
}

.app-sidebar-desktop {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1030;
  overflow-y: auto;
  padding: 20px 14px 18px;
  scrollbar-width: thin;
}

.app-sidebar-offcanvas {
  --bs-offcanvas-width: min(92vw, 320px);
  width: min(92vw, 320px);
  background: var(--app-sidebar-bg);
  color: var(--app-sidebar-text);
  border-right: 1px solid var(--app-sidebar-border);
}

.app-sidebar-offcanvas .offcanvas-header {
  padding: 18px 16px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.app-sidebar-offcanvas .offcanvas-body {
  padding: 10px 16px 16px;
}

.app-sidebar-offcanvas .btn-close {
  opacity: 0.65;
}

.app-sidebar-offcanvas .app-sidebar-brand {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.app-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 16px 6px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  color: inherit;
  text-decoration: none;
}

.app-sidebar-brand:hover {
  color: var(--app-sidebar-text);
}

.app-sidebar-brand:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 16px;
}

.app-sidebar-brand-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: block;
}

.app-sidebar-brand-mark img,
.app-sidebar-brand-mark svg {
  width: 100%;
  height: 100%;
  display: block;
}

.app-sidebar-brand-title {
  display: block;
  color: var(--app-sidebar-text);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.app-sidebar-brand-subtitle {
  display: block;
  margin-top: 3px;
  color: var(--app-sidebar-muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.app-sidebar-nav {
  display: grid;
  gap: 4px;
  align-content: start;
}

.app-sidebar-nav-caption {
  margin: 14px 0 6px;
  padding: 0 10px;
  color: var(--app-sidebar-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.app-sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--app-sidebar-text);
  font-size: 0.93rem;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease,
    box-shadow 0.15s ease, transform 0.15s ease;
}

.app-sidebar-nav-link:hover,
.app-sidebar-nav-link:focus {
  background: var(--app-sidebar-link-hover);
  color: #0e385a;
  border-color: rgba(15, 98, 173, 0.08);
  transform: translateX(2px);
}

.app-sidebar-nav-link:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.app-sidebar-nav-link.active {
  background: var(--app-sidebar-link-active);
  color: #0a4d8c;
  border-color: var(--app-sidebar-link-active-border);
  box-shadow: 0 12px 24px rgba(15, 98, 173, 0.08);
}

.app-sidebar-nav-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--app-sidebar-icon-bg);
  color: var(--brand);
  font-size: 0.98rem;
}

.app-sidebar-nav-link.active .app-sidebar-nav-icon {
  background: linear-gradient(180deg, rgba(15, 98, 173, 0.16) 0%, rgba(18, 122, 111, 0.18) 100%);
  color: var(--brand-strong);
}

.app-sidebar-nav-form {
  margin: 0;
}

.app-sidebar-nav-button {
  width: 100%;
  background: transparent;
  border: 0;
  font: inherit;
  text-align: left;
  color: inherit;
}

.app-sidebar-nav-link--logout {
  color: #8c2d23;
}

.app-sidebar-nav-link--logout .app-sidebar-nav-icon {
  color: var(--danger);
  background: linear-gradient(180deg, rgba(180, 35, 24, 0.08) 0%, rgba(180, 83, 9, 0.12) 100%);
}

.app-sidebar-nav-link--logout:hover,
.app-sidebar-nav-link--logout:focus {
  background: rgba(180, 35, 24, 0.06);
  border-color: rgba(180, 35, 24, 0.08);
  color: #8c2d23;
}

.app-sidebar-meta {
  margin: 4px 0 8px;
  padding: 0 10px;
}

.app-sidebar-meta-label {
  display: block;
  color: var(--app-sidebar-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.app-sidebar-meta-value {
  display: block;
  margin-top: 4px;
  color: var(--app-sidebar-text);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.4;
}

.app-sidebar-footer {
  margin-top: auto;
  padding: 14px 10px 0;
}

.app-sidebar-footer-version {
  display: block;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  color: var(--app-sidebar-muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.app-main-shell {
  min-height: 100vh;
  margin: 0 0 0 var(--app-sidebar-width);
  width: calc(100% - var(--app-sidebar-width));
  max-width: none;
  min-width: 0;
  padding: 0;
}

.app-topbar {
  min-height: 68px;
  background: rgba(249, 251, 253, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--app-shell-border);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.04);
  z-index: 1020;
}

.app-topbar .container-fluid,
.app-topbar .container-fluid > * {
  min-width: 0;
}

.app-topbar .icon-only,
.app-topbar-menu-btn {
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.72);
  color: #34526f;
}

.app-topbar .icon-only:hover,
.app-topbar-menu-btn:hover {
  border-color: rgba(15, 98, 173, 0.28);
  background: #ffffff;
  color: var(--brand);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.app-topbar .icon-only.active {
  border-color: rgba(15, 98, 173, 0.2);
  background: linear-gradient(180deg, rgba(15, 98, 173, 0.08) 0%, rgba(18, 122, 111, 0.08) 100%);
  color: var(--brand-strong);
}

.app-topbar-action-danger {
  color: #8c2d23;
  border-color: rgba(180, 35, 24, 0.22) !important;
}

.app-topbar-action-danger:hover {
  color: var(--danger) !important;
  border-color: rgba(180, 35, 24, 0.28) !important;
}

.app-topbar-menu-btn:focus-visible,
.app-topbar .icon-only:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.app-topbar-org-label {
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-topbar-org-name {
  margin-top: 4px;
  color: #102a43;
  font-size: 1.04rem;
  font-weight: 700;
  line-height: 1.2;
}

.app-topbar-user .app-topbar-org-name {
  color: #48607a;
  font-size: 0.94rem;
  font-weight: 600;
}

.app-page-container {
  max-width: 100%;
}

.login-form-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 1rem;
  text-align: center;
}

.login-form-links a {
  display: inline-block;
  padding: 10px 12px;
  min-height: 40px;
  line-height: 20px;
  color: var(--bs-primary, #0d6efd);
  text-decoration: underline;
  font-size: 0.92rem;
}

.app-message-stack {
  display: grid;
  gap: 12px;
  margin-bottom: 1.25rem;
}

.app-message-stack .alert {
  margin-bottom: 0;
  border-radius: 16px;
}

@media (max-width: 991.98px) {
  .app-main-shell {
    margin-left: 0;
    width: 100%;
  }

  .app-topbar {
    min-height: 64px;
  }

  .app-topbar .container-fluid {
    padding-inline: 0.75rem !important;
  }

  .app-topbar-menu-btn,
  .app-topbar .icon-only {
    min-width: 38px;
    min-height: 38px;
    width: 38px;
    height: 38px;
    padding: 0;
  }

  .app-topbar-org-name {
    font-size: 0.98rem;
  }

  .app-sidebar-offcanvas {
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.12);
  }
}

@media (max-width: 575.98px) {
  .app-topbar {
    min-height: 60px;
  }

  .app-topbar-org-label {
    display: none;
  }

  .app-topbar-org-name {
    margin-top: 0;
    font-size: 0.92rem;
  }

  .app-sidebar-offcanvas .offcanvas-header {
    padding: 14px 14px 10px;
  }

  .app-sidebar-offcanvas .offcanvas-body {
    padding: 8px 14px 14px;
  }
}
