:root {
  color-scheme: light;
  --ink: #1c2721;
  --muted: #66736a;
  --line: #ded8c7;
  --soft: #f7f2e6;
  --panel: #fffdf6;
  --paper: #f4efe2;
  --accent: #285338;
  --accent-dark: #173923;
  --rose: #bd8377;
  --gold: #b87918;
  --blue: #315f73;
  --shadow: 0 22px 60px rgba(31, 45, 35, 0.12);
  --radius: 22px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "DM Sans", ui-rounded, "Avenir Next", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 0%, rgba(189, 131, 119, 0.18), transparent 28rem),
    linear-gradient(180deg, rgba(40, 83, 56, 0.12), transparent 24rem),
    var(--paper);
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: 100%;
  margin: 0 auto;
  padding: 0 clamp(16px, 2vw, 28px);
}

.topbar,
.section-head.row,
.actions,
.workflow,
.split,
.upload-actions,
.selected-dataset {
  display: flex;
  align-items: center;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: clamp(24px, 5vw, 72px);
  min-height: 210px;
  margin-bottom: 18px;
  margin-right: calc(-1 * clamp(16px, 2vw, 28px));
  margin-left: calc(-1 * clamp(16px, 2vw, 28px));
  padding: clamp(24px, 4vw, 54px);
  border: 0;
  border-radius: 0;
  color: #fbf7ec;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 100%) 0 50% / 56px 1px repeat-x,
    linear-gradient(135deg, var(--accent-dark), var(--accent));
  box-shadow: none;
  overflow: hidden;
  position: relative;
}

.topbar-nav-mark {
  position: absolute;
  z-index: 1;
  top: 30px;
  left: clamp(38px, 5vw, 78px);
}

.topbar-copy {
  position: relative;
  z-index: 1;
  max-width: 1120px;
}

.brand-mark {
  display: block;
  width: 40px;
  height: auto;
}

.topbar-kicker {
  margin: 0 0 20px;
  color: #c8d9c0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.04rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.home-headline {
  max-width: 1080px;
  color: #e8f0e0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  font-weight: 500;
  line-height: 1.22;
}

.workflow-title {
  display: none;
}

.topbar-description {
  max-width: 780px;
  margin: 28px 0 0;
  color: rgba(232, 240, 224, 0.68);
  font-size: 1.08rem;
  font-weight: 560;
  line-height: 1.65;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 42px;
}

.topbar-actions .primary,
.topbar-actions .secondary {
  min-width: 180px;
  min-height: 52px;
  border-radius: 8px;
}

.topbar-actions .primary {
  color: var(--accent-dark);
  background: #e8f0e0;
  box-shadow: none;
}

.topbar-actions .secondary {
  border-color: rgba(255, 253, 246, 0.18);
  color: #c8d9c0;
  background: transparent;
}

.topbar-actions .primary:hover {
  color: #0f2e1c;
  border-color: #fffdf0;
  background: #fffdf0;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

.topbar-actions .secondary:hover {
  border-color: rgba(255, 253, 246, 0.42);
  color: #fffdf0;
  background: rgba(255, 253, 246, 0.1);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.16);
  transform: translateY(-2px);
}

body.home-view {
  background: var(--panel);
}

body.home-view .shell {
  padding-right: 0;
  padding-left: 0;
}

