:root {
  --ink: #16202c; --ink-2: #3b4652; --muted: #6a7480; --line: #e2e5ea; --line-2: #eef0f3;
  --bg: #f5f6f8; --card: #fff; --accent: #1d3557; --accent-2: #2b4a75; --accent-soft: #e9eef6;
  --amber: #a35f00; --amber-bg: #fff4e0; --blue: #1f5fae; --blue-bg: #e8f1fc; --red: #b4351f; --red-bg: #fdecea;
  --green: #217a45; --green-bg: #e6f5ec; --teal: #23686e; --teal-bg: #e3f2f2; --gray-bg: #eef0f3;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.5; font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent-2); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1.25rem 0 .5rem; color: var(--ink-2); }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.inline { display: inline; }

/* header */
.top { background: var(--accent); color: #fff; }
.top-inner { max-width: 1240px; margin: 0 auto; padding: 0 20px; height: 58px; display: flex; align-items: center; gap: 28px; }
.brand { color: #fff; text-decoration: none; font-weight: 650; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, #8fb3e8, #fff); display: inline-block; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { color: #d6e1f2; text-decoration: none; padding: 7px 11px; border-radius: 7px; font-size: .92rem; white-space: nowrap; }
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav a.on { background: rgba(255, 255, 255, .15); color: #fff; }
.me { display: flex; gap: 14px; align-items: center; font-size: .9rem; white-space: nowrap; }
.me a { color: #fff; text-decoration: none; }
.me .linkbtn { color: #d6e1f2; }

/* layout */
.wrap { max-width: 760px; margin: 0 auto; padding: 28px 20px 60px; }
.wrap.wide { max-width: 1240px; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.crumb { margin: 0 0 4px; font-size: .85rem; color: var(--muted); }
.crumb a { color: var(--muted); }
.lead { font-size: 1.02rem; color: var(--ink-2); }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.cols .main, .cols .side { display: grid; gap: 20px; min-width: 0; }
@media (max-width: 960px) { .cols { grid-template-columns: 1fr; } .me a { display: none; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card.narrow { max-width: 440px; margin: 40px auto; }
.cardhead { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.cardhead h2 { margin: 0; }
.stack { display: grid; gap: 16px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card.pick { text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s; }
.card.pick:hover { border-color: var(--accent-2); box-shadow: 0 4px 14px rgba(29, 53, 87, .1); }
.empty { color: var(--muted); padding: 18px 0; margin: 0; }

/* forms */
.field { display: grid; gap: 6px; }
.field > label, fieldset legend { font-weight: 600; font-size: .9rem; color: var(--ink-2); }
.field-check label { font-weight: 500; display: flex; gap: 8px; align-items: center; font-size: .95rem; }
.req { color: var(--red); margin-left: 3px; }
.help { margin: 0; font-size: .82rem; color: var(--muted); }
input:not([type=checkbox]):not([type=radio]):not([type=file]), textarea, select {
  font: inherit; color: inherit; width: 100%; padding: 9px 11px; border: 1px solid #cfd4db; border-radius: 8px; background: #fff;
}
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(43, 74, 117, .35); outline-offset: 0; border-color: var(--accent-2); }
input[disabled] { background: var(--gray-bg); color: var(--muted); }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; accent-color: var(--accent); }
input[type=file] { font: inherit; font-size: .9rem; }
textarea { resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 12px; margin: 0; }
.form-grid h2.section { margin: 8px 0 0; padding-top: 14px; border-top: 1px solid var(--line-2); font-size: 1rem; }
.form-grid h2.section:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: .92rem;
  padding: 9px 16px; border-radius: 8px; border: 1px solid #cfd4db; background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f6f7f9; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.warn { color: var(--red); border-color: #e7b5ab; }
.btn.warn:hover { background: var(--red-bg); }
.btn.danger { color: var(--red); border-color: #e7b5ab; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn:disabled { opacity: .6; cursor: default; }
.linkbtn { font: inherit; background: none; border: 0; padding: 0; color: var(--accent-2); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; font-size: inherit; }
.linkbtn:disabled { color: #b7bec7; cursor: default; text-decoration: none; }
.linkbtn.danger { color: var(--red); }

/* flash + callouts */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; border: 1px solid; }
.flash ul { margin: 6px 0 0; padding-left: 20px; }
.flash-ok { background: var(--green-bg); border-color: #b9e0c7; color: #17502f; }
.flash-error { background: var(--red-bg); border-color: #f2c4bb; color: #7b2414; }
.callout { border-radius: var(--radius); padding: 18px 22px; margin-bottom: 20px; border: 1px solid; }
.callout h2 { margin-bottom: 10px; }
.callout p:last-child { margin-bottom: 0; }
.callout-amber { background: var(--amber-bg); border-color: #f1d4a3; }
.callout-blue { background: var(--blue-bg); border-color: #bcd5f3; }
.callout-green { background: var(--green-bg); border-color: #b9e0c7; }
.callout-gray { background: var(--gray-bg); border-color: var(--line); }
.callout form { max-width: 620px; }

/* badges + chips */
.badge { display: inline-block; font-size: .78rem; font-weight: 650; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-teal { background: var(--teal-bg); color: var(--teal); }
.badge-gray { background: var(--gray-bg); color: var(--muted); }
.pagehead .badge { font-size: .85rem; padding: 6px 12px; margin-top: 4px; }
.chip { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--gray-bg); color: var(--muted); white-space: nowrap; }
.chip-green { background: var(--green-bg); color: var(--green); }
.chip-red { background: var(--red-bg); color: var(--red); }
.chip-staff { background: var(--accent-soft); color: var(--accent); }

/* stepper */
.stepper { list-style: none; display: flex; margin: 0 0 22px; padding: 0; counter-reset: s; }
.stepper li { flex: 1; position: relative; padding-top: 30px; font-size: .82rem; color: var(--muted); text-align: center; counter-increment: s; }
.stepper li::before { content: counter(s); position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 24px; height: 24px; border-radius: 50%;
  background: #fff; border: 2px solid #cfd4db; display: grid; place-items: center; font-size: .75rem; font-weight: 700; z-index: 1; line-height: 20px; }
.stepper li::after { content: ""; position: absolute; top: 11px; left: -50%; width: 100%; height: 2px; background: #d6dbe1; }
.stepper li:first-child::after { display: none; }
.stepper li.done { color: var(--green); }
.stepper li.done::before { content: "✓"; background: var(--green); border-color: var(--green); color: #fff; }
.stepper li.done::after, .stepper li.current::after { background: var(--green); }
.stepper li.current { color: var(--ink); font-weight: 650; }
.stepper li.current::before { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.stepper li.stop { color: var(--muted); font-weight: 650; }
.stepper li.stop::before { content: "×"; background: var(--muted); border-color: var(--muted); color: #fff; }
.stepper.cancelled { max-width: 320px; }

/* tables */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-size: .88rem; font-weight: 550; }
.tabs a:hover { background: #e9ecf0; }
.tabs a.on { background: var(--accent); color: #fff; }
.tabs .count { margin-left: 6px; font-size: .75rem; opacity: .75; }
.search input { width: 260px; padding: 7px 11px; }
.side .search input, .main > .search input { width: 100%; }
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table.list { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; padding: 11px 16px; border-bottom: 1px solid var(--line); background: #fafbfc; }
.list td { padding: 13px 16px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.list tr:last-child td { border-bottom: 0; }
.list tbody tr:hover { background: #fafbfd; }
.rowlink { font-weight: 600; text-decoration: none; color: var(--ink); }
.rowlink:hover { color: var(--accent-2); text-decoration: underline; }
.ref { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; margin-right: 4px; }

/* job page */
.pdf { width: 100%; height: 78vh; min-height: 520px; border: 1px solid var(--line); border-radius: 8px; background: #f0f1f3; }
.note { background: var(--gray-bg); border-radius: 8px; padding: 10px 14px; font-size: .92rem; white-space: pre-wrap; }
.kv { display: grid; grid-template-columns: minmax(130px, 34%) 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: .88rem; }
.kv dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.side .kv { grid-template-columns: 1fr; gap: 2px; margin-top: 8px; font-size: .85rem; }
.side .kv dd { margin-bottom: 6px; }
ul.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.people { list-style: none; padding: 0; margin: 0; }
.people li { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.people li:last-child { border-bottom: 0; }
.person { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; overflow-wrap: anywhere; }
.quote { margin: 6px 0 0; padding: 6px 10px; border-left: 3px solid var(--line); color: var(--ink-2); font-size: .88rem; white-space: pre-wrap; }
details { margin-top: 8px; }
details summary { cursor: pointer; font-weight: 600; color: var(--accent-2); font-size: .92rem; padding: 4px 0; }
details[open] summary { margin-bottom: 10px; }
.side details + details { border-top: 1px solid var(--line-2); padding-top: 8px; }
.earlier { border-top: 1px solid var(--line-2); padding-top: 8px; margin-top: 14px; }
.comment-form { margin-bottom: 18px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 18px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 15px; width: 10px; height: 10px; border-radius: 50%; background: #cfd4db; }
.timeline li.comment::before { background: var(--accent-2); }
.timeline li.approve::before, .timeline li.complete::before { background: var(--green); }
.timeline li.revise::before, .timeline li.cancel::before { background: var(--red); }
.tl-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: .88rem; }
.tl-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .93rem; color: var(--ink-2); }
.timeline li.comment .tl-body { background: var(--accent-soft); border-radius: 8px; padding: 8px 12px; margin-top: 4px; color: var(--ink); }
.mailbody { white-space: pre-wrap; font-size: .82rem; background: var(--gray-bg); padding: 10px; border-radius: 6px; max-width: 640px; overflow-wrap: anywhere; }

/* field builder */
.field-builder { display: grid; gap: 12px; margin-top: 8px; justify-items: start; }
.fb-row { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 10px; background: #fbfcfd; }
.fb-main { display: grid; grid-template-columns: 1fr 170px auto; gap: 12px; align-items: end; }
.fb-row label { display: grid; gap: 4px; font-size: .8rem; font-weight: 600; color: var(--muted); }
.fb-req { display: flex !important; align-items: center; gap: 6px; padding-bottom: 9px; color: var(--ink-2) !important; }
.fb-actions { display: flex; gap: 14px; font-size: .85rem; }
@media (max-width: 640px) {
  .fb-main { grid-template-columns: 1fr; }
  .top-inner { height: auto; flex-wrap: wrap; gap: 6px 14px; padding: 10px 16px; }
  .brand { font-size: .95rem; flex: 1; }
  .nav { order: 3; flex: 1 1 100%; margin: 0 -11px; }
  .pagehead { flex-wrap: wrap; }
  .search input { width: 100%; }
  .search { flex: 1 1 100%; }
}

/* approver lists */
.approver-builder { display: grid; gap: 8px; margin-top: 14px; justify-items: start; }
.ap-row { width: 100%; display: grid; grid-template-columns: 1fr 1.3fr auto auto; gap: 10px; align-items: center; }
.ap-always { display: flex; gap: 6px; align-items: center; font-size: .85rem; white-space: nowrap; }
.plainset { border: 0; padding: 0; display: grid; gap: 10px; }
.radio { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.radio input { margin-top: 4px; accent-color: var(--accent); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.approver-pick { gap: 4px; }
.pick-row { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-weight: 400; }
.pick-row:hover { background: var(--gray-bg); }
.pick-row input:disabled { opacity: .7; }
@media (max-width: 640px) { .ap-row { grid-template-columns: 1fr; } }
