@import url("theme.css");

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 400 13.5px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
::selection { background: var(--brand-tint); }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 268px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--bosia-sidebar);
  color: var(--bosia-sidebar-text);
  border-right: 1px solid var(--bosia-sidebar-line);
  z-index: 40;
}
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 14px; border-bottom: 1px solid var(--bosia-sidebar-line); }
.sb-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(150deg, #3d7bf0, #2358c6);
  color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .5px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
}
.sb-brand h1 { font-size: 14px; letter-spacing: -.01em; color: #fff; font-weight: 650; }
.sb-brand span { display: block; font-size: 10.5px; color: var(--bosia-sidebar-muted); letter-spacing: .04em; text-transform: uppercase; }
.ws {
  margin: 12px 12px 8px; padding: 10px; border-radius: 8px;
  background: var(--bosia-sidebar-2); border: 1px solid var(--bosia-sidebar-line);
}
.ws-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--bosia-sidebar-muted); }
.ws-name { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 3px; font-size: 12.5px; color: #fff; font-weight: 600; }
.ws-sub { font-size: 11px; color: var(--bosia-sidebar-muted); margin-top: 1px; }
.ws-name svg { opacity: .7; flex: none; }

.sb-scroll { flex: 1; overflow-y: auto; padding: 4px 10px 12px; scrollbar-width: thin; }
.nav-group { margin-top: 14px; }
.nav-group:first-child { margin-top: 4px; }
.nav-label { font-size: 9.5px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: #6f8194; padding: 0 8px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: 6px; font-size: 12.3px; color: var(--bosia-sidebar-text);
  border: 1px solid transparent; line-height: 1.35;
}
.nav-item:hover { background: rgba(255,255,255,.055); color: #fff; }
.nav-item.active { background: #1d3550; border-color: #2b4a6d; color: #fff; }
.nav-item .ni-ico { width: 15px; flex: none; opacity: .8; }
.nav-item .ni-meta { margin-left: auto; font-size: 10px; color: var(--bosia-sidebar-muted); }
.step { display: flex; gap: 8px; align-items: flex-start; padding: 5px 8px; border-radius: 6px; border: 1px solid transparent; color: var(--bosia-sidebar-text); }
.step:hover { background: rgba(255,255,255,.055); color: #fff; }
.step.active { background: #1d3550; border-color: #2b4a6d; color: #fff; }
.step-n {
  flex: none; width: 18px; height: 18px; border-radius: 50%; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; margin-top: 1px;
  background: #233645; color: #9db0c2; border: 1px solid #2f465a;
}
.step.done .step-n { background: #173f33; border-color: #2a6b52; color: #7fe0b3; }
.step.current .step-n { background: #2f6feb; border-color: #4d85f2; color: #fff; }
.step.rev .step-n { background: #4a3416; border-color: #7a5a26; color: #f0c07a; }
.step-body { min-width: 0; display: flex; flex-direction: column; }
.step-title { display: block; font-size: 12px; font-weight: 550; color: inherit; line-height: 1.3; }
.step-state { display: block; font-size: 10px; color: var(--bosia-sidebar-muted); margin-top: 1px; line-height: 1.3; }
.step.done .step-state { color: #6fb99a; }
.step.current .step-state { color: #8fb4f5; }
.step.rev .step-state { color: #d9ad68; }
.sb-foot { border-top: 1px solid var(--bosia-sidebar-line); padding: 10px 12px; display: flex; align-items: center; gap: 9px; }
.avatar { width: 27px; height: 27px; border-radius: 50%; display: grid; place-items: center; background: #2a4258; color: #dce7f2; font-size: 10.5px; font-weight: 700; flex: none; }
.sb-foot .who { font-size: 11.5px; color: #e8eef5; font-weight: 550; line-height: 1.25; }
.sb-foot .who span { display: block; color: var(--bosia-sidebar-muted); font-weight: 400; font-size: 10.5px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; flex-wrap: nowrap; align-items: center; gap: 14px;
  height: 52px; padding: 0 24px;
  background: rgba(255,255,255,.88); backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.menu-btn { display: none; }
.crumb { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); min-width: 0; }
.crumb b { color: var(--ink); font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb .sep { color: var(--line-strong); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.kbd-search {
  display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--muted);
  font-size: 11.5px; min-width: 190px;
}
.kbd-search kbd { margin-left: auto; font: 600 9.5px/1 var(--sans); color: var(--muted-2); border: 1px solid var(--line); border-radius: 4px; padding: 3px 4px; }

.content { padding: 24px 28px 56px; width: 100%; max-width: 1480px; margin: 0 auto; }
.screen { animation: screenIn .18s ease-out; }
@keyframes screenIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Typography ---------- */
.page-head { display: flex; align-items: flex-start; gap: 20px; margin-bottom: 20px; }
.page-head .ph-main { min-width: 0; }
.eyebrow { font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--brand); margin-bottom: 5px; }
.page-title { font-family: var(--serif); font-size: 27px; line-height: 1.15; letter-spacing: -.015em; font-weight: 600; }
.page-sub { color: var(--muted); font-size: 12.8px; margin-top: 5px; max-width: 78ch; }
.ph-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }
.section-title { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.tiny { font-size: 10.5px; }
.serif { font-family: var(--serif); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 7px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
  font-size: 12px; font-weight: 550; white-space: nowrap;
  box-shadow: var(--bosia-shadow-1); transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(47,111,235,.35); }
.btn-primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); }
.btn-brass { background: var(--brass); border-color: var(--brass); color: #fff; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn-ghost:hover { background: rgba(20,40,60,.05); color: var(--ink); }
.btn-sm { height: 27px; padding: 0 9px; font-size: 11.2px; border-radius: 6px; }
.btn-icon { width: 30px; padding: 0; }
.btn.menu-btn { display: none; }
.btn-link { background: none; border: 0; padding: 0; height: auto; color: var(--brand); font-size: 11.5px; font-weight: 600; box-shadow: none; }

/* ---------- Cards / surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--bosia-shadow-1); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line-soft); }
.card-head h3 { font-size: 12.5px; font-weight: 650; }
.card-body { padding: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.pad { padding: 16px; }
.divider { height: 1px; background: var(--line-soft); border: 0; margin: 14px 0; }

/* ---------- Badges / chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 19px; padding: 0 7px; border-radius: 5px; font-size: 10.5px; font-weight: 600; letter-spacing: .01em; white-space: nowrap; border: 1px solid transparent; }
.badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.b-ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, #fff); border-color: color-mix(in srgb, var(--ok) 22%, #fff); }
.b-warn { color: var(--warn); background: var(--warn-tint); border-color: color-mix(in srgb, var(--warn) 26%, #fff); }
.b-danger { color: var(--danger); background: var(--danger-tint); border-color: color-mix(in srgb, var(--danger) 24%, #fff); }
.b-info { color: var(--brand); background: var(--brand-tint); border-color: color-mix(in srgb, var(--brand) 22%, #fff); }
.b-brass { color: var(--brass); background: var(--brass-tint); border-color: color-mix(in srgb, var(--brass) 26%, #fff); }
.b-neutral { color: var(--muted); background: #f1f4f8; border-color: var(--line); }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); font-size: 10.8px; color: var(--ink-2); }
.chip svg { opacity: .6; }
.chip.link:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th { text-align: left; font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 650; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: color-mix(in srgb, var(--brand) 3%, #fff); }
.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td.mono { white-space: nowrap; }
.tbl .t-main { font-weight: 600; color: var(--ink); }
.tbl .t-sub { color: var(--muted); font-size: 10.8px; margin-top: 1px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 13px; }
.field > label { display: block; font-size: 11px; font-weight: 650; color: var(--ink-2); margin-bottom: 5px; }
.field .req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; min-height: 34px; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 7px;
  background: #fff; color: var(--ink); font-size: 12.5px; transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.textarea { min-height: 78px; resize: vertical; line-height: 1.5; }
.hint { font-size: 10.8px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.input-group { display: flex; }
.input-group .input { border-radius: 7px 0 0 7px; }
.input-group .btn { border-radius: 0 7px 7px 0; height: 34px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; padding: 7px 0; }
.check input { margin-top: 2px; accent-color: var(--brand); }

/* ---------- Layout helpers ---------- */
.grid-12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.col-8 { grid-column: span 8; } .col-4 { grid-column: span 4; }
.col-7 { grid-column: span 7; } .col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; } .col-9 { grid-column: span 9; } .col-3 { grid-column: span 3; }
.col-12 { grid-column: span 12; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.split { display: grid; grid-template-columns: minmax(0,1fr) 360px; gap: 16px; align-items: start; }

/* ---------- Stat strip ---------- */
.stat-strip { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--bosia-shadow-1); margin-bottom: 18px; }
.stat { padding: 12px 18px; border-right: 1px solid var(--line-soft); min-width: 0; }
.stat:last-child { border-right: 0; }
.stat .s-label { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.stat .s-value { font-size: 20px; font-weight: 650; letter-spacing: -.02em; margin-top: 1px; font-variant-numeric: tabular-nums; }
.stat .s-value small { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.stat .s-note { font-size: 10.5px; color: var(--muted); }

/* ---------- Stepper (journey) ---------- */
.journey { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.jstep { position: relative; padding: 12px 12px 13px; border-right: 1px solid var(--line-soft); text-align: left; background: none; border-top: 0; border-bottom: 0; border-left: 0; }
.jstep:last-child { border-right: 0; }
.jstep:hover { background: var(--surface-2); }
.jstep .j-n { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--muted); font-weight: 650; letter-spacing: .03em; }
.j-n .pill { width: 17px; height: 17px; border-radius: 50%; display: grid; place-items: center; font-size: 9.5px; background: #e8edf4; color: var(--muted); }
.jstep.done .pill { background: color-mix(in srgb, var(--ok) 15%, #fff); color: var(--ok); }
.jstep.current .pill { background: var(--brand); color: #fff; }
.jstep.rev .pill { background: var(--warn-tint); color: var(--warn); }
.jstep .j-title { display: block; font-size: 11.5px; font-weight: 600; margin-top: 7px; line-height: 1.3; }
.jstep .j-state { display: block; font-size: 10px; color: var(--muted); margin-top: 2px; line-height: 1.3; }
.jstep.done .j-state { color: var(--ok); }
.jstep.current .j-state { color: var(--brand); }
.jstep.rev .j-state { color: var(--warn); }
.jstep.current::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; background: var(--brand); }

/* ---------- Document workspace ---------- */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 342px; gap: 16px; align-items: start; }
.doc-shell { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--bosia-shadow-1); min-width: 0; }
.doc-bar { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--line-soft); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; flex-wrap: wrap; }
.doc-bar .db-title { font-size: 12px; font-weight: 650; }
.doc-bar .db-meta { font-size: 10.5px; color: var(--muted); }
.tabs { display: flex; gap: 2px; border: 1px solid var(--line); border-radius: 7px; padding: 2px; background: #fff; }
.tab { height: 24px; padding: 0 9px; border: 0; border-radius: 5px; background: none; font-size: 11px; color: var(--muted); font-weight: 550; }
.tab:hover { color: var(--ink); }
.tab.active { background: var(--brand-tint); color: var(--brand); font-weight: 650; }
.doc-body { padding: 22px 26px 28px; }
.doc-title { font-family: var(--serif); font-size: 23px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
.doc-lede { font-size: 12.8px; color: var(--muted); margin-top: 7px; line-height: 1.6; max-width: 74ch; }
.doc-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.doc-sec { margin-top: 22px; }
.doc-sec > h3 { font-family: var(--serif); font-size: 16.5px; font-weight: 600; letter-spacing: -.005em; margin-bottom: 8px; padding-bottom: 5px; border-bottom: 1px solid var(--line-soft); }
.doc-sec h4 { font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-2); margin: 14px 0 6px; }
.doc-sec p { font-size: 12.6px; color: var(--ink-2); line-height: 1.68; margin: 0 0 8px; }
.doc-sec ul { padding-left: 2px; list-style: none; }
.doc-sec li { position: relative; padding-left: 14px; font-size: 12.4px; color: var(--ink-2); line-height: 1.62; margin-bottom: 4px; }
.doc-sec li::before { content: ""; position: absolute; left: 2px; top: 7px; width: 4px; height: 4px; border-radius: 50%; background: var(--line-strong); }
.doc-sec ol { padding-left: 18px; }
.doc-sec ol li { padding-left: 4px; }
.doc-sec ol li::before { display: none; }
.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); border-radius: 7px; overflow: hidden; }
.kv { background: #fff; padding: 9px 12px; }
.kv .k { font-size: 9.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.kv .v { font-size: 12px; font-weight: 550; margin-top: 1px; }
.callout { display: flex; gap: 10px; padding: 11px 13px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface-2); font-size: 11.8px; line-height: 1.55; color: var(--ink-2); }
.callout .co-ico { flex: none; width: 23px; height: 23px; border-radius: 6px; display: grid; place-items: center; background: #fff; border: 1px solid var(--line); }
.callout.info { border-color: color-mix(in srgb, var(--brand) 25%, #fff); background: var(--brand-tint); }
.callout.warn { border-color: color-mix(in srgb, var(--warn) 30%, #fff); background: var(--warn-tint); }
.callout.danger { border-color: color-mix(in srgb, var(--danger) 25%, #fff); background: var(--danger-tint); }
.callout strong { color: var(--ink); }
.src-line { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--line-soft); font-size: 11.5px; }
.src-line:last-child { border-bottom: 0; }
.src-line .u { color: var(--brand); font-family: ui-monospace, Menlo, monospace; font-size: 10.8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.origin { display: inline-flex; align-items: center; gap: 4px; font-size: 9.5px; font-weight: 650; letter-spacing: .02em; text-transform: uppercase; padding: 1px 5px; border-radius: 3px; }
.origin.verified { color: var(--ok); background: color-mix(in srgb, var(--ok) 9%, #fff); }
.origin.declared { color: var(--brand); background: var(--brand-tint); }
.origin.hyp { color: var(--brass); background: var(--brass-tint); }

/* ---------- Chat ---------- */
.chat { position: sticky; top: 68px; display: flex; flex-direction: column; height: calc(100vh - 92px); min-height: 460px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--bosia-shadow-1); overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-bottom: 1px solid var(--line-soft); background: var(--surface-2); }
.chat-head .ch-ico { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; background: var(--brand-tint); color: var(--brand); flex: none; }
.chat-head .ch-title { font-size: 11.8px; font-weight: 650; }
.chat-head .ch-sub { font-size: 10px; color: var(--muted); }
.chat-ctx { display: flex; gap: 5px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--line-soft); background: #fbfcfe; }
.chat-ctx .chip { height: 19px; font-size: 9.8px; background: #fff; }
.chat-log { flex: 1; overflow-y: auto; padding: 13px 12px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; gap: 8px; }
.msg .m-av { width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 9px; font-weight: 700; background: var(--brand-tint); color: var(--brand); }
.msg.user .m-av { background: #e9edf3; color: var(--muted); }
.msg .m-body { min-width: 0; }
.msg .m-name { font-size: 9.8px; font-weight: 700; color: var(--muted); letter-spacing: .03em; text-transform: uppercase; margin-bottom: 2px; }
.msg .m-text { font-size: 11.8px; line-height: 1.55; color: var(--ink-2); }
.msg.user .m-text { background: #f2f5f9; border: 1px solid var(--line-soft); border-radius: 7px; padding: 7px 9px; }
.msg .m-actions { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.msg .m-actions .btn { height: 24px; font-size: 10.5px; padding: 0 8px; }
.chat-note { padding: 8px 12px; border-top: 1px solid var(--line-soft); background: #fbfcfe; display: flex; gap: 7px; align-items: flex-start; font-size: 10.3px; color: var(--muted); line-height: 1.45; }
.chat-compose { border-top: 1px solid var(--line-soft); padding: 10px 12px 11px; background: #fff; }
.chat-compose .cp-box { border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 8px; background: #fff; }
.chat-compose .cp-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.chat-compose textarea { width: 100%; border: 0; resize: none; min-height: 38px; font-size: 12px; line-height: 1.5; outline: 0; background: transparent; }
.chat-compose .cp-tools { display: flex; align-items: center; gap: 3px; }
.chat-compose .cp-tools .btn { box-shadow: none; }
.chat-compose .send { margin-left: auto; width: 27px; height: 27px; border-radius: 6px; background: var(--brand); color: #fff; border: 1px solid var(--brand); display: grid; place-items: center; }
.chat-toggle { display: none; }

/* ---------- Flow diagram ---------- */
.diagram { border: 1px solid var(--line); border-radius: 8px; background: linear-gradient(180deg, #fbfcfe, #fff); padding: 12px; overflow-x: auto; }
.diagram svg { display: block; width: 100%; height: auto; min-width: 620px; }
.diagram-legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; font-size: 10.5px; color: var(--muted); }
.diagram-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }
details.code-toggle { margin-top: 10px; }
details.code-toggle summary { font-size: 10.5px; color: var(--muted); cursor: pointer; user-select: none; }
details.code-toggle pre { margin: 7px 0 0; padding: 10px; background: #0f1822; color: #c9d7e4; border-radius: 7px; font-size: 10.5px; line-height: 1.5; overflow-x: auto; }

/* ---------- Priority/severity ---------- */
.sev { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 600; }
.sev i { width: 7px; height: 7px; border-radius: 2px; }
.sev.high i { background: var(--danger); } .sev.high { color: var(--danger); }
.sev.mid i { background: var(--warn); } .sev.mid { color: var(--warn); }
.sev.low i { background: var(--ok); } .sev.low { color: var(--ok); }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 1px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 15px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ""; position: absolute; left: -17px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: #fff; border: 2px solid var(--line-strong); }
.tl-item.ok::before { border-color: var(--ok); background: var(--ok); }
.tl-item.cur::before { border-color: var(--brand); background: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.tl-item.warn::before { border-color: var(--warn); background: var(--warn); }
.tl-title { font-size: 12px; font-weight: 600; }
.tl-meta { font-size: 10.5px; color: var(--muted); margin-top: 1px; }
.tl-desc { font-size: 11.5px; color: var(--ink-2); margin-top: 4px; line-height: 1.5; }

/* ---------- Toggle switch ---------- */
.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--ink-2); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 30px; height: 17px; border-radius: 999px; background: #cfd8e3; position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(13px); }

/* ---------- Opportunities ---------- */
.opp { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--bosia-shadow-1); }
.opp + .opp { margin-top: 10px; }
.opp-head { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; }
.opp-head .op-check { margin-top: 2px; accent-color: var(--brand); }
.opp-title { font-size: 13.5px; font-weight: 650; }
.opp-problem { font-size: 11.8px; color: var(--muted); margin-top: 2px; line-height: 1.5; max-width: 80ch; }
.opp-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.opp-body { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 13px; padding: 0 16px 15px; }
.opp-body .ob-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 3px; }
.opp-body .ob-val { font-size: 11.5px; color: var(--ink-2); line-height: 1.5; }
.opp.selected { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); box-shadow: 0 0 0 3px var(--brand-tint); }
.opp details { border-top: 1px dashed var(--line-soft); }
.opp summary { padding: 9px 16px; font-size: 11px; color: var(--brand); cursor: pointer; font-weight: 550; list-style: none; }
.opp summary::-webkit-details-marker { display: none; }
.opp details .ob-grid { padding: 0 16px 14px; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }

/* ---------- PRD doc ---------- */
.prd-layout { display: grid; grid-template-columns: 196px minmax(0,1fr); gap: 16px; align-items: start; }
.prd-toc { position: sticky; top: 68px; padding: 12px; font-size: 11.2px; }
.prd-toc .toc-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 650; margin-bottom: 7px; }
.prd-toc a { display: block; padding: 3px 6px; border-radius: 4px; color: var(--muted); border-left: 2px solid transparent; line-height: 1.35; }
.prd-toc a:hover { background: var(--surface-2); color: var(--ink); }
.prd-toc a.active { color: var(--brand); border-left-color: var(--brand); background: var(--brand-tint); font-weight: 600; }
.req-id { font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; color: var(--brand); font-weight: 600; white-space: nowrap; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 34px 20px; }
.empty .e-ico { width: 40px; height: 40px; border-radius: 10px; margin: 0 auto 10px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.empty h4 { font-size: 12.5px; font-weight: 650; margin-bottom: 3px; }
.empty p { font-size: 11.5px; color: var(--muted); max-width: 44ch; margin: 0 auto 12px; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 9px; padding: 10px 13px; border-radius: 8px; background: #14202c; color: #eaf1f8; font-size: 11.8px; box-shadow: var(--bosia-shadow-2); animation: toastIn .18s ease-out; max-width: 340px; }
.toast .t-ok { color: #7fe0b3; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Sidebar backdrop ---------- */
.sb-backdrop { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .workspace { grid-template-columns: minmax(0,1fr); }
  .chat { position: fixed; top: 0; right: 0; bottom: 0; width: min(390px, 92vw); height: 100vh; border-radius: 0; z-index: 60; transform: translateX(102%); transition: transform .2s ease; box-shadow: var(--bosia-shadow-2); }
  body.chat-open .chat { transform: none; }
  body.chat-open .sb-backdrop { display: block; position: fixed; inset: 0; background: rgba(12,22,32,.4); z-index: 55; }
  .chat-toggle { display: inline-flex; }
  .prd-layout { grid-template-columns: minmax(0,1fr); }
  .prd-toc { display: none; }
}
@media (max-width: 980px) {
  .app { grid-template-columns: minmax(0,1fr); }
  .sidebar { position: fixed; left: 0; top: 0; width: 274px; transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--bosia-shadow-2); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sb-backdrop { display: block; position: fixed; inset: 0; background: rgba(12,22,32,.45); z-index: 35; }
  .btn.menu-btn { display: inline-flex; }
  .journey { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .jstep:nth-child(4) { border-right: 0; }
  .jstep:nth-child(n+5) { border-top: 1px solid var(--line-soft); }
  .grid-12 > [class*="col-"] { grid-column: span 12; }
  .split { grid-template-columns: minmax(0,1fr); }
  .content { padding: 18px 18px 48px; }
  .topbar { padding: 0 16px; }
  .topbar .crumb { flex: 1; overflow: hidden; }
  .kbd-search { display: none; }
}
@media (max-width: 700px) {
  .crumb { white-space: nowrap; min-width: 0; }
  .crumb > :not(b) { display: none; }
  .topbar { gap: 8px; }
  .row { flex-wrap: wrap; }
}
@media (max-width: 640px) {
  .page-head { flex-direction: column; gap: 10px; }
  .ph-actions { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .page-title { font-size: 23px; }
  .content { padding: 14px 12px 44px; }
  .journey { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .jstep:nth-child(2n) { border-right: 0; }
  .jstep:nth-child(n+3) { border-top: 1px solid var(--line-soft); }
  .doc-body { padding: 16px 14px 22px; }
  .stat-strip { flex-wrap: wrap; }
  .stat { flex: 1 1 45%; border-bottom: 1px solid var(--line-soft); }
  .kv-grid, .opp-body, .opp details .ob-grid { grid-template-columns: minmax(0,1fr); }
  .opp-body { gap: 9px; }
  .tbl td, .tbl th { padding: 8px 10px; }
  .hide-sm { display: none; }
  .chat { width: 100vw; }
  .top-actions .btn-export-label { display: none; }
  .doc-bar { padding: 9px 12px; }
  .diagram svg { min-width: 560px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
