/* Commerce Hub — styles. All classes are prefixed ch- (robots: chr-). No external fonts. */

:root {
  color-scheme: light;
  --ch-bg: #f5f6f8;
  --ch-surface: #ffffff;
  --ch-surface-2: #f0f2f5;
  --ch-border: #d9dee6;
  --ch-text: #111827;
  --ch-muted: #556070;
  --ch-accent: #4338ca;
  --ch-accent-hover: #3730a3;
  --ch-accent-text: #ffffff;
  --ch-focus: #2563eb;
  --ch-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .06);
  --ch-err-bg: #fef2f2; --ch-err-fg: #991b1b; --ch-err-border: #fca5a5;
  --ch-ok-bg: #ecfdf5; --ch-ok-fg: #065f46;
  --ch-warn-bg: #fffbeb; --ch-warn-fg: #92400e;
  --ch-n-bg: #eef1f5; --ch-n-fg: #374151;
  --ch-blue-bg: #e0ecff; --ch-blue-fg: #1e40af;
  --ch-amber-bg: #fef3c7; --ch-amber-fg: #92400e;
  --ch-violet-bg: #ede9fe; --ch-violet-fg: #5b21b6;
  --ch-orange-bg: #ffedd5; --ch-orange-fg: #9a3412;
  --ch-red-bg: #fee2e2; --ch-red-fg: #991b1b;
  --ch-green-bg: #dcfce7; --ch-green-fg: #166534;
  --ch-env-staging: #b45309; --ch-env-local: #1d4ed8; --ch-env-ci: #6d28d9;
  --ch-top-h: 56px;
  --ch-radius: 10px;
  --ch-gutter: 16px;
}

