:root {
  --s42-ink: #14131a;
  --s42-ink-soft: #4c4a57;
  --s42-ink-faint: #7a7787;
  --s42-accent: #e5662f;
  --s42-accent-2: #1e7f6d;
  --s42-accent-3: #f2b134;
  --s42-bg: #f7f3ee;
  --s42-shadow: 0 18px 50px rgba(18, 17, 25, 0.16);
  --s42-font-sans: "Aptos", "Space Grotesk", "Segoe UI", "Trebuchet MS", sans-serif;
  --s42-font-display: "Aptos", "Fraunces", "Times New Roman", serif;
  --s42-tool-max-width: 960px;
}

html,
body {
  min-height: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0 !important;
  padding-top: 0 !important;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--s42-ink);
  font-family: var(--s42-font-sans);
  background: #f4f6fa;
}

body:not(.s42-landing):not(.s42-home-bootstrap) {
  background: #f0f1f5;
  --s42-page-top: 1.5rem;
  --s42-page-bottom: 2.5rem;
}

body:not(.s42-landing):not(.s42-home-bootstrap) .s42-page {
  background: #f0f1f5;
}

body:not(.s42-landing):not(.s42-home-bootstrap) .s42-page > .container,
body:not(.s42-landing):not(.s42-home-bootstrap) .s42-page > .s42-container,
body:not(.s42-landing):not(.s42-home-bootstrap) .s42-page > main > .container,
body:not(.s42-landing):not(.s42-home-bootstrap) .s42-page > main > .s42-container {
  max-width: var(--s42-tool-max-width);
}

body:not(.s42-landing):not(.s42-home-bootstrap) .s42-page-title {
  font-family: var(--s42-font-display);
  font-size: clamp(1.6rem, 2.4vw, 2.2rem);
  font-weight: 700;
  text-align: center;
  margin: 0 0 1.5rem;
}

.s42-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.s42-header {
  position: sticky;
  top: 0;
  z-index: 1040;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(20, 19, 26, 0.08);
  box-shadow: 0 6px 18px rgba(20, 19, 26, 0.06);
}

.s42-header .navbar {
  padding: 0.45rem 0;
}

/* Protect header layout from page-level ".container" overrides */
.s42-header .container,
.s42-header .container.s42-container {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  background: transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.s42-header .navbar-brand {
  font-family: var(--s42-font-display);
  color: var(--s42-ink);
  letter-spacing: -0.02em;
}

.s42-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(245, 247, 250, 0.92));
  border: 1px solid rgba(20, 19, 26, 0.08);
  box-shadow: 0 3px 10px rgba(20, 19, 26, 0.12);
}

.s42-brand-mark img {
  width: 28px;
  height: 28px;
  display: block;
}

.s42-brand-text {
  font-size: 1rem;
  font-weight: 700;
}

.s42-brand-sub {
  font-size: 0.66rem;
  color: var(--s42-ink-faint);
  margin-top: 0.2rem;
  letter-spacing: 0.02em;
}

