:root {
  color-scheme: light dark;
  --bg: light-dark(#fff, #181818);
  --fg: light-dark(#1a1c1f, #f4f4f4);
  --muted: light-dark(rgb(26 28 31 / 55%), rgb(255 255 255 / 55%));
  --card: light-dark(#f6f6f7, #222);
  --border: light-dark(rgb(26 28 31 / 10%), rgb(255 255 255 / 10%));
  --input: light-dark(rgb(26 28 31 / 18%), rgb(255 255 255 / 18%));
  --accent: light-dark(#e5f2ff, #0d273f);
  --accent-fg: light-dark(#1f7ad6, #83c3ff);
  --warn-bg: light-dark(#fff3e8, #3a2414);
  --warn-fg: light-dark(#b2470a, #ff9a66);
  --ok: light-dark(#00843a, #40c977);
  --radius: 8px;
  font-family: ui-sans-serif, -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
body { margin: 0; background: var(--bg); color: var(--fg); }
a { color: var(--accent-fg); }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.top { display: flex; gap: 20px; align-items: center; padding: 10px 20px; border-bottom: 1px solid var(--border); }
.top .brand { margin-right: 12px; }
.top a { color: inherit; text-decoration: none; }
.top .tab { padding: 4px 0; border-bottom: 2px solid transparent; }
.top .tab.active { border-color: var(--fg); font-weight: 600; }
.top .tab.later { color: var(--muted); cursor: default; }

main { max-width: 1180px; margin: 0 auto; padding: 16px 20px 40px; }
h1 { font-size: 24px; margin: 0; font-weight: 600; }
h2 { font-size: 18px; margin: 0 0 4px; font-weight: 600; }
h3 { font-size: 17px; margin: 0; font-weight: 600; }
h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 6px; font-weight: 600; }

.client { display: flex; justify-content: space-between; gap: 16px; align-items: end; flex-wrap: wrap; margin-bottom: 14px; }
.client p { margin: 2px 0; }
.policy { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 14px 16px;
  background: var(--card); border-radius: var(--radius); margin-bottom: 8px; }
.money { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.money small { font-size: 14px; font-weight: 400; }
.recon { font-size: 13px; margin: 0 0 14px; }
.recon.ok { color: var(--muted); }

.workspace { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(360px, 1.15fr); gap: 20px; align-items: start; }
.workspace .side { position: sticky; top: 12px; }
@media (max-width: 860px) { .workspace { grid-template-columns: 1fr; } .workspace .side { display: none; } }

.group-title { margin: 6px 0 8px; }
.item { display: block; width: 100%; text-align: left; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
.item:hover { border-color: var(--input); }
.item.selected { border-color: var(--accent-fg); box-shadow: 0 0 0 1px var(--accent-fg) inset; }
.item-title { font-weight: 600; }
.amounts { display: flex; justify-content: space-between; margin-top: 6px; font-variant-numeric: tabular-nums; }

.card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; background: var(--bg); margin-bottom: 8px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0 4px; }
.facts div { background: var(--card); border-radius: var(--radius); padding: 8px 10px; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.facts span { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.card ul { margin: 0; padding-left: 18px; }
.card li { margin: 2px 0; }
.covers { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.covers td { padding: 4px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.covers td.num { text-align: right; white-space: nowrap; padding-left: 10px; }
/* tick columns sit clear of the figures beside them */
.covers td.tick { padding-left: 14px; text-align: center; }
dl.identity { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0; }
dl.identity dt { color: var(--muted); }
dl.identity dd { margin: 0; }

.notice { background: var(--warn-bg); color: var(--warn-fg); border-radius: var(--radius); padding: 8px 10px; margin-top: 8px; font-size: 14px; }
.notice.done { background: var(--accent); color: var(--accent-fg); }
.case-ownership { background: var(--card); border-radius: var(--radius); padding: 8px 10px; margin: 8px 0; }
.history { font-size: 13px; }
.history li { margin-bottom: 4px; }
.history pre { white-space: pre-wrap; font: inherit; margin: 0; }

.actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.btn { border: 1px solid var(--input); background: var(--bg); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn.link { border: 0; padding: 0; background: none; color: var(--accent-fg); text-decoration: underline; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, textarea { font: inherit; color: inherit; background: var(--bg); width: 100%; box-sizing: border-box;
  border: 1px solid var(--input); border-radius: 6px; padding: 6px 8px; }
textarea { min-height: 70px; }
.row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.row2 { display: grid; grid-template-columns: 1fr 2fr auto; gap: 6px; margin-bottom: 6px; }
.row3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 6px; margin: 6px 0; }
.row4 { display: grid; grid-template-columns: 2fr 1.2fr 1fr 1fr 1.4fr; gap: 6px; margin: 6px 0; }
@media (max-width: 640px) { .row4 { grid-template-columns: 1fr 1fr; } }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
[hidden] { display: none !important; }   /* hidden wins over a layout's display */
.grid2 > * { min-width: 0; }
.grid2 select { max-width: 100%; }
.error { color: var(--warn-fg); margin-top: 8px; }
.saved { color: var(--ok); font-size: 13px; }
details.other { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 10px; }
details.other summary { cursor: pointer; font-weight: 600; }
.foot { margin-top: 24px; font-size: 12px; color: var(--muted); }
.list a { display: block; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; color: inherit; text-decoration: none; }

.servicing { margin: -2px 0 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
/* a Start form opens under its row from the row's left edge, as wide as fits: never off the screen or pushing it sideways */
.servicing { position: relative; }
.servicing > details > .card { position: absolute; left: 0; z-index: 5; width: min(560px, 100%); box-sizing: border-box; }
.servicing > .form-error { flex-basis: 100%; margin: 2px 0 0; }
.servicing > details > .card select { width: 100%; max-width: 100%; }
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(600px, 100vw); box-sizing: border-box; overflow-y: auto;
  background: var(--bg); border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgb(0 0 0 / 12%); padding: 16px 20px 40px; z-index: 10; }
@media (min-width: 1300px) { body.with-panel main { margin-right: 600px; margin-left: 0; } }
.panel-head { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.panel-head h2 { margin: 2px 0 6px; }
.chip { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--card); color: var(--muted); }
.chip.open { background: var(--accent); color: var(--accent-fg); }
.steps { list-style: none; padding: 0; margin: 14px 0 6px; border-left: 2px solid var(--border); }
.steps li { position: relative; padding: 4px 0 10px 16px; }
.steps li::before { content: ""; position: absolute; left: -7px; top: 8px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--input); }
.steps li.done::before { background: var(--ok); border-color: var(--ok); }
.steps li.next::before { border-color: var(--accent-fg); background: var(--accent); }
.steps li.next strong { color: var(--accent-fg); }
.step-kind { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.cmp td.changed { font-weight: 600; }
.cmp-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; margin-top: 8px; }
.cmp-item ul { margin: 4px 0 0; padding-left: 18px; }
.cmp-item select { font: inherit; margin-top: 4px; width: 100%; padding: 4px; color: inherit; background: var(--bg); border: 1px solid var(--input); border-radius: 6px; }
textarea.letter { min-height: 260px; font-size: 14px; }
pre.letter { white-space: pre-wrap; font: inherit; font-size: 14px; background: var(--card); padding: 10px; border-radius: var(--radius); }
.btn[disabled] { opacity: .5; cursor: default; }
.foot ul { margin: 4px 0 0; padding-left: 18px; }

.change-form .for-add, .change-form .for-edit, .change-form .for-existing, .change-form .for-amount { display: none; }
.change-form[data-mode=edit] .for-existing, .change-form[data-mode=edit] .for-edit, .change-form[data-mode=edit] .for-amount,
.change-form[data-mode=remove] .for-existing,
.change-form[data-mode=add] .for-add, .change-form[data-mode=add] .for-amount { display: block; }
.change-form select, .resolve input { font: inherit; width: 100%; padding: 6px; color: inherit; background: var(--bg); border: 1px solid var(--input); border-radius: 6px; box-sizing: border-box; }
.chip.ok { background: light-dark(#e6f6ec, #13301f); color: var(--ok); }
ul.changes { padding-left: 18px; margin: 0; }
.letter-block { border-top: 1px dashed var(--border); margin-top: 10px; }

.offer-form select, .issued-form select, [data-n] { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--input); border-radius: 6px; padding: 5px; box-sizing: border-box; width: 100%; }
.offer-form table input, .issued-form table input { padding: 4px 6px; }
.cmp-item.muted { opacity: .65; }
.cmp td.num { vertical-align: top; }

.panel.wide { width: min(980px, 100vw); }
@media (min-width: 1300px) { body.with-wide-panel main { margin-right: 980px; } }
@media (max-width: 1700px) { body.with-wide-panel main { margin-right: 0; } }
.cmp td { min-width: 90px; }

table.nbgrid { table-layout: fixed; min-width: 640px; }
table.nbgrid td { min-width: 0; overflow-wrap: anywhere; }
table.nbgrid td:first-child { width: 150px; }
table.nbgrid td.num { white-space: normal; }

/* Work */
.work-row { padding: 10px 12px; }
.work-row.due { border-color: var(--warn-fg); }
.work-head { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
/* on a phone the heading reads as one line of text, its date under it */
@media (max-width: 600px) { .work-head { display: block; } .work-head > .small { display: block; margin-left: 0 !important; } }
.chip.due { background: var(--warn-bg); color: var(--warn-fg); }
.top .who { margin-left: auto; }

/* Onboarding: the review beside its source on wide screens */
.onboarding-page main { max-width: none; }
.beside { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.arrival section { min-width: 0; overflow-wrap: anywhere; }
.arrival select { font: inherit; color: inherit; background: var(--bg); width: 100%; max-width: 100%; box-sizing: border-box;
  border: 1px solid var(--input); border-radius: 6px; padding: 6px 8px; }
.arrival label.tick { display: flex; gap: 8px; align-items: baseline; color: inherit; }
.arrival label.tick input { width: auto; }
/* on a phone each arrival in the list reads as a block, not four squeezed columns */
@media (max-width: 600px) {
  table.arrival-list, table.arrival-list tbody, table.arrival-list tr, table.arrival-list td { display: block; }
  table.arrival-list tr { position: relative; padding: 8px 0; border-bottom: 1px solid var(--border); }
  table.arrival-list td { border: 0; padding: 2px 0; }
  table.arrival-list td.pick { position: absolute; right: 0; top: 8px; }
}
@media (max-width: 700px) { .beside.arrival { grid-template-columns: minmax(0, 1fr); } }
.beside .source { position: sticky; top: 12px; }
.beside .source iframe { width: 100%; height: calc(100vh - 90px); border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 12px; }
@media (max-width: 700px) { .grid3 { grid-template-columns: 1fr 1fr; } }
.items-edit td { padding: 4px 4px 4px 0; }
.items-edit input, .items-edit select { width: 100%; box-sizing: border-box; }
.items-edit td.num input { text-align: right; }
.items-edit td.num { width: 7.5em; }   /* amounts stay narrow so item names can be read whole */
.onboarding-list td { padding: 8px 8px 8px 0; }
.review select, .onboarding-list select { font: inherit; color: inherit; background: var(--bg); max-width: 100%; box-sizing: border-box;
  border: 1px solid var(--input); border-radius: 6px; padding: 6px 8px; }
@media (max-width: 700px) {
  .onboarding-list tr, .review table.covers tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
  .onboarding-list td, .review table.covers td { display: block; border: 0; padding: 0; min-width: 0; }
  .onboarding-list td:first-child, .review table.covers td:first-child { grid-column: 1 / -1; }
  .review table.covers td.num { text-align: left; }
  .review input, .review select { max-width: 100%; }
  /* the list's two forms one above the other; insured items as labelled fields, the name across the top */
  .onboarding-forms { grid-template-columns: 1fr; }
  .review table.items-edit tr.items-head { display: none; }
  .items-edit td { width: auto !important; }
  .items-edit td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
  .items-edit td.num input { text-align: left; }
}
.top { flex-wrap: wrap; row-gap: 6px; }
@media (max-width: 700px) { .top { gap: 6px 14px; padding: 8px 16px; } .top .who { margin-left: 0; flex-basis: 100%; } }

/* Reported changes remain readable inside the case panel, including on phones. */
.covers.import tr { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.covers.import td { min-width: 0; border: 0; overflow-wrap: anywhere; }
.covers.import td:first-child { grid-column: 1; grid-row: 1 / 4; }
.covers.import td:not(:first-child) { grid-column: 2; }
.covers.import td:nth-child(n+3) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 10px; }
.covers.import label { margin: 0; }
.covers.import label[hidden] { display: none; }
.covers.import input, .covers.import select { box-sizing: border-box; min-width: 0; width: 100%; }
.covers.import [data-im="include"] { width: auto; }
@media (max-width: 480px) { .covers.import td:nth-child(n+3) { grid-template-columns: minmax(0, 1fr); } }
.covers.import, .covers.import tbody { display: block; width: 100%; }
.covers.import tr { width: 100%; box-sizing: border-box; }
.covers.import label { display: block; min-width: 0; }

.onboarding-list th { text-align: left; padding: 6px 8px 6px 0; font-size: 12px; color: var(--muted); }
@media (max-width: 700px) { .onboarding-list thead { display: none; } }

/* a pilot or rehearsal instance, on every page */
.pilot-bar { background: #fff4d6; color: #5c4400; border-bottom: 1px solid #ecd9a0; padding: 4px 16px; }
.read-only-bar { background: var(--warn-bg); color: var(--warn-fg); padding: 6px 20px; border-bottom: 1px solid var(--border); }

/* a wide table scrolls within its own box at phone width, not the whole page */
.scroll-x { overflow-x: auto; max-width: 100%; }
.case-list { margin: 4px 0 8px; padding-left: 18px; }
.case-list li { margin: 2px 0; }
/* a panel's message stays in view however far down the panel the broker acted */
.panel > .panel-msg { position: sticky; top: 0; z-index: 6; margin: 8px 0; padding: 8px 10px; border-radius: var(--radius); box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.panel > .panel-msg.saved { background: var(--accent); color: var(--accent-fg); font-size: 14px; }
.step-link { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }

/* the demonstration guide: users that stack on a phone, a jump list, and figures to read off while typing */
.demo-users { list-style: none; padding: 0; margin: 0 0 8px; }
.demo-users li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.demo-users code { overflow-wrap: anywhere; }
.demo-jump { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.demo-steps { padding-left: 1.3em; display: grid; gap: 10px; }
.demo-steps .figures { display: grid; grid-template-columns: minmax(0, max-content) minmax(0, 1fr); gap: 2px 14px; margin: 6px 0;
  padding: 8px 12px; border-left: 3px solid var(--border); background: var(--bg); border-left-color: var(--accent-fg); }
.demo-steps .figures dt { color: var(--muted); font-size: 14px; }
.demo-steps .figures dd { margin: 0; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; user-select: all; }
@media (max-width: 520px) { .demo-steps .figures { grid-template-columns: 1fr; } .demo-steps .figures dd { margin-bottom: 4px; } }

/* Settings: the brand colour with its swatch, the email preview, and on a phone the users as stacked rows */
.colour-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.colour-row input { margin: 0; }
.swatch { width: 34px; height: 34px; border-radius: 6px; border: 1px solid var(--border); flex: none; }
.email-preview { width: 100%; height: 520px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
@media (max-width: 700px) {
  .settings .grid2 { grid-template-columns: 1fr; }
  .settings table.users tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .settings table.users td { display: block; border: 0; padding: 0; min-width: 0; }
  .settings table.users td:first-child, .settings table.users td.num { grid-column: 1 / -1; text-align: left; }
  .email-preview { height: 460px; }
}
/* Account, signed in with a temporary password: the other pages wait until the user chooses their own */
.must-change header .tab, .must-change .who a[href="/effort"], .must-change .who a[href="/settings"] { display: none; }
/* Effort: a gap before the brokers column; on a phone each row is a block with its figures labelled */
.effort td.brokers, .effort th:last-child { padding-left: 14px; }
@media (max-width: 700px) {
  .effort tr:first-child { display: none; }
  .effort tr { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .effort td, .effort td.num { display: block; border: 0; padding: 0; min-width: 0; text-align: left; white-space: normal; }
  .effort td:first-child, .effort td.brokers, .effort td[data-label^="Docs"] { grid-column: 1 / -1; padding-left: 0; }
  .effort td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); }
}
