/* MP Collections styles (step 6f). Light theme only; a dense working tool, no animation.
   Colours come from the Metal Park logo: charcoal for the header, Metal Park blue for anything you can click.
   Stage severity colours and the four department colours carry meaning and stay as the procedure set them. */

@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("/static/fonts/IBMPlexSans-Regular.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: italic; font-weight: 400; font-display: swap; src: url("/static/fonts/IBMPlexSans-Italic.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("/static/fonts/IBMPlexSans-Medium.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("/static/fonts/IBMPlexSans-SemiBold.woff2") format("woff2"); }

:root {
  --bg: #eef1f4;            /* steel: the page */
  --surface: #ffffff;       /* paper: panels and tables */
  --line: #d6dbe1;          /* rules between rows and around panels */
  --field-border: #8a93a0;  /* input edges: dark enough to see (3.1:1) */
  --text: #262a2e;
  --muted: #5d6670;
  --charcoal: #383838;      /* the header, from the logo */
  --accent: #3a72a3;        /* Metal Park blue, from the logo */
  --accent-dark: #2f5f8a;
  --accent-ink: #ffffff;
  --accent-light: #6fa5d6;  /* the current-page bar on the charcoal header */
  --danger: #b42318;
  --danger-bg: #fdecea;
  --ok: #1e7a3c;
  --ok-bg: #e6f4ea;
  --hos: #9b2c2c;
  --row-hover: #f3f5f8;
  --radius: 3px;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --dept-finance: #2b5d8c;
  --dept-finance-bg: #e4edf6;
  --dept-sales: #3f6522;
  --dept-sales-bg: #e7f1dc;
  --dept-logistics: #5b45a8;
  --dept-logistics-bg: #ebe6f7;
  --dept-management: #9b2c2c;
  --dept-management-bg: #f8e3e3;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  font: 13px/1.45 var(--font);
  color: var(--text);
  background: var(--bg);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums;
}

h1 { font-size: 18px; font-weight: 600; margin: 0 0 12px; text-wrap: balance; }
h2 { font-size: 15px; font-weight: 600; margin: 16px 0 8px; text-wrap: balance; }
p { margin: 0 0 8px; }
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.skip-link {
  position: absolute; left: -999px; top: 4px; z-index: 30;
  background: var(--surface); padding: 6px 10px; border: 1px solid var(--line);
}
.skip-link:focus { left: 8px; }

/* ---- Header: a charcoal band with the logo on a white tile ---------------------------------------- */
.topbar {
  display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap;
  min-height: 48px;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  background: var(--charcoal); color: #fff;
}
.topbar :focus-visible { outline-color: #fff; outline-offset: -3px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; white-space: nowrap; }
.brand-tile { display: inline-flex; align-items: center; background: #fff; border-radius: var(--radius); padding: 3px 6px; }
.brand-tile img { display: block; height: 28px; width: auto; }
.brand-name { font-weight: 600; font-size: 14px; letter-spacing: 0.01em; }
.topbar-nav { display: flex; align-items: stretch; gap: 2px; margin-left: 12px; }
.nav-link {
  display: inline-flex; align-items: center; min-height: 48px; padding: 0 10px;
  color: rgba(255, 255, 255, 0.82); text-decoration: none; font-weight: 500;
  border-top: 3px solid transparent; border-bottom: 3px solid transparent;
}
.nav-link:hover { color: #fff; }
.nav-link.is-current { color: #fff; border-bottom-color: var(--accent-light); }
.account { margin-left: auto; position: relative; display: flex; align-items: center; }
.account-summary {
  list-style: none; cursor: pointer; display: flex; flex-direction: column; align-items: flex-end;
  justify-content: center; line-height: 1.15; min-height: 48px; padding: 0 4px; color: #fff; text-align: right;
}
.account-summary::-webkit-details-marker { display: none; }
.account-summary::after { content: ""; display: none; }
.who-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.who-role { color: rgba(255, 255, 255, 0.72); font-size: 11px; }
.who-role::after { content: " \25BE"; }
.nowrap { white-space: nowrap; }
.account[open] .account-summary { background: rgba(255, 255, 255, 0.08); }
.account-menu {
  position: absolute; right: 0; top: 100%; z-index: 20; min-width: 190px; padding: 4px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 6px 16px rgba(20, 24, 28, 0.16);
}
.account-item {
  display: block; width: 100%; min-height: 36px; padding: 8px 10px; text-align: left;
  color: var(--text); text-decoration: none; background: none; border: 0; cursor: pointer; font: inherit;
  border-radius: var(--radius);
}
.account-item:hover { background: var(--row-hover); }
.inline-form { margin: 0; }

/* ---- Page and panels ----------------------------------------------------------------------------- */
.page { padding: 16px; max-width: 1400px; margin: 0 auto; }
.page-narrow { max-width: 420px; margin-top: 40px; }
.page-narrow-wide { max-width: 720px; margin-top: 24px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel h3 { margin: 14px 0 4px; font-size: 14px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head h1 { margin-bottom: 2px; }
.page-head-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sub { display: block; color: var(--muted); font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; margin: 2px 0 0; }
.hint-wrap { overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 12px 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.col { min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.table-wrap { overflow-x: auto; }

/* Client header facts */
.head-facts { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.fact { display: flex; flex-direction: column; min-width: 90px; }
.fact-label { color: var(--muted); font-size: 12px; }
.fact-value { font-weight: 600; font-size: 14px; }
.head-btn { align-self: center; }

/* Segmented navigation (Mine / Everyone, admin sections, dashboard views) */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.seg-item {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px;
  color: var(--text); text-decoration: none; border-right: 1px solid var(--line);
}
.seg-item:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.seg-item:last-child { border-right: 0; border-radius: 0 var(--radius) var(--radius) 0; }
.seg-item:hover { background: var(--row-hover); }
.seg-item.is-active { background: var(--accent); color: var(--accent-ink); }
.seg-item:focus-visible { outline-offset: -3px; }
.seg-item.is-active:focus-visible { outline-color: #fff; }

/* ---- Forms and buttons --------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-weight: 600; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.inline-fields { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0 10px; }
.inline-fields input[type="text"], .inline-fields input[type="date"], .inline-fields select { width: auto; min-width: 140px; }
.group { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; margin: 0; }
.group legend { font-weight: 600; padding: 0 4px; }

input, select, textarea, button { font: inherit; color: inherit; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="tel"],
input[type="date"], input[type="file"], select, textarea {
  width: 100%; min-height: 32px; padding: 5px 8px;
  border: 1px solid var(--field-border); border-radius: var(--radius); background: var(--surface);
}
select { background-color: var(--surface); color: var(--text); }
input:hover, select:hover, textarea:hover { border-color: var(--text); }
input[readonly], textarea[readonly] { background: var(--bg); border-color: var(--line); color: var(--muted); }
input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
input.short { max-width: 220px; }
textarea { line-height: 1.45; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; min-height: 32px; cursor: pointer; }
.check input { width: 18px; }
.check-only { justify-content: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 32px; padding: 4px 12px;
  border-radius: var(--radius); border: 1px solid var(--field-border); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; line-height: 1.3; font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--row-hover); border-color: var(--text); }
.btn:active { background: #e6e9ee; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-primary:active { background: #27507a; }
.btn-quiet { background: transparent; border-color: transparent; }
.btn-quiet:hover { background: #e3e7ec; border-color: transparent; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-small { min-height: 28px; padding: 2px 10px; font-size: 12px; }
@media (pointer: coarse) {
  .btn, .btn-small, .seg-item, select, input:not([type="checkbox"]), .account-item { min-height: 44px; }
}

.form-error {
  background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger);
  border-radius: var(--radius); padding: 6px 10px;
}
ul.form-error { padding-left: 24px; }
.form-success {
  background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok);
  border-radius: var(--radius); padding: 6px 10px;
}
.field.has-error input, .field.has-error textarea { border-color: var(--danger); }

/* Password fields: input with a Show/Hide button beside it */
.pw-field { display: flex; gap: 6px; align-items: stretch; }
.pw-field input { flex: 1; }
.pw-field .btn { min-height: 32px; }

/* ---- Tables -------------------------------------------------------------------------------------- */
table.data { border-collapse: collapse; width: 100%; background: var(--surface); border: 1px solid var(--line); }
table.data th, table.data td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data thead th { font-weight: 600; background: #f7f8fa; color: var(--muted); font-size: 12px; }
table.data tbody th[scope="row"] { font-weight: 500; }
table.data tbody tr:hover td, table.data tbody tr:hover th { background: var(--row-hover); }
.num { font-variant-numeric: tabular-nums; }
table.data .num { text-align: right; }
table.compact { max-width: 520px; }
table.compact td, table.compact th { padding: 4px 8px; }
table.timeline tr.tl-superseded td, table.timeline tr.tl-skipped td { color: var(--muted); }
.row-actions { white-space: nowrap; }
.row-actions .btn { margin-right: 4px; }

/* Stage pills, track and department badges (severity colours from the procedure document) */
.pill, .badge, .dept {
  display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 600;
  line-height: 1.6; white-space: nowrap; vertical-align: middle;
}
.pill { border: 1px solid transparent; }
.pill-sev-0 { background: #eef1f5; color: #4a5560; }
.pill-sev-1 { background: #e4edf6; color: #2b5d8c; }
.pill-sev-2 { background: #fff4d6; color: #8a5a00; }
.pill-sev-3 { background: #ffe6c7; color: #9a4b00; }
.pill-sev-4 { background: #f8d8d2; color: #a3321b; }
.pill-sev-5 { background: var(--hos); color: #fff; }
.badge-ladder { background: #eef1f5; color: #4a5560; }
.badge-hos { background: var(--hos); color: #fff; }
.badge-hold { background: #ffe6c7; color: #9a4b00; }
.badge-promise { background: #e7f1dc; color: #3f6522; }
.dept-finance { background: var(--dept-finance-bg); color: var(--dept-finance); }
.dept-sales { background: var(--dept-sales-bg); color: var(--dept-sales); }
.dept-logistics { background: var(--dept-logistics-bg); color: var(--dept-logistics); }
.dept-management { background: var(--dept-management-bg); color: var(--dept-management); }

/* ---- Login --------------------------------------------------------------------------------------- */
.login-logo { display: block; margin: 0 auto 14px; height: 58px; width: auto; }
.login h1 { text-align: center; }

/* ---- Confirmation page --------------------------------------------------------------------------- */
.confirm-message { font-size: 14px; max-width: 60ch; }
.confirm-details { margin: 0 0 12px; display: grid; gap: 4px; }
.confirm-details div { display: flex; gap: 10px; }
.confirm-details dt { color: var(--muted); min-width: 60px; }
.confirm-details dd { margin: 0; }

/* ---- Draft panel (step 5) ------------------------------------------------------------------------ */
.panel.action-panel { margin-bottom: 10px; }
.action-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.draft { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }
.draft textarea { font-family: inherit; font-size: 13px; width: 100%; }
.draft-meta { margin: 2px 0; font-size: 13px; }
.htmx-request button { opacity: 0.6; cursor: progress; }

/* ---- Admin screens (step 6b) --------------------------------------------------------------------- */
.mapping-list { display: grid; grid-template-columns: 1fr; gap: 2px; margin: 4px 0 0; font-size: 13px; }
.mapping-list div { display: flex; gap: 8px; }
.mapping-list dt { color: var(--muted); min-width: 160px; }
.mapping-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.secret-panel { border-color: var(--accent); margin-bottom: 12px; }
.secret { margin: 4px 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.secret-label { display: inline-block; min-width: 80px; color: var(--muted); }
.secret code { font-size: 15px; padding: 2px 6px; background: #f7f8fa; border: 1px solid var(--line); border-radius: var(--radius); user-select: all; }
.reminders-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* ---- Setup screen (step 6c) ---------------------------------------------------------------------- */
table.setup input[type="text"], table.setup input[type="email"], table.setup select { width: 100%; min-width: 150px; }

/* ---- Dashboard (step 6e): a ledger strip of figures, then tables ---------------------------------- */
.filters { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; margin: 0; }
.filters label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.filters select { min-width: 150px; }
.ledger {
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px;
}
.ledger-cell { padding: 10px 14px; border-left: 1px solid var(--line); min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ledger-cell:first-child { border-left: 0; }
.ledger-value { font-size: clamp(17px, 1.6vw, 22px); font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.ledger-caption { color: var(--muted); font-size: 12px; }
.ledger-cell.is-hos { box-shadow: inset 0 3px 0 var(--hos); }
.ledger-3 { grid-template-columns: repeat(3, 1fr); }
/* Bar charts on the Collections view: one hue, thin marks, the table beneath carries the exact figures. */
.bars { margin: 8px 0 12px; max-width: 720px; }
.bars svg { display: block; width: 100%; height: auto; max-height: 160px; }
.bar { fill: var(--accent); }
.bar:hover { fill: var(--accent-dark); }
.bar-axis { stroke: var(--line); stroke-width: 1; }
.bar-label { font-size: 11px; fill: var(--muted); font-family: var(--font); }
.ledger-cell.is-hos .ledger-value { color: var(--hos); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; margin-bottom: 12px; align-items: start; }
.dash-section { margin-bottom: 12px; }
.dash-section h2 { margin-top: 0; }

/* ---- Phone widths: the queue and client page are the screens used on a phone --------------------- */
@media (max-width: 900px) {
  .ledger { grid-template-columns: repeat(3, 1fr); }
  .ledger-cell:nth-child(4) { border-left: 0; }
  .ledger-cell:nth-child(n + 4) { border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .cols { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .head-facts { gap: 12px; }
  .row-actions { white-space: normal; }
  /* The queue table becomes one card per action. */
  table.queue, table.queue tbody, table.queue tr { display: block; }
  table.queue thead { display: none; }
  table.queue tr { padding: 8px 10px; border-bottom: 1px solid var(--line); }
  table.queue tr:last-child { border-bottom: 0; }
  table.queue td, table.queue th[scope="row"] { display: block; padding: 1px 0; border: 0; text-align: left; }
  table.queue th[scope="row"] { font-size: 14px; }
  table.queue td.num { text-align: left; }
  table.queue td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); }
  table.queue td:empty { display: none; }
  table.queue td:nth-child(2) { display: none; }  /* the track badge repeats what the stage pill says */
  table.queue .row-actions { display: flex; gap: 6px; margin-top: 6px; }
  table.queue .row-actions .btn { margin: 0; }
}
@media (max-width: 600px) {
  .topbar { gap: 0; }
  .topbar-nav { order: 3; flex-basis: 100%; margin-left: -4px; overflow-x: auto; }
  .nav-link { min-height: 40px; }
  .brand-name { font-size: 13px; }
}
@media (max-width: 480px) {
  .topbar { padding: 0 10px; }
  .page { padding: 10px; }
  .page-narrow { margin-top: 16px; }
  .fact { min-width: 44%; }
  .ledger { grid-template-columns: repeat(2, 1fr); }
  .ledger-cell:nth-child(odd) { border-left: 0; }
  .ledger-cell:nth-child(even) { border-left: 1px solid var(--line); }
  .ledger-cell:nth-child(n + 3) { border-top: 1px solid var(--line); }
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); border: 0; white-space: nowrap;
}

/* Plain bulleted notes, for example the points an import skipped or guessed. */
.plain-list { margin: 0; padding-left: 1.2em; }
.plain-list li { margin: 0.25em 0; }
