/* Survey results page. Same greens and type as the survey; bars use a slightly brighter green
   (#2a8a57 light, #3fa36e dark) that passes the chart colour checks. */
:root {
  --bg: #f6f8f6; --card: #ffffff; --ink: #14261d; --ink2: #4f6157; --ink3: #66766d;
  --line: #e2e9e1; --line2: #edf1ed; --accent: #2a6a49; --accent-ink: #ffffff; --accent-hover: #235a3e;
  --bar: #2a8a57; --soft: #f0f6f0; --tip: #14261d; --tip-ink: #ffffff; --err: #a3361f;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1411; --card: #121a16; --ink: #e4ede6; --ink2: #b0bfb6; --ink3: #8d9d94;
    --line: #26352d; --line2: #1c2822; --accent: #3fa36e; --accent-ink: #06140c; --accent-hover: #4cb27c;
    --bar: #3fa36e; --soft: #17251d; --tip: #e4ede6; --tip-ink: #0d1411; --err: #f08a70;
    color-scheme: dark;
  }
  .logo { filter: brightness(0) invert(.92); }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.55 "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }

/* top bar */
.top { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { display: block; height: 24px; width: auto; }
.divider { width: 1px; height: 26px; background: var(--line); }
h1 { font-size: 16px; line-height: 1.2; font-weight: 700; }
.sub { font-size: 12.5px; color: var(--ink2); line-height: 1.3; }
.actions { display: flex; align-items: center; gap: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid transparent; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; color: var(--ink2); border-color: var(--line); }
.btn.ghost:hover { color: var(--ink); border-color: var(--ink3); }
.btn:disabled { opacity: .6; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 2px; }
.link:hover { text-decoration-color: currentColor; }

.loading { padding: 48px 0; color: var(--ink2); }

/* sign in */
.login { display: flex; justify-content: center; padding: clamp(32px, 10vh, 96px) 0; }
.login-card { width: 100%; max-width: 420px; display: grid; gap: 10px; padding: 28px; }
.login-card h2 { font-size: 20px; line-height: 1.3; }
.login-card label { margin-top: 8px; font-size: 13px; font-weight: 600; }
.login-card input { width: 100%; min-height: 44px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); font-size: 15px; }
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.login-card .btn { margin-top: 6px; min-height: 44px; }
.err { color: var(--err); font-size: 14px; }

/* tabs */
.tabs { display: flex; align-items: center; gap: 4px; margin: 20px 0 18px; border-bottom: 1px solid var(--line); }
.tabs [role="tab"] { position: relative; background: none; border: 0; padding: 10px 12px; font-size: 15px; font-weight: 600; color: var(--ink2); cursor: pointer; }
.tabs [role="tab"][aria-selected="true"] { color: var(--ink); }
.tabs [role="tab"][aria-selected="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }
.pill { display: inline-block; min-width: 22px; padding: 0 7px; margin-left: 4px; border-radius: 99px; background: var(--soft); color: var(--accent); font-size: 12.5px; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.updated { margin-left: auto; font-size: 13px; color: var(--ink2); white-space: nowrap; }
.updated .link { font-size: 13px; }

/* cards and sections */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; }
.meta { font-size: 13px; color: var(--ink2); }
.section { margin-top: 32px; }
.section > h2 { font-size: 18px; line-height: 1.3; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.stats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); margin-bottom: 16px; }
.stat .meta { margin-bottom: 4px; }
.stat strong { display: block; font-size: 26px; line-height: 1.2; font-weight: 700; font-variant-numeric: tabular-nums; }

.chart h3, .quotes h3 { font-size: 15px; line-height: 1.4; font-weight: 600; }
.chart > .meta, .quotes > .meta { margin: 2px 0 12px; }

/* bar rows: label | bar | count */
.rows { display: grid; gap: 2px; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(90px, 36%) 68px; align-items: center; gap: 12px; padding: 5px 6px; margin: 0 -6px; border-radius: 6px; }
.row[tabindex] { cursor: default; }
.row[tabindex]:hover, .row[tabindex]:focus-visible { background: var(--soft); }
.lab { font-size: 14px; line-height: 1.35; }
.track { display: block; height: 12px; border-left: 1px solid var(--line); }
.bar { display: block; height: 12px; min-width: 3px; border-radius: 0 4px 4px 0; background: var(--bar); }
.val { font-size: 13px; color: var(--ink2); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row.zero .lab, .row.zero .val { color: var(--ink3); }
.row.zero .bar { display: none; }
.none { color: var(--ink3); font-size: 14px; padding: 6px 0; }

.typed { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line2); }
.typed ul { margin: 4px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 14px; }

