:root {
  --ink: #1d2433;
  --muted: #667085;
  --line: #d9dee8;
  --paper: #fbfcff;
  --panel: #ffffff;
  --blue: #1868db;
  --blue-dark: #124c9f;
  --green: #1b806a;
  --red: #b42318;
  --gold: #c47f19;
  --shadow: 0 18px 45px rgba(29, 36, 51, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 32px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 180px;
  max-width: 470px;
}

.brand img {
  display: block;
  height: auto;
  max-height: 84px;
  max-width: 100%;
}

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

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

h1 {
  font-size: 28px;
  line-height: 1.15;
  margin-bottom: 0;
}

h2 {
  font-size: 24px;
  margin-bottom: 6px;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

.tabs {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  background: #f6f8fb;
}

.public-mode .tabs {
  display: none;
}

.public-mode .topbar {
  position: static;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px 14px;
  border-radius: 6px;
  cursor: pointer;
}

.tab.active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(29, 36, 51, 0.12);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.section-head p,
.survey-description {
  color: var(--muted);
  margin-bottom: 0;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button,
.small-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.button {
  background: var(--blue);
  color: #ffffff;
  padding: 11px 16px;
  min-height: 44px;
}

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

.button.secondary,
.small-button,
.icon-button {
  color: var(--ink);
  background: #ffffff;
  border-color: var(--line);
}

.small-button {
  padding: 7px 10px;
  min-width: 54px;
}

.small-button.danger {
  color: var(--red);
}

.icon-button {
  padding: 7px 10px;
}

.builder-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel,
.question-editor,
.survey-card,
.metrics article,
.chart-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
  position: sticky;
  top: 124px;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #ffffff;
  padding: 10px 11px;
}

.select-other-group {
  display: grid;
  gap: 10px;
}

.other-input[hidden] {
  display: none;
}

textarea {
  resize: vertical;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
}

.toggle input {
  width: 18px;
  height: 18px;
}

.toggle.compact {
  margin: 24px 0 14px;
}

.public-link {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.public-link code {
  display: block;
  color: var(--ink);
  background: #f2f5f9;
  border-radius: 6px;
  padding: 9px;
  overflow-wrap: anywhere;
}

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

.question-editor {
  padding: 16px;
}

.question-toolbar,
.toolbar-actions,
.editor-row {
  display: flex;
  gap: 10px;
}

.question-toolbar {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.toolbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.editor-row {
  align-items: start;
}

.editor-row label {
  flex: 1 1 160px;
}

.options-field.hidden {
  display: none;
}

.survey-shell {
  max-width: 820px;
  margin: 0 auto;
}

.survey-card {
  padding: 28px;
}

.survey-card h2 {
  font-size: 30px;
}

.survey-category-header {
  border-top: 2px solid var(--ink);
  margin-top: 26px;
  padding-top: 18px;
}

.survey-category-header:first-of-type {
  margin-top: 22px;
}

.survey-category-header h3 {
  color: var(--green);
  font-size: 18px;
  margin-bottom: 0;
  text-transform: uppercase;
}

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

.survey-question h3 {
  font-size: 17px;
  margin-bottom: 10px;
}

.required {
  color: var(--red);
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 10px;
}

.choice input {
  width: 18px;
  margin-top: 2px;
}

.rating-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(52px, 1fr));
  gap: 9px;
}

.rating-row label {
  margin: 0;
}

.rating-row input {
  display: none;
}

.rating-row span {
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

.rating-row input:checked + span {
  border-color: var(--blue);
  background: #e8f1ff;
  color: var(--blue-dark);
}

.submit {
  width: 100%;
}

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

.metrics article {
  padding: 18px;
}

.metrics span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 700;
}

.metrics strong {
  font-size: 30px;
}

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

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

.winner-panel h3 {
  margin-bottom: 4px;
}

.winner-panel p {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
}

.winner-summary {
  overflow-x: auto;
}

.winner-table {
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

.winner-table th,
.winner-table td {
  border-top: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}

.winner-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.winner-table td {
  font-size: 14px;
}

.winner-rank {
  display: block;
  font-weight: 800;
}

.winner-votes {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.chart-card {
  padding: 18px;
}

.chart-card h3 {
  margin-bottom: 4px;
}

.chart-card p {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(120px, 2fr) 42px;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.bar-label {
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 700;
}

.bar-track {
  height: 13px;
  border-radius: 999px;
  overflow: hidden;
  background: #eef2f7;
}

.bar {
  height: 100%;
  min-width: 2px;
  background: linear-gradient(90deg, var(--green), var(--gold));
}

.text-response {
  border-left: 3px solid var(--blue);
  background: #f7f9fc;
  padding: 10px 12px;
  border-radius: 0 7px 7px 0;
  margin-bottom: 10px;
}

.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #ffffff;
}

@media (max-width: 820px) {
  .topbar,
  .section-head,
  .builder-grid {
    display: grid;
  }

  .panel {
    position: static;
  }

  .tabs,
  .actions {
    justify-content: stretch;
  }

  .tab,
  .actions .button {
    flex: 1;
  }

  .builder-grid,
  .metrics,
  .charts {
    grid-template-columns: 1fr;
  }

  .editor-row,
  .question-toolbar {
    display: grid;
  }

  .toolbar-actions {
    justify-content: start;
  }

  .brand {
    max-width: 360px;
  }
}

@media (max-width: 520px) {
  main,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .rating-row {
    grid-template-columns: repeat(5, minmax(38px, 1fr));
  }

  .bar-row {
    grid-template-columns: 1fr 40px;
  }

  .bar-track {
    grid-column: 1 / -1;
    order: 3;
  }

  .brand img {
    max-height: 58px;
  }
}
