/* MacroEpsilon prototype: one hand-written stylesheet. No external files.
   Design: matched to macroepsilon.com (measured 10 Nov 2026). Every rule here
   is recorded in docs/design-system.md. Add no colour, font or component
   outside it. Fonts and the logo are local files in static/fonts and static/img. */

/* ---------- Fonts (SIL Open Font License, see static/fonts/*-OFL.txt) ---------- */
@font-face {
  font-family: "Raleway"; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url("fonts/raleway-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Raleway"; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url("fonts/raleway-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Source Sans Pro"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("fonts/source-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Source Sans Pro"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("fonts/source-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ---------- */
:root {
  /* Colour: measured on macroepsilon.com */
  --black: #020202;        /* header, footer, primary buttons, strong rules */
  --orange: #EF4925;       /* the one accent: lines, borders, fills; never body-size text */
  --white: #FFFFFF;        /* every content surface; text on black */
  --text: #000000;         /* body text and headings */
  --grey-dark: #545454;    /* table headers, labels, secondary text */
  --grey-mid: #838383;     /* hints, footer text, not started */
  --grey-light: #CECECE;   /* input borders; header user text */
  --grey-line: #E6E6E6;    /* table row lines, card borders */
  --menu-current: #AAAAAA; /* text of the current navigation item */
  /* State colours: the app's own, for states only */
  --done: #2E7D4F;
  --hold: #8A5A00;
  --error: #A3271F;
  --done-tint: #EAF3ED;
  --hold-tint: #FBF3DF;
  --error-tint: #FAEAE8;
  /* Type */
  --heading: Raleway, "Segoe UI", system-ui, sans-serif;
  --body: "Source Sans Pro", "Segoe UI", system-ui, sans-serif;
  /* Line, shape, space */
  --line: 1px solid var(--grey-line);
  --strong: 2px solid var(--black);
  --tap: 44px;
  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 32px; --s5: 40px; --s6: 48px;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; border-radius: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--white); color: var(--text);
  font-family: var(--body); font-size: 16px; font-weight: 400; line-height: 1.7;
  font-variant-numeric: tabular-nums;
}
a {
  color: var(--text); text-decoration: underline; text-decoration-color: var(--orange);
  text-decoration-thickness: 1px; text-underline-offset: 3px;
}
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { font-family: var(--heading); color: var(--text); line-height: 1.3; }
h1 {
  font-weight: 700; font-size: 1.5rem; text-transform: uppercase; letter-spacing: .5px;
  margin: 0 0 var(--s3);
}
h1::after {
  content: ""; display: block; width: 48px; height: 3px; background: var(--orange); margin-top: 12px;
}
h2 { font-weight: 300; font-size: 1.5rem; text-transform: uppercase; margin: var(--s5) 0 var(--s2); }
h3 { font-weight: 700; font-size: 1.0625rem; margin: 0; }
p { margin: 0 0 var(--s2); }
b, strong { font-weight: 600; }
.muted { color: var(--grey-dark); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.inline { display: inline; margin: 0; }

/* Focus: every focusable element */
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.site-header :focus-visible { outline-color: var(--white); }

/* ---------- Header: one black bar ---------- */
.site-header {
  display: flex; align-items: center; gap: 0 var(--s3); flex-wrap: wrap;
  background: var(--black); color: var(--white); min-height: 72px; padding: 0 var(--s4);
}
.topbar { display: flex; align-items: center; gap: var(--s2); min-height: 72px; }
.brand { display: flex; align-items: center; text-decoration: none; }
.brand-logo { display: block; height: 44px; width: auto; }
.demo-label {
  font-family: var(--heading); font-size: .75rem; font-weight: 700; letter-spacing: .5px; line-height: 1.4;
  color: var(--hold); background: var(--hold-tint); border: 1px solid var(--hold); padding: 2px var(--s1);
  white-space: nowrap;
}
.mainnav { display: flex; margin-left: auto; align-self: stretch; }
.mainnav a {
  display: flex; align-items: center; min-height: 72px; padding: 0 12px;
  font-family: var(--heading); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--white); text-decoration: none; white-space: nowrap;
  border-top: 3px solid transparent; border-bottom: 3px solid transparent;
}
.mainnav a:hover { border-bottom-color: var(--orange); }
.mainnav a.on { color: var(--menu-current); border-bottom-color: var(--orange); }
.who {
  display: flex; align-items: center; gap: 4px 12px; color: var(--grey-light);
  font-size: .875rem; line-height: 1.3; min-height: 72px;
}
.topbar + .who { margin-left: auto; } /* roles without navigation */
.who-name { font-weight: 600; }
.link-button {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--s2);
  font-family: var(--heading); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--white); background: transparent; border: 1px solid var(--white); cursor: pointer;
}
.link-button:hover { border-color: var(--orange); }

/* Sign in: the logo larger and centred */
.signin-page .site-header { justify-content: center; padding-top: var(--s2); padding-bottom: var(--s2); }
.signin-page .topbar { flex-direction: column; gap: var(--s1); }
.signin-page .brand-logo { height: 56px; }

/* ---------- Page ---------- */
.page { flex: 1 0 auto; width: 100%; max-width: 1100px; margin: 0 auto; padding: var(--s5) var(--s4) var(--s6); }
.crumbs { margin: 0 0 var(--s1); font-size: .875rem; color: var(--grey-dark); }

/* ---------- Footer: one black band ---------- */
.site-footer { background: var(--black); padding: var(--s3) var(--s2); text-align: center; }
.site-footer p {
  margin: 0; font-family: var(--body); font-size: 14px; text-transform: uppercase; letter-spacing: 2px;
  color: var(--grey-mid);
}

/* ---------- Cards and notices ---------- */
.card { background: var(--white); border: var(--line); padding: var(--s3); }
/* Where a heading already groups the content, white space does the work */
form.card, .filters.card, .facts.card, .stages .stage.card, .narrow.card { border: 0; padding: 0; }
.notice { max-width: 640px; margin: 0; }
.notice p:last-child { margin-bottom: 0; }
.narrow { max-width: 420px; margin: 0 auto; }
.signin-sheet .title-block { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); margin: 0; }

/* ---------- Page title and project facts (title_block macro) ---------- */
.title-block { margin: 0 0 var(--s3); }
.tb-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; }
.tb-title { flex: 1 1 auto; min-width: 0; margin: 0 0 var(--s1); }
.tb-title .badge { vertical-align: middle; }
.tb-action { flex: 0 0 auto; display: flex; align-items: center; gap: var(--s1); }
.tb-cells, dl.facts {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2) var(--s3);
  margin: var(--s2) 0 0; padding: var(--s2) 0; border-top: var(--line); border-bottom: var(--line);
}
.tb-cell { min-width: 0; }
.tb-cell.full { grid-column: 1 / -1; }
.tb-label, dl.facts dt {
  display: block; margin: 0 0 2px; font-family: var(--heading); font-weight: 700; font-size: 13px;
  text-transform: uppercase; letter-spacing: .5px; color: var(--grey-dark); line-height: 1.5;
}
.tb-value, dl.facts dd { margin: 0; font-weight: 600; color: var(--text); line-height: 1.5; overflow-wrap: anywhere; }
.tb-cell.full .tb-value { font-weight: 400; }
.tb-firm { font-family: var(--heading); font-weight: 700; }

