:root {
  --ink: #073459;
  --muted: #60727c;
  --line: #d9e7e6;
  --panel: #ffffff;
  --bg: #f4faf9;
  --brand: #39afe6;
  --brand-dark: #073459;
  --leaf: #43c531;
  --danger: #a83d3d;
  --success: #1f6f4f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(57,175,230,.11), transparent 260px),
    var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--brand-dark);
  text-decoration: none;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  font: inherit;
  cursor: pointer;
}

button.primary,
.button.primary,
.public-form button[type="submit"] {
  border-color: var(--brand);
  background: var(--brand);
  color: #052b49;
  font-weight: 800;
}

button:disabled,
.public-form.is-submitting button[type="submit"] {
  opacity: .72;
  cursor: wait;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

aside {
  background: #073459;
  color: #fff;
  padding: 24px;
}

.admin-brand {
  display: grid;
  justify-items: start;
  gap: 12px;
  margin-bottom: 28px;
}

.admin-brand img {
  width: 86px;
  height: 86px;
  object-fit: contain;
  border-radius: 999px;
  background: #fff;
  padding: 6px;
}

.admin-brand strong {
  font-size: 18px;
}

aside nav {
  display: grid;
  gap: 8px;
}

aside a {
  color: #e8f6f2;
  padding: 10px 12px;
  border-radius: 6px;
}

aside a:hover {
  background: rgba(255,255,255,.1);
}

main {
  padding: 28px;
}

h1,
h2 {
  margin: 0 0 18px;
  line-height: 1.2;
}

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

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

.head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-head h1,
.panel-head h2 {
  margin: 0;
}

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

.stats div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.stats b {
  display: block;
  font-size: 30px;
  line-height: 1;
}

.stats span,
small,
td small {
  color: var(--muted);
}

.analysis-filters {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 170px 170px auto auto;
  gap: 12px;
  align-items: end;
}

.analysis-stats {
  margin: 0;
}

.analysis-stats b {
  font-size: 21px;
  overflow-wrap: anywhere;
}

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

.analysis-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
  display: grid;
  gap: 12px;
}

.analysis-card-wide {
  grid-column: 1 / -1;
}

.analysis-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.analysis-card h3 {
  margin: 0;
  max-width: 82ch;
  font-size: 16px;
  line-height: 1.35;
}

.analysis-note {
  margin: -4px 0 0;
  color: var(--brand-dark);
  font-weight: 800;
}

.analysis-bar-row {
  display: grid;
  gap: 7px;
}

.analysis-bar-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.analysis-bar-meta span {
  min-width: 0;
  color: #30464f;
  font-weight: 700;
  line-height: 1.35;
}

.analysis-bar-meta b {
  flex: 0 0 auto;
}

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

.analysis-bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.analysis-pie-layout {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 18px;
  align-items: center;
}

.analysis-pie {
  width: 150px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 8px solid #f4faf9;
  box-shadow: inset 0 0 0 1px rgba(7,52,89,.08);
}

.analysis-legend {
  display: grid;
  gap: 8px;
}

