/* Kosken. Tokens first, then shell, surfaces, forms, tables. Direction: DESIGN.md. */
@font-face { font-family: "Plex Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("/static/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Plex Sans"; font-weight: 500; font-style: normal; font-display: swap; src: url("/static/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Plex Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url("/static/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Plex Mono"; font-weight: 400; font-style: normal; font-display: swap; src: url("/static/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Plex Mono"; font-weight: 500; font-style: normal; font-display: swap; src: url("/static/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }

:root {
  --bg: #f5f3ee; --surface: #fcfbf8; --surface-2: #ece9e1; --border: #dcd8cc; --border-strong: #bdb8a8;
  --text: #1d211f; --muted: #596059;
  --accent: #1c6b55; --accent-text: #ffffff; --accent-soft: #dcebe4;
  --ok: #1c6b55; --ok-bg: #dcebe4; --warn: #85560a; --warn-bg: #f6e7c4; --bad: #a2282f; --bad-bg: #f6dcda; --info: #2a5a8c; --info-bg: #dde8f3;
  --focus: #0c4a38; --radius: 10px; --radius-sm: 6px; --gap: 16px; --pop: 0 8px 28px rgba(29,33,31,.16);
  --font: "Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --side: 244px; --top: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1311; --surface: #151b18; --surface-2: #1c2420; --border: #2a3430; --border-strong: #3d4a44;
    --text: #e8ece9; --muted: #9aa6a0;
    --accent: #5ccfa6; --accent-text: #072016; --accent-soft: #14302a;
    --ok: #5ccfa6; --ok-bg: #123226; --warn: #e6b655; --warn-bg: #352a0e; --bad: #ff8d86; --bad-bg: #3b1a1a; --info: #8db8ea; --info-bg: #17283b;
    --focus: #9be7cb; --pop: 0 8px 28px rgba(0,0,0,.5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1311; --surface: #151b18; --surface-2: #1c2420; --border: #2a3430; --border-strong: #3d4a44;
  --text: #e8ece9; --muted: #9aa6a0;
  --accent: #5ccfa6; --accent-text: #072016; --accent-soft: #14302a;
  --ok: #5ccfa6; --ok-bg: #123226; --warn: #e6b655; --warn-bg: #352a0e; --bad: #ff8d86; --bad-bg: #3b1a1a; --info: #8db8ea; --info-bg: #17283b;
  --focus: #9be7cb; --pop: 0 8px 28px rgba(0,0,0,.5); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.55 var(--font); font-feature-settings: "ss01" 0; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 1.75rem; line-height: 1.2; font-weight: 600; letter-spacing: -.02em; margin: 0 0 .25rem; }
h2 { font-size: 1.0625rem; line-height: 1.3; font-weight: 600; letter-spacing: -.005em; margin: 0 0 .75rem; }
h3 { font-size: .95rem; font-weight: 600; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
code, pre, .mono, kbd { font-family: var(--mono); font-size: .86em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
pre code { background: none; padding: 0; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-text); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* shell */
.top { display: flex; align-items: center; gap: 10px; height: var(--top); padding: 0 20px; background: color-mix(in srgb, var(--bg) 92%, var(--surface)); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 600; letter-spacing: -.01em; color: var(--text); text-decoration: none; font-size: 1.0625rem; display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 20px; height: 20px; background: var(--accent); display: inline-block; border-radius: 4px; clip-path: polygon(0 0, 100% 0, 100% 62%, 62% 100%, 0 100%); }
.top .grow { flex: 1; }
.top .muted { font-family: var(--mono); font-size: .82rem; padding-left: 10px; border-left: 1px solid var(--border-strong); line-height: 1; }
.top select { width: auto; min-height: 32px; padding: 3px 28px 3px 10px; font-size: .85rem; border-color: transparent; background-color: transparent; }
.top select:hover { border-color: var(--border); }
.top [role=group] { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.top [role=group] .btn { border-radius: 0; min-height: 30px; padding: 3px 10px; font-weight: 400; color: var(--muted); }
.top [role=group] .btn + .btn { border-left: 1px solid var(--border); }
.top [role=group] .btn[aria-pressed=true] { background: var(--surface-2); color: var(--text); font-weight: 500; }
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: calc(100vh - var(--top) - 50px); }
.shell.nosidebar { grid-template-columns: minmax(0, 1fr); }
.side { border-right: 1px solid var(--border); padding: 20px 12px 16px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto; }
.side h2 { font-size: .75rem; font-weight: 500; letter-spacing: .01em; color: var(--muted); margin: 0 10px 6px; }
.side a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; transition: background-color .12s; }
.side a:hover { background: var(--surface-2); }
.side a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.side .spacer { flex: 1; }
.main { padding: 32px 40px 48px; max-width: 1240px; width: 100%; margin: 0 auto; }
.nosidebar .main { max-width: 1080px; }
.narrow { max-width: 440px; margin: 56px auto; }
.narrow > h1 { margin-bottom: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.page-head .sub { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.foot { padding: 14px 24px; color: var(--muted); font-size: .78rem; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.foot code { background: none; padding: 0; }

/* surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: var(--gap); }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: var(--gap); }
.grid { margin-bottom: var(--gap); }
.grid > .card { margin-bottom: 0; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 16px 20px; }
.stat .n { font-size: 2rem; line-height: 1.1; font-weight: 500; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: .85rem; }

/* forms */
label { display: block; font-weight: 500; font-size: .88rem; margin-bottom: 5px; }
.field { margin-bottom: 16px; }
.hint { color: var(--muted); font-size: .82rem; margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=url], input[type=datetime-local], select, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; min-height: 40px; transition: border-color .12s, box-shadow .12s; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent); }
td select, td input[type=text], td input[type=number] { width: auto; min-height: 32px; padding: 3px 10px; }
textarea { min-height: 110px; resize: vertical; font-family: var(--mono); font-size: .88em; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; vertical-align: -3px; margin-right: 8px; accent-color: var(--accent); }
.check { display: flex; align-items: center; font-weight: 400; margin: 6px 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 7px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; transition: background-color .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); border-color: transparent; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: var(--bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { min-height: 32px; padding: 3px 11px; font-size: .86rem; }
.btn[disabled], .btn[aria-disabled=true] { opacity: .5; cursor: not-allowed; }
.inline { display: inline; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 180px; margin-bottom: 0; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 0 0 16px; padding: 12px 14px; }
legend { font-weight: 500; padding: 0 6px; }

/* messages */
.flash { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 20px; border: 1px solid; display: flex; gap: 8px; align-items: flex-start; font-size: .92rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.flash.error { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.flash.info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 45%, transparent); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 1px 8px; border-radius: 4px; font-size: .78rem; font-weight: 500; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); white-space: nowrap; line-height: 1.6; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.badge.bad .dot { border-radius: 1px; transform: rotate(45deg); }
.badge.warn .dot { border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }

/* tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; color: var(--muted); font-weight: 500; white-space: nowrap; padding-top: 6px; padding-bottom: 8px; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.group td { background: var(--surface-2); font-weight: 500; }
meter { width: 84px; height: 10px; vertical-align: middle; }
.empty { text-align: center; padding: 44px 16px 36px; color: var(--muted); max-width: 520px; margin: 0 auto; }
.empty h2 { color: var(--text); font-size: 1.125rem; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 500; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); border-color: var(--accent); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border-strong); margin-left: 6px; }
.timeline li { position: relative; padding: 0 0 20px 22px; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 7px; width: 9px; height: 9px; background: var(--bg); border: 2px solid var(--muted); border-radius: 50%; }
.timeline li.k-guardian::before, .timeline li.k-gate::before { border-color: var(--warn); border-radius: 0; }
.timeline li.k-execution::before, .timeline li.k-rollback::before { border-color: var(--bad); border-radius: 1px; transform: rotate(45deg); }
.timeline li.k-verification::before { border-color: var(--ok); background: var(--ok); }
.timeline .meta { color: var(--muted); font-size: .8rem; font-family: var(--mono); }
.timeline .quoted { border-left: 2px solid var(--border-strong); padding-left: 12px; color: var(--muted); }

/* dialog */
dialog { border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 24px; width: min(520px, 92vw); box-shadow: var(--pop); }
dialog::backdrop { background: rgba(8,12,10,.55); }
.copybox { display: flex; gap: 8px; align-items: stretch; }
.copybox pre { flex: 1; margin: 0; }

/* chart */
.chart { width: 100%; height: 160px; display: block; }
.chart-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); }

/* sign-in pages: one centered column, the card is the focus */
.narrow .card { padding: 24px; }
.narrow .card .actions .btn.primary { flex: 1; }
.sso-row { display: grid; gap: 8px; margin: 12px 0; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); margin: 16px 0; font-size: .85rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

/* landing: the pipeline is the page. Mono labels carry the machine facts. */
.landing { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 72px; align-items: start; padding: 56px 0 24px; }
.landing h1 { font-size: clamp(2rem, 4.2vw, 3.1rem); line-height: 1.08; letter-spacing: -.03em; font-weight: 600; margin-bottom: 18px; }
.landing .lede { font-size: 1.125rem; color: var(--muted); max-width: 34ch; margin-bottom: 28px; }
.pipeline { list-style: none; margin: 0; padding: 0; counter-reset: step; border-top: 1px solid var(--border-strong); }
.pipeline li { counter-increment: step; display: grid; grid-template-columns: 3.2rem 1fr; gap: 4px 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.pipeline li::before { content: counter(step, decimal-leading-zero); font-family: var(--mono); font-size: .8rem; color: var(--muted); padding-top: 3px; grid-row: span 2; }
.pipeline b { font-weight: 600; }
.pipeline span { color: var(--muted); font-size: .92rem; }
.pipeline li.gate b { color: var(--accent); }

@media (max-width: 960px) {
  .grid.c3, .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; gap: 4px 10px; border-right: 0; border-bottom: 1px solid var(--border); padding: 10px 12px; overflow: visible; }
  .side > div { display: contents; }
  .side h2 { display: none; }
  .side .spacer { display: none; }
  .landing { grid-template-columns: minmax(0, 1fr); gap: 36px; padding-top: 32px; }
  .main { padding: 24px 20px 40px; }
}
@media (max-width: 640px) {
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: minmax(0, 1fr); }
  .top { padding: 0 12px; gap: 6px; flex-wrap: wrap; height: auto; min-height: var(--top); padding-block: 8px; }
  .main { padding: 20px 16px 36px; }
  .narrow { margin: 28px auto; }
  .btn { min-height: 44px; }
  .btn.small { min-height: 36px; }
  table.stack thead { display: none; }
  table.stack tr { display: block; border-bottom: 1px solid var(--border); padding: 8px 0; }
  table.stack td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 0; text-align: right; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-weight: 500; text-align: left; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

[hidden] { display: none !important; }
.kicker { font-size: .85rem; font-weight: 500; color: var(--muted); margin-bottom: 10px; }