body.home-view .topbar,
body.home-view .site-footer {
  margin-right: 0;
  margin-left: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

body.home-view .topbar {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  min-height: min(620px, calc(100vh - 56px));
  margin-bottom: 0;
  padding: clamp(90px, 8vw, 118px) clamp(38px, 5vw, 78px) clamp(54px, 8vw, 92px);
}

body.home-view .landing-panel {
  padding-right: clamp(40px, 6vw, 88px);
  padding-left: clamp(40px, 6vw, 88px);
}

body.home-view .site-footer {
  margin-top: 0;
}

.topbar::after {
  display: none;
  content: "";
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 1;
  max-width: 780px;
  font-weight: 760;
}

h2 {
  font-size: 1.15rem;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: max-content;
  color: var(--muted);
  font-size: 0.92rem;
}

body:not(.home-view) .topbar-kicker,
body:not(.home-view) .home-headline,
body:not(.home-view) .topbar-description,
body:not(.home-view) .topbar-actions {
  display: none;
}

body:not(.home-view) .topbar {
  min-height: 210px;
  grid-template-columns: 1fr;
}

body:not(.home-view) .topbar-nav-mark {
  position: relative;
  top: auto;
  left: auto;
  margin-bottom: 14px;
}

body:not(.home-view) .workflow-title {
  display: block;
}

.home-link {
  position: relative;
  z-index: 1;
  min-height: 38px;
  margin-top: 18px;
  padding: 0 18px;
  border-color: rgba(255, 253, 246, 0.28);
  color: #fbf7ec;
  background: rgba(255, 253, 246, 0.08);
}

.home-link:hover {
  border-color: rgba(255, 253, 246, 0.5);
  background: rgba(255, 253, 246, 0.14);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--gold);
}

.site-footer {
  display: grid;
  gap: 22px;
  margin-top: 28px;
  margin-right: calc(-1 * clamp(16px, 2vw, 28px));
  margin-left: calc(-1 * clamp(16px, 2vw, 28px));
  padding: clamp(24px, 4vw, 46px);
  border: 0;
  border-radius: 0;
  color: rgba(255, 253, 246, 0.78);
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  box-shadow: none;
}

.site-footer .eyebrow {
  color: rgba(255, 253, 246, 0.72);
}

.footer-disclaimer {
  max-width: 980px;
  margin: 10px auto 0;
  text-align: center;
}

.footer-disclaimer p:last-child {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 560;
  line-height: 1.55;
}

.footer-contact {
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
}

.email-link {
  display: inline-flex;
  align-items: center;
  color: #fbf7ec;
  font-size: 0.96rem;
  font-weight: 560;
  text-decoration: none;
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: rgba(255, 253, 246, 0.68);
  font-size: 0.86rem;
  font-weight: 560;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  color: rgba(255, 253, 246, 0.82);
  text-decoration: none;
}

.footer-links a:hover,
.email-link:hover {
  color: white;
}

.workflow {
  position: sticky;
  top: 10px;
  z-index: 10;
  padding: 10px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 246, 0.82);
  box-shadow: 0 12px 34px rgba(31, 45, 35, 0.08);
  backdrop-filter: blur(14px);
}

.flow-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 700;
  border-radius: 999px;
  white-space: nowrap;
  transition: color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.flow-step:hover,
.flow-step:focus-visible {
  color: var(--accent-dark);
  background: rgba(40, 83, 56, 0.07);
  outline: none;
}

.flow-step span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
}

.flow-step.active {
  color: var(--accent-dark);
  background: #efe7d4;
}

.flow-step.active span {
  color: white;
  border-color: var(--accent);
  background: var(--accent);
}

.flow-line {
  height: 1px;
  flex: 1;
  margin: 0 12px;
  background: var(--line);
}

.workspace {
  display: block;
}

.launch-callout {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding: 14px 18px;
  border: 1px solid rgba(40, 83, 56, 0.18);
  border-radius: 22px;
  color: var(--accent-dark);
  background: linear-gradient(135deg, rgba(239, 231, 212, 0.92), rgba(255, 253, 246, 0.92));
  box-shadow: 0 12px 28px rgba(31, 45, 35, 0.08);
}

.launch-callout span {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  color: #fbf7ec;
  background: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.launch-callout p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.35;
}

.landing-page,
.analysis-page {
  display: block;
}

