/* Sochle web app (manager console and rep pages). Colours are defined once here and swap with the system theme. */
:root {
  color-scheme: light;
  --bg: #F3F6F5;
  --surface: #FFFFFF;
  --ink: #15211E;
  --muted: #56665F;
  --line: #D3DDD9;
  --accent: #0B6E5E;
  --accent-soft: #DCEEE9;
  --on-accent: #FFFFFF;
  --warn: #8F5400;
  --warn-soft: #FAEED3;
  --critical: #A5311F;
  --critical-soft: #F8E0DA;
  --good: #1D7439;
  --good-soft: #DCF0E1;

  /* Chart marks only. Checked for colour-blind separation on both surfaces. */
  --data-1: #2a78d6;
  --data-1-track: #cde2fb;
  --data-2: #eb6834;
  --data-neutral: #93a19c;

  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0E1513;
    --surface: #161F1C;
    --ink: #E3ECE8;
    --muted: #9BABA5;
    --line: #2B3733;
    --accent: #5CC9B0;
    --accent-soft: #143A33;
    --on-accent: #0E1513;
    --warn: #E9B458;
    --warn-soft: #382B0F;
    --critical: #F08A75;
    --critical-soft: #3C1912;
    --good: #6FCF8B;
    --good-soft: #14311F;

    --data-1: #3987e5;
    --data-1-track: #0d366b;
    --data-2: #d95926;
    --data-neutral: #6b7a75;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

h1,
h2,
h3,
p,
ul,
ol,
dl,
dd,
figure {
  margin: 0;
}

h1 {
  font-size: 1.5rem;
  line-height: 1.25;
  font-weight: 650;
}

h2 {
  font-size: 1.05rem;
  line-height: 1.3;
  font-weight: 650;
}

h3 {
  font-size: 0.95rem;
  font-weight: 650;
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

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

main:focus {
  outline: none;
}

.boot {
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.87rem;
}

.dash {
  color: var(--muted);
}

.nowrap {
  white-space: nowrap;
}

/* ---------- page frame ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px 24px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
  padding: 12px 0;
}

.nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  flex: 1 1 auto;
  min-width: 0;
  scrollbar-width: thin;
}

.nav a {
  flex: none;
  padding: 14px 10px 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 550;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.nav a:hover {
  color: var(--ink);
}

.nav a[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.who {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 8px 0;
}

main {
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.page-head {
  margin-bottom: 20px;
}

.page-head p {
  color: var(--muted);
  margin-top: 4px;
  max-width: 72ch;
}

.crumb {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  text-decoration: none;
}

.crumb:hover {
  text-decoration: underline;
}

.stack > * + * {
  margin-top: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

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

.card > h2 {
  margin-bottom: 4px;
}

.card > h2 + .muted {
  margin-bottom: 14px;
}

.card > h2:only-child {
  margin-bottom: 0;
}

.card-flush {
  padding: 0;
}

.card-flush > .card-head {
  padding: 16px 20px 12px;
}

.card-foot {
  padding: 12px 20px 16px;
  color: var(--muted);
  font-size: 0.87rem;
  border-top: 1px solid var(--line);
}

.empty {
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
}

.empty strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
}

/* ---------- notices ---------- */
.notice {
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px 16px;
}

.notice.warn {
  border-color: var(--warn);
  background: var(--warn-soft);
  color: var(--ink);
}

.notice.warn strong {
  color: var(--warn);
}

.notice.critical {
  border-color: var(--critical);
  background: var(--critical-soft);
}

.notice.critical strong {
  color: var(--critical);
}

.notice.good {
  border-color: var(--good);
  background: var(--good-soft);
}

.notice.good strong {
  color: var(--good);
}

.notice.info {
  border-left-color: var(--muted);
}

/* ---------- badges ---------- */
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 550;
  line-height: 1.5;
  white-space: nowrap;
}

.badge.good {
  background: var(--good-soft);
  border-color: transparent;
  color: var(--good);
}

.badge.warn {
  background: var(--warn-soft);
  border-color: transparent;
  color: var(--warn);
}

.badge.critical {
  background: var(--critical-soft);
  border-color: transparent;
  color: var(--critical);
}

.badge.quiet {
  color: var(--muted);
  font-weight: 500;
}

.trend-up {
  color: var(--good);
  font-weight: 550;
}

.trend-down {
  color: var(--critical);
  font-weight: 550;
}

/* ---------- buttons and forms ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.btn:hover {
  border-color: var(--muted);
}

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

.btn.primary:hover {
  filter: brightness(1.08);
}

.btn.quiet {
  border-color: transparent;
  background: transparent;
  color: var(--accent);
  padding: 6px 8px;
}

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

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

label,
.label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.hint {
  color: var(--muted);
  font-size: 0.87rem;
  font-weight: 400;
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}

textarea {
  resize: vertical;
  min-height: 2.6em;
}

textarea.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.87rem;
  white-space: pre;
  overflow-x: auto;
}

input[type="file"] {
  font: inherit;
  color: var(--muted);
  max-width: 100%;
}

.field + .field {
  margin-top: 14px;
}

.grid-2 > .field {
  margin-top: 0;
  display: flex;
  flex-direction: column;
}

/* Inputs in a row line up along the bottom even when only one has a hint above it. */
.grid-2 > .field > input {
  margin-top: auto;
}

form > .grid-2 + .field,
form > .grid-2 + .actions {
  margin-top: 14px;
}

.form-status {
  min-height: 1.5em;
  font-size: 0.92rem;
}

.form-status.ok {
  color: var(--good);
}

.form-status.bad {
  color: var(--critical);
}

.rows > .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto;
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.rows > .row:first-child {
  border-top: 0;
}

.rows label {
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0;
}

.rows input,
.rows textarea {
  display: block;
  margin-top: 4px;
  font-size: 0.95rem;
  font-weight: 400;
}

.rows .row > button {
  align-self: center;
  justify-self: start;
}

fieldset {
  border: 0;
  padding: 0;
  margin: 22px 0 0;
  min-width: 0;
}

legend {
  padding: 0;
  font-weight: 650;
  font-size: 0.95rem;
}

/* ---------- sign in ---------- */
.signin {
  max-width: 380px;
  margin: 10vh auto 0;
  padding: 0 16px;
}

.signin h1 {
  margin-bottom: 4px;
}

.signin .card {
  margin-top: 20px;
}

/* ---------- tables ---------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

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

thead th {
  border-top: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  vertical-align: bottom;
}

.card-flush table th:first-child,
.card-flush table td:first-child {
  padding-left: 20px;
}

.card-flush table th:last-child,
.card-flush table td:last-child {
  padding-right: 20px;
}

.card-flush .table-wrap {
  border-top: 1px solid var(--line);
}

th.num,
td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

tbody th {
  font-weight: 600;
}

tr[data-href] {
  cursor: pointer;
}

tr[data-href]:hover td,
tr[data-href]:hover th {
  background: var(--bg);
}

.rate .of,
.of {
  color: var(--muted);
  font-size: 0.87em;
}

.cell-sub {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.wide-cell {
  min-width: 140px;
}

.note-cell {
  min-width: 260px;
}

/* ---------- headline answer ---------- */
.answer .question {
  color: var(--muted);
  font-size: 0.92rem;
}

.answer .verdict {
  font-size: 1.75rem;
  line-height: 1.2;
  font-weight: 650;
  margin: 6px 0 8px;
}

.answer p {
  max-width: 72ch;
}

.answer .progress {
  margin-top: 14px;
  max-width: 360px;
}

/* ---------- chart marks ---------- */
.meter {
  height: 8px;
  border-radius: 4px;
  background: var(--data-1-track);
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  background: var(--data-1);
  border-radius: 4px;
}

.score {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.score .meter {
  width: 56px;
  height: 6px;
  flex: none;
}

.funnel {
  display: grid;
  gap: 12px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  align-items: center;
  gap: 4px 12px;
}

.funnel-name {
  font-weight: 600;
  font-size: 0.92rem;
}

.funnel-plot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 10px;
  min-width: 0;
  border-left: 1px solid var(--line);
  padding: 3px 0;
}

.funnel-bar {
  flex: none;
  height: 16px;
  width: calc((100% - 13rem) * var(--share, 0));
  background: var(--data-1);
  border-radius: 0 4px 4px 0;
}

.funnel-row:hover .funnel-bar {
  filter: brightness(1.12);
}

.funnel-val {
  flex: none;
  white-space: nowrap;
  font-size: 0.92rem;
}

.funnel-val strong {
  font-weight: 650;
}

.quad {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.quad-cell {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
  min-width: 0;
}

.quad-kind {
  color: var(--muted);
  font-size: 0.85rem;
}

.quad-meaning {
  font-weight: 650;
}

.quad-n {
  font-size: 1.6rem;
  font-weight: 650;
  line-height: 1.2;
  margin-top: 8px;
}

.quad-n span {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
}

.quad-win {
  font-size: 0.9rem;
  margin: 2px 0 8px;
}

.seg {
  display: flex;
  gap: 2px;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}

.seg.dense {
  height: 4px;
  max-width: 180px;
  margin-bottom: 4px;
}

.seg > span {
  flex: 0 0 auto;
  min-width: 2px;
}

.seg > span:hover {
  filter: brightness(1.12);
}

.seg-lead,
.sw-lead {
  background: var(--data-1);
}

.seg-rep,
.sw-rep {
  background: var(--data-2);
}

.seg-unclear,
.sw-unclear {
  background: var(--data-neutral);
}

.sw {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: baseline;
}

.legend {
  list-style: none;
  padding: 0;
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.legend li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: baseline;
}

.legend .what {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  padding-left: 16px;
}

.loss-inline {
  display: flex;
  gap: 2px 10px;
  font-size: 0.87rem;
  white-space: nowrap;
}

.spark {
  display: block;
  overflow: visible;
}

.spark polyline {
  fill: none;
  stroke: var(--data-1);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.spark .spark-end {
  fill: var(--data-1);
  stroke: var(--surface);
  stroke-width: 2;
}

.spark .spark-mid {
  stroke: var(--line);
  stroke-width: 1;
}

.tip {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  background: var(--ink);
  color: var(--bg);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.82rem;
  line-height: 1.35;
  max-width: 240px;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.25);
}

.tip strong {
  display: block;
  font-size: 0.95rem;
}

/* ---------- stat tiles ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.tile {
  padding: 14px 18px;
  box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line);
}

.tile dt {
  color: var(--muted);
  font-size: 0.85rem;
}

.tile dd {
  font-size: 1.3rem;
  font-weight: 650;
  line-height: 1.3;
  margin-top: 2px;
}

.tile dd .of,
.tile dd .unit {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
}

.tile dd .unit {
  display: block;
}

/* ---------- detail pages ---------- */
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px 20px;
}

.facts dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.facts dd {
  font-weight: 550;
  overflow-wrap: anywhere;
}

.quotes {
  list-style: none;
  padding: 0;
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.quotes li {
  border-left: 2px solid var(--line);
  padding-left: 10px;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.ts {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.85rem;
  margin-right: 6px;
}

button.ts {
  font-family: inherit;
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.plain-list {
  padding-left: 1.1rem;
  display: grid;
  gap: 4px;
}

.focus-area {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
}

.focus-area dl {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.focus-area dt {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.plan-headline {
  font-size: 1.15rem;
  font-weight: 650;
  margin: 6px 0 2px;
}

.transcript {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 10px;
}

.transcript li {
  display: grid;
  grid-template-columns: 52px 84px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}

.transcript .who-rep {
  font-weight: 650;
}

.transcript .who-other {
  font-weight: 650;
  color: var(--muted);
}

.transcript .said {
  overflow-wrap: anywhere;
}

audio {
  width: 100%;
  max-width: 560px;
  display: block;
}

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .card {
    padding: 16px;
  }

  .card-flush {
    padding: 0;
  }

  .card-flush > .card-head {
    padding: 14px 16px 10px;
  }

  .card-flush table th:first-child,
  .card-flush table td:first-child {
    padding-left: 16px;
  }

  .who {
    width: 100%;
    justify-content: space-between;
    border-top: 1px solid var(--line);
  }

  .topbar-inner {
    gap: 0 16px;
  }

  .nav {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .nav a {
    padding: 10px 10px 8px;
  }

  .funnel-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .funnel-bar {
    width: calc((100% - 10.5rem) * var(--share, 0));
  }

  .rows > .row {
    grid-template-columns: minmax(0, 1fr);
  }

  .transcript li {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .transcript .said {
    grid-column: 1 / -1;
  }

  .answer .verdict {
    font-size: 1.45rem;
  }
}

@media (max-width: 420px) {
  .quad {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .btn,
  .nav a {
    transition: color 0.12s, background-color 0.12s, border-color 0.12s;
  }
}

/* A transcript line the coach attached a note to. */
.transcript li.flagged {
  background: var(--warn-soft, #faeed3);
  border-left: 3px solid var(--warn, #8f5400);
  border-radius: 4px;
  padding: 8px 10px;
}

.transcript .coach-note {
  display: block;
  margin-top: 6px;
  font-size: 0.92em;
}

/* ---------- signed-in frame additions ---------- */
.brand-org {
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
  font-weight: 500;
  font-size: 0.92rem;
  color: var(--muted);
}

.who a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 550;
}

.who a:hover {
  text-decoration: underline;
}

.role-tag {
  margin-left: 8px;
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

.shell-notice {
  max-width: 1160px;
  margin: 16px auto 0;
  padding: 0 16px;
}

select {
  width: auto;
  max-width: 100%;
}

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

label.choice {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-weight: 500;
  margin: 6px 0 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- progress ---------- */
.delta {
  font-weight: 600;
  white-space: nowrap;
}

.tile dd .arrow {
  color: var(--muted);
  font-weight: 400;
}

.tiles-inset {
  border-width: 1px 0 0;
  border-radius: 0;
}

.chart {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 4px;
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-tick {
  fill: var(--muted);
  font-size: 11px;
}

.chart-line {
  fill: none;
  stroke: var(--data-1);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-dot {
  fill: var(--data-1);
  stroke: var(--surface);
  stroke-width: 2;
}

.chart-last {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 650;
}

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

.chart-empty {
  padding: 24px 0;
}

details.data-table > summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 550;
}

details.data-table[open] > summary {
  margin-bottom: 12px;
}

/* ---------- ask the coach ---------- */
.chat {
  max-width: 820px;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 58vh;
  min-height: 140px;
  overflow-y: auto;
  padding-bottom: 6px;
}

.bubble {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble.mine {
  align-self: flex-end;
  background: var(--accent);
  color: var(--on-accent);
}

.bubble.coach {
  align-self: flex-start;
  border: 1px solid var(--line);
  background: var(--bg);
}

.bubble-who {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
}

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

.chat-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 12px;
}

.chat-form textarea {
  flex: 1 1 auto;
}

@media (max-width: 760px) {
  .brand-org {
    display: none;
  }

}
