/* =============================================================================
   Proposal Builder — dynamic proposals for architecture & engineering firms
   Mockup styles. App chrome = Methodology IT brand (slate + coral).
   Proposal canvas = the *firm's* brand (accent driven by --firm var).
   ========================================================================== */

:root {
  /* MIT app chrome */
  --coral:        #DC3C34;
  --coral-soft:   rgba(220, 60, 52, 0.10);
  --coral-strong: rgba(220, 60, 52, 0.22);

  --canvas:      #F6F8FB;
  --surface:     #FFFFFF;
  --surface-alt: #F1F4F9;
  --hairline:    #EEF2F7;
  --divider:     #E2E8F0;
  --text:        #0F172A;
  --text-muted:  #475569;
  --text-subtle: #7E8A96;

  --slate-900: #171C23;
  --slate-800: #212932;
  --slate-700: #2E3843;
  --slate-600: #46525F;
  --slate-500: #5A6773;
  --slate-400: #7E8A96;
  --slate-300: #A8B2BC;
  --slate-200: #CFD5DC;
  --slate-100: #E6EAEF;
  --slate-050: #F3F5F7;

  --success: #2F9E5E;
  --warn:    #E0A93C;
  --info:    #2563EB;

  --font-display: Sora, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --ease: cubic-bezier(.2, .8, .2, 1);
  --shadow-1: 0 1px 2px rgba(15,23,42,.05), 0 2px 6px rgba(15,23,42,.05);
  --shadow-2: 0 2px 8px rgba(15,23,42,.08), 0 12px 28px rgba(15,23,42,.08);

  /* Firm accent — swapped live by the brand picker */
  --firm: #C2761A;
  --firm-dark: #96590F;
  --firm-soft: rgba(194, 118, 26, .10);
  --firm-ink: #171C23;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--canvas);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

/* ---------------------------------------------------------------- app top */
.app-top {
  height: 56px; min-width: 0;
  background: var(--slate-900);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 18px;
  border-bottom: 1px solid #000;
  position: relative;
  z-index: 60;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--coral); color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  letter-spacing: -.02em;
}
.brand .wordmark {
  font-family: var(--font-display); font-weight: 700; font-size: 16px;
  letter-spacing: -.02em; line-height: 1;
  max-width: 230px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand .byline {
  font-size: 10px; color: rgba(255,255,255,.45); letter-spacing: .04em;
  margin-top: 3px;
  max-width: 230px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-nav { display: flex; gap: 4px; margin-left: 10px; }
.app-nav button {
  background: none; border: 0; cursor: pointer; white-space: nowrap;
  color: rgba(255,255,255,.62);
  font-size: 12.5px; font-weight: 600;
  padding: 7px 12px; border-radius: 7px;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.app-nav button:hover { color: #fff; background: rgba(255,255,255,.07); }
.app-nav button.active { color: #fff; background: rgba(255,255,255,.12); }

.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.prep {
  font: 600 11px/1 var(--font-body); color: #fff;
  background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.14);
  padding: 7px 12px; border-radius: 999px; white-space: nowrap;
}
.prep b { color: var(--coral); font-weight: 700; filter: brightness(1.35); }
.demo-badge {
  font: 600 10px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
  color: var(--warn); border: 1px solid rgba(224,169,60,.4);
  background: rgba(224,169,60,.1);
  padding: 6px 9px; border-radius: 6px;
}
.firm-switch {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.10);
  border-radius: 8px; padding: 5px 8px 5px 10px;
}
.firm-switch label { font-size: 10px; color: rgba(255,255,255,.45); letter-spacing: .08em; text-transform: uppercase; }
.firm-switch input {
  background: none; border: 0; outline: 0; color: #fff;
  font-size: 12.5px; font-weight: 600; width: 190px;
}
.swatches { display: flex; gap: 4px; }
.swatch {
  width: 16px; height: 16px; border-radius: 4px; cursor: pointer;
  border: 2px solid transparent; transition: transform .12s var(--ease);
}
.swatch:hover { transform: scale(1.15); }
.swatch.on { border-color: #fff; }

/* ------------------------------------------------------------------ shell */
.app {
  display: grid;
  grid-template-columns: 372px minmax(0,1fr) 296px;
  height: calc(100vh - 56px);
}
.app.client-view { grid-template-columns: minmax(0,1fr); }
.app.client-view .builder,
.app.client-view .rail { display: none; }

.pane { overflow-y: auto; overflow-x: hidden; }
.pane::-webkit-scrollbar { width: 10px; }
.pane::-webkit-scrollbar-thumb { background: var(--slate-200); border-radius: 8px; border: 3px solid var(--canvas); }

/* --------------------------------------------------------------- builder */
.builder { background: var(--surface); border-right: 1px solid var(--divider); }
.builder-head {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; background: var(--surface); z-index: 5;
}
.builder-head h1 { font-family: var(--font-display); font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.builder-head p { font-size: 11.5px; color: var(--text-subtle); margin-top: 3px; }

details.step { border-bottom: 1px solid var(--hairline); }
details.step > summary {
  list-style: none; cursor: pointer;
  padding: 13px 18px; display: flex; align-items: center; gap: 10px;
  transition: background .12s var(--ease);
}
details.step > summary::-webkit-details-marker { display: none; }
details.step > summary:hover { background: var(--surface-alt); }
details.step[open] > summary { background: var(--surface-alt); }
.step-num {
  width: 20px; height: 20px; border-radius: 5px; flex: 0 0 auto;
  background: var(--slate-100); color: var(--slate-600);
  display: grid; place-items: center;
  font: 600 10px/1 var(--font-mono);
}
details.step[open] .step-num { background: var(--coral); color: #fff; }
.step-title { font-size: 12.5px; font-weight: 650; display: block; }
.step-sub { font-size: 11px; color: var(--text-subtle); margin-top: 1px; display: block; }
details.step > summary > span:nth-child(2) { min-width: 0; flex: 1; }
.step-chev { margin-left: auto; color: var(--slate-300); font-size: 11px; transition: transform .18s var(--ease); }
details.step[open] .step-chev { transform: rotate(90deg); }
.step-body { padding: 4px 18px 20px; }

.field { margin-top: 12px; }
.field > label,
.flabel {
  display: block; font-size: 10.5px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-subtle); margin-bottom: 5px;
}
.field input[type=text], .field input[type=number], .field input[type=date],
.field select, .field textarea {
  width: 100%; background: #fff;
  border: 1px solid var(--divider); border-radius: 7px;
  padding: 8px 10px; font-size: 13px; outline: 0;
  transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--coral); box-shadow: 0 0 0 3px var(--coral-soft);
}
.field textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
.field .hint { font-size: 11px; color: var(--text-subtle); margin-top: 4px; line-height: 1.45; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }

/* segmented control */
.seg { display: flex; background: var(--slate-050); border: 1px solid var(--divider); border-radius: 8px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; border: 0; background: none; cursor: pointer;
  font-size: 11.5px; font-weight: 600; color: var(--text-muted);
  padding: 6px 4px; border-radius: 6px; white-space: nowrap;
  transition: all .12s var(--ease);
}
.seg button.on { background: #fff; color: var(--text); box-shadow: var(--shadow-1); }

/* toggle rows (phases, disciplines, exclusions, sections) */
.rows { margin-top: 10px; border: 1px solid var(--divider); border-radius: 9px; overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-bottom: 1px solid var(--hairline);
  background: #fff;
}
.row:last-child { border-bottom: 0; }
.row.off { background: var(--slate-050); }
.row.off .row-name { color: var(--slate-400); }
.row-name { font-size: 12.5px; font-weight: 550; flex: 1; min-width: 0; }
.row-meta { font-size: 10.5px; color: var(--text-subtle); font-family: var(--font-mono); }
.row input.num {
  width: 58px; text-align: right; border: 1px solid var(--divider);
  border-radius: 6px; padding: 4px 6px; font-size: 12px; font-family: var(--font-mono);
  outline: 0;
}
.row input.num:focus { border-color: var(--coral); }
.row .tag {
  font: 600 9.5px/1 var(--font-mono); letter-spacing: .06em; text-transform: uppercase;
  padding: 4px 6px; border-radius: 4px; background: var(--slate-100); color: var(--slate-600);
  cursor: pointer; user-select: none;
}
.row .tag.sub { background: rgba(37,99,235,.10); color: var(--info); }
.row .x { cursor: pointer; color: var(--slate-300); font-size: 15px; line-height: 1; padding: 0 2px; }
.row .x:hover { color: var(--coral); }

/* checkbox */
.cb {
  width: 15px; height: 15px; flex: 0 0 auto; border-radius: 4px;
  border: 1.5px solid var(--slate-300); background: #fff; cursor: pointer;
  display: grid; place-items: center; transition: all .12s var(--ease);
}
.cb.on { background: var(--coral); border-color: var(--coral); }
.cb.on::after { content: "✓"; color: #fff; font-size: 10px; font-weight: 700; line-height: 1; }

.addbtn {
  margin-top: 8px; width: 100%; background: #fff; cursor: pointer;
  border: 1px dashed var(--slate-200); border-radius: 8px;
  padding: 8px; font-size: 11.5px; font-weight: 600; color: var(--text-muted);
  transition: all .12s var(--ease);
}
.addbtn:hover { border-color: var(--coral); color: var(--coral); background: var(--coral-soft); }

.sumline {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 9px; padding: 8px 10px; border-radius: 7px;
  background: var(--slate-050); font-size: 12px;
}
.sumline b { font-family: var(--font-mono); font-size: 12.5px; }
.sumline.warn { background: rgba(224,169,60,.12); color: #8a6413; }

/* --------------------------------------------------------------- stage */
.stage { background: var(--canvas); display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.stage-top {
  height: 46px; flex: 0 0 auto;
  background: var(--surface); border-bottom: 1px solid var(--divider);
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
}
.stage-top .doc-name { font-size: 12.5px; font-weight: 650; }
.stage-top .doc-meta { font-size: 11px; color: var(--text-subtle); font-family: var(--font-mono); }
.stage-tools { margin-left: auto; display: flex; align-items: center; gap: 7px; }
.tbtn {
  background: #fff; border: 1px solid var(--divider); border-radius: 7px;
  padding: 6px 11px; font-size: 11.5px; font-weight: 600; cursor: pointer;
  color: var(--text-muted); transition: all .12s var(--ease);
}
.tbtn:hover { border-color: var(--slate-300); color: var(--text); }
.tbtn.primary { background: var(--coral); border-color: var(--coral); color: #fff; }
.tbtn.primary:hover { background: #c2332c; }
.tbtn.on { background: var(--slate-900); border-color: var(--slate-900); color: #fff; }

.paper-scroll { flex: 1; overflow-y: auto; padding: 22px 0 60px; }
.paper-scroll::-webkit-scrollbar { width: 12px; }
.paper-scroll::-webkit-scrollbar-thumb { background: var(--slate-200); border-radius: 8px; border: 3px solid var(--canvas); }

/* ------------------------------------------------------------- AI rail */
.rail { background: var(--surface); border-left: 1px solid var(--divider); }
.rail-head {
  padding: 14px 16px 12px; border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; background: var(--surface); z-index: 5;
}
.rail-head .kicker {
  display: flex; align-items: center; gap: 6px;
  font: 600 9.5px/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--coral);
}
.rail-head h2 { font-family: var(--font-display); font-size: 13.5px; font-weight: 700; margin-top: 7px; letter-spacing: -.01em; }
.rail-head p { font-size: 11px; color: var(--text-subtle); margin-top: 4px; line-height: 1.45; }
.rail-body { padding: 12px 14px 40px; }

.sugg {
  border: 1px solid var(--divider); border-radius: 10px;
  padding: 11px 12px; margin-bottom: 9px; background: #fff;
  transition: all .15s var(--ease);
  animation: pop .3s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }
.sugg:hover { border-color: var(--slate-300); box-shadow: var(--shadow-1); }
.sugg .ev {
  font: 600 9.5px/1 var(--font-mono); letter-spacing: .07em; text-transform: uppercase;
  color: var(--coral); margin-bottom: 6px; display: flex; align-items: center; gap: 5px;
}
.sugg h4 { font-size: 12.5px; font-weight: 650; line-height: 1.35; margin-bottom: 4px; }
.sugg p { font-size: 11.5px; color: var(--text-muted); line-height: 1.5; }
.sugg .acts { display: flex; gap: 6px; margin-top: 9px; }
.sugg .acts button {
  border: 1px solid var(--divider); background: #fff; border-radius: 6px;
  padding: 5px 10px; font-size: 11px; font-weight: 600; cursor: pointer;
  transition: all .12s var(--ease);
}
.sugg .acts .yes { background: var(--slate-900); border-color: var(--slate-900); color: #fff; }
.sugg .acts .yes:hover { background: #000; }
.sugg .acts .no { color: var(--text-subtle); }
.sugg .acts .no:hover { border-color: var(--slate-300); color: var(--text); }

.rail-block { border-top: 1px solid var(--hairline); padding-top: 14px; margin-top: 16px; }
.rail-block h3 {
  font: 600 9.5px/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-subtle); margin-bottom: 11px;
}
.gauge { margin-bottom: 6px; }
.gauge-track {
  height: 6px; border-radius: 4px; position: relative;
  background: linear-gradient(90deg, #E6EAEF 0%, rgba(47,158,94,.35) 35%, rgba(47,158,94,.5) 60%, rgba(224,169,60,.45) 85%, rgba(220,60,52,.4) 100%);
}
.gauge-band {
  position: absolute; top: -3px; height: 12px; border-radius: 3px;
  background: rgba(47,158,94,.18); border: 1px solid rgba(47,158,94,.35);
}
.gauge-pin {
  position: absolute; top: -6px; width: 3px; height: 18px; border-radius: 2px;
  background: var(--slate-900); transform: translateX(-1.5px);
  transition: left .3s var(--ease);
}
.gauge-scale { display: flex; justify-content: space-between; font: 500 9.5px/1 var(--font-mono); color: var(--text-subtle); margin-top: 7px; }
.metric { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 0; border-bottom: 1px dashed var(--hairline); }
.metric:last-child { border-bottom: 0; }
.metric .k { font-size: 11.5px; color: var(--text-muted); }
.metric .v { font-family: var(--font-mono); font-size: 12px; font-weight: 600; }
.metric .v.good { color: var(--success); }
.metric .v.warn { color: #b07d18; }

/* ------------------------------------------------------ library view */
.view { display: none; height: calc(100vh - 56px); overflow-y: auto; }
.view.on { display: block; }
.app.on { display: grid; }
.app.hidden { display: none; }
.lib-wrap { max-width: 1080px; margin: 0 auto; padding: 34px 28px 80px; }
.lib-head h1 { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.lib-head p { color: var(--text-muted); font-size: 14px; margin-top: 7px; max-width: 640px; }

.drop {
  margin-top: 22px; border: 1.5px dashed var(--slate-200); border-radius: 14px;
  background: #fff; padding: 26px; display: flex; align-items: center; gap: 20px;
}
.drop .ic {
  width: 46px; height: 46px; border-radius: 12px; flex: 0 0 auto;
  background: var(--coral-soft); color: var(--coral); display: grid; place-items: center; font-size: 20px;
}
.drop h3 { font-family: var(--font-display); font-size: 15px; font-weight: 650; }
.drop p { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.drop .go {
  margin-left: auto; background: var(--slate-900); color: #fff; border: 0;
  border-radius: 9px; padding: 10px 18px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 20px; }
.kpi { background: #fff; border: 1px solid var(--divider); border-radius: 12px; padding: 16px 18px; }
.kpi .n { font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: -.025em; line-height: 1; }
.kpi .n .u { font-size: .55em; color: var(--coral); margin-left: 1px; }
.kpi .l { font-size: 11.5px; color: var(--text-muted); margin-top: 7px; line-height: 1.4; }

.lib-cols { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; margin-top: 22px; align-items: start; }
.card { background: #fff; border: 1px solid var(--divider); border-radius: 13px; overflow: hidden; }
.card > header { padding: 13px 17px; border-bottom: 1px solid var(--hairline); display: flex; align-items: center; gap: 9px; }
.card > header h3 { font-family: var(--font-display); font-size: 13.5px; font-weight: 650; }
.card > header .count { margin-left: auto; font: 600 10px/1 var(--font-mono); color: var(--text-subtle); }
.card .body { padding: 6px 17px 15px; }

table.lib { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.lib th {
  text-align: left; font: 600 9.5px/1 var(--font-mono); letter-spacing: .09em;
  text-transform: uppercase; color: var(--text-subtle); padding: 10px 8px 8px; border-bottom: 1px solid var(--divider);
}
table.lib td { padding: 9px 8px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
table.lib tr:last-child td { border-bottom: 0; }
table.lib td.num { font-family: var(--font-mono); text-align: right; font-size: 12px; }
.pill { font: 600 9.5px/1 var(--font-mono); letter-spacing: .05em; text-transform: uppercase; padding: 4px 7px; border-radius: 5px; display: inline-block; }
.pill.won { background: rgba(47,158,94,.12); color: var(--success); }
.pill.lost { background: rgba(220,60,52,.10); color: var(--coral); }
.pill.open { background: var(--slate-100); color: var(--slate-600); }

.pattern { padding: 11px 0; border-bottom: 1px dashed var(--hairline); }
.pattern:last-child { border-bottom: 0; }
.pattern .h { display: flex; align-items: baseline; gap: 8px; }
.pattern .h b { font-size: 12.5px; font-weight: 650; }
.pattern .h span { margin-left: auto; font: 600 10px/1 var(--font-mono); color: var(--coral); }
.pattern p { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }
.bar { height: 5px; border-radius: 3px; background: var(--slate-100); margin-top: 7px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--coral); border-radius: 3px; }

/* ================================ CLIENT-FACING PROPOSAL ASSISTANT ====== */
#chat { display: none; }
body.client-view #chat { display: block; }

.chat-fab {
  position: fixed; right: 26px; bottom: 24px; z-index: 150;
  display: flex; align-items: center; gap: 10px;
  background: var(--firm-ink); color: #fff; border: 0; cursor: pointer;
  border-radius: 999px; padding: 13px 20px 13px 15px;
  box-shadow: 0 6px 20px rgba(15,23,42,.22), 0 2px 6px rgba(15,23,42,.14);
  font: 600 13px/1 var(--font-body);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.chat-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(15,23,42,.26); }
.chat-fab .fab-ic {
  width: 24px; height: 24px; border-radius: 50%; flex: 0 0 auto;
  background: var(--firm); color: var(--firm-ink);
  display: grid; place-items: center; font-size: 12px;
}
#chat.open .chat-fab { transform: scale(.85); opacity: 0; pointer-events: none; }

.chat-panel {
  position: fixed; right: 26px; bottom: 24px; z-index: 151;
  width: 374px; max-width: calc(100vw - 32px);
  height: 560px; max-height: calc(100vh - 120px);
  background: var(--surface); border: 1px solid var(--divider); border-radius: 16px;
  box-shadow: 0 10px 40px rgba(15,23,42,.20), 0 2px 8px rgba(15,23,42,.10);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: translateY(12px) scale(.98); pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
#chat.open .chat-panel { opacity: 1; transform: none; pointer-events: auto; }

.chat-panel > header {
  display: flex; align-items: center; gap: 11px; padding: 13px 14px;
  background: var(--firm-ink); color: #fff; flex: 0 0 auto;
}
.chat-panel .cav {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto;
  background: var(--firm); color: var(--firm-ink);
  display: grid; place-items: center;
  font: 700 12px/1 var(--font-display);
}
.chat-panel .cname { font: 650 13px/1.2 var(--font-display); }
.chat-panel .cstat {
  font-size: 10.5px; color: rgba(255,255,255,.6); margin-top: 3px;
  display: flex; align-items: center; gap: 5px;
}
.chat-panel .cstat .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.chat-panel .cclose {
  margin-left: auto; background: none; border: 0; color: rgba(255,255,255,.55);
  font-size: 21px; line-height: 1; cursor: pointer; padding: 0 3px;
}
.chat-panel .cclose:hover { color: #fff; }

.chat-log { flex: 1; overflow-y: auto; padding: 15px 14px 6px; }
.chat-log::-webkit-scrollbar { width: 8px; }
.chat-log::-webkit-scrollbar-thumb { background: var(--slate-200); border-radius: 6px; border: 2px solid var(--surface); }

.msg { margin-bottom: 12px; display: flex; animation: pop .25s var(--ease); }
.msg.me { justify-content: flex-end; }
.msg .bub {
  max-width: 84%; padding: 10px 13px; border-radius: 13px;
  font-size: 12.5px; line-height: 1.6; color: var(--text);
  background: var(--surface-alt); border: 1px solid var(--hairline);
  border-bottom-left-radius: 4px;
}
.msg.me .bub {
  background: var(--firm-ink); color: #fff; border-color: transparent;
  border-bottom-left-radius: 13px; border-bottom-right-radius: 4px;
}
.msg .bub b { font-weight: 650; }
.msg .bub .kv { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px dashed var(--divider); }
.msg .bub .kv:last-of-type { border-bottom: 0; }
.msg .bub .kv span:last-child { font-family: var(--font-mono); font-size: 11.5px; white-space: nowrap; }
.msg .bub ul { list-style: none; margin: 6px 0 0; }
.msg .bub li { padding: 3px 0 3px 14px; position: relative; }
.msg .bub li::before { content: "—"; position: absolute; left: 0; color: var(--firm); }
.msg .bub .src {
  display: block; margin-top: 9px; padding-top: 7px; border-top: 1px solid var(--divider);
  font: 600 9px/1.4 var(--font-mono); letter-spacing: .07em; text-transform: uppercase; color: var(--text-subtle);
}
.typing { display: flex; gap: 4px; padding: 13px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--slate-300); animation: blink 1.3s infinite; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

.chat-chips { display: flex; gap: 6px; padding: 4px 14px 10px; flex-wrap: wrap; flex: 0 0 auto; }
.chat-chips button {
  background: #fff; border: 1px solid var(--divider); border-radius: 999px;
  padding: 6px 11px; font-size: 11px; font-weight: 550; color: var(--text-muted); cursor: pointer;
  transition: all .12s var(--ease);
}
.chat-chips button:hover { border-color: var(--firm); color: var(--firm-dark); background: var(--firm-soft); }

.chat-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--hairline); flex: 0 0 auto; }
.chat-input input {
  flex: 1; min-width: 0; border: 1px solid var(--divider); border-radius: 9px;
  padding: 9px 11px; font-size: 12.5px; outline: 0; background: #fff;
}
.chat-input input:focus { border-color: var(--firm); box-shadow: 0 0 0 3px var(--firm-soft); }
.chat-input button {
  width: 36px; flex: 0 0 auto; border: 0; border-radius: 9px; cursor: pointer;
  background: var(--firm-ink); color: #fff; font-size: 15px;
}
.chat-input button:hover { filter: brightness(1.25); }
.chat-foot {
  padding: 0 14px 11px; font-size: 10px; color: var(--text-subtle); text-align: center;
}

@media (max-width: 560px) {
  .chat-fab .fab-tx { display: none; }
  .chat-fab { padding: 14px; }
}

/* ------------------------------------------------------------- toast */
.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--slate-900); color: #fff; border-radius: 10px;
  padding: 11px 18px; font-size: 12.5px; font-weight: 550;
  box-shadow: var(--shadow-2); animation: rise .3s var(--ease);
  display: flex; align-items: center; gap: 9px;
}
.toast .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); flex: 0 0 auto; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* =========================================================================
   THE PROPOSAL — firm-branded document canvas
   ====================================================================== */
.doc { --pg: 0; }
.pg {
  background: #fff; max-width: 820px; margin: 0 auto 22px;
  padding: 62px 58px; position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.05);
  border-radius: 2px;
  color: var(--slate-900);
}
.pg.dark { background: var(--firm-ink); color: #fff; }
.pg .pgnum {
  position: absolute; top: 22px; right: 28px;
  font: 600 9.5px/1 var(--font-mono); letter-spacing: .12em; color: var(--slate-300);
}
.pg.dark .pgnum { color: rgba(255,255,255,.35); }
.ey {
  font: 600 10px/1 var(--font-body); letter-spacing: .15em; text-transform: uppercase;
  color: var(--firm); margin-bottom: 13px;
}
.pg.dark .ey { color: var(--firm); filter: brightness(1.5); }
.pg h1 { font-family: var(--font-display); font-size: 40px; font-weight: 700; letter-spacing: -.028em; line-height: 1.08; }
.pg h2 { font-family: var(--font-display); font-size: 27px; font-weight: 700; letter-spacing: -.022em; line-height: 1.16; margin-bottom: 12px; }
.pg h3 { font-family: var(--font-display); font-size: 16px; font-weight: 650; letter-spacing: -.01em; line-height: 1.3; }
.pg h4 { font-family: var(--font-display); font-size: 13.5px; font-weight: 650; }
.pg p { font-size: 13.5px; line-height: 1.72; color: var(--slate-700); text-wrap: pretty; }
.pg .lead { font-size: 14.5px; color: var(--slate-600); line-height: 1.65; max-width: 600px; }
.pg.dark p, .pg.dark .lead { color: rgba(255,255,255,.72); }
.pg.dark h1, .pg.dark h2, .pg.dark h3 { color: #fff; }

/* cover */
.cover {
  background: var(--firm-ink); color: #fff; padding: 74px 58px 60px; overflow: hidden;
  background-image:
    linear-gradient(rgba(255,255,255,.032) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.032) 1px, transparent 1px);
  background-size: 42px 42px;
}
.cover .firmtag { position: absolute; top: 46px; right: 58px; display: flex; align-items: center; gap: 10px; }
.cover .firmtag .fm {
  width: 34px; height: 34px; border-radius: 8px; background: var(--firm);
  display: grid; place-items: center; color: var(--firm-ink);
  font-family: var(--font-display); font-weight: 700; font-size: 14px;
}
.cover .firmtag .fn { font-family: var(--font-display); font-weight: 650; font-size: 13px; color: #fff; }
.cover .eye { color: var(--firm); font: 600 10.5px/1 var(--font-body); letter-spacing: .2em; text-transform: uppercase; margin-bottom: 20px; filter: brightness(1.35); }
.cover h1 { color: #fff; font-size: 44px; max-width: 600px; }
.cover .sub { color: rgba(255,255,255,.7); font-size: 15.5px; max-width: 520px; margin-top: 18px; line-height: 1.55; }
.cover .meta { display: flex; gap: 42px; margin-top: 46px; padding-top: 24px; border-top: 1px solid rgba(255,255,255,.13); flex-wrap: wrap; }
.cover .meta .lbl { font: 600 9.5px/1 var(--font-mono); letter-spacing: .12em; color: var(--firm); text-transform: uppercase; margin-bottom: 7px; filter: brightness(1.4); }
.cover .meta .val { font-family: var(--font-display); font-weight: 600; color: #fff; font-size: 13.5px; }
.cover .chips { display: flex; gap: 7px; margin-top: 26px; flex-wrap: wrap; }
.cover .chip { background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.14); color: rgba(255,255,255,.88); padding: 5px 11px; border-radius: 20px; font-size: 10.5px; font-weight: 550; }

/* transmittal letter */
.letter { display: grid; grid-template-columns: 190px 1fr; gap: 44px; margin-top: 24px; align-items: start; }
.letter .sigcol { position: sticky; top: 20px; }
.sig-photo {
  width: 100%; max-width: 175px; aspect-ratio: 4 / 5; margin: 0 0 16px;
  border-radius: 11px; overflow: hidden; background: var(--slate-050);
  box-shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 20px rgba(15,23,42,.10);
}
.sig-photo img { width: 100%; height: 100%; object-fit: cover; object-position: center 22%; display: block; }
.sig-block { border-left: 2px solid var(--firm); padding-left: 14px; }
.sig-name { font-family: var(--font-display); font-weight: 700; font-size: 13.5px; }
.sig-role { font-size: 11.5px; color: var(--slate-500); margin-top: 2px; line-height: 1.4; }
.sig-reg { font: 500 10px/1.4 var(--font-mono); color: var(--slate-400); margin-top: 6px; }
.sig-script {
  font-family: 'Snell Roundhand', 'Segoe Script', cursive;
  font-size: 30px; color: var(--slate-700); margin: 16px 0 4px; transform: rotate(-2deg); transform-origin: left;
}
.letter .body p { font-size: 13.5px; line-height: 1.78; color: var(--slate-700); margin-bottom: 15px; }
.letter .body p strong { color: var(--slate-900); font-weight: 600; }
.letter .rfp-ref {
  background: var(--slate-050); border-left: 3px solid var(--firm);
  padding: 12px 15px; border-radius: 0 8px 8px 0; margin-bottom: 18px;
  font-size: 12px; color: var(--slate-600); line-height: 1.6;
}
.letter .rfp-ref b { color: var(--slate-900); }

/* generic blocks */
.mt { margin-top: 26px; }
.mt-s { margin-top: 16px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.three { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.cellbox { border: 1px solid var(--slate-100); border-radius: 11px; padding: 17px 18px; background: #fff; }
.cellbox .kn { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cellbox .kn .n { font: 600 10px/1 var(--font-mono); color: var(--firm); letter-spacing: .08em; }
.cellbox .kn .dash { height: 1px; width: 16px; background: var(--slate-100); }
.cellbox .kn .l { font: 600 9.5px/1 var(--font-body); letter-spacing: .13em; text-transform: uppercase; color: var(--slate-400); }
.cellbox h4 { margin-bottom: 6px; }
.cellbox p { font-size: 12.5px; line-height: 1.55; color: var(--slate-600); }

/* understanding — issue → response */
.ir { border-top: 1px solid var(--slate-100); }
.ir-row { display: grid; grid-template-columns: 1fr 26px 1fr; padding: 16px 0; border-bottom: 1px solid var(--slate-100); align-items: start; }
.ir-row .k { font: 600 10px/1 var(--font-mono); color: var(--slate-400); letter-spacing: .08em; margin-bottom: 5px; }
.ir-row h4 { font-size: 13.5px; line-height: 1.3; margin-bottom: 4px; }
.ir-row p { font-size: 12.5px; line-height: 1.55; color: var(--slate-500); }
.ir-arrow { display: grid; place-items: center; color: var(--firm); font-size: 15px; font-weight: 700; padding-top: 14px; }
.ir-res { padding-left: 16px; border-left: 1px solid var(--slate-100); }
.ir-res .k { color: var(--firm); }
.ir-res p { color: var(--slate-600); }

/* team */
.team-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 11px; margin-top: 20px; }
.person { border: 1px solid var(--slate-100); border-radius: 11px; padding: 14px 15px; display: flex; gap: 12px; align-items: flex-start; }
.person .av {
  width: 40px; height: 40px; border-radius: 9px; flex: 0 0 auto;
  background: var(--firm-soft); color: var(--firm-dark);
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 13px;
}
.person .nm { font-family: var(--font-display); font-weight: 650; font-size: 13px; }
.person .rl { font-size: 11.5px; color: var(--firm-dark); font-weight: 600; margin-top: 1px; }
.person .dt { font: 500 10px/1.5 var(--font-mono); color: var(--slate-400); margin-top: 5px; }

/* experience */
.proj { display: grid; grid-template-columns: 1fr auto; gap: 14px; padding: 15px 0; border-bottom: 1px solid var(--slate-100); align-items: center; }
.proj:last-child { border-bottom: 0; }
.proj h4 { font-size: 13.5px; margin-bottom: 3px; }
.proj .cl { font-size: 12px; color: var(--slate-500); }
.proj .tags { display: flex; gap: 5px; margin-top: 7px; flex-wrap: wrap; }
.proj .tg { font: 600 9px/1 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; background: var(--slate-050); color: var(--slate-500); padding: 4px 6px; border-radius: 4px; }
.proj .tg.match { background: var(--firm-soft); color: var(--firm-dark); }
.proj .amt { text-align: right; }
.proj .amt .v { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.proj .amt .y { font: 500 10px/1 var(--font-mono); color: var(--slate-400); margin-top: 4px; }

/* scope phases */
.phase { border: 1px solid var(--slate-100); border-radius: 12px; margin-top: 12px; overflow: hidden; }
.phase > .ph-head {
  display: flex; align-items: center; gap: 12px; padding: 13px 17px;
  background: var(--slate-050); border-bottom: 1px solid var(--slate-100);
}
.phase .ph-key {
  font: 700 10px/1 var(--font-mono); letter-spacing: .08em; color: #fff;
  background: var(--firm); padding: 5px 7px; border-radius: 5px;
}
.phase .ph-name { font-family: var(--font-display); font-weight: 650; font-size: 14px; }
.phase .ph-fee { margin-left: auto; text-align: right; flex: 0 0 auto; }
.phase .ph-fee .v, .phase .ph-fee .p { display: block; }
.phase .ph-fee .v { font-family: var(--font-display); font-weight: 700; font-size: 14.5px; }
.phase .ph-fee .p { font: 500 9.5px/1 var(--font-mono); color: var(--slate-400); margin-top: 3px; }
.phase .ph-body { padding: 14px 17px 16px; }
.phase .ph-body > p { font-size: 12.5px; line-height: 1.6; color: var(--slate-600); }
.deliv { margin-top: 12px; }
.deliv .dh { font: 600 9.5px/1 var(--font-mono); letter-spacing: .11em; text-transform: uppercase; color: var(--slate-400); margin-bottom: 8px; }
.deliv ul { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.deliv li { font-size: 12px; line-height: 1.5; color: var(--slate-600); padding-left: 15px; position: relative; }
.deliv li::before {
  content: ""; position: absolute; left: 0; top: 7px; width: 7px; height: 7px;
  border-radius: 2px; background: var(--firm-soft); border: 1.4px solid var(--firm);
}

/* tables */
.tscroll { overflow-x: auto; margin-top: 16px; }
.tscroll table.doc-t { margin-top: 0; min-width: 560px; }
.tscroll::-webkit-scrollbar { height: 8px; }
.tscroll::-webkit-scrollbar-thumb { background: var(--slate-200); border-radius: 6px; }
table.doc-t { width: 100%; border-collapse: collapse; margin-top: 16px; }
table.doc-t th {
  text-align: left; font: 600 9.5px/1.3 var(--font-mono); letter-spacing: .09em; text-transform: uppercase;
  color: var(--slate-400); padding: 9px 8px; border-bottom: 1.5px solid var(--slate-200); vertical-align: bottom;
}
table.doc-t th.r, table.doc-t td.r { text-align: right; }
table.doc-t td { padding: 10px 8px; border-bottom: 1px solid var(--slate-100); font-size: 12.5px; color: var(--slate-700); }
table.doc-t td.r { font-family: var(--font-mono); font-size: 12px; }
table.doc-t tr.tot td { border-bottom: 0; border-top: 1.5px solid var(--slate-800); font-weight: 700; color: var(--slate-900); padding-top: 12px; }
table.doc-t tr.tot td.r { font-size: 13.5px; }
table.doc-t tr.sub td { background: var(--slate-050); font-weight: 600; }
table.doc-t td .who { font: 500 9px/1 var(--font-mono); color: var(--slate-400); text-transform: uppercase; letter-spacing: .05em; margin-left: 6px; }

/* fee hero */
.fee-hero {
  margin-top: 20px; border-radius: 14px; overflow: hidden;
  display: grid; grid-template-columns: 1fr 1fr 1fr; background: var(--firm-ink);
}
.fee-hero .cell { padding: 24px 22px; border-right: 1px solid rgba(255,255,255,.09); }
.fee-hero .cell:last-child { border-right: 0; }
.fee-hero .cell .l { font: 600 9.5px/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--firm); margin-bottom: 11px; filter: brightness(1.4); }
.fee-hero .cell .v { font-family: var(--font-display); font-weight: 700; font-size: 30px; letter-spacing: -.03em; color: #fff; line-height: 1; }
.fee-hero .cell .c { font-size: 11px; color: rgba(255,255,255,.55); margin-top: 9px; line-height: 1.45; }

/* schedule */
.gantt { margin-top: 20px; border: 1px solid var(--slate-100); border-radius: 11px; overflow: hidden; }
.gantt .grow { display: grid; grid-template-columns: 178px 1fr; align-items: center; border-bottom: 1px solid var(--slate-100); }
.gantt .grow:last-child { border-bottom: 0; }
.gantt .glabel { padding: 10px 14px; font-size: 12px; font-weight: 600; color: var(--slate-700); border-right: 1px solid var(--slate-100); }
.gantt .glabel small { display: block; font: 500 9.5px/1.4 var(--font-mono); color: var(--slate-400); font-weight: 500; }
.gantt .gtrack { position: relative; height: 40px; }
.gantt .gbar {
  position: absolute; top: 12px; height: 16px; border-radius: 4px;
  background: var(--firm); display: flex; align-items: center; padding: 0 7px;
  font: 600 9px/1 var(--font-mono); color: #fff; white-space: nowrap; overflow: hidden;
}
.gantt .gbar.rev { background: var(--slate-300); color: var(--slate-700); }
.gantt .gbar.ca { background: var(--slate-600); }
.gantt .ghead { background: var(--slate-050); }
.gantt .ghead .gtrack { height: 26px; display: flex; }
.gantt .ghead .gtick { flex: 1; border-left: 1px solid var(--slate-100); font: 500 9px/26px var(--font-mono); color: var(--slate-400); padding-left: 5px; }

/* lists */
ul.tick { list-style: none; margin-top: 12px; }
ul.tick li { font-size: 12.5px; line-height: 1.6; color: var(--slate-600); padding: 6px 0 6px 22px; position: relative; border-bottom: 1px solid var(--slate-050); }
ul.tick li:last-child { border-bottom: 0; }
ul.tick li::before { content: "✓"; position: absolute; left: 2px; top: 6px; color: var(--firm); font-size: 11px; font-weight: 700; }
ul.tick.ex li::before { content: "—"; color: var(--slate-300); }
ul.tick li b { color: var(--slate-900); font-weight: 600; }

.note {
  margin-top: 18px; background: var(--slate-050); border-radius: 10px; padding: 14px 16px;
  font-size: 12px; line-height: 1.6; color: var(--slate-600);
}
.note b { color: var(--slate-900); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(3,1fr); margin-top: 22px; border-top: 1px solid var(--slate-200); border-bottom: 1px solid var(--slate-200); }
.stats .s { padding: 22px 18px; border-right: 1px solid var(--slate-100); }
.stats .s:last-child { border-right: 0; }
.stats .s .n { font-family: var(--font-display); font-weight: 700; font-size: 34px; letter-spacing: -.03em; color: var(--slate-800); line-height: 1; }
.stats .s .n .u { color: var(--firm); font-size: .6em; }
.stats .s .l { font-size: 12px; color: var(--slate-500); margin-top: 8px; line-height: 1.4; }

/* signature page */
.authorize { margin-top: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 34px; }
.authorize .sline { border-bottom: 1.5px solid rgba(255,255,255,.28); height: 42px; }
.authorize .slabel { font: 600 9.5px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.45); margin-top: 9px; }
.acceptbar { margin-top: 30px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.acceptbtn {
  background: var(--firm); color: var(--firm-ink); border: 0; border-radius: 10px;
  padding: 13px 26px; font: 700 13.5px/1 var(--font-body); cursor: pointer;
  transition: filter .15s var(--ease);
}
.acceptbtn:hover { filter: brightness(1.08); }
.ghostbtn {
  background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.25);
  border-radius: 10px; padding: 13px 22px; font: 600 13px/1 var(--font-body); cursor: pointer;
}

/* sample-data watermark */
.samp {
  position: absolute; bottom: 18px; left: 58px;
  font: 600 8.5px/1 var(--font-mono); letter-spacing: .14em; text-transform: uppercase;
  color: var(--slate-200);
}
.pg.dark .samp { color: rgba(255,255,255,.18); }

/* narrower windows — keep the document readable */
@media (max-width: 1440px) {
  .app { grid-template-columns: 336px minmax(0,1fr) 268px; }
}
@media (max-width: 1240px) {
  .app { grid-template-columns: 312px minmax(0,1fr) 248px; }
  .pg { padding: 46px 38px; }
  .cover { padding: 56px 38px 46px; }
  .cover .firmtag { top: 34px; right: 38px; }
  .pg h1 { font-size: 34px; }
  .cover h1 { font-size: 36px; }
  .pg h2 { font-size: 23px; }
  .letter { grid-template-columns: 150px 1fr; gap: 26px; }
  .samp { left: 38px; }
  .deliv ul, .two, .team-grid { grid-template-columns: 1fr; }
}

/* the fee matrix carries a column per phase — tighten it so it always fits */
table.fee-matrix { table-layout: fixed; }
table.fee-matrix th:first-child, table.fee-matrix td:first-child { width: 22%; }
table.fee-matrix th, table.fee-matrix td { padding-left: 4px; padding-right: 4px; }
table.fee-matrix td { font-size: 12px; }
table.fee-matrix td.r { font-size: 11px; letter-spacing: -.02em; }
table.fee-matrix tr.tot td.r { font-size: 11.5px; }
table.fee-matrix td .who { display: block; margin-left: 0; margin-top: 2px; }
.tscroll table.fee-matrix { min-width: 0; }

@media print {
  body { overflow: visible; }
  .app-top, .builder, .rail, .stage-top, .toast-wrap { display: none !important; }
  .app { display: block; height: auto; }
  .paper-scroll { overflow: visible; padding: 0; }
  .pg { box-shadow: none; margin: 0 auto; page-break-after: always; max-width: none; }
}
