:root {
  /* The dark look is the standard look of the site, whatever the device is set to. */
  color-scheme: dark;
  --bg: #15171a; --card: #1f2226; --text: #e8e9eb; --muted: #9aa0a8; --line: #33373d;
  --accent: #ffb500; --accent-ink: #1d1d1f; --link: #6cb2ff;
  --good: #5bd17a; --bad: #ff7b7b; --ok-bg: #173323; --err-bg: #3a1c1c;
}
.brand img { background: #fff; border-radius: 4px; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--link); }
main { max-width: 1100px; margin: 0 auto; padding: 16px 16px 80px; }
h1 { font-size: 1.6rem; margin: 8px 0 12px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 16px 0 6px; }
code, pre { font-family: ui-monospace, Consolas, monospace; }
pre { background: var(--bg); border: 1px solid var(--line); padding: 10px; border-radius: 6px; overflow-x: auto; }

.top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
       background: var(--card); border-bottom: 3px solid var(--accent); padding: 8px 16px; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 1.05rem; }
.brand img { height: 52px; }
/* Top right: who is logged in and the three bars; the bars open the menu. */
.menu { position: relative; margin-left: auto; }
.menu summary { display: flex; align-items: center; gap: 12px; cursor: pointer; list-style: none; padding: 6px 8px; border-radius: 6px; user-select: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover, .menu[open] summary { background: var(--bg); }
.who { font-weight: 500; }
.bars { display: inline-flex; flex-direction: column; gap: 4px; }
.bars i { display: block; width: 22px; height: 3px; border-radius: 2px; background: var(--text); }
.menu nav { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 220px; display: flex; flex-direction: column;
            background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
.menu nav a { text-decoration: none; font-weight: 500; padding: 9px 12px; border-radius: 6px; white-space: nowrap; }
.menu nav a:hover, .menu nav a:focus-visible { background: var(--bg); }
.menu nav a:last-child { border-top: 1px solid var(--line); border-radius: 0 0 6px 6px; margin-top: 4px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin: 0 0 16px; }
.narrow { max-width: 420px; margin: 40px auto; }
.muted { color: var(--muted); }
.small { font-size: 0.88em; }
.flash { padding: 10px 14px; border-radius: 6px; margin: 0 0 12px; background: var(--ok-bg); border: 1px solid var(--good); }
.flash.err { background: var(--err-bg); border-color: var(--bad); }

label { display: block; margin: 0 0 12px; font-weight: 500; }
label.check { display: flex; align-items: center; gap: 6px; font-weight: 400; }
input, select, textarea, button, .button { font: inherit; color: inherit; }
input:not([type=radio]):not([type=checkbox]):not([type=file]), select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 7px 9px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--card); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
button, .button { display: inline-block; padding: 7px 14px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); cursor: pointer; text-decoration: none; white-space: nowrap; }
button:hover, .button:hover { filter: brightness(0.96); }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.danger { color: var(--bad); }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; }

.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.row > label { flex: 1 1 160px; }
.row > label.check { flex: 0 0 auto; }
.row > .grow { flex: 1 1 300px; align-self: flex-start; }
.row > button { margin-bottom: 12px; }
form.inline { display: inline-flex; gap: 4px; align-items: center; margin: 2px 0; }
form.inline input { width: auto !important; display: inline-block !important; margin: 0 !important; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--text); border-color: var(--accent); font-weight: 600; }

