/* howdwedo signed-in app. Plain CSS, no build step. Colours and fonts come from tokens.css; load it first.
   Order: base, frame (sidebar and top bar), page furniture, forms, tables, components, sign-in pages, small screens.
   Every component here is shown on the component page at /_ui/ in local development. Reuse before adding. */

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 1rem/1.5 var(--text); -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul, ol, fieldset, figure { margin: 0; }
h1 { font: 700 1.6rem/1.2 var(--text); letter-spacing: -0.01em; }
h2 { font: 600 1.15rem/1.3 var(--text); }
h3 { font: 600 1rem/1.4 var(--text); }
a { color: var(--signal-ink); }
img, svg { max-width: 100%; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 16px; top: -48px; z-index: 50; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { top: 12px; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--slate); }
.small { font-size: .875rem; color: var(--faint); }

/* ---------- Frame: sidebar and main ---------- */
/* The sidebar is two pieces in one grid cell: the firm and navigation at the top, and who is signed in at the
   foot. The foot comes after the page in the markup (the keyboard reaches the page first), so it is placed here
   and kept in view with sticky positioning. The column's colour is its own layer behind both. */
.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); grid-template-rows: minmax(100vh, auto); }
.app::before {
  content: ""; grid-area: 1 / 1; align-self: start; position: sticky; top: 0; height: 100vh;
  background: linear-gradient(180deg, var(--cloud), var(--paper) 70%); border-right: 1px solid var(--mist);
}
.side {
  grid-area: 1 / 1; align-self: start; position: sticky; top: 0; z-index: 1;
  max-height: calc(100vh - 120px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px; padding: 16px 12px;
}
.main { grid-area: 1 / 2; }
.firm {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 14px; min-width: 0;
  background: var(--surface); border: 1px solid var(--mist); border-radius: 14px; font-weight: 600;
}
/* The firm's colour from Firm details, and white or near-black text, whichever reads on it (brand_style in
   responses/templatetags/answer_ui.py). The faint edge keeps a very pale colour visible on the light sidebar. */
.firm-mark {
  width: 28px; height: 28px; border-radius: 8px; flex: none; display: grid; place-items: center;
  background: var(--brand, var(--signal)); color: var(--on-brand, #fff); font-size: .85rem;
  box-shadow: inset 0 0 0 1px rgba(14, 34, 53, .12);
}
.firm-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: grid; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid transparent; color: var(--slate); font-weight: 500; text-decoration: none;
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { background: var(--surface); border-color: var(--mist); color: var(--ink); }
.side-label { font: 400 .8rem/1.5 var(--text); color: var(--faint); padding: 18px 12px 6px; }
.recent { list-style: none; padding: 0; }
.recent a {
  display: block; padding: 8px 12px; border-radius: 10px; color: var(--slate); text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.recent a:hover, .recent a[aria-current="page"] { color: var(--ink); }
.side-foot {
  grid-area: 1 / 1; align-self: end; position: sticky; bottom: 0; z-index: 1;
  padding: 14px 24px 20px; display: grid; gap: 8px; font-size: .875rem; color: var(--slate);
}
.side-foot .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; }
.side-foot form { margin: 0; }
/* Theme: Light, Dark or Auto, three buttons in one pill. The chosen one is marked like a chosen .pill. */
.theme-switch [role="group"] {
  display: flex; gap: 2px; max-width: 20rem; padding: 3px; margin-bottom: 4px;
  border: 1px solid var(--mist); border-radius: 12px; background: var(--surface);
}
.theme-switch button {
  flex: 1; justify-content: center; gap: 5px; min-height: 32px; padding: 4px 6px;
  border: 0; border-radius: 9px; background: none; color: var(--slate); font-size: .8125rem;
}
.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.theme-switch .icon { width: 16px; height: 16px; }
.wordmark { display: block; margin-top: 6px; opacity: .8; }
.wordmark img { display: block; height: 15px; width: auto; }
.linkish {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; min-height: 0;
  text-decoration: underline; cursor: pointer;
}

.main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px;
  min-height: 64px; padding: 12px 32px; border-bottom: 1px solid var(--mist);
}
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; color: var(--faint); min-width: 0; }
.crumbs a { text-decoration: none; color: var(--slate); }
.crumbs a:hover { text-decoration: underline; }
.crumbs [aria-current="page"] { color: var(--ink); font-weight: 500; }
.topbar-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 10px; }
.page { padding: 28px 32px 40px; max-width: 1400px; width: 100%; flex: 1; }
.page > * + * { margin-top: 20px; }
/* Running text and plain forms keep a readable line length; cards, tables and grids use the full width. */
.page > p, .page > ul, .page > ol, .page > form, .page > fieldset, .page > blockquote { max-width: 44rem; }
.page > h2 { margin-top: 32px; }
.page > ul, .page > ol { padding-left: 1.25rem; }
.page li + li { margin-top: 4px; }
.site-footer { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 16px 32px 24px; font-size: .875rem; }
.site-footer a { color: var(--faint); }

