:root {
  --ground:#F5F7FA; --surface:#FFFFFF; --surface-2:#EDF2F8; --surface-3:#E4EBF3;
  --ink:#10243D; --ink-2:#44586F; --ink-3:#6B7C90;
  --line:#DDE5EE; --line-2:#C4D0DE;
  --accent:#0072CE; --accent-2:#005BA8; --accent-soft:#F0F7FD; --accent-ink:#001F4D;
  --navy:#10243D;
  --good:#1C7A55; --good-soft:#E3F2EC;
  --warn:#8A5A00; --warn-soft:#FCF1DC;
  --alert:#B3441C; --alert-soft:#FFF2EC;
  --muted-soft:#EDF1F6;
  --mine:#E8F3FD; --theirs:#F3F5F8;
  --shadow:0 1px 2px rgba(16,36,61,.05), 0 8px 24px -14px rgba(16,36,61,.20);
  --radius:12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground:#0B1220; --surface:#121B2B; --surface-2:#1A2537; --surface-3:#243247;
    --ink:#E6EDF6; --ink-2:#A8B7C9; --ink-3:#8496AC;
    --line:#263347; --line-2:#35455C;
    --accent:#4BA6ED; --accent-2:#77C0F5; --accent-soft:#12243A; --accent-ink:#A9D4F7;
    --navy:#7FC2F7;
    --good:#5FBF95; --good-soft:#12301F;
    --warn:#E0B15C; --warn-soft:#2E2412;
    --alert:#E88C63; --alert-soft:#331C12;
    --muted-soft:#1A2537;
    --mine:#12304D; --theirs:#1A2537;
    --shadow:0 1px 2px rgba(0,0,0,.3), 0 8px 24px -14px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ground); color: var(--ink);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.hide { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- top bar ---------- */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top-in { max-width: 1240px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 18px; }
.logo { height: 30px; display: block; }
@media (prefers-color-scheme: dark) { .logo-light { display: none; } }
@media (prefers-color-scheme: light) { .logo-dark { display: none; } }
.brandline { display: flex; flex-direction: column; line-height: 1.15; }
.brandline b { font-size: 15px; }
.brandline span { font-size: 12px; color: var(--ink-3); }
.nav { display: flex; gap: 4px; margin-left: 12px; flex: 1; }
.nav button {
  background: none; border: 0; padding: 8px 14px; border-radius: 8px; color: var(--ink-2); font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.nav button:hover { background: var(--surface-2); }
.nav button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.who { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 10px; }
.linkbtn { background: none; border: 0; color: var(--accent); padding: 4px 6px; font-size: 13px; text-decoration: underline; }
.badge { background: var(--alert); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; min-width: 18px; padding: 1px 6px; text-align: center; line-height: 16px; }
.staffbar { background: var(--navy); color: #fff; font-size: 13px; padding: 7px 20px; text-align: center; }
@media (prefers-color-scheme: dark) { .staffbar { color: #07121F; } }
.staffbar a { color: inherit; }

/* ---------- page ---------- */
.page { max-width: 1240px; margin: 0 auto; padding: 24px 20px 60px; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.pagehead h1 { font-size: 26px; }
.asof { font-size: 13px; color: var(--ink-3); }
.notice { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 28px; line-height: 1.1; letter-spacing: -.02em; }
.stat span { font-size: 13px; color: var(--ink-2); }
.stat.hot b { color: var(--good); }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 7px 16px; border-radius: 8px; font-weight: 600; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
input[type=search], input[type=text], input[type=email], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 9px; padding: 8px 11px;
}
input[type=search] { min-width: 220px; flex: 1; max-width: 340px; }

.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 18px; align-items: start; }
@media (max-width: 960px) {
  .split { grid-template-columns: 1fr; }
  .split.has-detail .listcol { display: none; }
  .split:not(.has-detail) .detailcol { display: none; }
}
.listcol { display: flex; flex-direction: column; gap: 18px; }
.group h3 { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 8px 2px; }
.rows { display: flex; flex-direction: column; gap: 8px; }
.row {
  text-align: left; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; box-shadow: var(--shadow);
}
.row:hover { border-color: var(--line-2); }
.row[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.row .nm { font-weight: 600; }
.row .sub { font-size: 13px; color: var(--ink-2); grid-column: 1; }
.row .when { font-size: 13px; color: var(--ink-2); grid-column: 1; }
.row .end { grid-column: 2; grid-row: 1 / span 3; display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 6px; }
.empty { background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--ink-2); }

.pill { display: inline-block; border-radius: 999px; font-size: 12px; font-weight: 700; padding: 2px 10px; white-space: nowrap; }
.pill.active, .pill.active_unapproved { background: var(--good-soft); color: var(--good); }
.pill.pending, .pill.approved { background: var(--accent-soft); color: var(--accent); }
.pill.wrapup { background: var(--warn-soft); color: var(--warn); }
.pill.ended, .pill.cancelled { background: var(--muted-soft); color: var(--ink-2); }

/* ---------- detail ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.detail { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 76px; }
.dhead { padding: 18px 20px; }
.dhead .back { display: none; margin-bottom: 8px; }
@media (max-width: 960px) { .dhead .back { display: inline-block; } .detail { position: static; } }
.dhead h2 { font-size: 22px; margin-bottom: 4px; }
.dhead .meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--ink-2); font-size: 14px; }
.bar { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin: 14px 0 4px; }
.bar i { display: block; height: 100%; background: var(--good); border-radius: 999px; }
.barnote { font-size: 13px; color: var(--ink-2); display: flex; justify-content: space-between; }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; border-top: 1px solid var(--line); }
.facts div { padding: 12px 20px; border-bottom: 1px solid var(--line); }
.facts div:nth-child(odd) { border-right: 1px solid var(--line); }
.facts dt { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.facts dd { margin: 2px 0 0; font-weight: 600; }
.facts { margin: 0; }
.block { padding: 16px 20px; }
.block h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); margin-bottom: 6px; }
.block p { margin: 0; white-space: pre-line; }
.btn { display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 9px; padding: 9px 16px; font-weight: 600; text-decoration: none; }
.btn:hover { background: var(--accent-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.ghost:hover { background: var(--surface-3); }
.btn.danger { background: var(--alert); }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; }
.chat-head { padding: 14px 20px; border-bottom: 1px solid var(--line); }
.chat-head h3 { font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--ink); margin: 0; }
.chat-head p { margin: 2px 0 0; font-size: 13px; color: var(--ink-2); }
.msgs { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; max-height: 420px; min-height: 120px; overflow-y: auto; }
.msg { max-width: 88%; padding: 9px 13px; border-radius: 14px; background: var(--theirs); align-self: flex-start; }
.msg.mine { background: var(--mine); align-self: flex-end; }
.msg .by { font-size: 12px; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.msg .tag { background: var(--accent); color: #fff; font-size: 10px; padding: 0 6px; border-radius: 4px; letter-spacing: .05em; text-transform: uppercase; }
.msg .txt { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.msg .at { font-size: 11px; color: var(--ink-3); margin-top: 3px; display: flex; gap: 10px; }
.msg.fresh { box-shadow: 0 0 0 2px var(--accent); }
.nomsgs { color: var(--ink-3); text-align: center; padding: 22px 10px; font-size: 14px; }
.composer { border-top: 1px solid var(--line); padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.composer textarea { width: 100%; min-height: 64px; resize: vertical; }
.composer .foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.err { color: var(--alert); font-size: 13px; }

/* ---------- sign in / admin ---------- */
.center { max-width: 440px; margin: 9vh auto; padding: 0 20px; }
.center .card { padding: 28px; }
.center h1 { font-size: 24px; margin: 14px 0 6px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 14px 0; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.ok { background: var(--good-soft); color: var(--good); padding: 10px 12px; border-radius: 9px; margin-top: 12px; font-size: 14px; }
.bad { background: var(--alert-soft); color: var(--alert); padding: 10px 12px; border-radius: 9px; margin-top: 12px; font-size: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.tools { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.tile { text-align: left; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.tile:hover { border-color: var(--accent); }
.tile b { font-size: 17px; }
.stack > * + * { margin-top: 14px; }

/* ---------- status progress ---------- */
.steps { list-style: none; margin: 0; padding: 0; }
.step { display: grid; grid-template-columns: 22px 1fr; gap: 12px; position: relative; padding-bottom: 14px; }
.step:last-child { padding-bottom: 0; }
.step::before { content: ""; position: absolute; left: 10px; top: 22px; bottom: 0; width: 2px; background: var(--line-2); }
.step:last-child::before { display: none; }
.step .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-2); background: var(--surface);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; z-index: 1; }
.step.complete .dot { background: var(--good); border-color: var(--good); }
.step.complete::before { background: var(--good); }
.step.in_progress .dot { border-color: var(--accent); background: var(--accent-soft); }
.step.waiting .dot { border-color: var(--warn); background: var(--warn-soft); }
.step .sl { font-weight: 600; line-height: 1.3; }
.step .sd { font-size: 13px; color: var(--ink-3); }
.step .sm { font-size: 13px; color: var(--ink-2); }
.step.complete .sm { color: var(--good); }
.step.in_progress .sm { color: var(--accent); }
.step.waiting .sm { color: var(--warn); }

/* ---------- the four tiles are buttons ---------- */
button.stat { text-align: left; cursor: pointer; font: inherit; color: inherit; }
button.stat:hover { border-color: var(--accent); }
button.stat[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); background: var(--accent-soft); }
.facts dd a { font-weight: 600; }

/* Status Progress pill on each leave in the list */
.pill.prog { background: var(--surface); color: var(--ink-2); border: 1px solid var(--line-2); font-weight: 600; }
.pill.prog.alldone { background: var(--good-soft); color: var(--good); border-color: transparent; }

/* ---------- @ mentions ---------- */
.boxwrap { position: relative; }
.mentions { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); z-index: 30; max-height: 260px; overflow-y: auto; }
.mentions .mi { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.mentions .mi.on, .mentions .mi:hover { background: var(--accent-soft); }
.mentions .mn { font-weight: 600; }
.mentions .ml { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.mentions .mi.needs .mn { color: var(--ink-3); font-weight: 400; }
.mentions .mi.needs .ml { color: var(--warn); }
.mention { background: var(--accent-soft); color: var(--accent); font-weight: 600; border-radius: 4px; padding: 0 3px; }
.msg.mine .mention { background: rgba(255,255,255,.55); }