.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; vertical-align: top; padding: 8px; border-bottom: 1px solid var(--line); }
th { font-size: 0.85em; color: var(--muted); font-weight: 600; }
td.actions { white-space: nowrap; }
.tag { display: inline-block; font-size: 0.78em; padding: 0 6px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.correct { color: var(--good); font-weight: 600; }
.correct::after { content: " ✓"; }
.good { color: var(--good); font-weight: 600; }
.bad { color: var(--bad); font-weight: 600; }

.group h2 { margin: 24px 0 10px; padding-left: 10px; border-left: 4px solid var(--accent); }
fieldset.q { margin: 0 0 12px; }
fieldset.q legend { float: left; width: 100%; padding: 0; margin-bottom: 10px; font-weight: 600; }
fieldset.q legend + * { clear: both; }
.num { color: var(--muted); }
.qimg { display: block; max-width: 100%; max-height: 360px; margin: 0 0 12px; border: 1px solid var(--line); border-radius: 6px; }
.opt { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; padding: 8px 10px; margin: 0 0 6px;
       border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.opt:hover { border-color: var(--accent); }
.opt input { margin-top: 4px; }
.opt:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.savebar { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; border-top: 1px solid var(--line); text-align: right; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 0.88em; }

/* ---- cases ---- */
.crumb { margin: 4px 0 0; }
.crumb a { text-decoration: none; }
.badge { display: inline-block; vertical-align: middle; font-size: 0.75rem; font-weight: 600; padding: 2px 10px; border-radius: 12px;
         border: 1px solid var(--line); background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge.progress { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 22%, transparent); }
.badge.done { border-color: var(--good); color: var(--good); background: var(--ok-bg); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0 0 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--line); border-radius: 8px; padding: 10px 14px;
        text-decoration: none; color: var(--text); display: flex; flex-direction: column; }
.stat b { font-size: 1.7rem; line-height: 1.2; }
.stat span { color: var(--muted); }
.stat.progress { border-top-color: var(--accent); }
.stat.done { border-top-color: var(--good); }
.casegroup { margin-top: 24px; }
.casegroup h2 { margin: 0; padding-left: 10px; border-left: 4px solid var(--line); }
.casegroup#progress h2 { border-left-color: var(--accent); }
.casegroup#done h2 { border-left-color: var(--good); }
.casegroup > p { margin: 2px 0 10px; }
.count { font-weight: 400; color: var(--muted); }
.caselist { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
a.case { display: flex; flex-direction: column; margin: 0; text-decoration: none; color: var(--text); }
a.case:hover { border-color: var(--accent); }
a.case h3 { margin: 0 0 6px; font-size: 1.05rem; }
a.case .desc { margin: 0 0 10px; color: var(--muted); font-size: 0.92em; flex: 1; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: auto; }
.bar i { display: block; height: 100%; background: var(--accent); }
a.case.done .bar i { background: var(--good); }
a.case .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 10px 0 0; font-size: 0.88em; color: var(--muted); }
.casedesc p { margin: 0 0 8px; }
.casedesc p:last-child { margin: 0; }
.savebar { display: flex; justify-content: flex-end; gap: 8px; }
textarea:disabled, input:disabled { opacity: 1; color: var(--text); background: var(--bg); }
.opt:has(input:disabled) { cursor: default; }
.opt:has(input:disabled):hover { border-color: var(--line); }
.opt:has(input:disabled:checked):hover { border-color: var(--accent); }
table.matrix th, table.matrix td { white-space: nowrap; }
@media (max-width: 520px) { .stats { gap: 6px; } .stat { padding: 8px; } .stat b { font-size: 1.3rem; } }

/* ---- review and follow-up questions ---- */
.flash.warn { background: color-mix(in srgb, var(--accent) 16%, var(--card)); border-color: var(--accent); }
.futag { display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 1px 8px; border-radius: 10px; vertical-align: middle;
         background: var(--accent); color: var(--accent-ink); white-space: nowrap; }
fieldset.q.fu { border-color: var(--accent); border-left-width: 4px; margin-left: 20px; }
.fuby { clear: both; margin: 0 0 8px; }
.funote { margin: 0 0 10px; font-size: 0.88em; font-weight: 600; padding: 4px 8px; border-radius: 6px;
          background: color-mix(in srgb, var(--accent) 22%, transparent); }
.review h3 { margin: 0 0 10px; }
.ropt { display: flex; gap: 10px; align-items: baseline; padding: 6px 10px; margin: 0 0 4px; border: 1px solid var(--line); border-radius: 6px; }
.ropt .mark { color: var(--muted); }
.ropt.picked { font-weight: 600; border-color: var(--muted); }
.ropt.right { border-color: var(--good); background: var(--ok-bg); }
.ropt.wrong { border-color: var(--bad); background: var(--err-bg); }
.ropt .tag { margin-left: auto; font-weight: 400; }
.answer { white-space: normal; padding: 8px 10px; border-left: 3px solid var(--line); background: var(--bg); border-radius: 0 6px 6px 0; }
.futhread { margin: 12px 0 0 20px; padding: 8px 12px; border-left: 4px solid var(--accent); }
.futhread p { margin: 0 0 4px; }
.waiting { font-weight: 600; }
button.link { border: 0; background: none; padding: 0 0 0 8px; text-decoration: underline; font-weight: 400; }
details.ask { margin-top: 12px; }
details.ask summary { cursor: pointer; color: var(--link); width: fit-content; }
details.ask[open] summary { margin-bottom: 6px; }
.savebar { align-items: center; }
a.cell { text-decoration: none; display: inline-flex; gap: 6px; align-items: center; }
a.cell:hover .small { text-decoration: underline; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px 16px; margin: 0 0 12px; }
.checks label { margin: 0; padding: 4px 0; }
form.inline select { width: auto; display: inline-block; margin: 0; }
.nowrap { white-space: nowrap; }

/* ---- manager edits and simultaneous editing ---- */
.offscreen { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.flash.live { position: sticky; top: 8px; z-index: 5; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); }
.flash.live button { margin-left: 8px; }
fieldset.q.edited { border-left: 4px solid var(--accent); }
.recheck { clear: both; margin: 0 0 10px; padding: 6px 10px; border-radius: 6px; font-weight: 600;
           background: color-mix(in srgb, var(--accent) 22%, transparent); border: 1px solid var(--accent); }
.qedit { padding: 10px 12px; border: 1px dashed var(--line); border-radius: 6px; background: var(--bg); }
.qedit label:last-child { margin-bottom: 0; }
.qedit .qtype { width: auto; min-width: 12em; }
.futhread .ropt, .futhread .answer { margin-top: 4px; }

/* "Other" choice of a multiple choice question, with its text box */
.opt.other { align-items: center; flex-wrap: wrap; }
.opt.other input[type=radio] { margin-top: 0; }
.opt.other .othertext { flex: 1 1 14em; min-width: 0; margin: 0; }

.case .caseref { margin: -4px 0 6px; }

/* Admin → Accounts: role filter and a table that fits the window without sideways scrolling */
.rolefilter { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 10px; }
.chip { display: inline-block; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: inherit; font-size: 0.9em; }
.chip b { color: var(--muted); font-weight: 600; margin-left: 2px; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #1a1a1a; font-weight: 600; }
.chip.on b { color: inherit; }
table.accounts { table-layout: fixed; }
table.accounts td { overflow-wrap: anywhere; }
table.accounts .c-acc { width: 32%; } table.accounts .c-name { width: 15%; } table.accounts .c-role { width: 18%; }
table.accounts .c-cases { width: 12%; } table.accounts .c-pw { width: 15%; } table.accounts .c-del { width: 8%; }
form.inline.fill { display: flex; }
form.inline.fill input, form.inline.fill select { flex: 1 1 0; min-width: 0; width: 100% !important; }
table.accounts button { padding: 6px 8px; }
table.accounts input, table.accounts select { padding-left: 8px; padding-right: 8px; }
table.accounts td.actions { text-align: right; }
@media (max-width: 900px) {
  table.accounts, table.accounts tbody, table.accounts tr, table.accounts td { display: block; width: auto; }
  table.accounts thead, table.accounts colgroup { display: none; }
  table.accounts tr { border-bottom: 2px solid var(--line); padding: 6px 0; }
  table.accounts td { border: 0; padding: 4px 0; }
  table.accounts td.actions { text-align: left; }
}

/* Admin -> Managers: the two assignment lists */
table.assign td { vertical-align: middle; }
table.assign th:nth-child(1) { width: 34%; } table.assign th:nth-child(2) { width: 16%; }
.picks { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; }
td.picks { display: table-cell; }
td.picks .pick { margin-right: 16px; }
.pick { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; margin: 0; white-space: nowrap; }
.pick input { margin: 0; }
.tag.unassigned { color: var(--bad); border-color: var(--bad); }
.addacc { align-items: flex-end; margin-top: 14px; }
.addacc .picks { padding-bottom: 10px; }
#assignfilter, #cs-filter { align-items: flex-end; }
#assignfilter button, #cs-filter button { margin-bottom: 10px; }
tr[hidden] { display: none; }

/* Admin -> Cases: keep case and account numbers on one line */
#cs-table th:nth-child(-n+2), #cs-table td:nth-child(-n+2) { white-space: nowrap; }

.chipgap { margin-left: 14px; }
table.accounts td form.inline.fill + form.inline.fill { margin-top: 4px; }

/* Performance dashboard */
.stats.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 700px) { .stats.four { grid-template-columns: repeat(2, 1fr); } }
th.num, td.num { text-align: right; }
.bar { display: inline-block; width: 90px; height: 8px; border-radius: 4px; background: var(--line); vertical-align: middle; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--good); }
.age { white-space: nowrap; }
.age.warn { color: #b26a00; font-weight: 600; }
.age.late { color: var(--bad); font-weight: 600; }
.buckets { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
#perf td:nth-child(2) { white-space: nowrap; }

/* Review list: the four status boxes are toggles */
button.stat.toggle { font: inherit; text-align: left; cursor: pointer; align-items: flex-start; }
button.stat.toggle:hover { border-color: var(--accent); }
button.stat.toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.stat.toggle[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 18%, var(--card)); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
button.stat.toggle[aria-pressed="true"] span { color: var(--text); font-weight: 600; }
.stat.wait { border-top-color: #b26a00; }

/* History tab of a case */
.casetabs { margin-top: 12px; }
#history td { vertical-align: top; }
#history td:nth-child(2) { min-width: 9em; }
.histdetail { margin-top: 4px; color: var(--muted); overflow-wrap: anywhere; }
.tag.ev-finalized, .tag.ev-reopened { color: var(--text); font-weight: 600; }

/* Answer page laid out like the 8D report form: a sheet of blocks, each with the discipline's number and name
   in a band on the left and its fields in four columns. */
.d8sheet { --d8-strong: #ffbb33; --d8-light: color-mix(in srgb, #ffbb33 45%, var(--card)); --d8-rule: color-mix(in srgb, var(--text) 55%, var(--card));
           border: 1px solid var(--d8-rule); background: var(--card); margin: 16px 0; }
.d8sheettitle { background: var(--d8-strong); color: #1d1d1f; font-weight: 700; font-size: 1.25rem; text-align: center; padding: 12px 8px;
                border-bottom: 1px solid var(--d8-rule); }
.d8 { display: grid; grid-template-columns: 58px minmax(0, 1fr); margin: 0; border-bottom: 1px solid var(--d8-rule); }
.d8:last-child { border-bottom: 0; }
.d8.d8top, .d8.d8plain { display: block; }
.d8band { background: var(--d8-strong); color: #1d1d1f; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 8px 4px;
          border-right: 1px solid var(--d8-rule); }
.d8band .n { font-size: 2rem; font-weight: 700; line-height: 1; }
.d8band .t { writing-mode: vertical-rl; transform: rotate(180deg); font-weight: 700; white-space: nowrap; }
.group h2.d8title { margin: 0; padding: 8px 10px; border: 0; border-bottom: 1px solid var(--d8-rule); background: var(--d8-strong); color: #1d1d1f;
                    font-size: 1.05rem; text-align: center; }
.d8grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--d8-rule); }
.d8grid fieldset.q { grid-column: span 4; margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: var(--card);
                     display: flex; flex-direction: column; min-width: 0; }
.d8grid fieldset.q.c1 { grid-column: span 1; }
.d8grid fieldset.q.c2 { grid-column: span 2; }
.d8grid fieldset.q.c3 { grid-column: span 3; }
.d8grid fieldset.q legend { float: none; display: block; width: 100%; box-sizing: border-box; margin: 0; padding: 4px 8px; font-size: 0.86rem; font-weight: 700;
                            background: var(--d8-light); color: var(--text); border-bottom: 1px solid var(--d8-rule); }
.d8grid fieldset.q:first-child legend, .d8grid fieldset.q.c1:first-child ~ fieldset.q.c1:nth-child(-n+4) legend { background: var(--d8-strong); color: #1d1d1f; }
.d8grid fieldset.q > textarea { display: block; width: 100%; box-sizing: border-box; margin: 0; border: 0; border-radius: 0; background: transparent;
                                padding: 8px; resize: vertical; flex: 1 1 auto; }
.d8grid fieldset.q > textarea:focus { outline: 2px solid var(--d8-strong); outline-offset: -2px; }
.d8grid fieldset.q > textarea:disabled { color: var(--text); opacity: 1; -webkit-text-fill-color: var(--text); resize: none; }
.d8grid fieldset.q > :not(legend):not(textarea) { margin: 6px 8px; }
.d8grid fieldset.q.edited { border-left: 4px solid var(--accent); }
.d8grid fieldset.q.fu { margin: 0; border: 0; border-left: 4px solid var(--accent); }
/* the heading block of the form: label on the left, value on the right, two columns filled top to bottom */
.d8head { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(4, auto); grid-auto-flow: column; gap: 0; background: var(--card); padding: 10px 8px; }
.d8head fieldset.q, .d8head fieldset.q.c2 { grid-column: auto; display: grid; grid-template-columns: minmax(0, 11em) minmax(0, 1fr); align-items: center; gap: 0 8px; }
.d8head fieldset.q legend, .d8head fieldset.q:first-child legend { display: contents; }
.d8head fieldset.q legend { font-size: 0.9rem; }
/* The first label of the report details has no yellow bar behind it, so it takes the normal text colour (it was dark on dark in dark mode). */
.d8head fieldset.q legend, .d8head fieldset.q:first-child legend { color: var(--text); background: none; }
.d8head fieldset.q > textarea { grid-column: 2; border-bottom: 1px solid var(--line); padding: 4px 6px; resize: none; }
.d8head fieldset.q > :not(legend):not(textarea) { grid-column: 1 / -1; }
@media (max-width: 760px) {
  .d8 { display: block; }
  .d8band { flex-direction: row; justify-content: flex-start; gap: 10px; padding: 6px 10px; border-right: 0; border-bottom: 1px solid var(--d8-rule); }
  .d8band .n { font-size: 1.4rem; }
  .d8band .t { writing-mode: horizontal-tb; transform: none; white-space: normal; }
  .d8grid { grid-template-columns: minmax(0, 1fr); }
  .d8grid fieldset.q, .d8grid fieldset.q.c1, .d8grid fieldset.q.c2, .d8grid fieldset.q.c3 { grid-column: auto; }
  .d8head { grid-template-rows: none; grid-auto-flow: row; }
}

/* The Review page (admin, manager, account manager) in the same 8D form layout */
.d8grid section.q { grid-column: span 4; margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: var(--card); min-width: 0; }
.d8grid section.q.c1 { grid-column: span 1; }
.d8grid section.q.c2 { grid-column: span 2; }
.d8grid section.q.c3 { grid-column: span 3; }
.d8grid section.q > h3 { margin: 0; padding: 4px 8px; font-size: 0.86rem; font-weight: 700; background: var(--d8-light); color: var(--text);
                         border-bottom: 1px solid var(--d8-rule); }
.d8grid section.q:first-child > h3, .d8grid section.q.c1:first-child ~ section.q.c1:nth-child(-n+4) > h3 { background: var(--d8-strong); color: #1d1d1f; }
.d8grid section.q > :not(h3) { margin: 6px 8px; }
.d8grid section.q > .d8val { min-height: 2.6em; overflow-wrap: anywhere; }
.d8grid section.q > .d8val .answer { padding: 0; border: 0; background: none; border-radius: 0; }
.d8grid section.q > .d8val p { margin: 0; }
.d8grid section.q details.ask { margin-top: 4px; font-size: 0.9rem; }
.d8grid section.q .futhread { margin-left: 8px; }
.d8head section.q, .d8head section.q.c2 { grid-column: auto; display: grid; grid-template-columns: minmax(0, 11em) minmax(0, 1fr); align-items: start; gap: 0 8px; padding: 2px 0; }
.d8head section.q > h3, .d8head section.q:first-child > h3 { grid-column: 1; grid-row: 1; background: none; border: 0; padding: 4px 0 4px 8px; font-size: 0.9rem; color: var(--text); }
.d8head section.q > .d8val { grid-column: 2; grid-row: 1; margin: 0; padding: 4px 6px; min-height: 1.5em; border-bottom: 1px solid var(--line); }
.d8head section.q > :not(h3):not(.d8val) { grid-column: 1 / -1; margin: 2px 8px; }
@media (max-width: 760px) {
  .d8grid section.q, .d8grid section.q.c1, .d8grid section.q.c2, .d8grid section.q.c3 { grid-column: auto; }
}

/* Review requests: a reviewer asks the engineer to review one answer, with an optional note */
.reviewreq .note { display: block; margin: 2px 0; color: var(--text); font-style: italic; overflow-wrap: anywhere; }
.reviewreq.done { opacity: 0.75; }
.d8grid .q > p.reviewreq { border-left: 3px solid var(--accent); padding-left: 8px; }
details.ask textarea { width: 100%; box-sizing: border-box; }

/* Review: the admin buttons of a case */
.caseadmin { margin: .6rem 0; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* Admin -> Managers: the assignment boards (managers on the left, their list and what can be added on the right) */
.asg { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 16px; align-items: start; }
.asg h3 { margin: 0 0 8px; } .asg h4 { margin: 0 0 8px; font-size: .95rem; }
.asg-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.asg input[type=search], .asg select { margin: 0 0 8px; }
.asg .pick { margin: 0 0 8px; white-space: normal; font-size: .9em; }
.asg-filters { display: flex; gap: 8px; } .asg-filters input { flex: 1; min-width: 0; } .asg-filters select { width: auto; }
.asg-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; max-height: 56vh; min-height: 120px; overflow-y: auto; background: var(--card); }
.asg-list li { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.asg-list li:last-child { border-bottom: 0; }
.asg-list li.asg-empty { padding: 14px 10px; }
.asg-main { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: left; }
.asg-main b { overflow-wrap: anywhere; } .asg-main small { color: var(--muted); overflow-wrap: anywhere; }
.asg-main small.asg-nobody { color: var(--bad); }
.asg-list li button { padding: 4px 10px; flex: none; }
.asg-mgrs li { padding: 0; }
.asg-mgr { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-left: 4px solid transparent; border-radius: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.asg-mgr:hover { background: var(--bg); }
.asg-mgr.on { background: var(--bg); border-left-color: var(--accent); }
.asg-mgr .count { min-width: 2em; text-align: right; font-weight: 600; } .asg-mgr .count.zero { color: var(--bad); }
.asg-unsaved { color: #9a6700; border-color: #d4a72c; white-space: nowrap; flex: none; }
.asg-new-row, .asg-gone-row { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.asg-foot { margin: 8px 0 0; }
.asg-new { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.asg-new label { flex: 1; margin: 0; } .asg-new input { margin-bottom: 0; }
#asg-switch button.chip { font: inherit; cursor: pointer; }
.asg-save { position: sticky; bottom: 0; display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 10px 0; background: var(--bg); }
#asg-status.unsaved { color: var(--text); font-weight: 600; }
@media (max-width: 900px) { .asg, .asg-cols { grid-template-columns: 1fr; } .asg-list { max-height: 40vh; } }
.asg button:disabled, .asg-save button:disabled { opacity: .5; cursor: default; }

/* Review: reassign a case */
.reassign { margin: .6rem 0; }
.reassign .row { align-items: flex-end; max-width: 46rem; }
.reassign .row button { margin-bottom: 10px; }

/* Performance Dashboard and Performance Review: charts */
:root { --series: #3987e5; --rest: #3d424a; --gridline: #2c3036; }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 0 0 16px; align-items: start; }
.charts > .card { margin: 0; }
@media (max-width: 900px) { .charts { grid-template-columns: minmax(0, 1fr); } }
.chart { font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.chart.cols .plot { position: relative; height: 190px; margin: 12px 0 0 34px; }
.chart.cols .grid { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--gridline); }
.chart.cols .grid:first-child { border-top-color: var(--muted); }
.chart.cols .grid i { position: absolute; right: 100%; top: -0.7em; margin-right: 8px; font-style: normal; color: var(--muted); }
.chart.cols .marks { position: absolute; inset: 0; display: flex; }
.chart.cols .col { flex: 1 1 0; min-width: 0; display: flex; align-items: flex-end; justify-content: center; outline: none; }
.chart.cols .col b { width: min(24px, 70%); background: var(--series); border-radius: 4px 4px 0 0; }
.chart.cols .col:hover, .chart.cols .col:focus-visible { background: color-mix(in srgb, var(--series) 10%, transparent); }
.chart.cols .xlabels { display: flex; margin: 6px 0 0 34px; color: var(--muted); }
.chart.cols .xlabels span { flex: 1 1 0; min-width: 0; text-align: center; white-space: nowrap; font-size: 0.78rem; }
.chart.cols .xlabels span:nth-child(even) { visibility: hidden; }   /* every second week is labelled */
@media (max-width: 520px) { .chart.cols .xlabels span:not(:nth-child(4n+1)) { visibility: hidden; } }
.chart.bars { display: grid; grid-template-columns: minmax(90px, max-content) minmax(60px, 1fr) max-content; gap: 6px 10px; align-items: center; margin-top: 10px; }
.chart.bars .brow { display: contents; }
.chart.bars .brow[hidden] { display: none; }
.chart.bars .blabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 15em; }
.chart.bars .btrack { display: flex; gap: 2px; height: 16px; padding: 4px 0; box-sizing: content-box; outline: none; }
.chart.bars .btrack b { background: var(--series); min-width: 2px; }
.chart.bars .btrack b.rest { background: var(--rest); }
.chart.bars .btrack b:last-child { border-radius: 0 4px 4px 0; }
.chart.bars .btrack:hover b, .chart.bars .btrack:focus-visible b { filter: brightness(0.88); }
.chart.bars .bval { color: var(--muted); white-space: nowrap; }
.chart.bars > p { grid-column: 1 / -1; margin: 6px 0 0; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; color: var(--muted); font-size: 0.88rem; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; background: var(--series); }
.legend i.k2 { background: var(--rest); }
#charttip { position: fixed; z-index: 50; max-width: 320px; padding: 6px 10px; border-radius: 6px; background: var(--text); color: var(--card);
            font-size: 0.85rem; pointer-events: none; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); }
.stat b small { font-size: 0.55em; font-weight: 600; color: var(--muted); }
.stat em { font-style: normal; font-size: 0.82rem; color: var(--muted); margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); }
.prhead h2 { margin-bottom: 2px; } .prhead p:last-child { margin-bottom: 0; }
.stats.three { grid-template-columns: repeat(3, 1fr); margin-bottom: 12px; }
/* Performance Dashboard: managers with their engineers, account managers with their accounts */
details.grp > summary { display: grid; grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)); gap: 6px 16px; align-items: center; cursor: pointer; list-style-position: outside; margin-left: 1.1em; }
details.grp > summary > span { display: flex; flex-direction: column; min-width: 0; }
details.grp > summary b { font-size: 1.05rem; }
details.grp[open] > summary { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
details.grp:hover { border-color: var(--accent); }
@media (max-width: 700px) { details.grp > summary { grid-template-columns: 1fr 1fr; } }
#grp-filter button { margin-bottom: 12px; }
/* The status Irrelevant */
.badge.irrelevant { border-color: var(--muted); color: var(--muted); background: transparent; }
.stat.irrelevant { border-top-color: var(--muted); }
.casegroup#irrelevant h2 { border-left-color: var(--muted); }
a.case.irrelevant { opacity: 0.8; } a.case.irrelevant .bar i { background: var(--muted); }
.funote.irr { color: var(--muted); }
.stats.five { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 900px) { .stats.five { grid-template-columns: repeat(2, 1fr); } }
.flash.irrelevant { background: var(--bg); border: 1px solid var(--muted); }
.flash.irrelevant form { display: block; margin-top: 8px; }
.irrelevantbox form { max-width: 46rem; }
.opt.irr { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.opt.irr input[type=text] { flex: 1 1 14rem; margin: 0; }
.exportrange > label { flex: 0 1 12rem; }
/* Date questions: a text box that holds MM/DD/YYYY and a calendar button */
.datefield { display: flex; align-items: center; gap: 4px; position: relative; max-width: 16rem; }
.datefield .datetext { flex: 1 1 auto; min-width: 0; margin: 0; font-variant-numeric: tabular-nums; }
.datefield .datepick { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; margin: 0; }
.datefield .datebtn { flex: 0 0 auto; margin: 0; padding: 5px 7px; line-height: 0; }
.datefield.bad .datetext { outline: 2px solid var(--bad); outline-offset: -2px; }
.d8grid fieldset.q > .datefield { margin: 4px 8px 6px; max-width: none; }
.d8grid fieldset.q > .datefield .datetext { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; padding: 4px 6px; color: var(--text); }
.d8grid fieldset.q > .datefield .datetext:focus { outline: 2px solid var(--d8-strong); outline-offset: -2px; }
.d8head fieldset.q > .datefield { grid-column: 2; margin: 0; }
.datefield .datetext:disabled { opacity: 1; -webkit-text-fill-color: var(--text); }
/* Stat boxes never push the page wider than the screen: columns may shrink and long labels wrap. */
.stats, .stats.four, .stats.five { grid-template-columns: repeat(var(--stat-cols, 3), minmax(0, 1fr)); }
.stats.four { --stat-cols: 4; } .stats.five { --stat-cols: 5; } .stats.three { --stat-cols: 3; }
@media (max-width: 900px) { .stats.five { --stat-cols: 2; } }
@media (max-width: 700px) { .stats.four { --stat-cols: 2; } }
.stat { min-width: 0; overflow-wrap: anywhere; }
#history td { overflow-wrap: anywhere; }
button.stat.toggle { white-space: normal; }
.flash.locked { background: var(--bg); border: 1px solid var(--accent); }
.flash.locked form { display: inline-block; margin-left: 10px; }
.lockform { max-width: 46rem; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
