/* component anatomy mirrors frontend monorepo packages/spark/src/components/<name>/<name>.recipe.ts; tokens live in spark.css */
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; min-height: 100vh; background: var(--colors-bg-subtle); color: var(--colors-fg); font-family: var(--fonts-body); font-size: 14px; line-height: 20px; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: underline; text-underline-offset: 0.3em; }
a:hover { color: var(--colors-primary); }
a:focus-visible, button:focus-visible { outline: 4px solid var(--colors-focus); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
code, .mono { font-family: var(--fonts-code); font-weight: 500; letter-spacing: 0.4px; }
code { background: var(--colors-bg-strong); padding: 1px 5px; border-radius: var(--radii-xs); overflow-wrap: anywhere; }
svg { display: block; }
.icon { display: inline-flex; width: 20px; height: 20px; flex: none; }
.icon svg { width: 100%; height: 100%; }
.icon.s { width: 16px; height: 16px; }

.app { display: flex; min-height: 100vh; }
.side { width: 264px; flex: none; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; padding: 24px 12px 16px; background: var(--colors-bg); border-right: 1px solid var(--colors-border-subtle); overflow-y: auto; }
.brand { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 4px; }
.brand .logo { height: 20px; width: auto; color: var(--colors-fg); }
.appname { padding: 8px 8px 16px; font-family: var(--fonts-heading); font-size: 20px; line-height: 28px; }
.side .lbl { padding: 16px 8px 8px; }
.navitem { display: flex; align-items: center; gap: 8px; width: 100%; height: 40px; padding: 8px; border: 0; border-radius: var(--radii-xs); background: transparent; color: var(--colors-fg-secondary); text-decoration: none; text-align: left; cursor: pointer; transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease; }
.navitem:hover, .navitem.on { background: var(--colors-bg-subtle); color: var(--colors-fg); box-shadow: var(--shadows-sink); }
.navitem .grow { flex: 1; }
.navitem .live { display: none; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; color: var(--colors-fg-secondary); font-variant-numeric: tabular-nums; }
.navitem.running .live { display: inline-flex; }
.side .foot { margin-top: auto; padding: 12px 0 0; border-top: 1px solid var(--colors-border-subtle); display: flex; flex-direction: column; gap: 8px; }
.side .foot .seg { margin: 4px 8px 0; align-self: flex-start; }
.main { flex: 1; min-width: 0; padding: 32px 40px 64px; }
.page { max-width: 1344px; margin: 0 auto; }

.lbl { font-family: var(--fonts-mono); font-size: 12px; line-height: 16px; letter-spacing: -0.5px; text-transform: uppercase; color: var(--colors-fg-secondary); }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.h1 { font-family: var(--fonts-heading); font-weight: 400; font-size: 28px; line-height: 32px; letter-spacing: -1px; overflow-wrap: anywhere; }
.h2 { font-family: var(--fonts-heading); font-weight: 400; font-size: 24px; line-height: 32px; letter-spacing: -0.5px; }
.h3 { font-family: var(--fonts-heading); font-weight: 400; font-size: 20px; line-height: 28px; }
.h4 { font-weight: 600; font-size: 14px; line-height: 20px; }
.lede { color: var(--colors-fg-secondary); margin-top: 4px; max-width: 760px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; color: var(--colors-fg-secondary); font-size: 12px; line-height: 16px; margin-bottom: 12px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--colors-fg); text-decoration: underline; }
.muted { color: var(--colors-fg-secondary); }
.small { font-size: 12px; line-height: 16px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; }
.row.s { gap: 8px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 24px; }
.stack.s { gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.grid6 { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
.hidden { display: none !important; }

.card { background: var(--colors-bg); border-radius: var(--radii-m); box-shadow: var(--shadows-elevation-sm); overflow: clip; }
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px 12px; border-bottom: 1px solid var(--colors-border-subtle); }
.cardhead .h3 { min-width: 0; }
.cardbody { padding: 24px; }
.cardbody.s { padding: 16px 24px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--colors-border-subtle); }
.cardfoot { display: flex; align-items: center; gap: 12px; padding: 16px 24px; border-top: 1px solid var(--colors-border); }
.stat { background: var(--colors-bg); border-radius: var(--radii-s); box-shadow: var(--shadows-elevation-sm); padding: 16px; min-width: 0; }
.stat .v { font-size: 36px; line-height: 48px; font-weight: 300; margin-top: 8px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat .v.m { font-size: 18px; line-height: 24px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .s { color: var(--colors-fg-secondary); margin-top: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 12px; border: 0; border-radius: var(--radii-pill); font-weight: 600; font-size: 14px; line-height: 20px; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out, color 0.15s ease-in-out; background: var(--colors-primary); color: var(--colors-primary-contrast); box-shadow: var(--shadows-button-lift); }
.btn:hover { background: var(--colors-primary-hover); color: var(--colors-primary-contrast); box-shadow: var(--shadows-button-hover); }
.btn:active { box-shadow: var(--shadows-button-pressed); }
.btn.sm { min-height: 32px; padding: 4px 10px; }
.btn.secondary { background: var(--colors-secondary); color: var(--colors-fg); }
.btn.secondary:hover { background: var(--colors-secondary-hover); color: var(--colors-fg); }
.btn.secondary:active { box-shadow: var(--shadows-button-pressed-subtle); }
.btn.subtle { background: var(--colors-ghost); color: var(--colors-fg); box-shadow: none; }
.btn.subtle:hover { background: var(--colors-ghost-hover); color: var(--colors-fg); box-shadow: none; }
.btn.ghost { background: transparent; color: var(--colors-fg); box-shadow: none; }
.btn.ghost:hover { background: var(--colors-ghost-hover); color: var(--colors-fg); box-shadow: none; }
.btn.danger { background: var(--colors-destructive); color: var(--colors-destructive-contrast); }
.btn.danger:hover { background: var(--colors-destructive-hover); color: var(--colors-destructive-contrast); }
.btn.danger:focus-visible { outline-color: var(--colors-focus-destructive); }
.btn:disabled { cursor: not-allowed; box-shadow: none; background: var(--colors-primary-inactive); color: var(--colors-primary-contrast); }
.btn.secondary:disabled, .btn.subtle:disabled, .btn.ghost:disabled { background: var(--colors-secondary-inactive); color: var(--colors-fg-inactive); }
.btn.danger:disabled { background: var(--colors-destructive-inactive); }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex: none; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--colors-fg); cursor: pointer; transition: background-color 0.15s ease, box-shadow 0.15s ease; }
.iconbtn:hover { background: var(--colors-ghost); }
.iconbtn:active { background: var(--colors-ghost-hover); }
.iconbtn.nav { width: 40px; height: 40px; background: var(--colors-bg); box-shadow: var(--shadows-button-lift); }
.iconbtn.nav:hover { background: var(--colors-bg-subtle); }
.iconbtn:disabled { cursor: not-allowed; color: var(--colors-fg-inactive); background: transparent; box-shadow: none; }
.iconbtn.nav:disabled { background: var(--colors-bg-inactive); }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .field > .flabel { font-weight: 600; }
.help { color: var(--colors-fg-secondary); }
.input { width: 100%; min-height: 40px; padding: 8px 10px; border: 0; border-radius: var(--radii-xs); background: var(--colors-bg); color: var(--colors-fg); font: inherit; box-shadow: inset 0 0 0 1px var(--colors-border-strong); transition: box-shadow 0.15s ease; }
.input:hover { box-shadow: inset 0 0 0 1px var(--colors-border-hover); }
.input:focus { outline: none; box-shadow: inset 0 0 0 1px var(--colors-primary), var(--shadows-field-focus); }
.input::placeholder { color: var(--colors-fg-tertiary); }
.input:disabled { background: var(--colors-bg-inactive); color: var(--colors-fg-inactive); }
textarea.input { resize: vertical; line-height: 20px; }
textarea.input.code { font-family: var(--fonts-code); font-size: 13px; }
select.input { cursor: pointer; padding-right: 28px; }
.input.sm { min-height: 32px; padding: 4px 8px; }
.search { position: relative; }
.search .icon { position: absolute; left: 10px; top: 10px; color: var(--colors-fg-secondary); pointer-events: none; }
.search .input { padding-left: 38px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--colors-primary); }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border-radius: var(--radii-pill); font-family: var(--fonts-mono); font-size: 12px; line-height: 16px; letter-spacing: -0.5px; text-transform: uppercase; white-space: nowrap; vertical-align: middle; background: var(--colors-ghost); color: var(--colors-fg-secondary); }
.chip.success { background: var(--colors-success-strong); color: var(--colors-success-contrast); }
.chip.warning { background: var(--colors-warning); color: var(--colors-warning-contrast); }
.chip.warn-subtle { background: var(--colors-warning-subtle); color: var(--colors-warning-contrast); }
.chip.critical { background: var(--colors-destructive); color: var(--colors-destructive-contrast); }
.chip.info { background: var(--colors-info); color: var(--colors-info-contrast); }
.chip.queued { background: var(--colors-status-queued); color: #ffffff; }
.chip.outline { background: transparent; color: var(--colors-fg); box-shadow: inset 0 0 0 1px var(--colors-border-strong); }
.chip.code { font-family: var(--fonts-code); font-weight: 500; letter-spacing: 0.4px; text-transform: none; }
.chip.admin { background: transparent; color: var(--colors-admin); box-shadow: inset 0 0 0 1px var(--colors-admin); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--colors-status-inactive); }
.dot.l { width: 12px; height: 12px; }
.dot.active { background: var(--colors-status-active); }
.dot.error { background: var(--colors-status-error); }
.dot.warning { background: var(--colors-warning); }
.dot.queued { background: var(--colors-status-queued); }
.dot.draft { background: transparent; box-shadow: inset 0 0 0 1.5px var(--colors-status-inactive); }
.dot.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.status { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

.tabs { display: flex; gap: 16px; box-shadow: inset 0 -1px 0 var(--colors-border); overflow-x: auto; scrollbar-width: none; }
.cardhead + .tabs, .card > .tabs { padding: 0 24px; }
.tab { position: relative; flex: none; display: inline-flex; align-items: center; gap: 4px; padding: 12px 0; border: 0; background: transparent; color: var(--colors-fg-inactive); font-weight: 600; cursor: pointer; white-space: nowrap; }
.tab::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: transparent; }
.tab:hover { color: var(--colors-fg-tertiary); }
.tab:hover::after { background: var(--colors-border-strong); }
.tab.on, .tab.on:hover { color: var(--colors-fg); }
.tab.on::after { height: 2px; background: var(--colors-primary); }
.tab .count { font-weight: 500; color: var(--colors-fg-secondary); }
.seg { display: inline-flex; gap: 2px; padding: 4px; border-radius: var(--radii-xs); background: var(--colors-bg-medium); box-shadow: var(--shadows-sink); }
.seg button { min-height: 28px; padding: 4px 8px; border: 0; border-radius: var(--radii-2xs, 2px); background: transparent; color: var(--colors-fg-secondary); cursor: pointer; white-space: nowrap; }
.seg button:hover { background: var(--colors-bg-strong); color: var(--colors-fg); }
.seg button.on { background: var(--colors-bg); color: var(--colors-fg); box-shadow: var(--shadows-elevation-sm); }
.seg.small { padding: 2px; }
.seg.small button { min-height: 24px; padding: 2px 8px; font-size: 12px; line-height: 16px; }

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; vertical-align: middle; }
table.t th { padding: 16px 12px; font-weight: 500; color: var(--colors-fg-secondary); white-space: nowrap; border-bottom: 1px solid var(--colors-border-subtle); }
table.t td { padding: 12px; border-bottom: 1px solid var(--colors-border-subtle); }
table.t.dense td { padding: 8px 12px; }
table.t.dense th { padding: 12px; }
table.t th:first-child, table.t td:first-child { padding-left: 24px; }
table.t th:last-child, table.t td:last-child { padding-right: 24px; }
table.t tbody tr:last-child td { border-bottom: 0; }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr.click:hover, table.t tbody tr.sel { background: var(--colors-bg-hover); }
table.t tbody tr.click:focus-visible { outline: 2px solid var(--colors-focus); outline-offset: -2px; }
table.t tbody tr.sub td { background: var(--colors-bg-subtle); }
table.t td.num, table.t th.num { text-align: right; }
table.t td.w { width: 1%; white-space: nowrap; }
.kv { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.kv dt { color: var(--colors-fg-secondary); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.empty { padding: 40px 24px; text-align: center; color: var(--colors-fg-secondary); }

.pager { display: flex; align-items: center; justify-content: center; gap: 40px; padding: 16px 24px; border-top: 1px solid var(--colors-border-subtle); }
.pager .grp { display: flex; align-items: center; gap: 8px; }
.pager .count { color: var(--colors-fg-secondary); font-variant-numeric: tabular-nums; }

.banner { display: flex; gap: 8px; align-items: flex-start; padding: 16px 12px 16px 16px; border-radius: var(--radii-s); background: var(--colors-info); color: var(--colors-info-contrast); overflow-wrap: anywhere; }
.banner.warn { background: var(--colors-warning-subtle); color: var(--colors-fg); }
.banner.danger { background: var(--colors-destructive-inactive); color: var(--colors-fg); }
.banner.success { background: var(--colors-success-subtle); color: var(--colors-fg); }
.banner.tip { background: var(--colors-accent); color: var(--colors-accent-contrast); }
.banner .grow { white-space: pre-wrap; }

pre.code { margin: 0; padding: 12px 16px; border-radius: var(--radii-xs); background: var(--colors-bg-medium); color: var(--colors-fg); font: 500 13px/20px var(--fonts-code); letter-spacing: 0.2px; white-space: pre-wrap; word-break: break-word; overflow: auto; max-height: 560px; }
pre.code.tall { max-height: 72vh; }
pre.code.log { white-space: pre; }
.codehead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 16px 0 8px; }

.scrim { position: fixed; inset: 0; z-index: 40; background: var(--colors-ghost-hover); }
.panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: 560px; max-width: 100vw; display: flex; flex-direction: column; background: var(--colors-bg); box-shadow: var(--shadows-elevation-lg); }
.panel.wide { width: 880px; }
.panel .phead { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 16px; border-bottom: 1px solid var(--colors-border); }
.panel .phead .h2 { overflow-wrap: anywhere; }
.panel .pbody { flex: 1; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.panel .pfoot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px; border-top: 1px solid var(--colors-border); }

