:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --sidebar: #0f172a;
  --sidebar-soft: #172033;
  --text: #111827;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #e4e7ec;
  --line-strong: #cfd5df;
  --accent: #e21d38;
  --accent-dark: #ba1730;
  --accent-soft: #fff1f3;
  --success: #027a48;
  --success-soft: #ecfdf3;
  --warning: #b54708;
  --warning-soft: #fffaeb;
  --shadow: 0 18px 48px rgba(16, 24, 40, .08);
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  background: var(--bg);
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
  -webkit-tap-highlight-color: transparent;
}

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

button {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 13px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  touch-action: manipulation;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

button:hover {
  background: #eef2f6;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(226, 29, 56, .18);
  outline-offset: 2px;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-dark);
}

.ghost {
  background: #f2f4f7;
  border-color: #eaecf0;
}

.danger {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  min-height: 42px;
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

label {
  display: grid;
  gap: 7px;
  color: #475467;
  font-size: 12px;
  font-weight: 750;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 0, rgba(226, 29, 56, .10), transparent 30%),
    linear-gradient(180deg, #fff, var(--bg));
}

.login-card {
  width: min(440px, 100%);
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: grid;
  gap: 15px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 850;
}

.brand::before {
  content: "";
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.35), transparent 45%),
    linear-gradient(135deg, #e21d38, #111827);
  box-shadow: 0 10px 22px rgba(226, 29, 56, .20);
}

.login-card h1 {
  margin: 8px 0 0;
  font-size: 30px;
  line-height: 1.12;
  text-wrap: balance;
}

.login-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.message {
  min-height: 20px;
  color: var(--muted);
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--sidebar);
  color: #fff;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar-top {
  display: grid;
  gap: 6px;
  padding: 4px 2px 12px;
}

.workspace-caption {
  color: #98a2b3;
  font-size: 13px;
  padding-left: 36px;
}

.nav-stack {
  display: grid;
  gap: 5px;
}

.nav {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #cbd5e1;
  border-color: transparent;
}

.nav.active,
.nav:hover {
  background: var(--sidebar-soft);
  color: #fff;
}

.sidebar-card {
  margin-top: auto;
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-card span {
  color: #98a2b3;
  font-size: 12px;
}

.sidebar-card strong {
  font-size: 14px;
}

.workspace {
  width: min(1560px, 100%);
  padding: 30px;
  display: grid;
  gap: 22px;
  align-content: start;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.eyebrow {
  display: inline-flex;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
}

.topbar h1 {
  margin: 10px 0 0;
  font-size: 36px;
  line-height: 1.1;
  font-weight: 850;
  text-wrap: balance;
}

.topbar p,
.panel-head p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.view {
  display: grid;
  gap: 20px;
}

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

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .04);
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  font-variant-numeric: tabular-nums;
}

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

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(16, 24, 40, .04);
  padding: 18px;
  min-width: 0;
}

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

.panel-head h2,
.panel-head h3 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
}

.panel-head.small {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

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

.list,
.questions,
.responses {
  display: grid;
  gap: 10px;
}

.list-panel {
  position: sticky;
  top: 18px;
}

.item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px;
  background: #fff;
  display: grid;
  gap: 8px;
  min-width: 0;
}

button.item {
  cursor: pointer;
}

.item:hover {
  background: #fbfcfd;
  border-color: var(--line-strong);
}

.item.active {
  border-color: rgba(226, 29, 56, .42);
  box-shadow: 0 0 0 4px rgba(226, 29, 56, .08);
}

.item h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
  font-weight: 800;
  word-break: break-word;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.meta span {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-width: 30px;
  justify-content: center;
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(160px, .75fr) minmax(160px, .75fr);
  gap: 12px;
}

.editor {
  padding: 0;
  overflow: hidden;
}

.editor > .panel-head {
  margin: 0;
  padding: 18px;
  background: #fbfcfd;
  border-bottom: 1px solid var(--line);
}

.editor form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

#surveyTitle {
  font-size: 26px;
  font-weight: 850;
  min-height: 52px;
}

#surveyDescription {
  min-height: 96px;
}

.link-box {
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  padding: 13px;
  display: grid;
  gap: 5px;
  background: var(--surface-2);
}

.link-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.link-box strong {
  word-break: break-all;
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
}

.question {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 12px;
  background: #fff;
}

.question:focus-within {
  border-color: rgba(226, 29, 56, .42);
  box-shadow: 0 0 0 4px rgba(226, 29, 56, .08);
}

.question-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.question-head strong {
  color: var(--muted);
  font-size: 13px;
}

.question .actions {
  opacity: .65;
  transition: opacity .15s ease;
}

.question:hover .actions,
.question:focus-within .actions {
  opacity: 1;
}

.question textarea[data-question-text] {
  font-size: 17px;
  font-weight: 750;
}

.options {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-2);
}

.option-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.option-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.option-row input[type="checkbox"] {
  width: auto;
  min-height: auto;
}

.empty {
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  padding: 28px;
  text-align: center;
  background: var(--surface-2);
}

.responses-panel {
  align-self: start;
}

.response-answer {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.users-form {
  grid-template-columns: 1fr 1fr 1fr 180px auto;
  align-items: end;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.profile {
  line-height: 1.9;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  background: var(--text);
  color: #fff;
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 50;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}

@media (max-width: 1180px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    z-index: 5;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .sidebar-top {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0;
    white-space: nowrap;
  }

  .workspace-caption,
  .sidebar-card {
    display: none;
  }

  .nav-stack {
    display: flex;
    gap: 6px;
  }

  .nav {
    width: auto;
    white-space: nowrap;
  }

  .workspace {
    padding: 22px;
  }

  .split,
  .grid,
  .users-form,
  .metrics {
    grid-template-columns: 1fr;
  }

  .list-panel {
    position: static;
  }
}

@media (max-width: 700px) {
  .workspace {
    padding: 16px;
  }

  .topbar,
  .panel-head,
  .question-head,
  .option-row {
    grid-template-columns: 1fr;
    display: grid;
  }

  .actions {
    justify-content: start;
  }

  .topbar h1 {
    font-size: 30px;
  }
}
