/* UI kit (SAP Fiori Horizon look). Rendered by js/core/ui.js. Colours from tokens.css only. */

/* ───── Layout helpers */
.stack { --gap: var(--sp-4); display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.stack-xs { --gap: var(--sp-1); } .stack-sm { --gap: var(--sp-2); } .stack-lg { --gap: var(--sp-6); } .stack-xl { --gap: var(--sp-8); }
.inline { --gap: var(--sp-2); display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap); min-width: 0; }
.inline-lg { --gap: var(--sp-4); } .inline-end { justify-content: flex-end; } .inline-between { justify-content: space-between; } .inline-nowrap { flex-wrap: nowrap; } .inline-top { align-items: flex-start; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid { --gap: var(--sp-4); display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); min-width: 0; }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(min(var(--min, 16rem), 100%), 1fr)); }
@media (min-width: 600px) { .grid-2, .grid-3, .grid-4, .grid-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
  .grid-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
  .grid-3-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
}
@media (min-width: 1440px) { .grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.span-all { grid-column: 1 / -1; }
.section { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; scroll-margin-top: 6rem; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-1) var(--sp-3); }
.section-head .grow { min-width: 1rem; }
.section-title { font-size: var(--fs-md); font-weight: var(--fw-bold); }
.section-sub { color: var(--c-text-label); }

/* ───── Card */
.card { background: var(--c-surface); border-radius: var(--r-card); box-shadow: var(--sh-card); border: 1px solid var(--c-border); min-width: 0; display: flex; flex-direction: column; }
.card-head { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-4) var(--sp-4) 0; min-width: 0; }
.card-head-icon { flex: none; width: 2.25rem; height: 2.25rem; border-radius: var(--r-button); display: grid; place-items: center; background: var(--tone-bg, var(--c-selected-bg)); color: var(--tone-el, var(--c-brand)); }
.card-head-icon svg { width: 1.15rem; height: 1.15rem; }
.card-titles { flex: 1 1 auto; min-width: 0; }
.card-title { font-size: var(--fs-md); font-weight: var(--fw-bold); line-height: var(--lh-snug); }
.card-sub { color: var(--c-text-label); font-size: var(--fs-xs); margin-top: 0.125rem; }
.card-actions { display: flex; gap: var(--sp-1); flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.card-body { padding: var(--sp-4); min-width: 0; flex: 1 1 auto; }
.card-body.flush { padding: 0; }
.card-body.flush-x { padding-inline: 0; }
.card-foot { padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--c-border); display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.card-subtle { background: var(--c-bg-subtle); box-shadow: none; border-color: transparent; }
.card-link { color: inherit; transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease); }
.card-link:hover { text-decoration: none; box-shadow: var(--sh-1); }
.card.tone-top { border-top: 3px solid var(--tone-el, var(--c-brand)); }

/* ───── Launchpad tile (Fiori generic tile) */
.tiles { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(min(11.5rem, 100%), 1fr)); }
.tile { position: relative; display: flex; flex-direction: column; min-height: 11rem; padding: var(--sp-4); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-tile); box-shadow: var(--sh-card); color: var(--c-text); transition: box-shadow var(--dur) var(--ease); min-width: 0; }
.tile:hover { text-decoration: none; box-shadow: var(--sh-1); }
.tile-title { font-weight: var(--fw-bold); line-height: var(--lh-snug); }
.tile-sub { color: var(--c-text-label); font-size: var(--fs-xs); margin-top: 0.15rem; line-height: var(--lh-snug); }
.tile-mid { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-2); padding-top: var(--sp-3); }
.tile-mid svg.tile-ico { width: 1.6rem; height: 1.6rem; color: var(--c-icon-muted); }
.tile-num { font-size: 2.25rem; font-weight: var(--fw-light); line-height: 1; color: var(--tone-text, var(--c-text)); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile-num small { font-size: var(--fs-xs); font-weight: var(--fw-regular); color: var(--c-text-label); margin-left: 0.15rem; }
.tile-foot { margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--tone-text, var(--c-text-label)); font-weight: var(--fw-semibold); }
.tile-foot.muted { color: var(--c-text-label); font-weight: var(--fw-regular); }
.tile-wide { grid-column: span 2; }
@media (max-width: 599.98px) { .tile-wide { grid-column: span 1; } .tile { min-height: 9.5rem; } }

