:root {
  --soft: #f3f6f4; --bg: #f4f2ee; --panel: #ffffff; --ink: #1d2433; --muted: #5d6577; --line: #dcd8d0; --line2: #ebe8e2;
  --accent: #0f5c4d; --accent-ink: #ffffff; --accent-soft: #e3efe9;
  --warn: #9a5b12; --warn-soft: #fbf0dd; --bad: #a1362a; --bad-soft: #f8e4e1; --good: #1f7a4d; --good-soft: #e1f2e8;
  --info-soft: #e6ecf7; --radius: 8px; --shadow: 0 1px 2px rgba(20,24,33,.06), 0 4px 16px rgba(20,24,33,.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); }
a { color: var(--accent); }
h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 13px; margin: 14px 0 8px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.num, td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: var(--mono); font-size: 12px; }
.hide { display: none !important; }

/* top bar */
.top { position: sticky; top: 0; z-index: 20; background: #16201d; color: #e9efe9; display: flex; align-items: center; gap: 4px; padding: 0 16px; height: 48px; overflow-x: auto; }
.top .brand { font-weight: 700; margin-right: 14px; white-space: nowrap; display: flex; gap: 8px; align-items: center; }
.top .brand svg { width: 22px; height: 22px; }
.top a.nav { color: #c4cec8; text-decoration: none; padding: 6px 10px; border-radius: 6px; white-space: nowrap; font-size: 13px; }
.top a.nav:hover { background: #24302c; color: #fff; }
.top a.nav.on { background: #2d3c37; color: #fff; }
.top .badge { background: #d9822b; color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
main { max-width: 1320px; margin: 0 auto; padding: 18px 16px 90px; }

/* account menu */
.acct { position: fixed; right: 14px; bottom: 14px; z-index: 30; }
.acct > button { background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 20px; padding: 7px 14px; font: inherit; cursor: pointer; color: var(--ink); }
.acct .menu { position: absolute; right: 0; bottom: 44px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 230px; padding: 6px; }
.acct .menu .who { padding: 8px 10px; border-bottom: 1px solid var(--line2); margin-bottom: 4px; }
.acct .menu a { display: block; padding: 8px 10px; border-radius: 6px; text-decoration: none; color: var(--ink); }
.acct .menu a:hover { background: var(--bg); }

/* panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.panel.tight { padding: 10px 12px; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 10px 14px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
.split2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 1000px) { .split, .split2 { grid-template-columns: minmax(0, 1fr); } .split > .sticky { position: static; order: -1; } }
.sticky { position: sticky; top: 62px; }

/* forms */
label.f { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
label.f.flag > span::after { content: " • check"; color: var(--warn); font-weight: 600; }
label.f.flag input, label.f.flag select, label.f.flag textarea { border-color: #d9a441; background: var(--warn-soft); }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #7fb5a7; outline-offset: -1px; border-color: var(--accent); }
input[disabled], select[disabled], textarea[disabled] { background: #f7f6f3; color: #3a4150; }
input[type=checkbox], input[type=radio] { width: auto; flex: none; }
textarea { min-height: 70px; resize: vertical; }
td input, td select { padding: 4px 6px; font-size: 13px; }
td input.n { text-align: right; font-variant-numeric: tabular-nums; }
.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 13px; }

button, .btn { font: inherit; font-size: 13px; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 6px; padding: 7px 12px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover, .btn:hover { border-color: #b8b3a8; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { background: #0c4b3f; }
button.danger { color: var(--bad); border-color: #e2b9b3; }
button.good { background: var(--good); border-color: var(--good); color: #fff; font-weight: 600; }
button.ai { background: #2b2f6b; border-color: #2b2f6b; color: #fff; font-weight: 600; }
button.link { border: 0; background: none; color: var(--accent); padding: 2px 4px; }
button.icon { padding: 3px 7px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* tables */
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 7px 8px; background: #faf9f6; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid var(--line2); vertical-align: top; }
tr.click { cursor: pointer; } tr.click:hover td { background: #faf8f3; }
tr.total td { font-weight: 700; border-top: 1px solid var(--line); background: #faf9f6; }
tr.off td { opacity: .45; }
.tablewrap { overflow-x: auto; }

/* status pills */
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--line2); color: var(--muted); white-space: nowrap; }
.pill.Draft, .pill.Open { background: var(--info-soft); color: #2b4a80; }
.pill.InReview, .pill.Costing { background: var(--warn-soft); color: var(--warn); }
.pill.SubmittedtoGM { background: #efe3f6; color: #6a2f87; }
.pill.Approved, .pill.Valid, .pill.OK { background: var(--good-soft); color: var(--good); }
.pill.Superseded, .pill.Withdrawn, .pill.Closed, .pill.Lost { background: #eee; color: #777; }
.pill.Changesneeded, .pill.High { background: var(--bad-soft); color: var(--bad); }
.pill.Medium { background: var(--warn-soft); color: var(--warn); }
.pill.Low { background: var(--info-soft); color: #2b4a80; }

.note { border-radius: 6px; padding: 9px 12px; font-size: 13px; margin: 8px 0; background: var(--info-soft); }
.note.warn { background: var(--warn-soft); color: #6d4210; }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.note.good { background: var(--good-soft); color: #175c3a; }
.note.ai { background: #ecebf8; color: #2b2f6b; }

/* results panel */
.kpi { background: var(--accent); color: #fff; border-radius: var(--radius); padding: 14px 16px; }
.kpi .big { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .sub { opacity: .85; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.bars { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin: 8px 0 4px; background: var(--line2); }
.bars span { display: block; height: 100%; }
.legend { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 3px 8px; font-size: 12.5px; align-items: center; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.comp { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; background: #fff; }
.comp > .ch { display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: #faf9f6; border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; flex-wrap: wrap; }
.comp > .cb { padding: 12px; }

.thread .msg { border-bottom: 1px solid var(--line2); padding: 8px 0; }
.thread .msg b { font-size: 13px; } .thread .msg .t { white-space: pre-wrap; }
.drop { border: 2px dashed #c6c0b4; border-radius: var(--radius); padding: 26px; text-align: center; color: var(--muted); background: #fbfaf7; cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.files { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.files .fc { border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; background: #fff; font-size: 12.5px; display: flex; gap: 8px; align-items: center; }
.preview img { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 8px; }
.preview iframe { width: 100%; height: 520px; border: 1px solid var(--line); border-radius: 6px; }
.preview pre { white-space: pre-wrap; background: #faf9f6; border: 1px solid var(--line); border-radius: 6px; padding: 10px; max-height: 420px; overflow: auto; font-size: 12.5px; }
.steps { display: flex; gap: 6px; font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.steps span.on { color: var(--accent); font-weight: 700; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #1d2433; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 50; box-shadow: var(--shadow); max-width: 90vw; }
.toast.bad { background: var(--bad); }
.modal-bg { position: fixed; inset: 0; background: rgba(20,24,33,.4); z-index: 40; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 10px; padding: 18px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.flow { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; font-size: 12px; margin: 6px 0; }
.flow span { background: var(--accent-soft); color: var(--accent); border-radius: 4px; padding: 2px 7px; }
.flow em { color: var(--muted); font-style: normal; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: 100%; max-width: 380px; box-shadow: var(--shadow); }
.login h1 { display: flex; gap: 10px; align-items: center; }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }

@media (max-width: 640px) {
  .tablewrap > table { min-width: 680px; }
  .comp > .ch > input { max-width: none !important; flex: 1 1 100%; }
  .comp > .ch label.f { flex: 1 1 30%; width: auto !important; }
  main { padding: 12px 10px 90px; }
  .panel { padding: 12px; }
  .kpi .big { font-size: 24px; }
}
@media print { .top, .acct, button { display: none !important; } }
.certpick { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.chk { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink); cursor: pointer; }
.pill.cert { background: var(--good-soft); color: var(--good); }
input.calc { background: var(--soft); }
input.man { border-color: #d9a441; }
.aopbar { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; padding: 8px 10px; margin: 6px 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--soft); font-size: 13px; }
.aopbar label { display: inline-flex; gap: 6px; align-items: center; }
.aopbar select { width: auto; padding: 4px 8px; }
.photos { display: flex; flex-wrap: wrap; gap: 10px; }
.photos figure { margin: 0; position: relative; width: 140px; }
.photos img { width: 140px; height: 140px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
.photos figcaption { font-size: 11px; color: var(--muted); margin-top: 2px; }
.photos [data-hprm] { position: absolute; top: 4px; right: 4px; }
.photos.small-ph figure, .photos.small-ph img { width: 72px; height: 72px; }
input.need { border-color: var(--bad); background: var(--bad-soft); }

/* reports */
.cards4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
@media (max-width: 760px) { .cards4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.repcat { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card, #fff); min-height: 0; height: auto; white-space: normal; }
.repcat b { font-size: 26px; line-height: 1.1; }
.repcat small { font-size: 12px; font-weight: 400; }
.repcat.on { border-color: var(--accent, #2b4a80); box-shadow: 0 0 0 2px var(--accent, #2b4a80) inset; }
table.clickrows tbody tr { cursor: pointer; }
table.clickrows tbody tr:hover { background: var(--info-soft); }
.pill.Pendingcost, .pill.Notstarted { background: var(--info-soft); color: #2b4a80; }
.pill.Costingsent, .pill.Sent, .pill.ApprovednotSent, .pill.Approvednotsent { background: #efe3f6; color: #6a2f87; }
.pill.Recost { background: var(--warn-soft); color: var(--warn); }
.pill.Confirmed { background: var(--good-soft); color: var(--good); }
td.nw { white-space: nowrap; }

/* notifications & merchandiser */
.bell { position: relative; background: transparent; border: 0; font-size: 17px; padding: 4px 8px; margin-right: 4px; }
.bell .badge { position: absolute; top: -2px; right: -4px; }
.notes { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow: auto; margin-top: 10px; }
.nitem { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: inherit; text-decoration: none; }
.nitem.unread { border-color: var(--accent, #2b4a80); background: var(--info-soft); }
.nitem:hover { background: var(--info-soft); }
ol.steps2 { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; counter-reset: s; }
ol.steps2 li { counter-increment: s; padding: 5px 10px 5px 8px; border-radius: 999px; background: #eee; color: #777; font-size: 13px; }
ol.steps2 li::before { content: counter(s) " "; font-weight: 700; margin-right: 4px; }
ol.steps2 li.done { background: var(--good-soft); color: var(--good); }
ol.steps2 li.done::before { content: "✓ "; }
ol.steps2 li.now { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
dl.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--muted, #777); font-size: 13px; } dl.kv dd { margin: 0; overflow-wrap: anywhere; }
tr.hl td { background: var(--good-soft); }
.mcblock { padding: 10px 0; border-top: 1px solid var(--line2, #eee); } .mcblock:first-of-type { border-top: 0; }
.tablewrap.fit > table { min-width: 0; }
.bell .badge { position: absolute; top: -4px; right: -6px; background: var(--bad, #b3261e); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; text-align: center; }
.bell .badge.hide { display: none; }

.mcards { display: none; flex-direction: column; gap: 8px; }
.mcard { display: flex; flex-direction: column; gap: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; color: inherit; text-decoration: none; }
@media (max-width: 640px) { .mcards { display: flex; } .mtable { display: none; } }

.mailtable { overflow-x: auto; margin: 4px 0 10px; padding: 4px 2px; background: #fff; border-radius: 6px; color: #1d2433; }
.modal:has(.mailtable) { max-width: min(1000px, 96vw); }
.mailtable th, .mailtable td { text-transform: none; letter-spacing: normal; font-size: 13px; }

.pill.Lost, .pill.Missed { background: var(--bad-soft); color: var(--bad); }
.pill.Jobwork { background: #eee; color: #555; }

.mailpreview { overflow-x: auto; background: #fff; color: #1d2433; padding: 6px 4px; border-radius: 6px; }
.mailpreview th, .mailpreview td { text-transform: none; letter-spacing: normal; }
.mailpreview h3 { text-transform: none; letter-spacing: normal; }

/* yarn dyeing colours under a yarn line */
tr.dyerow td { border-top: 0; }
.dyebox { margin: 0 0 6px 18px; padding: 8px 10px; border-left: 3px solid var(--accent, #0f5c4d); background: color-mix(in srgb, var(--accent, #0f5c4d) 5%, transparent); border-radius: 0 8px 8px 0; }
.dyebox table { margin-top: 4px; width: auto; }
.dyebox th, .dyebox td { padding: 3px 6px; }
.yq { display: grid; gap: 4px; min-width: 140px; }
.yq label { display: grid; gap: 2px; }
.yq select, .yq input { padding: 4px 6px; font-size: 13px; }
