  :root {
    --bg: #0f1216; --panel: #171c22; --panel2: #1e242c; --line: #2a323c;
    --fg: #e6edf3; --muted: #8b97a6; --accent: #4c8dff; --accent2: #2d6fe0;
    --done: #3fb950; --planning: #d29922; --active: #4c8dff; --blocked: #f85149;
    --review: #a371f7; --unknown: #6e7681; --radius: 10px;
    --sidebar-w: 232px;
    /* Design tokens (Wave 2). Contrast verified WCAG AA: --fg on --bg ~15:1,
       --muted on --panel ~5.1:1 (dark) / ~5.8:1 (light) — both >= 4.5:1. */
    --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 22px; --sp-6: 32px;
    --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-pill: 999px;
    --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-lg: 17px; --fs-xl: 22px;
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Consolas", monospace;
    /* Real header height — synced from JS (syncHeaderH) on load+resize so sticky
       table headers offset by the live header, not a hardcoded 56px. */
    --header-h: 56px;
  }
  @media (prefers-color-scheme: light) {
    :root { --bg:#f4f6f9; --panel:#fff; --panel2:#f0f3f7; --line:#e1e7ee;
            --fg:#1b2027; --muted:#5b6675; }
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; }
  body {
    background: var(--bg); color: var(--fg);
    font: var(--fs-md)/1.5 var(--font-sans);
    display: flex; min-height: 100vh;
  }
  /* Monospace for identifiers/hashes/code so slugs and key ids read precisely. */
  code, kbd, samp, pre, .mono, .key-id, .hashid { font-family: var(--font-mono); }

  /* ── Grouped left sidebar (Wave-1 IA) ─────────────────────────────────── */
  .sidebar {
    flex: 0 0 var(--sidebar-w); width: var(--sidebar-w);
    background: var(--panel); border-right: 1px solid var(--line);
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    display: flex; flex-direction: column; gap: 2px; padding: 14px 10px;
  }
  body:not(.authed) .sidebar { display: none; }   /* no nav on the login screen */
  .brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 14px; }
  .brand-mark { width: 24px; height: 24px; color: var(--accent); flex: 0 0 24px; }
  .brand-name { font-size: 16px; font-weight: 680; letter-spacing: .3px; }
  .nav { display: flex; flex-direction: column; gap: 12px; }
  .nav-group { display: flex; flex-direction: column; gap: 1px; }
  .nav-group-label {
    font-size: 10.5px; font-weight: 600; letter-spacing: .7px; text-transform: uppercase;
    color: var(--muted); padding: 4px 10px 3px; opacity: .8;
  }
  .navlink {
    display: flex; align-items: center; gap: 10px;
    color: var(--muted); text-decoration: none; font-size: 13.5px;
    padding: 7px 10px; border-radius: 8px; transition: background .15s, color .15s;
  }
  .navlink:hover { color: var(--fg); background: var(--panel2); }
  .navlink.on { color: var(--fg); background: var(--panel2); box-shadow: inset 2px 0 0 var(--accent); }
  .ico { width: 18px; height: 18px; flex: 0 0 18px; }

  /* ── Content column + slim topbar ─────────────────────────────────────── */
  .content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  header.topbar {
    display: flex; align-items: center; gap: 12px; padding: 10px 22px;
    border-bottom: 1px solid var(--line); background: var(--panel);
    position: sticky; top: 0; z-index: 10;
  }
  header .spacer { flex: 1; }
  .crumb { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50vw; }
  .topbar-search { margin: 0; max-width: 260px; }
  .icobtn { display: inline-flex; align-items: center; justify-content: center; padding: 6px 9px; }
  #navtoggle { display: none; }   /* shown only on narrow viewports */

  /* ── Wave 1.2: focus-visible, active-nav, responsive off-canvas, motion ── */
  a:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px;
  }
  .navlink[aria-current="page"] { color: var(--fg); background: var(--panel2); box-shadow: inset 2px 0 0 var(--accent); }
  .nav-backdrop { display: none; }
  @media (max-width: 860px) {
    #navtoggle { display: inline-flex; }
    .sidebar {
      position: fixed; top: 0; left: 0; z-index: 40; height: 100vh;
      transform: translateX(-100%); transition: transform .2s ease;
      box-shadow: 2px 0 16px rgba(0,0,0,.4);
    }
    body.nav-open .sidebar { transform: none; }
    body:not(.authed) .sidebar { display: none; }
    .nav-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30; }
    body.nav-open .nav-backdrop { display: block; }
    .crumb { max-width: 34vw; }
    main { padding: 16px; }
  }
  @media (prefers-reduced-motion: reduce) {
    .sidebar { transition: none; }
    .navlink, .card { transition: none; }
  }
  .pill {
    font-size: 12px; color: var(--muted); border: 1px solid var(--line);
    border-radius: 999px; padding: 3px 10px; white-space: nowrap;
  }
  .pill.ok { color: var(--done); border-color: var(--done); }
  .pill.err { color: var(--blocked); border-color: var(--blocked); }
  button {
    font: inherit; cursor: pointer; border: 1px solid var(--line);
    background: var(--panel2); color: var(--fg); border-radius: 8px;
    padding: 6px 12px;
  }
  button:hover { border-color: var(--accent); }
  button.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
  button:disabled, button[aria-busy="true"] { opacity: .55; cursor: not-allowed; }
  button[aria-busy="true"] { pointer-events: none; }

  /* ── Wave 2.2: one form-control base (text inputs / select / textarea) ─── */
  /* Unifies the 5+ ad-hoc input rules onto the token system; component rules
     still override sizing. Catches previously-unstyled controls (e.g. the
     topbar search) that fell back to an ugly browser default on the dark bg. */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea {
    font: inherit; color: var(--fg); background: var(--panel2);
    border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 10px;
  }
  input:not([type="checkbox"]):not([type="radio"])::placeholder, textarea::placeholder { color: var(--muted); }

  /* Consistent empty-state utility (icon + message) across views. */
  .empty {
    color: var(--muted); text-align: center; padding: var(--sp-6) var(--sp-4);
    border: 1px dashed var(--line); border-radius: var(--r-md); background: var(--panel);
  }
  .empty svg { width: 28px; height: 28px; opacity: .5; margin-bottom: var(--sp-2); }
  main { padding: 22px; max-width: 1200px; margin: 0 auto; }
  .grid {
    display: grid; gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
  .card {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 16px; cursor: pointer;
    transition: border-color .12s, transform .12s;
  }
  .card:hover { border-color: var(--accent); transform: translateY(-2px); }
  .card h3 { margin: 0 0 4px; font-size: 15px; text-transform: capitalize; }
  .card .total { font-size: 26px; font-weight: 680; }
  .card .total small { font-size: 12px; color: var(--muted); font-weight: 400; }
  .bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin: 12px 0 10px; background: var(--panel2); }
  .bar span { display: block; height: 100%; }
  .legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--muted); }
  .legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
  .sw-done { background: var(--done); } .sw-planning { background: var(--planning); }
  .sw-active { background: var(--active); } .sw-blocked { background: var(--blocked); }
  .sw-review { background: var(--review); } .sw-unknown { background: var(--unknown); }
  .meta { color: var(--muted); font-size: 12px; margin-top: 8px; }

  .toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
  .chip {
    font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
    background: var(--panel); color: var(--muted); cursor: pointer;
  }
  .chip.on { color: #fff; border-color: var(--accent2); background: var(--accent2); }
  /* P0a-1 sticky-header fix: the table no longer owns an `overflow:hidden`
     scroll container (that broke `position:sticky` on th — it stuck to the
     non-scrolling table). The PAGE scrolls; `border-collapse:separate` keeps the
     sticky header's bottom border (collapse drops it on scroll → phantom gap).
     The lost border is restored via an inset box-shadow on th. */
  table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
  th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
  th { color: var(--muted); font-weight: 600; background: var(--panel2); position: sticky; top: var(--header-h); z-index: 5; box-shadow: inset 0 -1px 0 var(--line); }
  /* separate borders don't auto-round the table corners — clip the first/last
     header & footer cells so the radius is preserved without overflow:hidden. */
  thead tr:first-child th:first-child { border-top-left-radius: var(--radius); }
  thead tr:first-child th:last-child  { border-top-right-radius: var(--radius); }
  /* Count line above each data table (P0a "N показано"). */
  .count-line { font-size: 12px; color: var(--muted); margin: 0 2px 6px; }
  /* Clickable rows (drawer discoverability — P0a-2). */
  tr.rowlink { cursor: pointer; }
  tr.rowlink:hover { background: var(--hover, rgba(255,255,255,0.04)); }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 4px; }
  tr:last-child td { border-bottom: none; }
  td.slug { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); white-space: nowrap; }
  .status-tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
  .st-done { background: rgba(63,185,80,.16); color: var(--done); }
  .st-planning { background: rgba(210,153,34,.16); color: var(--planning); }
  .st-active { background: rgba(76,141,255,.16); color: var(--active); }
  .st-blocked { background: rgba(248,81,73,.16); color: var(--blocked); }
  .st-review { background: rgba(163,113,247,.16); color: var(--review); }
  .st-unknown { background: rgba(110,118,129,.16); color: var(--unknown); }

  .empty, .error { padding: 40px; text-align: center; color: var(--muted); }
  .error { color: var(--blocked); }
  a.back { color: var(--accent); text-decoration: none; font-size: 13px; }
  a.back:hover { text-decoration: underline; }

  .modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none; align-items: center; justify-content: center; z-index: 50; }
  .modal-bg.show { display: flex; }
  .modal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; width: 380px; max-width: 92vw; }
  .modal h2 { margin: 0 0 6px; font-size: 16px; }
  .modal p { color: var(--muted); margin: 0 0 14px; font-size: 13px; }
  .modal input { width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); color: var(--fg); font: inherit; margin-bottom: 12px; }
  .modal .row { display: flex; gap: 8px; justify-content: flex-end; }
  .skel { color: var(--muted); padding: 40px; text-align: center; }

  /* metrics time-series (#53) */
  .charts { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  .chart-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
  .chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
  .chart-head h4 { margin: 0; font-size: 13px; font-weight: 600; }
  .chart-cur { font-size: 18px; font-weight: 680; white-space: nowrap; }
  .chart-cur small { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 3px; }
  .chart-cur .trend { font-size: 12px; margin-left: 6px; }
  .trend.good { color: var(--done); } .trend.bad { color: var(--blocked); } .trend.flat { color: var(--muted); }
  .eng-panel { margin-top: 18px; }
  .eng-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
  .eng-head h4 { margin: 0; font-size: 13px; font-weight: 600; }
  .eng-table tbody tr { cursor: pointer; }
  .eng-table tbody tr:hover { background: var(--hover, rgba(255,255,255,0.04)); }
  #eng-drill { margin-top: 12px; }
  .chart-foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; }
  svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
  svg.chart .grid { stroke: var(--line); stroke-width: 1; }
  svg.chart .axis { fill: var(--muted); font-size: 9px; }
  svg.chart .area { fill: var(--accent); opacity: .08; }
  svg.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
  svg.chart .dot { fill: var(--accent); }
  svg.chart .dot:hover { r: 4; }
  svg.chart .target { stroke: var(--planning); stroke-width: 1.5; stroke-dasharray: 4 3; }
  svg.chart .target-lbl { fill: var(--planning); font-size: 9px; }
  svg.chart .c-empty { fill: var(--muted); font-size: 11px; }

  /* health badge + summary (#54) */
  .badge { font-size: 11px; font-weight: 650; padding: 2px 8px; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; cursor: help; }
  .badge.h-healthy { background: rgba(63,185,80,.16); color: var(--done); border-color: var(--done); }
  .badge.h-watch   { background: rgba(210,153,34,.16); color: var(--planning); border-color: var(--planning); }
  .badge.h-risk    { background: rgba(248,81,73,.16); color: var(--blocked); border-color: var(--blocked); }
  .badge.h-unknown { background: rgba(110,118,129,.16); color: var(--unknown); border-color: var(--unknown); }
  .card .badge { position: absolute; top: 14px; right: 14px; }
  .card { position: relative; }
  .health { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
  .health-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
  .health-top h3 { margin: 0; font-size: 14px; font-weight: 650; }
  .health-rows { display: grid; gap: 6px 18px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .health-row { display: flex; align-items: baseline; gap: 6px; font-size: 12px; }
  .health-row .hm { color: var(--muted); flex: 1; }
  .health-row .hv { font-weight: 640; }
  .health-row .ok { color: var(--done); } .health-row .miss { color: var(--blocked); }
  .leverage { margin-top: 10px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; }
  .leverage b { color: var(--planning); font-weight: 600; }
  h1#navhome { cursor: pointer; }
  .navlink { color: var(--muted); text-decoration: none; font-size: 13px; padding: 3px 8px; border-radius: 6px; }
  .navlink:hover, .navlink.on { color: var(--fg); background: var(--hover, rgba(255,255,255,0.06)); }
  .tasks-wrap { display: grid; grid-template-columns: 210px 1fr; gap: 16px; align-items: start; }
  .tasks-side { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 12px; }
  .tasks-side label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
  .tasks-side select, .tasks-side input { width: 100%; box-sizing: border-box; background: var(--panel); color: var(--fg);
    border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 13px; }
  .tasks-main { min-width: 0; }
  .tasks-search { margin-bottom: 10px; }
  .loadmore { margin: 12px auto 0; display: block; }
  .drawer-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: none; z-index: 30; }
  .drawer-bg.show { display: block; }
  .drawer { position: fixed; top: 0; right: 0; height: 100%; width: min(440px, 92vw); background: var(--panel);
    border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(0,0,0,0.3); padding: 18px 20px; overflow-y: auto; z-index: 31; }
  .drawer h3 { margin: 0 0 4px; font-size: 15px; word-break: break-word; }
  .drawer .kv { display: grid; grid-template-columns: 92px 1fr; gap: 4px 10px; font-size: 13px; margin-top: 12px; }
  .drawer .kv .k { color: var(--muted); }
  .drawer .trace-note { margin-top: 16px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 8px;
    font-size: 12px; color: var(--muted); }
  .drawer .closex { float: right; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; }
  /* task-detail drawer — long-text field sections (T2.1) */
  .drawer .fld { margin-top: 14px; }
  .drawer .fld > .fld-k { font-size: 11px; font-weight: 650; color: var(--muted);
    text-transform: uppercase; letter-spacing: .03em; margin-bottom: 4px; }
  .drawer .fld .md { margin-top: 0; }
  .drawer .gates { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
  .drawer .gate { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line);
    white-space: nowrap; }
  .drawer .gate.pass { color: var(--done); border-color: var(--done); background: rgba(63,185,80,.12); }
  .drawer .gate.fail { color: var(--blocked); border-color: var(--blocked); background: rgba(248,81,73,.12); }
  /* Team view (#57): drop zones + roster pool */
  .team-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
  .team-grid.with-roster { grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr); }
  .dropzone { border: 1px dashed transparent; border-radius: 8px; margin-bottom: 14px; }
  .dropzone.dragover { border-color: var(--active); background: rgba(80, 160, 255, 0.06); }
  .dz-head { font-size: 13px; font-weight: 600; padding: 4px 2px 6px; }
  .dz-hint { float: right; font-weight: 400; }
  .roster { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; align-self: start; position: sticky; top: 12px; }
  .roster-chips { display: flex; flex-wrap: wrap; gap: 6px; }
  .uchip { border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px;
    cursor: grab; user-select: none; background: var(--panel2, var(--panel)); }
  .uchip:hover { border-color: var(--active); }
  /* RENAR trace chain viz (#52) */
  .tc-wrap { overflow-x: auto; margin-top: 6px; }
  .tc-head { font: 600 11px sans-serif; fill: var(--muted); }
  .tc-id { font: 600 11px monospace; fill: var(--fg); pointer-events: none; }
  .tc-status { font: 10px sans-serif; pointer-events: none; }
  .tc-node rect { fill: var(--panel2, var(--panel)); stroke-width: 1.5; cursor: pointer; }
  .tc-node:hover rect { filter: brightness(1.25); }
  .tc-edge { fill: none; stroke: var(--line); stroke-width: 1.5; }
  .tc-detail { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }

  /* ── RENAR «Требования» viewer (P1) ─────────────────────────────────── */
  .renar-wrap { display: grid; grid-template-columns: 190px 1fr; gap: 16px; align-items: start; }
  .renar-rail { display: flex; flex-direction: column; gap: 6px; position: sticky; top: calc(var(--header-h) + 12px); }
  .renar-rail .rl-tab { display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel);
    color: var(--muted); cursor: pointer; font-size: 13px; }
  .renar-rail .rl-tab.on { color: #fff; border-color: var(--accent2); background: var(--accent2); }
  .renar-rail .rl-tab .rl-n { font-size: 11px; opacity: .85; }
  .renar-rail .rl-sub { font-size: 11px; color: var(--muted); margin: 8px 2px 2px; }
  .renar-main { min-width: 0; }
  .lc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
  /* lifecycle badge palette (P1 spec): draft slate · approved green · verified
     teal · accepted blue · deprecated orange · obsolete/superseded red. */
  .lc { font-size: 11px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; }
  .lc-draft       { background: rgba(110,118,129,.16); color: #9aa6b2; border-color: #5b6675; }
  .lc-approved    { background: rgba(63,185,80,.16);  color: var(--done);    border-color: var(--done); }
  .lc-verified    { background: rgba(45,212,191,.16); color: #2dd4bf;        border-color: #2dd4bf; }
  .lc-accepted    { background: rgba(76,141,255,.16); color: var(--active);  border-color: var(--active); }
  .lc-deprecated  { background: rgba(217,119,6,.16);  color: #e08c2b;        border-color: #e08c2b; }
  .lc-obsolete    { background: rgba(248,81,73,.16);  color: var(--blocked); border-color: var(--blocked); }
  .lc-unknown     { background: rgba(110,118,129,.16);color: var(--unknown); border-color: var(--unknown); }
  /* dual-signature dots ●agent ●human */
  .sig-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-left: 4px;
    vertical-align: middle; border: 1px solid var(--line); background: transparent; }
  .sig-dot.on { background: var(--done); border-color: var(--done); }
  .ver-pill { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px;
    color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; }
  .drift-badge { font-size: 11px; border-radius: 999px; padding: 1px 8px; border: 1px solid var(--line); white-space: nowrap; }
  .drift-badge.warn { color: #b45309; border-color: #f59e0b; background: rgba(245,158,11,0.12); }
  .drift-badge.ok { color: var(--muted); }
  .cov-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--panel2);
    border: 1px solid var(--line); margin: 6px 0; }
  .cov-bar span { display: block; height: 100%; background: var(--done); }
  /* rendered markdown in the drawer — readable + escaped (renderMd). */
  .md { font-size: 13px; line-height: 1.55; margin-top: 12px; word-break: break-word; }
  .md h1, .md h2, .md h3 { font-size: 14px; margin: 12px 0 4px; font-weight: 650; }
  .md p { margin: 6px 0; }
  .md ul { margin: 6px 0; padding-left: 20px; }
  .md code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
    background: var(--panel2); padding: 1px 4px; border-radius: 4px; }
  .md pre { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px;
    padding: 8px 10px; overflow-x: auto; font-size: 12px; }
  .md pre code { background: none; padding: 0; }
  .ref-chip { display: inline-block; font-size: 11px; font-family: ui-monospace, monospace;
    border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; margin: 2px 4px 2px 0;
    color: var(--accent); cursor: pointer; background: var(--panel); }
  .ref-chip:hover { border-color: var(--accent); }
  .panel-note { margin-top: 14px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 8px;
    font-size: 12px; color: var(--muted); }
  .panel-warn { border-style: solid; border-color: var(--planning); color: var(--planning); }

  /* ── RENAR version + lifecycle MANAGEMENT (P2) ──────────────────────── */
  /* Manager/admin-only action rail in the detail drawer; engineer never sees
     these (gated on CTX.role — server is the barrier regardless). */
  .renar-mng { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
  .renar-mng h4 { margin: 0 0 8px; font-size: 12px; font-weight: 650; color: var(--muted);
    text-transform: uppercase; letter-spacing: .03em; }
  .renar-mng + .renar-mng { margin-top: 14px; }
  /* signature widget — labelled dots + signer/time + sign button */
  .sig-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
  .sig-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
  .sig-tag .sig-dot { margin-left: 0; }
  /* action rail — transition buttons + inputs */
  .rail-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
  .rail-row .lc-to { font-size: 12px; padding: 4px 10px; border-radius: 8px;
    border: 1px solid var(--line); background: var(--panel2); color: var(--fg); cursor: pointer; }
  .rail-row .lc-to:hover { border-color: var(--accent); }
  .renar-mng input, .renar-mng select { font: inherit; font-size: 12px; padding: 5px 9px; border-radius: 8px;
    border: 1px solid var(--line); background: var(--panel2); color: var(--fg); }
  .renar-mng input { flex: 1; min-width: 120px; }
  .renar-mng button { font-size: 12px; padding: 5px 12px; }
  /* inline action feedback (success / error) */
  .rail-msg { font-size: 12px; margin-top: 4px; min-height: 1em; }
  .rail-msg.ok { color: var(--done); }
  .rail-msg.err { color: var(--blocked); }
  /* version timeline — vertical, newest first */
  .vtl { list-style: none; margin: 4px 0 0; padding: 0; position: relative; }
  .vtl li { position: relative; padding: 0 0 10px 18px; border-left: 1px solid var(--line); }
  .vtl li:last-child { border-left-color: transparent; }
  .vtl li::before { content: ""; position: absolute; left: -4px; top: 3px; width: 7px; height: 7px;
    border-radius: 50%; background: var(--accent2); border: 1px solid var(--bg, #0d1117); }
  .vtl .vtl-main { font-size: 12px; }
  .vtl .vtl-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }
  .vtl .vtl-arrow { color: var(--muted); margin: 0 4px; }
  /* supersedes chain list */
  .chain-list { list-style: none; margin: 4px 0 0; padding: 0; }
  .chain-list li { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 3px 0;
    border-bottom: 1px solid var(--line); }
  .chain-list li:last-child { border-bottom: none; }
  .chain-list li.cur { font-weight: 600; }
  /* content diff (T1.1) — line-level added/removed between a version and the
     version it supersedes. Monospace gutter with +/- glyphs + colour styling. */
  .renar-diff { margin: 6px 0 0; border: 1px solid var(--line); border-radius: 8px;
    overflow: auto; max-height: 320px; background: var(--panel2); }
  .renar-diff .dl { display: flex; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
  .renar-diff .dl .dg { flex: 0 0 16px; text-align: center; color: var(--muted); user-select: none; }
  .renar-diff .dl .dt { flex: 1; padding-right: 8px; }
  .renar-diff .dl.add { background: rgba(63,185,80,.12); }
  .renar-diff .dl.add .dg { color: var(--done); }
  .renar-diff .dl.del { background: rgba(248,81,73,.12); }
  .renar-diff .dl.del .dg { color: var(--blocked); }
  .renar-diff .dl.trunc { color: var(--muted); font-style: italic; }
  .diff-toggle { font-size: 12px; padding: 4px 10px; }
  /* review-notes (return-to-author) */
  .note-list { list-style: none; margin: 6px 0 0; padding: 0; }
  .note-item { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; margin-bottom: 6px;
    background: var(--panel2); font-size: 12px; }
  .note-item .note-head { color: var(--muted); font-size: 11px; margin-bottom: 3px; }
  .note-item .note-text { white-space: pre-wrap; word-break: break-word; }
  .renar-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

  /* ── Project GROUPS / workspaces (P3) ───────────────────────────────── */
  /* Group cards reuse .card; the totals strip + per-project status bars reuse
     the .bar/.legend visual language. Admin form mirrors the .toolbar inline
     style used by the projects/keys admin surfaces. */
  .grp-totals { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: baseline;
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
    padding: 12px 16px; margin-bottom: 14px; }
  .grp-totals .gt { display: flex; flex-direction: column; gap: 1px; }
  .grp-totals .gt b { font-size: 20px; font-weight: 680; }
  .grp-totals .gt span { font-size: 11px; color: var(--muted); }
  .grp-member { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px;
    background: var(--panel); }
  .grp-member .gm-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
  .grp-member .gm-head h4 { margin: 0; font-size: 13px; font-weight: 600; }
  .grp-member .gm-role { font-size: 11px; color: var(--muted); }
  .grp-actions { display: inline-flex; gap: 4px; }
  .grp-actions button { padding: 3px 8px; font-size: 12px; }
  .grp-mng-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
  .grp-mng-row input, .grp-mng-row select { font: inherit; font-size: 13px; padding: 6px 8px; border-radius: 6px;
    border: 1px solid var(--line); background: var(--panel2); color: var(--fg); }

  /* ── Security UI & key hygiene (P5) ─────────────────────────────────── */
  /* Key-hygiene table reuses the .tbl/.status-tag/.chip system. The hygiene
     signals (no-owner / stale / expired / test) get their own muted+semantic
     chip styles; destructive selection drives a sticky action bar. */
  .hg-group { font-size: 12px; font-weight: 650; color: var(--muted); padding: 12px 4px 4px;
    text-transform: none; letter-spacing: .01em; }
  .hg-group:first-child { padding-top: 2px; }
  .hg-chk { width: 1px; white-space: nowrap; }
  /* advisory hygiene chips (hover-explained) */
  .hg { font-size: 11px; padding: 1px 7px; border-radius: 999px; white-space: nowrap;
    border: 1px solid transparent; cursor: help; }
  .hg-noowner { background: rgba(210,153,34,.16); color: var(--planning); border-color: var(--planning); }
  .hg-test    { background: rgba(163,113,247,.16); color: var(--review); border-color: var(--review); }
  .hg-stale   { color: var(--planning); }
  .hg-never   { color: var(--blocked); }
  .hg-expired { color: var(--blocked); font-weight: 600; }
  td.hg-muted { color: var(--muted); }
  /* sticky bulk-action bar (appears when ≥1 row checked) */
  .hg-actionbar { position: sticky; bottom: 0; z-index: 6; display: flex; align-items: center; gap: 10px;
    flex-wrap: wrap; padding: 10px 14px; margin-top: 12px; border: 1px solid var(--accent2);
    border-radius: var(--radius); background: var(--panel); box-shadow: 0 -4px 16px rgba(0,0,0,.25); }
  .hg-actionbar.hide { display: none; }
  .hg-actionbar .ab-count { font-weight: 650; }
  .hg-actionbar .spacer { flex: 1; }
  button.danger { background: rgba(248,81,73,.16); border-color: var(--blocked); color: var(--blocked); }
  button.danger:hover { background: var(--blocked); color: #fff; }
  .k-action { padding: 3px 8px; font-size: 12px; }
  /* access-map matrix (manager-readable /keys/audit) inside the Keys view */
  .accessmap { overflow-x: auto; margin-top: 6px; }
  .accessmap table { min-width: 480px; }
  .accessmap td.cell { text-align: center; }
  .am-perm { font-size: 10px; padding: 1px 6px; border-radius: 999px; white-space: nowrap; }
  .am-read  { background: rgba(76,141,255,.16); color: var(--active); }
  .am-write { background: rgba(210,153,34,.18); color: var(--planning); }
  .am-admin { background: rgba(248,81,73,.18); color: var(--blocked); }
  .am-none  { color: var(--unknown); }
  .sec-section { margin-top: 22px; }
  .sec-section > h3 { font-size: 14px; font-weight: 650; margin: 0 0 8px; }
  .collapse-head { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 8px; }
  .collapse-head .caret { color: var(--muted); transition: transform .12s; }
  .collapse-head.open .caret { transform: rotate(90deg); }

  /* ── Audit readability (P5) ─────────────────────────────────────────── */
  /* action-type colour legend + day grouping + click-to-expand JSON detail. */
  .audit-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
  .audit-controls select, .audit-controls input { font: inherit; font-size: 13px; padding: 6px 8px;
    border-radius: 6px; border: 1px solid var(--line); background: var(--panel2); color: var(--fg); }
  .audit-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 11px; color: var(--muted);
    margin-bottom: 10px; }
  .audit-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px;
    vertical-align: middle; }
  .ev-issue  { background: rgba(63,185,80,.16);  color: var(--done);     }
  .ev-revoke { background: rgba(248,81,73,.16);  color: var(--blocked);  }
  .ev-rotate { background: rgba(76,141,255,.16); color: var(--active);   }
  .ev-login  { background: rgba(45,212,191,.16); color: #2dd4bf;         }
  .ev-loginf { background: rgba(248,81,73,.16);  color: var(--blocked);  }
  .ev-logout { background: rgba(110,118,129,.16);color: var(--unknown);  }
  .ev-team   { background: rgba(210,153,34,.16); color: var(--planning); }
  .ev-deny   { background: rgba(217,119,6,.18);  color: #e08c2b;         }
  .ev-other  { background: rgba(110,118,129,.16);color: var(--unknown);  }
  i.ev-issue{background:var(--done)} i.ev-revoke{background:var(--blocked)} i.ev-rotate{background:var(--active)}
  i.ev-login{background:#2dd4bf} i.ev-loginf{background:var(--blocked)} i.ev-logout{background:var(--unknown)}
  i.ev-team{background:var(--planning)} i.ev-deny{background:#e08c2b} i.ev-other{background:var(--unknown)}
  .audit-day { font-size: 12px; font-weight: 650; color: var(--muted); padding: 14px 4px 4px; }
  tr.ev-row { cursor: pointer; }
  tr.ev-row:hover { background: var(--hover, rgba(255,255,255,0.04)); }
  tr.ev-detail > td { background: var(--panel2); }
  tr.ev-detail pre { margin: 0; font-size: 12px; white-space: pre-wrap; word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--fg); }
  /* ── Audit clarity (T4) — readable sentence rows + change diff ─────────── */
  /* Readable «{actor} {action} {target} {when}» line as the lead cell. */
  .ev-sentence { line-height: 1.5; }
  .ev-sentence .ev-actor, .ev-sentence .ev-target { font-weight: 600; color: var(--fg); word-break: break-all; }
  .ev-sentence .ev-verb { color: var(--muted); }
  .ev-sentence .ev-when { color: var(--muted); font-size: 12px; }
  /* Field-level change diff table inside an expanded mutation row. */
  table.ev-diff { width: 100%; border-collapse: collapse; font-size: 12px; margin: 2px 0; }
  table.ev-diff th, table.ev-diff td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line);
    vertical-align: top; word-break: break-word; }
  table.ev-diff th { color: var(--muted); font-weight: 600; }
  table.ev-diff td.ev-key { font-weight: 600; color: var(--fg); white-space: nowrap; }
  table.ev-diff .ev-before { color: var(--blocked); }
  table.ev-diff .ev-after { color: var(--done); }
  table.ev-diff tr.hg-muted td { color: var(--muted); }
  .ev-detail-h { font-size: 12px; font-weight: 650; color: var(--muted); margin: 2px 0 4px; }