/* ---------- Messages ---------- */
.flash {
  padding: 12px var(--s2); margin: 0 0 var(--s2); background: var(--white); line-height: 1.5;
  border: var(--line); border-left: 4px solid var(--black);
}
.flash-success { border-left-color: var(--done); }
.flash-error { border-left-color: var(--error); }
.flash-info { border-left-color: var(--black); }

/* ---------- Buttons ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap);
  padding: 0 var(--s3); font-family: var(--heading); font-weight: 700; font-size: 13px; line-height: 1.2;
  text-transform: uppercase; letter-spacing: .5px; text-decoration: none; white-space: nowrap; cursor: pointer;
  color: var(--text); background: var(--white); border: 1px solid var(--black);
}
.button:hover { border-color: var(--orange); }
.button.primary { background: var(--black); border-color: var(--black); color: var(--white); }
.button.primary:hover { background: var(--orange); border-color: var(--orange); color: var(--white); }
.button.danger { background: var(--white); border-color: var(--error); color: var(--error); }
.button.danger:hover { background: var(--error-tint); border-color: var(--error); }
.button.small { padding: 0 var(--s2); }
.button.wide { width: 100%; }

/* Big action buttons (Restricted user's home, PROTO-02) */
.big-actions { display: flex; flex-direction: column; gap: var(--s2); }
.big-action {
  display: flex; align-items: center; justify-content: flex-start; width: 100%; min-height: 72px;
  padding: var(--s2) var(--s3); font-family: var(--heading); font-weight: 700; font-size: 1.125rem;
  text-transform: uppercase; letter-spacing: .5px; text-align: left; text-decoration: none; cursor: pointer;
  color: var(--white); background: var(--black); border: 0; border-left: 4px solid var(--orange);
}
.big-action:hover { background: var(--orange); border-left-color: var(--black); }