.landing-panel {
  padding: clamp(34px, 5vw, 72px) clamp(22px, 3vw, 48px);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.landing-copy h2 {
  max-width: 860px;
  font-size: clamp(1.8rem, 4vw, 3.6rem);
  line-height: 1.02;
}

.landing-copy p,
.builder-profile p,
.analysis-card p {
  color: var(--muted);
  font-weight: 650;
  line-height: 1.55;
}

.builder-profile {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.42fr);
  gap: clamp(24px, 4vw, 52px);
  align-items: center;
  margin: 0 clamp(22px, 5vw, 78px);
  padding: clamp(22px, 4vw, 42px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(135deg, #efe7d4, rgba(255, 253, 246, 0.86));
  box-shadow: 0 18px 44px rgba(18, 47, 30, 0.06);
}

.builder-profile-photo {
  grid-column: 2;
  justify-self: end;
  width: min(100%, 340px);
  margin: 0;
}

.builder-profile-photo img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(520px, 62vh);
  border-radius: 14px;
  object-fit: contain;
  box-shadow: 0 18px 40px rgba(31, 45, 35, 0.14);
}

.builder-profile-copy {
  grid-column: 1;
  grid-row: 1;
  max-width: 760px;
}

.builder-profile-copy h2 {
  margin: 0;
  color: var(--accent-dark);
  font-size: clamp(1.65rem, 3vw, 2.7rem);
  line-height: 1.08;
}

.builder-profile-copy p {
  margin: 16px 0 0;
  max-width: 680px;
}

.builder-profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  margin-top: 22px;
}

.builder-profile-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 8px;
  color: #fbf7ec;
  background: var(--accent);
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.builder-profile-actions a:hover {
  background: var(--accent-dark);
  box-shadow: 0 14px 34px rgba(31, 45, 35, 0.14);
  transform: translateY(-2px);
}

.builder-profile-actions span {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 760;
}

.builder-profile-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 180px));
  gap: 16px;
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.builder-profile-stats strong,
.builder-profile-stats span {
  display: block;
}

.builder-profile-stats strong {
  color: var(--accent-dark);
  font-size: 1.1rem;
}

.builder-profile-stats span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.landing-section {
  padding: clamp(36px, 6vw, 76px) clamp(22px, 5vw, 78px);
}

.landing-section-head {
  max-width: 840px;
  margin-bottom: 28px;
}

.landing-section-head.compact {
  margin-bottom: 22px;
}

.landing-section-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.8rem, 3vw, 3rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.landing-section-head p {
  max-width: 720px;
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 650;
  line-height: 1.55;
}

.feature-grid,
.audience-grid {
  display: grid;
  gap: 16px;
}

.feature-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.audience-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.feature-card,
.audience-card {
  min-height: 220px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 246, 0.78);
  box-shadow: 0 18px 44px rgba(18, 47, 30, 0.06);
}

.audience-card {
  min-height: 190px;
  padding: 18px 20px;
}

.feature-card h3,
.audience-card h3 {
  margin: 14px 0 10px;
  color: var(--accent-dark);
  font-size: 1.2rem;
  line-height: 1.2;
}

.feature-card p,
.audience-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 650;
  line-height: 1.5;
}

.feature-tag,
.audience-card span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.feature-tag.live {
  color: #fffdf6;
  background: var(--accent);
}

.feature-tag.soon {
  color: var(--accent-dark);
  border: 1px solid var(--line);
  background: var(--soft);
}

.audience-card span {
  color: var(--accent-dark);
  border: 1px solid var(--line);
  background: var(--soft);
}

.landing-divider {
  height: 1px;
  margin-bottom: 34px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}

.landing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  grid-column: 1 / -1;
}

.landing-actions button {
  min-width: 190px;
  min-height: 52px;
}

.analysis-panel {
  padding: clamp(18px, 2vw, 26px);
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
  margin-bottom: 16px;
}

.analysis-card {
  display: grid;
  gap: 8px;
  min-height: 180px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--soft);
}