/* ---------- Page head ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; }
.page-head .sub { color: var(--slate); }
.page-head .chip { align-self: center; }

/* ---------- Buttons, chips, tags ---------- */
.btn, button, input[type="submit"] {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--mist); border-radius: 12px; background: var(--surface); color: var(--ink);
  font: 500 .95rem/1.2 var(--text); text-decoration: none; cursor: pointer;
}
.btn:hover, button:hover { border-color: var(--faint); }
.btn-go, .plain-card button[type="submit"] { background: var(--signal); border-color: var(--signal); color: var(--on-signal); }
.btn-go:hover, .plain-card button[type="submit"]:hover { background: var(--signal-ink); border-color: var(--signal-ink); }
.btn .icon { width: 18px; height: 18px; }
button.linkish, button.linkish:hover { background: none; border: 0; color: inherit; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 12px; border-radius: 999px;
  font-size: .85rem; font-weight: 500; white-space: nowrap; background: var(--cloud); color: var(--slate);
}
.chip::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip-hi { background: var(--hi-soft); color: var(--hi-ink); }
.chip-mid { background: var(--mid-soft); color: var(--mid-ink); }
.chip-lo { background: var(--lo-soft); color: var(--lo-ink); }
.tag-lo {
  display: inline-block; padding: 1px 9px; border-radius: 8px; background: var(--lo-soft); color: var(--lo-ink);
  font-size: .82rem; font-weight: 600;
}
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.dot { display: inline-block; margin-right: 6px; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot-lo { background: var(--lo); } .dot-mid { background: var(--mid); } .dot-hi { background: var(--hi); }

/* ---------- Cards and empty states ---------- */
.card { background: var(--surface); border: 1px solid var(--mist); border-radius: 16px; padding: 22px 24px; min-width: 0; }
.card > * + * { margin-top: 12px; }
.empty { padding: 36px 32px; }
.empty h2 { font: 500 1.9rem/1.15 var(--display); letter-spacing: -0.02em; }
.empty p { color: var(--slate); max-width: 56ch; }

/* ---------- Menu and dialog ---------- */
/* A menu is a button that opens a short list of links: <details class="menu"> with a <summary class="btn">. */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary .icon:last-child { width: 16px; height: 16px; margin-left: -2px; color: var(--faint); }
.menu[open] > summary { border-color: var(--faint); }
.menu-list {
  position: absolute; z-index: 5; top: calc(100% + 6px); left: 0; min-width: 100%; width: max-content; padding: 6px;
  background: var(--surface); border: 1px solid var(--mist); border-radius: 12px; box-shadow: 0 8px 24px rgba(14, 34, 53, .12);
}
.menu-list a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.menu-list a:hover { background: var(--cloud); }
/* A dialog holds a short form over the page it belongs to: <dialog class="card">, opened by <a href="#its-id" data-dialog>. */
dialog.card { width: min(46rem, calc(100% - 32px)); max-width: none; max-height: calc(100dvh - 32px); margin: auto; overflow: auto; color: var(--ink); }
dialog::backdrop { background: rgba(14, 34, 53, .45); }
/* Add a contact (contacts/list.html): the email address gets a row to itself, then the names, then company and owner. */
#add-contact[open] .form-grid > :first-child { grid-column: 1 / -1; }
#add-contact[open] .form-grid > :first-child input { max-width: none; }
/* Without app.js the link jumps to the dialog, which is then shown as an ordinary card in the page. */
dialog.card:target:not([open]) { display: block; position: static; width: auto; max-height: none; margin: 20px 0 0; }
dialog:not([open]) .dialog-close { display: none; }

/* ---------- Forms ---------- */
label { font-weight: 500; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="color"]), select, textarea {
  display: block; width: 100%; max-width: 32rem; min-height: 42px; margin-top: 6px; padding: 9px 12px;
  border: 1px solid var(--mist); border-radius: 10px; background: var(--surface); color: var(--ink);
  font: 400 1rem/1.4 var(--text);
}
textarea { max-width: 44rem; }
input[type="color"] { display: block; width: 64px; height: 42px; margin-top: 6px; padding: 4px; border: 1px solid var(--mist); border-radius: 10px; background: var(--surface); cursor: pointer; }
input[type="file"] { display: block; margin-top: 6px; font: inherit; color: var(--slate); max-width: 100%; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; margin: 0 6px 0 0; vertical-align: -3px; accent-color: var(--signal); }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--signal); outline-offset: 1px; border-color: var(--signal); }
form > p + p, form > * + p, form > p + * { margin-top: 16px; }
.page > form > * + button, .card > form > * + button, .plain-card form > * + button { margin-top: 18px; }
fieldset { border: 1px solid var(--mist); border-radius: 14px; padding: 16px 18px; min-width: 0; }
fieldset > * + * { margin-top: 12px; }
legend { font-weight: 600; padding: 0 6px; }
.helptext, .help { display: block; font-size: .875rem; font-weight: 400; color: var(--slate); margin-top: 4px; }
.errorlist { list-style: none; padding: 0; margin: 0 0 6px; color: var(--lo-ink); font-size: .9rem; font-weight: 500; }
/* A form laid out by Django (form.as_div): label, help, then the error right above its own box. */
.fields > div + div { margin-top: 18px; }
.fields .helptext { max-width: 44rem; margin-top: 2px; }
.fields .errorlist { margin: 6px 0 0; }
.fields .errorlist.nonfield { margin: 0 0 12px; }
/* !important: the box styles above are more specific, and hover changes the border too. The message says what is wrong. */
.fields [aria-invalid="true"] { border-color: var(--lo) !important; }
/* Read only (a Member looking at Firm details): plainly not something to type in. */
/* !important: the box styles above are more specific. */
.fields :disabled { background: var(--cloud) !important; color: var(--slate) !important; cursor: not-allowed; }
/* A tick box sits before its label, on one line, with any error above the pair. Not a file field that has
   grown a "Clear" tick box (a logo already uploaded): that keeps the usual label, help, box order. */
