/* Demographix Lab — shared app shell (header, layout, icon rail) */
:root {
  --dx-bg: #ffffff;
  --dx-bg-soft: #efece1;
  --dx-ink: #0a0a0a;
  --dx-ink-2: #1a1f24;
  --dx-muted: #525a63;
  --dx-muted-2: #6b7280;
  --dx-hairline: #e7e6df;
  --dx-accent: #0f766e;
  --dx-accent-ink: #0b5a55;
  --dx-accent-soft: #e6f4f3;
  --dx-maxw: 1200px;
  --dx-header-h: 68px;
}

body.dx-shell {
  margin: 0;
  background: var(--dx-bg);
  color: var(--dx-ink);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ===== Site header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--dx-hairline);
}

.site-header .container {
  max-width: var(--dx-maxw);
  margin-inline: auto;
  padding-inline: clamp(20px, 4vw, 40px);
}

.site-header .nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: var(--dx-header-h);
}

.site-header .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--dx-ink);
  font-size: 1rem;
  text-decoration: none;
}

.site-header .brand-logo-frame {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  max-width: 44px;
  padding: 0;
  box-sizing: border-box;
  border-radius: 10px;
  background: var(--dx-accent);
  flex-shrink: 0;
}

.site-header .brand-logo {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: contain;
  transform: translateX(1px);
}

.site-header .brand .brand-mark {
  display: none;
}

.site-header .brand.brand-fallback .brand-logo-frame {
  display: none;
}

.site-header .brand.brand-fallback .brand-mark {
  display: grid;
}

.site-header .brand.brand-fallback .brand-name {
  display: inline;
}

.site-header .brand-name {
  display: inline;
}

.site-header .brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--dx-accent);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1;
}

.site-header .brand-name span {
  color: var(--dx-accent);
}

.site-header .nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.site-header .nav-links > a,
.site-header .nav-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--dx-ink-2);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
}

.site-header .nav-links > a:hover,
.site-header .nav-dropdown-trigger:hover,
.site-header .nav-dropdown.open .nav-dropdown-trigger,
.site-header .nav-dropdown:focus-within .nav-dropdown-trigger {
  background: var(--dx-bg-soft);
  color: var(--dx-ink);
}

.site-header .nav-dropdown {
  position: relative;
}

.site-header .nav-dropdown-trigger {
  gap: 5px;
  border: none;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.site-header .nav-dropdown-chevron {
  width: 14px;
  height: 14px;
  opacity: 0.55;
  transition: transform 0.15s ease;
}

.site-header .nav-dropdown:hover .nav-dropdown-chevron,
.site-header .nav-dropdown.open .nav-dropdown-chevron,
.site-header .nav-dropdown:focus-within .nav-dropdown-chevron {
  transform: rotate(180deg);
}

.site-header .nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  background: #fff;
  border: 1px solid var(--dx-hairline);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
  z-index: 60;
}

.site-header .nav-dropdown:hover .nav-dropdown-menu,
.site-header .nav-dropdown.open .nav-dropdown-menu,
.site-header .nav-dropdown:focus-within .nav-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.site-header .nav-dropdown-menu a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 7px;
  color: var(--dx-ink);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
}

.site-header .nav-dropdown-menu a:hover {
  background: var(--dx-bg-soft);
}

.site-header .nav-dropdown-menu a span {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--dx-muted);
  line-height: 1.35;
}

.site-header .nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.site-header .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1;
  min-height: 42px;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.site-header .btn-primary {
  background: var(--dx-accent);
  color: #fff;
}

.site-header .btn-primary:hover {
  background: var(--dx-accent-ink);
}

.site-header .btn-ghost {
  color: var(--dx-ink-2);
}

.site-header .btn-ghost:hover {
  background: var(--dx-bg-soft);
}

.site-header .btn-outline {
  color: var(--dx-ink);
  border-color: var(--dx-hairline);
}

.site-header .btn-outline:hover {
  border-color: #cfd2d4;
  background: var(--dx-bg-soft);
}

.site-header .nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  color: var(--dx-ink);
  border: none;
  background: none;
  cursor: pointer;
}

.site-header .nav-toggle:hover {
  background: var(--dx-bg-soft);
}

.site-header .nav-toggle .icon-close {
  display: none;
}

.site-header .nav.mobile-open .nav-toggle .icon-open {
  display: none;
}

.site-header .nav.mobile-open .nav-toggle .icon-close {
  display: block;
}

.site-header .mobile-drawer {
  display: none;
}

