/* ============================================================
   Groundsworth — prototype v2 design system
   Static navigation prototype. One stylesheet, every page.
   Shell: dark forest sidebar · light content · optional right
   assistant rail · per-job stage rail.
   ============================================================ */

:root {
  --forest-900: #0f231b;
  --forest-800: #143025;
  --forest-850: #122b20;
  --forest-700: #1c4433;
  --forest-600: #23573f;
  --brand: #1e6f50;
  --brand-soft: #e3f1ea;
  --ink: #1c2320;
  --ink-soft: #4c5a53;
  --ink-faint: #7d8a83;
  --line: #e0e6e2;
  --paper: #ffffff;
  --wash: #f4f6f5;
  --wash-deep: #eceff0;
  --amber: #9a6b0a;
  --amber-bg: #fdf6e3;
  --amber-line: #ecd9a4;
  --blue: #2456a6;
  --blue-bg: #e9f0fb;
  --purple: #6b46a8;
  --purple-bg: #f0eaf9;
  --red: #a63232;
  --red-bg: #faeaea;
  --green: #1e7a46;
  --green-bg: #e6f4ec;
  --gray-bg: #eef0ef;
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 230px;
  --rail-w: 316px;
  --shadow: 0 1px 2px rgba(15, 35, 27, .06), 0 4px 14px rgba(15, 35, 27, .05);
  --shadow-pop: 0 6px 28px rgba(15, 35, 27, .18);
  --mono: "Cascadia Code", "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: "Segoe UI Variable Text", "Segoe UI", -apple-system, "Inter", system-ui, sans-serif;
  color: var(--ink);
  background: var(--wash);
  min-height: 100vh;
  display: flex;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; letter-spacing: -.015em; }
h2 { font-size: 1.1rem; letter-spacing: -.01em; }
h3 { font-size: .95rem; }
small, .dim { color: var(--ink-faint); }
code, .mono { font-family: var(--mono); font-size: .85em; }
kbd {
  font-family: var(--mono); font-size: .72rem; background: var(--wash-deep);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px;
}

/* ---------- app sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: linear-gradient(175deg, #12291f, #0e1f18);
  color: #cfe0d7;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 12px; font-weight: 650; font-size: 1.02rem; color: #fff;
  letter-spacing: -.01em;
}
.monogram {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(140deg, #2e8a63, #1e6f50);
  color: #fff; font-weight: 700; font-size: .8rem;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.company-switch {
  margin: 0 12px 10px; padding: 8px 10px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-sm); font-size: .8rem; color: #e8f1ec;
  display: flex; justify-content: space-between; align-items: center; cursor: pointer;
}
.company-switch .chev { opacity: .55; font-size: .7rem; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 4px 12px; }
.navgroup { margin-bottom: 14px; }
.navgroup h6 {
  font-size: .62rem; text-transform: uppercase; letter-spacing: .14em;
  color: #6f857b; padding: 8px 10px 4px; font-weight: 600;
}
.navgroup a {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: 7px;
  color: #cfe0d7; font-size: .88rem; text-decoration: none;
}
.navgroup a .ico { width: 17px; text-align: center; opacity: .8; font-size: .85rem; }
.navgroup a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.navgroup a.active { background: rgba(46,138,99,.28); color: #fff; font-weight: 600; }
.navgroup a .count {
  margin-left: auto; background: #d98f2b; color: #fff; font-size: .66rem;
  font-weight: 700; border-radius: 99px; padding: 1px 7px;
}
.sidebar-foot {
  border-top: 1px solid rgba(255,255,255,.08); padding: 12px 16px;
  display: flex; align-items: center; gap: 10px; font-size: .8rem;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: #2e8a63; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; flex: none;
}
.sidebar-foot .who b { display: block; color: #fff; font-weight: 600; font-size: .8rem; }
.sidebar-foot .who span { color: #8ba297; font-size: .68rem; }

/* ---------- sidebar collapse (toggle injected by rail.js; persists per user) ----------
   `.sidebar.compact` is the same icon-rail look as the ≤1100px breakpoint below,
   but user-invokable at any width. Collapsed → click the monogram to reopen. */
