/* Atlas blocks — the card around every widget (v7.1 "module block", blocks/blocks.css) and the look of what
   kit.js draws inside it: stat tiles, the data table, charts, meters, the confirm block, markdown, the
   fallback view. Shared pieces module widgets may use (.w-section, .big-num, .item-row) are at the end.
   Colours only from tokens.css; the module's hue arrives as --block-c (set by kit.card from --s<color>). */

/* --- the card: a 3px edge in the module colour, a tinted header strip, the widget below ----------------------- */

.card.block {
  --block-c: var(--border-strong);
  padding: 0; border-radius: var(--r-2); background: var(--surface);
  border: 1px solid var(--border); border-left: 3px solid var(--block-c); box-shadow: none;
  overflow: hidden; position: relative; min-width: 0;
}
.card.block.appear { animation: fade-up .32s var(--ease-out) both; }
.card.block.loading > .card-body { opacity: .45; transition: opacity .2s; }
.card.block > .block-head {
  display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 41px;
  padding: 7px 8px 7px 12px; border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--block-c) 7%, var(--surface));
  font-size: 12.5px; line-height: 1.4;
}
.block-module { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; font-weight: 650; color: var(--text); letter-spacing: .01em; }
.block-module svg { width: 15px; height: 15px; color: var(--block-c); }
.block-titles { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex: 1; overflow: hidden; }
.block-module + .block-titles::before { content: "·"; color: var(--text-3); flex: none; }
.block-head .card-title { margin: 0; font-size: 12.5px; font-weight: 560; color: var(--text-2); letter-spacing: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.block-head .card-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1 1 0; }
.block-head .card-actions { margin: 0 0 0 auto; display: inline-flex; gap: 2px; flex-shrink: 0; opacity: 1; }
.block-btn { width: 26px; height: 26px; border-radius: var(--r-1); color: var(--text-3); }
.block-btn svg { width: 15px; height: 15px; }
.block-btn:hover { background: var(--surface-3); color: var(--text); }
.block-btn:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.block-btn.on { color: var(--accent-text); }
.card.block > .card-body { padding: 10px 12px 12px; min-width: 0; font-size: 14px; line-height: 1.5; color: var(--text); }
.card.block > .card-body > :first-child { margin-top: 0; }
.card.block > .card-body > :last-child { margin-bottom: 0; }
/* a card inside a card (confirm result, veri's flow preview): no second edge colour fight, no shadow */
.card.block.compact { box-shadow: none; }
.confirm-result .card.block { background: var(--surface); }
@media (max-width: 560px) { .block-head .card-sub { display: none; } }

/* --- stat tiles (core.kpis) ------------------------------------------------------------------------------------ */

