/* Trade Execution Survey: shared styles for the public form and the admin view.
   Editorial palette: warm off-white ground, near-black ink, copper accent,
   serif display type with a clean sans for everything else. */

:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --ink: #131311;
  --muted: #6b6760;
  --line: #e6e1d8;
  --line-strong: #cfc8bc;
  --hover: #f2eee6;
  --accent: #131311;
  --accent-ink: #ffffff;
  --copper: #c68b3d;
  --copper-soft: #f6ead9;
  --danger: #b3261e;
  --ok: #2e6b4a;
  --focus: #c68b3d;
  --radius: 4px;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Instrument Serif', 'Times New Roman', Georgia, serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); }

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
  padding-block: 48px 80px;
}

.page.wide { max-width: 1200px; }

.label {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  border-top: 3px solid var(--copper);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-inner.wide { max-width: 1200px; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-logo { width: 30px; height: 30px; display: block; flex: none; }

.brand-name b { font-weight: 700; }

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

.progress-label {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bar {
  width: 160px;
  max-width: 35vw;
  height: 3px;
  background: var(--line);
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--copper);
  transition: width 200ms ease;
}

/* Hero */

.masthead { display: grid; gap: 18px; margin-bottom: 40px; }

h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.4rem, 5.5vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--ink);
  text-wrap: balance;
}

.lede { color: var(--ink); margin: 0; max-width: 58ch; font-size: 1.05rem; line-height: 1.6; }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 0;
  margin: 4px 0 0;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.meta span + span::before { content: '\00b7'; margin: 0 12px; color: var(--copper); }

/* Section cards */

.section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 36px;
  margin-bottom: 16px;
}

@media (max-width: 600px) {
  .section { padding: 24px 18px; }
}

.section-head {
  display: grid;
  gap: 6px;
  margin-bottom: 26px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.section-num {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--copper);
  font-variant-numeric: tabular-nums;
}

h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.7rem;
  line-height: 1.15;
  margin: 0;
  color: var(--ink);
}

fieldset.q, .q {
  border: 0;
  padding: 0 0 26px;
  margin: 0 0 26px;
  min-width: 0;
  display: grid;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.q:last-child { padding-bottom: 0; margin-bottom: 0; border-bottom: 0; }

.q-label {
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.45;
  margin: 0;
  padding: 0;
  color: var(--ink);
}

.q-optional { color: var(--muted); font-weight: 400; }

.q-help { color: var(--muted); font-size: 0.875rem; margin: -6px 0 0; }

/* Option buttons */

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

.chip { position: relative; display: inline-block; }

.chip input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.chip span {
  display: inline-block;
  padding: 10px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--surface);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink);
  user-select: none;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.chip:hover span { border-color: var(--ink); background: var(--hover); }

.chip input:checked + span {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--accent-ink);
}

.chip input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.other-field { max-width: 380px; }

.text-input, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  line-height: 1.4;
}

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

.text-input::placeholder, textarea::placeholder { color: #a39d93; }

.text-input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--ink);
}

/* Matrix (hours per activity) */

.matrix {
  display: grid;
  grid-template-columns: minmax(170px, 1.5fr) repeat(var(--cols, 5), minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
}

.matrix-head, .matrix-row { display: contents; }

.matrix-head > span {
  padding: 12px 6px;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.matrix-row .rl {
  padding: 14px 12px;
  font-size: 0.925rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
}

.matrix-row:last-child .rl, .matrix-row:last-child .cell { border-bottom: 0; }

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--line);
  min-height: 52px;
  cursor: pointer;
}

.cell:hover { background: var(--hover); }

.cell input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.cell .dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  transition: border-color 120ms ease, background 120ms ease;
}

.cell input:checked + .dot {
  border-color: var(--ink);
  background: var(--ink);
  box-shadow: inset 0 0 0 4px var(--surface);
}

.cell input:focus-visible + .dot { outline: 2px solid var(--focus); outline-offset: 2px; }

.cell .txt { display: none; }

.matrix-row.has-error .rl { color: var(--danger); }

@media (max-width: 640px) {
  .matrix { display: block; border: 0; }
  .matrix-head { display: none; }
  .matrix-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
  .matrix-row .rl { width: 100%; padding: 0 0 4px; border: 0; font-weight: 500; }
  .cell { border: 0; min-height: 0; display: inline-block; }
  .cell:hover { background: transparent; }
  .cell .dot { display: none; }
  .cell .txt {
    display: inline-block;
    padding: 9px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 2px;
    background: var(--surface);
    font-size: 0.875rem;
    font-weight: 500;
  }
  .cell input:checked + .dot + .txt { background: var(--ink); border-color: var(--ink); color: var(--accent-ink); }
}

