:root {
  color-scheme: dark;
  --bg: #071120;
  --panel: rgba(13, 27, 44, .82);
  --panel-2: rgba(10, 22, 37, .92);
  --line: rgba(139, 169, 205, .18);
  --line-strong: rgba(139, 169, 205, .28);
  --text: #edf5ff;
  --muted: #8fa1bb;
  --quiet: #5e718d;
  --cyan: #21a6e8;
  --green: #2fc09b;
  --blue: #2b7bdb;
  --amber: #d6a93b;
  --red: #d95c55;
  --shadow: 0 24px 70px rgba(0, 0, 0, .35);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(rgba(36, 108, 177, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(36, 108, 177, .045) 1px, transparent 1px),
    radial-gradient(circle at 18% 0%, rgba(33, 166, 232, .14), transparent 34%),
    radial-gradient(circle at 92% 16%, rgba(47, 192, 155, .10), transparent 28%),
    var(--bg);
  background-size: 74px 74px, 74px 74px, auto, auto, auto;
}

button,
input {
  font: inherit;
}

.app {
  width: min(1500px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 42px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(47, 192, 155, .55);
  animation: pulse 2.6s ease-out infinite;
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1;
  letter-spacing: -.03em;
  font-weight: 760;
}

.subtitle {
  color: var(--muted);
  font-size: 15px;
  white-space: nowrap;
}

.top-count,
.results-head strong {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 14px;
}

.top-count strong,
.results-head strong {
  color: var(--green);
  font-size: 17px;
  font-weight: 720;
}

.layout {
  display: grid;
  grid-template-columns: minmax(760px, 1fr) 430px;
  gap: 16px;
  align-items: start;
}

.survey-panel,
.results-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(15, 32, 52, .9), rgba(8, 18, 32, .9));
  box-shadow: var(--shadow);
}

.form-strip {
  display: grid;
  grid-template-columns: minmax(210px, 1.1fr) minmax(220px, .9fr) auto;
  gap: 14px;
  align-items: end;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.field span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.field input {
  width: 100%;
  height: 45px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 14px;
  color: var(--text);
  background: rgba(6, 15, 28, .65);
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.field input:focus {
  border-color: rgba(33, 166, 232, .8);
  box-shadow: 0 0 0 3px rgba(33, 166, 232, .12);
}

.submit,
.export {
  border: 0;
  border-radius: 6px;
  color: white;
  background: linear-gradient(180deg, #2b86ea, #1f6ed0);
  cursor: pointer;
}

.submit {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 45px;
  padding: 0 20px;
  font-weight: 700;
}

.submit:disabled {
  cursor: not-allowed;
  color: #7b8da7;
  background: rgba(50, 74, 104, .46);
}

.submit svg,
.export svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.progress-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  color: var(--quiet);
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}

.progress-line span:last-child {
  color: var(--muted);
}

.survey-scroll {
  overflow-x: auto;
}

.matrix {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

.matrix th,
.matrix td {
  border-bottom: 1px solid var(--line);
  padding: 14px 12px;
  text-align: left;
  vertical-align: middle;
}

.matrix thead th {
  color: #d8e6f7;
  font-size: 14px;
  font-weight: 720;
}

.matrix thead small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.matrix tbody tr:hover {
  background: rgba(47, 192, 155, .035);
}

.number-col {
  width: 32px;
  color: var(--muted);
}

.direction-col {
  width: 245px;
}

.direction-name {
  color: #edf5ff;
  font-size: 15px;
  line-height: 1.35;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(5, 30px);
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(5, 14, 26, .52);
}

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

.segmented label {
  display: grid;
  place-items: center;
  color: #b9c9df;
  border-right: 1px solid var(--line);
  cursor: pointer;
  transition: color .14s ease, background .14s ease;
}

.segmented label:last-child {
  border-right: 0;
}

.segmented label:hover {
  color: white;
  background: rgba(43, 123, 219, .22);
}

.segmented input:checked + label {
  color: white;
  background: linear-gradient(180deg, #2785ea, #1d69ca);
}

.results-panel {
  position: sticky;
  top: 16px;
  overflow: hidden;
}

.results-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 22px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.results-head h2 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -.02em;
}

.results-head span {
  color: var(--muted);
  font-size: 14px;
}

.metric-block {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.metric-block h3 {
  margin: 0 0 14px;
  color: #c7d7ed;
  font-size: 14px;
  font-weight: 660;
}

.criterion-rings {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.ring-card {
  text-align: center;
  color: #dce9f8;
}

.ring {
  position: relative;
  width: 66px;
  height: 66px;
  margin: 0 auto 8px;
}

.ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring circle {
  fill: none;
  stroke-width: 10;
}

.ring .track {
  stroke: rgba(103, 127, 158, .28);
}

.ring .value {
  stroke: var(--green);
  stroke-linecap: round;
}

.ring strong {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 15px;
}

.ring-card span {
  display: block;
  min-height: 33px;
  color: #b9c9df;
  font-size: 12px;
  line-height: 1.25;
}

.ranking {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rank-row {
  display: grid;
  grid-template-columns: 20px minmax(125px, 1fr) minmax(110px, .8fr) 42px;
  gap: 10px;
  align-items: center;
  color: #dce9f8;
  font-size: 13px;
}

.rank-row .idx {
  color: var(--muted);
}

.rank-row .bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(103, 127, 158, .26);
  overflow: hidden;
}

.rank-row .bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), #35b8bf);
}

.rank-row strong {
  text-align: right;
  font-weight: 720;
}

.distribution {
  display: grid;
  grid-template-columns: 154px 1fr;
  gap: 18px;
  align-items: center;
}

.pie {
  width: 154px;
  height: 154px;
  border-radius: 50%;
  background: conic-gradient(rgba(103, 127, 158, .28) 0 360deg);
  position: relative;
}

.pie::after {
  content: attr(data-total);
  position: absolute;
  inset: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--text);
  background: #081426;
  white-space: pre-line;
  text-align: center;
  font-size: 13px;
  line-height: 1.35;
}

.legend {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: #c9d8eb;
  font-size: 13px;
}

.legend li {
  display: grid;
  grid-template-columns: 11px 1fr auto;
  gap: 9px;
  align-items: center;
}

.swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.legend b {
  color: var(--text);
  font-weight: 720;
}

.results-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  color: var(--muted);
  font-size: 13px;
}

.export {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 11px;
  background: transparent;
  color: #58a9ff;
}

.toast {
  color: var(--green);
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(47, 192, 155, .42); }
  72% { box-shadow: 0 0 0 12px rgba(47, 192, 155, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 192, 155, 0); }
}

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

  .results-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .app {
    width: min(100vw - 20px, 720px);
    padding-top: 14px;
  }

  .topbar,
  .progress-line {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand {
    display: grid;
    grid-template-columns: 10px 1fr;
    column-gap: 10px;
    row-gap: 6px;
  }

  .brand h1 {
    font-size: 25px;
  }

  .subtitle {
    grid-column: 2;
  }

  .form-strip {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .note-field {
    display: none;
  }

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

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