/* Desk v0.3/v0.4: a calm, dense operations desk. One light theme. v0.4 adds the Outlook-familiar layer at the end.
   Barlow Semi Condensed (headings, stage track, badges) over Source Sans 3 (body, tabular figures).
   Fixed palette: action blue, risk red, deadline amber, exception plum, done green. */

@font-face { font-family: "Barlow SC"; src: url(/static/fonts/barlow-semi-condensed-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow SC"; src: url(/static/fonts/barlow-semi-condensed-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Source Sans 3"; src: url(/static/fonts/source-sans-3-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Source Sans 3"; src: url(/static/fonts/source-sans-3-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Source Sans 3"; src: url(/static/fonts/source-sans-3-latin-400-italic.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  --canvas: #e9edec; --surface: #fff; --ink: #17212b; --ink-2: #56616d; --ink-3: #8a939c;
  --line: #d3d9da; --line-2: #e6eaea; --zebra: #f5f7f7;
  --act: #1d4e89; --act-bg: #e4ecf6;
  --risk: #b3261e; --risk-bg: #fbe9e7;
  --due: #8a5a00; --due-bg: #fcf1dc;
  --exc: #6a3e8e; --exc-bg: #f1e9f7;
  --ok: #2d6a4f; --ok-bg: #e3f1e8;
  --head: "Barlow SC", "Segoe UI Semibold", "Arial Narrow", sans-serif;
  --body: "Source Sans 3", "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 var(--body); color: var(--ink); background: var(--canvas); font-variant-numeric: tabular-nums; }
a { color: var(--act); text-underline-offset: 2px; }
a:hover { color: #123a6a; }
:focus-visible { outline: 2px solid var(--act); outline-offset: 2px; }

/* ---- navigation ---- */
.top { background: var(--ink); color: #dfe5ea; position: sticky; top: 0; z-index: 20; }
.top nav { display: flex; align-items: stretch; gap: 2px; padding: 0 20px; max-width: 1640px; margin: 0 auto; overflow-x: auto; }
.top nav a { color: #c9d2da; text-decoration: none; padding: 11px 10px 9px; border-bottom: 3px solid transparent; white-space: nowrap;
  font-family: var(--head); font-weight: 500; font-size: 15px; letter-spacing: .01em; }
.top nav a:hover { color: #fff; }
.top nav a.on { color: #fff; border-bottom-color: #8fb4e3; }
.top nav .brand { font-weight: 600; font-size: 18px; color: #fff; padding-right: 18px; }
.top nav .brand span { color: #8fb4e3; }
.top .spacer { flex: 1; }
.top .spend { align-self: center; color: #9aa7b3; font-size: 13px; white-space: nowrap; padding: 0 10px; }
.top form { align-self: center; }
.top button.link { color: #c9d2da; text-decoration: none; }
.banner { background: var(--risk); color: #fff; padding: 8px 24px; }

main { padding: 18px 24px 64px; max-width: 1640px; margin: 0 auto; }

/* ---- page head: title, context line, primary action ---- */
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 20px; margin: 4px 0 16px; }
.pagehead .t { flex: 1 1 420px; min-width: 0; }
.pagehead .act { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
h1 { font: 600 28px/1.15 var(--head); margin: 0; letter-spacing: -.005em; }
h1 .sub { font-weight: 500; color: var(--ink-2); font-size: 20px; margin-left: 8px; }
.ctx { margin: 4px 0 0; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 2px 18px; }
.ctx b { color: var(--ink); font-weight: 600; }
h2 { font: 600 18px/1.2 var(--head); margin: 0 0 10px; }
h2 .n { color: var(--ink-2); font-weight: 500; }
h3 { font: 600 16px/1.25 var(--head); margin: 0 0 4px; }
h4 { font: 600 15px/1.25 var(--head); margin: 12px 0 4px; }

/* ---- panels and grids ---- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 14px 16px; margin: 0 0 16px; min-width: 0; }
.panel > h2:first-child { margin-top: 0; }
.panel.flush { padding: 0; }
.panel.flush > h2 { padding: 14px 16px 0; }
.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid.main-side { grid-template-columns: minmax(0, 2.1fr) minmax(300px, 1fr); }
section { min-width: 0; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: 13px; }
.err { color: var(--risk); }
.ok { color: var(--ok); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.hidden { display: none; }
.empty { color: var(--ink-2); margin: 4px 0; }
.note { background: var(--due-bg); padding: 8px 12px; border-left: 3px solid var(--due); border-radius: 0 3px 3px 0; margin: 0 0 12px; }
.warn { background: var(--risk-bg); padding: 8px 12px; border-left: 3px solid var(--risk); border-radius: 0 3px 3px 0; margin: 0 0 10px; }
.warn-text { color: var(--risk); }
.quote { color: var(--ink-2); font-style: italic; overflow-wrap: anywhere; }
.meta { color: var(--ink-2); font-size: 13px; display: inline-flex; flex-wrap: wrap; gap: 0 12px; }

/* ---- badges: one small fixed palette ---- */
.badge, .tag { display: inline-block; font: 600 12.5px/1.5 var(--head); letter-spacing: .02em; border-radius: 3px; padding: 0 7px;
  white-space: nowrap; vertical-align: 1px; }
.tag { background: var(--line-2); color: var(--ink-2); font-weight: 500; }
.badge.risk, .badge { background: var(--risk-bg); color: var(--risk); }
.badge.exc { background: var(--exc-bg); color: var(--exc); }
.badge.due { background: var(--due-bg); color: var(--due); }
.badge.prop { background: var(--surface); color: var(--act); box-shadow: inset 0 0 0 1px var(--act); border: 0; }
.badge.rule { background: var(--act-bg); color: var(--act); }
.stage { display: inline-block; font: 600 13px/1.5 var(--head); border-radius: 3px; padding: 0 8px; white-space: nowrap;
  background: var(--line-2); color: var(--ink); }
.stage.s-quoted { background: #e7ecf2; }
.stage.s-booked, .stage.s-picked_up, .stage.s-export_cleared, .stage.s-departed, .stage.s-arrived,
.stage.s-import_cleared, .stage.s-delivered { background: var(--act-bg); color: var(--act); }
.stage.s-invoiced, .stage.s-paid { background: var(--ok-bg); color: var(--ok); }
.stage.s-closed { background: #dfe3e3; color: var(--ink-2); }
.stage.s-lost { background: #ececec; color: var(--ink-3); text-decoration: line-through; text-decoration-thickness: 1px; }

/* ---- tables ---- */
table { border-collapse: collapse; width: 100%; }
td, th { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
th { font: 600 13.5px/1.3 var(--head); color: var(--ink-2); background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 42px; z-index: 5; }
table.list tbody tr:nth-child(even) td { background: var(--zebra); }
table.list tbody tr:hover td { background: #edf2f8; }
.num, td.num, th.num { text-align: right; white-space: nowrap; }
table.num td:not(:first-child):not(:nth-child(2)), table.num th:not(:first-child):not(:nth-child(2)) { text-align: right; }
.facts td { padding: 5px 8px; }
.facts td:first-child { color: var(--ink-2); white-space: nowrap; width: 1%; }
.scroll { overflow-x: auto; }

/* the hero on the project page: sell, buy, margin */
.money-hero { border-top: 3px solid var(--act); }
.money-hero .figures { display: flex; flex-wrap: wrap; gap: 8px 36px; margin: 0 0 12px; }
.money-hero .fig { display: flex; flex-direction: column; }
.money-hero .fig .v { font: 600 26px/1.1 var(--head); }
.money-hero .fig .l { color: var(--ink-2); font-size: 13px; }
.money-hero .fig.m .v { color: var(--ok); }
.money-hero .fig.m.low .v { color: var(--risk); }
table.money td, table.money th { padding: 7px 10px; }
table.money td.num { font-size: 15.5px; }
table.money tr.total td { font-weight: 600; border-top: 2px solid var(--ink); border-bottom: 0; background: var(--surface); }
table.money tr.total td.num { font-size: 16.5px; }
table.money td.mg { color: var(--ok); font-weight: 600; }
table.money td.mg.neg { color: var(--risk); }

/* ---- stage track (project page) ---- */
.track { display: flex; margin: 0 0 6px; padding: 0; list-style: none; overflow-x: auto; }
.track li { flex: 1 1 0; min-width: 74px; position: relative; padding: 18px 4px 0; text-align: center;
  font: 500 13.5px/1.2 var(--head); color: var(--ink-3); }
.track li::before { content: ""; position: absolute; top: 7px; left: 0; right: 0; height: 3px; background: var(--line); }
.track li::after { content: ""; position: absolute; top: 3px; left: calc(50% - 5px); width: 11px; height: 11px; border-radius: 50%;
  background: var(--surface); box-shadow: inset 0 0 0 2px var(--line); }
.track li:first-child::before { left: 50%; }
.track li:last-child::before { right: 50%; }
.track li.done { color: var(--ink-2); }
.track li.done::before, .track li.cur::before { background: var(--act); }
.track li.done::after { background: var(--act); box-shadow: none; }
.track li.cur { color: var(--ink); font-weight: 600; }
.track li.cur::after { background: var(--surface); box-shadow: inset 0 0 0 3px var(--act); width: 15px; height: 15px; top: 1px; left: calc(50% - 7px); }
.track li.cur + li::before { background: var(--line); }
.track li.prop { color: var(--act); }
.track li.prop::after { background: var(--act-bg); box-shadow: inset 0 0 0 2px var(--act); }
/* v0.7: the other party's steps by the Incoterm, steps passed without proof, the unknown flow */
.track li.theirs { color: var(--ink-3); font-style: italic; }
.track li.theirs::after { opacity: .45; }
.track li.skip::after { background: var(--surface); box-shadow: inset 0 0 0 2px var(--act); opacity: .6; }
.track li .skipnote { display: block; font: 400 11px/1.2 var(--body, inherit); color: var(--ink-3); }
.track li.unknown a { font-weight: 600; text-decoration: none; }
.flowline { margin: 0 0 6px; color: var(--ink-2); }
.warn-inline { color: var(--warn, #9a5b00); margin-left: 4px; }
.track.lost li { color: var(--ink-3); }
.track.lost li::before, .track.lost li::after { background: var(--line); box-shadow: none; }

/* proposal box: project page, list, Today */
.proposal { border: 1px dashed var(--act); background: #f6f9fd; border-radius: 4px; padding: 10px 12px; margin: 10px 0; }
.proposal .what { font-weight: 600; }
.proposal form { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin: 8px 0 0; }
.proposal.lost { border-color: var(--ink-2); background: #f7f7f7; }
.proposal.tight { padding: 6px 8px; margin: 4px 0 0; }
.proposal.tight form { margin-top: 4px; }

/* ---- forms and buttons ---- */
input, select, textarea, button, .button { font: inherit; font-size: 14.5px; }
input, select, textarea { border: 1px solid #b9c2c6; border-radius: 3px; padding: 5px 7px; background: #fff; color: var(--ink); max-width: 100%; }
textarea { width: 100%; }
button, .button { display: inline-block; border: 1px solid #a7b1ba; background: #fff; border-radius: 3px; padding: 5px 12px;
  cursor: pointer; color: var(--ink); text-decoration: none; line-height: 1.35; white-space: nowrap; }
button:hover, .button:hover { background: #eef2f6; color: var(--ink); }
.button.primary, button.primary { background: var(--act); color: #fff; border-color: var(--act); }
.button.primary:hover, button.primary:hover { background: #163f70; color: #fff; }
button.exc { color: var(--exc); border-color: #b9a1cd; background: var(--exc-bg); }
button.exc:hover { background: #e7dbf1; }
button.link { border: 0; background: none; color: var(--act); padding: 0; text-decoration: underline; }
form.inline { display: inline; }
.inline-form { margin: 8px 0; display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.stack > * { display: block; margin: 0 0 8px; width: 100%; }
.stack > button { width: auto; }
.qa { margin: 0; padding: 7px 0; border-bottom: 1px solid var(--line-2); }
.qa:last-child { border-bottom: 0; }
.qa p { margin: 0 0 6px; }
.qa .row-in { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.qa input[name=answer] { flex: 1 1 260px; }
.qa .where { font-size: 13px; color: var(--ink-2); display: inline-flex; gap: 0 10px; flex-wrap: wrap; }

/* ---- Today: a morning briefing ---- */
.brief { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.brief-day { font: 500 15px var(--head); color: var(--ink-2); }
.bsec { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--act); border-radius: 4px;
  padding: 12px 16px 6px; margin: 0 0 16px; }
.bsec h2 { font-size: 21px; display: flex; align-items: baseline; gap: 10px; }
.bsec h2 .count { font: 600 15px/1.4 var(--head); background: var(--act); color: #fff; border-radius: 3px; padding: 0 8px; }
.bsec.risks { border-left-color: var(--risk); }
.bsec.risks h2 .count { background: var(--risk); }
.bsec.due { border-left-color: var(--due); }
.bsec.due h2 .count { background: var(--due); }
.bsec.margin { border-left-color: var(--exc); }
.bsec.margin h2 .count { background: var(--exc); }
.bsec h3 { color: var(--ink-2); font-weight: 500; font-size: 15px; margin: 12px 0 2px; }
.bsec .line { display: flex; flex-wrap: wrap; gap: 2px 12px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--line-2); }
.bsec .line:last-child { border-bottom: 0; }
.bsec .line .grow { flex: 1 1 300px; min-width: 0; }
.allclear { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 18px 16px; }
.since h2 { font-size: 16px; }
.since .entry { padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.since .entry:last-child { border-bottom: 0; }

/* ---- drop ---- */
.dropzone { border: 2px dashed #8a96a3; border-radius: 6px; background: #fff; padding: 36px 20px; text-align: center; }
.dropzone.over { background: var(--act-bg); border-color: var(--act); }
.rowhead, .row { display: grid; grid-template-columns: 2fr 3fr 1fr; gap: 12px; padding: 8px 12px; }
.rowhead { font: 600 13.5px var(--head); color: var(--ink-2); border-bottom: 1px solid var(--line); background: var(--surface); }
.row { background: #fff; border-bottom: 1px solid var(--line-2); align-items: start; }
.row:nth-child(even) { background: var(--zebra); }
.row.err { display: block; color: var(--risk); }
.row form.correct { display: flex; flex-wrap: wrap; gap: 4px; }
.row select { max-width: 180px; }
.status.s-done { color: var(--ok); }
.status.s-error, .status.s-capped { color: var(--risk); }
.status.s-intake, .status.s-desk, .status.s-parsed { color: var(--due); }

/* ---- thread ---- */
.msg { background: #fff; border: 1px solid var(--line); border-left: 4px solid #a7b1ba; border-radius: 0 4px 4px 0; padding: 10px 14px; margin: 0 0 10px; }
.msg.out { border-left-color: var(--act); }
.msg > header { margin: 0 0 8px; }
.msg .pre { max-height: 520px; overflow: auto; }
article.msg.quoted { opacity: .88; border-left-style: dashed; }
.draft { background: #fff; border: 1px solid #b9cbe0; border-top: 3px solid var(--act); border-radius: 4px; padding: 10px 16px 12px; margin: 0 0 16px; }
.draft.faded { opacity: .55; }
.draft textarea { font-family: inherit; background: #fbfcfc; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.dstatus { margin: 8px 0; display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.st-sent_by_user { color: var(--ok); }
.st-rejected { color: var(--risk); }
.feedback { background: var(--zebra); border: 1px solid var(--line-2); padding: 8px 10px; margin: 10px 0 0; border-radius: 3px;
  display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.feedback textarea { margin: 2px 0; flex-basis: 100%; }
.entry { margin: 0 0 8px; }
.entry p { margin: 0 0 4px; }
.claims .mref { font-size: 12.5px; }
details summary { cursor: pointer; }
details { padding: 4px 0; }
.pfilter { padding: 0 16px; }
table.pdir tbody tr:nth-child(even) td { background: none; }
table.pdir tbody:nth-of-type(even) td { background: var(--zebra); }
table.pdir tr.pexp td { border-top: 0; padding-top: 0; }
table.pdir tr[hidden] { display: none !important; }
.pcard { padding: 2px 0 6px 14px; border-left: 3px solid var(--line); max-width: 980px; }
.contacts { columns: 2 380px; column-gap: 28px; }
.contacts li { break-inside: avoid; }
.pcard p { margin: 0 0 6px; }
.contacts { margin: 0; padding: 0; list-style: none; }
.contacts li { padding: 4px 0; border-top: 1px solid var(--line-2); overflow-wrap: anywhere; }
.contacts .meta { display: flex; }
.exc-list { margin: 0; padding: 0; list-style: none; }
.exc-list li { padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.exc-list li:last-child { border-bottom: 0; }

/* ---- login ---- */
body.login { display: grid; place-items: center; min-height: 100vh; }
.card { background: #fff; padding: 28px 32px; border: 1px solid var(--line); border-top: 4px solid var(--ink); border-radius: 4px; width: 320px; max-width: 92vw; }
.card h1 span { color: var(--act); }
.card label { display: block; margin: 14px 0; }
.card input { width: 100%; margin-top: 4px; }

/* ---- smaller screens ---- */
@media (max-width: 1180px) {
  .brief { grid-template-columns: minmax(0, 1fr); }
  .grid.main-side { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  main { padding: 12px 12px 48px; }
  .top nav { padding: 0 8px; }
  .top .spend { display: none; }
  h1 { font-size: 24px; }
  th { position: static; }
  .rowhead { display: none; }
  .row { grid-template-columns: 1fr; }
  table.list.cards thead { display: none; }
  table.list.cards, table.list.cards tbody, table.list.cards tr, table.list.cards td { display: block; width: 100%; }
  table.list.cards tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
  table.list.cards td { border: 0; padding: 2px 10px; background: none !important; }
  table.list.cards td[data-l]::before { content: attr(data-l) ": "; color: var(--ink-2); }
  table.list.cards td.num { text-align: left; }
}
table.list tbody tr.sub td { background: var(--surface) !important; border-top: 0; padding-top: 0; }
/* inside a horizontal scroller the sticky header can only stick to the scroller's own top */
.scroll th { top: 0; }
table.list td.pm { max-width: 300px; color: var(--ink-2); }
table.list td:first-child { min-width: 200px; }
table.list td[data-l="Ruta"] { white-space: nowrap; }

/* ==== v0.4: familiar for an Outlook user. Same palette and type; denser structure. ==== */
.ic { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
kbd { font: 600 12px/1 var(--body); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; padding: 2px 5px;
  background: var(--zebra); color: var(--ink); white-space: nowrap; }
kbd.hint { font-size: 11px; color: var(--ink-3); background: none; border-color: var(--line-2); margin-left: auto; padding: 1px 5px; }
.icon-btn { border: 0; background: none; padding: 4px; border-radius: 3px; color: var(--ink-2); line-height: 0; }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
.top .keyhelp { color: #c9d2da; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; padding: 0 10px; }
.top .keyhelp:hover { color: #fff; }

/* command bar under the page title, as the Outlook ribbon in its simplified form */
.pagehead { margin-bottom: 10px; }
.cmdbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 4px; padding: 3px 4px; margin: 0 0 14px; }
.cmdbar form.inline { display: contents; }
.cmd { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--ink); padding: 5px 10px;
  border-radius: 3px; font-size: 14px; text-decoration: none; line-height: 1.35; cursor: pointer; transition: background-color 120ms ease; }
.cmd .ic { color: var(--act); }
.cmd:hover { background: var(--act-bg); color: var(--ink); }
.cmd:disabled, .cmd[aria-disabled="true"] { color: var(--ink-3); cursor: default; background: none; }
.cmd:disabled .ic { color: var(--ink-3); }
.cmd.quiet { color: var(--ink-2); }
.cmdbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.cmdbar .grow { flex: 1; }
.actions .button, .actions button { display: inline-flex; align-items: center; gap: 6px; }
button.quiet { border-color: var(--line); color: var(--ink-2); }

/* ---- message list and reading pane ---- */
.mpanel > h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding-bottom: 10px; margin: 0; }
.mlist { display: grid; grid-template-columns: minmax(290px, 38%) minmax(0, 1fr); height: calc(100vh - 110px); min-height: 440px;
  max-height: 900px; border-top: 1px solid var(--line); }
.mlist-col { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.mlist-tools { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-bottom: 1px solid var(--line-2); }
.msearch { flex: 1; display: flex; align-items: center; gap: 6px; border: 1px solid #b9c2c6; border-radius: 3px; padding: 0 7px;
  color: var(--ink-3); background: #fff; }
.msearch:focus-within { border-color: var(--act); box-shadow: 0 0 0 1px var(--act); }
.msearch input { border: 0; padding: 4px 0; flex: 1; min-width: 0; outline: none; background: none; }
.mlist-rows { position: relative; overflow: auto; flex: 1; min-height: 0; overscroll-behavior: contain; }
.mbar { position: absolute; left: 0; top: 0; width: 3px; height: 0; background: var(--act); z-index: 3; opacity: 0;
  transition: transform 160ms ease, height 160ms ease, opacity 120ms ease; pointer-events: none; }
.mgroup { position: sticky; top: 0; z-index: 2; background: var(--surface); font: 600 13px/1.2 var(--head); color: var(--ink-2);
  padding: 7px 12px 5px; border-bottom: 1px solid var(--line-2); letter-spacing: .02em; }
.mgroup .n { font-weight: 500; color: var(--ink-3); }
.mrow { display: block; padding: 7px 12px 7px 14px; border-bottom: 1px solid var(--line-2); cursor: pointer; position: relative;
  transition: background-color 120ms ease; outline: none; }
.mrow:hover { background: #edf2f8; }
.mrow[aria-selected="true"] { background: var(--act-bg); }
.mrow:focus-visible { box-shadow: inset 0 0 0 2px var(--act); }
.mrow[hidden] { display: none; }
.mrow .l1, .mrow .l2, .mrow .l3 { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.mrow .from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.mrow .from .ic { color: var(--ink-3); width: 14px; height: 14px; }
.mrow .date { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.mrow .subj { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.mrow .l3 { font-size: 13px; color: var(--ink-2); }
.mrow .pv { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow .l3 .tag { font-size: 11.5px; padding: 0 5px; }
.mrow.new .from, .mrow.new .subj { font-weight: 600; color: var(--ink); }
.mrow.new .date { color: var(--act); font-weight: 600; }
.mrow.quoted .from, .mrow.quoted .subj { color: var(--ink-2); }
.mbs { display: inline-flex; gap: 6px; flex: none; }
.mb { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.mb .ic { width: 13px; height: 13px; }
.mb.act, .mb.q { color: var(--act); font-weight: 600; }
.mb.count { color: var(--ink-3); }
.mlist-empty { padding: 12px; }
.mchev { flex: none; width: 14px; height: 14px; padding: 0; border: 0; background: none; color: var(--ink-3);
  cursor: pointer; font-size: 11px; line-height: 14px; text-align: center; transition: transform 120ms ease; }
.mchev[aria-expanded="true"] { transform: rotate(90deg); }
.mrow.child { padding-left: 30px; }
.mrow.thread-head .from { margin-left: 2px; }

.mpane { overflow: auto; min-height: 0; padding: 14px 18px 18px; outline: none; background: var(--surface); }
.mpane-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  color: var(--ink-2); gap: 2px; }
.mpane-empty .ic { width: 40px; height: 40px; color: var(--line); stroke-width: 1; }
.mpane-empty p { margin: 0; }
.pane-in { transition: opacity 160ms ease, transform 160ms ease; }
.pane-in.enter { opacity: 0; transform: translateY(8px); }
.ph-top { display: flex; align-items: flex-start; gap: 10px; }
.ph-top h2 { flex: 1; font-size: 19px; margin: 0 0 8px; overflow-wrap: anywhere; }
dl.hdr { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 1px 12px; margin: 0 0 6px; font-size: 13.5px; }
dl.hdr dt { color: var(--ink-2); }
dl.hdr dd { margin: 0; overflow-wrap: anywhere; }
.plinks { margin: 0 0 8px; }
.plinks .ic, .atts .ic { width: 14px; height: 14px; }
.atts { margin: 0 0 10px; padding: 6px 8px; background: var(--zebra); border-radius: 3px; }
.mbody { border-top: 1px solid var(--line-2); padding: 10px 0; font-size: 14.5px; }
.says { margin-top: 10px; border-top: 2px solid var(--line); padding-top: 10px; }
.says > h3 { font-size: 15px; color: var(--act); margin-bottom: 6px; }
.says h4 { margin-top: 14px; }
.says .draft { margin: 10px 0; }
.draft h3 { display: flex; align-items: center; gap: 6px; margin: 2px 0 6px; }
.draft h3 .ic { color: var(--act); }
.draft .dhead { margin: 0 0 6px; }
.draft .actions { margin: 6px 0 8px; }
.fbwrap { padding: 2px 0; }
.fbwrap .feedback { margin-top: 4px; }
ul.rates { margin: 4px 0; padding: 0; list-style: none; }
ul.rates li { padding: 3px 0; border-bottom: 1px solid var(--line-2); }

/* the pane under the selected row (Today, and every list below 860 px) */
.mlist.inline { display: block; height: auto; max-height: none; min-height: 0; border-top: 0; }
.mlist.inline .mlist-col { border-right: 0; }
.mlist.inline .mlist-rows { overflow: visible; }
.mlist.inline .mgroup { position: static; }
.mlist .mpane.under { border: 1px solid var(--line); border-left: 3px solid var(--act); border-radius: 0 0 4px 4px; margin: 0 0 6px;
  overflow: visible; }
.mlist.inline > .mpane:not(.under) { display: none; }
.bsec .mlist.inline { margin: 2px -16px 6px; }
.bsec .mlist.inline .mrow { padding-left: 16px; }

/* facts grouped per key */
.facts-g h2 { margin-bottom: 6px; }
.fg { padding: 0; border-bottom: 1px solid var(--line-2); }
.fg:last-child { border-bottom: 0; }
.fg > summary { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; gap: 8px; align-items: baseline; padding: 2px 0;
  list-style: none; font-size: 13.5px; line-height: 1.4; cursor: pointer; }
.fg > summary::-webkit-details-marker { display: none; }
.fg > summary:hover { background: #f3f6f9; }
.fg .k { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.fg .v { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fg[open] .v { white-space: normal; overflow-wrap: anywhere; }
.fg .src { font-size: 12.5px; color: var(--act); white-space: nowrap; }
.fg[open] .src { font-weight: 600; }
.fsrc { margin: 0 0 6px 0; padding: 4px 0 4px 10px; list-style: none; border-left: 3px solid var(--line); font-size: 13.5px; }
.fsrc li { padding: 2px 0; }
.fsrc .fv { font-weight: 600; }

/* side lists on the project and thread pages */
ul.threads { list-style: none; margin: 0; padding: 0 16px 8px; }
ul.threads li { padding: 4px 0; border-bottom: 1px solid var(--line-2); }
ul.threads li:last-child { border-bottom: 0; }
ul.threads .meta { display: flex; }
details.panel > summary { list-style: none; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary h2 { margin: 0; }
details.panel > summary h2::before { content: "\25B8"; display: inline-block; width: 14px; color: var(--ink-3); font-size: 13px;
  transition: transform 120ms ease; }
details.panel[open] > summary h2::before { transform: rotate(90deg); }
/* the projects list: four groups, lost as the archive at the bottom */
.pgroup > .empty { padding: 0 16px 14px; }
.pfind { display: flex; margin: 0 0 12px; max-width: 560px; }
.pfind .msearch { background: var(--surface); }
.pfind .msearch input { padding: 7px 0; }
details.pgroup > summary { padding: 14px 16px 10px; }
details.panel[open] > summary { margin-bottom: 8px; }
.qline { margin: 0 0 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line-2); }
.qline:last-child { border-bottom: 0; }
.proposal[data-proposal].sel { box-shadow: 0 0 0 2px var(--act-bg); border-style: solid; }
.bsec h2 { align-items: center; }

/* ---- drop anywhere ---- */
.dropov { position: fixed; inset: 0; z-index: 50; background: rgba(23, 33, 43, .34); display: grid; place-items: center;
  pointer-events: none; opacity: 0; transition: opacity 120ms ease; }
.dropov.on { opacity: 1; }
.dropov .box { background: var(--surface); border: 2px dashed var(--act); border-radius: 8px; padding: 26px 44px; display: flex;
  flex-direction: column; align-items: center; gap: 4px; color: var(--ink-2); box-shadow: 0 8px 30px rgba(0, 0, 0, .18); }
.dropov .box .ic { width: 34px; height: 34px; color: var(--act); stroke-width: 1.2; }
.dropov .box strong { font: 600 22px/1.2 var(--head); color: var(--ink); }
.dropov .where { font-weight: 600; color: var(--act); min-height: 1.2em; }
[data-drop-project].drop-hover, [data-drop-project].drop-hover td { background: var(--act-bg) !important; }

/* ---- toasts ---- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  max-width: calc(100vw - 32px); }
.toast { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--act); border-radius: 4px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .16); padding: 10px 12px 10px 14px; width: 400px; max-width: 100%; display: flex; gap: 10px;
  align-items: flex-start; transition: transform 180ms ease, opacity 180ms ease; font-size: 14px; }
.toast.enter, .toast.leave { transform: translateY(12px); opacity: 0; }
.toast.ok { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--risk); }
.toast .tb { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast .tb ul { margin: 4px 0 0; padding-left: 18px; font-size: 13px; }
.toast .bar { height: 4px; background: var(--line-2); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.toast .bar span { display: block; height: 100%; background: var(--act); width: 0; transition: width 160ms ease; }

/* ---- the ? window ---- */
dialog.keys { border: 1px solid var(--line); border-radius: 6px; padding: 16px 22px 20px; width: 720px; max-width: calc(100vw - 24px);
  color: var(--ink); box-shadow: 0 12px 40px rgba(0, 0, 0, .25); }
dialog.keys::backdrop { background: rgba(23, 33, 43, .4); }
dialog.keys[open] { animation: kin 160ms ease; }
@keyframes kin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.kh-head { display: flex; align-items: center; }
.kh-head h2 { flex: 1; margin: 0; }
.kh-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
dialog.keys h3 { margin: 12px 0 4px; font-size: 15px; color: var(--ink-2); }
dialog.keys dl { display: grid; grid-template-columns: max-content 1fr; gap: 5px 12px; margin: 0; align-items: baseline; font-size: 14px; }
dialog.keys dd { margin: 0; }

@media (max-width: 860px) {
  .mlist { display: block; height: auto; max-height: none; min-height: 0; }
  .mlist-col { border-right: 0; }
  .mlist-rows { overflow: visible; }
  .mgroup { position: static; }
  .mlist > .mpane:not(.under) { display: none; }
  .cmd { padding: 6px 8px; }
  .cmdbar .grow, .cmd.quiet { display: none; }
  .kh-cols { grid-template-columns: 1fr; }
  .fg > summary { grid-template-columns: 96px minmax(0, 1fr) auto; }
  .toast { width: 100%; }
  .top .keyhelp span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0s !important; animation-duration: 0s !important;
    transition-delay: 0s !important; }
}

/* v0.5: the local trucking leg on the project page, the tariff in /admin, the thread story */
.localleg { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.localleg h3 { margin: 0 0 6px; }
.localleg .lc-total { font-size: 17px; margin: 0 0 4px; }
.localleg .lc-parts { margin: 0 0 6px; padding-left: 18px; }
.localleg .lc-form { flex-wrap: wrap; gap: 6px 12px; }
.list.tariff td, .list.tariff th { padding: 3px 8px; }
.list.tariff tr.hl td { background: var(--due-bg); font-weight: 600; }
.story { margin: 0; padding-left: 22px; }
.story li { margin: 0 0 4px; }
.story .who { color: var(--ink-2); font-size: 13px; }
.story-status { font: 600 16px/1.3 var(--head); margin: 8px 0 2px; }
.story-status .why { font-weight: 400; color: var(--ink-2); }
.story-others { list-style: none; margin: 8px 0 0; padding: 0; }
.story-others > li { padding: 4px 0; border-top: 1px solid var(--line); }
.status-line { display: block; color: var(--ink-2); font-size: 12px; }
