:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #657085;
  --line: #d9e0ea;
  --paper: #ffffff;
  --soft: #f5f7fb;
  --green: #16a36a;
  --blue: #2877c9;
  --orange: #e7832f;
  --red: #d94343;
  --focus: #111827;
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 900;
  text-align: left;
}

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

.survey-body {
  min-height: 100vh;
  background: linear-gradient(180deg, #f8fbff 0%, #eef3f8 100%);
}

.survey-shell {
  min-height: 100vh;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 48px);
  display: grid;
  place-items: center;
}

.survey-step {
  display: none;
  width: 100%;
}

.survey-step.is-active {
  display: block;
}

.survey-step h1 {
  max-width: 920px;
  margin: 0 auto clamp(26px, 5vw, 48px);
  text-align: center;
  font-size: clamp(2rem, 5vw, 4.6rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.faces-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: clamp(12px, 2vw, 22px);
}

.face-option {
  min-height: clamp(140px, 24vw, 260px);
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  display: grid;
  place-items: center;
  align-content: center;
  font-weight: 800;
  font-size: clamp(1.25rem, 2.6vw, 2.4rem);
  box-shadow: none;
  transition: transform 160ms ease, filter 160ms ease;
}

.face-option:active {
  transform: scale(0.98);
}

.face-option:hover,
.face-option:focus-visible {
  transform: translateY(-3px) scale(1.03);
  outline: 0;
}

.face-icon {
  width: clamp(100px, 16vw, 190px);
  height: clamp(100px, 16vw, 190px);
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(24, 33, 47, 0.18));
}

.back-button {
  position: fixed;
  left: clamp(16px, 3vw, 34px);
  bottom: clamp(16px, 3vw, 34px);
  z-index: 10;
  width: 42px;
  height: 42px;
  border: 1px solid #c8d4e1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
  box-shadow: 0 8px 20px rgba(24, 33, 47, 0.12);
  backdrop-filter: blur(8px);
}

.back-button:hover,
.back-button:focus-visible {
  color: var(--ink);
  border-color: var(--ink);
}

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

.nps-scale button {
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid #c8d4e1;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-size: clamp(1.05rem, 3vw, 2rem);
  font-weight: 800;
}

.nps-scale button:hover,
.nps-scale button:focus-visible,
.nps-scale button.is-selected {
  border-color: var(--focus);
  background: var(--focus);
  color: white;
}

.option-list {
  width: min(760px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 12px;
}

.option-choice {
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 58px;
  border: 1px solid #c8d4e1;
  border-radius: 8px;
  background: var(--paper);
  padding: 12px 14px;
  color: var(--ink);
  font-size: clamp(1.05rem, 2vw, 1.35rem);
}

.option-choice input {
  width: auto;
}

.option-submit {
  width: min(320px, 100%);
  margin: 18px auto 0;
}

.scale-labels,
.actions-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  color: var(--muted);
  font-weight: 600;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid #c8d4e1;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  padding: 14px 16px;
}

input:disabled,
select:disabled,
textarea:disabled {
  background: #eef2f7;
  color: var(--muted);
  cursor: not-allowed;
}

textarea {
  resize: vertical;
  min-height: 170px;
  font-size: 1.15rem;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  border-radius: 8px;
  padding: 0 18px;
  border: 1px solid var(--focus);
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-button {
  background: var(--focus);
  color: white;
}

.secondary-button {
  background: white;
  color: var(--focus);
}

.thanks-step {
  text-align: center;
}

.thanks-step p {
  margin: -24px 0 0;
  color: var(--muted);
  font-size: clamp(1.2rem, 3vw, 2rem);
  font-weight: 700;
}

.thanks-icon {
  width: clamp(86px, 16vw, 150px);
  height: clamp(86px, 16vw, 150px);
  margin: 0 auto 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: 900;
}

.error-text {
  min-height: 24px;
  color: var(--red);
  font-weight: 700;
}

.success-text {
  color: var(--green);
  font-weight: 800;
}

.admin-body {
  background: #f6f8fb;
}

.admin-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px 18px 48px;
}

.login-card,
.panel,
.metrics-grid article,
.filters {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(24, 33, 47, 0.06);
}

.login-panel {
  width: min(430px, 100%);
  margin: clamp(58px, 9vh, 110px) auto 0;
}

.login-card {
  padding: 34px 26px 26px;
}

.admin-header h1 {
  margin: 0 0 18px;
}

.login-mark {
  width: 76px;
  height: 76px;
  display: block;
  margin: 0 auto 26px;
  object-fit: contain;
  filter: drop-shadow(0 14px 22px rgba(22, 163, 106, 0.24));
}

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

.login-brand {
  margin: 28px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.muted,
.eyebrow {
  color: var(--muted);
}

.is-hidden {
  display: none !important;
}

.admin-header,
.filters,
.admin-layout,
.config-form,
.token-form,
.question-form,
.catalog-form {
  display: grid;
  gap: 14px;
}

.admin-header {
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-bottom: 18px;
}

.admin-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.admin-nav button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
  padding: 0 14px;
  font-weight: 900;
  white-space: nowrap;
}

.admin-nav button:hover,
.admin-nav button:focus-visible,
.admin-nav button.is-active {
  border-color: var(--focus);
  background: var(--focus);
  color: white;
  outline: 0;
}

.compact-filters {
  grid-template-columns: minmax(220px, 360px);
}

.template-grid {
  display: grid;
  gap: 14px;
}