.navtoggle {
  position: absolute; top: 15px; right: 8px; z-index: 3;
  width: 22px; height: 22px; border-radius: 6px; padding: 0;
  border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06);
  color: #cfe0d7; font-size: .8rem; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.navtoggle:hover { background: rgba(255,255,255,.14); color: #fff; }

.sidebar.compact { width: 64px; min-width: 64px; }
.sidebar.compact .brand { font-size: 0; gap: 0; justify-content: center; padding: 14px 8px 20px; position: relative; cursor: pointer; }
.sidebar.compact .brand::after { content: "»"; position: absolute; bottom: 3px; left: 0; right: 0; text-align: center; font-size: .8rem; color: #6f857b; }
.sidebar.compact .company-switch { display: none; }
.sidebar.compact nav { padding: 4px 8px; }
.sidebar.compact .navgroup { margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar.compact .navgroup:last-child { border-bottom: 0; }
.sidebar.compact .navgroup h6 { display: none; }
.sidebar.compact .navgroup a { position: relative; justify-content: center; padding: 10px 0; font-size: 0; gap: 0; }
.sidebar.compact .navgroup a .ico { font-size: 1rem; opacity: .9; }
.sidebar.compact .navgroup a .count { position: absolute; top: 3px; right: 4px; margin: 0; font-size: .56rem; padding: 0 4px; }
.sidebar.compact .sidebar-foot { justify-content: center; padding: 10px 6px; }
.sidebar.compact .sidebar-foot .who { display: none; }
.sidebar.compact .navtoggle { display: none; }

/* ---------- main column ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 52px; background: var(--paper); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 20px;
  position: sticky; top: 0; z-index: 40;
}
.crumbs { font-size: .84rem; color: var(--ink-faint); white-space: nowrap; }
.crumbs a { color: var(--ink-soft); }
.crumbs b { color: var(--ink); font-weight: 600; }
.searchbox {
  flex: 1; max-width: 430px; margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--wash); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; font-size: .82rem; color: var(--ink-faint); cursor: text;
}
.searchbox kbd { margin-left: auto; }
.topbar .actions { display: flex; align-items: center; gap: 8px; }

/* ---------- content ---------- */
.content { padding: 22px 26px 60px; max-width: 1180px; width: 100%; margin: 0 auto; }
.content.wide { max-width: none; }
.content.fill { padding: 0; max-width: none; }
.pagehead { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.pagehead .sub { color: var(--ink-faint); font-size: .86rem; margin-top: 4px; }
.pagehead .spacer { flex: 1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: .84rem; font-weight: 600;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: 8px; padding: 7px 13px; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--wash); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #1a5f45; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-soft); }
.btn.sm { padding: 4px 9px; font-size: .76rem; border-radius: 6px; }
.btn.assistant { border-color: #cdd9ea; background: var(--blue-bg); color: var(--blue); }

/* ---------- cards & tiles ---------- */
.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card .cardhead {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
}
.card .cardhead h2, .card .cardhead h3 { flex: none; }
.card .cardhead .spacer { flex: 1; }
.card .cardbody { padding: 15px 16px; }
.card .cardfoot {
  padding: 10px 16px; border-top: 1px solid var(--line);
  font-size: .8rem; color: var(--ink-faint);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.tile {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 15px; box-shadow: var(--shadow);
}
.tile .k { font-size: .72rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.tile .v { font-size: 1.5rem; font-weight: 650; letter-spacing: -.02em; margin-top: 3px; }
.tile .d { font-size: .74rem; color: var(--ink-faint); margin-top: 3px; }
.tile.alert { border-color: var(--amber-line); background: var(--amber-bg); }

/* ---------- pills & badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .68rem; font-weight: 650; border-radius: 99px; padding: 2px 9px;
  background: var(--gray-bg); color: var(--ink-soft); white-space: nowrap;
}
.pill.type { background: var(--brand-soft); color: var(--brand); }
.pill.addon { background: var(--purple-bg); color: var(--purple); }
.pill.jur { background: var(--blue-bg); color: var(--blue); }
.pill.connector { background: #fdeedd; color: #a05e15; }
.pill.verified { background: var(--green-bg); color: var(--green); }
.pill.candidate { background: var(--amber-bg); color: var(--amber); }
.pill.ai { background: var(--blue-bg); color: var(--blue); }
.pill.user { background: var(--gray-bg); color: var(--ink-soft); }
.pill.locked { background: var(--amber-bg); color: var(--amber); }
/* job lifecycle */
.pill.requested { background: var(--gray-bg); color: var(--ink-soft); }
.pill.in-progress { background: var(--blue-bg); color: var(--blue); }
.pill.in-review { background: var(--purple-bg); color: var(--purple); }
.pill.on-hold { background: var(--amber-bg); color: var(--amber); }
.pill.delivered { background: var(--green-bg); color: var(--green); }
.pill.cancelled { background: var(--red-bg); color: var(--red); }
.pill.archived { background: var(--wash-deep); color: var(--ink-faint); }

/* ---------- filter chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--paper); border-radius: 99px;
  font-size: .76rem; padding: 4px 11px; color: var(--ink-soft); cursor: pointer;
}
.chip b { color: var(--ink); font-weight: 600; }
.chip .x { color: var(--ink-faint); font-weight: 700; }
.chip.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }

/* ---------- tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: .84rem; }
.tbl th {
  text-align: left; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-faint); font-weight: 650; padding: 9px 12px;
  border-bottom: 1px solid var(--line); background: var(--wash);
  position: sticky; top: 0;
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:hover td { background: #f7faf8; }
.tbl td .sub { display: block; font-size: .72rem; color: var(--ink-faint); margin-top: 2px; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- in-page tabs (horizontal) ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a {
  padding: 8px 14px; font-size: .86rem; font-weight: 600; color: var(--ink-soft);
  border-bottom: 2px solid transparent; text-decoration: none;
}
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs a .count {
  background: #d98f2b; color: #fff; font-size: .64rem; font-weight: 700;
  border-radius: 99px; padding: 1px 6px; margin-left: 5px;
}

/* ============================================================
   JOB WORKSPACE — header + stage rail
   ============================================================ */
.jobhead {
  background: var(--paper); border-bottom: 1px solid var(--line); padding: 14px 26px 0;
}
.jobhead .row1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.jobhead h1 { font-size: 1.2rem; }
.jobhead .meta {
  display: flex; gap: 18px; flex-wrap: wrap; font-size: .78rem; color: var(--ink-faint);
  margin: 8px 0 12px;
}
.jobhead .meta b { color: var(--ink); font-weight: 600; }
.readiness { display: flex; align-items: center; gap: 10px; margin-left: auto; min-width: 240px; }
.readiness .bar {
  flex: 1; height: 8px; border-radius: 99px; background: var(--wash-deep); overflow: hidden;
}
.readiness .bar i { display: block; height: 100%; background: linear-gradient(90deg, #2e8a63, #1e6f50); }
.readiness .lbl { font-size: .74rem; color: var(--ink-soft); white-space: nowrap; }
.readiness .lbl b { color: var(--brand); }

.jobshell { flex: 1; display: flex; min-height: 0; }
.stage-rail {
  width: 218px; min-width: 218px; border-right: 1px solid var(--line);
  background: var(--paper); padding: 14px 10px; overflow-y: auto;
}
.stage {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  border-radius: 7px; color: var(--ink-soft); font-size: .86rem; font-weight: 600;
  text-decoration: none;
}
.stage:hover { background: var(--wash); text-decoration: none; }
.stage.active { background: var(--brand-soft); color: var(--brand); }
.stage .n {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  border: 1.5px solid currentColor; font-size: .68rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.stage.done .n { background: var(--brand); border-color: var(--brand); color: #fff; }
.stage .state { margin-left: auto; font-size: .64rem; color: var(--ink-faint); font-weight: 600; }
.stage-sub { margin: 2px 0 8px 26px; border-left: 1px solid var(--line); padding-left: 10px; }
.stage-sub a {
  display: flex; align-items: center; gap: 6px;
  font-size: .76rem; color: var(--ink-soft); padding: 4px 6px; border-radius: 5px;
  text-decoration: none;
}
.stage-sub a:hover { background: var(--wash); }
.stage-sub a.on { color: var(--brand); font-weight: 600; }
.stage-sub .packtag {
  margin-left: auto; font-size: .58rem; font-weight: 700; letter-spacing: .05em;
  border-radius: 4px; padding: 1px 5px;
}
.packtag.addon { background: var(--purple-bg); color: var(--purple); }
.packtag.jur { background: var(--blue-bg); color: var(--blue); }
.packtag.type { background: var(--brand-soft); color: var(--brand); }
.stage-content { flex: 1; min-width: 0; overflow-y: auto; padding: 20px 24px 60px; }

/* ---------- assistant rail ---------- */
.assistant-rail {
  width: var(--rail-w); min-width: var(--rail-w);
  border-left: 1px solid var(--line); background: var(--paper);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.assistant-rail .ahead {
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}
.assistant-rail .ahead b { font-size: .86rem; }
.assistant-rail .ribbon {
  font-size: .6rem; font-weight: 700; letter-spacing: .1em; color: var(--amber);
  background: var(--amber-bg); border: 1px solid var(--amber-line);
  border-radius: 4px; padding: 2px 6px; margin-left: auto;
}
.assistant-rail .alog { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { font-size: .8rem; line-height: 1.45; border-radius: 10px; padding: 9px 12px; max-width: 92%; }
.msg.bot { background: var(--wash); border: 1px solid var(--line); align-self: flex-start; }
.msg.me { background: var(--brand-soft); align-self: flex-end; }
.msg .toolpill {
  display: inline-block; font-size: .64rem; font-weight: 650; color: var(--blue);
  background: var(--blue-bg); border-radius: 5px; padding: 1px 7px; margin: 2px 2px 2px 0;
}
.changecard {
  border: 1px solid #cdd9ea; background: #f6f9fd; border-radius: 8px; padding: 8px 10px;
  font-size: .74rem;
}
.changecard b { color: var(--blue); }
.changecard .acts { margin-top: 6px; display: flex; gap: 6px; }
.assistant-rail .abox { border-top: 1px solid var(--line); padding: 12px 14px; }
.assistant-rail .abox .fake-input {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px;
  font-size: .8rem; color: var(--ink-faint); background: var(--wash);
}

/* ---------- appraiser-only / locked ---------- */
.lockbox {
  border: 1.5px solid var(--amber-line); background: var(--amber-bg);
  border-radius: var(--radius); padding: 14px 16px;
}
.lockbox .lockhead {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  font-size: .7rem; font-weight: 700; letter-spacing: .1em; color: var(--amber);
}

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(15, 35, 27, .45); z-index: 90;
  display: none; align-items: flex-start; justify-content: center; padding: 6vh 20px;
}
.modal-back.open { display: flex; }
.modal {
  background: var(--paper); border-radius: 14px; box-shadow: var(--shadow-pop);
  width: 640px; max-width: 100%; max-height: 86vh; overflow-y: auto;
}
.modal .mhead { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal .mbody { padding: 18px 20px; }
.modal .mfoot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- forms ---------- */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: .74rem; font-weight: 650; color: var(--ink-soft); margin-bottom: 4px; }
.field input[type=text], .field select, .field textarea {
  width: 100%; font: inherit; font-size: .84rem; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--paper); color: var(--ink);
}
.checkrow { display: flex; align-items: center; gap: 8px; font-size: .82rem; padding: 5px 0; }

/* ---------- misc ---------- */
.hint {
  border-left: 3px solid var(--brand); background: var(--brand-soft);
  border-radius: 0 8px 8px 0; padding: 10px 14px; font-size: .8rem; color: #24523f;
}
.empty {
  text-align: center; color: var(--ink-faint); font-size: .84rem; padding: 34px 20px;
  border: 1.5px dashed var(--line); border-radius: var(--radius); background: var(--paper);
}
.feed { list-style: none; }
.feed li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--wash-deep); font-size: .8rem; }
.feed li:last-child { border-bottom: 0; }
.feed .t { color: var(--ink-faint); font-size: .72rem; white-space: nowrap; min-width: 66px; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.proto-foot {
  margin-top: 40px; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: .74rem; color: var(--ink-faint);
}
.proto-foot a { color: var(--ink-soft); }

/* ---------- map mock (Explorer & mini-maps) ---------- */
.mapmock {
  position: relative; overflow: hidden; border-radius: var(--radius);
  background:
    repeating-linear-gradient(0deg, transparent 0 46px, rgba(30,111,80,.07) 46px 47px),
    repeating-linear-gradient(90deg, transparent 0 46px, rgba(30,111,80,.07) 46px 47px),
    linear-gradient(140deg, #eef4ee, #e2ecdf 55%, #dbe7e3);
}
.mapmock.fill { border-radius: 0; }
.mappin {
  position: absolute; transform: translate(-50%, -100%);
  background: var(--brand); color: #fff; font-size: .64rem; font-weight: 700;
  border-radius: 99px; padding: 2px 8px; box-shadow: var(--shadow);
}
.mappin.subject { background: #b7431f; }
.mappin.candidate { background: #d98f2b; }
.parcel-line {
  position: absolute; border: 1.5px solid rgba(30,111,80,.5); border-radius: 3px;
}

/* ============================================================
   RESPONSIVE — honest collapse (desktop-first)
   ≥1101px  full shell: sidebar · main · assistant rail
   ≤1100px  tablet: assistant rail hides · sidebar → icon rail
   ≤900px   job stage rail → horizontal stepper
   ≤760px   phone: sidebar → bottom tab bar · tables scroll ·
            search hidden · content padded above the bar
   The IA never changes — only its rendering.
   ============================================================ */

/* ---------- tablet ≤1100px ---------- */
@media (max-width: 1100px) {
  .assistant-rail { display: none; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .grid3 { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }

  /* sidebar → icon rail; labels return on hover-less small screens via title attrs */
  .sidebar { width: 64px; min-width: 64px; }
  .brand { font-size: 0; gap: 0; justify-content: center; padding: 14px 8px 10px; }
  .company-switch { display: none; }
  .sidebar nav { padding: 4px 8px; }
  .navgroup { margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,.08); }
  .navgroup:last-child { border-bottom: 0; }
  .navgroup h6 { display: none; }
  .navgroup a { position: relative; justify-content: center; padding: 10px 0; font-size: 0; gap: 0; }
  .navgroup a .ico { font-size: 1rem; opacity: .9; }
  .navgroup a .count { position: absolute; top: 3px; right: 4px; margin: 0; font-size: .56rem; padding: 0 4px; }
  .sidebar-foot { justify-content: center; padding: 10px 6px; }
  .sidebar-foot .who { display: none; }
}

/* ---------- job workspace ≤900px: stage rail → horizontal stepper ---------- */
@media (max-width: 900px) {
  .jobshell { flex-direction: column; }
  .stage-rail {
    width: auto; min-width: 0; display: flex; align-items: center; gap: 2px;
    overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line);
    padding: 8px 12px; -webkit-overflow-scrolling: touch;
  }
  .stage { flex: none; padding: 6px 10px; white-space: nowrap; }
  .stage .state { margin-left: 6px; }
  .stage-sub, .stage-rail .railnote { display: none; }
  .jobhead { padding: 12px 14px 0; }
  .jobhead .readiness { flex: 1 1 100%; min-width: 0; margin-left: 0; }
  .stage-content { padding: 16px 14px 40px; }
}

/* ============================================================
   WORKSPACE SHELL v2 — the studio pattern (decided 2026-07-24)
   Full-width topbar · compact one-row job strip · slim expandable
   stage strip with sub-nav · contextual right rail with tabs
   (assistant · page panels) · dropdown menus · toasts.
   First adopted by job-report-studio.html; stage pages follow.
   On normally-scrolling pages make .railcol sticky below the
   topbar (top: 52px; height: calc(100vh - 52px)) — the fixed-
   height shell is only needed when the canvas owns its scroll.
   Behavior wiring lives in assets/rail.js.
   ============================================================ */

/* compact job strip — one row; the workspace gets the vertical space */
.jobstrip {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--paper); border-bottom: 1px solid var(--line); padding: 7px 16px;
}
.jobstrip b { font-size: .9rem; }
.jobstrip .readiness { min-width: 170px; margin-left: auto; }
.jobstrip .ref { font-size: .72rem; color: var(--ink-faint); }

/* slim expandable stage strip */
.stagestrip {
  width: 46px; min-width: 46px; border-right: 1px solid var(--line);
  background: var(--paper); display: flex; flex-direction: column;
  align-items: center; gap: 6px; padding: 10px 0;
}
.stagestrip .sexp {
  border: 0; background: none; color: var(--ink-faint); font-size: .82rem;
  font-weight: 700; cursor: pointer; padding: 2px 8px; border-radius: 5px; margin-bottom: 2px;
}
.stagestrip .sexp:hover { background: var(--wash); }
.stagestrip .st { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink-soft); border-radius: 7px; }
.stagestrip .st .n {
  width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--ink-faint);
  color: var(--ink-faint); font-size: .7rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.stagestrip .st.done .n { background: var(--brand); border-color: var(--brand); color: #fff; }
.stagestrip .st.active .n { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.stagestrip .sname { display: none; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.stagestrip .st.active .sname { color: var(--brand); }
.stagestrip .lbl {
  font-size: .56rem; color: var(--ink-faint); writing-mode: vertical-rl; margin-top: 8px;
  letter-spacing: .08em; text-transform: uppercase; font-weight: 700;
}
.stagestrip .ssub, .stagestrip .srailnote { display: none; }
.stagestrip.open { width: 196px; min-width: 196px; align-items: stretch; padding: 10px; overflow-y: auto; }
.stagestrip.open .sexp { align-self: flex-end; }
.stagestrip.open .st { padding: 5px 7px; }
.stagestrip.open .st:hover { background: var(--wash); }
.stagestrip.open .sname { display: inline; }
.stagestrip.open .lbl { display: none; }
.stagestrip.open .ssub { display: block; margin: 1px 0 7px 20px; border-left: 1px solid var(--line); padding-left: 9px; }
.stagestrip.open .ssub a {
  display: flex; align-items: center; gap: 6px; font-size: .72rem; color: var(--ink-soft);
  padding: 3px 5px; border-radius: 5px; text-decoration: none;
}
.stagestrip.open .ssub a:hover { background: var(--wash); }
.stagestrip.open .ssub .packtag {
  margin-left: auto; font-size: .58rem; font-weight: 700; letter-spacing: .05em;
  border-radius: 4px; padding: 1px 5px;
}
.stagestrip.open .srailnote {
  display: block; font-size: .68rem; color: var(--ink-faint); margin-top: auto;
  line-height: 1.5; padding: 8px 4px 0;
}

/* contextual right rail: assistant · page panels, as tabs */
.railcol {
  width: 302px; min-width: 302px; border-left: 1px solid var(--line);
  background: var(--paper); display: flex; flex-direction: column; min-height: 0;
}
.rtabs { display: flex; border-bottom: 1px solid var(--line); }
.rtabs a {
  flex: 1; text-align: center; padding: 9px 2px; font-size: .74rem; font-weight: 650;
  color: var(--ink-soft); border-bottom: 2px solid transparent; text-decoration: none;
  white-space: nowrap; cursor: pointer;
}
.rtabs a:hover { color: var(--ink); }
.rtabs a.on { color: var(--brand); border-bottom-color: var(--brand); }
.rtabs .n {
  display: inline-flex; align-items: center; justify-content: center; min-width: 15px; height: 15px;
  border-radius: 99px; background: #d98f2b; color: #fff; font-size: .58rem; font-weight: 700;
  padding: 0 4px; margin-left: 4px; vertical-align: 1px;
}
.rbody { flex: 1; overflow-y: auto; padding: 12px; }
.rpane { display: none; }
.rpane.on { display: block; }
.railfoot { border-top: 1px solid var(--line); padding: 9px 12px; font-size: .66rem; color: var(--ink-faint); }

/* rail collapse (toggle injected by rail.js; persists per user) — a slim icon
   strip that KEEPS tab icons + badges visible; click an icon to reopen to it.
   Mirrors the stage strip's 46px, so the shell is symmetric left ↔ right. */
.rcollapse {
  flex: none; border: 0; background: none; color: var(--ink-faint);
  font-size: .82rem; font-weight: 700; cursor: pointer; padding: 4px 8px; border-radius: 5px;
}
.rcollapse:hover { background: var(--wash); color: var(--ink); }
.railcol.collapsed { width: 46px; min-width: 46px; }
.railcol.collapsed .rbody, .railcol.collapsed .railfoot { display: none; }
.railcol.collapsed .rtabs { flex-direction: column; border-bottom: 0; padding: 8px 0; gap: 5px; align-items: center; }
.railcol.collapsed .rtabs a {
  flex: none; width: 34px; height: 34px; border-bottom: 0; border-radius: 8px;
  font-size: 0; position: relative; padding: 0;
}
.railcol.collapsed .rtabs a::before { content: attr(data-icon); font-size: 1.05rem; line-height: 1; }
.railcol.collapsed .rtabs a.on { background: var(--brand-soft); color: var(--brand); }
.railcol.collapsed .rtabs a .n { position: absolute; top: -3px; right: -3px; margin: 0; }
.railcol.collapsed .rcollapse { order: -1; }

/* dropdown menu (Export ▾ etc.) — <div class="mwrap"><a data-menu>…</a><div class="menu">…</div></div> */
.mwrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); right: 0; background: var(--paper);
  border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow-pop);
  min-width: 262px; z-index: 60; display: none; padding: 5px;
}
.menu.open { display: block; }
.menu a { display: block; padding: 8px 10px; border-radius: 6px; font-size: .78rem; font-weight: 600; color: var(--ink); text-decoration: none; }
.menu a span { display: block; font-size: .66rem; font-weight: 400; color: var(--ink-faint); margin-top: 1px; }
.menu a:hover { background: var(--wash); }

/* assistant pane (inside .railcol) */
.drib {
  font-size: .58rem; font-weight: 700; letter-spacing: .1em; color: var(--amber);
  background: var(--amber-bg); border: 1px solid var(--amber-line); border-radius: 4px;
  padding: 2px 6px; display: inline-block; margin-bottom: 10px;
}
.alog2 { display: flex; flex-direction: column; gap: 10px; }
.ain {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px;
  font-size: .78rem; color: var(--ink-faint); background: var(--wash); margin-top: 12px;
}

/* toast — GW.toast(msg) in rail.js */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--forest-900); color: #fff; font-size: .76rem; padding: 9px 16px;
  border-radius: 9px; box-shadow: var(--shadow-pop); z-index: 120; opacity: 0;
  pointer-events: none; transition: opacity .18s; max-width: 70vw; text-align: center;
}
.toast.show { opacity: 1; }

@media (max-width: 1240px) { .railcol { display: none; } }

/* ≤900px: the stage strip becomes a horizontal stepper (matches the legacy rail's collapse) */
@media (max-width: 900px) {
  .jobshell > .stagestrip {
    width: auto; min-width: 0; height: auto;
    flex-direction: row; align-items: center; gap: 8px;
    border-right: 0; border-bottom: 1px solid var(--line);
    padding: 8px 12px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .jobshell > .stagestrip .sexp, .jobshell > .stagestrip .lbl,
  .jobshell > .stagestrip .ssub, .jobshell > .stagestrip .srailnote { display: none !important; }
  .jobshell > .stagestrip .sname { display: inline; }
  .jobshell > .stagestrip .st { flex: none; padding: 4px 6px; }
}

/* ---------- phone ≤760px: bottom tab bar ---------- */
@media (max-width: 760px) {
  body { flex-direction: column; }
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    height: auto; width: auto; min-width: 0;
    flex-direction: row; z-index: 80; background: #0e1f18;
    border-top: 1px solid rgba(255,255,255,.14);
  }
  .brand, .company-switch, .sidebar-foot, .navtoggle { display: none; }
  /* the phone bottom bar overrides any user collapse state */
  .sidebar.compact { width: auto; min-width: 0; }
  .sidebar nav { display: flex; flex: 1; padding: 0; overflow: visible; }
  .navgroup { display: contents; }
  .navgroup a {
    flex: 1 1 0; flex-direction: column; gap: 3px; justify-content: center;
    padding: 7px 2px 9px; font-size: .55rem; border-radius: 0;
  }
  .navgroup a .ico { font-size: 1.05rem; }
  .navgroup a .count { position: absolute; top: 2px; right: 8px; font-size: .56rem; padding: 0 4px; margin: 0; }
  .navgroup a { position: relative; }

  .main { padding-bottom: 54px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .searchbox { display: none; }
  .content { padding: 16px 14px 96px; }
  .pagehead { flex-wrap: wrap; }
  .tiles { gap: 10px; }
  .tbl { display: block; overflow-x: auto; }
  .modal-back { padding: 3vh 10px; }
  .jobhead .meta { gap: 10px; }
  .stage-content { padding-bottom: 96px; }
}
