/* The Control Room.
 *
 * Written for two readers - the owner and one colleague - confirming a proposal, often
 * on a phone, often standing up. Three consequences show up in every rule below.
 *
 * Mobile first. Every layout here starts as one column and only widens at 40rem. The
 * proposal is 778 lines long; a table that needs sideways scrolling on a phone is a
 * table nobody finishes reading.
 *
 * The WORDING is the thing being judged, not the machine name, so the real phrasing sits
 * at full size and the canonical name is muted traceability text beneath it.
 *
 * Every control is at least 44px tall. A mis-tap on Accept is not a typo anyone notices.
 *
 * Tokens with the same fallbacks the other IQ views use, so this page cannot drift from
 * the rest of the product's theme.
 */
:root {
  --paper: #f9fafb; --surface: #ffffff; --ink: #111827; --muted: #6b7280;
  --line: #e5e7eb; --blue: #1d4ed8; --red: #b91c1c; --green: #15803d; --amber: #b45309;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.room { max-width: 60rem; margin: 0 auto; padding: 1rem 1rem 3rem; }
h1 { font-size: 1.5rem; margin-block: 0 .25rem; }
h2 { font-size: 1.125rem; margin-block: 0 .5rem; }
h3 { font-size: 1rem; margin-block: 0 .35rem; }
p { margin-block: .35rem; }

.masthead { margin-block-end: 1rem; }
.brand { color: var(--muted); font-size: .8125rem; letter-spacing: .04em; text-transform: uppercase; margin: 0; }
.lede { color: var(--muted); }
.footer { margin-block-start: 2rem; padding-block-start: 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; }
.muted { color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.error { color: var(--red); font-weight: 600; }
.status { color: var(--muted); font-size: .875rem; min-height: 1.5rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .5rem;
  padding: 1rem;
  margin-block: 1rem;
}

/* The proposal notice. The single most important sentence on the page: it is the reason
 * a reader is allowed to disagree with everything below it. */
.notice {
  border-left: 3px solid var(--blue);
  background: var(--surface);
  border-radius: .25rem;
  padding: .75rem 1rem;
  margin-block: 1rem;
}
.notice strong { display: block; letter-spacing: .04em; text-transform: uppercase; font-size: .8125rem; color: var(--blue); }

button {
  font: inherit;
  min-height: 44px;
  padding: .5rem 1rem;
  border: 1px solid var(--line);
  border-radius: .375rem;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
button.danger { border-color: var(--red); color: var(--red); }
button.quiet { border: 0; color: var(--muted); margin-inline-start: auto; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-block-start: .75rem; }

label { display: block; font-size: .875rem; font-weight: 600; margin-block: .75rem .25rem; }
input, textarea {
  font: inherit;
  width: 100%;
  min-height: 44px;
  padding: .5rem .625rem;
  border: 1px solid var(--line);
  border-radius: .375rem;
  background: var(--surface);
  color: var(--ink);
}
textarea { min-height: 5rem; resize: vertical; }
input:focus-visible, textarea:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.tabs { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-block: 1rem; }
.tabs button[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }

/* ---- one trade, then its lines ------------------------------------------------- */
.trade { margin-block: 1.5rem; }
.trade > h3 { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; }
.trade-count { color: var(--muted); font-weight: 400; font-size: .875rem; }

/* One candidate line. Closed it is a name, a price range and what was decided; open it
 * is the evidence. <details> rather than a JavaScript drawer: it works before the script
 * runs, it is keyboard-operable for free, and it cannot get out of step with itself. */
.candidate { background: var(--surface); border: 1px solid var(--line); border-radius: .5rem; margin-block: .5rem; }
.candidate > summary {
  display: block; /* the default marker box breaks the grid on Safari */
  list-style: none;
  padding: .75rem;
  min-height: 44px;
  cursor: pointer;
}
.candidate > summary::-webkit-details-marker { display: none; }
/* One fact per line on a phone. These are inline spans so that the wide layout can place
 * them in a grid; left inline at narrow widths they run together into
 * "...DB Box / tripRM 100.00 - RM 150.00602 quotations", which is unreadable and was
 * exactly what the 400px screenshot showed. Direct children only: the amounts INSIDE
 * .range must stay on one line. */
.candidate > summary > span { display: block; }
.candidate > summary > .muted { margin-block-start: .25rem; }
.candidate > summary::after { content: "Show the quotations"; display: block; color: var(--blue); font-size: .8125rem; margin-block-start: .35rem; }
.candidate[open] > summary::after { content: "Hide the quotations"; }
.candidate[data-decided="accept"] { border-left: 4px solid var(--green); }
.candidate[data-decided="amend"] { border-left: 4px solid var(--amber); }
.candidate[data-decided="strike"] { border-left: 4px solid var(--red); }

.headline { font-weight: 600; }
.range { font-size: 1.125rem; font-weight: 700; margin-block: .25rem; }
.range .middle { color: var(--blue); }
.verdict { font-size: .875rem; font-weight: 600; margin-block-start: .35rem; }
.verdict[data-decision="accept"] { color: var(--green); }
.verdict[data-decision="amend"] { color: var(--amber); }
.verdict[data-decision="strike"] { color: var(--red); }
.verdict[data-decision="none"] { color: var(--muted); font-weight: 400; }

.drawer { padding: 0 .75rem .75rem; border-top: 1px solid var(--line); }
.phrasing { margin-block: .5rem; padding-inline-start: .75rem; border-left: 2px solid var(--line); }
.phrasing .text { overflow-wrap: anywhere; }

/* The numbers, as three labelled figures rather than a row nobody can read on a phone. */
.figures { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-block: .75rem; }
.figures div { background: var(--paper); border-radius: .375rem; padding: .5rem; text-align: center; }
.figures dt { color: var(--muted); font-size: .75rem; }
.figures dd { margin: 0; font-weight: 700; }

.choice-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.choice-row button { flex: 1 1 8rem; }

/* ---- the business-unit registry -------------------------------------------------- */
.units { list-style: none; margin: 0; padding: 0; }
.unit {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .25rem .75rem;
  align-items: baseline;
  padding: .625rem .75rem;
  min-height: 44px;
  border-top: 1px solid var(--line);
}
.unit:first-child { border-top: 0; }
.unit .groups { grid-column: 1 / -1; color: var(--muted); font-size: .8125rem; }
.unit .lines { font-weight: 700; font-variant-numeric: tabular-nums; }
.unit[data-empty="yes"] .lines { color: var(--muted); font-weight: 400; }
/* The one number that says how complete the registry is. */
.unit[data-code="unassigned"] { background: #fff7ed; border-left: 4px solid var(--amber); }
.unit[data-code="unassigned"] .lines { color: var(--amber); }

.tally { display: flex; flex-wrap: wrap; gap: 1rem; margin-block: .75rem; }
.tally div { flex: 1 1 7rem; }
.tally dt { color: var(--muted); font-size: .8125rem; }
.tally dd { margin: 0; font-size: 1.25rem; font-weight: 700; }
.tally div[data-highlight="yes"] dd { color: var(--amber); }

@media (min-width: 40rem) {
  .room { padding-inline: 1.5rem; }
  h1 { font-size: 1.875rem; }
  .candidate > summary { display: grid; grid-template-columns: 1fr auto; gap: .25rem 1rem; align-items: baseline; }
  .candidate > summary::after { grid-column: 1 / -1; }
  .range { text-align: right; }
}