.template-card {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 16px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.template-card-main {
  min-width: 0;
}

.template-card-actions {
  display: flex;
  justify-content: end;
}

.template-card h3 {
  margin: 0 0 6px;
}

.template-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.template-summary {
  display: grid;
  gap: 8px;
  margin: 0;
  grid-column: 1 / -1;
}

.template-card > .primary-button {
  width: fit-content;
  grid-column: 1 / -1;
}

.template-summary div {
  display: grid;
  gap: 2px;
}

.template-summary dt {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.template-summary dd {
  margin: 0;
  font-weight: 800;
}

.template-questionnaires {
  display: grid;
  gap: 10px;
}

.template-questionnaire {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.template-questionnaire ol {
  margin: 0;
  padding-left: 22px;
  color: var(--ink);
}

.template-questionnaire li {
  margin: 4px 0;
}

.admin-view {
  display: none;
}

.admin-view.is-active {
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 10px;
}

.user-menu {
  position: relative;
}

.user-menu-button {
  width: 46px;
  height: 46px;
  border: 1px solid var(--focus);
  border-radius: 50%;
  background: var(--focus);
  color: white;
  font-weight: 900;
  display: grid;
  place-items: center;
}

.user-menu-button:hover,
.user-menu-button:focus-visible {
  outline: 2px solid rgba(40, 119, 201, 0.28);
  outline-offset: 2px;
}

.user-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 30;
  width: 230px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 18px 38px rgba(24, 33, 47, 0.16);
  display: grid;
  gap: 6px;
}

.user-menu-summary {
  display: grid;
  gap: 2px;
  padding: 8px 8px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.user-menu-summary span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.user-menu-panel button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 850;
  padding: 0 8px;
}

.user-menu-panel button:hover,
.user-menu-panel button:focus-visible {
  background: #eef3f8;
  outline: 0;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  font-weight: 900;
}

.filters {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: end;
  padding: 16px;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.9rem;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.metrics-grid article {
  padding: 18px;
}

.metrics-grid span {
  display: block;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 8px;
}

.metric-label,
.section-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.help-tip {
  position: relative;
  width: 18px;
  height: 18px;
  border: 1px solid #c8d4e1;
  border-radius: 50%;
  background: #f7f9fc;
  color: var(--muted);
  display: inline-grid;
  place-items: center;
  padding: 0;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  cursor: help;
}

.help-tip::after {
  content: attr(data-help);
  position: absolute;
  z-index: 10;
  left: 50%;
  bottom: calc(100% + 8px);
  width: min(260px, 78vw);
  padding: 10px 12px;
  border-radius: 8px;
  background: #18212f;
  color: white;
  box-shadow: 0 14px 32px rgba(24, 33, 47, 0.18);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  text-align: left;
  transform: translate(-50%, 4px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.help-tip:hover,
.help-tip:focus-visible {
  border-color: var(--focus);
  color: var(--focus);
  outline: 0;
}

.help-tip:hover::after,
.help-tip:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.metrics-grid strong {
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.admin-layout {
  grid-template-columns: 1fr 1fr;
  margin-bottom: 16px;
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 1.15rem;
}

.token-form,
.question-form,
.catalog-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  margin: 14px 0 12px;
}

.token-form button,
.question-form button,
.catalog-form button {
  min-width: 0;
}

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

.add-button {
  width: fit-content;
  margin: 14px 0 0;
}

.response-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(150px, 0.8fr) minmax(150px, 0.8fr) minmax(150px, 0.8fr) minmax(150px, 0.8fr) auto auto;
  gap: 12px;
  align-items: end;
  margin: 8px 0 16px;
}

.inline-filter {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px;
}

.wide-field {
  grid-column: span 2;
}

td a {
  color: var(--blue);
  font-weight: 800;
}

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

.table-actions .link-button {
  font-size: 0.86rem;
}

.link-button:disabled {
  color: #aab4c3;
  cursor: default;
}

.is-muted-row td {
  color: var(--muted);
  background: #f8fafc;
}

.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 44px;
  gap: 12px;
  align-items: center;
  margin: 12px 0;
}

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

.bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--blue);
}

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

.compact-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.compact-row strong {
  font-size: 0.98rem;
}

.compact-row span {
  font-weight: 900;
}

.compact-row small {
  color: var(--muted);
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.84rem;
}

.is-selected-row td {
  background: #eef6ff;
}

.check-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.check-row input {
  width: auto;
}

@media (max-width: 820px) {
  .faces-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .nps-scale {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 2px 10px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .nps-scale button {
    flex: 0 0 52px;
    width: 52px;
    height: 52px;
    aspect-ratio: auto;
    scroll-snap-align: center;
    font-size: 1.2rem;
  }

  .filters,
  .metrics-grid,
  .admin-layout,
  .admin-header,
  .token-form,
  .question-form,
  .catalog-form,
  .response-toolbar,
  .wide-field {
    grid-template-columns: 1fr;
    grid-column: auto;
  }

  .header-actions {
    justify-content: space-between;
  }

  .admin-nav {
    margin-left: -18px;
    margin-right: -18px;
    padding: 0 18px 4px;
  }
}

@media (max-width: 520px) {
  .survey-shell {
    padding: 18px 12px;
  }

  .survey-step h1 {
    font-size: clamp(2rem, 11vw, 2.8rem);
    margin-bottom: 30px;
  }

  .scale-labels {
    font-size: 0.82rem;
    align-items: flex-start;
  }

  .faces-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .face-option {
    min-height: 82px;
    padding: 0;
  }

  .face-icon {
    width: clamp(62px, 21vw, 82px);
    height: clamp(62px, 21vw, 82px);
    filter: drop-shadow(0 6px 12px rgba(24, 33, 47, 0.16));
  }

  .scale-labels,
  .actions-row {
    flex-direction: column;
  }

  .template-card {
    grid-template-columns: 1fr;
  }
}