/* ───── KPI strip */
.kpis { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(min(12rem, 100%), 1fr)); }
.kpi { position: relative; display: flex; flex-direction: column; gap: 0.2rem; padding: var(--sp-3) var(--sp-4); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-element); box-shadow: var(--sh-card); min-width: 0; color: var(--c-text); }
a.kpi:hover { text-decoration: none; box-shadow: var(--sh-1); }
.kpi::before { content: ''; position: absolute; left: 0; top: 0.75rem; bottom: 0.75rem; width: 3px; border-radius: 0 3px 3px 0; background: var(--tone-el, var(--c-brand)); }
.kpi-label { font-size: var(--fs-xs); color: var(--c-text-label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-size: var(--fs-xl); font-weight: var(--fw-semibold); line-height: 1.15; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value small { font-size: var(--fs-xs); font-weight: var(--fw-regular); color: var(--c-text-label); }
.kpi-foot { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); color: var(--c-text-label); min-height: 1.1rem; }
.kpi-foot .spark { margin-left: auto; }
.delta { display: inline-flex; align-items: center; gap: 0.15rem; font-weight: var(--fw-semibold); white-space: nowrap; }
.delta svg { width: 0.8rem; height: 0.8rem; }
.delta.up { color: var(--c-positive); } .delta.down { color: var(--c-negative); } .delta.flat { color: var(--c-text-label); }
.delta.up.bad { color: var(--c-negative); } .delta.down.good { color: var(--c-positive); }

/* ───── Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; min-height: var(--control-h); padding: 0 0.875rem; border: 1px solid var(--c-border-button); border-radius: var(--r-button); background: var(--c-btn-bg); color: var(--c-btn-text); font-weight: var(--fw-semibold); white-space: nowrap; text-decoration: none; line-height: 1; }
.btn:hover { background: var(--c-btn-hover); text-decoration: none; }
.btn:active { background: var(--c-active); }
.btn svg { width: 1rem; height: 1rem; }
.btn-emph { background: var(--c-btn-emph-bg); border-color: var(--c-btn-emph-bg); color: #fff; }
.btn-emph:hover { background: var(--c-btn-emph-hover); border-color: var(--c-btn-emph-hover); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--c-hover); }
.btn-accept { background: var(--c-btn-accept-bg); border-color: var(--c-positive-border); color: var(--c-btn-accept-text); }
.btn-accept:hover { background: #dff0b4; }
.btn-reject { background: var(--c-btn-reject-bg); border-color: var(--c-negative-border); color: var(--c-btn-reject-text); }
.btn-reject:hover { background: #ffc2de; }
.btn-attn { background: var(--c-btn-attention-bg); border-color: var(--c-critical-border); color: var(--c-critical); }
.btn-sm { min-height: var(--control-h-sm); padding: 0 0.55rem; font-size: var(--fs-xs); border-radius: 0.375rem; }
.btn-icon { width: var(--control-h); padding: 0; }
.btn-icon.btn-sm { width: var(--control-h-sm); }
.btn[disabled], .btn.is-disabled { opacity: 0.45; pointer-events: none; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--r-button) 0 0 var(--r-button); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--r-button) var(--r-button) 0; }
.btn-group .btn.is-active { background: var(--c-selected-bg); color: var(--c-selected); border-color: var(--c-brand); position: relative; z-index: 1; }
.link-btn { border: 0; background: none; padding: 0; color: var(--c-link); font-weight: var(--fw-semibold); }
.link-btn:hover { text-decoration: underline; }

/* ───── Fields */
.field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.label { font-size: var(--fs-xs); color: var(--c-text-label); font-weight: var(--fw-regular); }
.label.req::after { content: ' *'; color: var(--c-required); }
.input, .select, .textarea { width: 100%; min-height: var(--control-h); padding: 0 0.625rem; border: 1px solid var(--c-border-field); border-bottom-width: 1px; border-radius: var(--r-field); background: var(--c-bg); color: var(--c-text); box-shadow: inset 0 -1px 0 var(--c-border-field); }
.textarea { padding: 0.5rem 0.625rem; min-height: 4.5rem; resize: vertical; line-height: var(--lh-base); }
.input:hover, .select:hover, .textarea:hover { background: #f5f9ff; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--c-focus); outline-offset: -1px; }
.input[readonly], .input.is-readonly { background: var(--c-readonly-bg); border-color: transparent; box-shadow: none; }
.input.num, .input[type='number'] { text-align: right; font-variant-numeric: tabular-nums; }
.input-sm, .select-sm { min-height: var(--control-h-sm); font-size: var(--fs-xs); padding: 0 0.45rem; }
.input.is-error, .select.is-error { border-color: var(--c-negative-border); box-shadow: inset 0 -1px 0 var(--c-negative-border); background: var(--c-negative-bg); }
.input.is-warn { border-color: var(--c-critical-border); box-shadow: inset 0 -1px 0 var(--c-critical-border); background: var(--c-critical-bg); }
.field-msg { font-size: var(--fs-xs); color: var(--c-text-label); }
.field-msg.neg { color: var(--c-negative); } .field-msg.crit { color: var(--c-critical); }
.select { appearance: none; padding-right: 2rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23556b82' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.55rem center; background-size: 1rem; }
.input-group { display: flex; align-items: stretch; min-width: 0; }
.input-group .input { border-radius: var(--r-field) 0 0 var(--r-field); min-width: 0; }
.input-group .btn { border-radius: 0 var(--r-field) var(--r-field) 0; margin-left: -1px; min-height: var(--control-h); }
.search-input { position: relative; min-width: 12rem; }
.search-input svg { position: absolute; left: 0.6rem; top: 50%; transform: translateY(-50%); width: 0.95rem; height: 0.95rem; color: var(--c-icon-muted); pointer-events: none; }
.search-input .input { padding-left: 2rem; border-radius: var(--r-button); box-shadow: none; border-color: var(--c-border-button); }
.check { display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.check input { width: 1rem; height: 1rem; accent-color: var(--c-brand); margin: 0; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.switch input { appearance: none; width: 2.5rem; height: 1.4rem; border-radius: 1rem; background: var(--c-border-content); position: relative; margin: 0; transition: background var(--dur); cursor: pointer; }
.switch input::after { content: ''; position: absolute; top: 0.2rem; left: 0.2rem; width: 1rem; height: 1rem; border-radius: 50%; background: #fff; transition: transform var(--dur) var(--ease); }
.switch input:checked { background: var(--c-brand); }
.switch input:checked::after { transform: translateX(1.1rem); }
.form-grid { display: grid; gap: var(--sp-3) var(--sp-5); grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 599.98px) { .form-grid .span-2 { grid-column: span 1; } }

/* Display pairs (object page form, read mode) */
.dl { display: grid; gap: var(--sp-3) var(--sp-6); grid-template-columns: repeat(auto-fill, minmax(min(13rem, 100%), 1fr)); margin: 0; }
.dl > div { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.dl dt { font-size: var(--fs-xs); color: var(--c-text-label); }
.dl dd { margin: 0; font-weight: var(--fw-semibold); overflow-wrap: anywhere; }
.dl-rows { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.45rem var(--sp-4); margin: 0; }
.dl-rows dt { color: var(--c-text-label); }
.dl-rows dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.dl-rows .total { font-weight: var(--fw-bold); font-size: var(--fs-md); border-top: 1px solid var(--c-border-strong); padding-top: 0.45rem; }

/* ───── Tags, status, badges, avatars */
.tag { display: inline-flex; align-items: center; gap: 0.3rem; height: 1.375rem; padding: 0 0.5rem; border-radius: 0.375rem; font-size: var(--fs-xs); font-weight: var(--fw-semibold); background: var(--tone-bg, var(--c-neutral-bg)); color: var(--tone-text, var(--c-neutral)); border: 1px solid color-mix(in oklab, var(--tone-border, var(--c-neutral-border)) 45%, transparent); white-space: nowrap; line-height: 1; }
.tag svg { width: 0.8rem; height: 0.8rem; }
.tag-accent { background: var(--accent-bg); color: var(--accent-text); border-color: transparent; }
.status { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--tone-text, var(--c-text)); font-weight: var(--fw-semibold); white-space: nowrap; }
.status svg { width: 0.95rem; height: 0.95rem; color: var(--tone-el, currentColor); }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 1.25rem; height: 1.25rem; padding: 0 0.35rem; border-radius: var(--r-pill); background: var(--tone-el, var(--c-negative-el)); color: #fff; font-size: var(--fs-2xs); font-weight: var(--fw-bold); line-height: 1; }
.badge.soft { background: var(--c-bg-muted); color: var(--c-text-label); }
.avatar { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--accent-bg, var(--c-accent-6-bg)); color: var(--accent-text, var(--c-accent-6)); font-weight: var(--fw-bold); font-size: var(--fs-xs); flex: none; }
.avatar.lg { width: 3rem; height: 3rem; font-size: var(--fs-md); }
.avatar.xl { width: 4rem; height: 4rem; font-size: var(--fs-lg); }
.dot { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--tone-el, var(--c-neutral-el)); flex: none; }
.chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.15rem 0.6rem; border: 1px solid var(--c-border-button); border-radius: var(--r-pill); background: var(--c-bg); font-size: var(--fs-xs); white-space: nowrap; }
.chip.is-active { background: var(--c-selected-bg); border-color: var(--c-brand); color: var(--c-selected); font-weight: var(--fw-semibold); }
button.chip:hover { background: var(--c-hover); }
.obj-id { font-family: var(--font-mono); font-size: 0.9em; color: var(--c-text-label); }
a .obj-id { color: inherit; }

/* ───── Message strip */
.strip { display: flex; align-items: flex-start; gap: var(--sp-2); padding: 0.6rem var(--sp-3); border-radius: var(--r-element); background: var(--tone-bg, var(--c-info-bg)); color: var(--c-text); border: 1px solid color-mix(in oklab, var(--tone-border, var(--c-info-border)) 35%, transparent); line-height: var(--lh-snug); }
.strip > svg { width: 1.05rem; height: 1.05rem; color: var(--tone-el, var(--c-info-el)); margin-top: 0.1rem; }
.strip .grow { flex: 1 1 auto; }
.strip strong { font-weight: var(--fw-bold); }

/* ───── Tables */
.tbl-card { padding: 0; overflow: hidden; }
.tbl-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--c-border); }
.tbl-toolbar .tbl-title { font-weight: var(--fw-bold); font-size: var(--fs-md); }
.tbl-toolbar .tbl-count { color: var(--c-text-label); }
.tbl-toolbar .grow { min-width: 0.5rem; }
.tbl-filters { display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--c-border); background: var(--c-bg-subtle); align-items: flex-end; }
.tbl-filters .field { min-width: 10rem; flex: 0 1 13rem; }
.tbl-scroll { overflow-x: auto; }
.tbl { width: 100%; font-size: var(--fs-sm); }
.tbl th { position: sticky; top: 0; z-index: 1; background: var(--c-bg-subtle); color: var(--c-text-label); font-weight: var(--fw-semibold); font-size: var(--fs-xs); text-align: left; padding: 0.55rem var(--sp-3); border-bottom: 1px solid var(--c-border-strong); white-space: nowrap; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--c-text); }
.tbl th .sort-ico { display: inline-block; width: 0.7rem; height: 0.7rem; vertical-align: -0.05rem; margin-left: 0.2rem; opacity: 0.35; }
.tbl th.is-sorted .sort-ico { opacity: 1; color: var(--c-brand); }
.tbl td { padding: 0.55rem var(--sp-3); border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--c-hover); }
.tbl tbody tr.is-click { cursor: pointer; }
.tbl tbody tr.is-alert td { background: var(--c-row-alert); }
.tbl tbody tr.is-alert:hover td { background: #ffe3e3; }
.tbl tbody tr.is-warn td { background: #fffbea; }
.tbl tbody tr.is-selected td { background: var(--c-selection-row); }
.tbl tbody tr.is-group td { background: var(--c-bg-muted); font-weight: var(--fw-bold); }
.tbl tfoot td { padding: 0.6rem var(--sp-3); font-weight: var(--fw-bold); border-top: 1px solid var(--c-border-strong); background: var(--c-bg-subtle); }
.tbl .num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .ctr { text-align: center; }
.tbl .nowrap { white-space: nowrap; }
.tbl .chev-cell { width: 2rem; color: var(--c-icon-muted); }
.tbl .chev-cell svg { width: 0.9rem; height: 0.9rem; }
.tbl .sel-cell { width: 2.25rem; }
.tbl-compact td, .tbl-compact th { padding-block: 0.35rem; }
.tbl .cell-main { font-weight: var(--fw-semibold); color: var(--c-text); }
.tbl .cell-sub { font-size: var(--fs-xs); color: var(--c-text-label); }
.tbl a.cell-main { color: var(--c-link); }
.tbl-pager { display: flex; align-items: center; gap: var(--sp-2); justify-content: flex-end; padding: var(--sp-2) var(--sp-4); border-top: 1px solid var(--c-border); color: var(--c-text-label); font-size: var(--fs-xs); flex-wrap: wrap; }
.tbl-empty { padding: var(--sp-10) var(--sp-4); text-align: center; color: var(--c-text-label); }
.tbl-edit td { padding: 0.3rem 0.4rem; }
.tbl-edit .input, .tbl-edit .select { min-height: 2rem; }
@media (max-width: 599.98px) {
  .tbl-cards thead { display: none; }
  .tbl-cards, .tbl-cards tbody, .tbl-cards tr, .tbl-cards td { display: block; width: 100%; }
  .tbl-cards tr { border-bottom: 1px solid var(--c-border); padding: var(--sp-2) 0; }
  .tbl-cards td { border: 0; padding: 0.2rem var(--sp-4); display: flex; justify-content: space-between; gap: var(--sp-3); text-align: right; }
  .tbl-cards td::before { content: attr(data-label); color: var(--c-text-label); font-size: var(--fs-xs); text-align: left; flex: none; }
  .tbl-cards td.num { text-align: right; }
  .tbl-cards td.hide-s, .tbl-cards td.chev-cell { display: none; }
  .tbl-cards tr:last-child td { border: 0; }
}

/* ───── In-page tabs (icon tab bar) */
.tabs { display: flex; gap: var(--sp-5); border-bottom: 1px solid var(--c-border); overflow-x: auto; scrollbar-width: none; }
.tab { position: relative; padding: var(--sp-2) 0 var(--sp-3); border: 0; background: none; white-space: nowrap; color: var(--c-text); }
.tab:hover { color: var(--c-selected); }
.tab.is-active { color: var(--c-selected); font-weight: var(--fw-bold); }
.tab.is-active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--c-brand); }
.tab .count { color: var(--c-text-label); font-weight: var(--fw-regular); margin-left: 0.25rem; }

