:root {
  color-scheme: light;
  --bg: #fbfbfc;
  --ink: #181820;
  --muted: #606060;
  --panel: #ffffff;
  --line: #cfcfcf;
  --brand: #7040e8;
  --brand-dark: #4b269e;
  --brand-blue: #002afc;
  --accent: #ffb000;
  --soft: #f3efff;
  --warn: #ffb000;
  --danger: #ff0059;
  --shadow: 0 18px 45px rgba(24, 24, 32, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.shell {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0;
}

.intro {
  margin-bottom: 24px;
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 900px;
  margin-bottom: 12px;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
  letter-spacing: 0;
}

.intro-text {
  max-width: 660px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.5;
}

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

.panel {
  margin-top: 16px;
  padding: 24px;
}

.hidden {
  display: none;
}

label,
.open-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 760;
}

.identity-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input {
  min-height: 48px;
  padding: 0 14px;
}

textarea {
  min-height: 96px;
  padding: 12px 14px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(112, 64, 232, 0.16);
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--brand-dark);
}

button.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

button.ghost:hover {
  background: var(--soft);
}

.hint {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.93rem;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.section-heading.compact {
  margin-bottom: 14px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.mode-card {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 8px;
  width: 100%;
  min-height: 188px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  box-shadow: 0 8px 18px rgba(24, 24, 32, 0.05);
  align-content: start;
}

.mode-card:not(.recommended) small {
  visibility: hidden;
}

.mode-card small {
  justify-self: start;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--accent);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 850;
  line-height: 1;
  text-transform: uppercase;
}

.mode-card.recommended {
  border-color: var(--brand);
  background: linear-gradient(180deg, #f7f4ff 0%, #ffffff 100%);
  box-shadow: 0 12px 24px rgba(112, 64, 232, 0.14);
}

.mode-card.recommended em {
  background: var(--brand-dark);
}

.mode-card:hover {
  border-color: var(--brand);
  background: var(--soft);
  color: var(--ink);
  transform: translateY(-1px);
}

.mode-card:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(112, 64, 232, 0.2);
  outline: none;
}

.mode-card.selected {
  border-color: var(--brand);
  background: var(--soft);
}

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

.mode-card span {
  color: var(--muted);
  font-weight: 500;
  line-height: 1.4;
}

.mode-card em {
  align-self: end;
  justify-self: stretch;
  border-radius: 6px;
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--brand);
  color: #fff;
  font-size: 0.86rem;
  font-style: normal;
  font-weight: 850;
  text-align: center;
}

.mode-card:hover em,
.mode-card.selected em {
  background: var(--brand-dark);
}

.detail-panel {
  margin-top: 16px;
}

.identified-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
}

.week-pill,
.progress {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border-radius: 999px;
  padding: 0 12px;
  background: var(--soft);
  color: var(--brand-dark);
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
}

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