.analysis-card span {
  color: var(--rose);
  font-weight: 900;
}

.analysis-card strong {
  color: var(--accent-dark);
  font-size: 1.1rem;
}

.dataset-step {
  padding: clamp(18px, 2vw, 26px);
  margin-bottom: 18px;
}

.dataset-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.dataset-column {
  display: grid;
  gap: 12px;
}

.dataset-column h3 {
  margin: 0 0 4px;
  padding: 14px 18px;
  border: 1px solid rgba(40, 83, 56, 0.16);
  border-radius: var(--radius-sm);
  color: var(--accent-dark);
  background: #efe7d4;
  font-size: 1.08rem;
  letter-spacing: 0;
}

.dataset-divider {
  align-self: stretch;
  min-height: 100%;
  background: var(--line);
}

.dataset-card {
  min-height: 118px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  text-align: left;
  background: rgba(255, 253, 246, 0.78);
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.dataset-card:hover,
.dataset-card:focus-visible {
  border-color: var(--accent);
  outline: 2px solid rgba(40, 83, 56, 0.16);
  outline-offset: 0;
  background: white;
  box-shadow: 0 16px 34px rgba(31, 45, 35, 0.1);
  transform: translateY(-1px);
}

.dataset-card strong,
.dataset-card span {
  display: block;
}

.dataset-card strong {
  margin-bottom: 8px;
  font-size: 1rem;
}

.dataset-card span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.35;
}

.selected-dataset {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--soft);
}

.selected-dataset label {
  width: 100%;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel:focus,
.cleaning-page:focus {
  outline: none;
}

.intake,
.output,
.cleaning {
  padding: 20px;
}

.output,
.cleaning {
  margin-top: 18px;
}

.section-head {
  margin-bottom: 18px;
}

.section-head.row {
  justify-content: space-between;
  gap: 14px;
}

.panel > .section-head.row {
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 0;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel > .section-head.row > div:first-child {
  flex: 1 1 280px;
  min-width: 0;
}

.panel > .section-head.row .actions {
  flex: 1 1 460px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  overflow: hidden;
}

.source-toggle {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  overflow: hidden;
}

.mode-btn {
  min-height: 44px;
  border-radius: 999px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.mode-btn.active {
  color: white;
  background: var(--accent);
}

.mode-panel {
  display: none;
}

.mode-panel.active {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  color: var(--ink);
  background: rgba(255, 253, 246, 0.94);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

input:focus,
select:focus {
  border-color: var(--accent);
  background: white;
  box-shadow: 0 0 0 4px rgba(40, 83, 56, 0.12);
  outline: none;
}

.split {
  gap: 12px;
}

.split > * {
  flex: 1;
}

button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(40, 83, 56, 0.14);
}

.primary {
  color: white;
  background: var(--accent);
  box-shadow: 0 10px 24px rgba(40, 83, 56, 0.16);
}

.primary:hover,
.mode-btn.active:hover {
  background: var(--accent-dark);
}

.primary:focus-visible,
.secondary:focus-visible,
.icon-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(40, 83, 56, 0.14);
}

.secondary,
.icon-btn {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(255, 253, 246, 0.9);
}

.secondary:hover,
.icon-btn:hover {
  border-color: var(--accent);
  background: white;
  box-shadow: 0 8px 20px rgba(31, 45, 35, 0.08);
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  position: absolute;
  z-index: 20;
  bottom: calc(100% + 8px);
  left: 50%;
  width: max-content;
  max-width: min(320px, calc(100vw - 32px));
  padding: 8px 10px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: white;
  box-shadow: 0 8px 20px rgba(16, 24, 40, 0.14);
  content: attr(data-tooltip);
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.3;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 0.16s ease 0.55s, transform 0.16s ease 0.55s;
  white-space: pre-line;
  overflow-wrap: anywhere;
  text-align: left;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after,
[data-tooltip].tooltip-open::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.info-dot[data-tooltip]::after {
  right: 0;
  left: auto;
  min-width: 220px;
  text-align: left;
  transform: translate(0, 4px);
}

.info-dot[data-tooltip]:hover::after,
.info-dot[data-tooltip]:focus-visible::after,
.info-dot[data-tooltip].tooltip-open::after {
  transform: translate(0, 0);
}

.saved-table-actions [data-tooltip]::after {
  right: 0;
  left: auto;
  width: 300px;
  transform: translate(0, 4px);
}

.saved-table-actions [data-tooltip]:hover::after,
.saved-table-actions [data-tooltip]:focus-visible::after,
.saved-table-actions [data-tooltip].tooltip-open::after {
  transform: translate(0, 0);
}

.cleaning-page .actions [data-tooltip]::after {
  top: calc(100% + 8px);
  bottom: auto;
  width: 320px;
  transform: translate(-50%, -4px);
}

.cleaning-page .actions [data-tooltip]:hover::after,
.cleaning-page .actions [data-tooltip]:focus-visible::after,
.cleaning-page .actions [data-tooltip].tooltip-open::after {
  transform: translate(-50%, 0);
}

.danger {
  color: #9f1d1d;
  border-color: #e7b8b8;
  background: #fff7f7;
}

.danger:hover {
  border-color: #c24141;
}

.dialog-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.38);
}

.dialog-card {
  display: grid;
  gap: 14px;
  width: min(520px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(16, 24, 40, 0.24);
}

#site-message-dialog .dialog-card {
  width: min(640px, calc(100vw - 40px));
}

.dialog-card.wide-dialog {
  width: min(760px, calc(100vw - 40px));
}

#site-message-dialog .compact-head {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

#site-message-body {
  font-weight: 560;
  line-height: 1.5;
  white-space: pre-line;
}

