:root {
  --bg: #f5f5f7;
  --bg-alt: #f0f1f4;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: #ffffff;
  --ink: #1d1d1f;
  --ink-soft: #6e6e73;
  --line: #e4e4e7;
  --line-strong: #d7d7dc;
  --accent: #0a84ff;
  --accent-soft: #e8f2ff;
  --warn-bg: #fff2f4;
  --warn-ink: #b4233c;
}

* { box-sizing: border-box; }

html {
  scrollbar-gutter: stable;
  font-size: 15px;
}

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #fbfbfc 0%, var(--bg) 35%, var(--bg-alt) 100%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Helvetica, Arial, sans-serif;
  min-height: 100vh;
  overflow-y: scroll;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.topbar {
  background: rgba(248, 248, 250, 0.7);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 2;
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 72px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 650;
}

.topbar nav { display: flex; gap: 1rem; margin-left: auto; }
.topbar a { color: var(--ink); text-decoration: none; font-weight: 600; }
.topbar a:hover { color: #0b6bd3; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.1rem;
  margin: 1rem 0;
  box-shadow: 0 8px 30px rgba(16, 24, 40, 0.06);
}

.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

.wide { overflow: hidden; }
.stack { display: grid; gap: 0.8rem; }
.stack > .btn { justify-self: start; }
.survey-form > .btn { justify-self: end; }
.survey-form .btn { min-width: calc(148px + 10ch); }
label { display: grid; gap: 0.35rem; }

input[type="text"], input[type="email"], input[type="password"] {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  background: var(--surface-strong);
  color: var(--ink);
}

select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  background: var(--surface-strong);
  color: var(--ink);
}

input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus {
  outline: 2px solid #bfdbfe;
  outline-offset: 1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  border: 1px solid #0b76e5;
  color: #ffffff;
  font-weight: 600;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

.btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #ffffff;
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.btn-danger {
  background: #dc2626;
  border-color: #b91c1c;
  color: #ffffff;
}

.alert {
  background: var(--warn-bg);
  color: var(--warn-ink);
  border: 1px solid #f5c2cb;
  padding: 0.6rem;
  border-radius: 8px;
}

.success {
  background: #edf8f0;
  color: #1e6b3b;
  border: 1px solid #cde9d6;
  padding: 0.6rem;
  border-radius: 8px;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(420px, 92vw);
  background: rgba(255, 255, 255, 0.88);
  padding: 1.5rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(16, 24, 40, 0.08);
}

.group-block { border-top: 1px dashed var(--line-strong); padding-top: 0.8rem; margin-top: 0.8rem; }
.question-row {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  border-radius: 10px;
  padding: 0.7rem;
  margin: 0.55rem 0;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 230px;
  gap: 0.8rem;
  align-items: center;
}

.question-text {
  margin: 0;
}

.likert {
  display: grid;
  grid-template-columns: repeat(5, minmax(28px, 1fr));
  gap: 0.4rem;
  justify-items: center;
  align-items: center;
}

.section-scale-header {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 230px;
  gap: 0.8rem;
  align-items: center;
  margin: 0.2rem 0 0.45rem;
}

.section-scale-header h3 {
  margin: 0;
}

.section-scale-values {
  display: grid;
  grid-template-columns: repeat(5, minmax(28px, 1fr));
  gap: 0.4rem;
  justify-items: center;
  align-items: center;
  padding: 0 0.55rem;
  transform: translateX(-11px);
  color: #3a3a3c;
  font-weight: 600;
}

.likert-row {
  padding: 0 0.55rem;
}

.likert label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
}

.likert input[type="radio"] {
  accent-color: var(--accent);
}