div.kpis { padding: 0; background: none; border: 0; border-radius: 0; overflow: visible; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpis .stat { padding: 12px 14px; }
.kpis .stat-value b { font-size: 22px; }

/* --- data table extras (core.table; the table itself is .dtable in components.css) --------------------------- */

.table-more { padding: 8px 2px 0; font-size: 12.5px; }
.dtable .k-bar { min-width: 140px; }
.dtable .k-date, .dtable .k-datetime { white-space: nowrap; color: var(--text-2); }
.dtable .k-code code { color: var(--text-2); font-size: 12.5px; }
.dtable .k-status { white-space: nowrap; }
.cell-bar { display: grid; grid-template-columns: minmax(60px, 1fr) 42px; gap: 8px; align-items: center; }
.cell-bar span { text-align: right; font-variant-numeric: tabular-nums; }

/* --- meters: a 6px pill (training look) ---------------------------------------------------------------------- */

.meter { height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; min-width: 40px; }
.meter-fill { height: 100%; border-radius: inherit; transition: width .4s var(--ease); }
.m-good { background: var(--good); }
.m-accent, .m-info { background: var(--accent); }
.m-warning { background: var(--warn); }
.m-serious { background: var(--serious); }
.m-critical { background: var(--bad); }
.m-neutral, .m-done { background: var(--text-3); }
/* nothing to count: a dashed empty track, never a full bar */
.meter.is-none { background: transparent; outline: 1px dashed var(--border-strong); outline-offset: -1px; }

/* --- charts -------------------------------------------------------------------------------------------------- */

.chart { position: relative; }
.chart-box { width: 100%; min-height: 40px; }
.chart-svg { display: block; overflow: visible; }
.chart-svg .grid { stroke: var(--border); stroke-width: 1; }
.chart-svg .axis { stroke: var(--border-strong); stroke-width: 1; }
.chart-svg .tick { fill: var(--text-3); font-size: 11px; font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.chart-svg .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .area { opacity: .12; }
.chart-svg .dot { stroke: var(--surface); stroke-width: 2; }
.chart-svg .crosshair { stroke: var(--border-strong); stroke-width: 1; }
.chart-svg .target { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 4 3; opacity: .8; }
.chart-svg .target-label { fill: var(--text-2); }
.chart-svg .bar { transition: opacity .12s; }
.chart-svg .bar:hover { opacity: .8; }
.spark { display: block; }
.spark .line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark .dot { stroke: var(--surface); stroke-width: 2; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 8px; font-size: 12.5px; color: var(--text-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.swatch-line { height: 3px; border-radius: 2px; width: 14px; }
.hbars { display: flex; flex-direction: column; gap: 7px; }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.hbar-track { height: 18px; display: flex; align-items: center; }
.hbar-fill { height: 14px; border-radius: 0 4px 4px 0; min-width: 2px; transition: width .4s var(--ease-out); }
.hbar-value { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 12.5px; white-space: nowrap; }
@media (max-width: 760px) { .hbar-row { grid-template-columns: minmax(70px, 38%) 1fr auto; } }

/* the chart / matrix hover card (kit.tip): follows the pointer, so it fades rather than slides */
.tooltip {
  position: fixed; left: 0; top: 0; z-index: 350; pointer-events: none; max-width: 280px;
  padding: 8px 11px; border-radius: var(--r-2); border: 1px solid var(--border-2);
  background: var(--glass-3); color: var(--text);
  backdrop-filter: blur(var(--glass-blur-3)) saturate(var(--glass-saturation)); -webkit-backdrop-filter: blur(var(--glass-blur-3)) saturate(var(--glass-saturation));
  box-shadow: var(--sh-2); font-size: 12.5px; line-height: 1.45; opacity: 0; transition: opacity .1s linear;
}
.tooltip.on { opacity: 1; }
[data-lite] .tooltip { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--surface); }
.tip-title { font-weight: 650; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 7px; }
.tip-row b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; font-weight: 620; }
.tip-name { color: var(--text-2); }

/* --- confirm block: before anything changes; shows the arguments, not just the tool -------------------------- */

div.confirm { border-radius: var(--r-3); padding: 15px 17px; background: var(--warn-soft);
  border: 1px solid color-mix(in oklab, var(--warn) 55%, transparent); border-left: 3px solid var(--warn); }
.confirm-title { font-weight: 620; font-size: 14.5px; color: var(--text); margin-bottom: 10px; }
.confirm-lines { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 12px; font-size: 13.5px; }
.confirm-lines dt { color: var(--text-2); }
.confirm-lines dd { margin: 0; font-weight: 540; color: var(--text); overflow-wrap: anywhere; }
.confirm > p { margin: 0 0 12px; font-size: 13.5px; color: var(--text-2); }
.confirm-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.confirm-foot .muted { color: var(--text-2); }
.confirm-result { margin-top: 12px; }
/* decided: the warning tint steps back */
div.confirm.is-decided { background: var(--surface-2); border-color: var(--border); border-left-color: var(--border-strong); }
div.confirm.is-decided.is-good { border-left-color: var(--good); }
div.confirm.is-decided.is-bad { border-left-color: var(--bad); }

/* --- error, fallback, fields ----------------------------------------------------------------------------------- */

.error-box { display: flex; gap: 8px; align-items: flex-start; color: var(--bad-ink); background: var(--bad-soft);
  border-radius: var(--r-2); padding: 10px 12px; font-size: 14px; }
.error-box svg { margin-top: 2px; }
.fallback-note { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); margin-bottom: 8px; }
dl.fields { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 13.5px; }
dl.fields dt { color: var(--text-3); }
dl.fields dd { margin: 0; overflow-wrap: anywhere; }

/* --- markdown (kit.markdown: core.text and the answer text) ---------------------------------------------------- */

.md { line-height: 1.62; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md :is(h3, h4) { margin: 16px 0 8px; color: var(--text); line-height: 1.35; font-weight: 640; letter-spacing: -.01em; }
.md h3 { font-size: 17px; }
.md h4 { font-size: 15.5px; }
.md .md-h { font-weight: 640; color: var(--text); }
.md :is(ul, ol) { margin: 4px 0 10px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md li::marker { color: var(--text-3); }
.md strong { color: var(--text); font-weight: 640; }
.md :not(pre) > code { font-size: .86em; padding: 1.5px 5px; border-radius: 6px; background: var(--code-bg);
  border: 1px solid var(--border); color: var(--text); }
.md blockquote { margin: 0 0 10px; padding: 2px 0 2px 14px; border-left: 3px solid var(--border-strong); color: var(--text-3); }
.md .md-table { margin: 0 0 12px; overflow-x: auto; scrollbar-width: thin; border: 1px solid var(--border); border-radius: var(--r-2); }
.md table { border-collapse: collapse; min-width: 100%; font-size: 14px; line-height: 1.5; }
.md :is(th, td) { padding: 7px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; overflow-wrap: normal; }
.md th { background: var(--surface-2); color: var(--text); font-weight: 600; white-space: nowrap; }
.md tr:last-child td { border-bottom: 0; }
.md td.num, .md th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* streaming caret: still writing */
.md-cursor { display: inline-block; width: 7px; height: 1.05em; margin-left: 2px; vertical-align: -.15em; border-radius: 1.5px;
  background: var(--accent); animation: md-cursor 1s steps(1) infinite; }

/* --- shared pieces for module widgets -------------------------------------------------------------------------- */

.w-section { font-size: 11px; font-weight: 640; color: var(--text-3); text-transform: uppercase; letter-spacing: .07em; margin: 16px 0 8px; }
.big-num { font-size: 26px; font-weight: 660; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
/* a list row (training rows, documents): the one being pointed at gets an accent edge and ring */
.item-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item-row { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-2); background: var(--surface); }
.item-row.is-target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.item-row.is-action { cursor: pointer; transition: border-color .14s linear, background .14s linear; }
.item-row.is-action:hover { border-color: var(--border-strong); background: var(--surface-2); }
