:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --text: #1b2430;
  --muted: #687385;
  --line: #dde2e8;
  --accent: #1f5fbf;
  --accent-ink: #ffffff;
  --ok: #2e7d4f;
  --warn: #b26a00;
  --bad: #c0392b;
  --info: #5b4bc4;
  --col: #e9edf2;
  --radius: 8px;
  color-scheme: light dark;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #13171c;
    --panel: #1b2128;
    --text: #e5e8ec;
    --muted: #97a1af;
    --line: #2b333d;
    --accent: #5b9bff;
    --accent-ink: #0b1220;
    --ok: #4fbf7f;
    --warn: #e0a23a;
    --bad: #ef6b5b;
    --info: #9a8cff;
    --col: #171c22;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; overflow-wrap: anywhere; }
h2 { font-size: 16px; margin: 24px 0 10px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
code { font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--bg); padding: 1px 4px; border-radius: 4px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px; height: 52px; padding: 0 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--text); white-space: nowrap; }
.brand span { margin-left: 8px; font-weight: 400; color: var(--muted); }
.top nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.top nav a { padding: 6px 10px; border-radius: 6px; color: var(--text); white-space: nowrap; }
.top nav a.on { background: var(--bg); font-weight: 600; }
.me { display: flex; align-items: center; gap: 8px; color: var(--muted); white-space: nowrap; }
main { max-width: 1320px; margin: 0 auto; padding: 24px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel + .panel { margin-top: 16px; }
.panel h2:first-child { margin-top: 0; }
.login { max-width: 440px; margin: 80px auto; }
.narrow { max-width: 680px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.head h1 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.bad { color: var(--bad); }
.warn { color: var(--warn); font-weight: 600; }
.error { color: var(--bad); font-weight: 600; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.login .fields { margin: 12px 0; }
.scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
th, td { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
tr.mine td { background: var(--bg); }

.badge { display: inline-block; padding: 1px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.s-in_progress { color: var(--accent); border-color: currentColor; }
.s-review { color: var(--info); border-color: currentColor; }
.s-blocked { color: var(--bad); border-color: currentColor; }
.s-done { color: var(--ok); border-color: currentColor; }
.s-inbox { border-style: dashed; }
.s-refinement { color: var(--warn); border-color: currentColor; }
.s-release { color: var(--ok); border-color: currentColor; border-style: dashed; }
.epic { display: inline-block; padding: 0 6px; border-left: 3px solid var(--epic, var(--accent)); border-radius: 3px; background: var(--panel); font-size: 12px; }
.badge.q { border-color: var(--warn); color: var(--warn); }
.prio { font-size: 12px; font-weight: 600; }
.p-high { color: var(--warn); }
.p-critical { color: var(--bad); }
.due.hot { color: var(--warn); font-weight: 600; }
.due.overdue { color: var(--bad); font-weight: 600; }

.stages { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stage-head, .stage > summary { display: grid; grid-template-columns: minmax(0, 1fr) 110px 80px 170px; gap: 8px; padding: 8px 10px; align-items: center; }
.stage-head { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.stage { border-top: 1px solid var(--line); }
.stage > summary { cursor: pointer; list-style: none; }
.stage > summary::-webkit-details-marker { display: none; }
.stage > summary > span:first-child::before { content: "▸ "; color: var(--muted); }
.stage[open] > summary > span:first-child::before { content: "▾ "; }
.stage table { border: 0; border-radius: 0; border-top: 1px solid var(--line); }
td details > summary { cursor: pointer; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi b { display: block; font-size: 26px; }
.kpi span { color: var(--muted); }
a.kpi { display: block; color: inherit; text-decoration: none; }
a.kpi:hover, a.kpi:focus-visible { border-color: var(--accent); }
.bar { min-width: 120px; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 16px; }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { max-width: 100%; padding: 6px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
select { min-width: 0; }
textarea { width: 100%; min-height: 90px; }
button, .btn { display: inline-block; padding: 7px 14px; border: 0; border-radius: 6px; background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; }
button.secondary, .btn.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
button.link { padding: 0; background: none; color: var(--accent); font-weight: 400; }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin: 8px 0 16px; }
.filters label { display: flex; flex-direction: column; flex: 1 1 160px; min-width: 0; max-width: 100%; gap: 3px; font-size: 12px; color: var(--muted); }
.filters label > select, .filters label > input { width: 100%; }
.filters .search { flex: 2 1 220px; }
.filters label.chip { flex: 0 0 auto; flex-direction: row; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--text); font-size: 13px; cursor: pointer; }
.filters label.chip > input { width: auto; margin: 0; }
.filters label.chip:has(:checked) { border-color: var(--bad); color: var(--bad); }
.filters .more { align-self: end; padding-bottom: 8px; }
.filters .more[open] { flex-basis: 100%; }
.filters .more > summary { width: max-content; color: var(--accent); font-size: 13px; cursor: pointer; }
.filters .more .n { color: var(--muted); }
.filters .more > div { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin-top: 8px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
form.inline { display: inline; }

/* The board takes the whole width; each project is a lane with its numbers and a bar of its flow. */
main:has(.lanes) { max-width: none; }
/* minmax(0, …): a lane wider than the screen scrolls its board instead of widening the page. */
.lanes { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
.lane > summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin-bottom: 10px; cursor: pointer; list-style: none; }
.lane > summary::-webkit-details-marker { display: none; }
.lane > summary::before { content: "▾"; width: 12px; color: var(--muted); }
.lane:not([open]) > summary::before { content: "▸"; }
.lane h2 { margin: 0; font-size: 17px; }
.lane h2 a { color: var(--text); }
.stats { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); }
.stats .bad { font-weight: 600; }
.flow { display: flex; flex-basis: 100%; height: 4px; margin-left: 28px; overflow: hidden; border-radius: 2px; background: var(--line); }
.f-done, .f-release { background: var(--ok); }
.f-release { opacity: .55; }
.f-review { background: var(--info); }
.f-in_progress { background: var(--accent); }
.f-blocked { background: var(--bad); }
/* Columns share the width: an empty one shrinks to its header, a wide one lays its cards out in several rows. */
.board { display: flex; gap: 10px; align-items: flex-start; overflow-x: auto; padding-bottom: 6px; }
.col { flex: 1 1 0; min-width: 200px; padding: 8px; background: var(--col); border-top: 3px solid var(--line); border-radius: var(--radius); }
.col.empty { flex: 0 0 150px; min-width: 150px; }
.col[data-status="refinement"] { border-top-color: var(--warn); }
.col[data-status="in_progress"] { border-top-color: var(--accent); }
.col[data-status="review"] { border-top-color: var(--info); }
.col[data-status="blocked"] { border-top-color: var(--bad); }
.col[data-status="release"], .col[data-status="done"] { border-top-color: var(--ok); }
.col.over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.col h3 { display: flex; justify-content: space-between; gap: 8px; margin: 2px 4px 8px; font-size: 13px; }
.col h3 .n { color: var(--muted); font-weight: 400; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 8px; align-content: start; min-height: 32px; }
/* A long token in a title (NODE_TLS_REJECT_UNAUTHORIZED=0) breaks inside the card instead of sticking out. */
.card { padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: 6px; cursor: grab; overflow-wrap: anywhere; }
.card.dragging { opacity: .4; }
.card.p-high { border-left-color: var(--warn); }
.card.p-critical { border-left-color: var(--bad); }
.card .title { color: var(--text); }
.card .title:hover { color: var(--accent); text-decoration: none; }
.card .key { margin-right: 2px; color: var(--muted); font-size: 12px; font-weight: 600; }
.card footer { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.rest { display: block; margin: 8px 4px 2px; font-size: 13px; }

.task { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.task aside { position: sticky; top: 68px; }
.task > *, .grid2 > * { min-width: 0; }
.desc { white-space: pre-wrap; word-break: break-word; }
.comment { padding: 10px 0; border-top: 1px solid var(--line); }
.comment.report { padding: 10px; border-radius: 6px; background: color-mix(in srgb, var(--info) 8%, transparent); }
.fields label { display: block; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.fields label > input, .fields label > select, .fields label > textarea { display: block; width: 100%; margin-top: 3px; font-size: 14px; color: var(--text); }
pre.cmd { margin: 6px 0 10px; padding: 10px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; }
.steps li { margin-bottom: 16px; }
.rows form { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.check { display: flex; align-items: center; gap: 6px; }
.changes div { font-size: 13px; }

@media (max-width: 900px) {
  .task { grid-template-columns: 1fr; }
  .task aside { position: static; }
}
@media (max-width: 640px) {
  main { padding: 16px; }
  .top { gap: 12px; padding: 0 16px; }
  .brand span { display: none; }
  .board { scroll-snap-type: x mandatory; }
  .col { flex: 0 0 82%; scroll-snap-align: start; }
  .col.empty { flex: 0 0 45%; min-width: 0; }
}
