:root {
  --bg: #f6f5f1; --surface: #ffffff; --ink: #1c2227; --muted: #5f6b76; --line: #dcdcd4; --line-soft: #ebeae4;
  --accent: #1f5f5b; --accent-ink: #ffffff; --accent-soft: #e2efed;
  --ok: #1d6b3f; --ok-bg: #e3f2e7; --warn: #8a5300; --warn-bg: #fdf0d5; --danger: #a12626; --danger-bg: #fbe4e2; --info: #1e4f8a; --info-bg: #e3edf9;
  --syn: #6b2d8f; --syn-bg: #f1e6f8;
  --radius: 8px; --shadow: 0 1px 2px rgba(20, 30, 40, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1 { font-size: 1.45rem; line-height: 1.25; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
h3 { font-size: .95rem; margin: 0 0 .4rem; }
p { margin: 0 0 .7rem; }
small, .small { font-size: .84rem; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
:focus-visible { outline: 3px solid #f2b705; outline-offset: 2px; }

.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.side { background: #14292b; color: #d8e3e2; padding: 14px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side a { color: inherit; text-decoration: none; display: block; padding: 6px 10px; border-radius: 6px; }
.side a:hover, .side a[aria-current="page"] { background: rgba(255, 255, 255, .11); color: #fff; }
.brand { font-weight: 700; font-size: 1.05rem; color: #fff; padding: 4px 10px 12px; display: flex; gap: 8px; align-items: center; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: #e9b44c; display: inline-block; }
.side h2 { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #8fa7a6; margin: 16px 10px 4px; }
.side .count { float: right; background: #e9b44c; color: #1c2227; border-radius: 999px; padding: 0 7px; font-size: .75rem; font-weight: 700; }
.side .who { margin-top: 18px; padding: 10px; border-top: 1px solid rgba(255, 255, 255, .14); font-size: .84rem; }
.side button.link { color: #d8e3e2; }
.navtoggle { display: none; }
.main { padding: 22px 28px 60px; max-width: 1180px; width: 100%; }
.topbar { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.topbar form.search { flex: 1 1 260px; display: flex; gap: 6px; }
.crumbs { font-size: .86rem; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 14px; }
.head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card > h2:first-child { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 16px; align-items: start; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 1.5rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .84rem; }

.badge { display: inline-block; font-size: .74rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--line-soft); color: var(--ink); white-space: nowrap; vertical-align: middle; }
.badge-ok { background: var(--ok-bg); color: var(--ok); } .badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); } .badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: #eeeeea; color: var(--muted); }
.badge-synthetic { background: var(--syn-bg); color: var(--syn); border: 1px dashed var(--syn); }
.due { font-size: .84rem; font-weight: 600; white-space: nowrap; }
.due-danger { color: var(--danger); } .due-warn { color: var(--warn); } .due-neutral { color: var(--muted); }

.banner { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; border: 1px solid; }
.banner-ok { background: var(--ok-bg); border-color: #b6dcc2; color: var(--ok); }
.banner-warn { background: var(--warn-bg); border-color: #efd28f; color: var(--warn); }
.banner-danger { background: var(--danger-bg); border-color: #eeb8b3; color: var(--danger); }
.banner-info { background: var(--info-bg); border-color: #bdd3ee; color: var(--info); }
.banner-synthetic { background: var(--syn-bg); border: 1px dashed var(--syn); color: var(--syn); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.tablewrap { overflow-x: auto; }
ul.list { list-style: none; margin: 0; padding: 0; }
ul.list > li { padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
ul.list > li:last-child { border-bottom: 0; }
.row { display: flex; gap: 10px; justify-content: space-between; align-items: baseline; flex-wrap: wrap; }
.row .meta { color: var(--muted); font-size: .84rem; }
.empty { color: var(--muted); font-style: italic; margin: 4px 0; }
dl.kv { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 6px 14px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .86rem; } dl.kv dd { margin: 0; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
blockquote { margin: 6px 0; padding: 4px 12px; border-left: 3px solid var(--line); color: var(--muted); }

form.stack > * + * { margin-top: 10px; }
.field { display: block; }
.field-label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: 3px; }
.field-hint { display: block; color: var(--muted); font-size: .8rem; margin-top: 2px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=datetime-local], input[type=search], input[type=number], input[type=file], select, textarea {
  width: 100%; font: inherit; padding: 7px 9px; border: 1px solid #b9bcb6; border-radius: 6px; background: #fff; color: var(--ink); min-height: 38px; }
textarea { min-height: 90px; resize: vertical; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline > * { flex: 1 1 150px; } .inline > .fit { flex: 0 0 auto; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 4px; }
button, .btn { font: inherit; font-weight: 600; cursor: pointer; border-radius: 6px; padding: 7px 14px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); text-decoration: none; display: inline-block; min-height: 38px; }
button:hover, .btn:hover { filter: brightness(1.08); }
.btn-secondary, button.secondary { background: var(--surface); color: var(--accent); }
.btn-danger, button.danger { background: var(--danger); border-color: var(--danger); }
.btn-small, button.small { padding: 3px 10px; min-height: 30px; font-size: .84rem; }
button.link { background: none; border: 0; color: var(--accent); padding: 0; min-height: 0; text-decoration: underline; font-weight: 400; }
button[disabled], .btn[aria-disabled=true] { opacity: .5; cursor: not-allowed; }
details.disclose { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; background: #fbfbf8; }
details.disclose + details.disclose { margin-top: 8px; }
details.disclose > summary { cursor: pointer; font-weight: 600; }
details.disclose[open] > summary { margin-bottom: 10px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 600; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .n { font-weight: 400; color: var(--muted); }

.state { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.state > div { background: #fbfbf8; border: 1px solid var(--line-soft); border-radius: 6px; padding: 10px 12px; }
.state .k { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: block; }
.state .v { font-weight: 600; overflow-wrap: anywhere; }

.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 16px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.timeline li.failed::before { background: var(--danger); } .timeline li.pending::before { background: #d39b1d; } .timeline li.info::before { background: #9aa5ad; }
.timeline .when { font-size: .8rem; color: var(--muted); }
.timeline .failed .what { color: var(--danger); font-weight: 600; }

.tree, .tree ul { list-style: none; margin: 0; padding-left: 0; }
.tree ul { padding-left: 18px; }
.tree summary { cursor: pointer; padding: 2px 0; }
.tree .leaf { padding: 2px 0 2px 18px; }

.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.col { flex: 0 0 270px; background: #ecebe5; border-radius: var(--radius); padding: 8px; min-height: 120px; }
.col.over { outline: 3px dashed var(--accent); }
.col h3 { display: flex; justify-content: space-between; gap: 6px; font-size: .84rem; padding: 2px 4px 6px; }
.col .n { background: #fff; border-radius: 999px; padding: 0 8px; font-weight: 600; }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; margin-bottom: 8px; box-shadow: var(--shadow); }
.kcard[draggable=true] { cursor: grab; }
.kcard.dragging { opacity: .45; }
.kcard a.title { font-weight: 600; text-decoration: none; color: var(--ink); display: block; }
.kcard .meta { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.kcard details { margin-top: 6px; font-size: .84rem; }
.kcard details a { display: block; padding: 3px 0; }

.msg { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; background: #fff; }
.msg header { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.msg.outbound header { background: var(--accent-soft); }
.msg .body { padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg footer { padding: 8px 12px; border-top: 1px solid var(--line-soft); font-size: .86rem; }
.review dl.kv dd { font-weight: 600; }
.chat { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; background: #fff; }
.chat.assistant { background: #f7f7f2; } .chat.offbranch { opacity: .6; border-style: dashed; }
.auth { max-width: 420px; margin: 8vh auto; padding: 0 16px; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: step; padding: 10px 0 10px 40px; position: relative; border-bottom: 1px solid var(--line-soft); }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 10px; width: 26px; height: 26px; border-radius: 50%; background: var(--line-soft); text-align: center; font-weight: 700; line-height: 26px; }
.steps li.done::before { content: "✓"; background: var(--ok-bg); color: var(--ok); }
.fab { position: fixed; right: 18px; bottom: 18px; border-radius: 999px; padding: 12px 18px; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); z-index: 20; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 8px 12px; }
  .side nav { display: none; }
  .side.open nav { display: block; }
  .navtoggle { display: inline-block; background: transparent; border-color: rgba(255, 255, 255, .4); float: right; }
  .main { padding: 14px 14px 80px; }
  .split { grid-template-columns: 1fr; }
  dl.kv { grid-template-columns: 1fr; gap: 0 0; } dl.kv dd { margin-bottom: 8px; }
  .col { flex-basis: 82vw; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat b { font-size: 1.25rem; }
  .brand { justify-content: space-between; }
  .brand .navtoggle { margin-left: auto; }
  h1 { font-size: 1.25rem; }
}
@media print { .side, .topbar, .fab, form { display: none !important; } .shell { display: block; } }

/* spacing utilities (no inline styles: the Content Security Policy forbids them) */
.mt-4 { margin-top: 4px; } .mt-6 { margin-top: 6px; } .mt-8 { margin-top: 8px; } .mt-10 { margin-top: 10px; } .mt-12 { margin-top: 12px; } .mt-14 { margin-top: 14px; }
.mb-16 { margin-bottom: 16px; } .py-6 { padding: 6px 0; } .py-8 { padding: 8px 0; } .pad-4 { padding: 4px; } .w-70 { width: 70px; }
.inline-form { display: inline; } a.plain { text-decoration: none; color: inherit; } .brand.brand-plain { color: inherit; padding-left: 0; }
mark { background: #fff2b3; padding: 0 2px; }