/* free-text answers */
.qlist { margin: 0; padding: 0; list-style: none; display: grid; }
.qlist > li { padding: 12px 0; border-top: 1px solid var(--line2); }
.qlist > li:first-child { border-top: 0; padding-top: 2px; }
.qtext { font-size: 15px; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }
.qby { margin-top: 4px; font-size: 13px; color: var(--ink2); }
.qby .link { font-size: 13px; }
.qlist ol { margin: 4px 0 0; padding-left: 20px; font-size: 15px; overflow-wrap: anywhere; }

/* people table */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input { flex: 1 1 260px; max-width: 420px; min-height: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); }
.toolbar input:focus { outline: none; border-color: var(--accent); }
.tbl-card { padding: 0; overflow: hidden; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--ink2); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line2); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover { background: var(--soft); }
.tbl .num { font-variant-numeric: tabular-nums; color: var(--ink2); white-space: nowrap; }
.tbl .sub-org { display: none; font-size: 13px; color: var(--ink2); }

/* one response */
dialog#detail { padding: 0; border: 0; margin: 0 0 0 auto; width: min(640px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; background: var(--card); color: var(--ink); box-shadow: -12px 0 40px rgba(0, 0, 0, .18); }
dialog#detail::backdrop { background: rgba(10, 20, 15, .35); }
.d-in { min-height: 100%; display: flex; flex-direction: column; }
.d-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 24px 14px; background: var(--card); border-bottom: 1px solid var(--line); }
.d-head h2 { font-size: 20px; line-height: 1.3; overflow-wrap: anywhere; }
.d-head .meta a { color: var(--accent); }
.d-body { flex: 1; padding: 18px 24px 28px; display: grid; gap: 22px; align-content: start; }
.levelbox { background: var(--soft); border-radius: 10px; padding: 14px 16px; }
.levelbox strong { display: block; font-size: 20px; line-height: 1.3; }
.levelbox ul { margin: 6px 0 0; padding-left: 18px; font-size: 14px; color: var(--ink2); }
.levelbox p { font-size: 14px; color: var(--ink2); margin-top: 4px; }
.report { margin: 8px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.d-sec h3 { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.d-sec dl { margin: 0; display: grid; }
.d-sec dt { font-size: 13px; color: var(--ink2); padding-top: 10px; }
.d-sec dd { margin: 2px 0 0; padding-bottom: 10px; border-bottom: 1px solid var(--line2); font-size: 15px; white-space: pre-line; overflow-wrap: anywhere; }
.d-sec dd.empty { color: var(--ink3); }
.d-foot { position: sticky; bottom: 0; display: flex; justify-content: space-between; gap: 8px; padding: 12px 24px max(12px, env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); }

/* hover detail for bars */
.tip { position: fixed; z-index: 20; max-width: 300px; padding: 9px 11px; border-radius: 8px; background: var(--tip); color: var(--tip-ink); font-size: 13px; line-height: 1.45; pointer-events: none; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); }
.tip strong { display: block; }
.tip .tip-who { margin-top: 4px; opacity: .85; }

.empty-state { padding: 40px 24px; text-align: center; }
.foot { margin: 40px 0 32px; padding-top: 14px; border-top: 1px solid var(--line); }
.foot .link { font-size: 13px; }
.narrow { display: none; }
.empty-state h2 { font-size: 18px; margin-bottom: 6px; }

@media (max-width: 640px) {
  .sub, .divider, .wide { display: none; }
  .narrow { display: inline; }
  .logo { height: 20px; }
  .top-in { min-height: 54px; }
  .actions .btn { min-height: 34px; padding: 0 10px; font-size: 13px; }
  .tabs { margin-top: 12px; }
  .tabs [role="tab"] { padding: 10px 8px; }
  .updated #updated { display: none; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 12px; }
  .stat strong { font-size: 18px; }
  .stat .meta { font-size: 12px; }
  .card { padding: 14px 14px; }
  .row { grid-template-columns: minmax(0, 1fr) 64px; row-gap: 4px; }
  .row .lab { grid-column: 1 / -1; }
  .c-id, .c-org, .c-lang { display: none; }
  .tbl .sub-org { display: block; }
  .tbl th, .tbl td { padding-left: 12px; padding-right: 12px; }
  .d-head, .d-body, .d-foot { padding-left: 16px; padding-right: 16px; }
}
