:root {
  color-scheme: dark;
  --bg: #070807;
  --panel: rgba(18, 20, 18, 0.82);
  --panel-strong: #111411;
  --text: #f4f6f0;
  --muted: #9aa197;
  --line: rgba(255, 255, 255, 0.1);
  --field: rgba(255, 255, 255, 0.055);
  --accent: #52ff55;
  --accent-soft: rgba(82, 255, 85, 0.14);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.light {
  color-scheme: light;
  --bg: #f7f8f4;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: #ffffff;
  --text: #101210;
  --muted: #697063;
  --line: rgba(0, 0, 0, 0.1);
  --field: rgba(0, 0, 0, 0.045);
  --accent-soft: rgba(49, 207, 53, 0.14);
  --shadow: 0 24px 80px rgba(12, 20, 12, 0.12);
}

.home-stage,
.remote-admin {
  min-height: calc(100vh - 104px);
  display: grid;
  align-items: center;
}

.home-hero,
.admin-login {
  max-width: 780px;
  padding: 48px 0 72px;
}

.home-hero h1,
.admin-login h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(42px, 7vw, 92px);
  line-height: 0.94;
}

.home-hero p,
.admin-login p {
  max-width: 580px;
  color: var(--muted);
}

.home-link {
  display: inline-flex;
  margin-top: 18px;
  text-decoration: none;
}

.admin-shell {
  max-width: 1380px;
}

.login-form {
  display: grid;
  gap: 12px;
  max-width: 380px;
  margin-top: 26px;
}

.login-form label {
  color: var(--muted);
  font-size: 0.9rem;
}

.remote-admin-panel {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 18px;
  align-items: start;
  width: 100%;
}

.admin-list-panel,
.submission-detail {
  min-height: 70vh;
}

.admin-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.admin-panel-head h2 {
  margin: 4px 0 0;
}

.client-list {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
}

.client-button {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  text-align: left;
}

.client-button.active {
  border-color: rgba(82, 255, 85, 0.7);
  background: var(--accent-soft);
}

.client-button small {
  display: grid;
  place-items: center;
  min-width: 28px;
  min-height: 28px;
  border-radius: 999px;
  background: var(--field);
  color: var(--muted);
}

.detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 14px;
}

.danger {
  min-height: 42px;
  border: 1px solid rgba(255, 95, 95, 0.44);
  border-radius: var(--radius);
  background: rgba(255, 95, 95, 0.1);
  color: #ff8d8d;
  padding: 0 16px;
}

.raw-payload {
  margin-top: 20px;
  color: var(--muted);
}

.raw-payload pre {
  max-height: 360px;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: pre-wrap;
}

@media (max-width: 820px) {
  .home-hero h1,
  .admin-login h1 {
    font-size: 44px;
  }

  .remote-admin-panel {
    grid-template-columns: 1fr;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 0%, rgba(82, 255, 85, 0.12), transparent 30rem),
    linear-gradient(145deg, var(--bg), #0e110e 58%, var(--bg));
  color: var(--text);
  font-family: var(--font);
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0 18px;
  backdrop-filter: blur(16px);
}

.brand,
.nav-actions,
.client-card,
.admin-hero,
.submission-list,
.submission-detail,
.form-stage,
.progress-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 8px 12px 8px 8px;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}

.brand img,
.client-card img {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.nav-actions {
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: var(--radius);
}

.ghost,
.icon-button,
.secondary,
.primary {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
  text-decoration: none;
}

.ghost.active,
.ghost:hover {
  background: var(--field);
  color: var(--text);
}

.icon-button {
  width: 42px;
  background: var(--field);
  color: var(--text);
}

.primary {
  background: var(--accent);
  color: #050705;
  border-color: transparent;
  font-weight: 800;
  padding: 0 20px;
}

.secondary {
  background: var(--field);
  color: var(--text);
  padding: 0 16px;
}

.primary:hover,
.secondary:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: rise 300ms ease both;
}

#formView {
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
}

#formView.active {
  display: grid;
}

.progress-panel {
  position: sticky;
  top: 84px;
  align-self: start;
  border-radius: var(--radius);
  padding: 16px;
}

.client-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
  padding: 14px;
  border-radius: var(--radius);
  box-shadow: none;
}

.client-card h1,
.admin-hero h2,
.step h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 54px);
  line-height: 0.98;
  letter-spacing: 0;
}

.client-card p,
.admin-hero p,
.step p,
.empty-state p {
  color: var(--muted);
  line-height: 1.55;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin: 22px 0 10px;
  color: var(--muted);
}

.progress-copy strong {
  color: var(--text);
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--field);
}

#progressFill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #d8ffda);
  transition: width 260ms ease;
}

.step-list {
  display: grid;
  gap: 6px;
  margin: 18px 0;
  padding: 0;
  list-style: none;
}

.step-list button {
  width: 100%;
  min-height: 36px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 0 10px;
}

.step-list button.active,
.step-list button:hover {
  background: var(--field);
  color: var(--text);
}

.save-state {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

#saveDot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 18px var(--accent);
}

.form-stage {
  min-height: 72vh;
  border-radius: var(--radius);
  overflow: hidden;
}

#discoveryForm {
  display: flex;
  min-height: 72vh;
  flex-direction: column;
}

#stepMount {
  flex: 1;
}

.step {
  padding: clamp(24px, 5vw, 68px);
  animation: rise 280ms ease both;
}

.step-header {
  max-width: 780px;
  margin-bottom: 28px;
}

.step-header p {
  font-size: 17px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--field);
  color: var(--muted);
  font-size: 13px;
}

.fields {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 9px;
}