/* ---------- Forms ---------- */
.form { max-width: 640px; }
.field { margin-bottom: var(--s2); display: flex; flex-direction: column; line-height: 1.5; }
.field > label, .filters label {
  font-family: var(--heading); font-weight: 700; font-size: 13px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--grey-dark); margin-bottom: 6px;
}
.field-check > label {
  font-family: var(--body); font-weight: 400; font-size: 16px; text-transform: none; letter-spacing: 0;
  color: var(--text); display: flex; gap: var(--s1); align-items: center; min-height: var(--tap); cursor: pointer;
}
.field-check input { width: 24px; height: 24px; min-height: 0; accent-color: var(--black); }
.req { color: var(--grey-mid); }
input, select, textarea {
  font-family: var(--body); font-size: 16px; line-height: 1.5; color: var(--text); background: var(--white);
  padding: 9px 12px; border: 1px solid var(--grey-light); min-height: var(--tap); width: 100%; max-width: 100%;
}
input:hover, select:hover, textarea:hover { border-color: var(--black); }
input:focus, select:focus, textarea:focus { border-color: var(--orange); }
textarea { min-height: 88px; }
input:not([type=checkbox]):not([type=radio]), select { height: var(--tap); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--error); }
.field-error { color: var(--error); margin: 4px 0 0; font-size: .875rem; }
.hint { color: var(--grey-mid); margin: 4px 0 0; font-size: .875rem; line-height: 1.5; }
.form > .hint { margin: -8px 0 var(--s2); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s2); }
.form-actions { display: flex; gap: var(--s1); flex-wrap: wrap; margin-top: var(--s1); }
.danger-zone { margin-top: var(--s4); padding-top: var(--s3); border-top: var(--line); max-width: 640px; }

/* ---------- Filters ---------- */
.filters {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 var(--s2);
  align-items: end; margin: 0 0 var(--s2); padding: var(--s2) 0 0;
  border-top: var(--line); border-bottom: var(--line);
}
.filters .form-actions { margin-bottom: var(--s2); flex-wrap: nowrap; }
.filters .form-actions .button { flex: 1; padding: 0 var(--s2); }
.filters-inline { display: flex; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s3); }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--black); background: var(--white); }
.seg a {
  display: flex; align-items: center; min-height: 42px; padding: 0 var(--s2);
  font-family: var(--heading); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text); text-decoration: none;
}
.seg a + a { border-left: 1px solid var(--black); }
.seg a:hover { text-decoration: underline; text-decoration-color: var(--orange); text-decoration-thickness: 2px; }
.seg a.on { background: var(--black); color: var(--white); }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; line-height: 1.5; }
th, td { text-align: left; padding: 12px; border-bottom: var(--line); vertical-align: top; }
th {
  font-family: var(--heading); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--grey-dark); border-bottom: var(--strong); white-space: nowrap; vertical-align: bottom;
}
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.actions { text-align: right; white-space: nowrap; }
.row-off td { color: var(--grey-dark); }
table.compact th, table.compact td { padding: 8px; font-size: .9375rem; }
table.compact th { font-size: 12px; }
table.compact th:first-child, table.compact td:first-child { padding-left: 0; }
.issues .table-wrap { margin-bottom: var(--s2); }
.changes { margin: 0; padding-left: var(--s2); font-size: .875rem; }
.changes li { word-break: break-word; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; font-family: var(--heading); font-weight: 700; font-size: 11px; line-height: 1.4;
  text-transform: uppercase; letter-spacing: .5px; padding: 2px 6px; white-space: nowrap; vertical-align: middle;
  border: 1px solid var(--grey-light); background: var(--white); color: var(--grey-mid);
}
.badge-not_started { border-color: var(--grey-light); background: var(--white); color: var(--grey-mid); }
.badge-in_progress { border: 2px solid var(--orange); padding: 1px 5px; background: var(--white); color: var(--text); }
.badge-done { border-color: var(--done); background: var(--done-tint); color: var(--done); }
.badge-issue-open { border-color: var(--error); background: var(--error-tint); color: var(--error); }
.badge-issue-closed { border-color: var(--grey-light); background: var(--white); color: var(--grey-mid); }
.badge-act-create { border-color: var(--done); background: var(--done-tint); color: var(--done); }
.badge-act-change { border-color: var(--black); background: var(--white); color: var(--text); }
.badge-act-delete { border-color: var(--error); background: var(--error-tint); color: var(--error); }
.badge-warn { border-color: var(--hold); background: var(--hold-tint); color: var(--hold); }

