/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  /* ── Redesign design tokens (2026-06 UI refresh) ──
     Warm-neutral palette + DM Sans/Mono. Legacy token names below are aliased
     to these so existing selectors restyle automatically. */
  --ink: #23211e;          /* near-black, warmer than pure */
  --ink-2: #57544e;
  --ink-3: #8c8881;
  --ink-4: #b4afa6;
  --line: #e7e6e2;
  --line-strong: #dcdbd6;
  --orange-ink: #b35e00;
  --orange-wash: #fff4e4;
  --orange-line: #ffd9a6;
  --green-wash: #e7f6ed;
  --amber-wash: #fdf3da;
  --blue-wash: #e9eefb;
  --slate-wash: #eeedea;
  --r: 10px; --r-sm: 7px; --r-lg: 14px;
  --shadow: 0 1px 2px rgba(35,33,30,.04), 0 1px 1px rgba(35,33,30,.03);
  --shadow-md: 0 4px 16px -4px rgba(35,33,30,.12), 0 2px 4px rgba(35,33,30,.05);
  --rail: 62px;

  /* Brand + semantic */
  --orange: #ff8b01;
  --green: #1f9d63;
  --amber: #c2820a;
  --blue: #3563c9;
  --purple: #6366f1;

  /* ── Legacy aliases — keep existing selectors working ── */
  --charcoal: var(--ink);
  --bg: #f6f6f4;
  --surface: #ffffff;
  --border: var(--line);
  --text: var(--ink);
  --muted: var(--ink-3);
  --green-light: var(--green-wash);
  --sidebar-w: 220px;
  --header-h: 52px;
  --pipeline-h: 56px;
  --radius: 8px;
  --font: "DM Sans", -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
body { font-family: var(--font); background: var(--bg); color: var(--text); height: 100dvh; overflow: hidden; letter-spacing: -.005em; -webkit-font-smoothing: antialiased; }
.mono { font-family: "DM Mono", ui-monospace, monospace; }
.hidden { display: none !important; }

/* ── Login ── */
#login-screen { display: flex; align-items: center; justify-content: center; height: 100dvh; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2.5rem 2rem; width: 320px; box-shadow: 0 4px 24px rgba(0,0,0,.06); }
.login-logo { display: flex; align-items: center; gap: .5rem; font-size: 1.25rem; font-weight: 700; color: var(--charcoal); margin-bottom: .25rem; }
.login-sub { color: var(--muted); font-size: .85rem; margin-bottom: 1.75rem; }
.login-box input { width: 100%; padding: .65rem .85rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .95rem; outline: none; transition: border-color .15s; margin-bottom: .5rem; }
.login-box input:focus { border-color: var(--orange); }
.login-box button { width: 100%; margin-top: .75rem; padding: .7rem; background: var(--orange); color: #fff; border: none; border-radius: var(--radius); font-size: .95rem; font-weight: 600; cursor: pointer; transition: opacity .15s; }
.login-box button:hover { opacity: .9; }
#login-error { color: #e53e3e; font-size: .82rem; margin-top: .5rem; min-height: 1.2em; }

/* ── Shared ── */
.logo-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--orange); display: inline-block; flex-shrink: 0; }
.btn-ghost { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .35rem .75rem; font-size: .82rem; font-weight: 600; color: var(--ink-2); cursor: pointer; transition: border-color .12s, color .12s, background .12s; }
.btn-ghost:hover { border-color: var(--line-strong); color: var(--ink); background: var(--bg); }
.btn-primary { background: var(--orange); color: #fff; border: 1px solid transparent; border-radius: 8px; padding: .5rem 1.1rem; font-size: .88rem; font-weight: 600; cursor: pointer; box-shadow: 0 1px 2px rgba(255,139,1,.35); transition: filter .12s; }
.btn-primary:hover { filter: brightness(1.05); opacity: 1; }
.btn-sm { padding: .35rem .7rem !important; font-size: .78rem !important; }
.btn-icon { padding: .35rem .45rem; display: flex; align-items: center; }
.btn-icon svg { width: 16px; height: 16px; }

/* status chips (shared) */
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.chip.gray { background: var(--slate-wash); color: var(--ink-2); }
.chip.green { background: var(--green-wash); color: var(--green); }
.chip.amber { background: var(--amber-wash); color: var(--amber); }
.chip.blue { background: var(--blue-wash); color: var(--blue); }

/* ── Header ── */
header { height: var(--header-h); display: flex; align-items: center; gap: 14px; padding: 0 1rem; background: var(--surface); border-bottom: 1px solid var(--line); position: fixed; top: 0; left: 0; right: 0; z-index: 10; }
.header-left { display: flex; align-items: center; gap: .85rem; min-width: 0; }
.header-title { font-weight: 700; font-size: .95rem; color: var(--ink); }
/* breadcrumb trail */
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; letter-spacing: -.02em; color: var(--ink); }
.brand .dot { width: 22px; height: 22px; border-radius: 6px; background: var(--ink); display: grid; place-items: center; color: #fff; flex: none; }
.brand .dot svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 2.2; fill: none; }
.crumbs { display: flex; align-items: center; gap: 7px; color: var(--ink-3); font-size: 12.5px; font-weight: 500; min-width: 0; }
.crumbs .sep { color: var(--ink-4); }
.crumbs .active { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30ch; }
.crumbs .ws { white-space: nowrap; text-transform: lowercase; }
.crumbs:empty { display: none; }
.pill-tag { background: var(--orange-wash); color: var(--orange-ink); border: 1px solid var(--orange-line); padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.pill-tag:empty { display: none; }
/* legacy badges — repurposed into crumb segments */
.project-badge { font-size: .75rem; background: var(--orange-wash); color: var(--orange); border: 1px solid #f9c9a9; border-radius: 4px; padding: .15rem .5rem; font-weight: 600; }
.workspace-badge { font-size: .7rem; background: var(--bg); color: var(--ink-3); border: 1px solid var(--line); border-radius: 3px; padding: .1rem .4rem; font-weight: 500; text-transform: lowercase; letter-spacing: .02em; }
.workspace-badge:empty { display: none; }
.project-type-badge { font-size: .7rem; background: var(--bg); color: var(--ink-3); border: 1px solid var(--line); border-radius: 3px; padding: .1rem .4rem; font-weight: 500; }
.header-right { display: flex; gap: .5rem; }

/* ── Top-bar kebab menu + avatar ── */
.topright { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.menu-wrap { position: relative; }
.kebab { width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--ink-2); display: grid; place-items: center; cursor: pointer; transition: background .12s, border-color .12s; }
.kebab svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.75; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.kebab:hover { background: var(--bg); color: var(--ink); }
.kebab[aria-expanded="true"] { background: var(--slate-wash); color: var(--ink); border-color: var(--line); }
.menu { position: absolute; top: 42px; right: 0; min-width: 212px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-md); padding: 6px; z-index: 50; opacity: 0; transform: translateY(-6px) scale(.98); transform-origin: top right; pointer-events: none; transition: opacity .14s ease, transform .14s ease; }
.menu.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.menu-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-4); padding: 7px 10px 4px; }
.menu-label.hidden, .menu-div.hidden { display: none !important; }
.menu button.menu-item, .menu a.menu-item { width: 100%; text-align: left; background: none; border: none; font-family: inherit; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--ink); font-size: 13.5px; font-weight: 500; cursor: pointer; }
.menu .menu-item svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 1.75; fill: none; stroke-linecap: round; stroke-linejoin: round; color: var(--ink-3); flex: none; }
.menu .menu-item:hover { background: var(--orange-wash); color: var(--orange-ink); }
.menu .menu-item:hover svg { color: var(--orange-ink); }
.menu .menu-item.danger:hover { background: #fdecec; color: #c0392b; }
.menu .menu-item.danger:hover svg { color: #c0392b; }
.menu-div { height: 1px; background: var(--line); margin: 6px 4px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg,#ffb45a,#ff8b01); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; flex: none; }

/* Account button (avatar + name) — opens the account menu */
.acct-btn { display: flex; align-items: center; gap: 8px; background: none; border: 1px solid transparent; border-radius: 999px; padding: 3px 4px 3px 10px; cursor: pointer; font-family: inherit; transition: background .12s, border-color .12s; }
.acct-btn:hover { background: var(--bg); border-color: var(--line); }
.acct-btn[aria-expanded="true"] { background: var(--slate-wash); border-color: var(--line); }
.acct-name { font-size: 13px; font-weight: 600; color: var(--ink); max-width: 16ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) { .acct-name { display: none; } }
/* Current-workspace header line inside the account menu */
.acct-ws { display: flex; flex-direction: column; gap: 2px; padding: 7px 10px 4px; }
.acct-ws-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-4); }
.acct-ws-name { font-size: 13.5px; font-weight: 600; color: var(--ink); }
/* Switch-workspace modal list */
.sw-ws-list { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; }
.sw-ws-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; font-family: inherit; font-size: 13.5px; color: var(--ink); }
.sw-ws-row:hover { background: var(--orange-wash); border-color: var(--orange); }
.sw-ws-row.current { border-color: var(--orange); background: var(--orange-wash); cursor: default; }
.sw-ws-row .sw-ws-meta { font-size: 11.5px; color: var(--ink-3); font-weight: 600; text-transform: capitalize; }

/* ── App shell ── */
#app { display: flex; flex-direction: column; height: 100dvh; }