/* ───── Object page sections */
.obj-section { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-card); box-shadow: var(--sh-card); min-width: 0; }
.obj-section > h2, .obj-section-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-4) var(--sp-3); font-size: var(--fs-md); }
.obj-section-head .grow { flex: 1 1 auto; }
.obj-section-body { padding: 0 var(--sp-4) var(--sp-4); }

/* ───── Process flow (document flow) */
.flow { display: flex; align-items: stretch; gap: 0; overflow-x: auto; padding: var(--sp-1) 0 var(--sp-2); }
.flow-step { position: relative; flex: 1 0 9.5rem; display: flex; flex-direction: column; gap: 0.25rem; padding: var(--sp-3); margin-right: 1.4rem; border: 1px solid var(--c-border); border-top: 3px solid var(--tone-el, var(--c-border-strong)); border-radius: var(--r-element); background: var(--c-surface); min-width: 9.5rem; color: var(--c-text); }
a.flow-step:hover { text-decoration: none; box-shadow: var(--sh-1); }
.flow-step:not(:last-child)::after { content: ''; position: absolute; right: -1.15rem; top: 50%; width: 0.8rem; height: 0.8rem; border-top: 2px solid var(--c-border-content); border-right: 2px solid var(--c-border-content); transform: translateY(-50%) rotate(45deg); }
.flow-step:last-child { margin-right: 0; }
.flow-kind { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--c-text-label); font-weight: var(--fw-bold); }
.flow-id { font-weight: var(--fw-bold); font-family: var(--font-mono); font-size: var(--fs-xs); }
.flow-meta { font-size: var(--fs-xs); color: var(--c-text-label); }
.flow-step.is-pending { border-style: dashed; background: var(--c-bg-subtle); }