#site-message-body strong {
  color: var(--ink);
  font-weight: 800;
}

.format-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.format-actions.two-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.acknowledgement-box {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(251, 246, 234, 0.78);
}

.acknowledgement-box p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.45;
}

.acknowledgement-box label {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.acknowledgement-box textarea {
  min-height: 96px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.45;
}

.file-drop {
  min-height: 172px;
  place-items: center;
  padding: 22px;
  border: 1px dashed rgba(40, 83, 56, 0.44);
  border-radius: var(--radius-sm);
  color: var(--ink);
  text-align: center;
  background: #fbf6ea;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.file-drop:hover {
  border-color: var(--accent);
  background: #fffdf6;
}

.compact-file-drop {
  min-height: 82px;
  padding: 14px;
}

.file-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.file-drop span {
  max-width: 260px;
  color: var(--muted);
  font-weight: 500;
}

.upload-actions,
.request-actions,
.actions {
  gap: 10px;
}

.upload-actions button,
.request-actions button {
  flex: 1;
}

.request-actions {
  display: flex;
}

.request-card {
  display: grid;
  gap: 16px;
}

.query-fields {
  display: grid;
  gap: 12px;
  padding-top: 4px;
}

.compact-head {
  margin-bottom: 0;
}

.query-catalog {
  display: grid;
  gap: 14px;
}

.query-block {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 246, 0.82);
  overflow: hidden;
}

.query-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  color: #fbf7ec;
  background: var(--accent);
}

.query-block-header strong {
  font-size: 1rem;
}

.query-block-header span {
  font-size: 0.82rem;
  font-weight: 800;
  opacity: 0.9;
}

.query-section-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 14px;
}

.query-control {
  display: grid;
  gap: 7px;
}

.query-control.wide {
  grid-column: 1 / -1;
}

.query-control select {
  min-height: 42px;
}

.query-control select[multiple] {
  min-height: 150px;
  padding: 8px;
}

.checkbox-grid,
.radio-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  padding: 10px;
  border: 1px solid var(--line);
  background: white;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 700;
}

.check-row input {
  width: auto;
  min-height: auto;
}

