/* Joyride app shell. All colors via tokens.css variables; no hex here. */
:root {
  --good: color-mix(in srgb, var(--p3) 45%, var(--ink));
  --bad: color-mix(in srgb, var(--p5) 55%, var(--ink));
  --side-w: 260px;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--app-bg); color: var(--ink);
  font-family: var(--font-sans); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; letter-spacing: -0.01em; }
p { margin: 0; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.muted { color: var(--ink-3); }
.r { text-align: right; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: var(--radius-sm); }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--app-side); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 12px 16px;
}
.side-logo { display: flex; align-items: center; padding: 2px 10px 0; min-height: 26px; }
.side-logo img { height: 22px; display: block; }
.side-logo .logo-fallback { font-weight: 600; font-size: 16px; letter-spacing: -0.02em; display: none; }
.side-logo.no-img img { display: none; }
.side-logo.no-img .logo-fallback { display: inline; }
.org { display: flex; align-items: center; gap: 8px; padding: 14px 10px 6px; font-weight: 500; font-size: 14px; }
.org .badge { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.04em; padding: 2px 7px; border-radius: var(--radius-pill); background: var(--blue-soft); color: var(--blue-ink); }
:root[data-theme="dark"] .org .badge { color: var(--ink); }
.sec { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); padding: 18px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 7px 10px; border: 0; border-radius: var(--radius-sm); background: none; cursor: pointer;
  color: var(--ink-2); font-weight: 500; font-size: 14px; text-decoration: none; transition: background 120ms, color 120ms;
}
.nav-item svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { background: var(--paper-3); color: var(--ink); }
.nav-item.active { background: var(--blue-soft); color: var(--blue-ink); }
:root[data-theme="dark"] .nav-item.active { color: var(--ink); }
.nav-item[aria-expanded="true"] { color: var(--ink); }
.nav-item .chev { margin-left: auto; width: 12px; height: 12px; opacity: 0.6; transition: transform 200ms var(--ease); }
.nav-item[aria-expanded="true"] .chev { transform: rotate(90deg); }
.setup-panel { margin: 2px 4px 8px; padding: 10px 12px; background: var(--app-card); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 12.5px; }
.setup-panel[hidden] { display: none; }
.sp-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.sp-list { list-style: none; margin: 0 0 10px; padding: 0; color: var(--ink-2); }
.sp-list li { padding: 2px 0; display: flex; justify-content: space-between; gap: 8px; }
.sp-list li span { color: var(--ink-3); font-size: 10.5px; }
.sp-link { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 4px 0; color: var(--blue-ink); cursor: pointer; font-size: 12.5px; }
.sp-link:hover { text-decoration: underline; }
.sp-code { display: flex; align-items: center; gap: 6px; margin: 6px 0 4px; }
.sp-code code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 11px; background: var(--paper-3); padding: 5px 7px; border-radius: var(--radius-sm); }
.side-foot { margin-top: auto; padding: 12px 10px 0; font-size: 11.5px; color: var(--ink-3); }
.main { min-width: 0; padding: 18px 28px 64px; }