/* ── HOME VIEW ── */
#home-view { margin-top: var(--header-h); height: calc(100dvh - var(--header-h)); overflow-y: auto; padding: 2rem; }
.home-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.home-header h1 { font-size: 1.3rem; font-weight: 700; color: var(--charcoal); }
.home-header-actions { display: flex; align-items: center; gap: 0.75rem; }
.home-header-actions #project-filter { width: auto; min-width: 140px; }
.show-deleted-toggle { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; color: var(--muted); white-space: nowrap; cursor: pointer; }
.project-card.is-deleted { opacity: 0.55; border-style: dashed; }
.project-card.is-deleted:hover { opacity: 0.75; }
.pc-deleted-actions { margin-top: 0.6rem; display: flex; gap: 0.5rem; align-items: center; }
.pc-deleted-badge { font-size: 0.72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
#no-projects { text-align: center; padding: 3rem; color: var(--muted); line-height: 2; }

/* Project cards grid */
#project-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.project-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.1rem 1.25rem; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.project-card:hover { border-color: var(--orange); box-shadow: 0 2px 12px rgba(242,101,34,.08); }
.pc-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: .6rem; }
.pc-name { font-weight: 700; font-size: .95rem; color: var(--charcoal); }
.pc-url { font-size: .78rem; color: var(--muted); margin-top: .1rem; }
.pc-status { font-size: .72rem; border-radius: 4px; padding: .15rem .5rem; font-weight: 600; flex-shrink: 0; }
.status-active { background: #e8f5e9; color: var(--green); }
.status-on_hold { background: #fff8e1; color: #f57f17; }
.status-completed { background: #ede7f6; color: #4527a0; }
.pc-meta { display: flex; gap: 1rem; margin-bottom: .75rem; }
.pc-meta span { font-size: .78rem; color: var(--muted); }
.pc-meta strong { color: var(--text); }
/* Pipeline dots */
.pipeline-dots { display: flex; align-items: center; gap: 0; }
.pipe-dot { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 700; border: 2px solid var(--border); background: var(--bg); color: var(--muted); flex-shrink: 0; }
.pipe-dot.done { background: var(--green-light); border-color: var(--green); color: var(--green); }
.pipe-dot.current { background: var(--orange-wash); border-color: var(--orange); color: var(--orange); }
.pipe-line { width: 18px; height: 2px; background: var(--border); flex-shrink: 0; }
.pipe-line.done { background: var(--green); }
/* Topic 1 Slice C — base-agent card badge (shown instead of migration dots) */
.pc-agent-badge { font-size: .72rem; font-weight: 600; border-radius: 4px; padding: .15rem .5rem; background: #ede7f6; color: #4527a0; }
.pc-updated { font-size: .72rem; color: var(--muted); margin-top: .5rem; }

/* ── PROJECT VIEW ── */
#project-view { margin-top: var(--header-h); height: calc(100dvh - var(--header-h)); display: flex; flex-direction: column; }

/* Pipeline nav */
#pipeline-nav { height: var(--pipeline-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 1rem; gap: .5rem; flex-shrink: 0; overflow-x: auto; }
#pipeline-stages { display: flex; align-items: center; gap: .25rem; flex: 1; }
.stage-btn { display: flex; align-items: center; gap: .4rem; padding: .4rem .8rem; border-radius: 6px; border: 1.5px solid transparent; background: none; cursor: pointer; font-size: .82rem; font-weight: 500; color: var(--muted); transition: all .15s; white-space: nowrap; }
.stage-btn:hover { background: var(--bg); color: var(--text); }
.stage-btn.active { border-color: var(--orange); background: var(--orange-wash); color: var(--orange); font-weight: 700; }
.stage-btn.done { color: var(--green); }
.stage-btn.done .stage-check { display: inline; }
.stage-check { display: none; font-size: .75rem; }
.stage-arrow { color: var(--border); font-size: .8rem; user-select: none; }
.stage-doc-btn { background: none; border: 1px solid var(--border); border-radius: 4px; padding: .15rem .35rem; font-size: .75rem; cursor: pointer; color: var(--muted); transition: border-color .12s, color .12s; }
.stage-doc-btn:hover { border-color: var(--orange); color: var(--orange); }

/* Body layout */
#project-view .body { display: flex; flex: 1; overflow: hidden; }

/* ── GENERAL VIEW ── */
#general-view { margin-top: var(--header-h); height: calc(100dvh - var(--header-h)); }
#general-view .body { display: flex; height: 100%; overflow: hidden; }

/* ── Sidebar ── */
aside { width: var(--sidebar-w); border-right: 1px solid var(--border); background: var(--surface); padding: 1rem .75rem; overflow-y: auto; flex-shrink: 0; display: flex; flex-direction: column; }
.sidebar-label { font-size: .72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .5rem; }
.skill-btn { display: flex; align-items: center; gap: .5rem; width: 100%; background: none; border: none; border-radius: 6px; padding: .5rem .6rem; font-size: .84rem; color: var(--text); cursor: pointer; text-align: left; transition: background .12s; }
.skill-btn:hover { background: var(--bg); }
.skill-btn.active { background: var(--orange-wash); color: var(--orange); font-weight: 600; }
.skill-icon { font-size: 1rem; flex-shrink: 0; }
.stage-skill-placeholder { font-size: .8rem; color: var(--muted); padding: .4rem .5rem; line-height: 1.5; }
.meta-row { margin-bottom: .6rem; }
.meta-row label { display: block; font-size: .72rem; color: var(--muted); margin-bottom: .2rem; }
.meta-row input, .meta-row select { width: 100%; padding: .4rem .55rem; border: 1px solid var(--border); border-radius: 5px; font-size: .8rem; outline: none; }
.meta-row input:focus { border-color: var(--orange); }
.meta-val { font-size: .8rem; color: var(--text); padding: .2rem 0; word-break: break-all; }
.meta-input { width: 100%; padding: .35rem .45rem; border: 1px solid var(--border); border-radius: 5px; font-size: .78rem; outline: none; background: var(--bg); color: var(--text); box-sizing: border-box; }
.meta-input:focus { border-color: var(--orange); }
.sidebar-meta { margin-top: auto; }
.sidebar-meta-header { display: flex; align-items: center; justify-content: space-between; margin-top: 1.5rem; }
.btn-meta-edit { background: none; border: none; cursor: pointer; font-size: .85rem; padding: .1rem .3rem; border-radius: 4px; opacity: .6; transition: opacity .15s; }
.btn-meta-edit:hover { opacity: 1; background: var(--bg); }
.meta-edit-actions { display: flex; gap: .4rem; margin-top: .5rem; }
.btn-xs-primary { padding: .3rem .7rem; font-size: .75rem; background: var(--orange); color: #fff; border: none; border-radius: 5px; cursor: pointer; font-weight: 600; }
.btn-xs-primary:hover { background: #d9541a; }
.btn-xs-ghost { padding: .3rem .7rem; font-size: .75rem; background: none; color: var(--muted); border: 1px solid var(--border); border-radius: 5px; cursor: pointer; }
.btn-xs-ghost:hover { color: var(--text); border-color: var(--text); }

/* ── Skill info panel ── */
#skill-info, #skill-info-general { border-bottom: 1px solid var(--border); background: var(--surface); padding: 1rem 1.25rem .9rem; flex-shrink: 0; }
#skill-info.collapsed, #skill-info-general.collapsed { padding-bottom: .75rem; }
#skill-info.collapsed .skill-info-cols, #skill-info-general.collapsed .skill-info-cols { display: none; }
#skill-info.collapsed .skill-info-header, #skill-info-general.collapsed .skill-info-header { margin-bottom: 0; }
.skill-info-header { display: flex; align-items: flex-start; gap: .75rem; margin-bottom: .85rem; }
.skill-info-header > span { font-size: 1.6rem; line-height: 1; flex-shrink: 0; margin-top: .1rem; }
#si-label, #si-label-g { font-size: .95rem; font-weight: 700; color: var(--charcoal); margin-bottom: .2rem; }
#si-purpose, #si-purpose-g { font-size: .82rem; color: var(--muted); line-height: 1.55; max-width: 680px; }
.si-toggle { margin-left: auto; flex-shrink: 0; background: none; border: 1px solid var(--border); border-radius: 5px; width: 24px; height: 24px; cursor: pointer; font-size: .9rem; color: var(--muted); line-height: 1; display: flex; align-items: center; justify-content: center; transition: background .15s, color .15s; }
.si-toggle:hover { background: var(--bg); color: var(--text); }
.collapsed .si-toggle { transform: rotate(180deg); }
.skill-info-cols { display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.si-col { flex: 1; padding: .7rem .9rem; }
.si-divider { width: 1px; background: var(--border); flex-shrink: 0; }
.si-col-title { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--orange); margin-bottom: .45rem; }
.si-col ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.si-col ul li { font-size: .8rem; color: var(--text); line-height: 1.45; padding-left: .9rem; position: relative; }
.si-col ul li::before { content: '›'; position: absolute; left: 0; color: var(--orange); font-weight: 700; }

/* ── Chat ── */
main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#messages, #general-messages { flex: 1; overflow-y: auto; padding: 1.5rem 1rem; display: flex; flex-direction: column; gap: 1rem; }
.msg { display: flex; flex-direction: column; max-width: 760px; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; align-items: flex-start; }
.bubble { padding: 12px 14px; border-radius: 14px; font-size: .9rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word; box-shadow: var(--shadow); }
.msg.user .bubble { background: var(--ink); color: #fff; border-top-right-radius: 5px; }
.msg.assistant .bubble { background: var(--surface); border: 1px solid var(--line); color: var(--ink); border-top-left-radius: 5px; }
.msg.assistant .bubble pre { background: #f3f3f0; border-radius: 5px; padding: .75rem; overflow-x: auto; font-size: .82rem; margin: .5rem 0; }
.msg.assistant .bubble code { font-family: 'Courier New', monospace; font-size: .85em; }
.msg.assistant .bubble h2, .msg.assistant .bubble h3, .msg.assistant .bubble h4 { margin: .75rem 0 .35rem; color: var(--charcoal); }
.msg.assistant .bubble ul, .msg.assistant .bubble ol { padding-left: 1.25rem; margin: .35rem 0; }
.msg.assistant .bubble li { margin-bottom: .2rem; }
.msg.assistant .bubble hr { border: none; border-top: 1px solid var(--border); margin: .75rem 0; }
.msg.assistant .bubble table { border-collapse: collapse; width: 100%; font-size: .83rem; margin: .5rem 0; }
.msg.assistant .bubble th { background: var(--bg); padding: .4rem .6rem; border: 1px solid var(--border); font-weight: 600; }
.msg.assistant .bubble td { padding: .35rem .6rem; border: 1px solid var(--border); }

/* Per-response Copy / Retry toolbar (under assistant messages) */
.msg-toolbar { display: flex; gap: .4rem; margin-top: .25rem; opacity: 0; transition: opacity .12s ease; }
.msg.assistant:hover .msg-toolbar, .msg-toolbar:focus-within { opacity: 1; }
.msg-tool-btn { background: none; border: 1px solid var(--border); border-radius: 5px; color: var(--muted);
  cursor: pointer; font-size: .72rem; padding: .12rem .45rem; line-height: 1.4; }
.msg-tool-btn:hover { background: var(--bg); color: var(--text); border-color: var(--orange); }

/* Long-chat nudge — fold the conversation into the Brief */
.chat-hint { align-self: stretch; display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  background: #fff7ed; border: 1px solid #fdba74; color: #9a3412; border-radius: 8px;
  padding: .5rem .75rem; font-size: .82rem; margin: .25rem 0; }
.chat-hint-actions { display: flex; gap: .5rem; align-items: center; white-space: nowrap; }
.chat-hint .btn-link { background: none; border: none; color: #c2410c; cursor: pointer; font-size: .82rem; padding: 0; text-decoration: underline; }
.chat-hint .chat-hint-dismiss { text-decoration: none; font-weight: 700; }

/* Suggested next step banner */
.next-stage-banner { align-self: flex-start; background: var(--green-light); border: 1px solid #a5d6a7; border-radius: 8px; padding: .55rem .9rem; font-size: .82rem; color: var(--green); display: flex; align-items: center; gap: .6rem; }
.next-stage-banner button { background: var(--green); color: #fff; border: none; border-radius: 5px; padding: .25rem .7rem; font-size: .78rem; cursor: pointer; font-weight: 600; }

/* Document generation status + action card */
.doc-gen-status { display: inline-flex; align-items: center; gap: .4rem; margin-top: .6rem; padding: .4rem .75rem; border-radius: 20px; font-size: .82rem; background: #f5f5f2; color: var(--muted); }
.doc-gen-status .done { color: #16a34a; }
.review-badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: .1rem .45rem; border-radius: 10px; background: #dcfce7; color: #15803d; margin-left: .3rem; }
.review-badge.revised { background: #fef9c3; color: #854d0e; }
.doc-action-card { margin-top: 1rem; padding: .9rem 1.1rem; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; }
.doc-action-card p { margin: 0 0 .7rem; font-size: .88rem; color: var(--text); }
.doc-action-btns { display: flex; gap: .5rem; flex-wrap: wrap; }
.doc-action-btns .btn-primary { padding: .4rem 1rem; font-size: .82rem; }
.doc-action-btns .btn-ghost { padding: .4rem .9rem; font-size: .82rem; }
/* Inline chat document: the live-streamed doc body + the "writing…" hint. */
.chat-doc { margin: .4rem 0; padding: .75rem 1rem; background: var(--bg); border: 1px solid var(--border); border-left: 3px solid var(--orange); border-radius: 8px; }
.chat-doc-hint { margin-top: .4rem; font-size: .8rem; font-style: italic; color: var(--ink-3); }
/* Truncation notice — the response hit its output ceiling. Warning-toned and
   not italic, so it reads as a status the user must act on, not a soft hint. */
.chat-doc-warn { font-style: normal; font-weight: 500; color: var(--warn, #b4530a); }
.doc-action-card .cac-status { margin-top: .6rem; font-size: .82rem; color: var(--ink-3); }
.doc-action-card .cac-status.hidden { display: none; }

.typing-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; margin-right: 2px; }
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100%{opacity:.2} 40%{opacity:1} }

/* ── Composer ── */
#composer { border-top: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
#composer-inner { display: flex; align-items: flex-end; gap: .5rem; padding: .75rem 1rem .5rem; }
#general-composer { display: flex; align-items: flex-end; gap: .5rem; padding: .75rem 1rem; border-top: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
/* Rest at ~3 text lines (84px ≈ 3 × 1.5 line-height @ .9rem + padding) so the
   composer is comfortable to type in; autoResize still auto-grows up to max-height,
   and min-height clamps the rendered height above the inline auto height. */
#input, #general-input { flex: 1; resize: none; border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .85rem; font-size: .9rem; font-family: var(--font); outline: none; min-height: 84px; max-height: 200px; overflow-y: auto; line-height: 1.5; transition: border-color .15s; }
#input:focus, #general-input:focus { border-color: var(--orange); }
#send-btn, #general-send-btn { width: 38px; height: 38px; background: var(--orange); border: none; border-radius: var(--radius); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: opacity .15s; }
#send-btn:hover, #general-send-btn:hover { opacity: .85; }
#send-btn svg, #general-send-btn svg { width: 16px; height: 16px; }
#send-btn:disabled, #general-send-btn:disabled { opacity: .4; cursor: not-allowed; }

/* Save stage bar */
#save-stage-bar { display: flex; align-items: center; gap: .65rem; flex-shrink: 0; }
#save-stage-hint { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.btn-save-stage { background: var(--orange); color: #fff; border: none; border-radius: 6px; padding: .35rem .9rem; font-size: .78rem; font-weight: 600; cursor: pointer; transition: opacity .15s; white-space: nowrap; flex-shrink: 0; }
.btn-save-stage:hover { opacity: .88; }

/* ── Welcome ── */
.welcome { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; color: var(--muted); text-align: center; gap: .5rem; }
.welcome h2 { color: var(--charcoal); font-size: 1.1rem; }
.welcome p { font-size: .85rem; max-width: 380px; }

/* ── Sessions panel ── */
.panel { position: fixed; inset: 0; background: var(--surface); z-index: 20; overflow-y: auto; padding: 1.5rem; }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.panel-header h2 { font-size: 1.1rem; font-weight: 700; }
.stats-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.stat-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1.1rem; min-width: 130px; }
.stat-card .stat-val { font-size: 1.4rem; font-weight: 700; color: var(--orange); }
.stat-card .stat-lbl { font-size: .75rem; color: var(--muted); margin-top: .1rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th { text-align: left; padding: .5rem .75rem; border-bottom: 2px solid var(--border); color: var(--muted); font-weight: 600; white-space: nowrap; }
td { padding: .5rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:hover td { background: var(--bg); }
#overlay { position: fixed; inset: 0; background: rgba(0,0,0,.15); z-index: 15; }

/* ── Document Editor View ── */
#document-view {
  position: fixed; inset: 0; background: var(--bg);
  z-index: 25; display: flex; flex-direction: column;
}
.dv-header {
  height: var(--header-h); display: flex; align-items: center;
  justify-content: space-between; padding: 0 1rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0; gap: 1rem;
}
.dv-title-bar { display: flex; align-items: center; gap: .5rem; flex: 1; min-width: 0; }
.dv-title-bar > span:first-child { font-weight: 700; font-size: .95rem; color: var(--charcoal); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.version-badge { font-size: .72rem; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: .1rem .45rem; color: var(--muted); flex-shrink: 0; }
.dirty-badge { font-size: .72rem; color: var(--orange); flex-shrink: 0; }
.dv-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.dv-actions select { border: 1px solid var(--border); border-radius: 6px; padding: .3rem .55rem; font-size: .8rem; color: var(--muted); background: var(--surface); cursor: pointer; outline: none; }

.dv-body { display: flex; flex: 1; overflow: hidden; }

/* Sections nav */
.dv-sections-nav { width: 240px; border-right: 1px solid var(--border); background: var(--surface); padding: 1rem .75rem; overflow-y: auto; flex-shrink: 0; }
#dv-sections-list { display: flex; flex-direction: column; gap: .15rem; margin-top: .25rem; }
.dv-section-link { background: none; border: none; text-align: left; width: 100%; padding: .35rem .5rem; font-size: .78rem; color: var(--muted); cursor: pointer; border-radius: 5px; line-height: 1.4; transition: background .1s, color .1s; white-space: normal; word-break: break-word; }
.dv-section-link:hover { background: var(--bg); color: var(--text); }
.dv-section-link.h3 { padding-left: 1rem; font-size: .74rem; }
.dv-section-link.h4 { padding-left: 1.6rem; font-size: .7rem; }

/* Editor area */
.dv-editor-wrap { flex: 1; overflow-y: auto; padding: 2rem; background: var(--bg); }
.dv-editor-inner { max-width: 860px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 2.5rem 3rem; box-shadow: 0 2px 16px rgba(0,0,0,.04); min-height: 70vh; }

/* Editor content styles — mirrors PDF typography */
#dv-editor { outline: none; font-size: .94rem; line-height: 1.65; color: var(--text); font-family: inherit; }
#dv-editor:focus { outline: none; }
#dv-editor h1 { font-size: 1.45rem; color: var(--orange); border-bottom: 2px solid #F9C9A9; padding-bottom: .3rem; margin: 1.5rem 0 .6rem; font-weight: 700; }
#dv-editor h2 { font-size: 1.1rem; font-weight: 700; color: var(--charcoal); margin: 1.2rem 0 .45rem; }
#dv-editor h3 { font-size: .97rem; font-weight: 700; color: var(--charcoal); margin: 1rem 0 .35rem; }
#dv-editor h4 { font-size: .88rem; font-weight: 600; color: var(--muted); margin: .75rem 0 .25rem; }
#dv-editor p { margin-bottom: .55rem; }
#dv-editor ul, #dv-editor ol { padding-left: 1.4rem; margin: .35rem 0 .5rem; }
#dv-editor li { margin-bottom: .25rem; font-size: .92rem; }
#dv-editor hr { border: none; border-top: 1px solid var(--border); margin: 1.1rem 0; }
#dv-editor strong { color: var(--charcoal); }
#dv-editor em { color: var(--muted); }
#dv-editor code { background: #f5f5f2; padding: .1rem .35rem; border-radius: 3px; font-family: 'Courier New', monospace; font-size: .84em; }
#dv-editor pre { background: #f5f5f2; border-radius: 6px; padding: 1rem; font-size: .82rem; overflow-x: auto; margin: .75rem 0; }

/* Section header component */
#dv-editor .section-header { margin: 1.4rem 0 .6rem; padding-bottom: .35rem; border-bottom: 2px solid var(--orange); }
#dv-editor .section-label { font-size: .68rem; font-weight: 700; color: var(--orange); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 3px; }
#dv-editor .section-title { font-size: 1.2rem; font-weight: 700; color: var(--charcoal); line-height: 1.2; }

/* Callout boxes */
#dv-editor .callout, #dv-editor blockquote { border-left: 3px solid var(--orange); background: #FFF7ED; padding: .65rem .9rem; margin: .6rem 0; border-radius: 0 6px 6px 0; }
#dv-editor .callout-blue  { border-left-color: #2563EB; background: #EFF6FF; }
#dv-editor .callout-green { border-left-color: #059669; background: #ECFDF5; }
#dv-editor .callout-red   { border-left-color: #DC2626; background: #FEF2F2; }
#dv-editor .callout-amber { border-left-color: #D97706; background: #FFFBEB; }
#dv-editor .callout p, #dv-editor blockquote p { margin-bottom: .2rem; font-size: .88rem; }
#dv-editor .callout strong { color: var(--charcoal); display: block; margin-bottom: .2rem; }

/* Tables in editor */
#dv-editor table { width: 100%; border-collapse: collapse; margin: .75rem 0; font-size: .875rem; }
#dv-editor th { background: #2D2D2D; color: white; padding: .45rem .7rem; text-align: left; font-weight: 600; font-size: .83rem; }
#dv-editor td { padding: .42rem .7rem; border-bottom: 1px solid var(--border); }
#dv-editor tr:nth-child(even) td { background: #F3F4F6; }
#dv-editor td[contenteditable="true"]:focus { background: #fffdf9 !important; outline: 2px solid var(--orange); outline-offset: -2px; border-radius: 2px; }
#dv-editor .total-row td { font-weight: 700; border-top: 2px solid var(--orange); background: var(--orange-wash) !important; color: var(--orange); }
#dv-editor .calc-total { color: var(--orange); font-weight: 700; }

/* ── Modal ── */
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 30; background: rgba(0,0,0,.2); }
.modal-box { background: var(--surface); border-radius: 12px; padding: 1.75rem; width: 440px; box-shadow: 0 8px 32px rgba(0,0,0,.12); }
.modal-wide { width: 700px; max-width: 95vw; max-height: 80vh; overflow-y: auto; }
.modal-box h2 { font-size: 1.1rem; margin-bottom: 1.25rem; }
.form-row { margin-bottom: .9rem; }
.form-row label { display: block; font-size: .8rem; font-weight: 600; color: var(--charcoal); margin-bottom: .3rem; }
.form-row .req { color: var(--orange); }
.form-row input, .form-row select { width: 100%; padding: .55rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .9rem; outline: none; }
.form-row input:focus { border-color: var(--orange); }
/* Textareas match the inputs (consistent width/padding) instead of inheriting
   uneven browser defaults; only vertical resize so they can't blow out the modal. */
.form-row textarea { width: 100%; box-sizing: border-box; padding: .55rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); font: inherit; font-size: .9rem; outline: none; resize: vertical; min-height: 64px; }
.form-row textarea:focus { border-color: var(--orange); }
textarea.meta-input { resize: vertical; min-height: 56px; font: inherit; font-size: .78rem; }
.np-opt { font-weight: normal; opacity: .6; font-size: .82em; }
.np-url-warning { margin: .35rem 0 0; font-size: .8rem; color: #b45309; }
.np-url-warning.hidden { display: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }

/* Agent picker — clickable boxes (defaults to Migration), one per enabled agent. */
.agent-box-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.agent-box {
  flex: 1 1 auto; min-width: 110px;
  display: flex; align-items: center; justify-content: center;
  padding: .55rem .75rem;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font-size: .88rem; font-weight: 600; line-height: 1.2; text-align: center;
  cursor: pointer; transition: border-color .15s, background .15s, color .15s;
}
.agent-box:hover { border-color: var(--orange); }
.agent-box.selected { border-color: var(--orange); background: var(--orange-wash); color: var(--orange); }
#sout-content { font-size: .82rem; white-space: pre-wrap; word-break: break-word; background: var(--bg); border-radius: 6px; padding: 1rem; max-height: 55vh; overflow-y: auto; line-height: 1.6; }

/* ── AUTOMATION HUB PANEL ── */
.automation-tabs { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: 1.1rem; border-bottom: 2px solid var(--border); padding-bottom: .6rem; }
.atab { background: none; border: 1px solid var(--border); border-radius: 5px; padding: .3rem .75rem; font-size: .78rem; color: var(--muted); cursor: pointer; transition: background .15s, border-color .15s, color .15s; white-space: nowrap; }
.atab:hover { border-color: var(--charcoal); color: var(--charcoal); }
.atab.active { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 600; }
.atab-count { display: inline-block; background: rgba(255,255,255,.25); border-radius: 3px; padding: 0 .35rem; font-size: .72rem; margin-left: .25rem; min-width: 1.2rem; text-align: center; }
.atab:not(.active) .atab-count { background: var(--bg); color: var(--charcoal); }
.atab-count:empty { display: none; }
.automation-section-title { font-size: .75rem; font-weight: 700; color: var(--orange); text-transform: uppercase; letter-spacing: .08em; margin-bottom: .75rem; padding-bottom: .35rem; border-bottom: 2px solid #f9c9a9; display: inline-block; }
.automation-finding { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: .75rem; }
.automation-finding-header { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; }
.automation-source-badge { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: .15rem .45rem; border-radius: 3px; color: #fff; flex-shrink: 0; }
.badge-skill-execution { background: var(--orange); }
.badge-changelog-scanner { background: var(--purple); }
.badge-platform-monitor { background: var(--blue); }
.badge-db-validator { background: var(--amber); color: var(--charcoal); }
.badge-app-monitor { background: #c62828; }
.automation-finding-origin { font-size: .75rem; color: var(--muted); }
.automation-finding-date { font-size: .75rem; color: var(--muted); margin-left: auto; }
.automation-finding-title { font-size: .9rem; font-weight: 600; color: var(--charcoal); margin-bottom: .3rem; }
.automation-finding-detail { font-size: .8rem; color: var(--muted); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; margin-bottom: .65rem; }
.automation-finding-detail.expanded { display: block; -webkit-line-clamp: unset; }
.automation-actions { display: flex; gap: .5rem; justify-content: flex-end; }
.btn-action { font-size: .78rem; padding: .3rem .7rem; border-radius: 5px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; transition: background .15s, border-color .15s; }
.btn-action:hover { background: var(--surface); border-color: var(--charcoal); }
.btn-action-primary { background: var(--orange); color: #fff; border-color: var(--orange); }
.btn-action-primary:hover { opacity: .88; }
.automation-run-row { display: flex; align-items: center; gap: .75rem; padding: .45rem 0; border-bottom: 1px solid var(--border); font-size: .82rem; }
.automation-run-row:last-child { border-bottom: none; }
.automation-status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-ok { background: var(--green); }
.dot-needs_review { background: var(--amber); }
.dot-error { background: #c62828; }
.automation-run-script { font-weight: 600; color: var(--charcoal); min-width: 160px; }
.automation-run-ts { color: var(--muted); font-size: .78rem; }
.automation-run-summary { color: var(--muted); font-size: .78rem; margin-left: auto; }
.automation-empty { text-align: center; padding: 2rem; color: var(--muted); font-size: .85rem; }

/* ── SETTINGS VIEW ── */
#settings-view { margin-top: var(--header-h); height: calc(100dvh - var(--header-h)); display: flex; flex-direction: column; overflow: hidden; }
.settings-tabs { display: flex; gap: .35rem; padding: .6rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
.settings-tab { background: none; border: 1px solid transparent; border-radius: 6px; padding: .3rem .9rem; font-size: .83rem; color: var(--muted); cursor: pointer; font-weight: 500; transition: all .15s; }
.settings-tab:hover { color: var(--charcoal); border-color: var(--border); }
.settings-tab.active { color: var(--orange); border-color: var(--orange); background: #fff9f6; font-weight: 600; }
.settings-tab-panel { flex: 1; overflow-y: auto; overflow-x: hidden; }
.settings-tab-panel#settings-panel-skills { overflow: hidden; }
.settings-wrap { max-width: 680px; margin: 0 auto; padding: 2rem; }
.settings-header { margin-bottom: 2rem; }
.settings-header h1 { font-size: 1.3rem; font-weight: 700; color: var(--charcoal); }
.settings-subtitle { font-size: .8rem; color: var(--muted); margin-top: .25rem; }
.settings-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1.5rem; overflow: hidden; }
.settings-section-title { font-size: .78rem; font-weight: 700; color: var(--orange); text-transform: uppercase; letter-spacing: .08em; padding: .75rem 1.25rem; border-bottom: 1px solid var(--border); background: #fff9f6; }
.settings-section-body { padding: 1.25rem; }
.settings-desc { font-size: .88rem; color: var(--text); line-height: 1.6; margin-bottom: 1rem; }
.settings-when { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 1rem 1.1rem; margin-bottom: 1.25rem; }
.settings-when-title { font-size: .75rem; font-weight: 700; color: var(--charcoal); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .5rem; }
.settings-when ul { padding-left: 1.2rem; }
.settings-when li { font-size: .82rem; color: var(--muted); line-height: 1.7; }
.settings-when code { font-family: monospace; background: #f0f0ee; padding: .1rem .3rem; border-radius: 3px; font-size: .8rem; color: var(--charcoal); }
.settings-btn-row { display: flex; align-items: center; gap: 1rem; }
.refresh-status { font-size: .82rem; line-height: 1.5; }
.refresh-ok { color: var(--green); }
.refresh-err { color: #c62828; }

/* ── SKILLS BROWSER ── */
.skills-browser { display: flex; height: 100%; overflow: hidden; }
.skills-browser-left { width: 256px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--surface); overflow: hidden; }
.skills-browser-toolbar { padding: .65rem .85rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.skills-browser-toolbar .btn-primary { width: 100%; font-size: .82rem; padding: .4rem .75rem; }
.skills-file-list { overflow-y: auto; flex: 1; padding-bottom: .5rem; }
.skills-list-placeholder { padding: 1.25rem .85rem; font-size: .82rem; color: var(--muted); }
.skills-folder-label { padding: .6rem .85rem .2rem; font-size: .68rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .09em; }
.skills-file-item { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .4rem .85rem; cursor: pointer; border-left: 3px solid transparent; transition: background .1s; }
.skills-file-item:hover { background: var(--bg); }
.skills-file-item.active { background: var(--orange-wash); border-left-color: var(--orange); }
.skills-file-item.active .skills-file-name { color: var(--orange); font-weight: 600; }
.skills-file-name { font-size: .82rem; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skills-status-badge { font-size: .6rem; padding: .1rem .35rem; border-radius: 3px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; flex-shrink: 0; }
.skills-status-badge.active { background: var(--green-light); color: var(--green); }
.skills-status-badge.draft { background: #fef3c7; color: #92400e; }

/* Collapsible folder tree (Skills file browser). */
.skills-tree-children { display: none; }
.skills-tree-children.open { display: block; }
.skills-tree-folder, .skills-tree-file {
  display: flex; align-items: center; gap: .35rem; padding: .3rem .5rem;
  cursor: pointer; font-size: .82rem; white-space: nowrap; transition: background .1s;
}
.skills-tree-folder:hover, .skills-tree-file:hover { background: var(--bg); }
.skills-tree-caret { display: inline-block; width: .8em; flex-shrink: 0; color: var(--muted); font-size: .7rem; }
.skills-tree-folder-name { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.skills-tree-file { border-left: 3px solid transparent; }
.skills-tree-file.active { background: var(--orange-wash); border-left-color: var(--orange); }
.skills-tree-file.active .skills-tree-file-name { color: var(--orange); font-weight: 600; }
.skills-tree-file-name { overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.skills-browser-right { flex: 1; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }
#skills-editor-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); font-size: .88rem; }
#skills-editor-panel { display: flex; flex-direction: column; height: 100%; }
.skills-editor-header { display: flex; align-items: center; gap: .75rem; padding: .6rem 1.1rem; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
#skills-editor-path { font-size: .78rem; color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#skills-editor-textarea { flex: 1; padding: 1.1rem 1.25rem; font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; font-size: .82rem; line-height: 1.75; border: none; resize: none; background: #fff; outline: none; color: var(--text); overflow-y: auto; }
.skills-editor-footer { display: flex; align-items: center; gap: 1rem; padding: .65rem 1.1rem; background: var(--surface); border-top: 1px solid var(--border); flex-shrink: 0; }
.skills-save-ok { font-size: .82rem; color: var(--green); }
.skills-save-err { font-size: .82rem; color: #c62828; }

/* ── MODAL ── */
/* Universal modal backdrop + card — used by every `.modal-backdrop > .modal-card` modal in the app
   (new-client, brief-update, brief-versions, audit-trail, file-summary, intel-view,
    brief-apply-confirm, etc.). z-index 100 sits above the brief-overlay (80) so modals
    layer correctly when opened from inside the Brief overlay. */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 24, 30, .45);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
}
.modal-card {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  width: min(560px, 100%);
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal-box { background: var(--surface); border-radius: var(--radius); padding: 1.5rem; width: 440px; max-width: calc(100vw - 2rem); box-shadow: 0 8px 32px rgba(0,0,0,.18); }
.modal-title { font-size: .95rem; font-weight: 700; color: var(--charcoal); margin-bottom: 1.25rem; }
.modal-field { margin-bottom: 1rem; }
.modal-field label { display: block; font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: .35rem; }
.modal-field input { width: 100%; padding: .55rem .85rem; border: 1px solid var(--border); border-radius: 6px; font-size: .88rem; outline: none; transition: border-color .15s; font-family: inherit; }
.modal-field input:focus { border-color: var(--orange); }
.modal-note { font-size: .78rem; color: var(--muted); margin-bottom: 1.25rem; line-height: 1.55; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; }

/* ── ARCHITECTURE VIEW ── */
#architecture-view { margin-top: var(--header-h); height: calc(100dvh - var(--header-h)); overflow-y: auto; padding: 2rem; }
.arch-wrap { max-width: 1020px; margin: 0 auto; }
.arch-header { margin-bottom: 2rem; }
.arch-header h1 { font-size: 1.3rem; font-weight: 700; color: var(--charcoal); }
.arch-subtitle { font-size: .8rem; color: var(--muted); margin-top: .25rem; }
.arch-loading { color: var(--muted); text-align: center; padding: 3rem; }
.arch-error { color: #e53e3e; text-align: center; padding: 2rem; }

/* ── Architecture tabs + live diagrams ── */
.arch-tabs { display: flex; gap: .5rem; margin: 0 0 1.2rem; }
.arch-tab { background: none; border: 1px solid transparent; border-radius: 6px; padding: .3rem .9rem; font-size: .83rem; color: var(--muted); cursor: pointer; font-weight: 500; transition: all .15s; }
.arch-tab:hover { color: var(--charcoal); border-color: var(--border); }
.arch-tab.active { color: var(--orange); border-color: var(--orange); background: #fff9f6; font-weight: 600; }
.arch-diagram { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 1.2rem; overflow-x: auto; margin: 1rem 0; }
.arch-diagram svg { display: block; margin: 0 auto; }
.arch-diagram-err { color: #e53e3e; font-size: .8rem; white-space: pre-wrap; }

/* Living architecture doc — rendered straight from ARCHITECTURE.md via renderMd
   (mirrors the Brief markdown styling). */
.arch-md { font-size: .9rem; line-height: 1.65; max-width: 1000px; }
.arch-md h2, .arch-md h3, .arch-md h4 { margin: 1.4rem 0 .5rem; font-weight: 600; line-height: 1.3; }
.arch-md h2 { font-size: 1.2rem; border-bottom: 1px solid var(--border); padding-bottom: .3rem; }
.arch-md h3 { font-size: 1.02rem; color: var(--orange); }
.arch-md h4 { font-size: .92rem; color: var(--muted); }
.arch-md p  { margin: .5rem 0; }
.arch-md ul { margin: .5rem 0; padding-left: 1.4rem; }
.arch-md li { margin: .2rem 0; }
.arch-md strong { font-weight: 600; }
.arch-md a { color: var(--orange); text-decoration: underline; }
.arch-md hr { border: 0; border-top: 1px solid var(--border); margin: 1.2rem 0; }
.arch-md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .82em; background: rgba(0,0,0,.06);
  padding: .05rem .3rem; border-radius: 3px;
}
.arch-md pre {
  background: rgba(0,0,0,.04); padding: .7rem .9rem; border-radius: 5px;
  overflow-x: auto; margin: .7rem 0; line-height: 1.4;
}
.arch-md pre code {
  background: none; padding: 0; font-size: .78rem; white-space: pre;
}
.arch-md > *:first-child { margin-top: 0; }
.arch-md .md-table {
  display: block; max-width: 100%; overflow-x: auto;
  border-collapse: collapse; margin: .8rem 0; font-size: .85rem;
}
.arch-md .md-table th,
.arch-md .md-table td {
  border: 1px solid var(--border); padding: .4rem .6rem;
  text-align: left; vertical-align: top;
  white-space: normal; word-break: break-word;
}
.arch-md .md-table th { background: rgba(0,0,0,.04); font-weight: 600; }
.arch-md .md-table tbody tr:nth-child(even) td { background: rgba(0,0,0,.02); }
.arch-md .md-table tbody tr:hover td { background: rgba(255,140,0,.06); }
.arch-section { margin-bottom: 2.5rem; }
.arch-section-title { font-size: .78rem; font-weight: 700; color: var(--orange); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 1rem; padding-bottom: .4rem; border-bottom: 2px solid #f9c9a9; display: inline-block; }

/* Pipeline */
.arch-pipeline { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; padding: 1.25rem 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.arch-stage-box { background: var(--orange-wash); border: 1px solid #f9c9a9; border-radius: 6px; padding: .45rem 1rem; font-size: .88rem; font-weight: 600; color: var(--charcoal); }
.arch-arrow { color: var(--orange); font-size: 1.3rem; line-height: 1; user-select: none; }

/* File map */
.arch-folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.arch-folder-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.arch-folder-title { font-size: .78rem; font-weight: 700; color: var(--charcoal); margin-bottom: .75rem; padding-bottom: .4rem; border-bottom: 1px solid var(--border); }
.arch-file-item { padding: .35rem 0; border-bottom: 1px solid #f0f0ee; }
.arch-file-item:last-child { border-bottom: none; }
.arch-file-name { font-size: .76rem; color: var(--orange); background: var(--orange-wash); padding: .1rem .35rem; border-radius: 3px; display: inline-block; margin-bottom: .2rem; font-family: monospace; }
.arch-file-desc { font-size: .75rem; color: var(--muted); line-height: 1.45; display: block; }

/* Lane summary cards */
.arch-lane-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.arch-lane-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; border-left: 3px solid var(--orange); }
.arch-lane-num { font-size: .68rem; font-weight: 700; color: var(--orange); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .2rem; }
.arch-lane-name { font-size: .9rem; font-weight: 700; color: var(--charcoal); margin-bottom: .4rem; }
.arch-lane-dir { font-size: .73rem; color: var(--orange); background: var(--orange-wash); padding: .1rem .35rem; border-radius: 3px; display: inline-block; margin-bottom: .5rem; font-family: monospace; }
.arch-lane-owner { font-size: .74rem; color: var(--muted); margin-bottom: .3rem; }
.arch-lane-purpose { font-size: .78rem; color: var(--charcoal); line-height: 1.45; }

/* Data flows */
.arch-flow-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 1rem; }
.arch-flow-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; }
.arch-flow { font-size: .76rem; font-family: monospace; color: var(--charcoal); line-height: 1.9; white-space: pre; overflow-x: auto; margin: 0; }

/* View toggle (Agent / Legacy) */
.arch-view-toggle { display: flex; justify-content: flex-end; gap: .35rem; margin: -1rem 0 1.5rem; }
.arch-toggle-btn { background: #fff; border: 1px solid var(--border); color: var(--muted); font-size: .73rem; font-weight: 600; padding: .35rem .8rem; border-radius: 6px; cursor: pointer; transition: all .15s; }
.arch-toggle-btn:hover { color: var(--charcoal); border-color: var(--orange); }
.arch-toggle-btn.active { background: var(--orange); color: #fff; border-color: var(--orange); }
.arch-section-lede { font-size: .8rem; color: var(--muted); margin: -.5rem 0 1rem; line-height: 1.5; max-width: 720px; }

/* Agent Stack — vertical layered diagram */
.agent-stack { display: flex; flex-direction: column; align-items: stretch; max-width: 760px; margin: 0 auto; }
.agent-layer-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--orange); border-radius: var(--radius); padding: 1rem 1.2rem; }
.agent-layer-header { display: flex; align-items: center; gap: .7rem; margin-bottom: .55rem; }
.agent-layer-num { width: 26px; height: 26px; border-radius: 50%; background: var(--orange-wash); color: var(--orange); font-size: .78rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.agent-layer-icon { font-size: 1.15rem; line-height: 1; flex-shrink: 0; }
.agent-layer-titles { flex: 1; min-width: 0; }
.agent-layer-name { font-size: .95rem; font-weight: 700; color: var(--charcoal); }
.agent-layer-tag { font-size: .72rem; color: var(--muted); margin-top: .1rem; }
.agent-layer-what { font-size: .78rem; color: var(--charcoal); line-height: 1.5; margin-bottom: .3rem; }
.agent-layer-where { font-size: .72rem; color: var(--muted); font-family: monospace; margin-bottom: .55rem; word-break: break-word; }
.agent-layer-rows { display: flex; flex-direction: column; gap: .25rem; padding-top: .5rem; border-top: 1px solid #f0f0ee; }
.agent-row { display: flex; gap: .55rem; align-items: baseline; font-size: .73rem; line-height: 1.4; }
.agent-row-key { font-family: monospace; color: var(--orange); background: var(--orange-wash); padding: .05rem .3rem; border-radius: 3px; flex-shrink: 0; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-row-val { color: var(--muted); }
.agent-stack-arrow { color: var(--orange); font-size: 1.1rem; text-align: center; line-height: 1; padding: .35rem 0; user-select: none; opacity: .65; }

/* Governance band — cross-cutting */
.governance-band { margin-top: 1.5rem; max-width: 760px; margin-left: auto; margin-right: auto; background: linear-gradient(90deg, var(--orange-wash) 0%, #fff 50%, var(--orange-wash) 100%); border: 1px dashed var(--orange); border-radius: var(--radius); padding: .9rem 1.1rem; }
.gov-band-header { font-size: .73rem; font-weight: 700; color: var(--orange); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .65rem; }
.gov-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .55rem; }
.gov-chip { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: .5rem .65rem; }
.gov-chip-name { font-size: .76rem; font-weight: 700; color: var(--charcoal); margin-bottom: .15rem; }
.gov-chip-where { font-size: .68rem; color: var(--orange); font-family: monospace; display: inline-block; margin-bottom: .25rem; word-break: break-word; }
.gov-chip-purpose { font-size: .7rem; color: var(--muted); line-height: 1.4; }

/* Per-skill context map */
.ctxmap-grid { display: flex; flex-direction: column; gap: 1.1rem; }
.ctxmap-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1.1rem; }
.ctxmap-block-title { font-size: .8rem; font-weight: 700; color: var(--charcoal); margin-bottom: .55rem; padding-bottom: .35rem; border-bottom: 1px solid var(--border); }
.ctxmap-rows { display: flex; flex-direction: column; gap: .35rem; }
.ctxmap-row { display: grid; grid-template-columns: 1.3fr 1.3fr 2fr; gap: .55rem; padding: .3rem 0; border-bottom: 1px solid #f5f5f3; font-size: .74rem; line-height: 1.45; }
.ctxmap-row:last-child { border-bottom: none; }
.ctxmap-cell-0 { font-weight: 600; color: var(--charcoal); }
.ctxmap-cell-1 { color: var(--orange); font-family: monospace; font-size: .7rem; }
.ctxmap-cell-2 { color: var(--muted); font-family: monospace; font-size: .7rem; word-break: break-word; }

/* Audit upload card */
.audit-upload-bubble { background: #f3f6ff; border-color: #c5cae9; max-width: 520px; }
.audit-upload-title { font-size: .95rem; font-weight: 700; color: var(--charcoal); margin: 0 0 .4rem; }
.audit-upload-desc { font-size: .82rem; color: var(--muted); margin: 0 0 1rem; line-height: 1.5; }
.audit-upload-steps { display: flex; flex-direction: column; gap: .9rem; }
.audit-step { display: flex; gap: .75rem; align-items: flex-start; }
.audit-step-num { flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--orange); color: #fff; font-size: .72rem; font-weight: 700; display: flex; align-items: center; justify-content: center; margin-top: .1rem; }
.audit-step strong { font-size: .83rem; color: var(--charcoal); display: block; margin-bottom: .15rem; }
.audit-step p { font-size: .78rem; color: var(--muted); margin: 0; line-height: 1.45; }

/* Version badges */
.stage-version-badge {
  font-size: .62rem; font-weight: 700; background: var(--orange); color: #fff;
  padding: .1rem .3rem; border-radius: 3px; margin-left: .3rem;
  vertical-align: middle; letter-spacing: .02em;
}
.doc-version-tag {
  display: inline-block; font-size: .72rem; font-weight: 700;
  background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7;
  padding: .1rem .4rem; border-radius: 4px; margin-left: .3rem;
  vertical-align: middle;
}

/* Coming Soon stage */
.stage-btn.coming-soon { opacity: .55; cursor: default; }
.stage-btn.coming-soon:hover { background: transparent; }
.stage-soon-badge {
  font-size: .6rem; font-weight: 700; background: #90a4ae; color: #fff;
  padding: .1rem .28rem; border-radius: 3px; margin-left: .3rem;
  vertical-align: middle; letter-spacing: .02em;
}
.coming-soon-bubble { background: #f5f5f5; border-color: #e0e0e0; max-width: 420px; text-align: center; }
.coming-soon-icon { font-size: 2rem; margin: 0 0 .4rem; }
.coming-soon-title { font-size: 1rem; font-weight: 700; color: var(--charcoal); margin: 0 0 .5rem; }
.coming-soon-desc { font-size: .83rem; color: var(--muted); line-height: 1.55; margin: 0; }

/* ── Debug Panel ── */
.debug-panel-title { display: flex; align-items: center; gap: 1rem; }
.debug-limit-label { font-size: 0.8rem; color: var(--muted); display: flex; align-items: center; gap: 0.4rem; }
.debug-limit-label input[type=number] { width: 3.5rem; padding: 2px 6px; font-size: 0.8rem; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: inherit; }
.debug-entry { border: 1px solid var(--border); border-radius: 6px; margin-bottom: 1.25rem; overflow: hidden; }
.debug-entry-header { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 1rem; background: var(--surface); flex-wrap: wrap; }
.debug-badge { font-size: 0.68rem; font-weight: 700; padding: 2px 8px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.05em; }
.debug-type-chat { background: var(--orange); color: #fff; }
.debug-type-review_check { background: #10b981; color: #fff; }
.debug-type-review_rewrite { background: #6366f1; color: #fff; }
.debug-type-complete { background: var(--muted); color: #fff; }
.debug-model { font-size: 0.72rem; font-weight: 600; font-family: monospace; color: var(--muted); }
.debug-ts, .debug-stat { font-size: 0.72rem; color: var(--muted); }
.debug-section { border-top: 1px solid var(--border); }
.debug-section-hdr { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 1rem; font-size: 0.78rem; font-weight: 600; background: var(--bg); }
.debug-char-count { font-size: 0.7rem; color: var(--muted); font-weight: 400; margin-left: auto; }
.debug-copy-btn { margin-left: auto; }
.debug-char-count + .debug-copy-btn { margin-left: 0.5rem; }
.debug-pre { margin: 0; padding: 1rem; font-size: 0.7rem; line-height: 1.5; max-height: 380px; overflow-y: auto; overflow-x: auto; white-space: pre-wrap; word-break: break-word; background: #111; color: #e5e5e5; }
.debug-footer { font-size: 0.72rem; color: var(--muted); text-align: center; padding: 0.5rem 0; }

/* ── RBAC ── */
.panel-header-actions { display: flex; align-items: center; gap: .5rem; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.role-badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: .15rem .5rem; border-radius: 4px; text-transform: capitalize; }
.role-admin { background: #fce7d6; color: #c05000; }
.role-user  { background: #e8f0fe; color: #3a5fc4; }
.status-badge { display: inline-block; font-size: .72rem; padding: .15rem .5rem; border-radius: 4px; }
.status-active  { background: var(--green-light); color: var(--green); }
.status-revoked { background: #fdecea; color: #c62828; }
.status-pending { background: #fef3c7; color: #92400e; }
tr.row-dimmed { opacity: .5; }
.member-inline-select { padding: .2rem .4rem; font-size: .8rem; border: 1px solid var(--border); border-radius: 5px; background: var(--bg); color: var(--text); }
.form-error { color: #c62828; font-size: .82rem; margin-top: .4rem; }

/* Per-Project Access — member project picker modal + project-side access list */
.mp-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; padding: .4rem .6rem; margin: .3rem 0 .6rem; }
.mp-row { display: flex; align-items: center; gap: .5rem; padding: .25rem 0; font-size: .88rem; cursor: pointer; }
.mp-row input { margin: 0; }
.access-list { display: flex; flex-direction: column; gap: .15rem; }
.access-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: .85rem; padding: .15rem 0; cursor: pointer; }
.access-row input { margin-right: .4rem; }
.access-note { color: var(--muted); font-size: .75rem; }

/* ───── Project Brief tab (T3004-005 Phase 1) ───── */
.brief-tab-btn { display: inline-flex; align-items: center; gap: .35rem; padding: .4rem .8rem; margin-right: .6rem; border-radius: 6px; border: 1.5px solid var(--border); background: #fff; cursor: pointer; font-size: .82rem; font-weight: 600; color: var(--charcoal); transition: all .15s; }
.brief-tab-btn:hover { border-color: var(--orange); color: var(--orange); }
.brief-tab-btn.active { border-color: var(--orange); background: var(--orange-wash); color: var(--orange); }

#brief-panel { display: flex; flex-direction: column; gap: .9rem; padding: 1rem 1.25rem 0; flex: 1; overflow-y: auto; }
.brief-banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1rem; background: #fff8e6; border: 1px solid #f0c46a; border-radius: 8px; font-size: .88rem; color: #6b4a10; }
.brief-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; padding-bottom: .4rem; }
.brief-badge { font-size: .72rem; padding: .15rem .55rem; border-radius: 5px; background: var(--bg); color: var(--charcoal); border: 1px solid var(--border); font-weight: 600; }
.brief-badge-locked { background: var(--orange-wash); color: var(--orange); border-color: #f0c46a; }
.brief-badge-review { background: #fff8e6; color: #6b4a10; border-color: #f0c46a; }
.brief-badge-ok { background: var(--green-light); color: var(--green); border-color: transparent; }
.brief-meta-note { font-size: .78rem; color: var(--muted); margin-left: .35rem; }
.brief-content { white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; line-height: 1.55; padding: 1rem 1.1rem; background: #fafafa; border: 1px solid var(--border); border-radius: 8px; max-height: calc(100vh - 280px); overflow-y: auto; color: var(--text); }

/* Brief Content tab — formatted markdown (overrides monospace/pre-wrap above
   via #id specificity; other consumers of .brief-content keep raw display). */
#brief-content {
  white-space: normal; word-wrap: break-word;
  font-family: inherit; font-size: .9rem; line-height: 1.65;
  padding: 1.1rem 1.3rem;
}
#brief-content h2, #brief-content h3, #brief-content h4 {
  margin: 1rem 0 .4rem; font-weight: 600; line-height: 1.3;
}
#brief-content h2 { font-size: 1.15rem; border-bottom: 1px solid var(--border); padding-bottom: .25rem; }
#brief-content h3 { font-size: 1rem; color: var(--orange); }
#brief-content h4 { font-size: .9rem; color: var(--muted); }
#brief-content p  { margin: .45rem 0; }
#brief-content ul { margin: .45rem 0; padding-left: 1.4rem; }
#brief-content li { margin: .18rem 0; }
#brief-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .82em; background: rgba(0,0,0,.06);
  padding: .05rem .3rem; border-radius: 3px;
}
#brief-content pre {
  background: rgba(0,0,0,.04); padding: .55rem .75rem; border-radius: 4px;
  overflow-x: auto; margin: .55rem 0;
}
#brief-content pre code { background: none; padding: 0; }
#brief-content hr { border: 0; border-top: 1px solid var(--border); margin: .8rem 0; }
#brief-content strong { font-weight: 600; }
#brief-content a { color: var(--orange); text-decoration: underline; }
#brief-content > *:first-child { margin-top: 0; }
#brief-content > *:last-child  { margin-bottom: 0; }
#brief-content .md-table {
  display: block; max-width: 100%; overflow-x: auto;
  border-collapse: collapse; margin: .7rem 0;
  font-size: .85rem;
}
#brief-content .md-table th,
#brief-content .md-table td {
  border: 1px solid var(--border);
  padding: .4rem .6rem;
  text-align: left; vertical-align: top;
  white-space: normal; word-break: break-word;
}
#brief-content .md-table th {
  background: rgba(0,0,0,.04); font-weight: 600;
  position: sticky; top: 0;
}
#brief-content .md-table tbody tr:nth-child(even) td { background: rgba(0,0,0,.02); }
#brief-content .md-table tbody tr:hover td { background: rgba(255,140,0,.06); }
.brief-actions { display: flex; gap: .6rem; padding-bottom: 1rem; }

/* Brief Update diff modal */
.brief-diff-card { width: min(1100px, 96vw); max-height: 92vh; display: flex; flex-direction: column; }
.brief-diff-hint { font-size: .82rem; color: var(--muted); margin-top: -.35rem; }
.brief-diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: .75rem; flex: 1; min-height: 0; }
.brief-diff-label { display: block; font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .25rem; margin-top: .5rem; }
.brief-diff-text { width: 100%; height: 50vh; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; line-height: 1.5; background: #fafafa; resize: vertical; }
.brief-diff-text:focus { outline: none; border-color: var(--orange); }


/* ───── Clients (T3004-005 Phase 6) ───── */
.clients-header-right { display: flex; gap: .5rem; align-items: center; }

#client-list { display: grid; gap: .6rem; padding: 0 1.5rem; }
.client-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.client-card:hover { border-color: var(--orange); box-shadow: 0 2px 8px rgba(242,101,34,.08); }
.client-card-main { flex: 1; min-width: 0; }
.client-name { font-size: 1rem; font-weight: 600; color: var(--charcoal); margin-bottom: .35rem; }
.client-meta { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; font-size: .82rem; color: var(--muted); }
.client-type-badge { font-size: .72rem; padding: .15rem .55rem; border-radius: 5px; font-weight: 600; text-transform: capitalize; }
.client-type-direct  { background: #eef4ff; color: #2c5fc4; }
.client-type-agency  { background: #f3e8ff; color: #7c3aed; }
.client-type-partner { background: #ecfdf5; color: #047857; }
.client-status-badge { font-size: .72rem; padding: .15rem .55rem; border-radius: 5px; }
.client-email { font-size: .8rem; color: var(--muted); }
.client-stats { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.project-count strong { color: var(--charcoal); }

.client-detail-header { display: flex; align-items: center; gap: 1rem; padding: 1.5rem 1.5rem .75rem; }
.client-detail-header h1 { flex: 1; font-size: 1.4rem; font-weight: 700; color: var(--charcoal); }
.client-detail-body { display: grid; grid-template-columns: 320px 1fr; gap: 1.5rem; padding: 0 1.5rem 1.5rem; }
.client-info-card { padding: 1rem 1.25rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.client-notes { white-space: pre-wrap; font-size: .82rem; color: var(--muted); }
.client-projects-section h2 { font-size: 1rem; font-weight: 600; color: var(--charcoal); margin-bottom: .75rem; }
#cd-projects { display: grid; gap: .5rem; }
.cd-project-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; transition: border-color .15s; }
.cd-project-row:hover { border-color: var(--orange); }
.cd-project-name { font-size: .92rem; font-weight: 600; color: var(--charcoal); }
.cd-project-url { font-size: .78rem; color: var(--muted); margin-top: .15rem; }
.cd-project-meta { display: flex; gap: .5rem; align-items: center; font-size: .78rem; }
.cd-stage { color: var(--muted); text-transform: capitalize; }
.empty-hint { font-size: .85rem; color: var(--muted); padding: 1rem; }

/* ───── Change Orders (T3004-005 Phase 1.5) ───── */
#co-panel { display: flex; flex-direction: column; gap: .9rem; padding: 1rem 1.25rem 1rem; flex: 1; overflow-y: auto; }
.co-panel-header { display: flex; align-items: center; justify-content: space-between; }
.co-panel-header h2 { font-size: 1.15rem; font-weight: 700; color: var(--charcoal); }
.co-gate-msg { padding: .75rem 1rem; background: #fff8e6; border: 1px solid #f0c46a; border-radius: 6px; color: #6b4a10; font-size: .85rem; }

.co-list { display: grid; gap: .75rem; }
.co-card { border: 1px solid var(--border); border-radius: 8px; background: #fff; overflow: hidden; }
.co-card-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .9rem 1.1rem; background: #fafafa; border-bottom: 1px solid var(--border); }
.co-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; font-weight: 700; color: var(--orange); padding: .15rem .5rem; background: var(--orange-wash); border-radius: 4px; margin-right: .5rem; }
.co-title { font-size: .95rem; font-weight: 600; color: var(--charcoal); }
.co-amounts { display: flex; gap: .5rem; align-items: center; }
.co-amount-quoted, .co-amount-awarded { font-size: .78rem; color: var(--muted); }
.co-amount-awarded { color: var(--green); font-weight: 600; }
.co-status-badge { font-size: .72rem; padding: .15rem .55rem; border-radius: 5px; font-weight: 600; text-transform: capitalize; }
.co-status-draft, .co-status-scoping { background: var(--bg); color: var(--muted); }
.co-status-quoted    { background: #fff8e6; color: #6b4a10; }
.co-status-awarded   { background: var(--green-light); color: var(--green); }
.co-status-in-progress { background: #eef4ff; color: #2c5fc4; }
.co-status-complete  { background: #e6f7ed; color: var(--green); opacity: .7; }
.co-status-cancelled { background: #fdecea; color: #c62828; }
.co-status-on-hold   { background: var(--bg); color: var(--muted); font-style: italic; }

.co-scope { padding: .9rem 1.1rem; }
.co-scope-text { width: 100%; padding: .65rem .8rem; border: 1px solid var(--border); border-radius: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; line-height: 1.5; background: #fafafa; resize: vertical; }
.co-scope-text:focus { outline: none; border-color: var(--orange); }
.co-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .65rem; }
.co-action-btn { font-size: .8rem; padding: .35rem .75rem; border-radius: 5px; cursor: pointer; }

/* ───── Files (T3004-005 Phase 2) ───── */
#files-panel { display: flex; flex-direction: column; gap: .9rem; padding: 1rem 1.25rem 1rem; flex: 1; overflow-y: auto; }
.files-count-badge { font-size: .75rem; padding: .15rem .55rem; border-radius: 5px; background: var(--bg); color: var(--charcoal); font-weight: 600; margin-left: .35rem; }
.files-hint { font-size: .82rem; color: var(--muted); padding: .5rem .25rem; }
.upload-status { padding: .65rem 1rem; background: #fff8e6; border: 1px solid #f0c46a; border-radius: 6px; font-size: .85rem; color: #6b4a10; }

.files-list { display: grid; gap: .6rem; }
.file-card { display: grid; grid-template-columns: 44px 1fr auto; gap: .75rem; padding: .85rem 1rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; align-items: start; }
.file-card-icon { font-size: 1.5rem; line-height: 1; padding-top: .15rem; }
.file-card-main { min-width: 0; }
.file-card-name { font-size: .92rem; font-weight: 600; color: var(--charcoal); margin-bottom: .25rem; word-break: break-word; }
.file-card-meta { display: flex; flex-wrap: wrap; gap: .5rem; font-size: .75rem; color: var(--muted); margin-bottom: .35rem; }
.file-kind-badge { background: var(--bg); color: var(--charcoal); padding: .1rem .45rem; border-radius: 4px; font-weight: 600; text-transform: uppercase; }
.file-co-tag { background: var(--orange-wash); color: var(--orange); padding: .1rem .45rem; border-radius: 4px; font-weight: 600; }
.file-extract-failed { background: #fde8e8; color: #b42318; padding: .1rem .45rem; border-radius: 4px; font-weight: 600; }
.file-card-failed { border-color: #f4a4a0; background: #fffafa; }
.file-card-summary { font-size: .82rem; color: var(--text); line-height: 1.5; }
.file-card-actions { display: flex; gap: .25rem; align-items: flex-start; }
.file-action-btn, .file-action-link { padding: .25rem .55rem; font-size: 1rem; border: 1px solid var(--border); border-radius: 5px; background: #fff; cursor: pointer; color: var(--charcoal); text-decoration: none; }
.file-action-btn:hover, .file-action-link:hover { border-color: var(--orange); color: var(--orange); }

/* ───── Intelligence (T3004-005 Phase 3) ───── */
#intel-panel { display: flex; flex-direction: column; gap: .9rem; padding: 1rem 1.25rem 1rem; flex: 1; overflow-y: auto; }
.intel-tabs { display: flex; flex-wrap: wrap; gap: .35rem; padding: .15rem 0 .65rem; border-bottom: 1px solid var(--border); }
.intel-tab { padding: .35rem .85rem; border: 1px solid var(--border); border-radius: 999px; background: #fff; cursor: pointer; font-size: .8rem; color: var(--charcoal); font-weight: 600; }
.intel-tab.active { background: var(--orange); color: #fff; border-color: var(--orange); }
.intel-tab-count { font-size: .7rem; opacity: .7; margin-left: .25rem; }
.intel-cards { display: grid; gap: .6rem; }
.intel-card { display: grid; grid-template-columns: 38px 1fr auto; gap: .75rem; padding: .8rem 1rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; align-items: center; }
.intel-card.disabled { background: #fafafa; opacity: .7; }
.intel-card-icon { font-size: 1.4rem; line-height: 1; }
.intel-card-main { min-width: 0; }
.intel-card-label { font-size: .9rem; font-weight: 600; color: var(--charcoal); margin-bottom: .15rem; }
.intel-card-meta { display: flex; flex-wrap: wrap; gap: .35rem; font-size: .72rem; color: var(--muted); margin-bottom: .25rem; align-items: center; }
.intel-card-short { font-size: .82rem; color: var(--text); line-height: 1.45; }
.intel-card-actions { display: flex; gap: .25rem; align-items: center; flex-direction: column; }
.intel-status-badge { font-size: .7rem; padding: .12rem .5rem; border-radius: 4px; font-weight: 600; border: 1px solid var(--border); background: #fff; }
.intel-status-ok { background: var(--green-light); color: var(--green); border-color: transparent; }
.intel-status-stale { background: #fff8e6; color: #6b4a10; border-color: #f0c46a; }
.intel-status-warn { background: var(--orange-wash); color: var(--orange); border-color: #f0c46a; }
.intel-status-disabled { background: #f4f4f4; color: var(--muted); }
.intel-status-edited { background: #eef3ff; color: #2747a8; border-color: #c4d2f5; }
.intel-status-direct { background: #fdecf0; color: #b21e3a; border-color: #f0a4b4; }

/* ── Phase 4: Stage lock badges + Financials ── */
.stage-lock-badge {
  font-size: .65rem; font-weight: 700;
  padding: .1rem .28rem; border-radius: 3px; margin-left: .25rem;
  vertical-align: middle; line-height: 1;
  background: var(--orange-wash); color: var(--orange); border: 1px solid #f0c46a;
}
.stage-lock-badge.stage-stale { background: #fff8e6; color: #6b4a10; }
.stage-lock-badge.stage-lock-stale { background: #ffeef0; color: #b21e3a; border-color: #f0a4b4; }

.fin-content { padding: .5rem 1rem 2rem; }
.fin-section { margin-top: 1.25rem; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.fin-section-title {
  background: var(--surface); padding: .5rem 1rem; font-weight: 700;
  font-size: .85rem; color: var(--charcoal); border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: .05em;
}
.fin-row {
  display: grid; grid-template-columns: 1fr 140px 130px;
  gap: .75rem; padding: .75rem 1rem;
  align-items: center; border-bottom: 1px solid var(--border);
}
.fin-row:last-child { border-bottom: none; }
.fin-row-label { font-size: .9rem; color: var(--text); }
.fin-row-meta { font-size: .72rem; color: var(--muted); margin-top: .15rem; }
.fin-row-amount { text-align: right; font-weight: 700; font-size: 1rem; color: var(--charcoal); }
.fin-row-status { text-align: right; }
.fin-badge {
  display: inline-block; font-size: .7rem; font-weight: 600;
  padding: .15rem .55rem; border-radius: 4px; border: 1px solid var(--border);
  background: #fff;
}
.fin-badge-awarded { background: var(--green-light); color: var(--green); border-color: transparent; }
.fin-badge-quoted { background: #fff8e6; color: #6b4a10; border-color: #f0c46a; }
.fin-badge-draft { background: #f4f4f4; color: var(--muted); }
.fin-badge-cancelled { background: #fdecf0; color: #b21e3a; border-color: #f0a4b4; text-decoration: line-through; }
.fin-badge-onhold { background: #f0f0f0; color: var(--muted); font-style: italic; }
.fin-caveat {
  display: inline-block; margin-left: .35rem; font-size: .7rem;
  background: var(--orange-wash); color: var(--orange); border: 1px solid #f0c46a;
  padding: .08rem .4rem; border-radius: 3px; font-weight: 600;
}
.fin-evidence { margin-left: .35rem; text-decoration: none; color: var(--orange); }

.fin-totals {
  margin-top: 1.25rem; padding: 1rem 1rem;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface);
}
.fin-totals-row {
  display: flex; justify-content: space-between;
  padding: .35rem 0; font-size: .9rem;
}
.fin-totals-row.fin-totals-grand {
  margin-top: .5rem; padding-top: .65rem;
  border-top: 1px solid var(--border);
  font-weight: 700; font-size: 1.05rem; color: var(--charcoal);
}
.fin-footer {
  margin-top: 1rem; padding-top: .75rem;
  border-top: 1px dashed var(--border);
  font-size: .72rem; color: var(--muted); text-align: right;
}

/* Phase 4 — Client detail aggregate financials strip (spec 8.5) */
.cd-fin-strip {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem;
  padding: 1rem 1.25rem; margin: 1rem 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
}
.cd-fin-cell { text-align: center; }
.cd-fin-label { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .25rem; }
.cd-fin-value { font-size: 1.05rem; font-weight: 700; color: var(--charcoal); }

/* Phase 4 — locked-stage warning banner in sidebar */
.stage-lock-warning {
  margin-top: .75rem; padding: .65rem .75rem;
  background: var(--orange-wash); border: 1px solid #f0c46a; border-radius: 5px;
}

/* ── Brief View chat (T3004-005 Phase 4+ → Phase 8 layout) ── */
#brief-panel { display: flex; flex-direction: column; min-height: 0; height: 100%; position: relative; }
.brief-chat-col {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface);
}
.brief-chat-col-full { flex: 1; }
.brief-chat-header {
  padding: .85rem 1.25rem; border-bottom: 1px solid var(--line);
  font-size: .82rem; color: var(--ink); background: var(--surface);
  display: flex; align-items: center; gap: .75rem;
}
.brief-chat-header-titles { display: flex; flex-direction: column; gap: .15rem; flex: 1; min-width: 0; }
.brief-chat-header-titles > strong { font-weight: 700; font-size: 15px; }
.brief-chat-tools { display: flex; gap: .4rem; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.btn-ghost-xs {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: .35rem .6rem; font-size: .72rem; font-weight: 600; cursor: pointer; color: var(--ink-2);
  transition: border-color .12s, color .12s, background .12s;
}
.btn-ghost-xs:hover { background: var(--bg); border-color: var(--line-strong); color: var(--ink); }
.btn-ghost-xs:disabled { opacity: .5; cursor: not-allowed; }
.brief-chat-hint { font-size: .68rem; color: var(--ink-3); font-weight: 400; }
.brief-chat-messages {
  flex: 1; overflow-y: auto; padding: .75rem 1.25rem;
  display: flex; flex-direction: column; gap: .65rem;
}
/* Agent-aware empty state shown when the project (Brief) chat thread is empty
   or cleared — orientation + status snapshot + tailored suggestion chips. */
.bc-empty { display: flex; flex-direction: column; gap: 1rem; max-width: 560px; margin: auto; padding: 1.25rem 0; }
.bc-empty-head h3 { color: var(--charcoal); font-size: 1rem; margin-bottom: .3rem; }
.bc-empty-head p { color: var(--muted); font-size: .84rem; line-height: 1.5; }
.bc-status { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: .65rem .75rem; }
.bc-status-head { font-size: .76rem; color: var(--muted); margin-bottom: .5rem; }
.bc-status-head strong { color: var(--charcoal); }
.bc-pills { display: flex; flex-wrap: wrap; gap: .35rem; }
.bc-pill { font-size: .72rem; padding: .18rem .45rem; border-radius: 999px; border: 1px solid var(--border); background: #fff; color: var(--muted); white-space: nowrap; }
.bc-pill-completed { background: var(--green-light); border-color: #c8e6c9; color: var(--green); }
.bc-pill-soon { opacity: .55; }
.bc-suggest-label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: .5rem; }
.bc-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.bc-chip { font: inherit; font-size: .8rem; padding: .4rem .7rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.bc-chip:hover { background: var(--orange-wash); border-color: var(--orange-line); color: var(--orange-ink); }
.bc-activity:empty { display: none; }
.bc-activity-list { list-style: none; display: flex; flex-direction: column; }
.bc-act-row { display: flex; align-items: flex-start; gap: .55rem; padding: .45rem 0; border-bottom: 1px solid var(--border); }
.bc-act-row:last-child { border-bottom: none; }
.bc-act-icon { flex: none; font-size: .9rem; line-height: 1.3; }
.bc-act-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.bc-act-label { font-size: .82rem; color: var(--charcoal); }
.bc-act-detail { font-size: .74rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-act-meta { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: .1rem; }
.bc-act-time { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.bc-act-actor { font-size: .68rem; color: var(--muted); opacity: .8; white-space: nowrap; }
.bc-empty-foot { font-size: .76rem; color: var(--muted); line-height: 1.5; border-top: 1px solid var(--border); padding-top: .75rem; }

/* Role-aware project open — persistent chat banner ("about this project") */
.proj-chat-banner { flex: none; border-bottom: 1px solid var(--border); background: var(--bg); padding: .6rem 1.25rem; }
.pcb-head { display: flex; align-items: center; justify-content: space-between; }
.pcb-title { font-size: .78rem; font-weight: 700; color: var(--charcoal); letter-spacing: .02em; }
.pcb-toggle { font-size: .72rem; }
.pcb-body { margin-top: .45rem; }
.pcb-desc { font-size: .84rem; color: var(--charcoal); line-height: 1.45; }
.pcb-more { font-size: .76rem; white-space: nowrap; text-decoration: none; color: var(--accent, #2a6); }
.pcb-acts-label { margin: .6rem 0 .2rem; font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.pcb-acts { max-height: 9.5rem; overflow-y: auto; }

/* Role focus highlight — deliverables / skills / guide steps for the user's role */
.deliv-focus-chip { display: inline-block; font-size: .68rem; font-weight: 700; color: #8a5a00; background: #fff3d6; border: 1px solid #f0d79a; border-radius: 999px; padding: 0 .4rem; vertical-align: middle; }
.deliv-row-focus { border-left: 3px solid #f0b429; background: linear-gradient(90deg, #fffaf0 0%, transparent 60%); }
.skill-card-focus { border-color: #f0d79a !important; box-shadow: inset 3px 0 0 #f0b429; }
.guide-step-focus { border-left: 3px solid #f0b429; }
.brief-chat-composer {
  border-top: 1px solid var(--line); padding: .85rem 1rem; background: var(--surface);
  display: flex; gap: .55rem; align-items: center;
  border: 1px solid var(--line-strong); border-radius: 12px; margin: .75rem 1rem;
  transition: border-color .12s, box-shadow .12s;
}
.brief-chat-composer:focus-within { border-color: var(--orange-line); box-shadow: 0 0 0 3px var(--orange-wash); }
.brief-chat-composer textarea {
  flex: 1; resize: none; border: none; background: none; border-radius: 0;
  padding: .25rem .1rem; font: inherit; font-size: .9rem; min-height: 24px; max-height: 140px; outline: none;
}
/* CO scoping chat: roomier multi-line input resting at ~3 rows. Enter sends,
   Shift+Enter inserts a newline; auto-grows up to max-height. Send button
   stays pinned at the bottom-right (composer keeps align-items: flex-end). */
.co-chat-col .brief-chat-composer textarea { min-height: 72px; max-height: 200px; }
#brief-chat-send {
  background: var(--orange); color: #fff; border: none; border-radius: 9px;
  width: 34px; height: 34px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 2px rgba(255,139,1,.35); transition: filter .12s; flex: none;
}
#brief-chat-send:hover { filter: brightness(1.05); }
#brief-chat-send:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
#brief-chat-send svg { width: 16px; height: 16px; }
.brief-viewer-col {
  display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding: 1rem 1.25rem 1.5rem; flex: 1;
}
/* When the chat is in the Brief panel, .msg styles need to be slightly compacted */
.brief-chat-messages .msg { margin: 0; }
.brief-chat-messages .bubble { max-width: 100%; font-size: .85rem; line-height: 1.5; }

/* Phase 8 — Brief slide-in overlay */
.brief-overlay {
  position: fixed; inset: 0; z-index: 80;
  display: flex; justify-content: flex-end;
  pointer-events: auto;
}
.brief-overlay.hidden { display: none; }
.brief-overlay-scrim {
  position: absolute; inset: 0;
  background: rgba(20, 24, 30, .35); backdrop-filter: blur(2px);
  animation: briefScrimIn .15s ease-out;
}
.brief-overlay-panel {
  position: relative; width: 62vw; max-width: 1100px; height: 100%;
  background: #fff; box-shadow: -8px 0 28px rgba(0, 0, 0, .18);
  display: flex; flex-direction: column; min-height: 0;
  animation: briefPanelIn .22s cubic-bezier(.2, .8, .25, 1);
}
.brief-overlay-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .8rem 1.1rem; border-bottom: 1px solid var(--border); background: var(--surface);
}
.brief-overlay-header strong { font-size: .95rem; }
.brief-overlay-header button {
  font-size: 1.1rem; padding: .25rem .55rem;
  background: transparent; border: 1px solid var(--border); border-radius: 5px; cursor: pointer;
}
.brief-overlay-header button:hover { background: #f5f5f5; }

@keyframes briefScrimIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes briefPanelIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .brief-overlay-scrim, .brief-overlay-panel { animation: none; }
}

/* Mobile / narrow widths */
@media (max-width: 900px) {
  .brief-overlay-panel { width: 100vw; max-width: 100vw; }
  .brief-chat-tools .btn-ghost-xs { font-size: .68rem; padding: .25rem .4rem; }
}

/* ── CO detail mode (T3004-005 Phase 4+) ── */
.co-card-clickable { cursor: pointer; }
.co-card-clickable:hover { background: #fafafa; }
.co-detail-header {
  display: flex; align-items: center; gap: 1rem;
  padding: .75rem 1.25rem; border-bottom: 1px solid var(--border);
}
.co-detail-header h2 { margin: 0; font-size: 1.1rem; flex: 1; }
/* DETAIL mode is the positioning context for the slide-over Brief drawer.
   It's also a flex column that fills #co-panel so the chat composer pins to
   the bottom (only the message list scrolls) instead of the whole panel
   scrolling and pushing the input below the fold. */
#co-detail-mode { position: relative; }
#co-detail-mode:not(.hidden) { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.co-detail-split {
  /* Chat is the full-width primary surface. Scope / Brief / Files / Deliverables
     all live in the tabbed #co-panel-drawer overlay (opened by the ☰ button). */
  display: flex; flex: 1; min-height: 0;
}
.co-chat-col {
  display: flex; flex-direction: column; min-height: 0; flex: 1; background: var(--surface);
}
.co-detail-meta {
  margin-top: 1rem; padding: .75rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 5px;
  display: flex; flex-direction: column; gap: .35rem; font-size: .82rem;
}
/* CO Brief tab body (rendered markdown, read-only). */
.co-brief-body { font-size: .85rem; line-height: 1.55; }
.co-brief-body :first-child { margin-top: 0; }
.co-brief-body :last-child { margin-bottom: 0; }

/* CO deliverables list — reuses .deliv-row styling from the project hub. */
.co-deliverables #co-deliverables-list,
#co-deliverables-list { display: flex; flex-direction: column; gap: .4rem; }

/* CO-scoped files — reuses .file-card styling from the project Files panel. */
.co-files { display: flex; flex-direction: column; gap: .4rem; }
.co-files .co-files-hint { color: var(--muted); font-size: .75rem; }
.co-files #btn-co-upload-file { align-self: flex-start; }
.co-files #co-files-list { display: flex; flex-direction: column; gap: .4rem; margin-top: .4rem; }

/* Tabbed ☰ CO panel — slide-over drawer from the right edge. */
.co-brief-drawer {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(60%, 720px);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0, 0, 0, .08);
  display: flex; flex-direction: column;
  padding: .75rem .9rem; min-height: 0;
  z-index: 20;
  transition: transform .18s ease, opacity .18s ease;
}
.co-brief-drawer.hidden {
  display: flex;            /* keep laid out so the slide transition shows */
  transform: translateX(102%); opacity: 0; pointer-events: none;
}
.co-brief-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; margin-bottom: .6rem; border-bottom: 1px solid var(--border); padding-bottom: .5rem;
}
.co-panel-tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.co-panel-tab {
  border: 1px solid transparent; background: transparent; cursor: pointer;
  padding: .3rem .65rem; border-radius: 6px; font-size: .82rem; color: var(--muted);
}
.co-panel-tab:hover { background: var(--surface-2, #f3f3f0); color: inherit; }
.co-panel-tab.active { background: var(--orange); color: #fff; font-weight: 600; }
.co-panel-body { flex: 1; min-height: 0; overflow-y: auto; }
.co-tab-pane { display: flex; flex-direction: column; gap: .65rem; }
.co-tab-pane.hidden { display: none; }
#co-tab-scope .co-scope-text { width: 100%; min-height: 240px; resize: vertical; }
@media (max-width: 1100px) {
  .co-chat-col { border-right: none; border-left: none; }
  .co-brief-drawer { width: 100%; }
}

/* ── Phase 5 — Diff view ── */
.brief-diff-view {
  font-family: 'SFMono-Regular','Consolas',monospace; font-size: .76rem;
  line-height: 1.5; max-height: 36vh; overflow: auto;
  border: 1px solid var(--border); border-radius: 5px; background: #fafafa;
  padding: .5rem .65rem; white-space: pre-wrap; word-break: break-word;
}
.diff-eq    { color: var(--muted); }
.diff-add   { background: #e6f4ea; color: #1e7d3a; padding: 0 .35rem; border-left: 3px solid #4caf50; margin: 1px 0; }
.diff-del   { background: #fdecea; color: #b21e3a; padding: 0 .35rem; border-left: 3px solid #e53935; margin: 1px 0; }
.diff-marker { display: inline-block; width: 1.2em; font-weight: 700; }
.diff-collapse { color: var(--muted); font-style: italic; padding: .15rem .35rem; opacity: .6; }
.brief-diff-stats { font-size: .72rem; margin-left: .5rem; font-weight: 600; }
.diff-stat-add { color: #1e7d3a; }
.diff-stat-del { color: #b21e3a; }

/* ── Phase 5 — Version history modal ── */
.brief-versions-layout {
  display: grid; grid-template-columns: 240px 1fr; gap: 1rem;
  margin-top: .75rem; max-height: 60vh; min-height: 0;
}
.brief-versions-list {
  border: 1px solid var(--border); border-radius: 5px;
  overflow-y: auto; max-height: 60vh;
}
.brief-version-row {
  padding: .55rem .7rem; border-bottom: 1px solid var(--border);
  cursor: pointer; font-size: .82rem;
}
.brief-version-row:hover { background: var(--surface); }
.brief-version-row.selected { background: var(--orange-wash); border-left: 3px solid var(--orange); }
.brief-version-note { font-size: .72rem; color: var(--muted); margin-top: .15rem; }
.brief-version-date { font-size: .68rem; color: var(--muted); margin-top: .1rem; }
.brief-versions-detail { display: flex; flex-direction: column; min-height: 0; }
.brief-versions-tabs { display: flex; gap: .25rem; margin-bottom: .35rem; }
.brief-versions-tab {
  background: transparent; border: 1px solid var(--border); border-radius: 4px;
  padding: .25rem .65rem; cursor: pointer; font-size: .76rem;
}
.brief-versions-tab.active { background: var(--orange); color: #fff; border-color: var(--orange); }

/* ── Phase 5 — Stale deliverables modal ── */
.stale-deliverables-list { display: flex; flex-direction: column; gap: .5rem; margin-top: .5rem; }
.stale-deliverable-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: .65rem .85rem; border: 1px solid var(--border); border-radius: 5px;
  background: #fff;
}
.stale-deliv-meta { font-size: .72rem; color: var(--muted); margin-top: .15rem; }
.brief-tab-btn-utility {
  margin-left: auto;  /* push to far right of pipeline-nav */
  background: transparent; border: 1px solid #f0c46a; color: #6b4a10;
  font-size: .72rem;
}
.brief-tab-btn-utility:hover { background: #fff8e6; }

/* ── Phase 5 — Settings toggles ── */
.settings-toggle-row {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: .65rem 0; border-top: 1px solid var(--border); cursor: pointer;
}
.settings-toggle-row:first-child { border-top: none; }
.settings-toggle-row input[type="checkbox"] { margin-top: .2rem; flex-shrink: 0; }
.settings-toggle-label { font-size: .85rem; font-weight: 600; color: var(--charcoal); }
.settings-toggle-desc { font-size: .72rem; color: var(--muted); margin-top: .15rem; }

/* ── Phase 7 — Archive wizard ── */
.archive-stepper { display: flex; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.archive-step {
  font-size: .76rem; padding: .35rem .65rem; border-radius: 4px;
  background: var(--surface); color: var(--muted);
  border: 1px solid var(--border);
}
.archive-step.active { background: var(--orange); color: #fff; border-color: var(--orange); }
.archive-step-pane { display: flex; flex-direction: column; gap: .65rem; }
.archive-warning {
  background: #fdecea; border: 1px solid #f0a4b4; color: #b21e3a;
  padding: .85rem 1rem; border-radius: 5px; margin-bottom: .75rem;
}
.archive-promote-log { margin-top: .75rem; display: flex; flex-direction: column; gap: .25rem; }
.archive-promote-row { font-size: .76rem; padding: .35rem .55rem; border-radius: 4px; }
.archive-promote-ok { background: #e6f4ea; color: #1e7d3a; }
.archive-promote-fail { background: #fdecea; color: #b21e3a; }

/* ── Phase 7 — History (audit trail) ── */
.audit-trail-list {
  max-height: 60vh; overflow-y: auto; margin-top: .5rem;
  border: 1px solid var(--border); border-radius: 5px;
}
.audit-row {
  padding: .55rem .85rem; border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: .25rem; font-size: .82rem;
}
.audit-row:last-child { border-bottom: none; }
.audit-row-main { display: flex; align-items: center; gap: .5rem; }
.audit-action-badge {
  font-size: .68rem; font-weight: 700; padding: .15rem .55rem;
  border-radius: 4px; text-transform: uppercase; letter-spacing: .03em;
}
.audit-summary { flex: 1; color: var(--text); }
.audit-expand-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 3px;
  width: 22px; height: 22px; cursor: pointer; padding: 0; line-height: 1;
}
.audit-row-meta { font-size: .68rem; color: var(--muted); }
.audit-full-pre {
  background: #fafafa; border: 1px solid var(--border); border-radius: 4px;
  padding: .5rem .65rem; font-size: .72rem; max-height: 280px; overflow: auto;
  white-space: pre-wrap; margin-top: .25rem;
}

/* ── Phase 4++ — Deliverables panel ── */
.deliv-list { display: flex; flex-direction: column; gap: 10px; padding: 0 1.25rem 2rem; }
.deliv-group-header { margin: 1.25rem 0 .5rem; font-size: .8rem; font-weight: 700; color: var(--ink);
  text-transform: uppercase; letter-spacing: .04em; border-top: 1px solid var(--line); padding-top: 1rem;
  display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.deliv-group-hint { font-size: .72rem; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink-3); }

/* ── Deliverable cards (UI redesign PR2) ── */
.deliv-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 15px 16px; box-shadow: var(--shadow);
  transition: border-color .14s, box-shadow .14s, transform .14s;
}
.deliv-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.deliv-card.is-generated { border-left: 3px solid var(--green); }
.deliv-card.is-stale { border-left: 3px solid var(--amber); }
.deliv-card.is-focus { border-left: 3px solid var(--orange); background: linear-gradient(90deg, var(--orange-wash) 0%, transparent 60%); }
.deliv-card.is-soon { opacity: .6; }
.deliv-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.deliv-card-name { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14.5px; color: var(--ink); min-width: 0; }
.deliv-card-name .ic { width: 32px; height: 32px; border-radius: 9px; background: var(--slate-wash); display: grid; place-items: center; font-size: 1rem; flex: none; }
.deliv-card.is-generated .ic { background: var(--green-wash); }
.deliv-card.is-stale .ic { background: var(--amber-wash); }
.deliv-card-name .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deliv-card-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 7px; margin-left: 42px; }
.deliv-card-meta .status { font-size: 11.5px; color: var(--ink-3); font-weight: 500; }
.deliv-card-meta .blocked { font-size: 11.5px; color: #b21e3a; font-weight: 500; }
.deliv-card-actions { display: flex; align-items: center; gap: 7px; margin-top: 12px; margin-left: 42px; flex-wrap: wrap; }
.deliv-card .btn { display: inline-flex; align-items: center; gap: 6px; font-family: inherit; font-size: 13px; font-weight: 600; padding: 7px 13px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; white-space: nowrap; text-decoration: none; transition: filter .12s, background .12s, border-color .12s; }
.deliv-card .btn-primary { background: var(--orange); color: #fff; box-shadow: 0 1px 2px rgba(255,139,1,.35); }
.deliv-card .btn-primary:hover { filter: brightness(1.05); }
.deliv-card .btn-primary:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.deliv-card .btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.deliv-card .btn-ghost:hover { border-color: var(--line-strong); color: var(--ink); background: var(--bg); }
.deliv-card .btn-sm { padding: 5px 10px; font-size: 12px; }
.deliv-row {
  display: grid; grid-template-columns: 1fr auto;
  gap: 1rem; align-items: center;
  padding: .75rem 1rem; border: 1px solid var(--border); border-radius: 6px;
  background: #fff;
}
.deliv-row-soon { opacity: .55; }
.deliv-row-label { font-size: .9rem; color: var(--text); display: flex; flex-direction: column; gap: .25rem; }
.deliv-row-label > strong + .fin-badge,
.deliv-row-label > strong + .fin-badge + .fin-badge,
.deliv-row-label > strong + .fin-badge + .fin-badge + .fin-caveat,
.deliv-row-label > strong { display: inline-block; margin-right: .35rem; }
.deliv-row-meta { font-size: .72rem; color: var(--muted); margin-top: .15rem; }
.deliv-row-actions { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.deliv-row-actions button,
.deliv-row-actions a { font-size: .76rem; }

/* Sidebar hint after retirement of per-stage chat */
.sidebar-hint {
  background: #fff8e6; border: 1px solid #f0c46a; color: #6b4a10;
  padding: .65rem .85rem; border-radius: 5px; font-size: .78rem;
  line-height: 1.55; margin-bottom: 1rem;
}
.sidebar-hint strong { color: var(--charcoal); }

/* ───── Pending Changes side panel — Brief-as-truth P6 ───── */

/* Brief panel header button (📝 Pending N) */
.brief-pending-tools-count {
  display: inline-block; min-width: 1.2em; padding: 0 .35em;
  margin-left: .3em; border-radius: 999px;
  background: var(--orange); color: #fff;
  font-size: .68rem; font-weight: 700; line-height: 1.4;
}
#brief-pending-toggle.brief-pending-tools-warn {
  background: #fff8e6; border-color: #f0c46a; color: #6b4a10;
}
#brief-pending-toggle.brief-pending-tools-warn .brief-pending-tools-count {
  background: #b45309;
}

/* Tabs inside the brief overlay panel */
.brief-overlay-tabs {
  display: flex; gap: .25rem;
  padding: .5rem .85rem 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brief-overlay-tab {
  padding: .5rem .9rem; font-size: .82rem; font-weight: 600;
  background: transparent; color: var(--muted);
  border: 1px solid transparent; border-bottom: none;
  border-top-left-radius: 6px; border-top-right-radius: 6px;
  cursor: pointer;
}
.brief-overlay-tab:hover { color: var(--charcoal); }
.brief-overlay-tab.active {
  background: #fff; color: var(--charcoal);
  border-color: var(--border);
  margin-bottom: -1px;
}
.brief-overlay-tab-count {
  display: inline-block; min-width: 1.4em; padding: .05rem .4rem;
  margin-left: .35rem; border-radius: 999px;
  background: var(--orange); color: #fff;
  font-size: .68rem; font-weight: 700; line-height: 1.4;
}
.brief-overlay-tab-count.brief-overlay-tab-count-warn {
  background: #b45309;
}

/* Pending pane container */
.brief-pending-pane {
  display: flex; flex-direction: column; min-height: 0;
  flex: 1; padding: 1rem 1.25rem 0;
}
.brief-pending-pane.hidden { display: none; }

.brief-pending-empty {
  padding: 1.5rem 1rem; text-align: center; color: var(--muted);
  font-size: .9rem; line-height: 1.5;
  border: 1px dashed var(--border); border-radius: 6px;
  background: #fafafa;
}

.brief-pending-list {
  display: flex; flex-direction: column; gap: 1rem;
  overflow-y: auto; flex: 1; padding-bottom: 1rem;
}

/* Pinned apply button at bottom of pane */
.brief-pending-apply-bar {
  position: sticky; bottom: 0; z-index: 1;
  padding: .75rem 0 1rem;
  background: linear-gradient(to top, #fff 70%, rgba(255,255,255,0));
  border-top: 1px solid var(--border);
  margin-top: .5rem;
  display: flex; justify-content: flex-end;
}
.brief-pending-apply-bar.hidden { display: none; }
.brief-pending-apply-bar .btn-primary { min-width: 200px; }

/* Diff card */
.pd-card {
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; padding: .85rem 1rem;
  display: flex; flex-direction: column; gap: .55rem;
}
.pd-card-warn {
  border-color: #f0c46a; background: #fffdf6;
}

.pd-card-header {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
}
.pd-section-pill {
  font-size: .78rem; font-weight: 700; color: var(--charcoal);
  padding: .2rem .55rem; border-radius: 5px;
  background: var(--surface); border: 1px solid var(--border);
}

.pd-status {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: .15rem .5rem; border-radius: 4px;
  border: 1px solid var(--border);
}
.pd-status-pending  { background: #f4f4f4; color: var(--muted); }
.pd-status-approved { background: var(--green-light); color: var(--green); border-color: transparent; }
.pd-status-stale    { background: #fff8e6; color: #6b4a10; border-color: #f0c46a; }

.pd-confidence {
  font-size: .68rem; font-weight: 600;
  padding: .12rem .45rem; border-radius: 4px;
  border: 1px solid var(--border); background: #fff;
}
.pd-conf-high   { background: var(--green-light); color: var(--green); border-color: transparent; }
.pd-conf-medium { background: #fff8e6; color: #6b4a10; border-color: #f0c46a; }
.pd-conf-low    { background: #fdecf0; color: #b21e3a; border-color: #f0a4b4; }

.pd-edited-badge {
  font-size: .68rem; font-weight: 600;
  padding: .12rem .45rem; border-radius: 4px;
  background: #eef3ff; color: #2747a8; border: 1px solid #c4d2f5;
}

.pd-manual-edit-banner {
  font-size: .8rem; padding: .5rem .7rem;
  background: #fff8e6; color: #6b4a10;
  border: 1px solid #f0c46a; border-radius: 5px;
}

/* Gap-audit ("possibly missed from chat") — PR3 deferred verifier */
.pd-gap-group-head {
  margin: 1rem 0 .5rem; padding: .45rem .7rem;
  font-size: .8rem; font-weight: 700; color: var(--orange-ink, #8a4a00);
  background: var(--orange-wash, #fff3ec); border: 1px solid #f0c46a;
  border-radius: 6px;
}
.pd-gap-badge {
  font-size: .68rem; font-weight: 600;
  padding: .12rem .45rem; border-radius: 4px;
  background: var(--orange-wash, #fff3ec); color: var(--orange-ink, #8a4a00);
  border: 1px solid #f0c46a;
}
.pd-card-gap { border-color: #f0c46a; }

/* Stale variant — Brief-as-truth P7 (spec §10.5) */
.pd-card-stale {
  border-color: #d4b46a; background: #fdfbf2;
}
.pd-stale-banner {
  font-size: .82rem; padding: .55rem .75rem;
  background: #fff8e6; color: #6b4a10;
  border: 1px solid #d4b46a; border-radius: 5px;
  line-height: 1.45;
}
.pd-stale-banner strong { color: #6b4a10; }

.pd-source {
  font-size: .76rem; color: var(--muted); line-height: 1.4;
}
.pd-source code {
  background: var(--surface); padding: .05rem .35rem;
  border-radius: 3px; font-size: .72rem; color: var(--charcoal);
}

.pd-toggle-row {
  display: flex; gap: .25rem; margin-bottom: .25rem;
}
.pd-toggle {
  font-size: .7rem; font-weight: 600;
  padding: .2rem .55rem; border-radius: 4px;
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  cursor: pointer;
}
.pd-toggle.active { background: var(--orange); color: #fff; border-color: var(--orange); }

.pd-content {
  word-wrap: break-word;
  font-size: .85rem; line-height: 1.6;
  padding: .75rem .9rem;
  border: 1px solid var(--border); border-radius: 5px;
  background: #fafafa; color: var(--text);
  max-height: 420px; overflow-y: auto;
  margin: 0;
}
.pd-content-old { background: #fff5f5; border-color: #f0a4b4; }
.pd-content-new { background: #f3faf3; border-color: #b6d8b6; }
.pd-content h2, .pd-content h3, .pd-content h4 {
  margin: .8rem 0 .35rem; font-weight: 600; line-height: 1.3;
}
.pd-content h2 { font-size: 1.05rem; }
.pd-content h3 { font-size: .95rem; color: var(--orange); }
.pd-content h4 { font-size: .88rem; color: var(--muted); }
.pd-content p { margin: .4rem 0; }
.pd-content ul { margin: .4rem 0; padding-left: 1.3rem; }
.pd-content li { margin: .15rem 0; }
.pd-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .8em; background: rgba(0,0,0,.06);
  padding: .05rem .3rem; border-radius: 3px;
}
.pd-content pre {
  background: rgba(0,0,0,.04); padding: .5rem .7rem; border-radius: 4px;
  overflow-x: auto; margin: .5rem 0;
}
.pd-content pre code { background: none; padding: 0; }
.pd-content hr { border: 0; border-top: 1px solid var(--border); margin: .7rem 0; }
.pd-content strong { font-weight: 600; }
.pd-content a { color: var(--orange); text-decoration: underline; }
.pd-content > *:first-child { margin-top: 0; }
.pd-content > *:last-child  { margin-bottom: 0; }
.pd-content .md-table {
  display: block; max-width: 100%; overflow-x: auto;
  border-collapse: collapse; margin: .6rem 0;
  font-size: .8rem;
}
.pd-content .md-table th,
.pd-content .md-table td {
  border: 1px solid var(--border);
  padding: .35rem .55rem;
  text-align: left; vertical-align: top;
  white-space: normal; word-break: break-word;
}
.pd-content .md-table th {
  background: rgba(0,0,0,.04); font-weight: 600;
  position: sticky; top: 0;
}
.pd-content .md-table tbody tr:nth-child(even) td { background: rgba(0,0,0,.02); }
.pd-content .md-table tbody tr:hover td { background: rgba(255,140,0,.06); }

.pd-edit-textarea {
  width: 100%; box-sizing: border-box;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .8rem; line-height: 1.55;
  padding: .55rem .7rem;
  border: 1px solid var(--orange); border-radius: 5px;
  background: #fff; color: var(--text);
  resize: vertical; min-height: 200px;
}
.pd-edit-actions {
  display: flex; gap: .4rem; margin-top: .4rem;
}

.pd-card-actions {
  display: flex; gap: .35rem; flex-wrap: wrap;
  padding-top: .25rem;
}

/* ── Org Profile (Settings) ── */
.org-upload-row {
  display: flex; gap: .5rem; flex-wrap: wrap; align-items: center;
  margin: .5rem 0;
}
.org-select, .org-file {
  padding: .35rem .5rem; border: 1px solid var(--border, #d0d5dd);
  border-radius: 6px; font-size: .85rem; background: #fff;
}
.org-doc-list { display: flex; flex-direction: column; gap: .35rem; margin-top: .5rem; }
.org-doc-row {
  display: flex; align-items: center; gap: .6rem;
  padding: .4rem .6rem; border: 1px solid var(--border, #e4e7ec);
  border-radius: 6px; background: var(--bg-subtle, #f9fafb); font-size: .85rem;
}
.org-doc-type {
  font-weight: 600; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .02em; color: var(--text-muted, #667085);
  background: #eef2f7; padding: .12rem .45rem; border-radius: 4px; white-space: nowrap;
}
.org-doc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-doc-meta { color: var(--text-muted, #98a2b3); font-size: .78rem; white-space: nowrap; }
.org-doc-del { padding: .1rem .45rem; line-height: 1; color: var(--danger, #c0392b); }
.org-card-preview {
  white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow-y: auto;
  margin: .4rem 0 0; padding: .65rem .8rem; font-size: .82rem; line-height: 1.45;
  background: #fff; border: 1px solid var(--border, #e4e7ec); border-radius: 6px;
}

/* ── Agentic confirmation cards (chat) ── */
.chat-action-card {
  margin: .5rem 0 .5rem 2.2rem; padding: .7rem .85rem;
  border: 1px solid var(--orange-line); border-left: 3px solid var(--orange);
  border-radius: 10px; background: var(--orange-wash);
  max-width: 32rem;
}
.cac-title {
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--orange-ink); margin-bottom: .2rem;
}
.cac-main { font-weight: 600; font-size: .92rem; color: var(--ink); }
.cac-scope { font-size: .84rem; color: var(--ink-2); margin-top: .25rem; line-height: 1.4; }
.cac-actions { display: flex; gap: .5rem; margin-top: .6rem; align-items: center; flex-wrap: wrap; }
.cac-actions button { padding: .3rem .8rem; font-size: .84rem; }
.cac-dl { padding: .3rem .8rem; font-size: .84rem; text-decoration: none; display: inline-block; }
.cac-status { margin-top: .45rem; font-size: .82rem; color: var(--text-body, #344054); }
.cac-doc-label { display: block; font-size: .78rem; color: var(--ink-2); margin-top: .35rem; }
.cac-doc-title {
  display: block; width: 100%; margin-top: .2rem; padding: .35rem .5rem; font-size: .88rem;
  color: var(--ink); background: var(--surface, #fff);
  border: 1px solid var(--line); border-radius: var(--r-sm, 6px); box-sizing: border-box;
}
.cac-doc-title:focus { outline: none; border-color: var(--orange); }

/* ── Brief chat attachments (Phase 3) ── */
.bc-attach-btn {
  background: none; border: none; cursor: pointer; font-size: 1.1rem;
  padding: 0 .2rem; line-height: 1; color: var(--ink-3);
  align-self: center; flex: none;
}
.bc-attach-btn:hover { color: var(--ink); }

/* ── Voice dictation mic ── */
.mic-btn.mic-live {
  color: #e5484d;
  animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .4; }
}
.bc-attachments { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 .4rem; }
.bc-attachments:not(:empty) { margin: .35rem 0; }
.bc-att-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .8rem; padding: .2rem .5rem; border-radius: 14px;
  background: var(--primary-tint, #eff4ff); color: var(--text-body, #344054);
  border: 1px solid var(--primary, #2563eb);
}
.bc-att-chip-loading { opacity: .6; border-style: dashed; }
.bc-att-chip-x {
  background: none; border: none; cursor: pointer; font-size: .72rem;
  color: var(--text-muted, #667085); padding: 0; line-height: 1;
}
.bc-att-chip-x:hover { color: var(--danger, #c0392b); }
.brief-chat-messages.bc-dragover {
  outline: 2px dashed var(--primary, #2563eb); outline-offset: -6px;
  background: var(--primary-tint, #eff4ff);
}

/* ════════════════════════════════════════════════════════════
   P2-A — 3-column project view (Rail / Work pane / Persistent chat)
   ════════════════════════════════════════════════════════════ */
#project-view .body.proj-3col { display: flex; flex: 1; min-height: 0; overflow: hidden; }

/* ── Col 1 — icon rail (62px, SVG icons) ── */
#proj-rail {
  width: var(--rail); flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 0; overflow-y: auto;
}
#proj-rail .rail-spacer { flex: 1 1 auto; min-height: .5rem; }
.rail-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 46px; background: none; border: none; border-radius: 9px;
  padding: 7px 0; cursor: pointer; color: var(--ink-3); position: relative;
  transition: background .12s, color .12s;
}
.rail-btn:hover { background: var(--bg); color: var(--ink); }
.rail-btn.active { background: var(--orange-wash); color: var(--orange-ink); }
.rail-btn.active::before {
  content: ""; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px; border-radius: 0 3px 3px 0; background: var(--orange);
}
.rail-btn .rail-ico { line-height: 1; display: grid; place-items: center; }
.rail-btn .rail-ico svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.75; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.rail-btn .rail-lbl { font-size: 9.5px; font-weight: 600; letter-spacing: .01em; text-align: center; line-height: 1.15; }
.rail-btn-utility { color: var(--amber); }

/* ── Col 2 — work pane: the active rail section (~52% of the content width).
   Collapses only when the Chat rail item is picked (chat then fills full width). ── */
#project-view #chat-area { flex: 1.05 1 0; min-width: 320px; max-width: none; display: flex; flex-direction: column; overflow: hidden; border-right: 1px solid var(--line); }
#project-view #chat-area.collapsed { display: none; }
#project-view #chat-area > div:not(.hidden):not(.modal-backdrop) { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
#project-view #brief-panel:not(.hidden) { display: flex; flex-direction: column; overflow: hidden; }

/* Brief viewer — inline in Col 2 (was a right-slide overlay) */
.brief-overlay-inline { position: static !important; inset: auto !important; z-index: auto !important;
  display: flex !important; justify-content: stretch; flex: 1 1 auto; min-height: 0; pointer-events: auto; }
.brief-overlay-inline .brief-overlay-panel {
  position: static !important; width: 100% !important; max-width: none !important; height: 100%;
  box-shadow: none !important; border: none !important; transform: none !important; animation: none !important;
}

/* CO detail — inline tabs (drawer removed) */
.co-panel-tabs-inline { padding: .6rem 1.25rem 0; border-bottom: 1px solid var(--border); }

/* Edit / Skills / Guide panes */
.edit-pane-meta { max-width: 560px; padding: 1rem 1.25rem; }
.edit-pane-meta .sidebar-meta-header { margin-top: 0; }
.skills-catalog { display: flex; flex-direction: column; gap: .55rem; padding: .5rem 1.25rem 1.25rem; }
.skills-catalog .skill-card { border: 1px solid var(--border); border-radius: 8px; padding: .7rem .85rem; background: var(--surface); }
.skills-catalog .skill-card h4 { margin: 0 0 .25rem; font-size: .9rem; color: var(--charcoal); display: flex; align-items: center; gap: .4rem; }
.skills-catalog .skill-card p { margin: 0; font-size: .8rem; color: var(--muted); line-height: 1.5; }
/* Modules pane (Module Knowledge System) */
.modules-layout { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 1rem; padding: .5rem .25rem; align-items: start; }
.modules-list { display: flex; flex-direction: column; gap: .4rem; max-height: 70vh; overflow-y: auto; }
.module-row { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .65rem; background: var(--surface); cursor: pointer; }
.module-row:hover { border-color: var(--orange); }
.module-row.active { border-color: var(--orange); background: #fff7f2; }
.module-row-main { font-size: .88rem; color: var(--charcoal); font-weight: 600; }
.module-row-sub { font-size: .76rem; color: var(--muted); margin-top: .15rem; line-height: 1.4; }
.module-code { font-family: monospace; font-size: .72rem; color: var(--orange); margin-right: .3rem; }
.module-ver { font-size: .7rem; color: var(--muted); font-weight: 500; }
.module-detail { border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.15rem; background: var(--surface); min-height: 120px; }
.module-detail-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.module-detail-head h3 { font-size: 1rem; color: var(--charcoal); margin: 0; }
.module-detail-actions { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }
.module-detail-actions a.btn-sm { text-decoration: none; }
.module-summary { font-size: .85rem; color: var(--muted); margin: .4rem 0 .6rem; }
.module-doc { font-size: .85rem; line-height: 1.6; }
.module-doc h2 { font-size: .92rem; color: var(--charcoal); margin: 1rem 0 .35rem; }
.module-history { margin-top: 1rem; font-size: .8rem; color: var(--muted); }
.module-history summary { cursor: pointer; }
.module-history ul { margin: .4rem 0 0; padding-left: 1.1rem; }
.module-field { display: block; font-size: .8rem; color: var(--charcoal); margin-bottom: .7rem; }
.module-field input, .module-field textarea { width: 100%; margin-top: .25rem; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; font-size: .85rem; }
.module-field textarea { resize: vertical; }
.module-form-actions { display: flex; align-items: center; gap: .5rem; }
.module-form-status { font-size: .78rem; color: var(--muted); }

/* CO ↔ module links (PR2) + derived "Changed by" + materialize review modal */
.co-mod-list { display: flex; flex-direction: column; gap: .5rem; margin: .6rem 0; }
.co-mod-link { border: 1px solid var(--border); border-radius: 8px; padding: .55rem .65rem; background: var(--surface); }
.co-mod-link-main { font-size: .86rem; color: var(--charcoal); font-weight: 600; }
.co-mod-note { font-size: .78rem; color: var(--muted); margin-top: .2rem; }
.co-mod-link-actions { display: flex; align-items: center; gap: .4rem; margin-top: .45rem; }
.co-mod-done { font-size: .78rem; color: var(--success, #1a7f37); font-weight: 600; }
.co-mod-intent { font-size: .68rem; padding: .1rem .4rem; border-radius: 4px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.co-mod-intent-create { background: #e6f4ea; color: #1a7f37; }
.co-mod-intent-update { background: #fff3e0; color: #b5560a; }
.co-mod-intent-remove { background: #fde8e8; color: #b42318; }
.co-mod-addform { display: flex; flex-direction: column; gap: .45rem; margin-top: .9rem; padding-top: .8rem; border-top: 1px dashed var(--border); }
.co-mod-addform select, .co-mod-addform input, .co-mod-addform textarea { padding: .4rem .55rem; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; font-size: .84rem; }
.co-mod-addform textarea { resize: vertical; }
.co-mod-status { font-size: .78rem; color: var(--muted); }
.module-changedby { margin-top: 1rem; }
.module-changedby h4 { font-size: .82rem; color: var(--charcoal); margin: 0 0 .35rem; }
.module-changedby ul { margin: 0; padding-left: 1.1rem; font-size: .8rem; color: var(--muted); line-height: 1.6; }
.mat-sections { display: flex; flex-direction: column; gap: .6rem; margin: .6rem 0; }
.mat-sec { display: block; font-size: .8rem; color: var(--charcoal); }
.mat-sec input, .mat-sec textarea { width: 100%; margin-top: .25rem; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; font-size: .84rem; }
.mat-sec textarea { resize: vertical; }
.mat-status { font-size: .78rem; color: var(--muted); margin-left: .5rem; }
@media (max-width: 720px) { .modules-layout { grid-template-columns: 1fr; } }

.guide-body { padding: .5rem 1.5rem 1.5rem; max-width: 760px; }
.guide-title { font-size: 1rem; color: var(--charcoal); margin: .4rem 0 .5rem; display: flex; align-items: center; gap: .5rem; }
.guide-step-count { font-size: .7rem; font-weight: 600; color: var(--orange); background: var(--orange-wash); border-radius: 10px; padding: .1rem .5rem; }
.guide-intro { font-size: .85rem; color: var(--muted); line-height: 1.6; margin-bottom: 1rem; }
.guide-steps { display: flex; flex-direction: column; gap: .5rem; }
.guide-step { display: flex; gap: .7rem; border: 1px solid var(--border); border-radius: 8px; padding: .7rem .85rem; background: var(--surface); }
.guide-step-num { flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--orange); color: #fff; font-size: .75rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.guide-step-body { min-width: 0; }
.guide-step-body h4 { margin: 0 0 .2rem; font-size: .88rem; color: var(--charcoal); font-weight: 600; }
.guide-step-ico { margin-right: .15rem; }
.guide-step-body p { margin: 0; font-size: .8rem; color: var(--muted); line-height: 1.5; }
.guide-step-produces { margin-top: .3rem !important; color: var(--text) !important; }
.guide-step-lock { font-size: .68rem; font-weight: 600; color: #b45309; background: #fffbeb; border: 1px solid #fde68a; border-radius: 5px; padding: 0 .3rem; white-space: nowrap; }

/* ── Col 3 — persistent chat: always visible alongside the work pane (~48%). ── */
#proj-chat {
  flex: .95 1 0; min-width: 0; border-left: none; border-right: none;
  background: var(--surface); padding: 0; overflow: hidden;
  display: flex; flex-direction: column;
}
#proj-chat .brief-chat-col { flex: 1 1 auto; min-height: 0; height: 100%; }

/* ── Projects table view (dense alternative to the card grid) ── */
.proj-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; font-size: .875rem; }
.proj-table th { text-align: left; padding: .6rem .8rem; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--border); cursor: pointer; user-select: none; white-space: nowrap; background: var(--surface); }
.proj-table th:hover { color: var(--ink, #222); }
.proj-table td { padding: .6rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.proj-table tbody tr { cursor: pointer; transition: background .1s; }
.proj-table tbody tr:hover { background: rgba(0,0,0,.03); }
.proj-table tbody tr:last-child td { border-bottom: none; }
.proj-table tbody tr.is-deleted { cursor: default; opacity: .55; }
.proj-table tbody tr.is-deleted:hover { background: none; }
.proj-table .pt-name { font-weight: 600; }
.proj-table .pt-url { font-size: .78rem; color: var(--muted); }
.proj-table .pt-progress, .proj-table .pt-updated { white-space: nowrap; color: var(--muted); }
#project-search { min-width: 180px; }

/* Table view: the list container leaves the card grid (320px tracks would
   squeeze the table) and becomes a full-width block; horizontal scroll on
   narrow screens keeps the page from overflowing. */
#project-list.as-table { display: block; width: 100%; overflow-x: auto; }
#project-list.as-table .proj-table { min-width: 720px; }