/* Stepper (horizontal stages) */
.stepper { display: flex; gap: 0.25rem; overflow-x: auto; }
.stepper-step { flex: 1 0 auto; display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem; background: var(--c-bg-muted); color: var(--c-text-label); font-size: var(--fs-xs); font-weight: var(--fw-semibold); clip-path: polygon(0 0, calc(100% - 0.6rem) 0, 100% 50%, calc(100% - 0.6rem) 100%, 0 100%, 0.6rem 50%); padding-left: 1.1rem; white-space: nowrap; }
.stepper-step:first-child { clip-path: polygon(0 0, calc(100% - 0.6rem) 0, 100% 50%, calc(100% - 0.6rem) 100%, 0 100%); padding-left: 0.75rem; border-radius: 0.375rem 0 0 0.375rem; }
.stepper-step.is-done { background: var(--c-positive-bg); color: var(--c-positive); }
.stepper-step.is-current { background: var(--c-brand); color: #fff; }
.stepper-step.is-blocked { background: var(--c-negative-bg); color: var(--c-negative); }
.stepper-step svg { width: 0.85rem; height: 0.85rem; }

/* ───── Timeline */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { position: relative; display: grid; grid-template-columns: 2rem minmax(0, 1fr); gap: var(--sp-2); padding-bottom: var(--sp-4); }
.timeline li::before { content: ''; position: absolute; left: 0.95rem; top: 1.8rem; bottom: 0.2rem; width: 2px; background: var(--c-border); }
.timeline li:last-child::before { display: none; }
.tl-dot { width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; background: var(--tone-bg, var(--c-bg-muted)); color: var(--tone-el, var(--c-icon-muted)); }
.tl-dot svg { width: 0.95rem; height: 0.95rem; }
.tl-title { font-weight: var(--fw-semibold); }
.tl-meta { font-size: var(--fs-xs); color: var(--c-text-label); }

/* ───── Progress, meters */
.bar { position: relative; height: 0.5rem; border-radius: 0.25rem; background: var(--c-bg-muted); overflow: hidden; min-width: 3rem; }
.bar > span { position: absolute; inset: 0 auto 0 0; border-radius: 0.25rem; background: var(--tone-el, var(--c-brand)); }
.bar.thin { height: 0.35rem; }
.bar-row { display: grid; grid-template-columns: minmax(6rem, 10rem) minmax(0, 1fr) auto; align-items: center; gap: var(--sp-3); font-size: var(--fs-xs); }
.bar-row .bar-val { font-variant-numeric: tabular-nums; font-weight: var(--fw-semibold); min-width: 3.5rem; text-align: right; }
.stockbar { position: relative; height: 0.65rem; border-radius: 0.3rem; background: var(--c-bg-muted); min-width: 6rem; }
.stockbar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0.3rem; background: var(--tone-el, var(--c-brand)); }
.stockbar .mark { position: absolute; top: -0.2rem; bottom: -0.2rem; width: 2px; background: var(--c-text); opacity: 0.55; }
.stockbar .mark.rl { background: var(--c-critical-el); opacity: 1; }

