* { box-sizing: border-box; }
:root {
  --bg: #f7f8f5; --panel: #fff; --line: #e1e6df; --line2: #cbd3c9; --text: #202a24; --muted: #5e6b61; --faint: #667369;
  --accent: #276146; --accent-bg: #eaf2e9; --red: #b1342e; --red-bg: #fff2f0; --amber: #8c580b; --amber-bg: #fff8e8;
  --green: #276146; --green-bg: #edf6ec;
}
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 30px; line-height: 1.2; letter-spacing: -0.035em; font-weight: 650; margin: 0; }
h2 { font-size: 18px; line-height: 1.35; letter-spacing: -0.02em; font-weight: 650; margin: 0; }
h3 { font-size: 14px; margin: 0; }
:focus-visible { outline: 3px solid #649c75; outline-offset: 4px; }
.grow { flex: 1; min-width: 0; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.eyebrow { color: var(--accent); font: 600 10px/1.5 ui-monospace, monospace; letter-spacing: 0.13em; }
.button { display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; border-radius: 8px; font-weight: 550; }
a.button:hover { text-decoration: none; }
.skip-link { position: fixed; left: 16px; top: -100px; z-index: 100; padding: 12px; background: white; }
.skip-link:focus { top: 12px; }
pre, code { font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
pre { white-space: pre-wrap; word-break: break-word; background: #fafafa; border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 0; max-height: 60vh; overflow: auto; }

/* Sign-in and connector consent share the same shell. */
.auth-screen { min-height: 100vh; display: flex; gap: clamp(40px, 8vw, 140px); align-items: center; justify-content: center; padding: 48px; }
.auth-story { max-width: 490px; }
.wordmark { display: flex; align-items: center; gap: 18px; font-size: 24px; font-weight: 750; letter-spacing: -0.04em; }
.auth-story h2 { font-size: clamp(36px, 4vw, 56px); line-height: 1.1; letter-spacing: -0.045em; margin: 50px 0 24px; }
.auth-story > p:not(.wordmark) { color: var(--muted); font-size: 17px; line-height: 1.7; }
.auth-story .auth-note { font-size: 13px !important; margin-top: 40px; }
.card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 36px; box-shadow: 0 16px 50px #20362208; }
.card h1 { font-size: 24px; margin: 12px 0 28px; }
.card form, .card section { display: flex; flex-direction: column; gap: 14px; }
.divider { text-align: center; color: var(--faint); font-size: 12px; }
.row { display: flex; gap: 8px; }
.row button { flex: 1; }

/* Controls */
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line2); border-radius: 8px; font: inherit; background: #fff; color: inherit; }
textarea { min-height: 80px; resize: vertical; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 6px; }
label.check input { width: auto; }
button { padding: 10px 16px; border-radius: 8px; font: inherit; font-weight: 550; cursor: pointer; white-space: normal; transition: background-color 120ms, border-color 120ms; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.primary:hover:not(:disabled) { background: #1c4d35; }
.secondary { background: #fff; color: var(--text); border: 1px solid var(--line2); }
.secondary:hover:not(:disabled) { background: var(--bg); border-color: #92a391; }
.danger { background: #fff; color: var(--red); border: 1px solid #fecaca; }
.link { background: none; border: none; padding: 0; color: var(--muted); font-size: 12px; text-decoration: underline; }
.small { padding: 4px 9px; font-size: 12.5px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 12px; }
.error { color: var(--red); }

/* Shell: navigation stays secondary to the current handoff. */
#app { padding-left: 216px; }
.sidebar { width: 216px; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; padding: 30px 18px 24px; border-right: 1px solid var(--line); background: #f0f3ec; gap: 10px; }
.brand { font-weight: 750; font-size: 27px; letter-spacing: -0.06em; color: var(--text); padding: 0 12px; }
.brand:hover { text-decoration: none; }
.alpha-label { font: 600 9px/1.5 ui-monospace, monospace; letter-spacing: 0.1em; color: var(--muted); }
.sidebar > .alpha-label { padding: 0 12px; }
#nav { display: flex; flex-direction: column; gap: 5px; margin-top: 38px; }
#nav a { display: flex; justify-content: space-between; padding: 10px 12px; border-radius: 8px; color: var(--muted); font-weight: 550; }
#nav a.active { background: #dfe9db; color: #24523a; }
#nav a:hover { text-decoration: none; color: var(--text); background: #e7ede2; }
.sidebar-note { font-size: 12px; line-height: 1.7; padding: 24px 12px; color: var(--muted); margin-top: auto; }
.sidebar-account { display: flex; align-items: flex-start; flex-direction: column; gap: 8px; padding: 18px 12px 0; border-top: 1px solid var(--line2); overflow-wrap: anywhere; }
.sidebar-account strong { font-size: 12px; }
.sidebar-account select { font-size: 12px; }
.view { max-width: 1280px; margin: 0 auto; padding: 44px clamp(24px, 4vw, 64px) 70px; display: flex; flex-direction: column; gap: 26px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 220px; }
.page-head .sub { color: var(--muted); margin-top: 10px; max-width: 65ch; }
.breadcrumb { display: inline-block; color: var(--muted); margin-bottom: 18px; font-size: 12px; }
.quiet-link { color: var(--muted); font-size: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.section-head p { font-size: 13px; margin-top: 6px; }

/* Panels, lists, tables */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0; overflow-x: auto; }
.panel-head { display: flex; align-items: center; gap: 8px; }
.panel-head .grow { flex: 1; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }
.work-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 16px; }
.work-card { color: var(--text); transition: border-color 120ms, box-shadow 120ms; }
.work-card:hover { text-decoration: none; border-color: #90aa91; box-shadow: 0 4px 18px #20362207; }
.work-card .goal { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-arrow { font-size: 20px; color: var(--accent); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: #f4f4f5; color: #3f3f46; border: 1px solid var(--line); }
.badge.red { background: var(--red-bg); color: var(--red); border-color: #fecaca; }
.badge.amber { background: var(--amber-bg); color: var(--amber); border-color: #fde68a; }
.badge.green { background: var(--green-bg); color: var(--green); border-color: #bbf7d0; }
.badge.blue { background: var(--accent-bg); color: var(--accent); border-color: #c7d2fe; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); }
tr:last-child td { border-bottom: none; }
.items { display: flex; flex-direction: column; }
.item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: none; }
.item .body { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.item .actions { display: flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; }
.item.dim { opacity: 0.6; }
.kv { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.empty { color: var(--muted); padding: 8px 0; }
details > summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 6px 0; }

/* Primary sections, with low-level records behind a secondary navigation. */
.tabs { display: flex; gap: 26px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs a { border-bottom: 2px solid transparent; padding: 12px 0; color: var(--muted); font-weight: 550; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--accent); }
.tabs .count { margin-left: 6px; font-size: 11px; }
.tab-body, .record-content { display: flex; flex-direction: column; gap: 20px; }
.record-nav { display: flex; flex-wrap: wrap; gap: 8px; }
.record-nav a { padding: 7px 12px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); font-size: 12px; }
.record-nav a.active { background: var(--accent-bg); color: var(--accent); }

/* Conflicts */
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.side { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fafafa; }
.side .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* Metrics */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 4px; border-left-width: 4px; }
.tile.good { border-left-color: var(--green); }
.tile.bad { border-left-color: var(--red); }
.tile.none { border-left-color: var(--line2); }
.tile .val { font-size: 24px; font-weight: 650; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 8px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar .fill { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar .cap { font-size: 10px; color: var(--muted); }

/* Dialogs and toasts */
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(560px, 92vw); color: var(--text); box-shadow: 0 24px 80px #152b2226; }
dialog::backdrop { background: #152b2259; }
dialog form { padding: 30px; display: flex; flex-direction: column; gap: 18px; }
dialog.wide { width: min(900px, 94vw); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: #111; color: #fff; padding: 9px 14px; border-radius: 8px; font-size: 13px; max-width: 360px; }
.toast.err { background: var(--red); }
.copy-row { display: flex; gap: 8px; }
.copy-row input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
ol.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.spinner { color: var(--muted); padding: 24px 0; }
.copy-block { display: flex; flex-direction: column; gap: 12px; }
.copy-block textarea { font: 12px/1.7 ui-monospace, monospace; background: var(--bg); min-height: 140px; }

/* Handoff-first home */
.hero { padding: 22px 0 8px; }
.hero h1 { font-size: clamp(32px, 3.8vw, 49px); margin-top: 14px; letter-spacing: -0.045em; }
.hero-copy { max-width: 600px; font-size: 16px; line-height: 1.75; color: var(--muted); margin: 20px 0 24px; }
.tool-trail { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin-top: 34px; color: var(--muted); font-size: 12px; font-weight: 600; }
.tool-trail span { color: #8b9a89; }
.workflow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 26px; padding: 26px 0 32px; margin: 0; list-style: none; border-bottom: 1px solid var(--line); }
.workflow li { display: flex; gap: 12px; }
.step-number { font: 11px/1.8 ui-monospace, monospace; color: var(--accent); }
.workflow p { font-size: 12px; color: var(--muted); line-height: 1.7; margin-top: 8px; }
.empty-state { display: flex; align-items: flex-start; flex-direction: column; gap: 16px; padding: 32px; background: white; border: 1px dashed #c6d2c2; border-radius: 12px; grid-column: 1 / -1; }
.empty-state p { max-width: 65ch; color: var(--muted); }
.empty-mark { display: grid; place-items: center; width: 40px; height: 40px; background: var(--accent-bg); color: var(--accent); border-radius: 10px; font-size: 24px; }

/* The artifact and decision log are the primary unit of work. */
.brief-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; align-items: start; gap: 24px; }
.brief-main, .handoff-rail { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.handoff-rail { position: sticky; top: 24px; }
.brief-summary { font-size: 18px; line-height: 1.7; }
.next-step { border-left: 2px solid #9cb999; padding: 4px 0 4px 16px; }
.next-step p { margin-top: 6px; color: var(--muted); }
.review-callout { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; padding: 14px 18px; background: var(--amber-bg); border: 1px solid #efdfb2; color: var(--amber); border-radius: 9px; font-size: 12px; }
.destination-panel { background: #eff4ec; border-color: #d5e1d0; padding: 22px; }
.destination-panel h2 { font-size: 20px; }
.destination { display: flex; align-items: center; gap: 12px; text-align: left; border: 1px solid #d3dfce; background: white; padding: 11px 12px; color: var(--text); }
.destination:hover:not(:disabled) { border-color: var(--accent); background: #f8fbf5; }
.tool-mark, .file-mark { display: grid; place-items: center; width: 30px; height: 30px; flex-shrink: 0; border-radius: 7px; background: var(--bg); color: var(--accent); font: 600 12px ui-monospace, monospace; }
.file-mark { width: 36px; height: 40px; border: 1px solid var(--line); }
.artifact-row { display: flex; gap: 14px; align-items: center; text-align: left; background: var(--bg); color: var(--text); border: 1px solid var(--line); padding: 14px; font-weight: 400; }
.artifact-row:hover { border-color: #94ac93; }
.artifact-row .grow { display: flex; flex-direction: column; gap: 4px; }
.artifact-row .muted { font-size: 12px; }
.brief-facts { display: grid; grid-template-columns: minmax(90px, 1fr) 2fr; gap: 14px 20px; margin: 0; }
.brief-facts dt { font-size: 12px; color: var(--muted); }
.brief-facts dd { margin: 0; overflow-wrap: anywhere; }
.brief-facts .badge { margin-left: 8px; }
.open-questions { margin: 0; padding-left: 18px; }
.open-questions li { padding: 8px 0; }
.source-start { border-color: #a8bfa2; background: #f0f6ec; }

@media (min-width: 1600px) { .view { padding-top: 60px; } }
@media (max-width: 1100px) {
  .brief-layout { grid-template-columns: minmax(0, 1fr); }
  .handoff-rail { position: static; order: -1; }
  .destination-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .destination-panel > :not(button) { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  #app { padding-left: 0; }
  .sidebar { position: static; width: auto; padding: 18px 20px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0; }
  .sidebar > .alpha-label, .sidebar-note { display: none; }
  #nav { flex-direction: row; margin-top: 8px; gap: 6px; flex-wrap: wrap; }
  #nav a { padding: 8px 10px; font-size: 12px; gap: 10px; }
  .sidebar-account { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 0 0; font-size: 12px; }
  .sidebar-account select { width: auto; max-width: 160px; }
  .view { padding: 26px 20px 50px; gap: 24px; }
  .workflow { grid-template-columns: 1fr; gap: 20px; }
  .tabs { gap: 18px; font-size: 12px; }
  .panel { padding: 20px; }
  .auth-screen { flex-direction: column; padding: 28px 20px; gap: 28px; }
  .auth-story h2 { font-size: 34px; margin-top: 24px; }
  .auth-story .tool-trail, .auth-story .auth-note { display: none; }
  .card { max-width: 490px; padding: 28px; }
  .sides { grid-template-columns: 1fr; }
  .section-head { align-items: flex-start; flex-wrap: wrap; }
  .item { flex-wrap: wrap; }
  .item .body { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