.field-note {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.query-item {
  display: grid;
  gap: 2px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e6ebef;
}

.query-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.query-item strong {
  font-size: 0.9rem;
}

.query-item code {
  display: inline;
  width: fit-content;
  padding: 3px 6px;
  font-size: 0.78rem;
}

.query-item span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

code,
pre {
  border: 1px solid var(--line);
  background: var(--soft);
}

code {
  display: block;
  overflow-x: auto;
  padding: 12px;
}

pre {
  min-height: 230px;
  max-height: 360px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  line-height: 1.45;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  max-height: 520px;
  background: white;
}

.hidden {
  display: none !important;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  color: #fbf7ec;
  background: var(--accent);
}

tr:nth-child(even) td {
  background: #fbf7ee;
}

.notes {
  display: grid;
  gap: 4px;
  margin-top: 18px;
  padding: 14px;
  border-left: 4px solid var(--gold);
  background: #fff8ec;
}

.notes span,
.request-card p {
  margin: 0;
  color: var(--muted);
}

.saved-tables {
  display: grid;
  gap: 12px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.saved-status,
.empty-state {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.empty-state {
  margin: 0;
}

.saved-list {
  display: grid;
  gap: 10px;
}

.saved-table-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 246, 0.9);
}

.saved-table-item.selected {
  border-color: var(--accent);
  background: #eef5ed;
}

.saved-select {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.saved-select input {
  width: 18px;
  height: 18px;
}

.saved-table-item strong {
  display: block;
  margin-bottom: 4px;
}

.saved-table-item span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.saved-table-actions {
  display: flex;
  gap: 8px;
}

.saved-selection-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--soft);
}

.saved-selection-bar span {
  color: var(--muted);
  font-weight: 800;
}

.saved-selection-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.compact-action {
  min-height: 42px;
  padding: 0 16px;
}

#continue-cleaning {
  min-width: 170px;
}

.save-name-input {
  width: 180px;
  min-height: 42px;
  padding: 0 10px;
}

.compact-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.cleaning {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(17, 121, 105, 0.1);
}

.cleaning-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.cleaning-grid > div {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--soft);
}

.cleaning-grid strong {
  font-size: 0.92rem;
}

.cleaning-grid span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.4;
}

.cleaning-page {
  display: grid;
  gap: 18px;
  scroll-margin-top: 92px;
}

.cleaning-page-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(0, 1.25fr);
  gap: 18px;
}

.step3-sheet-grid {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.column-cleaner {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  background: white;
}

.column-selection-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.column-selection-grid h3 {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-size: 1rem;
}

.column-option-list {
  display: grid;
  gap: 8px;
}

.column-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--soft);
  font-weight: 800;
}

.column-option input {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.column-option > span:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.column-rename-panel {
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.column-rename-panel h3 {
  margin: 0;
  color: var(--accent-dark);
  font-size: 1rem;
}

.column-rename-list {
  display: grid;
  gap: 8px;
}

.rename-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.9fr) minmax(180px, 1.1fr);
  gap: 10px;
  align-items: center;
}

.rename-grid-head {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rename-row {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--soft);
}

.rename-row span {
  min-width: 0;
  color: var(--ink);
  font-weight: 800;
}

.rename-row input {
  min-height: 40px;
  background: white;
}

.info-dot,
.column-count {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  height: 22px;
  min-width: 22px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-dark);
  background: white;
  font-size: 0.78rem;
  font-weight: 900;
}

.info-dot {
  min-height: 22px;
  cursor: help;
  font-weight: 700;
}

.info-wrap {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
}

.info-tooltip {
  position: absolute;
  z-index: 30;
  right: 0;
  top: calc(100% + 8px);
  width: max-content;
  min-width: 220px;
  max-width: 300px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: white;
  box-shadow: 0 8px 20px rgba(16, 24, 40, 0.14);
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.3;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.16s ease 0.55s, transform 0.16s ease 0.55s;
  white-space: normal;
}