/* ---------- Stage strip: six joined squares ---------- */
.stage-strip { display: inline-flex; gap: 0; }
.dot {
  display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 28px;
  padding: 0 4px; font-family: var(--heading); font-weight: 700; font-size: 11px; letter-spacing: .5px; line-height: 1;
  border: 1px solid var(--grey-light); background: var(--white); color: var(--grey-mid); position: relative;
}
.stage-strip .dot + .dot { margin-left: -1px; }
.dot-not_started { border: 1px solid var(--grey-light); background: var(--white); color: var(--grey-mid); }
.dot-in_progress { border: 2px solid var(--orange); background: var(--white); color: var(--text); z-index: 2; }
.dot-done { border: 1px solid var(--black); background: var(--black); color: var(--white); z-index: 1; }
.legend { font-size: .875rem; margin-top: var(--s2); }
.legend .dot { vertical-align: middle; }

/* ---------- Stages on the project page: rows divided by lines ---------- */
.stages { list-style: none; padding: 0; margin: 0; border-top: var(--line); }
.stages .stage.card { min-width: 0; padding: var(--s3) 0; border-bottom: var(--line); }
.stage-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s1); }
.stage-head p { margin: 4px 0 0; }
.stage-no { display: inline-block; width: 32px; color: var(--grey-mid); }
.stage-head p, .stages .issues { padding-left: 32px; }
.status-form { display: flex; gap: var(--s1); align-items: center; }
.status-form select { width: auto; }
.pager { display: flex; gap: var(--s1); margin-top: var(--s2); }

