:root {
  --a-bg: #ffffff;
  --a-muted: #f3f5f7;
  --a-line: #dfe5eb;
  --a-text: #1e2732;
  --a-blue: #122d48;
  --a-sky: #3893d7;
  --a-success: #198754;
  --a-danger: #b02a37;
  --admin-topbar-h: 69px;
}

body {
  background: var(--a-bg);
  color: var(--a-text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.site-header {
  border-bottom: 1px solid var(--a-line);
  background: #fff;
}

.site-header .navbar {
  padding-top: .75rem;
  padding-bottom: .75rem;
}

.brand-title {
  color: var(--a-blue);
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand-title-text {
  color: var(--a-blue);
  font-weight: 700;
}

.brand-logo {
  max-height: 56px;
  max-width: 220px;
  width: auto;
  object-fit: contain;
}

.public-nav-wrap {
  gap: 1rem;
}

.public-nav-links {
  gap: .25rem;
}

.public-nav-links .nav-link {
  position: relative;
  color: #3d4b5b;
  font-weight: 500;
  padding: .55rem .75rem;
  border-radius: .5rem;
  transition: color .2s ease, background-color .2s ease;
}

.public-nav-links .nav-link:after {
  content: "";
  position: absolute;
  left: .75rem;
  right: .75rem;
  bottom: .35rem;
  height: 2px;
  background: var(--a-sky);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .2s ease;
}

.public-nav-links .nav-link:hover {
  color: var(--a-blue);
  background: #f2f6fa;
}

.public-nav-links .nav-link:hover:after,
.public-nav-links .nav-link.active:after {
  transform: scaleX(1);
}

.public-nav-cta {
  margin-left: .75rem;
}

.learning-main-nav {
  gap: .2rem;
}

.learning-main-nav .nav-link {
  color: #3d4b5b;
  font-weight: 500;
  padding: .55rem .75rem;
  border-radius: .5rem;
  transition: color .2s ease, background-color .2s ease;
}

.learning-main-nav .nav-link:hover,
.learning-main-nav .nav-link.active {
  color: var(--a-blue);
  background: #f2f6fa;
}

.learning-user-toggle {
  color: #334558;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  border-radius: .5rem;
  padding: .35rem .55rem;
}

.learning-user-toggle:hover,
.learning-user-toggle:focus {
  color: var(--a-blue);
  background: #f2f6fa;
}

.learning-avatar-sm,
.learning-avatar-fallback-sm {
  width: 34px;
  height: 34px;
  object-fit: cover;
  background: #e7eff7;
  color: #365270;
}

.learning-avatar-xl,
.learning-avatar-fallback-xl {
  width: 110px;
  height: 110px;
  object-fit: cover;
  background: #e7eff7;
  color: #365270;
  font-size: 2.6rem;
}

.navbar-toggler {
  border-color: #d0dae5;
  border-width: 2px;
  border-radius: .7rem;
  padding: .4rem .6rem;
}

.navbar-toggler:focus {
  box-shadow: 0 0 0 .2rem rgba(56, 147, 215, .2);
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 30 30' xmlns='http://www.w3.org/2000/svg'%3e%3cpath stroke='rgba(18,45,72,.85)' stroke-width='2.2' stroke-linecap='round' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Admin layout */
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 1060;
}

.admin-shell {
  display: flex;
  min-height: calc(100vh - var(--admin-topbar-h));
  background: #f7f9fc;
}

.admin-sidebar {
  width: 260px;
  background: var(--a-blue);
  color: #d5e2ef;
  border-right: 1px solid #0d2237;
  transition: width .22s ease, transform .22s ease;
}

.admin-sidebar-head {
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.admin-sidebar-subtitle {
  color: #a5bbd0;
  letter-spacing: .06em;
}

.admin-side-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: #deebf7 !important;
  border-radius: .65rem;
  padding: .55rem .7rem;
  transition: background-color .18s ease, color .18s ease;
}

.admin-side-dot {
  width: .5rem;
  height: .5rem;
  border-radius: 999px;
  background: rgba(173, 205, 231, .6);
  flex: 0 0 auto;
}

.admin-side-icon {
  font-size: 1rem;
  width: 1rem;
  text-align: center;
  flex: 0 0 1rem;
}

.admin-side-link:hover {
  color: #fff !important;
  background: rgba(255, 255, 255, .14);
}

.admin-side-link.active {
  color: #fff !important;
  background: rgba(56, 147, 215, .28);
}

.admin-side-link.active .admin-side-dot {
  background: #9dd9ff;
}

.admin-main {
  flex: 1;
  min-width: 0;
}

.admin-sidebar-toggle {
  width: 38px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.admin-sidebar-mobile-close {
  border-width: 1px;
  border-color: rgba(255, 255, 255, .35);
  color: #eef5fb;
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.admin-sidebar-mobile-close:hover {
  background: rgba(255, 255, 255, .16);
  color: #fff;
}

body.admin-sidebar-collapsed .admin-sidebar {
  width: 78px;
}

body.admin-sidebar-collapsed .admin-side-label,
body.admin-sidebar-collapsed .admin-sidebar-subtitle {
  display: none;
}

body.admin-sidebar-collapsed .admin-side-link {
  justify-content: center;
  padding: .65rem .35rem;
}

body.admin-sidebar-collapsed .admin-side-dot {
  display: none;
}

body.admin-sidebar-collapsed .admin-side-icon {
  font-size: 1.1rem;
}

.admin-sidebar-backdrop {
  display: none;
}

/* Admin site-content */
.cms-tabs .nav-link {
  color: #435569;
  font-weight: 600;
  border-top-left-radius: .65rem;
  border-top-right-radius: .65rem;
}

.cms-tabs .nav-link.active {
  color: var(--a-blue);
  background: #fff;
}

.admin-panel {
  background: #fff;
  border: 1px solid var(--a-line);
  border-radius: .8rem;
  overflow: hidden;
}

.admin-panel-head {
  background: linear-gradient(135deg, var(--a-blue) 0%, #1b4267 100%);
  color: #fff;
  font-weight: 600;
  padding: .65rem 1rem;
}

.admin-panel-body {
  padding: 1rem;
}

.hero-box {
  background: linear-gradient(135deg, #ffffff 0%, #eef4f9 100%);
  border: 1px solid var(--a-line);
  border-radius: 1rem;
  padding: 2rem;
}

.home-slide-image {
  width: 100%;
  height: min(55vh, 540px);
  object-fit: cover;
}

.home-slide-media {
  position: relative;
}

.home-slide-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    90deg,
    rgba(12, 33, 54, .72) 0%,
    rgba(12, 33, 54, .5) 35%,
    rgba(12, 33, 54, .22) 60%,
    rgba(12, 33, 54, 0) 100%
  );
}

.home-slide-content {
  position: absolute;
  z-index: 2;
  inset: 0 auto 0 clamp(2.75rem, 11vw, 11rem);
  width: min(620px, 52%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: clamp(1rem, 2.8vw, 2.5rem);
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .35);
}

.home-slide-title {
  margin: 0 0 .55rem;
  font-size: clamp(1.5rem, 2.7vw, 2.3rem);
  font-weight: 700;
}

.home-slide-text {
  margin: 0 0 1rem;
  font-size: clamp(.95rem, 1.35vw, 1.1rem);
  max-width: 58ch;
}

#homeCarousel .carousel-control-prev,
#homeCarousel .carousel-control-next {
  width: 12%;
  z-index: 3;
}

#homeCarousel .carousel-indicators {
  z-index: 4;
}

.section-card {
  background: #fff;
  border: 1px solid var(--a-line);
  border-radius: .75rem;
  padding: 1.25rem;
}

.footer-dark {
  background: var(--a-blue);
  color: #d9e2ec;
  padding: 2rem 0;
}

.footer-dark a {
  color: #d9e2ec;
}

.public-nav-links .nav-link.active,
.public-nav-links .nav-link:hover {
  color: var(--a-sky) !important;
}

.badge-soft {
  background: #e7eff7;
  color: var(--a-blue);
  border: 1px solid var(--a-line);
}

.viewer-shell {
  background: #f8fafc;
  border: 1px solid var(--a-line);
  border-radius: .75rem;
}

.viewer-header {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--a-line);
  background: #fff;
}

.viewer-body {
  min-height: 70vh;
  background: #edf2f7;
  position: relative;
  overflow: auto;
}

.viewer-inline-tools {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: .45rem;
  padding: .7rem .75rem 0;
  background: linear-gradient(180deg, rgba(237, 242, 247, .94) 0%, rgba(237, 242, 247, .68) 65%, rgba(237, 242, 247, 0) 100%);
}

.viewer-zoom-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid #b7c7d8;
  background: #fff;
  color: #20384f;
  font-weight: 700;
  padding: 0;
  line-height: 1;
}

.viewer-zoom-btn:hover {
  background: #f3f7fb;
}

.viewer-zoom-label {
  min-width: 56px;
  text-align: center;
  font-size: .82rem;
  font-weight: 600;
  color: #2d445b;
  background: rgba(255, 255, 255, .95);
  border: 1px solid #c9d7e5;
  border-radius: 999px;
  padding: .2rem .5rem;
}

.viewer-image-wrap {
  min-height: calc(68vh - 10px);
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: .75rem 1rem 1.1rem;
}

.viewer-body img {
  width: auto;
  max-width: none;
  max-height: none;
  height: auto;
  display: block;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
  border-radius: .25rem;
  transition: width .12s ease;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

.viewer-controls {
  border-top: 1px solid var(--a-line);
  padding: .75rem 1rem;
  background: #fff;
}

.viewer-slide-loading {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .82rem;
  color: #5d6e80;
  white-space: nowrap;
}

.material-open-loading {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(10, 22, 35, .38);
}

.material-open-loading-box {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  background: #fff;
  border: 1px solid var(--a-line);
  border-radius: .7rem;
  padding: .7rem .85rem;
  color: #1f3347;
  font-size: .9rem;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .2);
}

.materials-list .list-group-item {
  border-bottom: 1px solid #e5ebf2;
}

.material-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
}