.info-wrap:hover .info-tooltip,
.info-wrap:focus-within .info-tooltip,
.info-wrap.tooltip-open .info-tooltip {
  opacity: 1;
  transform: translateY(0);
}

.info-wrap.tooltip-open .info-tooltip {
  transition-delay: 0s;
}

.subsheet-panel {
  display: grid;
  gap: 12px;
}

.helper-text {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.35;
}

.group-builder {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 10px;
}

.group-builder input {
  min-height: 44px;
  border: 1px solid var(--line);
  padding: 0 12px;
  color: var(--ink);
  background: white;
  font-weight: 650;
}

.step4-upload-tools {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(280px, 1fr);
  gap: 12px;
  align-items: stretch;
}

.source-preview-editor {
  display: grid;
  gap: 12px;
  margin-top: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.tag-column-builder {
  display: grid;
  grid-template-columns: 90px minmax(180px, 1fr) minmax(180px, 1fr) auto;
  gap: 10px;
}

.tag-column-builder input {
  min-height: 44px;
  border: 1px solid var(--line);
  padding: 0 12px;
  color: var(--ink);
  background: white;
  font-weight: 650;
}

.subsheet-list {
  display: grid;
  gap: 10px;
  align-content: start;
}

.sheet-tab-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
}

.subsheet-group {
  display: grid;
  gap: 8px;
}

.subsheet-group > strong {
  color: var(--accent-dark);
  font-size: 0.86rem;
}

.subsheet-card {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--soft);
}

.selectable-card,
.unified-card {
  width: 100%;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.selectable-card:hover,
.selectable-card:focus-visible,
.selectable-card.is-active,
.unified-card:hover,
.unified-card:focus-visible,
.unified-card.is-active {
  border-color: var(--accent);
  background: white;
  outline: none;
  transform: translateY(-1px);
}

.selectable-card.is-active,
.unified-card.is-active {
  box-shadow: inset 4px 0 0 var(--accent);
}

.selectable-card.is-previewed {
  outline: 2px solid var(--rose);
  outline-offset: -2px;
}

.selectable-card.is-active.is-previewed,
.unified-card.is-active.is-previewed {
  border-color: var(--rose);
  box-shadow: inset 4px 0 0 var(--rose);
}

#unified-source-list .selectable-card.is-active {
  border-color: var(--rose);
  box-shadow: inset 4px 0 0 var(--rose);
}

#unified-source-list .selectable-card.is-previewed,
#unified-source-list .selectable-card.is-active.is-previewed {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.subsheet-card span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