@media (max-width: 760px) {
  .section-scale-header {
    display: none;
  }

  .question-row {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

.grid-3 {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.grid-2 {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.stat {
  min-height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.number { font-size: 2rem; font-weight: 700; margin: 0.5rem 0; color: #0b6bd3; }

.stat-count {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.stat-count .number {
  font-size: 3.4rem;
  margin: 0.2rem 0 0;
  line-height: 1;
}

.progress {
  height: 10px;
  background: #eceef2;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #60a5fa, #0a84ff);
}

.result-card {
  border-left: 4px solid #a8cdf8;
}

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

.gauge {
  --gauge-value: 0;
  width: 132px;
  height: 132px;
  margin: 0.2rem 0 1rem 0;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--gauge-value) * 1%), #e5e7eb 0);
  display: grid;
  place-items: center;
}

.gauge-inner {
  width: 94px;
  height: 94px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 0.35rem;
}

.gauge-inner strong {
  font-size: 1.1rem;
  line-height: 1.1;
}

.gauge-inner small {
  font-size: 0.72rem;
}

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

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

th {
  background: #f7f7f9;
  color: #3a3a3c;
}

td {
  background: rgba(255, 255, 255, 0.65);
}

.table-wrap { overflow-x: auto; }
.table-wrap table { min-width: 100%; }
.question-score-table { table-layout: fixed; }
.table-center-wrap { display: flex; justify-content: center; }
.table-center-wrap .table-center { width: 100%; margin: 0; table-layout: fixed; }
.table-center th, .table-center td { text-align: center; width: 50%; }
.invite-actions-cell {
  text-align: center;
  vertical-align: middle;
}

.respondents-table {
  font-size: 12px;
}

.invite-action-col {
  width: 7.5%;
  text-align: center;
}

.invite-meta-col {
  width: 12.5%;
}

.invite-name-col {
  width: 20%;
}

.invite-company-col {
  width: 10%;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.icon-btn img {
  width: 16px;
  height: 16px;
  display: block;
}

.icon-btn-danger {
  color: #111111;
}

.icon-btn-danger:hover {
  background: #f1f3f5;
  border-color: #d9dce1;
}

.icon-btn-reset {
  color: #0b6bd3;
}

.icon-btn-reset:hover {
  background: #eef5ff;
  border-color: #bfdbfe;
}

.icon-btn-resend {
  color: #0f766e;
}

.icon-btn-resend:hover {
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.icon-btn-disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 1000;
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal-screen {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  z-index: 2000;
}

.modal-card {
  width: min(460px, 100%);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.22);
}

.modal-card h3 {
  margin: 0 0 0.9rem 0;
  font-size: 1rem;
  font-weight: 400;
}

.modal-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.matrix th, .matrix td { min-width: 100px; }
.matrix th:first-child, .matrix td:first-child { min-width: 220px; position: sticky; left: 0; background: #f7f7f9; }
.responses-table-wrap {
  max-height: 72vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.responses-matrix {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  width: max-content;
  min-width: max-content;
}

.responses-matrix th,
.responses-matrix td {
  text-align: center;
  padding: 0.55rem 0.5rem;
}

.responses-matrix tbody td {
  vertical-align: middle;
}

.responses-matrix .domain-group-title {
  border-top: 2px solid #000;
  border-left: 2px solid #000;
  border-right: 0;
  border-bottom: 1px solid var(--line-strong);
}

.responses-matrix .domain-group-title.domain-group-first {
  border-left: 2px solid #000;
}

.responses-matrix .domain-group-title.domain-group-last {
  border-right: 2px solid #000;
}

.responses-matrix thead tr:nth-child(2) .domain-cell.domain-start {
  border-left: 2px solid #000;
}

.responses-matrix tbody .domain-cell.domain-start {
  border-left: 2px solid #000;
}

.responses-matrix thead tr:nth-child(2) .domain-cell.domain-last-group,
.responses-matrix tbody .domain-cell.domain-last-group {
  border-right: 2px solid #000;
}

.responses-matrix thead tr:nth-child(2) .domain-cell.domain-first-group,
.responses-matrix tbody .domain-cell.domain-first-group {
  border-left: 2px solid #000;
}

.responses-matrix tbody tr:last-child .domain-cell {
  border-bottom: 2px solid #000;
}

.responses-matrix .question-col {
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  padding: 0.45rem 0.2rem;
}

.responses-matrix .col-respondent {
  width: 260px;
}

.responses-matrix .col-question {
  width: 40px;
}

.responses-matrix .col-summary {
  width: 90px;
}

.responses-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f3f4f7;
  border-bottom: 1px solid var(--line-strong);
}

.responses-matrix thead tr:nth-child(1) th {
  top: 0;
  z-index: 5;
}

.responses-matrix thead tr:nth-child(2) th {
  top: 38px;
  z-index: 4;
}

.responses-matrix thead tr:nth-child(2) th:first-child {
  min-width: 40px;
  width: 40px;
  max-width: 40px;
  left: auto;
}

.responses-matrix .respondent-col {
  min-width: 260px;
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 4;
  background: #f7f7f9;
}

.responses-matrix .summary-col {
  min-width: 90px;
  background: #fcfcfd;
}

.responses-matrix tbody tr:nth-child(even) td {
  background-color: rgba(248, 249, 252, 0.9);
}

.responses-matrix tbody tr:hover td {
  background-color: #eef5ff;
}

.responses-matrix tbody tr:hover .respondent-col {
  background-color: #e6f0ff;
}

.score-cell {
  font-weight: 700;
}

.score-low {
  background-color: #fde8e8 !important;
  color: #9b1c1c;
}

.score-mid {
  background-color: #fff8e1 !important;
  color: #92400e;
}

.score-high {
  background-color: #e8f7ee !important;
  color: #166534;
}

.score-empty {
  color: #8a8f98;
}

.level-cell {
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.badge-laag {
  background: #fde8e8;
  color: #9b1c1c;
}

.badge-middel {
  background: #fff8e1;
  color: #92400e;
}

.badge-hoog {
  background: #e8f7ee;
  color: #166534;
}

.badge-onbekend {
  background: #eef2f7;
  color: #4b5563;
}

small { color: var(--ink-soft); }
h1, h2, h3, h4 { letter-spacing: 0.02em; }
p { line-height: 1.45; }

.dashboard-top-row {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dashboard-top-row .card {
  margin: 0;
}

.trend {
  display: inline-block;
  min-width: 54px;
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
  font-weight: 600;
}

.trend-up {
  background: #e8f7ee;
  color: #177245;
}

.trend-down {
  background: #fff0f0;
  color: #9c1f1f;
}

.trend-flat {
  background: #e8f1ff;
  color: #0a84ff;
}

.distribution-block {
  margin-top: 1rem;
}

.distribution-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 0.6rem;
}

.distribution-col {
  text-align: center;
}

.distribution-bar {
  height: 110px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f5f7fa;
  display: flex;
  align-items: end;
  justify-content: center;
  overflow: hidden;
}

.distribution-fill {
  width: 100%;
  background: linear-gradient(180deg, #93c5fd 0%, #0a84ff 100%);
}

.domain-avg-row {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 0.6rem;
}

.domain-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.domain-title-row h2 {
  margin: 0;
}

.trend-legend {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.domain-avg-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
  padding: 0.8rem;
  text-align: center;
}

.domain-avg-card h3 {
  margin-bottom: 0.25rem;
}

.domain-avg-card .number {
  margin: 0;
}

.donut-chart {
  --pct: 0;
  --donut-color: #0a84ff;
  width: 108px;
  height: 108px;
  margin: 0.45rem auto 0.3rem;
  border-radius: 50%;
  background: conic-gradient(var(--donut-color) calc(var(--pct) * 1%), #e5eaf1 0);
  display: grid;
  place-items: center;
}

.donut-center {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #dce3ee;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1f2937;
}

.donut-empty {
  background: #eef2f7;
}

.donut-up {
  --donut-color: #1f9d55;
}

.donut-down {
  --donut-color: #dc2626;
}

.donut-same {
  --donut-color: #0a84ff;
}

.distribution-question-list {
  margin-top: 0.45rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.12rem;
}

.distribution-question-item {
  display: block;
  color: #374151;
  font-size: 0.76rem;
  line-height: 1.15;
}

@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; }
  .topbar nav { width: 100%; order: 2; margin-left: 0; }
  .result-grid { grid-template-columns: 1fr; }
  .dashboard-top-row { grid-template-columns: 1fr; }
  .domain-avg-row { grid-template-columns: 1fr; }
}