.s42-nav-link {
  color: var(--s42-ink) !important;
  font-weight: 600;
  font-size: 0.92rem;
  border-radius: 999px;
  padding: 0.45rem 0.8rem !important;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.s42-nav-link:hover,
.s42-nav-link:focus {
  color: var(--s42-accent-2) !important;
  background: rgba(30, 127, 109, 0.09);
  transform: translateY(-1px);
}

.s42-header .btn.nav-link {
  text-decoration: none;
  line-height: 1.2;
}

.s42-header .navbar-toggler {
  border-color: rgba(20, 19, 26, 0.18);
}

.s42-header .dropdown-menu {
  border-radius: 14px;
  border: 1px solid rgba(20, 19, 26, 0.08);
  box-shadow: var(--s42-shadow);
}

.s42-tools-menu {
  width: min(980px, 96vw);
}

.s42-tools-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.s42-tools-category {
  border: 1px solid rgba(20, 19, 26, 0.07);
  border-radius: 12px;
  padding: 0.35rem;
  background: rgba(255, 255, 255, 0.65);
}

.s42-tools-category .dropdown-header {
  color: var(--s42-ink-soft);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.35rem 0.55rem 0.45rem;
}

.s42-tool-link {
  border-radius: 10px;
  white-space: normal;
  padding: 0.5rem 0.55rem;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.s42-tool-link:hover,
.s42-tool-link:focus {
  background: rgba(229, 102, 47, 0.1);
  transform: translateY(-1px);
}

.s42-tool-link.active {
  background: rgba(229, 102, 47, 0.16);
  color: var(--s42-ink);
}

.s42-tool-link.disabled {
  opacity: 0.52;
}

.s42-menu-desc {
  font-size: 0.76rem;
  line-height: 1.25;
}

.s42-tool-icon {
  width: 1rem;
  text-align: center;
  margin-top: 0.2rem;
  color: var(--s42-accent-2);
}

.s42-user-bar .btn {
  border-radius: 999px;
}

.s42-user-name {
  font-size: 0.79rem;
  border: 1px solid rgba(20, 19, 26, 0.1);
}

.s42-footer {
  margin-top: auto;
  background: #faf8f5;
  font-family: var(--s42-font-sans);
}

.s42-page {
  flex: 1 0 auto;
  padding-top: var(--s42-page-top, 0);
  padding-bottom: var(--s42-page-bottom, 2rem);
}

body:not(.s42-landing):not(.s42-home-bootstrap) .s42-page .card,
body:not(.s42-landing):not(.s42-home-bootstrap) .s42-page .s42-panel,
body:not(.s42-landing):not(.s42-home-bootstrap) .s42-page .s42-tool-frame {
  background: #fff;
  border-radius: 0.75rem;
  border: 1px solid rgba(20, 19, 26, 0.08);
  box-shadow: 0 0.125rem 0.25rem rgba(20, 19, 26, 0.08);
}

body.s42-home-bootstrap {
  --s42-page-top: 0.65rem;
  --s42-page-bottom: 1.85rem;
  background:
    radial-gradient(1200px 360px at -8% -15%, rgba(229, 102, 47, 0.14), transparent 58%),
    radial-gradient(900px 320px at 102% -10%, rgba(30, 127, 109, 0.16), transparent 56%),
    #f5f7fb;
}

.s42-home .s42-page {
  position: relative;
}

.s42-home .s42-page > main {
  position: relative;
  z-index: 1;
}

.s42-hero-card {
  border-radius: 1rem;
  overflow: hidden;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.88)),
    radial-gradient(circle at 15% 18%, rgba(242, 177, 52, 0.22), transparent 52%),
    radial-gradient(circle at 90% 90%, rgba(30, 127, 109, 0.18), transparent 52%);
  animation: s42-fade-up 0.45s ease both;
}

.s42-side-card {
  border-radius: 1rem;
  animation: s42-fade-up 0.55s ease both;
}

.s42-kpis {
  row-gap: 0.65rem;
}

.s42-kpi-card {
  height: 100%;
  border: 1px solid rgba(20, 19, 26, 0.08);
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.78);
  padding: 0.55rem 0.65rem;
  display: grid;
  gap: 0.2rem;
}

.s42-kpi-card i {
  color: var(--s42-accent-2);
  font-size: 0.9rem;
}

.s42-kpi-card strong {
  font-size: 1.03rem;
  line-height: 1.1;
}

.s42-kpi-card span {
  font-size: 0.72rem;
  color: var(--s42-ink-faint);
}

.s42-category-block {
  animation: s42-fade-up 0.45s ease both;
}

.s42-tool-card {
  border-radius: 0.95rem;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.s42-tool-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 32px rgba(20, 19, 26, 0.14) !important;
}

.s42-tool-card-locked {
  opacity: 0.8;
}

.s42-tool-card-locked .btn,
.s42-tool-card-locked .badge {
  filter: saturate(0.8);
}