@media (max-width: 1180px) {
  .shell {
    padding-right: 16px;
    padding-left: 16px;
  }

  .topbar {
    margin-right: -16px;
    margin-left: -16px;
  }

  body.home-view .topbar {
    grid-template-columns: minmax(0, 1fr);
    min-height: auto;
  }

  .home-headline {
    max-width: 920px;
  }

  .feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .audience-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .builder-profile {
    grid-template-columns: minmax(190px, 0.45fr) minmax(0, 1fr);
  }

  .panel > .section-head.row .actions {
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  .cleaning-page-grid {
    grid-template-columns: 1fr;
  }

  .step4-upload-tools {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .workflow {
    gap: 10px;
    padding: 12px;
  }

  .flow-step {
    min-width: 0;
    font-size: 0.9rem;
  }

  .query-section-body,
  .column-selection-grid {
    grid-template-columns: 1fr;
  }

  .checkbox-grid,
  .radio-grid {
    grid-template-columns: 1fr;
  }

  .group-builder,
  .tag-column-builder {
    grid-template-columns: 1fr;
  }

  .saved-table-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .saved-table-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .table-wrap {
    max-height: min(520px, 62vh);
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 700px) {
  .shell {
    padding-right: 10px;
    padding-left: 10px;
  }

  .topbar {
    margin-right: -10px;
    margin-left: -10px;
  }

  body.home-view .topbar {
    padding: 82px 22px 48px;
  }

  .launch-callout {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
  }

  .topbar-nav-mark {
    left: 22px;
  }

  .home-headline {
    font-size: clamp(2rem, 11vw, 3rem);
  }

  .topbar-description {
    font-size: 1rem;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar-actions .primary,
  .topbar-actions .secondary {
    width: 100%;
  }

  .landing-section,
  .landing-panel,
  .builder-profile {
    padding-right: 18px;
    padding-left: 18px;
  }

  .format-actions {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 560px;
  }

  th,
  td {
    padding: 9px 10px;
  }

  .source-toggle {
    grid-template-columns: 1fr;
    border-radius: var(--radius-sm);
  }

  .mode-toggle {
    border-radius: var(--radius-sm);
  }
}

@media (max-width: 840px) {
  .topbar,
  .workspace,
  .workflow,
  .dataset-columns,
  .landing-panel,
  .builder-profile,
  .analysis-grid,
  .feature-grid,
  .audience-grid {
    display: block;
  }

  .dataset-card {
    width: 100%;
    margin-bottom: 10px;
  }

  .analysis-card,
  .feature-card,
  .audience-card {
    margin-top: 12px;
  }

  .builder-profile {
    margin-right: 18px;
    margin-left: 18px;
  }

  .builder-profile-photo {
    grid-column: auto;
    justify-self: start;
    width: min(100%, 280px);
    margin-bottom: 22px;
  }

  .builder-profile-copy {
    grid-column: auto;
    grid-row: auto;
  }

  .dataset-divider {
    width: 100%;
    height: 1px;
    min-height: 1px;
    margin: 18px 0;
  }

  .status {
    margin-top: 12px;
  }

  .home-link {
    margin-top: 14px;
  }

  .footer-bottom {
    display: grid;
    gap: 10px;
    justify-items: center;
    text-align: center;
  }

  .footer-links {
    justify-content: center;
  }

  .flow-line {
    width: 1px;
    height: 18px;
    margin: 6px 0 6px 14px;
  }

  .intake {
    margin-bottom: 18px;
  }

  .query-section-body,
  .checkbox-grid,
  .radio-grid,
  .column-selection-grid,
  .rename-grid,
  .sheet-tab-grid,
  .cleaning-grid,
  .cleaning-page-grid {
    grid-template-columns: 1fr;
  }

  .saved-table-item,
  .saved-selection-bar {
    display: grid;
  }

  .saved-selection-actions {
    justify-content: stretch;
  }

  .group-builder,
  .step4-upload-tools,
  .saved-selection-actions button {
    width: 100%;
  }

  .group-builder,
  .tag-column-builder,
  .step4-upload-tools {
    grid-template-columns: 1fr;
  }

  .section-head.row {
    align-items: flex-start;
  }

  .actions {
    flex-wrap: wrap;
  }

  .save-name-input {
    width: 100%;
  }

  .saved-table-item,
  .saved-table-actions {
    display: grid;
  }
}

/* Storage warning toast */
.storage-toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  width: min(40rem, calc(100vw - 2rem));
  max-width: calc(100vw - 2rem);
  padding: 0.875rem 1.25rem;
  background: var(--color-warning-bg, #fff3cd);
  border: 1px solid var(--color-warning-border, #ffc107);
  border-radius: 0.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  font-size: 0.875rem;
  line-height: 1.4;
}

.storage-toast p {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.storage-toast button {
  flex-shrink: 0;
  margin-left: auto;
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
  white-space: nowrap;
  border-radius: 0.25rem;
}

@media (max-width: 560px) {
  .storage-toast {
    flex-direction: column;
    gap: 0.75rem;
  }

  .storage-toast button {
    align-self: flex-end;
    margin-left: 0;
  }
}