@media (max-width: 900px) {
  .site-header .nav-links {
    display: none;
  }

  .site-header .nav-actions .btn-ghost,
  .site-header .nav-actions .btn-primary,
  .site-header .nav-actions #auth-container {
    display: none;
  }

  .site-header .nav-toggle {
    display: inline-flex;
  }

  .site-header .nav.mobile-open .mobile-drawer {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: absolute;
    top: var(--dx-header-h);
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid var(--dx-hairline);
    padding: 16px clamp(20px, 4vw, 40px) 20px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
    z-index: 49;
  }

  .site-header .mobile-drawer a {
    padding: 12px 8px;
    border-radius: 8px;
    color: var(--dx-ink-2);
    font-weight: 500;
    text-decoration: none;
  }

  .site-header .mobile-drawer a:hover {
    background: var(--dx-bg-soft);
  }

  .site-header .mobile-drawer-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--dx-muted-2);
    padding: 8px 8px 4px;
  }

  .site-header .mobile-drawer-sublink {
    padding-left: 20px !important;
    font-size: 0.9rem !important;
  }

  .site-header .mobile-drawer .btn {
    margin-top: 8px;
    width: 100%;
  }

  .site-header .nav {
    position: relative;
    flex-wrap: wrap;
  }
}

/* ===== App body layouts ===== */
.dx-app-body {
  min-height: calc(100vh - var(--dx-header-h));
}

.dx-app-main {
  width: 100%;
  max-width: 100%;
  min-height: calc(100vh - var(--dx-header-h) - 48px);
}

body.dx-shell .dx-app-main.main,
body.dx-shell main.dx-app-main {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: none;
}

.dx-app-footer {
  text-align: center;
  padding: 16px;
  color: var(--dx-muted-2);
  font-size: 0.85rem;
  border-top: 1px solid var(--dx-hairline);
}

.dx-app-footer .copyright {
  margin: 0;
}

/* ===== Product landing sections (DxDatabase / DxChat) ===== */
.dx-product-hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.dx-product-hero::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: min(520px, 72vh);
  background:
    radial-gradient(58% 72% at 50% 8%, rgba(15, 118, 110, 0.14), transparent 68%),
    linear-gradient(180deg, rgba(230, 244, 243, 0.72), rgba(255, 255, 255, 0));
  pointer-events: none;
  z-index: -1;
}

.dx-product-section {
  max-width: var(--dx-maxw);
  margin: 0 auto;
  padding: clamp(36px, 6vw, 72px) clamp(20px, 4vw, 40px);
}

.dx-product-section + .dx-product-section {
  padding-top: 0;
}

.dx-product-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--dx-accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.dx-product-title {
  margin: 0;
  color: var(--dx-ink);
  font-size: clamp(1.8rem, 3vw, 2.55rem);
  line-height: 1.12;
  letter-spacing: -0.035em;
}

.dx-product-subtitle {
  max-width: 760px;
  margin: 16px 0 0;
  color: var(--dx-muted);
  font-size: clamp(1rem, 1.35vw, 1.12rem);
  line-height: 1.7;
}

.dx-product-hero .dx-product-subtitle {
  margin-inline: auto;
  text-align: center;
}

.dx-product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.dx-product-card {
  min-height: 178px;
  padding: 24px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.92), rgba(255,255,255,0.76)),
    radial-gradient(80% 60% at 18% 0%, rgba(15, 118, 110, 0.10), transparent 70%);
  box-shadow: 0 1px 0 rgba(10,10,10,0.04), 0 16px 34px rgba(15,23,42,0.07);
}

.dx-product-card h3 {
  margin: 0 0 10px;
  color: var(--dx-ink);
  font-size: 1.08rem;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.dx-product-card p {
  margin: 0;
  color: var(--dx-muted);
  font-size: 0.94rem;
  line-height: 1.65;
}

.dx-product-card-locked {
  border-color: rgba(15, 118, 110, 0.20);
  box-shadow: 0 1px 0 rgba(10,10,10,0.04), 0 18px 44px rgba(15,118,110,0.12);
}

.dx-product-contrast {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.09);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(10,10,10,0.04), 0 22px 52px rgba(15,23,42,0.09);
}

.dx-product-contrast-col {
  padding: clamp(22px, 3vw, 32px);
}

.dx-product-contrast-col + .dx-product-contrast-col {
  border-left: 1px solid rgba(15, 23, 42, 0.08);
  background: linear-gradient(180deg, rgba(230,244,243,0.58), rgba(255,255,255,0.88));
}

.dx-product-contrast h3 {
  margin: 0 0 18px;
  color: var(--dx-ink);
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.dx-product-contrast ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dx-product-contrast li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 0;
  color: var(--dx-muted);
  font-size: 0.95rem;
  line-height: 1.45;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
}

.dx-product-contrast li:first-child {
  border-top: 0;
}

.dx-product-contrast .dx-product-win li {
  color: var(--dx-ink-2);
}

.dx-product-contrast li::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-top: 0.45em;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.22);
  flex: 0 0 auto;
}