.s42-tool-avatar {
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 0.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(229, 102, 47, 0.18), rgba(30, 127, 109, 0.16));
  color: var(--s42-accent-2);
  flex-shrink: 0;
}

.s42-tool-avatar i {
  font-size: 1rem;
}

.s42-animate-up {
  animation: s42-fade-up 0.45s ease both;
}

.s42-auth-page {
  --s42-page-top: 1.1rem;
  --s42-page-bottom: 2.1rem;
}

.s42-auth-main,
.s42-admin-main {
  position: relative;
  z-index: 1;
}

.s42-auth-card {
  border-radius: 1rem;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.9)),
    radial-gradient(circle at 12% 8%, rgba(242, 177, 52, 0.2), transparent 48%);
}

.s42-auth-icon,
.s42-admin-icon {
  width: 2.55rem;
  height: 2.55rem;
  border-radius: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(229, 102, 47, 0.2), rgba(30, 127, 109, 0.18));
  color: var(--s42-accent-2);
  font-size: 1rem;
  flex-shrink: 0;
}

.s42-auth-page .form-control:focus,
.s42-admin-page .form-control:focus,
.s42-admin-page .form-select:focus,
.s42-admin-page .form-check-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(30, 127, 109, 0.18);
  border-color: rgba(30, 127, 109, 0.42);
}

.s42-admin-page {
  --s42-page-top: 1rem;
  --s42-page-bottom: 2rem;
}

.s42-admin-hero {
  border-radius: 1rem;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.9)),
    radial-gradient(circle at 12% 8%, rgba(30, 127, 109, 0.2), transparent 48%);
}

.s42-admin-card {
  border-radius: 1rem;
}

.s42-admin-accordion .accordion-item {
  border-radius: 0.9rem;
}

.s42-admin-accordion .accordion-button {
  font-weight: 600;
  background: #fff;
  box-shadow: none;
  border: 0;
}

.s42-admin-accordion .accordion-button:not(.collapsed) {
  color: var(--s42-ink);
  background: rgba(30, 127, 109, 0.08);
}

.s42-admin-accordion .accordion-button:focus {
  box-shadow: inset 0 0 0 2px rgba(30, 127, 109, 0.2);
}

.s42-tools-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.55rem;
}

.s42-check-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid rgba(20, 19, 26, 0.1);
  border-radius: 0.65rem;
  background: rgba(255, 255, 255, 0.82);
}

.s42-check-chip .form-check-input {
  margin-top: 0;
}

.s42-check-chip .form-check-label {
  font-size: 0.88rem;
}

@keyframes s42-fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Landing pages (login/admin) */
.s42-landing {
  font-family: var(--s42-font-sans);
  background: var(--s42-bg);
  color: var(--s42-ink);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.s42-landing::before,
.s42-landing::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(0px);
  opacity: 0.25;
  z-index: 0;
}

.s42-landing::before {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle at 30% 30%, var(--s42-accent-3), transparent 60%);
  top: -120px;
  right: -140px;
}

.s42-landing::after {
  width: 520px;
  height: 520px;
  background: radial-gradient(circle at 40% 40%, var(--s42-accent-2), transparent 60%);
  bottom: 0;
  left: -180px;
}

@media (max-width: 1199.98px) {
  .s42-tools-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 991.98px) {
  .s42-header .navbar {
    padding: 0.35rem 0;
  }

  .s42-tools-menu {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
  }

  .s42-nav-link {
    display: inline-flex;
    width: 100%;
    justify-content: flex-start;
  }

  .s42-user-bar {
    border-top: 1px dashed rgba(20, 19, 26, 0.12);
    margin-top: 0.65rem;
    padding-top: 0.75rem;
  }
}

@media (max-width: 767.98px) {
  .s42-container {
    padding: 0 1rem;
  }

  .s42-brand-sub {
    display: none;
  }

  .s42-kpi-card {
    padding: 0.5rem 0.55rem;
  }

  .s42-tool-avatar {
    width: 2.05rem;
    height: 2.05rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .s42-header,
  .s42-footer {
    display: none !important;
  }
}
