/* Project Portal – concrete, hoarding green and hi-vis */
:root {
  /* HMSP site palette: black, gold, paper */
  --paper: #fafaf8;
  --surface: #ffffff;
  --ink: #0b0b0d;
  --ink-2: #55565a;
  --line: #e2e0d9;
  --green: #17171a;
  --green-2: #8a6d14;
  --green-soft: #f6efd6;
  --hivis: #d4af37;
  --hivis-soft: #fbf3d9;
  --red: #a32d2d;
  --red-soft: #fdecec;
  --blue-soft: #eceae4;
  --display: "Space Grotesk", -apple-system, "Segoe UI", sans-serif;
  --body: "Inter", -apple-system, "Segoe UI", sans-serif;
  --r: 8px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.55 var(--body); }
a { color: var(--green-2); text-underline-offset: 2px; }
a:hover { color: var(--green); }
:focus-visible { outline: 3px solid var(--hivis); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0 0 .5em; }
h1 { font-size: 2rem; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 .75em; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.num, .r { text-align: right; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* top bar */
.topbar { background: var(--green); color: #fff; }
.topbar-in { display: flex; align-items: center; gap: 28px; min-height: 60px; flex-wrap: wrap; }
.brand { font-family: var(--display); font-stretch: 80%; font-weight: 800; font-size: 1.2rem; color: #fff; text-decoration: none; padding-left: 14px; border-left: 5px solid var(--hivis); }
.brand:hover { color: #fff; }
.mainnav { display: flex; gap: 4px; flex: 1; }
.mainnav a { color: #d6e4dd; text-decoration: none; padding: 18px 12px 15px; border-bottom: 3px solid transparent; font-weight: 500; }
.mainnav a:hover { color: #fff; }
.mainnav a.on { color: #fff; border-bottom-color: var(--hivis); }
.me { display: flex; gap: 12px; align-items: center; font-size: .9rem; }
.me a { color: #fff; }
.me .role { color: #a9c3b7; }
.me .signout { color: #d6e4dd; }

main.wrap { padding-top: 28px; padding-bottom: 48px; }
.foot { color: var(--ink-2); font-size: .8rem; padding-bottom: 28px; }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.pagehead h1 { margin: 0; }
.crumbs { font-size: .85rem; color: var(--ink-2); margin-bottom: 4px; }
.crumbs a { color: var(--ink-2); }

/* buttons & forms */
.btn { display: inline-block; background: var(--green); color: #fff; border: 1px solid var(--green); border-radius: var(--r); padding: 9px 16px; font: 600 .92rem var(--body); cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { background: var(--green-2); color: #fff; }
.btn.ghost { background: transparent; color: var(--green); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--green); background: var(--green-soft); }
.btn.sm { padding: 5px 10px; font-size: .82rem; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--green-2); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.danger { color: var(--red) !important; }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 12px; color: var(--ink); }
label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: 400 .95rem var(--body); color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: var(--r); }
input[type=checkbox] { width: auto; margin: 3px 0 0; }
input[type=file] { padding: 6px; background: var(--paper); }
input:focus, select:focus, textarea:focus { border-color: var(--green-2); outline: 2px solid var(--green-soft); }
.row input, .row select, .toolbar select, .toolbar input { margin-top: 0; width: auto; }
textarea { resize: vertical; }

/* layout blocks */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; margin-bottom: 20px; }
.panel > h2:first-child { margin-bottom: 14px; }
.panel-after { margin: -8px 0 20px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.grid2.wide-left { grid-template-columns: minmax(0, 1fr) 340px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid2.tight, .grid3.tight { gap: 12px; }
.sticky { position: sticky; top: 16px; }
.form-narrow { max-width: 760px; }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r); padding: 36px 28px; text-align: center; margin-bottom: 20px; }
.empty h2 { margin-bottom: 6px; }
.empty p { color: var(--ink-2); max-width: 52ch; margin: 0 auto 12px; }

.flash { padding: 11px 14px; border-radius: var(--r); margin-bottom: 16px; background: var(--green-soft); border-left: 4px solid var(--green-2); overflow-wrap: anywhere; }
.flash.err { background: var(--red-soft); border-left-color: var(--red); }
.flash.info { background: var(--hivis-soft); border-left-color: var(--hivis); }

/* badges & tags */
.badge, .tag { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #eceeea; color: var(--ink-2); white-space: nowrap; vertical-align: middle; }
.b-in_progress, .b-active, .b-approved { background: var(--hivis-soft); color: #6b5200; }
.b-complete, .b-completed, .b-paid { background: var(--green-soft); color: var(--green); }
.b-submitted { background: var(--blue-soft); color: #274a6e; }
.b-rejected, .b-overdue, .tag.late { background: var(--red-soft); color: var(--red); }
.b-on_hold { background: #f1e6d8; color: #7a4b12; }
.tag.team { background: #ebe7f3; color: #4b3a78; }
.tag.client { background: var(--blue-soft); color: #274a6e; }
.tag.outgoing { background: var(--green-soft); color: var(--green); }

/* progress */
.bar { display: inline-block; width: 100%; max-width: 180px; height: 8px; background: #e4e7e2; border-radius: 99px; overflow: hidden; vertical-align: middle; }
.bar > span { display: block; height: 100%; background: var(--hivis); }
.stage.complete .bar > span { background: #6fae8f; }

/* project header + programme strip (the one bold element) */
.phead { margin-bottom: 24px; }
.phead-top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.phead h1 { font-size: 2.4rem; margin-bottom: 2px; }
.phead-meta { display: flex; gap: 10px; align-items: center; }
.programme { margin: 20px 0 0; background: var(--ink); color: #fff; border-radius: var(--r); padding: 16px 18px 14px; }
.programme-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 12px; }
.programme .pct { font-family: var(--display); font-stretch: 75%; font-size: 2.2rem; font-weight: 800; line-height: 1; color: var(--hivis); }
.programme-head span { color: #c9d2d0; }
.strip { list-style: none; margin: 0; padding: 0; display: flex; gap: 3px; }
.seg { flex: 1 1 0; min-width: 0; position: relative; }
.seg .fill { display: block; height: 14px; background: var(--hivis); box-shadow: inset 0 0 0 999px transparent; }
.seg { background: linear-gradient(#3a474d, #3a474d) top / 100% 14px no-repeat; }
.seg.complete .fill { background: #6fae8f; }
.seg-label { display: block; font-size: .72rem; line-height: 1.25; color: #c9d2d0; padding-top: 6px; padding-right: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg.in_progress .seg-label { color: #fff; font-weight: 600; white-space: normal; }
.seg:first-child .fill, .seg:first-child { border-radius: 3px 0 0 3px; }
.seg:last-child .fill, .seg:last-child { border-radius: 0 3px 3px 0; }

.tabs { display: flex; gap: 2px; margin-top: 18px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 10px 14px 9px; text-decoration: none; color: var(--ink-2); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); border-bottom-color: var(--green); }

/* stats */
.stats { display: flex; flex-wrap: wrap; gap: 0; margin-bottom: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.stats > div { flex: 1 1 160px; padding: 14px 18px; border-right: 1px solid var(--line); }
.stats > div:last-child { border-right: 0; }
.stat { display: block; font-family: var(--display); font-stretch: 85%; font-weight: 700; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.stats .muted { font-size: .82rem; }
.stats .warn .stat { color: var(--red); }

/* dashboard cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; margin-bottom: 28px; }
.pcard { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--green); border-radius: var(--r); padding: 16px; text-decoration: none; color: var(--ink); }
.pcard:hover { border-color: var(--green-2); color: var(--ink); }
.pcard strong { font-family: var(--display); font-stretch: 85%; font-size: 1.2rem; }
.pcard-code { font-size: .8rem; color: var(--ink-2); }
.pcard .bar { max-width: none; margin-top: 8px; }
.pcard-foot { display: flex; justify-content: space-between; font-size: .85rem; color: var(--ink-2); }

/* tables */
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-size: .8rem; color: var(--ink-2); font-weight: 600; background: #f8f9f7; }
tbody tr:last-child td { border-bottom: 1px solid var(--line); }
table.money td:not(:first-child), table.money th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cat-row th, .cat-row td { background: #f8f9f7; font-weight: 700; }
tfoot th, tfoot td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; }
td.neg { color: var(--red); }
tr.inactive td { opacity: .55; }
div.actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.w-bar { width: 200px; }

/* stages list */
.stages { list-style: none; margin: 0; padding: 0; }
.stage { border-bottom: 1px solid var(--line); padding: 10px 0; }
.stage:last-child { border-bottom: 0; }
.stage-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) 140px 110px; gap: 12px; align-items: center; }
.stage-n { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: .8rem; font-weight: 700; color: var(--ink-2); }
.stage.in_progress .stage-n { border-color: var(--hivis); background: var(--hivis); color: var(--ink); }
.stage.complete .stage-n { border-color: var(--green-2); background: var(--green-2); color: #fff; }
.stage-main strong { display: block; }
.stage .badge { justify-self: end; }
.stage-edit { margin: 6px 0 0 42px; }
.stage-edit summary { cursor: pointer; color: var(--green-2); font-size: .85rem; }
.inline-form { display: grid; grid-template-columns: 2fr 1.3fr .8fr 1.2fr 1.2fr auto; gap: 8px; align-items: end; margin: 10px 0; }
.inline-form label { margin: 0; font-size: .75rem; }
.add-stage { margin-top: 14px; }
.add-stage input { flex: 1; }

/* feed */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 1fr; gap: 1px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .88rem; }
.feed li:last-child { border-bottom: 0; }
.feed time { color: var(--ink-2); font-size: .78rem; }
.wide-left > .panel:first-child .feed li { grid-template-columns: 130px 1fr; gap: 12px; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 7px 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: 0; }
ul.plain .num { float: right; }

/* toolbar & chips */
.toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar p { margin: 0; max-width: 60ch; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.toolbar .chips { margin-bottom: 0; }
.chips a { padding: 5px 11px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); text-decoration: none; color: var(--ink); font-size: .85rem; }
.chips a span { color: var(--ink-2); margin-left: 3px; }
.chips a.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chips a.on span { color: #c9d2d0; }
.seg-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg-toggle a { padding: 7px 12px; text-decoration: none; color: var(--ink-2); background: var(--surface); font-size: .88rem; }
.seg-toggle a.on { background: var(--ink); color: #fff; }

/* documents */
.doclist { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.doclist > li { display: flex; justify-content: space-between; gap: 16px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.doclist > li:last-child { border-bottom: 0; }
.doc-main { min-width: 0; }
.doc-title { font-weight: 600; font-size: 1rem; }
.doc-main p { margin: 6px 0 0; }
.doc-actions { display: flex; gap: 6px; align-items: flex-start; flex-shrink: 0; }

/* popovers built on <details> */
.pop { position: relative; }
.pop > summary { list-style: none; cursor: pointer; }
.pop > summary::-webkit-details-marker { display: none; }
.pop-body { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 320px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: 0 10px 30px rgba(30, 42, 47, .16); }
td .pop-body { right: auto; left: 0; }
.pop-body form { margin-bottom: 12px; display: grid; gap: 8px; }
.pop-body form:last-child { margin-bottom: 0; }
.pop-body h3 { margin: 4px 0 2px; font-size: .9rem; }
.pop-body label { margin: 0; }
.pop-body input, .pop-body select, .pop-body textarea { margin-top: 2px; }

/* updates */
.update { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; margin-bottom: 16px; position: relative; }
.update header p { margin-bottom: 10px; }
.attach-img { display: block; max-width: 100%; max-height: 420px; border-radius: var(--r); margin: 12px 0 4px; border: 1px solid var(--line); }
.replies { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.reply { padding: 8px 12px; background: #f8f9f7; border-radius: var(--r); margin-bottom: 8px; font-size: .92rem; }
.reply.from-client { background: var(--blue-soft); }
.reply-form { display: flex; gap: 8px; align-items: flex-start; }
.reply-form textarea { margin: 0; min-height: 38px; }
.update .del { position: absolute; top: 16px; right: 18px; }

/* auth */
body.bare { background: var(--green); }
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side { padding: 8vh 7vw; color: #fff; display: flex; flex-direction: column; justify-content: flex-end; border-right: 8px solid var(--hivis); }
.auth-brand { font-family: var(--display); font-stretch: 75%; font-weight: 800; font-size: clamp(2.4rem, 5vw, 4.2rem); line-height: .95; margin-bottom: 18px; }
.auth-lede { color: #d6e4dd; font-size: 1.05rem; max-width: 40ch; }
.auth-form { background: var(--paper); padding: 8vh 6vw; display: flex; flex-direction: column; justify-content: center; }
.auth-form > * { max-width: 380px; width: 100%; }
.auth-form .btn { margin: 6px 0 16px; }
body.bare .foot { display: none; }


/* HMSP billing pairs: supplier invoice → HMSP invoice */
.billing { list-style: none; margin: 0; padding: 0; }
.bill { display: grid; grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1.15fr); gap: 0; align-items: stretch; margin-bottom: 14px; }
.bill-src, .bill-hmsp { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; min-width: 0; }
.bill-hmsp { border-left: 4px solid var(--green); border-radius: 0 var(--r) var(--r) 0; }
.bill-hmsp.is-draft { border-left-color: var(--hivis); background: #fffdf5; }
.bill-hmsp.is-empty, .bill-src.is-empty { border-style: dashed; border-left-width: 1px; border-radius: var(--r); background: transparent; }
.bill-arrow { display: grid; place-items: center; color: var(--ink-2); font-size: 1.1rem; }
.bill-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.bill p { margin: 4px 0; }
.calc { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; font-variant-numeric: tabular-nums; font-size: .9rem; margin: 6px 0; }
.calc strong { margin-left: auto; font-size: 1.05rem; }
.bill .row { margin-top: 8px; gap: 8px; }
.bill .row form { margin: 0; }
.bill-hmsp.is-empty form label { margin-bottom: 8px; }
.b-draft { background: var(--hivis-soft); color: #6b5200; border: 1px dashed #c99a00; }
fieldset.billto { border: 1px solid var(--line); border-radius: var(--r); padding: 4px 12px 2px; margin: 4px 0 14px; background: var(--paper); }
fieldset.billto legend { padding: 0 4px; }
fieldset.billto legend label { margin: 0; font-weight: 600; }
.preview { min-height: 1.2em; color: var(--green) !important; font-weight: 600; }
details.panel > summary { cursor: pointer; }
details.panel form { margin-top: 12px; }
@media (max-width: 760px) { .bill { grid-template-columns: 1fr; } .bill-arrow { transform: rotate(90deg); height: 22px; } .bill-hmsp { border-radius: var(--r); } }

@media (max-width: 960px) {
  .grid2, .grid2.wide-left, .auth { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .auth-side { border-right: 0; border-bottom: 8px solid var(--hivis); min-height: 34vh; }
  .inline-form { grid-template-columns: 1fr 1fr; }
  .stage-row { grid-template-columns: 30px minmax(0, 1fr) 100px; }
  .stage-row .badge { display: none; }
  .seg-label, .seg.in_progress .seg-label { display: none; }
}
@media (max-width: 600px) {
  .wrap { padding: 0 14px; }
  .topbar-in { gap: 0 16px; padding-top: 10px; }
  .brand { font-size: 1.05rem; }
  .me { width: 100%; justify-content: flex-end; padding-bottom: 8px; margin-top: -6px; }
  .mainnav { flex: 0 0 100%; order: 3; }
  .phead h1 { font-size: 1.8rem; }
  .grid3 { grid-template-columns: 1fr; }
  .doclist > li { flex-direction: column; }
  .feed li { grid-template-columns: 1fr; gap: 2px; }
  .me .role { display: none; }
  .mainnav a { padding: 12px 8px; }
  .pop-body { width: min(320px, 86vw); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* merged into the HMSP site */
.brand { display: flex; align-items: center; gap: 10px; border-left: 0; padding-left: 0; font-stretch: normal; }
.brand img { height: 26px; width: auto; }
.brand span { color: var(--hivis); font-family: var(--display); font-weight: 600; font-size: 1rem; }
.topbar { border-bottom: 2px solid var(--hivis); }
.btn { border-radius: 100px; }
.btn:hover { background: var(--hivis); border-color: var(--hivis); color: var(--ink); }
.btn.ghost:hover { background: var(--hivis-soft); color: var(--ink); }
.programme { background: var(--green); }
.seg.complete .fill, .stage.complete .bar > span { background: #b8962f; }
.stage.complete .stage-n { background: var(--ink); border-color: var(--ink); color: var(--hivis); }
.stage.in_progress .stage-n { background: var(--hivis); border-color: var(--hivis); }
.pcard { border-top-color: var(--hivis); }
.tabs a.on { border-bottom-color: var(--hivis); }
body.bare { background: var(--ink); }
.auth-side { border-right-color: var(--hivis); }
.auth-logo { height: 84px; width: auto; margin-bottom: 26px; display: block; }
.auth-brand { font-stretch: normal; color: var(--hivis); }
.auth-lede a, .team-link a { color: var(--green-2); }
.team-link { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--ink-2); }
.bill-hmsp { border-left-color: var(--ink); }
.bill-hmsp.is-draft { border-left-color: var(--hivis); background: #fffcf2; }
.b-in_progress, .b-active, .b-approved, .b-draft { background: var(--hivis-soft); color: #6b5200; }
.b-complete, .b-completed, .b-paid { background: #e8efe9; color: #2e5b3a; }
@media (max-width: 600px) { .brand span { display: none; } }