/* ---------- Top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.topbar h1 { font-size: 22px; font-weight: 500; letter-spacing: -0.02em; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: var(--app-card); border-radius: var(--radius-pill); cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.icon-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .moon { display: none; }
:root[data-theme="dark"] .icon-btn .moon { display: block; }
:root[data-theme="dark"] .icon-btn .sun { display: none; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 3px 10px 3px 3px; border: 1px solid var(--line); background: var(--app-card); border-radius: var(--radius-pill); cursor: pointer; font-weight: 500; font-size: 13px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu .menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px; background: var(--app-card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,0.08); padding: 6px; z-index: 20; }
.user-menu .menu a, .user-menu .menu span { display: block; padding: 7px 10px; border-radius: var(--radius-sm); text-decoration: none; font-size: 13px; }
.user-menu .menu span { color: var(--ink-3); font-size: 12px; }
.user-menu .menu a:hover { background: var(--paper-3); }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 18px; }
.filters[hidden] { display: none; }
.pill-select { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 28px 0 12px; border: 1px solid var(--line); background: var(--app-card); border-radius: var(--radius-pill); font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.pill-select:hover { border-color: var(--line-strong); }
.pill-select.on { border-color: var(--blue); color: var(--blue-ink); background: var(--blue-soft); }
:root[data-theme="dark"] .pill-select.on { color: var(--ink); }
.pill-select > span { color: var(--ink-3); }
.pill-select.on > span { color: inherit; opacity: 0.8; }
.pill-select select { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.pill-select .val { font-weight: 500; color: var(--ink); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill-select.on .val { color: inherit; }
.pill-select::after { content: ""; position: absolute; right: 12px; top: 11px; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); opacity: 0.6; }
.btn-link { background: none; border: 0; color: var(--blue-ink); cursor: pointer; font-size: 12.5px; padding: 4px 6px; }
.btn-link:hover { text-decoration: underline; }

/* ---------- Buttons, pills, badges ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: var(--radius-pill); border: 1px solid transparent; font-weight: 500; font-size: 13.5px; cursor: pointer; text-decoration: none; transition: transform 120ms, opacity 120ms; }
.btn:active { transform: translateY(1px); }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ink:hover { opacity: 0.9; }
.btn-ghost { background: var(--app-card); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--line-strong); }
.btn-sm { height: 28px; padding: 0 11px; font-size: 12.5px; }
.btn[disabled] { opacity: 0.6; cursor: default; }
.mono-pill { display: inline-flex; align-items: center; font-family: var(--font-mono); font-size: 11px; padding: 2px 7px; border-radius: var(--radius-pill); background: var(--paper-3); color: var(--ink-2); text-decoration: none; white-space: nowrap; }
a.mono-pill:hover { background: var(--blue-soft); color: var(--blue-ink); }
.pill { display: inline-flex; align-items: center; font-size: 11.5px; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--paper-3); color: var(--ink-2); white-space: nowrap; }
.pill.o-shipped { background: var(--p3); color: var(--ink); }
.pill.o-in-review { background: var(--p4); color: var(--ink); }
.pill.o-closed { background: var(--p5); color: var(--ink); }
.pill.o-no-PR { background: var(--paper-3); }
.pill.o-active { background: var(--p6); color: var(--ink); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.agent { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; color: var(--ink); font-size: 11px; font-weight: 600; letter-spacing: 0.02em; flex: none; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.xs { width: 18px; height: 18px; font-size: 8.5px; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--app-card); padding: 2px; }
.seg button { border: 0; background: none; padding: 4px 11px; border-radius: var(--radius-pill); font-size: 12.5px; color: var(--ink-2); cursor: pointer; text-transform: capitalize; }
.seg button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.seg button:hover:not([aria-selected="true"]) { color: var(--ink); }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.search { height: 30px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--app-card); color: var(--ink); font: inherit; font-size: 12.5px; min-width: 220px; }
.search:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: transparent; }

/* ---------- Cards, sections ---------- */
.card { background: var(--app-card); border: 1px solid var(--line); border-radius: var(--radius); }
.card + .card, .grid + .card, .card + .grid, .tiles + .card { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 15px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.card-head .right { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--ink-3); }
.pad { padding: 16px 18px; }
.pad-sm { padding: 10px 14px; }
.section-head { display: flex; align-items: center; gap: 8px; margin: 26px 0 10px; }
.section-head:first-child { margin-top: 0; }
.eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.eyebrow-row { display: flex; align-items: center; gap: 6px; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid > .card { margin-top: 0; }
.empty { padding: 24px; text-align: center; color: var(--ink-3); font-size: 13px; }
.info { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--line-strong); color: var(--ink-3); font-family: var(--font-mono); font-size: 9.5px; cursor: help; position: relative; flex: none; }
.info::after, [data-tip]::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); width: max-content; max-width: 280px; padding: 7px 10px; border-radius: var(--radius-sm); background: var(--ink); color: var(--paper); font: 12px/1.4 var(--font-sans); text-transform: none; letter-spacing: 0; white-space: normal; opacity: 0; pointer-events: none; transition: opacity 150ms; z-index: 30; }
.info:hover::after, .info:focus-visible::after, [data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; }