.dx-product-contrast .dx-product-win li::before {
  background: var(--dx-accent);
  box-shadow: 0 0 0 4px rgba(15,118,110,0.10);
}

/* ===== Rich footer ===== */
.dx-rich-footer {
  position: relative;
  overflow: hidden;
  border-top: 1px solid rgba(94,234,212,0.16);
  background: linear-gradient(180deg, #111817 0%, #090f0f 72%, #060808 100%);
  color: rgba(255,255,255,0.78);
  padding-block: 56px 30px;
}

.dx-rich-footer::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(62% 70% at 15% 0%, rgba(15,118,110,0.24), transparent 62%),
    radial-gradient(48% 52% at 88% 100%, rgba(94,234,212,0.10), transparent 68%);
  pointer-events: none;
}

.dx-rich-footer-container {
  position: relative;
  z-index: 1;
  max-width: var(--dx-maxw);
  margin: 0 auto;
  padding-inline: clamp(20px, 4vw, 40px);
}

.dx-rich-footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 36px;
}

.dx-rich-footer-brand {
  max-width: 32ch;
  color: rgba(255,255,255,0.68);
  font-size: 0.9rem;
  line-height: 1.6;
}

.dx-rich-footer-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.dx-rich-footer-logo-frame {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--dx-accent);
  box-shadow: 0 0 0 1px rgba(94,234,212,0.18);
}

.dx-rich-footer-logo {
  display: block;
  width: 30px;
  height: 30px;
  object-fit: contain;
  transform: translateX(1px);
}

.dx-rich-footer-name span {
  color: #5eead4;
}

.dx-rich-footer-col h4 {
  margin: 0 0 14px;
  color: rgba(255,255,255,0.48);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dx-rich-footer-col ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.dx-rich-footer-col li {
  margin-bottom: 8px;
}

.dx-rich-footer-col a {
  color: rgba(255,255,255,0.74);
  font-size: 0.9rem;
  text-decoration: none;
}

.dx-rich-footer-col a:hover,
.dx-rich-footer-bar a:hover {
  color: #5eead4;
}

.dx-rich-footer-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding-top: 24px;
  border-top: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.56);
  font-size: 0.84rem;
}

.dx-rich-footer-bar a {
  color: rgba(255,255,255,0.84);
  text-decoration: none;
}

.dx-rich-footer-ext {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dx-rich-footer-ext svg {
  width: 11px;
  height: 11px;
}

body.dxchat-active .dx-chat-landing,
body.dxchat-active .dx-rich-footer {
  display: none;
}

@media (max-width: 820px) {
  .dx-product-grid,
  .dx-product-contrast,
  .dx-rich-footer-grid {
    grid-template-columns: 1fr;
  }

  .dx-product-contrast-col + .dx-product-contrast-col {
    border-left: 0;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
  }
}

/* Workspace with icon rail */
.dx-workspace-layout {
  display: flex;
  min-height: calc(100vh - var(--dx-header-h));
}

.dx-icon-rail {
  flex-shrink: 0;
  width: 56px;
  border-right: 1px solid var(--dx-hairline);
  background: #fbfbfa;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 4px;
  position: sticky;
  top: var(--dx-header-h);
  height: calc(100vh - var(--dx-header-h));
  z-index: 10;
}

.dx-icon-rail a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--dx-muted-2);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.dx-icon-rail a:hover {
  background: var(--dx-accent-soft);
  color: var(--dx-accent);
}

.dx-icon-rail a.active {
  background: var(--dx-accent-soft);
  color: var(--dx-accent);
}

.dx-icon-rail a svg {
  width: 20px;
  height: 20px;
}

.dx-icon-rail .rail-spacer {
  flex: 1;
}

.dx-workspace-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.dx-workspace-main .dx-app-main {
  flex: 1;
}

@media (max-width: 640px) {
  .dx-icon-rail {
    width: 48px;
    padding: 8px 0;
  }

  .dx-icon-rail a {
    width: 36px;
    height: 36px;
  }

  .dx-icon-rail a svg {
    width: 18px;
    height: 18px;
  }
}

/* Auth / marketing pages centered content */
body.dx-shell.dx-auth-page .dx-app-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 16px 48px;
}

body.dx-shell.dx-public-page .dx-app-main {
  max-width: var(--dx-maxw);
  margin-inline: auto;
  padding-inline: clamp(20px, 4vw, 40px);
}

/* DxChat fixed input — full viewport width (no sidebar offset) */
body.dx-shell .aichat-input-area.aichat-input-fixed {
  left: 0 !important;
  right: 0;
}

/* QBuilder cross-link on DxChat welcome */
.dx-qbuilder-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--dx-muted);
  text-decoration: none;
}

.dx-qbuilder-link:hover {
  color: var(--dx-accent);
}

.dx-qbuilder-link svg {
  width: 14px;
  height: 14px;
}