/* ───── Dialog, drawer, popover, toast */
.dlg-scrim { position: fixed; inset: 0; z-index: var(--z-dialog); background: rgba(19, 30, 41, 0.45); display: grid; place-items: center; padding: var(--sp-4); animation: fade var(--dur) var(--ease); }
.dlg { width: min(var(--dlg-w, 36rem), 100%); max-height: min(90dvh, 52rem); display: flex; flex-direction: column; background: var(--c-surface); border-radius: var(--r-card); box-shadow: var(--sh-3); overflow: hidden; animation: pop var(--dur) var(--ease); }
.dlg-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--c-border); }
.dlg-title { font-size: var(--fs-lg); font-weight: var(--fw-bold); flex: 1 1 auto; min-width: 0; }
.dlg-body { padding: var(--sp-5); overflow-y: auto; display: flex; flex-direction: column; gap: var(--sp-4); }
.dlg-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--c-border); background: var(--c-bg-subtle); flex-wrap: wrap; }
.dlg-foot .grow { flex: 1 1 auto; }
.drawer-scrim { position: fixed; inset: 0; z-index: var(--z-drawer); background: rgba(19, 30, 41, 0.35); animation: fade var(--dur) var(--ease); }
.drawer { position: fixed; z-index: calc(var(--z-drawer) + 1); top: 0; right: 0; bottom: 0; width: min(var(--drawer-w, 34rem), 100vw); background: var(--c-surface); box-shadow: var(--sh-3); display: flex; flex-direction: column; animation: slidein var(--dur-slow) var(--ease); }
.drawer .dlg-body { flex: 1 1 auto; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(0.5rem) scale(0.98); } }
@keyframes slidein { from { transform: translateX(100%); } }
.menu { position: fixed; z-index: var(--z-popover); min-width: 14rem; max-width: min(24rem, calc(100vw - 1rem)); background: var(--c-surface); border-radius: var(--r-popover); box-shadow: var(--sh-2); padding: var(--sp-1); max-height: 75vh; overflow-y: auto; animation: pop var(--dur-fast) var(--ease); }
.menu-item { display: flex; align-items: center; gap: var(--sp-3); width: 100%; padding: 0.5rem var(--sp-3); border: 0; background: none; border-radius: var(--r-field); text-align: left; color: var(--c-text); }
.menu-item:hover { background: var(--c-hover); text-decoration: none; }
.menu-item svg { width: 1rem; height: 1rem; color: var(--c-icon-muted); }
.menu-item.is-active { background: var(--c-selected-bg); color: var(--c-selected); font-weight: var(--fw-semibold); }
.menu-item .mi-sub { font-size: var(--fs-xs); color: var(--c-text-label); }
.menu-head { padding: var(--sp-3); border-bottom: 1px solid var(--c-border); margin-bottom: var(--sp-1); }
.menu-sep { height: 1px; background: var(--c-border); margin: var(--sp-1) 0; }
.toast-host { position: fixed; z-index: var(--z-toast); bottom: 1.25rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: var(--sp-2); align-items: center; pointer-events: none; width: min(32rem, calc(100vw - 2rem)); }
.toast { display: flex; align-items: center; gap: var(--sp-2); padding: 0.7rem 1rem; border-radius: var(--r-element); background: #1d2d3e; color: #fff; box-shadow: var(--sh-2); animation: pop var(--dur) var(--ease); pointer-events: auto; max-width: 100%; }
.toast svg { width: 1rem; height: 1rem; color: var(--tone-el, #9ad1ff); }
.toast[data-tone='positive'] svg { color: #8fdc9f; } .toast[data-tone='negative'] svg { color: #ff9b9b; } .toast[data-tone='critical'] svg { color: #ffc56b; }

/* Tooltip (charts and [data-tip]) */
.tip { position: fixed; z-index: calc(var(--z-toast) + 1); pointer-events: none; background: #1d2d3e; color: #fff; padding: 0.45rem 0.65rem; border-radius: 0.375rem; font-size: var(--fs-xs); line-height: 1.4; box-shadow: var(--sh-2); max-width: 18rem; white-space: pre-line; }
.tip b { font-weight: var(--fw-bold); }

/* ───── Kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(15rem, 1fr); gap: var(--sp-3); overflow-x: auto; padding-bottom: var(--sp-2); }
.kcol { background: var(--c-bg-muted); border-radius: var(--r-card); padding: var(--sp-2); display: flex; flex-direction: column; gap: var(--sp-2); min-height: 12rem; }
.kcol-head { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-1) var(--sp-2); font-weight: var(--fw-bold); }
.kcol-head .badge { margin-left: auto; }
.kcard { background: var(--c-surface); border: 1px solid var(--c-border); border-left: 3px solid var(--tone-el, var(--c-brand)); border-radius: var(--r-element); padding: var(--sp-2) var(--sp-3); display: flex; flex-direction: column; gap: 0.2rem; box-shadow: var(--sh-card); color: var(--c-text); }
a.kcard:hover { text-decoration: none; box-shadow: var(--sh-1); }

/* ───── Empty state, misc */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); padding: var(--sp-10) var(--sp-4); text-align: center; color: var(--c-text-label); }
.empty svg { width: 2.5rem; height: 2.5rem; color: var(--c-icon-muted); }
.empty h3 { font-size: var(--fs-md); color: var(--c-text); }
.ico { width: 1rem; height: 1rem; display: inline-block; vertical-align: -0.15rem; }
.ico-sm { width: 0.85rem; height: 0.85rem; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: var(--sp-3); padding: 0.6rem var(--sp-4); border-bottom: 1px solid var(--c-border); min-width: 0; }
.list > li:last-child { border-bottom: 0; }
.list > li > a.list-link { display: flex; align-items: center; gap: var(--sp-3); flex: 1 1 auto; color: inherit; min-width: 0; }
.list > li > a.list-link:hover { text-decoration: none; }
.list > li:hover { background: var(--c-hover); }
.legend { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-4); font-size: var(--fs-xs); color: var(--c-text-label); }
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend i { width: 0.65rem; height: 0.65rem; border-radius: 0.15rem; display: inline-block; }
.mini-stat { display: flex; flex-direction: column; gap: 0.1rem; }
.mini-stat .v { font-size: var(--fs-lg); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.mini-stat .l { font-size: var(--fs-xs); color: var(--c-text-label); }
.hint-box { background: var(--c-bg-subtle); border-radius: var(--r-element); padding: var(--sp-3) var(--sp-4); font-size: var(--fs-xs); color: var(--c-text-label); line-height: var(--lh-relaxed); }
.ai-box { background: linear-gradient(135deg, #f3f0ff, #eaf4ff); border: 1px solid #d9d0ff; border-radius: var(--r-card); padding: var(--sp-4); }
.ai-box .ai-kicker { display: inline-flex; align-items: center; gap: 0.35rem; font-size: var(--fs-2xs); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: #5d36ff; }
.ai-box .ai-kicker svg { width: 0.9rem; height: 0.9rem; }
.formula { font-family: var(--font-mono); font-size: var(--fs-xs); background: var(--c-bg-subtle); border: 1px solid var(--c-border); border-radius: var(--r-field); padding: 0.4rem 0.6rem; color: var(--c-text); }

/* Segmented controls never widen the page: they scroll inside their own box on narrow screens */
.btn-group { max-width: 100%; overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
.btn-group::-webkit-scrollbar { display: none; }
.btn-group .btn { flex: none; }