.material-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .55rem;
}

.material-icon {
  width: 1.65rem;
  height: 1.65rem;
  border-radius: .4rem;
  background: #f2f6fa;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-size: .95rem;
}

.material-meta {
  min-width: 0;
}

.material-name {
  font-size: .86rem;
  font-weight: 600;
  color: #25364a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 13rem;
}

.material-type {
  font-size: .73rem;
  color: #6a7a8b;
}

.material-actions {
  display: flex;
  align-items: center;
  gap: .28rem;
  flex: 0 0 auto;
}

.material-action-btn {
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.table thead th {
  background: var(--a-muted);
  color: #344255;
}

.tracking-table-compact th,
.tracking-table-compact td {
  font-size: .82rem;
  line-height: 1.15;
  white-space: nowrap;
}

.status-pill {
  border-radius: 999px;
  font-size: .78rem;
  padding: .2rem .55rem;
}

.status-queued { background: #e9ecef; color: #495057; }
.status-processing { background: #cff4fc; color: #055160; }
.status-completed { background: #d1e7dd; color: #0f5132; }
.status-failed { background: #f8d7da; color: #842029; }
.status-published { background: #d1e7dd; color: #0f5132; }
.status-draft { background: #fff3cd; color: #664d03; }
.status-ready { background: #cfe2ff; color: #084298; }
.status-archived { background: #e2e3e5; color: #41464b; }
.status-closed { background: #f8d7da; color: #842029; }
.status-active { background: #d1e7dd; color: #0f5132; }
.status-suspended { background: #fff3cd; color: #664d03; }
.status-revoked { background: #f8d7da; color: #842029; }

.form-label.required:after {
  content: " *";
  color: var(--a-danger);
}

.card-kpi {
  border: 1px solid var(--a-line);
  border-radius: .75rem;
  background: #fff;
  padding: 1rem;
}

.kpi-value {
  font-size: 1.5rem;
  color: var(--a-blue);
  font-weight: 700;
}

.dashboard-kpi-card {
  min-height: 106px;
}

.dashboard-alert-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .7rem;
  border: 1px solid var(--a-line);
  border-radius: .7rem;
  background: #fff;
  padding: .65rem .75rem;
  color: inherit;
  text-decoration: none;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}

.dashboard-alert-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(14, 33, 55, .08);
}

.dashboard-alert-title {
  font-size: .86rem;
  font-weight: 600;
}

.dashboard-alert-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.dashboard-alert-danger {
  border-color: #f5c2c7;
  background: #fff6f6;
}

.dashboard-alert-danger .dashboard-alert-count {
  color: #842029;
  background: #f8d7da;
  border-color: #f1aeb5;
}

.dashboard-alert-warning {
  border-color: #ffe69c;
  background: #fffef5;
}

.dashboard-alert-warning .dashboard-alert-count {
  color: #664d03;
  background: #fff3cd;
  border-color: #ffda6a;
}

.dashboard-alert-info {
  border-color: #9eeaf9;
  background: #f6feff;
}

.dashboard-alert-info .dashboard-alert-count {
  color: #055160;
  background: #cff4fc;
  border-color: #6edff6;
}

.dashboard-trend-table td {
  vertical-align: top;
}

.dashboard-bar-wrap {
  width: 100%;
  max-width: 220px;
  background: #edf2f7;
  border-radius: 999px;
  overflow: hidden;
  height: .5rem;
}

.dashboard-bar {
  display: block;
  height: 100%;
}

.dashboard-bar-study {
  background: linear-gradient(90deg, #3893d7 0%, #85c8f2 100%);
}

.dashboard-bar-completed {
  background: linear-gradient(90deg, #198754 0%, #71d3a4 100%);
}

.dashboard-bar-tests {
  background: linear-gradient(90deg, #0d6efd 0%, #7fb0ff 100%);
}

.dashboard-table-compact th,
.dashboard-table-compact td {
  font-size: .82rem;
}

.print-only {
  display: none;
}

@media (max-width: 991.98px) {
  .brand-logo {
    max-height: 48px;
    max-width: 180px;
  }

  .public-nav-wrap {
    margin-top: .75rem;
    border-top: 1px solid var(--a-line);
    padding-top: .7rem;
  }

  .public-nav-links .nav-link {
    padding-left: 0;
    padding-right: 0;
    border-radius: 0;
  }

  .public-nav-links .nav-link:after {
    left: 0;
    right: auto;
    width: 26px;
  }

  .public-nav-cta {
    margin-left: 0;
    margin-top: .55rem;
  }

  .learning-user-area {
    margin-top: .65rem;
    padding-top: .7rem;
    border-top: 1px solid var(--a-line);
    justify-content: space-between;
  }

  .home-slide-image {
    height: min(40vh, 320px);
  }

  .home-slide-content {
    inset: 0;
    width: 100%;
    align-items: center;
    text-align: center;
    padding: 1rem 1.25rem 2.15rem;
  }

  .home-slide-overlay {
    background: linear-gradient(
      90deg,
      rgba(12, 33, 54, .7) 0%,
      rgba(12, 33, 54, .5) 55%,
      rgba(12, 33, 54, .32) 100%
    );
  }

  .admin-shell {
    min-height: auto;
  }

  .admin-sidebar {
    position: fixed;
    top: var(--admin-topbar-h);
    left: 0;
    height: calc(100vh - var(--admin-topbar-h));
    z-index: 1045;
    transform: translateX(-100%);
    width: min(84vw, 280px);
    padding-top: 0;
  }

  .admin-sidebar-backdrop {
    display: block;
    position: fixed;
    top: var(--admin-topbar-h);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    background: rgba(9, 20, 33, .48);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }

  body.admin-sidebar-open .admin-sidebar {
    transform: translateX(0);
  }

  body.admin-sidebar-open .admin-sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .admin-main {
    width: 100%;
  }
}

@media (max-width: 767.98px) {
  #homeCarousel .carousel-control-prev,
  #homeCarousel .carousel-control-next {
    display: none;
  }

  .home-slide-image {
    height: min(48vh, 370px);
  }

  .home-slide-text {
    max-width: 100%;
  }
}

@media print {
  .no-print {
    display: none !important;
  }

  .print-only {
    display: block !important;
  }

  body {
    background: #fff;
  }
}
