/* BPLS portal. Deep claret blocks, gold accent, a geometric sans, square corners.
   The one bold element is the milestone track on the file page. */

@font-face { font-family: "Outfit"; font-weight: 400; font-display: swap; src: url("fonts/outfit-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Outfit"; font-weight: 500; font-display: swap; src: url("fonts/outfit-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Outfit"; font-weight: 600; font-display: swap; src: url("fonts/outfit-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Outfit"; font-weight: 700; font-display: swap; src: url("fonts/outfit-latin-700-normal.woff2") format("woff2"); }

:root {
  --claret: #850123;
  --claret-deep: #3a0612;
  --claret-soft: #a3213f;
  --gold: #f2cf44;
  --gold-dim: #b9a25c;
  --gold-tint: #fbf3d2;
  --ink: #1e1a1b;
  --ink-2: #5f5457;
  --ink-3: #9a9093;
  --rule: #d9d4cc;
  --rule-soft: #ebe7e0;
  --paper: #ffffff;
  --field: #edeae3;
  --ok: #1f6b4a;
  --ok-tint: #e3f1ea;
  --warn: #7a5200;
  --warn-tint: #fff4d6;
  --bad: #a33a2e;
  --bad-tint: #fbe9e7;
  --focus: #1d63d8;
  --font: "Outfit", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --radius: 2px;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font-family: var(--font); color: var(--ink); background: var(--field); line-height: 1.5;
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1;
}
a { color: var(--claret); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--claret-deep); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .92em; background: var(--rule-soft); padding: .1em .35em; }
code.secret { user-select: all; }
mark { background: none; color: var(--gold); }

.skip { position: absolute; left: -999px; top: 0; background: var(--paper); padding: .5rem 1rem; }
.skip:focus { left: .5rem; z-index: 10; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Top bar --------------------------------------------------------------- */
.topbar { background: var(--claret); color: #fff; }
.topbar-inner { max-width: 1160px; margin: 0 auto; padding: 0 1.5rem; display: flex; align-items: center; gap: 2rem; min-height: 76px; }
.brand { display: flex; align-items: center; }
.brand img { display: block; height: 46px; width: auto; }
.nav { display: flex; gap: .15rem; flex-wrap: wrap; }
.nav a { color: rgba(255,255,255,.82); text-decoration: none; padding: .45rem .7rem; font-weight: 500; border-radius: var(--radius); }
.nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav a[aria-current="page"] { color: var(--claret-deep); background: var(--gold); }
.who { margin-left: auto; display: flex; align-items: center; gap: 1rem; white-space: nowrap; }
.who-name { color: rgba(255,255,255,.85); }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--gold); cursor: pointer; font-weight: 500; }
button.link:hover { text-decoration: underline; }

/* Page ------------------------------------------------------------------ */
.page { flex: 1; width: 100%; max-width: 1000px; margin: 0 auto; padding: 2rem 1.5rem 3rem; }
.page-wide { max-width: 1160px; }
.page-narrow { max-width: 640px; }
.page-sign { max-width: 1160px; padding-top: 0; padding-bottom: 0; display: flex; flex-direction: column; }
h1 { font-size: 2rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 0 0 .75rem; letter-spacing: -.01em; }
.muted { color: var(--ink-2); }
.small { font-size: .9rem; }
.empty { color: var(--ink-3); }
.crumb { margin: 0 0 1rem; font-size: .95rem; }
.crumb a { color: var(--ink-2); text-decoration: none; }
.crumb a::before { content: "← "; }
.crumb a:hover { color: var(--claret); text-decoration: underline; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1, .page-head p { margin: 0; }
.section { margin-top: 2.25rem; }
.section > p:first-of-type { margin-top: 0; }

.notice { padding: .75rem 1rem; margin-bottom: 1.25rem; border-left: 4px solid var(--ink-3); background: var(--paper); }
.notice-ok { border-color: var(--ok); background: var(--ok-tint); }
.notice-info { border-color: var(--gold); background: var(--gold-tint); }
.notice-error { border-color: var(--bad); background: var(--bad-tint); color: var(--bad); }

.panel { background: var(--paper); border: 1px solid var(--rule); padding: 1.5rem; }
.panel h2 { margin-top: 0; }

/* Sign-in: a dark claret hero and a white panel, like the marketing site -- */
.page-sign .sign { display: grid; grid-template-columns: 1.1fr 1fr; gap: 0; margin: 2.5rem 0 3rem; background: var(--paper); border: 1px solid var(--rule); }
.sign-hero { background: var(--claret-deep); color: #fff; padding: 3rem 2.75rem; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.sign-hero::after { content: ""; position: absolute; right: -60px; bottom: -60px; width: 220px; height: 220px; border: 18px solid var(--claret); transform: rotate(45deg); opacity: .6; }
.sign-hero h1 { font-size: clamp(2.2rem, 4.5vw, 3.4rem); font-weight: 600; margin: 0 0 1rem; }
.sign-hero p { margin: 0; font-size: 1.1rem; color: rgba(255,255,255,.8); max-width: 34ch; }
.sign-hero a { color: var(--gold); }
.sign-panel { padding: 3rem 2.75rem; }
.sign-panel h2 { font-size: 1.5rem; margin-bottom: .5rem; }
.sign-panel .muted { margin-top: 0; }
.quiet { color: var(--ink-3); }

/* Forms ----------------------------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: 1rem; }
label { display: block; font-weight: 500; }
label .hint { font-weight: 400; color: var(--ink-2); font-size: .9rem; }
label.inline { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .4rem; }
legend { font-weight: 500; margin-bottom: .3rem; padding: 0; }
input:not([type=checkbox], [type=radio], [type=file]), select, textarea {
  display: block; width: 100%; margin-top: .3rem; font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid #b7afa6; border-radius: var(--radius); padding: .6rem .75rem;
}
input.short { width: 9rem; }
input[type=file] { margin-top: .3rem; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: 3px solid var(--focus); outline-offset: 0; }
.field-error { display: block; margin-top: .35rem; font-size: .9rem; color: var(--bad); font-weight: 400; }
.field-ok { display: block; margin-top: .35rem; font-size: .9rem; color: var(--ok); font-weight: 400; }
.row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.row.wrap { align-items: flex-end; }
.row.wrap label.inline { padding-bottom: .6rem; }

.btn {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.3;
  color: var(--claret-deep); background: var(--paper); border: 1px solid #b7afa6; border-radius: var(--radius); padding: .65rem 1.1rem;
}
.btn:hover { background: var(--field); color: var(--claret-deep); }
.btn-primary { background: var(--claret); border-color: var(--claret); color: #fff; }
.btn-primary:hover { background: var(--claret-deep); border-color: var(--claret-deep); color: #fff; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: var(--claret-deep); }
.btn-gold:hover { background: #e9c42e; border-color: #e9c42e; color: var(--claret-deep); }
.btn-danger { color: var(--bad); border-color: #e0b3ad; }
.btn-danger:hover { background: var(--bad-tint); color: var(--bad); }
.btn-link { color: var(--ink-2); font-size: .95rem; }

/* Hero on the list page ------------------------------------------------- */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.hero h1 { font-size: 2.4rem; margin: 0 0 .25rem; }
.hero-sub { margin: 0; color: var(--ink-2); }
.hero-sub strong { color: var(--ink); font-weight: 600; }
.search { display: flex; gap: .5rem; align-items: center; }
.search input, .search select { margin-top: 0; }
.search input[type=search] { width: 20rem; max-width: 60vw; }
.search select { width: auto; }

/* Case list ------------------------------------------------------------- */
.stage-key { display: none; }
.cases { list-style: none; margin: 0; padding: 0; background: var(--paper); border: 1px solid var(--rule); }
.case + .case { border-top: 1px solid var(--rule-soft); }
.case-link {
  display: grid; grid-template-columns: 7.5rem minmax(0, 1fr) 15rem 3.5rem; align-items: center; gap: 1.25rem;
  padding: .9rem 1.25rem; color: inherit; text-decoration: none;
}
.case-link:hover { background: #fbf8f2; color: inherit; }
.case-ref { font-weight: 700; font-size: 1.05rem; letter-spacing: .01em; color: var(--claret-deep); }
.case-who { display: flex; flex-direction: column; min-width: 0; }
.case-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.case-addr { color: var(--ink-2); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.case-stage { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: .6rem; align-items: center; }
.case-stage .ladder { grid-row: 1 / span 2; }
.case-stage-name { font-weight: 600; font-size: .95rem; line-height: 1.2; }
.case-stage-date { color: var(--ink-2); font-size: .85rem; line-height: 1.2; }
.case-go { color: var(--claret); font-weight: 600; font-size: .9rem; text-align: right; }
.case.is-complete .case-stage-name { color: var(--ok); }

.ladder { display: inline-flex; gap: 2px; }
.ladder i { display: block; width: 7px; height: 22px; background: var(--rule); }
.ladder i.on { background: var(--gold); }
.ladder.is-complete i.on { background: var(--ok); }

.pager { display: flex; gap: 1rem; align-items: center; margin-top: 1rem; font-size: .95rem; }
.pager .disabled { color: var(--ink-3); }
.empty-state { background: var(--paper); border: 1px dashed var(--rule); padding: 2.5rem 1.5rem; text-align: center; }
.empty-state p { margin: 0 0 .4rem; }

/* File page ------------------------------------------------------------- */
.file-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 2rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.file-ref { margin: 0; font-size: 1rem; font-weight: 700; letter-spacing: .06em; color: var(--claret); }
.file-hero h1 { font-size: 2.4rem; margin: .1rem 0 .3rem; }
.file-addr { margin: 0; color: var(--ink-2); font-size: 1.05rem; }
.file-status { background: var(--claret-deep); color: #fff; padding: 1rem 1.4rem; min-width: 15rem; display: flex; flex-direction: column; }
.file-status-label { font-size: .85rem; color: rgba(255,255,255,.7); }
.file-status-stage { font-size: 1.5rem; font-weight: 600; color: var(--gold); line-height: 1.15; }
.file-status-date { font-size: .95rem; color: rgba(255,255,255,.85); }
.file-status.is-complete { background: var(--ok); }
.file-status.is-complete .file-status-stage { color: #fff; }

/* The milestone track: a gold line that grows to the current stage ------ */
.journey { background: var(--paper); border: 1px solid var(--rule); padding: 2rem 1.5rem 1.25rem; margin-bottom: 1.5rem; }
.track { position: relative; --dot: 18px; }
.track-line { position: absolute; left: calc(50% / var(--n)); right: calc(50% / var(--n)); top: calc(var(--dot) / 2 - 2px); height: 4px; background: var(--rule); }
.track-fill { height: 100%; width: 0; background: var(--gold); transform-origin: left;
  transition: width 1.1s cubic-bezier(.4, 0, .2, 1); }
.track.is-run .track-fill { width: calc((var(--reached) - 1) / (var(--n) - 1) * 100%); }
.track.is-run[data-reached="0"] .track-fill { width: 0; }
.track-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(var(--n), 1fr); position: relative; }
.step { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 .25rem; }
.step-text { display: contents; }
.step-dot { width: var(--dot); height: var(--dot); border-radius: 50%; background: var(--paper); border: 3px solid var(--rule); margin-bottom: .6rem; position: relative; z-index: 1;
  transition: border-color .3s ease, background-color .3s ease, transform .3s ease; }
.track.is-run .step.reached .step-dot { background: var(--gold); border-color: var(--gold); }
.track.is-run .step.reached .step-dot { transition-delay: calc(var(--i) * 1.1s / max(var(--n) - 1, 1) * 1); }
.track.is-run .step.current .step-dot { background: var(--claret); border-color: var(--claret); transform: scale(1.25); box-shadow: 0 0 0 6px rgba(133,1,35,.15); }
.step-label { font-weight: 600; font-size: .92rem; line-height: 1.2; color: var(--ink-3); }
.step-date { font-size: .82rem; color: var(--ink-3); margin-top: .15rem; }
.step.reached .step-label { color: var(--ink); }
.step.reached .step-date { color: var(--ink-2); }
.step.current .step-label { color: var(--claret); }
.journey-note { margin: 1.25rem 0 0; color: var(--ink-2); text-align: center; }
.track.is-run .step.reached:last-child .step-dot,
.track.is-run .step.reached.current:last-child .step-dot { background: var(--ok); border-color: var(--ok); box-shadow: 0 0 0 6px rgba(31,107,74,.15); }

@media (prefers-reduced-motion: reduce) {
  .track-fill, .step-dot { transition: none !important; }
}

.file-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 1.5rem; align-items: start; }
.details { margin: 0; }
.detail { display: grid; grid-template-columns: 10rem 1fr; gap: 1rem; padding: .7rem 0; border-top: 1px solid var(--rule-soft); }
.detail:first-child { border-top: 0; padding-top: 0; }
.detail dt { color: var(--ink-2); font-weight: 500; }
.detail dd { margin: 0; overflow-wrap: anywhere; }
.postcode { letter-spacing: .04em; }
.multiline { white-space: pre-line; }

.accounts { background: var(--claret-deep); color: #fff; border-color: var(--claret-deep); }
.accounts h2 { color: var(--gold); }
.amounts { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.5rem; }
.amount dt { font-size: .85rem; color: rgba(255,255,255,.7); }
.amount dd { margin: 0; font-size: 1.35rem; font-weight: 600; }
.amount-main dd { font-size: 1.7rem; }
.amount-due dd { color: var(--gold); }
.paid-bar { height: 8px; background: rgba(255,255,255,.15); margin-top: 1.25rem; }
.paid-fill { height: 100%; width: var(--pct); background: var(--gold); transition: width .9s cubic-bezier(.4,0,.2,1); }
.accounts .muted { color: rgba(255,255,255,.7); }
.foot-note { margin-top: 1.5rem; }

/* Footer ---------------------------------------------------------------- */
.foot { background: var(--claret-deep); color: rgba(255,255,255,.75); font-size: .85rem; margin-top: auto; }
.foot-inner { max-width: 1160px; margin: 0 auto; padding: 1.1rem 1.5rem; display: flex; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; }
.foot a { color: var(--gold); }
.foot-warn { color: rgba(255,255,255,.6); }

/* Admin tables ---------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; background: var(--paper); border: 1px solid var(--rule); }
.table th { text-align: left; font-weight: 500; color: var(--ink-2); font-size: .85rem; padding: .6rem .8rem; border-bottom: 1px solid var(--rule); background: #faf8f4; }
.table td { padding: .6rem .8rem; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table.compact td, .table.compact th { padding: .45rem .7rem; font-size: .92rem; }
.table .num { text-align: right; }
.table .center { text-align: center; }
.table.mono td { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; white-space: nowrap; }
.table tr.inactive td { color: var(--ink-3); }
.table.mapping input, .table.mapping select { margin-top: 0; padding: .35rem .5rem; }
.table.mapping input.short { width: 4.5rem; }
.scroll { overflow-x: auto; }
.tag { display: inline-block; font-size: .75rem; padding: .05rem .5rem; background: var(--gold-tint); color: var(--warn); margin-left: .3rem; vertical-align: middle; }
.tag-ok { background: var(--ok-tint); color: var(--ok); }
.status { display: inline-block; font-size: .85rem; font-weight: 500; padding: .1rem .55rem; background: var(--rule-soft); color: var(--ink-2); }
.status-ok, .status-watching, .status-sent { background: var(--ok-tint); color: var(--ok); }
.status-unchanged, .status-waiting, .status-starting, .status-held { background: var(--warn-tint); color: var(--warn); }
.status-failed, .status-error { background: var(--bad-tint); color: var(--bad); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.fact { background: var(--paper); border: 1px solid var(--rule); padding: 1rem 1.1rem; display: flex; flex-direction: column; }
.fact-n { font-size: 2rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.fact-l { color: var(--ink-2); font-size: .9rem; margin-top: .2rem; }
.todo { list-style: none; margin: 0 0 1rem; padding: 0; }
.todo li { background: var(--gold-tint); border-left: 4px solid var(--gold); padding: .7rem 1rem; margin-bottom: .5rem; }
.todo li a { font-weight: 600; }
.kv { margin: 0 0 1rem; }
.kv.panel { padding: .25rem 1.25rem; }
.kv > div { display: grid; grid-template-columns: 11rem 1fr; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--rule-soft); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--ink-2); font-weight: 500; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.tabs { display: flex; gap: .25rem; margin-bottom: 1rem; }
.tabs a { padding: .4rem .8rem; text-decoration: none; color: var(--ink-2); border-bottom: 2px solid transparent; font-weight: 500; }
.tabs a[aria-current="page"] { color: var(--claret-deep); border-color: var(--gold); }

/* Responsive ------------------------------------------------------------ */
@media (max-width: 860px) {
  .page-sign .sign { grid-template-columns: 1fr; margin: 1rem 0 2rem; }
  .sign-hero, .sign-panel { padding: 2rem 1.5rem; }
  .file-grid, .two-col { grid-template-columns: 1fr; }
  .case-link { grid-template-columns: 6rem minmax(0,1fr) 11rem; }
  .case-go { display: none; }
}
@media (max-width: 720px) {
  .topbar-inner { gap: 1rem; flex-wrap: wrap; padding: .6rem 1rem; min-height: 0; }
  .brand img { height: 38px; }
  .nav { order: 3; width: 100%; }
  .page { padding: 1.25rem 1rem 2.5rem; }
  .hero h1, .file-hero h1 { font-size: 1.8rem; }
  .search input[type=search] { width: 100%; max-width: none; }
  .search { width: 100%; }
  .case-link { grid-template-columns: minmax(0,1fr); gap: .35rem; }
  .case-stage { grid-template-columns: auto 1fr; }
  .case-ref { font-size: .95rem; }
  /* Vertical track on phones: dots down the left, labels beside them. */
  .journey { padding: 1.25rem 1.25rem 1rem; }
  .track-line { display: none; }
  .track-steps { grid-template-columns: 1fr; }
  .step { flex-direction: row; align-items: flex-start; text-align: left; gap: .9rem; padding: 0 0 1.4rem; position: relative; }
  .step:last-child { padding-bottom: 0; }
  .step-dot { margin: 0; flex: none; }
  .step:not(:last-child)::before { content: ""; position: absolute; left: calc(var(--dot) / 2 - 2px); top: var(--dot); bottom: 0; width: 4px; background: var(--rule); }
  .step:not(:last-child)::after { content: ""; position: absolute; left: calc(var(--dot) / 2 - 2px); top: var(--dot); bottom: 0; width: 4px; background: var(--gold); transform: scaleY(0); transform-origin: top; transition: transform .45s ease; }
  .track.is-run .step.reached:not(.current)::after { transform: scaleY(1); transition-delay: calc(var(--i) * .3s); }
  .track.is-run .step.reached .step-dot { transition-delay: calc(var(--i) * .3s); }
  .step-label, .step-date { display: block; }
  .step-text { display: flex; flex-direction: column; }
  .journey-note { text-align: left; }
  .detail, .kv > div { grid-template-columns: 1fr; gap: .15rem; }
  .amounts { grid-template-columns: 1fr 1fr; }
  .file-status { width: 100%; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .nav a, .case-link { transition: background-color .12s ease; }
}