/* Dark theme: system preference unless forced light, or forced dark via the toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ch-bg: #0e1116; --ch-surface: #161b22; --ch-surface-2: #1d232c; --ch-border: #303844;
    --ch-text: #e6edf3; --ch-muted: #9ba7b6; --ch-accent: #8b93ff; --ch-accent-hover: #a5abff; --ch-accent-text: #0b0f19;
    --ch-focus: #7cb3ff; --ch-shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --ch-err-bg: #2a1215; --ch-err-fg: #fca5a5; --ch-err-border: #7f1d1d;
    --ch-ok-bg: #0f2a1f; --ch-ok-fg: #86efac; --ch-warn-bg: #2b2111; --ch-warn-fg: #fcd34d;
    --ch-n-bg: #262d37; --ch-n-fg: #cbd5e1; --ch-blue-bg: #172554; --ch-blue-fg: #93c5fd;
    --ch-amber-bg: #3a2a0a; --ch-amber-fg: #fcd34d; --ch-violet-bg: #2e1f5c; --ch-violet-fg: #c4b5fd;
    --ch-orange-bg: #3b1d0b; --ch-orange-fg: #fdba74; --ch-red-bg: #3b1214; --ch-red-fg: #fca5a5;
    --ch-green-bg: #0f2e1b; --ch-green-fg: #86efac;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ch-bg: #0e1116; --ch-surface: #161b22; --ch-surface-2: #1d232c; --ch-border: #303844;
  --ch-text: #e6edf3; --ch-muted: #9ba7b6; --ch-accent: #8b93ff; --ch-accent-hover: #a5abff; --ch-accent-text: #0b0f19;
  --ch-focus: #7cb3ff; --ch-shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --ch-err-bg: #2a1215; --ch-err-fg: #fca5a5; --ch-err-border: #7f1d1d;
  --ch-ok-bg: #0f2a1f; --ch-ok-fg: #86efac; --ch-warn-bg: #2b2111; --ch-warn-fg: #fcd34d;
  --ch-n-bg: #262d37; --ch-n-fg: #cbd5e1; --ch-blue-bg: #172554; --ch-blue-fg: #93c5fd;
  --ch-amber-bg: #3a2a0a; --ch-amber-fg: #fcd34d; --ch-violet-bg: #2e1f5c; --ch-violet-fg: #c4b5fd;
  --ch-orange-bg: #3b1d0b; --ch-orange-fg: #fdba74; --ch-red-bg: #3b1214; --ch-red-fg: #fca5a5;
  --ch-green-bg: #0f2e1b; --ch-green-fg: #86efac;
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--ch-top-h) + 8px); }
body {
  margin: 0; background: var(--ch-bg); color: var(--ch-text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}
body.ch-noscroll { overflow: hidden; }
a { color: var(--ch-accent); }
a:hover { color: var(--ch-accent-hover); }
h1, h2, h3, h4 { line-height: 1.25; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--ch-focus); outline-offset: 2px; border-radius: 4px; }
.ch-muted { color: var(--ch-muted); }
.ch-small { font-size: 13px; }
.ch-strong { font-weight: 600; }
.ch-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.ch-break { overflow-wrap: anywhere; }
.ch-errtext { color: var(--ch-err-fg); }
.ch-warntext { color: var(--ch-warn-fg); }
.ch-h2 { font-size: 17px; margin: 0 0 12px; }
.ch-h3 { font-size: 15px; margin: 20px 0 8px; }
.ch-noscript { padding: 16px; }

.ch-skip { position: absolute; left: 8px; top: -60px; z-index: 100; padding: 8px 12px; border-radius: 6px;
  background: var(--ch-accent); color: var(--ch-accent-text); border: 0; font: inherit; }
.ch-skip:focus { top: 8px; }

/* ---------------------------------------------------------------- buttons and forms */
.ch-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--ch-border);
  background: var(--ch-surface); color: var(--ch-text); font: inherit; font-weight: 600; cursor: pointer;
}
.ch-btn:hover { background: var(--ch-surface-2); }
.ch-btn:disabled { opacity: .6; cursor: not-allowed; }
.ch-btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.ch-btn-block { width: 100%; }
.ch-btn-primary { background: var(--ch-accent); border-color: var(--ch-accent); color: var(--ch-accent-text); }
.ch-btn-primary:hover { background: var(--ch-accent-hover); }
.ch-btn-ok { background: #15803d; border-color: #15803d; color: #fff; }
.ch-btn-ok:hover { background: #166534; }
.ch-btn-danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.ch-btn-danger:hover { background: #991b1b; }
.ch-btn-danger-ghost { color: var(--ch-red-fg); border-color: var(--ch-err-border); }
.ch-btn-ghost { background: transparent; }
.ch-busy { position: relative; }
.ch-busy::after {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: ch-rot .8s linear infinite;
}
.ch-iconbtn {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
  border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ch-text); cursor: pointer;
}
.ch-iconbtn:hover { background: var(--ch-surface-2); }
.ch-linkbtn {
  background: none; border: 0; padding: 0; color: var(--ch-accent); font: inherit; cursor: pointer;
  text-align: left; text-decoration: underline; text-underline-offset: 2px;
}

.ch-form { display: grid; gap: 12px; }
.ch-formrow { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.ch-field { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
.ch-field-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; min-height: 38px; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--ch-border);
  background: var(--ch-surface); color: var(--ch-text); font: inherit; font-weight: 400;
}
.ch-field-inline select { width: auto; max-width: 220px; }
textarea { resize: vertical; }
.ch-fieldset { border: 1px solid var(--ch-border); border-radius: 8px; padding: 10px 12px; margin: 0; display: grid; gap: 8px; min-width: 0; }
.ch-fieldset legend { font-size: 13px; font-weight: 600; padding: 0 4px; }
.ch-check { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; }
.ch-check input { margin-top: 3px; width: 16px; height: 16px; flex: none; }
.ch-checkgrid { display: grid; gap: 6px 14px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.ch-pass { position: relative; }
.ch-pass input { padding-right: 46px; }
.ch-pass .ch-eye { position: absolute; right: 1px; top: 50%; transform: translateY(-50%); }
.ch-pass .ch-eye[aria-pressed="true"] { color: var(--ch-accent); }
.ch-form-error, .ch-errbox {
  background: var(--ch-err-bg); color: var(--ch-err-fg); border: 1px solid var(--ch-err-border);
  border-radius: 8px; padding: 8px 12px; font-size: 14px; overflow-wrap: anywhere;
}
.ch-errbox p { margin: 4px 0 0; white-space: pre-wrap; }
.ch-note { background: var(--ch-warn-bg); color: var(--ch-warn-fg); border-radius: 8px; padding: 8px 12px; margin: 0 0 12px; font-size: 14px; }
.ch-btnrow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ---------------------------------------------------------------- top bar */
.ch-top { position: sticky; top: 0; z-index: 30; }
.ch-env { padding: 6px var(--ch-gutter); font-size: 13px; font-weight: 700; letter-spacing: .02em; color: #fff; text-align: center; background: #475569; }
.ch-env-staging { background: var(--ch-env-staging); }
.ch-env-local { background: var(--ch-env-local); }
.ch-env-ci { background: var(--ch-env-ci); }
.ch-header {
  display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 8px var(--ch-gutter);
  background: var(--ch-surface); border-bottom: 1px solid var(--ch-border);
}
.ch-brand { font-weight: 800; font-size: 16px; color: var(--ch-text); text-decoration: none; white-space: nowrap; }
.ch-header-spacer { flex: 1; }
.ch-whoami { font-size: 13px; color: var(--ch-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.ch-conn { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.ch-conn:empty { display: none; }
.ch-conn-ok { background: var(--ch-green-bg); color: var(--ch-green-fg); }
.ch-conn-bad { background: var(--ch-red-bg); color: var(--ch-red-fg); }
.ch-menubtn { display: none; }

.ch-boot { padding: 48px var(--ch-gutter); text-align: center; color: var(--ch-muted); }

/* ---------------------------------------------------------------- login */
.ch-login { display: grid; place-items: center; min-height: calc(100vh - var(--ch-top-h)); padding: 24px var(--ch-gutter); }
.ch-login-card {
  width: 100%; max-width: 380px; display: grid; gap: 12px; padding: 24px;
  background: var(--ch-surface); border: 1px solid var(--ch-border); border-radius: 14px; box-shadow: var(--ch-shadow);
}
.ch-login-title { margin: 0; font-size: 22px; }
.ch-login-card p { margin: 0; }

/* ---------------------------------------------------------------- layout */
.ch-app { display: grid; grid-template-columns: 240px minmax(0, 1fr); grid-template-areas: "nav live" "nav main"; grid-template-rows: auto 1fr; }
.ch-nav {
  grid-area: nav; position: sticky; top: var(--ch-top-h); align-self: start;
  height: calc(100vh - var(--ch-top-h)); overflow-y: auto; padding: 12px 10px;
  background: var(--ch-surface); border-right: 1px solid var(--ch-border);
  display: flex; flex-direction: column;
}
.ch-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.ch-nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; border-radius: 8px; color: var(--ch-text); text-decoration: none; font-weight: 500;
}
.ch-nav a:hover { background: var(--ch-surface-2); }
.ch-nav a[aria-current="page"] { background: var(--ch-blue-bg); color: var(--ch-blue-fg); font-weight: 700; }
.ch-navbadge { min-width: 22px; padding: 0 7px; border-radius: 999px; font-size: 12px; font-weight: 700; text-align: center; background: var(--ch-blue-bg); color: var(--ch-blue-fg); }
.ch-navbadge-warn { background: var(--ch-violet-bg); color: var(--ch-violet-fg); }
.ch-navbadge-bad { background: var(--ch-red-bg); color: var(--ch-red-fg); }
.ch-nav-actions { display: none; gap: 8px; flex-wrap: wrap; padding: 12px 12px 0; margin-top: auto; }
.ch-nav-foot { margin-top: auto; padding: 12px; font-size: 12px; color: var(--ch-muted); overflow-wrap: anywhere; }
.ch-scrim { display: none; }
.ch-livebar { grid-area: live; margin: 12px var(--ch-gutter) 0; padding: 8px 12px; border-radius: 8px; background: var(--ch-err-bg); color: var(--ch-err-fg); border: 1px solid var(--ch-err-border); font-size: 14px; }
.ch-main { grid-area: main; min-width: 0; padding: 20px 24px 48px; max-width: 1400px; width: 100%; }
.ch-main:focus { outline: none; }
.ch-viewhead { margin-bottom: 16px; }
.ch-viewhead h1 { margin: 0 0 4px; font-size: 24px; }
.ch-viewhead p { margin: 0; }

.ch-panel { background: var(--ch-surface); border: 1px solid var(--ch-border); border-radius: var(--ch-radius); padding: 16px; margin-top: 16px; box-shadow: var(--ch-shadow); min-width: 0; }
.ch-panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.ch-panel-head .ch-h2 { margin: 0; }
.ch-filters { display: flex; flex-wrap: wrap; gap: 10px; }
.ch-grid2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.ch-grid2 > .ch-panel { margin-top: 16px; }
.ch-empty { color: var(--ch-muted); margin: 4px 0; font-size: 14px; }
.ch-placeholder ul { margin: 0; padding-left: 20px; }
.ch-placeholder li { margin: 4px 0; }

/* ---------------------------------------------------------------- pills and badges */
.ch-pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--ch-n-bg); color: var(--ch-n-fg); }
.ch-st-running, .ch-sg-running { background: var(--ch-blue-bg); color: var(--ch-blue-fg); }
.ch-st-waiting_input, .ch-sg-waiting { background: var(--ch-amber-bg); color: var(--ch-amber-fg); }
.ch-st-awaiting_approval, .ch-ap-pending { background: var(--ch-violet-bg); color: var(--ch-violet-fg); }
.ch-st-retrying { background: var(--ch-orange-bg); color: var(--ch-orange-fg); }
.ch-st-failed, .ch-sg-failed, .ch-ap-rejected, .ch-res-error, .ch-res-denied { background: var(--ch-red-bg); color: var(--ch-red-fg); }
.ch-st-completed, .ch-sg-done, .ch-ap-approved, .ch-res-ok { background: var(--ch-green-bg); color: var(--ch-green-fg); }
.ch-badge { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; border: 1px solid var(--ch-border); color: var(--ch-muted); white-space: nowrap; }
.ch-badge-synth { border-style: dashed; color: var(--ch-warn-fg); border-color: currentColor; }

/* ---------------------------------------------------------------- worker health */
.ch-health { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-radius: var(--ch-radius); font-size: 14px; background: var(--ch-surface); border: 1px solid var(--ch-border); }
.ch-health-ok { background: var(--ch-ok-bg); color: var(--ch-ok-fg); border-color: transparent; }
.ch-health-bad { background: var(--ch-err-bg); color: var(--ch-err-fg); border-color: var(--ch-err-border); }
.ch-dot { flex: none; width: 10px; height: 10px; margin-top: 6px; border-radius: 50%; background: currentColor; }

/* ---------------------------------------------------------------- tiles */
.ch-tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.ch-tile { display: grid; gap: 2px; padding: 12px 14px; border-radius: var(--ch-radius); text-decoration: none; color: var(--ch-text); background: var(--ch-surface); border: 1px solid var(--ch-border); border-left: 4px solid #94a3b8; }
.ch-tile:hover { background: var(--ch-surface-2); color: var(--ch-text); }
.ch-tile-n { font-size: 24px; font-weight: 800; }
.ch-tile-l { font-size: 13px; color: var(--ch-muted); }
.ch-tile-running { border-left-color: #2563eb; }
.ch-tile-waiting_input { border-left-color: #d97706; }
.ch-tile-awaiting_approval, .ch-tile-approvals { border-left-color: #7c3aed; }
.ch-tile-retrying { border-left-color: #ea580c; }
.ch-tile-failed { border-left-color: #dc2626; }
.ch-tile-completed { border-left-color: #16a34a; }

/* ---------------------------------------------------------------- robots */
.ch-robots { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-top: 16px; }
.ch-robot { background: var(--ch-surface); border: 1px solid var(--ch-border); border-top: 4px solid var(--ch-rb, #64748b); border-radius: var(--ch-radius); padding: 12px; min-width: 0; box-shadow: var(--ch-shadow); }
.ch-robot-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ch-robot-head > .ch-pill { margin-left: auto; }
.ch-robot-head .chr-avatar { flex: none; }
.ch-robot-id { flex: 1 1 120px; min-width: 0; }
.ch-robot-id h3 { margin: 0; font-size: 16px; }
.ch-robot-id p { margin: 0; }
.ch-robot-auth { margin: 8px 0 0; font-size: 12px; color: var(--ch-muted); }
.ch-robot .ch-joblist { margin-top: 10px; }
.ch-rb-atlas { --ch-rb: #6366f1; } .ch-rb-scout { --ch-rb: #0ea5e9; } .ch-rb-margin { --ch-rb: #10b981; }
.ch-rb-scribe { --ch-rb: #f59e0b; } .ch-rb-pixel { --ch-rb: #ec4899; } .ch-rb-stocky { --ch-rb: #14b8a6; }
.ch-rb-buyer { --ch-rb: #8b5cf6; } .ch-rb-finder { --ch-rb: #64748b; } .ch-rb-guard { --ch-rb: #ef4444; }
.ch-rb-ledger { --ch-rb: #a16207; } .ch-rb-relay { --ch-rb: #2563eb; }

.ch-joblist { display: grid; gap: 8px; }
.ch-jobrow {
  display: grid; gap: 3px; width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px;
  background: var(--ch-surface-2); border: 1px solid var(--ch-border); color: var(--ch-text); font: inherit; cursor: pointer; min-width: 0;
}
.ch-jobrow:hover { border-color: var(--ch-accent); }
.ch-jobrow > span { display: block; overflow-wrap: anywhere; }
.ch-jobrow-title { font-weight: 700; }
.ch-jobrow-stage { font-size: 14px; }
.ch-jobrow-err { font-size: 13px; color: var(--ch-err-fg); background: var(--ch-err-bg); border-radius: 6px; padding: 4px 8px; }

/* ---------------------------------------------------------------- tables */
.ch-tablewrap { overflow-x: auto; max-width: 100%; border: 1px solid var(--ch-border); border-radius: 8px; }
.ch-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ch-table th, .ch-table td { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--ch-border); }
.ch-table th { background: var(--ch-surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ch-muted); white-space: nowrap; }
.ch-table tbody tr:last-child td { border-bottom: 0; }
.ch-table td { overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- lists, cards, events */
.ch-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ch-card { border: 1px solid var(--ch-border); border-radius: 8px; padding: 12px; display: grid; gap: 4px; background: var(--ch-surface); min-width: 0; }
.ch-card-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ch-card .ch-btn { justify-self: start; margin-top: 6px; }
.ch-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 10px; background: var(--ch-surface-2); border: 1px solid var(--ch-border); }
.ch-seg-btn { border: 0; background: transparent; color: var(--ch-text); font: inherit; font-weight: 600; padding: 6px 12px; border-radius: 7px; cursor: pointer; }
.ch-seg-btn[aria-pressed="true"] { background: var(--ch-surface); box-shadow: var(--ch-shadow); color: var(--ch-accent); }
.ch-events { list-style: none; margin: 0; padding: 0; }
.ch-event { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--ch-border); min-width: 0; }
.ch-event:last-child { border-bottom: 0; }
.ch-event-av { flex: none; width: 28px; height: 28px; display: grid; place-items: center; }
.ch-event-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ch-muted); }
.ch-event-body { min-width: 0; }
.ch-event-msg { overflow-wrap: anywhere; }
.ch-kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 12px 0; font-size: 14px; }
.ch-kv dt { color: var(--ch-muted); }
.ch-kv dd { margin: 0; overflow-wrap: anywhere; }
.ch-details summary { cursor: pointer; font-weight: 600; margin-top: 6px; }
.ch-details[open] summary { margin-bottom: 8px; }
.ch-pre { margin: 8px 0; padding: 10px; border-radius: 8px; background: var(--ch-surface-2); border: 1px solid var(--ch-border); font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow: auto; max-height: 420px; white-space: pre; }
.ch-pre-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- drawer */
.ch-drawer { position: fixed; inset: 0; z-index: 50; }
.ch-drawer-scrim { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); }
.ch-drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(760px, 100%);
  display: flex; flex-direction: column; background: var(--ch-bg); box-shadow: -8px 0 30px rgba(0, 0, 0, .25);
}
.ch-drawer-panel:focus { outline: none; }
.ch-drawer-head { display: flex; align-items: center; gap: 8px; padding: 12px var(--ch-gutter); background: var(--ch-surface); border-bottom: 1px solid var(--ch-border); }
.ch-drawer-title { flex: 1; margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.ch-drawer-body { flex: 1; overflow-y: auto; padding: 12px var(--ch-gutter) 40px; overscroll-behavior: contain; }
.ch-dh-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ch-actpanel { margin-top: 12px; padding: 12px; border-radius: var(--ch-radius); background: var(--ch-surface); border: 1px solid var(--ch-border); }
.ch-actpanel .ch-h3 { margin-top: 0; }
.ch-actpanel-input { border-left: 4px solid #d97706; }
.ch-actpanel-approval { border-left: 4px solid #7c3aed; }
.ch-question { font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }
.ch-timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ch-stage { display: flex; gap: 10px; padding: 10px; border-radius: 8px; background: var(--ch-surface); border: 1px solid var(--ch-border); min-width: 0; }
.ch-stage .chr-avatar { flex: none; }
.ch-stage-body { min-width: 0; flex: 1; }
.ch-stage-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ch-stage-sum { margin: 6px 0 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ch-sgrow-pending, .ch-sgrow-skipped { opacity: .8; }
.ch-artifact { margin-bottom: 10px; padding: 10px 12px; border-radius: 8px; background: var(--ch-surface); border: 1px solid var(--ch-border); min-width: 0; }
.ch-artifact summary { cursor: pointer; overflow-wrap: anywhere; }
.ch-artimg { max-width: 100%; height: auto; border-radius: 6px; margin-top: 8px; }
.ch-md { font-size: 14px; overflow-wrap: anywhere; }
.ch-md p { margin: 8px 0; }
.ch-md ul { margin: 8px 0; padding-left: 20px; }
.ch-md-h { margin: 12px 0 4px; font-size: 15px; }

/* ---------------------------------------------------------------- toasts */
.ch-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.ch-toast { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 8px; background: var(--ch-surface); color: var(--ch-text); border: 1px solid var(--ch-border); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); font-size: 14px; }
.ch-toast span { flex: 1; overflow-wrap: anywhere; }
.ch-toast-ok { border-left: 4px solid #16a34a; }
.ch-toast-error { border-left: 4px solid #dc2626; background: var(--ch-err-bg); color: var(--ch-err-fg); }
.ch-toast-x { border: 0; background: transparent; color: inherit; font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px; }

/* ---------------------------------------------------------------- robot avatars */
.chr-avatar { display: block; overflow: visible; }
.chr-spin { transform-box: fill-box; transform-origin: center; animation: ch-rot 3s linear infinite; }
.chr-blink { animation: chr-blink 1.4s ease-in-out infinite; }
@keyframes ch-rot { to { transform: rotate(360deg); } }
@keyframes chr-blink { 50% { opacity: .35; } }

@media (prefers-reduced-motion: reduce) {
  .chr-spin, .chr-blink, .ch-busy::after { animation: none !important; }
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .ch-menubtn { display: inline-flex; }
  .ch-app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "live" "main"; }
  .ch-nav {
    position: fixed; top: var(--ch-top-h); left: 0; bottom: 0; z-index: 40; height: auto; align-self: stretch;
    width: min(290px, 85vw); transform: translateX(-105%); transition: transform .2s ease; visibility: hidden;
    box-shadow: 4px 0 24px rgba(0, 0, 0, .2);
  }
  .ch-nav-open .ch-nav { transform: none; visibility: visible; }
  .ch-nav-open .ch-scrim { display: block; position: fixed; inset: var(--ch-top-h) 0 0 0; z-index: 35; background: rgba(15, 23, 42, .4); }
  .ch-main { padding: 16px var(--ch-gutter) 48px; }
  .ch-whoami { display: none; }
}
@media (max-width: 760px) {
  .ch-table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ch-table-cards, .ch-table-cards tbody, .ch-table-cards tr, .ch-table-cards td { display: block; width: 100%; }
  .ch-tablewrap:has(.ch-table-cards) { border: 0; overflow: visible; }
  .ch-table-cards tr { border: 1px solid var(--ch-border); border-radius: 8px; margin-bottom: 10px; padding: 6px 0; background: var(--ch-surface); }
  .ch-table-cards td { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; border: 0; padding: 4px 12px; }
  .ch-table-cards td > div { min-width: 0; }
  .ch-table-cards td::before { content: attr(data-label); font-size: 12px; font-weight: 600; color: var(--ch-muted); }
  .ch-drawer-panel { width: 100%; box-shadow: none; }
  .ch-grid2 { grid-template-columns: minmax(0, 1fr); }
  .ch-robots { grid-template-columns: minmax(0, 1fr); }
  .ch-viewhead h1 { font-size: 21px; }
}
@media (max-width: 480px) {
  .ch-header { gap: 6px; }
  .ch-header .ch-btn-sm { display: none; }
  .ch-nav-actions { display: flex; }
  .ch-nav-actions + .ch-nav-foot { margin-top: 0; }
  .ch-kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .ch-kv dd { margin-bottom: 6px; }
  .ch-field-inline { display: grid; width: 100%; }
  .ch-field-inline select { max-width: none; width: 100%; }
  .ch-filters { width: 100%; }
  .ch-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .ch-nav { transition: none; }
}