/* ---------- Stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: stretch; }
.tiles > .tile, .billing > .tile { align-self: stretch; margin: 0; transform: none; min-height: 132px; display: flex; flex-direction: column; justify-content: space-between; }
.tile { padding: 16px 18px 14px; }
.tile-body { display: flex; align-items: flex-end; gap: 16px; margin-top: 10px; }
.tile-val { font-size: 32px; font-weight: 500; letter-spacing: -0.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.tile-delta { display: inline-flex; align-items: center; gap: 5px; margin-top: 8px; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.tile-delta svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.tile-delta.up { color: var(--good); }
.tile-delta.down { color: var(--bad); }
.tile-delta .muted { font-weight: 400; }
.tile-spark { flex: 1; min-width: 0; align-self: center; }
.chart-slot { width: 100%; display: block; }
.chart-slot svg { display: block; max-width: 100%; height: auto; }
.ch-tick { font-family: var(--font-mono); font-size: 10.5px; fill: var(--ink-3); }
.ch-label { font-family: var(--font-sans); font-size: 13px; font-weight: 500; fill: var(--ink); }
.ch-center { font-family: var(--font-sans); font-size: 18px; font-weight: 500; fill: var(--ink); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Chart animation ---------- */
.anim .ch-line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: ch-draw 900ms var(--ease) forwards; }
.anim .ch-area { opacity: 0; animation: ch-fade 900ms var(--ease) 200ms forwards; }
.anim .ch-dot { opacity: 0; animation: ch-fade 500ms var(--ease) 600ms forwards; }
.anim .ch-bar { transform: scaleY(0); transform-origin: bottom; transform-box: fill-box; animation: ch-grow 900ms var(--ease) forwards; }
.anim .ch-bar-x { transform: scaleX(0); transform-origin: left; transform-box: fill-box; animation: ch-grow-x 900ms var(--ease) forwards; }
.anim .ch-ribbon, .anim .ch-node { opacity: 0; animation: ch-fade 900ms var(--ease) forwards; animation-delay: var(--d, 0ms); }
.anim .ch-donut { transform-origin: center; transform-box: fill-box; animation: ch-spin 900ms var(--ease) forwards; }
.anim .hbar > span, .anim .bar > span { transform-origin: left; animation: ch-grow-x 900ms var(--ease) forwards; }
@keyframes ch-draw { to { stroke-dashoffset: 0; } }
@keyframes ch-fade { to { opacity: 1; } }
@keyframes ch-grow { to { transform: scaleY(1); } }
@keyframes ch-grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes ch-spin { from { transform: rotate(-110deg); opacity: 0; } to { transform: rotate(0deg); opacity: 1; } }
.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); position: relative; }
.pulse::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--good); opacity: 0; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(0.5); opacity: 0.8; } 100% { transform: scale(1.4); opacity: 0; } }
.live-ind { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
@keyframes row-in { from { background: var(--blue-soft); } to { background: transparent; } }
.tbl tr.new-row td { animation: row-in 2.5s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .anim .ch-line, .anim .ch-area, .anim .ch-dot, .anim .ch-bar, .anim .ch-bar-x, .anim .ch-ribbon, .anim .ch-node, .anim .ch-donut, .anim .hbar > span, .anim .bar > span, .pulse::after, .tbl tr.new-row td { animation: none !important; opacity: 1; transform: none; stroke-dashoffset: 0; }
}

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.tbl th { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tr.row-btn { cursor: pointer; }
.tbl tr.row-btn:hover td { background: var(--paper-3); }
.tbl tr.row-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.tbl tr[aria-expanded="true"] td { background: var(--paper-3); }
.tbl td.sub { color: var(--ink-3); }
.tbl .sub { color: var(--ink-3); font-size: 11.5px; }
.tbl-compact th, .tbl-compact td { padding: 7px 10px; }
.tbl tr.detail-row > td { padding: 0; background: var(--paper); }
.tbl .chev { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-right: 1.5px solid var(--ink-3); border-bottom: 1.5px solid var(--ink-3); transform: rotate(-45deg); transition: transform 200ms var(--ease); vertical-align: middle; }
.tbl tr[aria-expanded="true"] .chev { transform: rotate(45deg); }
.tbl .sub-row td { color: var(--ink-2); font-size: 12.5px; background: var(--paper); }
.tbl .sub-row td:first-child { padding-left: 42px; }
.tbl .name-cell { display: flex; align-items: center; gap: 8px; }
.tbl a { text-decoration: none; }
.tbl a:hover { text-decoration: underline; }
.tbl .tbl-bar { display: inline-flex; align-items: center; gap: 8px; }
.bar { display: inline-block; height: 8px; width: 90px; border-radius: var(--radius-pill); background: var(--paper-3); overflow: hidden; vertical-align: middle; }
.bar > span { display: block; height: 100%; background: var(--ai); border-radius: var(--radius-pill); }
.bar.big { height: 12px; width: 280px; }
.bar.big > span { background: var(--ink); }
@media (max-width: 1600px) { .hide-lg { display: none; } }
@media (max-width: 1320px) { .hide-md { display: none; } }
.tbl-tight th, .tbl-tight td { padding: 8px 9px; }

/* ---------- Session detail / Show your work ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; padding: 16px 18px 18px; white-space: normal; border-bottom: 1px solid var(--line); }
.detail .eyebrow { display: block; margin: 12px 0 6px; }
.detail .eyebrow:first-child { margin-top: 0; }
.hbar { display: flex; height: 12px; border-radius: var(--radius-pill); overflow: hidden; background: var(--paper-3); }
.hbar > span { display: block; height: 100%; min-width: 2px; }
.hbar-legend { margin-top: 8px; }
.files { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.files li { font-family: var(--font-mono); font-size: 11.5px; padding: 3px 8px; background: var(--paper-3); border-radius: var(--radius-sm); }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.kv .eyebrow { margin: 0 0 3px; }
.kv b { font-weight: 500; font-size: 13px; }
.work { background: var(--app-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.work-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.work-note { font-size: 12px; color: var(--ink-3); margin-bottom: 12px; }
.work-ctx { margin-bottom: 12px; padding: 8px 10px; background: var(--paper-3); border-radius: var(--radius-sm); font-size: 12px; white-space: pre-wrap; }
.msgs { display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 9px 12px; border-radius: var(--radius); font-size: 13px; line-height: 1.5; }
.msg .who { display: block; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 3px; }
.msg.user { background: var(--blue-soft); }
.msg.bot { background: var(--paper-3); }
.msg.tool { background: var(--paper-3); border: 1px dashed var(--line-strong); }
.msg pre { margin: 0; font-family: var(--font-mono); font-size: 12px; white-space: pre-wrap; }
.msg.me { background: var(--blue-soft); align-self: flex-end; max-width: 92%; }
.msg.reply { background: var(--paper-3); border-left: 3px solid var(--p2); }
.chat { margin-top: 12px; }
.chat-log { display: flex; flex-direction: column; gap: 8px; }
.chat-log:not(:empty) { margin-bottom: 10px; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; min-width: 0; height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--app-card); color: var(--ink); font: inherit; font-size: 13px; }
.chat-form input:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
.typing { font-size: 12px; color: var(--ink-3); font-style: italic; }

/* Side panel */
.work-panel { position: fixed; top: 0; right: 0; bottom: 0; width: 400px; max-width: 92vw; background: var(--app-bg); border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgba(0,0,0,0.08); z-index: 40; overflow-y: auto; padding: 18px 20px 28px; transform: translateX(0); animation: panel-in 320ms var(--ease); }
.work-panel[hidden] { display: none; }
@keyframes panel-in { from { transform: translateX(24px); opacity: 0; } }
.work-panel .panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.work-panel .panel-head h3 { font-size: 16px; }
.work-panel .close { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--app-card); cursor: pointer; font-size: 18px; line-height: 1; }
.work-panel .line-preview { font-family: var(--font-mono); font-size: 12px; padding: 8px 10px; background: var(--app-card); border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 12px; white-space: pre-wrap; word-break: break-word; }

/* ---------- Reports ---------- */
.split-outcomes { display: grid; grid-template-columns: minmax(0, 1fr) 320px; }
.shipped { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.shipped-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 500; font-size: 14px; }
.shipped-head .muted { font-weight: 400; }
.shipped-list { overflow-y: auto; max-height: 420px; }
.ship-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.ship-row:last-child { border-bottom: 0; }
.ship-l { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ship-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ship-meta { display: flex; align-items: center; gap: 8px; color: var(--ink-3); font-size: 12px; }
.ship-r { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.ship-cost { font-variant-numeric: tabular-nums; font-weight: 500; }
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut-wrap .legend { flex-direction: column; gap: 6px; }
.donut-wrap .legend b { font-variant-numeric: tabular-nums; margin-left: auto; padding-left: 12px; font-weight: 500; color: var(--ink); }
.donut-wrap .legend span { width: 100%; }
.insight { padding: 16px 18px; }
.insight h4 { font-size: 14px; font-weight: 500; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.insight p.lead { color: var(--ink-3); font-size: 12.5px; margin-bottom: 12px; }
.insight .tbl th:first-child, .insight .tbl td:first-child { padding-left: 0; }
.insight .tbl th:last-child, .insight .tbl td:last-child { padding-right: 0; }
.insight .tbl th, .insight .tbl td { padding: 7px 6px; }
.insight .tbl .mono { display: inline-block; max-width: 140px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.split-bar { display: flex; height: 16px; border-radius: var(--radius-pill); overflow: hidden; margin: 6px 0 12px; }
.split-bar > span { display: block; height: 100%; }
.split-legend { display: grid; gap: 8px; }
.split-legend div { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.split-legend b { margin-left: auto; font-weight: 500; font-variant-numeric: tabular-nums; }
.split-legend .muted { font-size: 12px; min-width: 36px; text-align: right; }
.retention { display: inline-flex; align-items: center; gap: 8px; }
.retention .bar { width: 34px; }
.retention .bar > span { background: var(--p3); }

/* ---------- Pull requests ---------- */
.list .pr-row { display: grid; grid-template-columns: 24px minmax(0, 1fr) 210px 90px; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--line); text-decoration: none; transition: background 120ms; }
.list .pr-row:last-child { border-bottom: 0; }
.list .pr-row:hover { background: var(--paper-3); }
.pr-state { display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center; border-radius: 50%; }
.pr-state svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; }
.pr-state.s-merged { background: var(--p7); }
.pr-state.s-open { background: var(--p3); }
.pr-state.s-closed { background: var(--p5); }
.pr-main { min-width: 0; }
.pr-title { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-meta { display: flex; align-items: center; gap: 7px; margin-top: 3px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; }
.pr-meta .sep { color: var(--ink-3); }
.pr-share { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--ink-2); }
.pr-share .bar { width: 110px; }
.pr-cost { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.pr-head { margin-bottom: 20px; }
.pr-h1 { display: flex; align-items: center; gap: 10px; }
.pr-h1 h2 { font-size: 22px; letter-spacing: -0.02em; }
.pr-sub { color: var(--ink-2); margin-top: 6px; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pr-sub b { font-weight: 500; color: var(--ink); }
.share-row { display: flex; align-items: center; gap: 14px; margin-top: 18px; font-size: 14px; }
.share-row .cost { font-weight: 500; }
.share-row .cost .muted { font-weight: 400; margin-left: 4px; }

/* Code attribution */
.code { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; padding: 10px 0; }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.code-line { display: grid; grid-template-columns: 6px 44px minmax(0, 1fr); align-items: stretch; position: relative; cursor: pointer; }
.code-line:hover, .code-line:focus-visible { background: var(--paper-3); outline: none; }
.code-line.sel { background: var(--blue-soft); }
.code-line .gut { background: var(--paper-3); }
.code-line.k-ai .gut { background: var(--ai); }
.code-line.k-human .gut { background: var(--human); }
.code-line.k-mixed .gut { background: var(--mixed); }
.code-line .ln { color: var(--ink-3); text-align: right; padding-right: 12px; user-select: none; font-size: 11px; line-height: 1.6; padding-top: 1px; }
.code-line code { white-space: pre; padding-right: 18px; }
.code-line[data-tip]::after { left: 60px; bottom: auto; top: calc(100% + 2px); transform: none; max-width: 380px; white-space: nowrap; }
.code-line[data-tip]:hover::after, .code-line[data-tip]:focus-visible::after { opacity: 1; }
.attr-legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); }
.attr-legend i { width: 10px; height: 10px; border-radius: 2px; }

/* ---------- Contributors ---------- */
.contrib-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.contrib-head h2 { font-size: 20px; }
.contrib-head .sub { color: var(--ink-3); font-size: 13px; }

/* ---------- Query ---------- */
.query { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 12px; align-items: start; }
.catalog { list-style: none; margin: 0; padding: 6px; }
.catalog button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 12.5px; cursor: pointer; color: var(--ink-2); }
.catalog button:hover { background: var(--paper-3); }
.catalog button[aria-selected="true"] { background: var(--blue-soft); color: var(--blue-ink); }
:root[data-theme="dark"] .catalog button[aria-selected="true"] { color: var(--ink); }
.columns { list-style: none; margin: 0; padding: 4px 6px 10px; }
.columns li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 10px; font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-2); }
.columns li span { color: var(--ink-3); }
.sql { width: 100%; min-height: 150px; resize: vertical; border: 0; background: transparent; color: var(--ink); font-family: var(--font-mono); font-size: 13px; line-height: 1.55; padding: 14px 18px; display: block; }
.sql:focus { outline: none; }
.examples { display: flex; flex-wrap: wrap; gap: 6px; }
.examples button { border: 1px solid var(--line); background: var(--app-card); border-radius: var(--radius-pill); padding: 4px 10px; font-size: 12px; cursor: pointer; color: var(--ink-2); }
.examples button:hover { border-color: var(--line-strong); color: var(--ink); }
.result-note { padding: 10px 18px; font-size: 12.5px; color: var(--ink-3); border-bottom: 1px solid var(--line); }

/* ---------- Settings ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; font-size: 13.5px; color: var(--ink-2); cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.provider { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.provider:last-child { border-bottom: 0; }
.provider .name { font-weight: 500; display: flex; align-items: center; gap: 10px; }
.provider .desc { font-size: 12.5px; color: var(--ink-3); }
.key-row { display: grid; grid-template-columns: 160px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.key-row:last-child { border-bottom: 0; }
.key-row code { font-family: var(--font-mono); font-size: 12px; background: var(--paper-3); padding: 6px 10px; border-radius: var(--radius-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-row .desc { font-size: 12px; color: var(--ink-3); }
.key-row .actions { display: flex; gap: 6px; }
.codeblock { font-family: var(--font-mono); font-size: 12.5px; background: var(--paper-3); border-radius: var(--radius-sm); padding: 12px 14px; white-space: pre-wrap; margin: 6px 0 14px; position: relative; }
.codeblock .btn { position: absolute; right: 8px; top: 8px; }
.step { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: 0; }
.step .num { width: 24px; height: 24px; border-radius: 50%; background: var(--paper-3); display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 11px; }
.step h4 { font-size: 14px; margin-bottom: 4px; }
.dropzone { border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--ink-3); font-size: 13px; transition: background 120ms, border-color 120ms; }
.dropzone.over { background: var(--blue-soft); border-color: var(--blue); }
.dropzone input { display: none; }
.dropzone label { color: var(--blue-ink); cursor: pointer; text-decoration: underline; }
.dropzone .ok { color: var(--good); font-weight: 500; }
.tree { list-style: none; margin: 0; padding: 0; }
.tree > li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.tree > li:last-child { border-bottom: 0; }
.tree .team { font-weight: 500; display: flex; align-items: center; gap: 8px; }
.tree ul { list-style: none; margin: 6px 0 0 8px; padding: 0 0 0 14px; border-left: 1px solid var(--line); }
.tree ul li { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; color: var(--ink-2); }
.billing { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: stretch; }
.billing .tile-val { font-size: 26px; }
.form-row { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px 18px; border-bottom: 1px solid var(--line); font-size: 13px; }
.form-row:last-child { border-bottom: 0; }
.form-row .muted { font-size: 12px; }

/* ---------- Live ---------- */
.live-head { display: flex; align-items: center; gap: 14px; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: var(--radius-pill); font-size: 13px; z-index: 50; opacity: 0; transition: opacity 200ms; pointer-events: none; }
.toast.show { opacity: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .split-outcomes { grid-template-columns: minmax(0, 1fr); }
  .shipped { border-left: 0; border-top: 1px solid var(--line); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { padding: 18px 20px 64px; }
}
@media (max-width: 1024px) {
  :root { --side-w: 64px; }
  .side { padding: 18px 10px 16px; }
  .side .lbl, .side .org, .side .sec, .side .side-foot, .side .chev, .side .setup-panel, .side-logo .logo-fallback { display: none !important; }
  .side-logo { justify-content: center; padding: 0; }
  .side-logo img { height: 20px; width: 20px; object-fit: cover; object-position: left; }
  .nav-item { justify-content: center; padding: 10px 0; margin-top: 4px; }
  .sec + .nav-item { margin-top: 12px; }
  .grid-2, .grid-21, .settings-grid, .detail { grid-template-columns: minmax(0, 1fr); }
  .query { grid-template-columns: 200px minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .tiles, .grid-3, .billing { grid-template-columns: minmax(0, 1fr); }
  .query { grid-template-columns: minmax(0, 1fr); }
  .list .pr-row { grid-template-columns: 24px minmax(0, 1fr); }
  .list .pr-share, .list .pr-cost { display: none; }
  .topbar h1 { font-size: 18px; }
}

/* Cards inside grids: no stacking margin, equal height */
.grid > .card, .settings-grid > .card, .tiles > .card, .billing > .card { margin-top: 0; align-self: stretch; }
.grid, .settings-grid { align-items: stretch; }