.field label,
.field-label {
  color: var(--text);
  font-weight: 760;
}

.hint {
  color: var(--muted);
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--text);
  outline: none;
  padding: 14px 15px;
  transition: border-color 180ms ease, background 180ms ease;
}

textarea {
  min-height: 118px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: rgba(82, 255, 85, 0.65);
  background: var(--panel-strong);
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.choice {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  padding: 13px 14px;
  color: var(--text);
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice:has(input:checked) {
  border-color: rgba(82, 255, 85, 0.72);
  background: var(--accent-soft);
}

.choice:hover {
  transform: translateY(-1px);
}

.conditional,
.followups {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.follow-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--field);
}

.form-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding: 16px;
  background: rgba(0, 0, 0, 0.08);
}

.form-footer .secondary:first-child {
  margin-right: auto;
}

.completion {
  display: grid;
  place-items: center;
  min-height: 58vh;
  text-align: center;
}

.completion-inner {
  max-width: 660px;
}

.completion-mark {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  margin: 0 auto 22px;
  border-radius: 999px;
  background: var(--accent);
  color: #050705;
  font-size: 36px;
  font-weight: 900;
}

.admin-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  border-radius: var(--radius);
  padding: clamp(22px, 4vw, 44px);
}

.admin-hero h2 {
  font-size: clamp(32px, 5vw, 64px);
}

.admin-actions {
  display: flex;
  gap: 10px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.submission-list,
.submission-detail {
  min-height: 520px;
  border-radius: var(--radius);
  padding: 16px;
}

.admin-list-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 16px;
}

.search-row {
  margin-bottom: 12px;
}

.submission-button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--text);
  padding: 14px;
  text-align: left;
  margin-bottom: 10px;
}

.submission-button.active {
  border-color: rgba(82, 255, 85, 0.7);
}

.submission-button strong,
.submission-button small {
  display: block;
}

.submission-button small {
  margin-top: 5px;
  color: var(--muted);
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.summary-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.summary-brand img {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 11px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.response-section {
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}

.response-section h4 {
  margin: 0 0 12px;
}

.response-item {
  display: grid;
  gap: 4px;
  margin: 0 0 12px;
}

.response-item span {
  color: var(--muted);
  font-size: 13px;
}

.response-item strong {
  white-space: pre-wrap;
  line-height: 1.45;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 460px;
  text-align: center;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  :root {
    --mobile-footer-space: calc(96px + env(safe-area-inset-bottom));
  }

  .view.active,
  .step {
    animation: none;
    transform: none;
  }

  body {
    padding-bottom: var(--mobile-footer-space);
  }

  .shell {
    padding: 8px 10px 0;
  }

  .topbar {
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 6px 0 8px;
  }

  .admin-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-actions {
    width: 100%;
  }

  .admin-actions > * {
    flex: 1;
  }

  .brand {
    flex: 1;
    padding: 7px;
  }

  .brand img {
    width: 34px;
    height: 34px;
  }

  .brand strong {
    font-size: 16px;
  }

  .brand small {
    font-size: 11px;
  }

  .nav-actions {
    flex: 0 0 auto;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  .icon-button {
    width: 42px;
    min-height: 42px;
  }

  #formView.active,
  .admin-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .progress-panel {
    position: static;
    display: grid;
    gap: 10px;
    padding: 10px;
    box-shadow: none;
  }

  .step-list {
    display: none;
  }

  .client-card {
    grid-template-columns: auto 1fr;
    gap: 10px;
    padding: 10px;
  }

  .client-card img {
    width: 34px;
    height: 34px;
  }

  .client-card .eyebrow {
    margin-bottom: 4px;
    font-size: 10px;
  }

  .client-card h1 {
    font-size: clamp(22px, 7vw, 30px);
    line-height: 1.02;
  }

  .client-card p:not(.eyebrow) {
    display: none;
  }

  .progress-copy {
    margin: 2px 0 0;
    font-size: 14px;
  }

  .progress-track {
    height: 5px;
  }

  .save-state {
    font-size: 12px;
  }

  .form-stage,
  #discoveryForm {
    min-height: 0;
    overflow: visible;
  }

  #stepMount {
    padding-bottom: var(--mobile-footer-space);
  }

  .step {
    padding: 22px 16px 28px;
  }

  .step-header {
    margin-bottom: 18px;
  }

  .step h2 {
    font-size: clamp(32px, 11vw, 44px);
    line-height: 1;
  }

  .step-header p {
    font-size: 16px;
    line-height: 1.42;
  }

  .meta-row {
    margin-top: 16px;
  }

  .pill {
    min-height: 30px;
    font-size: 12px;
  }

  .form-footer {
    position: fixed;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 10px;
    z-index: 40;
    flex-wrap: nowrap;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 8px;
    background: rgba(7, 8, 7, 0.92);
    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.46);
    backdrop-filter: blur(18px);
  }

  .form-footer button {
    flex: 1;
    min-width: 0;
    min-height: 48px;
    padding: 0 12px;
    white-space: nowrap;
  }

  .form-footer .secondary:first-child {
    margin-right: 0;
  }

  .form-footer #saveBtn,
  .form-footer button:disabled {
    display: none;
  }
}

@media print {
  .topbar,
  .progress-panel,
  .submission-list,
  .admin-list-panel,
  .admin-hero,
  .form-stage,
  .detail-actions,
  .no-print {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  .shell,
  .admin-grid,
  .submission-detail {
    display: block;
    width: 100%;
    box-shadow: none;
    border: 0;
    padding: 0;
  }

  #adminView,
  #adminView.active {
    display: block;
  }
}