/* ---------- Phone width ---------- */
@media (max-width: 640px) {
  /* Header: two black rows */
  .site-header { padding: 0 12px; gap: 0 var(--s1); min-height: 0; }
  .topbar { min-height: 60px; gap: var(--s1); flex: 0 1 auto; min-width: 0; }
  .brand-logo { height: 36px; }
  .who {
    margin-left: auto; min-height: 60px; display: grid; grid-template-columns: auto auto;
    column-gap: 10px; align-content: center; justify-items: end; font-size: .8125rem;
  }
  .who-name { grid-column: 1; grid-row: 1; }
  .who-role { grid-column: 1; grid-row: 2; }
  .who form { grid-column: 2; grid-row: 1 / span 2; }
  .link-button { padding: 0 12px; }
  .mainnav {
    order: 3; flex: 0 0 100%; margin: 0 -12px; padding: 0 4px; max-width: none; width: calc(100% + 24px);
    overflow-x: auto; -webkit-overflow-scrolling: touch; border-top: 1px solid var(--grey-dark);
  }
  .mainnav a { min-height: 48px; padding: 0 10px; }
  .signin-page .site-header { padding: var(--s2) 12px; }
  .signin-page .topbar { min-height: 0; }
  .signin-page .brand-logo { height: 56px; }

  .page { padding: var(--s5) 12px var(--s4); }
  .grid-2 { grid-template-columns: 1fr; }
  .tb-cells, dl.facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px var(--s2); }
  .page-head .button { width: 100%; }
  .tb-action { flex: 1 1 100%; }
  .tb-action .button { flex: 1; }
  .form-actions .button { flex: 1; }
  .status-form { width: 100%; }
  .status-form select { flex: 1; }
  .stage-head p, .stages .issues { padding-left: 0; }
  .stage-no { width: 24px; }
  /* Issue lists: one block per issue instead of a wide row */
  table.stack-on-phone thead { display: none; }
  table.stack-on-phone, table.stack-on-phone tbody, table.stack-on-phone tr, table.stack-on-phone td { display: block; width: 100%; }
  table.stack-on-phone tr { border-bottom: var(--line); padding: var(--s1) 0; }
  table.stack-on-phone td { border: none; padding: 2px 0; text-align: left; white-space: normal; }
  table.stack-on-phone td[data-label]::before {
    content: attr(data-label) ": "; color: var(--grey-dark); font-family: var(--heading); font-weight: 700;
    font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
  }
  table.stack-on-phone td[data-label="Issue"]::before { content: none; }
  table.stack-on-phone td:empty { display: none; }
}
@media (max-width: 399px) {
  .tb-cells, dl.facts { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Stage 2 additions (documented in docs/design-system.md section 7) ---------- */
.attachments { list-style: none; margin: 4px 0 0; padding: 0; font-size: .875rem; }
.attachments li { margin: 0; }
tr.total-row td { border-top: var(--strong); font-weight: 600; }
tr.group-row td { font-family: var(--heading); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--grey-dark); background: var(--white); border-bottom: var(--strong); padding-top: var(--s2); }
.due-group { margin-top: var(--s4); }
.due-group h2 { margin-top: 0; }
.breakdown { margin-top: var(--s2); }
.breakdown h3 { margin-bottom: 4px; }
.home-links { display: flex; flex-wrap: wrap; gap: var(--s1); margin: 0 0 var(--s3); }
.checks td:first-child { width: 44px; padding-right: 0; }
.checks input[type=checkbox] { width: 24px; height: 24px; min-height: 0; accent-color: var(--black); }
.inline-form { display: inline; margin: 0; }
.inline-form .button { min-height: 36px; }
.est-grid input { min-width: 90px; }
.restricted-home .big-actions { margin: 0 0 var(--s4); }
.held-line { font-family: var(--heading); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; font-size: 13px; color: var(--grey-dark); margin: 0 0 var(--s1); }

/* Printable client invoice: the page alone, black on white */
.print-sheet { max-width: 800px; }
.print-only { display: none; }
@media print {
  .site-header, .site-footer, .flash, .no-print, .crumbs { display: none !important; }
  .print-only { display: block; }
  .page { max-width: none; padding: 0; }
  body { font-size: 12pt; }
  a { text-decoration: none; color: var(--text); }
  h1::after { display: none; }
  .print-sheet table { page-break-inside: auto; }
  .print-sheet tr { page-break-inside: avoid; }
}
@media (max-width: 640px) {
  .home-links .button { flex: 1 1 45%; }
}

/* Stage 3: twelve menu items do not fit beside the logo and the user below 1500px: the menu takes its own black row */
@media (max-width: 1500px) and (min-width: 641px) {
  .site-header { padding-bottom: 0; }
  .topbar + .mainnav { order: 3; flex: 0 0 100%; margin: 0 calc(-1 * var(--s4)); width: calc(100% + 2 * var(--s4)); padding: 0 var(--s4); border-top: 1px solid var(--grey-dark); }
  .mainnav ~ .who { order: 2; margin-left: auto; }
  .mainnav a { min-height: 52px; }
}

/* Phone: filter forms stack in one column so that no button touches the screen edge */
@media (max-width: 640px) {
  .filters { grid-template-columns: minmax(0, 1fr); }
  .filters .form-actions { flex-wrap: wrap; }
}