.fields > div:has(> input[type="checkbox"]):not(:has(> input[type="file"])) { display: flex; flex-wrap: wrap; align-items: baseline; }
.fields > div:has(> input[type="checkbox"]):not(:has(> input[type="file"])) > input { order: 1; }
.fields > div:has(> input[type="checkbox"]):not(:has(> input[type="file"])) > label { order: 2; flex: 1; }
.fields > div:has(> input[type="checkbox"]):not(:has(> input[type="file"])) > .errorlist { flex-basis: 100%; margin: 0 0 6px; }
.error {
  padding: 12px 16px; border: 1px solid var(--lo); border-radius: 12px; background: var(--lo-soft); color: var(--lo-ink);
}
form[method="get"] { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
form[method="get"] label { flex: 1 1 14rem; max-width: 24rem; }

/* ---------- Messages and notices ---------- */
.messages { list-style: none; padding: 0; display: grid; gap: 8px; max-width: none; }
.messages li {
  padding: 12px 16px; border: 1px solid var(--mist); border-left: 4px solid var(--signal); border-radius: 12px;
  background: var(--surface);
}
.messages li.success { border-left-color: var(--hi); }
/* A warning blocks something the user is about to rely on (an unconfirmed reply-to stops all sending), so it is
   filled amber, not just edged, to stand apart from the blue "done" messages around it. */
.messages li.warning, .notice.notice-warn { border-color: var(--mid); border-left: 6px solid var(--mid); background: var(--mid-soft); }
.messages li.error { border-color: var(--mist); border-left-color: var(--lo); background: var(--surface); color: var(--ink); }
.page > ul.messages { padding: 0; max-width: 44rem; }
.legal-links { font-size: .875rem; color: var(--slate); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .82rem; font-weight: 500; color: var(--faint); padding: 10px 14px; }
td { padding: 12px 14px; border-top: 1px solid var(--mist); vertical-align: middle; }
.page > table, .card-table { border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--mist); border-radius: 16px; overflow: hidden; }
td form { display: inline; margin: 0; }
td button { min-height: 34px; padding: 5px 12px; font-size: .875rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
blockquote { margin: 0; padding: 12px 16px; border-left: 3px solid var(--mist); }
blockquote footer { color: var(--faint); font-size: .9rem; margin-top: 4px; }

/* ---------- Counts: a row of small cards (a send's emails by status, before any answer) ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat { display: grid; gap: 4px; align-content: start; padding: 18px 20px; }
.stat > * + * { margin-top: 0; }
.stat-label { display: flex; align-items: center; color: var(--slate); font-size: .9rem; }
.stat-value { font: 700 1.9rem/1.2 var(--text); letter-spacing: -0.02em; }
.stat-value small { font: 400 .95rem/1 var(--text); letter-spacing: 0; color: var(--slate); margin-left: 6px; white-space: nowrap; }
.stat-note { color: var(--slate); font-size: .9rem; }
.bandbar { width: 100%; height: 6px; border-radius: 99px; overflow: hidden; margin-top: 10px; background: var(--mist); }

/* ---------- Results: the summary card ---------- */
/* One card, not five: the score is the one large number on the page, in the display serif as on the public site's
   NPS calculator. Beside it, the answers and how they split, in the bar's order, low to high. */
.result-summary { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; padding: 22px 28px; }
.result-summary > * + * { margin-top: 0; }
.result-score { padding-right: 32px; border-right: 1px solid var(--mist); }
.result-score .stat-value { font: 500 3.6rem/1 var(--display); letter-spacing: -0.03em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.result-detail { display: grid; gap: 10px; padding-left: 32px; max-width: 40rem; }
.result-detail .bandbar { height: 10px; margin-top: 0; }
.bands { list-style: none; padding: 0; display: grid; gap: 2px; color: var(--slate); font-size: .95rem; }
.page .bands li { margin: 0; }
.bands strong { color: var(--ink); font-weight: 600; }
.bandbar .lo, .chart .lo { fill: var(--lo); }
.bandbar .mid, .chart .mid { fill: var(--mid); }
.bandbar .hi, .chart .hi { fill: var(--hi); }

/* ---------- Results: chart and comments ---------- */
.cols { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.card h2 .count { color: var(--faint); font-weight: 400; }
.chart { width: 100%; height: auto; }
.chart text { font-family: var(--text); fill: var(--slate); text-anchor: middle; }
.chart .grid { stroke: var(--mist); stroke-width: 1; }
.chart .bar { fill: var(--signal); }
.chart .bar.detractors { fill: var(--lo); } .chart .bar.passives { fill: var(--mid); } .chart .bar.promoters { fill: var(--hi); }
.chart text.band.detractors { fill: var(--lo-ink); } .chart text.band.passives { fill: var(--mid-ink); } .chart text.band.promoters { fill: var(--hi-ink); }
.footnote { display: flex; gap: 8px; align-items: flex-start; color: var(--slate); font-size: .9rem; }
.footnote .icon { width: 18px; height: 18px; margin-top: 1px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; min-height: 36px; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--mist); background: var(--surface); color: var(--ink); font-size: .9rem; font-weight: 500; text-decoration: none;
}
a.pill:hover { border-color: var(--faint); }
.pill[aria-current="true"], .pill[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.pill .n { color: var(--faint); font-weight: 400; margin-left: 8px; }
.pill[aria-current="true"] .n { color: inherit; opacity: .7; }
.comments { list-style: none; padding: 0; }
.comments li { display: flex; gap: 14px; padding: 16px 0; border-top: 1px solid var(--mist); margin: 0; }
.comments li:first-child { border-top: 0; padding-top: 4px; }
.comments li.none { color: var(--slate); }
.tile {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 10px;
  font: 700 1.1875rem/1 var(--text); background: var(--cloud); color: var(--ink);
}
.tile-lo { background: var(--lo); color: #fff; } .tile-hi { background: var(--hi); color: #fff; } .tile-mid { background: var(--mid); color: var(--on-mid); }
.comment-text { font-size: 1.02rem; line-height: 1.45; overflow-wrap: anywhere; }
.comment-meta { color: var(--faint); font-size: .9rem; margin-top: 3px; overflow-wrap: anywhere; }

/* ---------- Surveys: list, getting-started steps, sends table ---------- */
.surveys { display: grid; gap: 12px; }
.survey { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 14px 28px; align-items: center; }
.survey > * + * { margin-top: 0; }
.survey h2 { font-size: 1.05rem; }
.quiet-links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: .9rem; }
.steps { list-style: none; padding: 0; max-width: 640px; }
.steps > li { display: flex; gap: 16px; padding: 18px 0; border-top: 1px solid var(--mist); align-items: flex-start; margin: 0; }
.steps li > div > * + * { margin-top: 6px; }
.steps p { font-size: .95rem; }
.step-n {
  width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 50%;
  border: 1.5px solid var(--mist); color: var(--slate); font-weight: 600; font-size: .9rem;
}
.step-done .step-n { background: var(--hi); border-color: var(--hi); color: #fff; }
.step-next .step-n { border-color: var(--signal); color: var(--signal-ink); }
/* The two ways to get a survey to clients: two tiles of equal weight (surveys/_ways.html). */
.ways { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 46rem; }
.way {
  display: grid; gap: 4px; align-content: start; padding: 14px 16px; border: 1px solid var(--mist); border-radius: 12px;
  background: var(--surface); color: var(--ink); text-decoration: none;
}
.way strong { font-weight: 600; }
.way span { color: var(--slate); font-size: .9rem; line-height: 1.45; }
a.way:hover { border-color: var(--signal); background: var(--signal-soft); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; }
.section-head a { font-size: .9rem; }
.notice > * + * { margin-top: 8px; }
.summary { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 20px; margin: 0; }
.summary dt { color: var(--slate); }
.summary dd { margin: 0; font-weight: 500; }
.follow form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.follow button, .follow .chip { white-space: nowrap; }
.comment-meta a { color: inherit; }
/* Results by label: a table inside a card. */
.split th:first-child, .split td:first-child { padding-left: 0; }
.split th:last-child, .split td:last-child { padding-right: 0; }
.split .bandbar { margin-top: 0; min-width: 120px; }
.split tr.few td { color: var(--faint); }
.card-table { padding: 6px 0; }
.card-table > table th, .card-table > table td { padding-left: 24px; padding-right: 24px; }
.lead a { font-weight: 600; text-decoration: none; color: var(--ink); }
.lead a:hover { text-decoration: underline; }
.sub { display: block; color: var(--faint); font-size: .875rem; }
.page-head .sub { display: inline; font-size: 1rem; }
.facts { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.preview-frame { display: block; width: 100%; max-width: 44rem; height: 520px; border: 1px solid var(--mist); border-radius: 16px; background: #fff; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; max-width: 32rem; }
.field-row > * + * { margin-top: 0; }

/* ---------- Score buttons ---------- */
.cols-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.stack-cards { display: grid; gap: 16px; min-width: 0; }
.code, textarea.code { display: block; width: 100%; max-width: none; font: 0.8rem/1.6 var(--mono); background: var(--cloud); border-radius: 12px; }
.plain-list { padding-left: 1.25rem; }
.plain-list li + li { margin-top: 8px; }
/* An email is light whatever the app's theme, so the preview keeps its own white ground and dark text. */
.email-preview { padding: 16px; border: 1px solid var(--mist); border-radius: 12px; background: #fff; color: #1a1a1a; overflow-x: auto; }
/* The preview is email HTML: undo the app's own table styles so it looks as it will in an inbox. */
.email-preview table { border-collapse: separate; }
.email-preview td { padding: 0; border: 0; vertical-align: middle; }
.choices > div { display: flex; flex-wrap: wrap; gap: 8px; }
.choices label {
  display: inline-flex; align-items: center; min-height: 40px; padding: 6px 16px 6px 12px; border-radius: 999px;
  border: 1px solid var(--mist); background: var(--surface); cursor: pointer;
}
.choices label:hover { border-color: var(--faint); }
.choices label:has(input:checked) { border-color: var(--signal); background: var(--signal-soft); }
.choices label:has(input:focus-visible) { outline: 2px solid var(--signal); outline-offset: 2px; }

/* ---------- Contacts: list, upload steps, delete ---------- */
.notice { padding: 12px 16px; border: 1px solid var(--mist); border-left: 4px solid var(--signal); border-radius: 12px; background: var(--surface); max-width: 44rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 16px; max-width: 48rem; }
.form-grid > * + * { margin-top: 0; }
.form-grid input:not([type="checkbox"]):not([type="radio"]), .form-grid select { max-width: none; }
.check { display: block; font-weight: 400; max-width: 44rem; }
.wrap { overflow-wrap: break-word; }
td .chip { white-space: normal; border-radius: 14px; }
td.go, td.nowrap { white-space: nowrap; }
td.go > * + * { margin-left: 10px; }
.pager { display: flex; align-items: center; gap: 12px; color: var(--slate); }
/* Settings > Plan: usage bars. The numbers are written beside each bar, so colour is never the only signal. */
.meter-row + .meter-row { margin-top: 18px; }
.meter-label { display: flex; justify-content: space-between; gap: 12px; font-weight: 500; }
.meter { height: 10px; margin-top: 6px; border-radius: 99px; background: var(--mist); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--signal); border-radius: 99px; }
.meter-near > span { background: var(--mid); }
.meter-over > span { background: var(--lo); }
.notice-lo { border-left-color: var(--lo); }  /* stopped: paused, closed, over the plan, a failed payment */
.notice-mid { border-left-color: var(--mid); }  /* not yet: switched off for now, or something still to do */
/* Two-step login: the QR code, the key to type, and the recovery codes. */
.qr { display: block; margin: 10px 0; background: #fff; padding: 8px; border: 1px solid var(--mist); border-radius: 10px; }
.secret { display: block; margin: 6px 0; padding: 8px 10px; border-radius: 8px; background: var(--cloud); font-size: .95rem; overflow-wrap: anywhere; }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 8px; }
.codes li, .page .codes li + li { margin: 0; }
.codes code { display: block; padding: 8px 10px; border-radius: 8px; background: var(--cloud); text-align: center; font-size: 1rem; letter-spacing: .04em; }
/* Settings > Team: a table card with its own heading, and a role picker with its Save button on one line. */
.card-table > .card-title { padding: 18px 24px 6px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.inline-form select { width: auto; min-height: 34px; margin-top: 0; padding: 5px 10px; }
.btn-danger, button.btn-danger { border-color: var(--lo); color: var(--lo-ink); background: var(--surface); }
.btn-danger:hover, button.btn-danger:hover { background: var(--lo-soft); border-color: var(--lo); }
.narrow, .page > form.narrow { max-width: 40rem; }
/* Settings > Company details: as wide as the form above it; the DNS records are long, so they may break anywhere. */
.page > .own-address { max-width: 44rem; scroll-margin-top: 16px; }
.own-address code { font-size: 0.8125rem; overflow-wrap: anywhere; }
/* Stopping is folded away: a second, deliberate step, never a button beside "Check now". */
.own-address .stop > summary { cursor: pointer; color: var(--slate); font-size: .9rem; width: fit-content; }
.own-address .stop[open] > summary { color: var(--ink); }
.own-address .stop > * + * { margin-top: 10px; }
.stepper { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 24px; color: var(--slate); max-width: none; }
.stepper li { display: flex; align-items: center; gap: 10px; margin: 0; }
.stepper [aria-current="step"] { color: var(--ink); font-weight: 600; }
.stepper [aria-current="step"] .step-n { background: var(--signal); border-color: var(--signal); color: var(--on-signal); }

/* Create a survey: one template per row, its name and then the opening line it starts with. */
.templates { max-width: 44rem; margin-top: 18px; }
.templates label { display: flex; align-items: baseline; gap: 4px; padding: 10px 12px; border: 1px solid var(--mist); border-radius: 10px; font-weight: 400; cursor: pointer; }
.templates label > span > span { display: block; font-size: .9rem; }
.templates label:hover { border-color: var(--faint); }
.templates label:has(input:checked) { border-color: var(--signal); background: var(--signal-soft); }
.templates label:has(input:focus-visible) { outline: 2px solid var(--signal); outline-offset: 2px; }

/* ---------- Sign-in, sign-up and password pages (no sidebar) ---------- */
.plain { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 40px 16px 24px; background: linear-gradient(180deg, var(--cloud), var(--paper) 420px); }
.plain-brand { display: block; margin-bottom: 28px; }
.plain-brand img { display: block; height: 21px; width: auto; }
.plain-card { width: 100%; max-width: 30rem; background: var(--surface); border: 1px solid var(--mist); border-radius: 20px; padding: 32px 28px; }
.plain-card > * + * { margin-top: 16px; }
.plain-card h1 { font: 500 2rem/1.15 var(--display); letter-spacing: -0.02em; }
.plain-card input:not([type="checkbox"]):not([type="radio"]), .plain-card select { max-width: none; }
.plain-card button[type="submit"] { width: 100%; justify-content: center; min-height: 46px; }
.plain-card button.linkish { width: auto; min-height: 0; background: none; border: 0; color: var(--signal-ink); }
.plain-card form > * + * { margin-top: 16px; }
.plain-card .helptext ul { font-size: .875rem; color: var(--slate); padding-left: 1.1rem; margin: 4px 0 0; }
.plain .site-footer { padding: 24px 0 0; justify-content: center; }

/* ---------- Medium and small screens ---------- */
@media (max-width: 1180px) {
  .cols, .cols-even { grid-template-columns: minmax(0, 1fr); }
  .survey { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .app { display: block; }
  .app::before { display: none; }
  .side {
    position: static; max-height: none; overflow: visible; padding: 12px 16px 0;
    display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px 12px; align-items: center;
    background: var(--cloud); border-bottom: 1px solid var(--mist);
  }
  .firm { margin-bottom: 0; padding: 8px 10px; }
  .nav { grid-column: 1 / -1; grid-row: 2; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; }
  .nav a { justify-content: center; gap: 8px; padding: 10px 4px; border-radius: 0; border: 0; border-bottom: 3px solid transparent; font-size: .92rem; }
  .nav a[aria-current="page"] { background: none; border-bottom-color: var(--signal); }
  .nav .icon { width: 18px; height: 18px; }
  .side-label, .recent { display: none; }
  .side-foot { position: static; padding: 16px; border-top: 1px solid var(--mist); background: var(--cloud); }
  .main { min-height: 0; }
  .topbar { padding: 10px 16px; min-height: 0; }
  .topbar-actions { margin-left: 0; width: 100%; }
  .topbar-actions:empty { display: none; }
  .topbar-actions .btn, .topbar-actions .menu { flex: 1 1 40%; justify-content: center; }
  .topbar-actions .menu > summary { width: 100%; }
  .page { padding: 20px 16px 32px; }
  .site-footer { padding: 12px 16px 24px; }
  h1 { font-size: 1.4rem; }
  .card { padding: 18px 16px; }
  .empty { padding: 26px 18px; }
  .empty h2 { font-size: 1.6rem; }
  .plain-card { padding: 24px 18px; }
  td.go { white-space: normal; }
  .wrap { overflow-wrap: anywhere; }
  .stepper li:not([aria-current]) { font-size: .9rem; }
  .survey { grid-template-columns: minmax(0, 1fr); }
  .ways { grid-template-columns: minmax(0, 1fr); }
  /* A table with class "stack" becomes one block per row, each value under its column name. */
  .card-table { padding: 0; }
  .card-table > .card-title { padding: 16px 16px 4px; }
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack, table.stack tbody, table.stack td { display: block; }
  table.stack tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; padding: 14px 16px; border-top: 1px solid var(--mist); }
  table.stack tr:first-child { border-top: 0; }
  .card-table > table.stack td, table.stack td { padding: 0; border: 0; text-align: left; }
  table.stack td.lead, table.stack td.go, table.stack td.wide { grid-column: 1 / -1; }
  table.stack td[data-label]:empty { display: none; }
  table.stack td[data-label]::before { content: attr(data-label); display: block; font-size: .78rem; color: var(--faint); }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .result-summary { grid-template-columns: minmax(0, 1fr); padding: 18px 16px; }
  .result-score { padding: 0 0 14px; border-right: 0; border-bottom: 1px solid var(--mist); }
  .result-detail { padding: 14px 0 0; }
  .result-score .stat-value { font-size: 3rem; }
  .stat { padding: 14px 16px; }
  .chart text { font-size: 17px; }
  .chart text.band { font-size: 14px; }
}