.question {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.question:first-child {
  border-top: 0;
  padding-top: 0;
}

.question-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.last-week-badge {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: var(--soft);
  color: var(--brand-dark);
  font-size: 0.85rem;
  font-weight: 850;
  white-space: nowrap;
}

.dimension {
  color: var(--brand);
  font-size: 0.85rem;
  font-weight: 850;
}

.scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.scale.enps {
  grid-template-columns: repeat(11, 1fr);
}

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

.scale label {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 0;
  background: #fff;
  cursor: pointer;
}

.scale input:checked + label {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.scale-legend {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.conditional {
  display: none;
  margin-top: 14px;
}

.conditional.visible {
  display: block;
}

.conditional label {
  color: var(--warn);
}

.support-offer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  border: 1px solid #ded6ff;
  border-radius: 8px;
  margin-top: 20px;
  padding: 16px;
  background: var(--soft);
}

.support-offer.hidden {
  display: none;
}

.support-offer p {
  max-width: 620px;
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.support-offer a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.support-offer a:hover {
  background: var(--brand-dark);
}

.open-label {
  margin-top: 24px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.form-alert {
  border: 1px solid #ffb7cf;
  border-radius: 8px;
  margin-top: 18px;
  padding: 12px 14px;
  background: #fff0f6;
  color: var(--danger);
  font-weight: 720;
  line-height: 1.4;
}

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

.admin {
  box-shadow: none;
}

#raw-data {
  min-height: 220px;
  margin-top: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
}

.empty {
  color: var(--muted);
  line-height: 1.5;
}

.analysis-shell {
  width: min(1180px, calc(100% - 32px));
}

.analysis-toolbar {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.inline-actions {
  margin-top: 0;
}

.analysis-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.analysis-tab {
  min-height: 40px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.analysis-tab.active,
.analysis-tab:hover {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.filter-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.filter-row label {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

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

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.metric-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 700;
}

.metric-card strong {
  font-size: 2rem;
  line-height: 1;
}

.analysis-two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 22px;
}

.analysis-two-column > * {
  min-width: 0;
}

h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.weekly-chart {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 20px;
  padding: 16px;
  background: #fff;
}

.weekly-chart svg {
  display: block;
  width: 100%;
  min-height: 220px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 760;
}

.chart-legend span {
  display: inline-flex;
  gap: 7px;
  align-items: center;
}

.chart-legend i {
  width: 11px;
  height: 11px;
  border-radius: 999px;
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-axis {
  stroke: var(--muted);
  stroke-width: 1.5;
}

.chart-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-dot {
  stroke: #fff;
  stroke-width: 2;
}

.chart-x-label,
.chart-y-label {
  fill: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.chart-x-label {
  text-anchor: middle;
}

.distribution-bars {
  display: grid;
  gap: 18px;
}

.distribution-card {
  display: grid;
  gap: 10px;
}

.distribution-card h4 {
  margin: 0;
  color: var(--ink);
  font-size: 0.95rem;
}

.distribution-row {
  display: grid;
  grid-template-columns: 20px minmax(72px, 1fr) 28px 42px;
  gap: 8px;
  align-items: center;
}

.bucket-delta {
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 0.76rem;
  font-style: normal;
  font-weight: 840;
  text-align: center;
  white-space: nowrap;
}

.bucket-up {
  background: #e8f8ef;
  color: #0c7a3d;
}

.bucket-down {
  background: #ffe9ef;
  color: #bd1745;
}

.bucket-flat {
  background: var(--soft);
  color: var(--muted);
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: var(--soft);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

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

.timeline-sections {
  display: grid;
  gap: 28px;
}

.timeline-section h3 {
  margin-bottom: 14px;
}

.timeline-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.timeline-header strong,
.timeline-header span {
  display: block;
}

.timeline-header span,
.timeline-trends {
  color: var(--muted);
  font-size: 0.9rem;
}

.timeline-trends {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.trend-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.82rem;
  font-weight: 840;
  line-height: 1;
  vertical-align: middle;
}

.trend-up {
  background: #e8f8ef;
  color: #0c7a3d;
}

.trend-down {
  background: #ffe9ef;
  color: #bd1745;
}

.trend-flat {
  background: #fff5cf;
  color: #8a5f00;
}

.trend-none {
  background: var(--soft);
  color: var(--muted);
}

.trend-delta {
  display: inline-block;
  margin-left: 6px;
  color: var(--muted);
  font-weight: 760;
}

.open-response-list {
  display: grid;
  gap: 14px;
}

.open-response-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.open-response-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.open-response-header strong,
.open-response-header span {
  display: block;
}

.open-response-header span {
  color: var(--muted);
  font-size: 0.9rem;
}

.open-notes {
  display: grid;
  gap: 10px;
}

.open-notes section {
  border-left: 4px solid var(--brand);
  padding-left: 12px;
}

.open-notes h3 {
  margin-bottom: 4px;
  color: var(--brand);
}

.open-notes p {
  margin: 0;
  color: var(--ink);
  line-height: 1.45;
}

.compact-table table {
  font-size: 0.88rem;
}

@media (max-width: 980px) {
  .mode-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode-card.recommended {
    grid-column: 1 / -1;
    min-height: 150px;
  }

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

  .analysis-two-column {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 24px, 960px);
    padding: 24px 0;
  }

  .intro,
  .identity-row,
  .identified-row,
  .mode-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 18px;
  }

  .section-heading,
  .question-title,
  .support-offer {
    display: block;
  }

  .support-offer a {
    width: 100%;
    margin-top: 14px;
  }

  .last-week-badge {
    margin-top: 10px;
  }

  .week-pill,
  .progress {
    margin-top: 10px;
  }

  .scale,
  .scale.enps {
    grid-template-columns: repeat(auto-fit, minmax(42px, 1fr));
  }

  .metric-grid,
  .timeline-list {
    grid-template-columns: 1fr;
  }

  .filter-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .analysis-toolbar {
    display: block;
  }

  .inline-actions {
    margin-top: 14px;
  }
}