/* Errors */

.q-error {
  color: var(--danger);
  font-size: 0.875rem;
  margin: 0;
  display: none;
}

.has-error > .q-error, .has-error .q-error { display: block; }
.has-error > .q-label { color: var(--danger); }

/* Buttons and panels */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 22px;
  border-radius: 2px;
  border: 1px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease;
}

.btn:hover { background: var(--hover); }

.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--accent-ink); }

.btn-primary:hover { background: #2a2925; }

.btn .arrow { font-size: 1rem; letter-spacing: 0; line-height: 1; }

.btn-lg { padding: 18px 28px; }

.btn-danger { color: var(--danger); border-color: var(--line-strong); }

.btn[disabled] { opacity: 0.6; cursor: default; }

.submit-row {
  display: grid;
  gap: 12px;
  justify-items: start;
  padding-top: 16px;
}

@media (max-width: 600px) {
  .submit-row .btn { width: 100%; }
}

.form-status { margin: 0; font-size: 0.925rem; color: var(--muted); }

.form-status.error { color: var(--danger); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 48px 32px;
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
}

.panel .check {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--copper-soft);
  color: var(--copper);
  display: grid;
  place-items: center;
  margin-bottom: 8px;
}

.panel .check svg { width: 26px; height: 26px; }

.panel h2 { font-size: 2rem; }

.panel p { margin: 0; color: var(--muted); }

.footer {
  margin-top: 40px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Admin */

.admin-head {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 32px;
}

.admin-head h1 { font-size: clamp(2.2rem, 4vw, 3rem); }

.admin-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.stat-total { display: grid; gap: 2px; }

.stat-total .num {
  font-family: var(--font-display);
  font-size: 3rem;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.stat-total .cap {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.admin-section { margin-block: 36px; }

.admin-section h2 {
  font-size: 1.5rem;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  align-items: start;
}

.sum {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  min-width: 0;
}

.sum h3 { font-size: 0.925rem; font-weight: 500; margin: 0 0 14px; line-height: 1.4; }

.sum-sub {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--copper);
  margin: 0 0 6px;
}

.bar-row { display: grid; gap: 5px; margin: 9px 0; font-size: 0.85rem; }

.bar-row .lbl { display: flex; justify-content: space-between; gap: 8px; }

.bar-row .cnt { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }

.bar-row .track { height: 4px; background: var(--line); overflow: hidden; }

.bar-row .fill { display: block; height: 100%; background: var(--ink); }

.comments { display: grid; gap: 10px; }

.comment {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 0.925rem;
  white-space: pre-wrap;
}

.comment .when {
  display: block;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

table { border-collapse: collapse; width: 100%; font-size: 0.85rem; }

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

th {
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  position: sticky;
  top: 0;
  background: var(--bg);
}

td.num { font-variant-numeric: tabular-nums; }

td.wrap { white-space: normal; min-width: 240px; max-width: 420px; }

tr:last-child td { border-bottom: 0; }

.empty { color: var(--muted); font-size: 0.925rem; margin: 0; }

.btn-small { padding: 6px 10px; font-size: 0.66rem; letter-spacing: 0.1em; }

@media (prefers-reduced-motion: reduce) {
  .bar-fill, .chip span, .cell .dot, .btn { transition: none; }
}

/* Required marker on unanswered questions after a submit attempt */

.has-error > .q-label::after {
  content: 'Required';
  display: inline-block;
  margin-left: 10px;
  padding: 3px 7px 2px;
  line-height: 1;
  vertical-align: 0.12em;
  white-space: nowrap;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--danger);
  border: 1px solid currentColor;
  border-radius: 2px;
}

.matrix-row.has-error .rl::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
  margin-left: 8px;
}

/* Completion screen */

.done {
  display: grid;
  gap: 18px;
  padding-block: 24px 8px;
}

.done-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

@media (max-width: 600px) {
  .done-actions .btn { width: 100%; }
}

/* Results opt-in on the completion screen */

.results-form {
  display: grid;
  gap: 12px;
  padding: 24px;
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.results-row { display: flex; flex-wrap: wrap; gap: 10px; }

.results-row .text-input { flex: 1 1 260px; }

@media (max-width: 600px) {
  .results-row .btn { width: 100%; }
}

/* Optional email before submit */

.email-q { padding-top: 8px; border-bottom: 0; }

.email-q .text-input { max-width: 380px; }

/* Larger tap targets on phones */

@media (max-width: 600px) {
  .chip span, .cell .txt { padding: 12px 16px; }
  .text-input, textarea { padding: 13px 14px; }
}

.btn-brand { text-transform: none; letter-spacing: 0.01em; font-size: 0.95rem; }