.analysis-legend.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.analysis-legend span {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.analysis-legend p {
  margin: 0;
  overflow: hidden;
  color: #30464f;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analysis-vertical-bars {
  min-height: 230px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(70px, 1fr);
  gap: 12px;
  align-items: end;
  overflow-x: auto;
  padding-top: 8px;
}

.analysis-vbar {
  min-width: 70px;
  display: grid;
  grid-template-rows: 150px auto auto auto;
  gap: 5px;
  text-align: center;
}

.analysis-vbar-plot {
  display: flex;
  align-items: end;
  justify-content: center;
  border-bottom: 1px solid var(--line);
}

.analysis-vbar-plot span {
  width: min(34px, 80%);
  min-height: 5px;
  border-radius: 6px 6px 0 0;
}

.analysis-vbar b {
  line-height: 1;
}

.analysis-vbar small {
  max-width: 110px;
  margin: 0 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analysis-vbar em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.analysis-area {
  display: grid;
  gap: 6px;
}

.analysis-area svg {
  width: 100%;
  height: 210px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #f6fbfa);
}

.analysis-area polygon {
  fill: rgba(57,175,230,.22);
}

.analysis-area polyline {
  fill: none;
  stroke: var(--brand);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 5;
}

.analysis-area div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

.table-scroll table {
  min-width: 980px;
  table-layout: fixed;
}

.entries-scroll {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 100%;
  background: #fff;
}

.entries-table {
  width: max-content;
  min-width: 100%;
  table-layout: auto;
}

.entries-table th,
.entries-table td {
  min-width: 190px;
  max-width: 260px;
  padding: 12px 16px;
  overflow: hidden;
}

.entries-table th:first-child,
.entries-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 210px;
  max-width: 210px;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}

.entries-table th:first-child {
  z-index: 3;
  background: #fbfdfc;
}

.entries-table th:nth-child(2),
.entries-table td:nth-child(2) {
  min-width: 220px;
  max-width: 220px;
}

.entries-table .entry-preview,
.entries-table .entry-more summary {
  max-width: 100%;
}

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

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

td small {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.nowrap {
  white-space: nowrap;
}

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

.entry-preview,
.entry-more summary {
  display: block;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-more summary {
  cursor: pointer;
  color: var(--brand-dark);
  font-weight: 800;
}

.entry-more[open] summary {
  white-space: normal;
  overflow: visible;
}

.entry-more div {
  width: min(520px, 70vw);
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

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

.actions form {
  margin: 0;
}

.actions a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
}

.details td {
  padding-top: 0;
}

.qr {
  display: block;
  width: 140px;
  height: 140px;
  margin: 12px 0;
}

code {
  display: block;
  background: #eef4f2;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  white-space: normal;
  overflow-wrap: anywhere;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cfdad7;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
}

.password-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: stretch;
  width: 100%;
}

.password-wrap input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  min-width: 0;
}

.password-toggle {
  width: auto;
  min-height: 0;
  border-left: 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  padding: 0 12px;
  color: var(--brand-dark);
  font-weight: 800;
  white-space: nowrap;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  outline: 3px solid rgba(57,175,230,.18);
}

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

select[multiple] {
  min-height: 120px;
}

input[readonly],
textarea[readonly],
select:disabled {
  background: #eef3f2;
  color: #59696d;
}

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

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

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-card,
.bulk-add {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  background: #fbfdfc;
}

.field-summary,
.checks,
.sticky-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.field-summary {
  justify-content: space-between;
  min-height: 58px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 800;
  list-style: none;
}

.field-summary::-webkit-details-marker {
  display: none;
}

.field-summary small {
  display: inline-block;
  margin-left: 8px;
  font-weight: 700;
}

.field-body {
  border-top: 1px solid var(--line);
  padding: 16px;
}

.field-card > form {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.bulk-add {
  padding: 14px 16px;
}

.bulk-add summary {
  cursor: pointer;
  font-weight: 800;
}

.field-advanced {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.field-advanced summary {
  width: max-content;
  cursor: pointer;
  color: var(--muted);
  font-weight: 800;
}

.field-advanced .grid {
  margin-top: 12px;
}

.bulk-add textarea {
  margin: 12px 0;
  min-height: 110px;
}

.drag {
  color: var(--muted);
  font-weight: 700;
}

.checks {
  margin-top: 12px;
}

.checks label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
}

.checks input {
  width: auto;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  background: rgba(245,248,247,.94);
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.auth-card,
.public-form {
  width: min(720px, 100%);
  margin: 48px auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  display: grid;
  gap: 18px;
  box-shadow: 0 22px 60px rgba(7,52,89,.08);
}

.auth-card {
  width: min(460px, 100%);
  margin-top: 72px;
  padding: 34px;
}

.auth-card h1 {
  margin-bottom: 4px;
  font-size: clamp(1.8rem, 4vw, 2.45rem);
}

.form-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  color: var(--brand-dark);
  font-weight: 800;
}

.form-brand img {
  width: 66px;
  height: 66px;
  object-fit: contain;
  border-radius: 999px;
}

.auth-card .form-brand img {
  width: 28px !important;
  height: 28px !important;
  max-width: 28px !important;
  max-height: 28px !important;
}

.auth-card .form-brand {
  gap: 10px;
  font-size: 14px;
}

.import-form {
  display: grid;
  gap: 18px;
  max-width: 560px;
}

.public-wrap {
  padding: 22px;
}

.embed {
  background: transparent;
}

.embed .public-wrap {
  padding: 0;
}

.embed .public-form {
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.description {
  color: var(--muted);
  margin: -6px 0 8px;
}

.public-field {
  gap: 8px;
}

.public-field b {
  color: var(--danger);
}

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

.choice-list label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 500;
}

.choice-list input {
  width: auto;
}

.choice-radios {
  gap: 12px;
  padding-top: 2px;
}

.choice-radios label {
  align-items: flex-start;
  color: #444;
  font-size: 16px;
  line-height: 1.35;
}

.choice-radios input[type="radio"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.other-input-wrap {
  width: min(360px, calc(100% - 36px));
  margin: -4px 0 2px 30px;
}

.other-input-wrap.is-hidden {
  display: none;
}

.rating-scale {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rating-scale label {
  display: block;
  font-weight: 800;
}

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

.rating-scale span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 42px;
  border: 1px solid #cfdad7;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.rating-scale input:checked + span {
  border-color: var(--brand);
  background: var(--brand);
  color: #052b49;
}

.rating-scale input:focus + span {
  outline: 3px solid rgba(57,175,230,.18);
}

.rating-scale input:disabled + span {
  background: #eef3f2;
  color: #59696d;
  cursor: default;
}

.notice,
.success,
.error {
  border-radius: 8px;
  padding: 13px 14px;
  margin-bottom: 16px;
}

.notice {
  background: #eef4f2;
  border: 1px solid var(--line);
}

.success {
  background: #eaf7ef;
  border: 1px solid #b9dec6;
  color: var(--success);
}

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

.submit-status {
  border-radius: 8px;
  padding: 13px 14px;
  margin: 0 0 14px;
  background: #eef7fb;
  border: 1px solid #b9ddea;
  color: var(--brand-dark);
  font-weight: 800;
}

.error {
  background: #fff0f0;
  border: 1px solid #e5b8b8;
  color: var(--danger);
}

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

  aside {
    padding: 16px;
  }

  aside nav {
    grid-template-columns: repeat(4, auto);
    justify-content: start;
  }

  main,
  .public-wrap {
    padding: 16px;
  }

  .stats,
  .grid.two,
  .grid.three,
  .analysis-filters,
  .analysis-grid {
    grid-template-columns: 1fr;
  }

  .panel-head,
  .actions {
    align-items: flex-start;
    justify-content: flex-start;
  }

  .analysis-pie-layout,
  .analysis-legend.compact {
    grid-template-columns: 1fr;
  }
}