.durbar { position: relative; width: 120px; height: 6px; border-radius: 3px; background: var(--colors-bg-strong); overflow: hidden; }
.durbar > span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--colors-data-1); }
.bars .plot { display: flex; align-items: flex-end; gap: 2px; margin-top: 4px; border-bottom: 1px solid var(--colors-border); }
.bars .bar { flex: 1 1 0; min-width: 1px; border-radius: 4px 4px 0 0; background: var(--colors-data-1); }
.bars .bar:hover { opacity: 0.8; }
.bars .xaxis { display: flex; gap: 2px; margin-top: 4px; }
.bars .xaxis span { flex: 1 1 0; min-width: 0; text-align: center; white-space: nowrap; font-size: 11px; line-height: 16px; color: var(--colors-fg-secondary); }

.d-add { background: var(--colors-success-subtle); }
.d-del { background: var(--colors-destructive-subtle); }
.d-chg { background: var(--colors-warning-subtle); }
ins.w { background: var(--colors-success-subtle); text-decoration: none; border-radius: 2px; }
del.w { background: var(--colors-destructive-subtle); border-radius: 2px; }
.arrow { color: var(--colors-fg-tertiary); padding: 0 4px; }
/* the warn/success/danger tints stay light in dark mode, so their ink must not follow --colors-fg */
.banner.warn, .banner.danger, .banner.success, .d-add, .d-chg, ins.w { color: var(--colors-warning-contrast); }
.d-add .muted, .d-chg .muted, .d-add .chip, .d-chg .chip, .d-add .help, .d-chg .help { color: inherit; }

.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 24px; align-items: start; }
.sticky { position: sticky; top: 24px; }
.filerow .icon { color: var(--colors-fg-secondary); }
iframe.preview { width: 100%; height: 70vh; border: 1px solid var(--colors-border-subtle); border-radius: var(--radii-xs); background: #ffffff; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; padding: 8px 12px; border-radius: var(--radii-xs); background: var(--colors-ghost-overlay); color: var(--colors-fg-inverse); backdrop-filter: blur(2px); }
.skel { height: 16px; border-radius: var(--radii-xs); background: linear-gradient(90deg, var(--colors-bg-strong), var(--colors-bg-medium), var(--colors-bg-strong)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 1100px) {
  .split, .grid2 { grid-template-columns: 1fr; }
  .grid4, .grid6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; }
  .main { padding: 20px 16px 48px; }
  .grid3 { grid-template-columns: 1fr; }
}
