/* Component styles (ui/components/). Borders and surface tints, no shadows. */

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 var(--s3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { background: var(--surface-3); }
.btn:disabled { cursor: not-allowed; opacity: 0.55; }
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-inverse);
}
.btn--primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn--danger { color: var(--danger); border-color: var(--danger-border); }
.btn--danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn--danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn--sm { height: 26px; padding: 0 var(--s2); font-size: var(--fs-sm); }
.btn--icon { width: 32px; padding: 0; }
.btn--icon.btn--sm { width: 26px; }
.btn .icon { flex: none; }
.btn-group { display: inline-flex; gap: var(--s2); flex-wrap: wrap; }

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  text-align: left;
}
.link-btn:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ---------- icons ---------- */
.icon {
  width: 16px;
  height: 16px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -3px;
}
.icon--sm { width: 14px; height: 14px; vertical-align: -2px; }
.icon--xs { width: 12px; height: 12px; vertical-align: -1px; }
.icon--lg { width: 24px; height: 24px; }
.icon--xl { width: 32px; height: 32px; stroke-width: 1.5; }

/* ---------- form controls ---------- */
.field { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.field__label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.field__hint { font-size: var(--fs-sm); color: var(--text-3); }
.field__error { font-size: var(--fs-sm); color: var(--danger); display: flex; gap: 4px; align-items: center; }
.input,
.select,
.textarea {
  height: 32px;
  min-width: 0;
  padding: 0 var(--s2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.textarea { height: auto; min-height: 72px; padding: var(--s2); resize: vertical; line-height: var(--lh); }
.input::placeholder,
.textarea::placeholder { color: var(--text-3); }
.input:hover,
.select:hover { border-color: var(--text-3); }
.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input--sm,
.select--sm { height: 26px; font-size: var(--fs-sm); }
.select {
  appearance: none;
  padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 13px) 50%, calc(100% - 9px) 50%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
}
.input-icon { position: relative; display: flex; align-items: center; min-width: 0; }
.input-icon > .icon { position: absolute; left: 9px; color: var(--text-3); pointer-events: none; }
.input-icon > .input { padding-left: 30px; width: 100%; }
.input-icon > kbd { position: absolute; right: 7px; pointer-events: none; }
.checkbox { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; cursor: pointer; }

/* ---------- badges / status ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border: 1px solid var(--neutral-border);
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}
.badge .icon { width: 12px; height: 12px; stroke-width: 2; vertical-align: 0; }
.badge--danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.badge--warn { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn); }
.badge--ok { background: var(--ok-soft); border-color: var(--ok-border); color: var(--ok); }
.badge--info { background: var(--info-soft); border-color: var(--info-border); color: var(--info); }
.badge--accent { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }
.badge--outline { background: transparent; }
.badge--square { border-radius: var(--radius-sm); }
.badge--lg { height: 24px; padding: 0 9px; font-size: var(--fs-sm); }

.count-pill {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.count-pill--alert { background: var(--danger); color: #fff; }
.count-pill--accent { background: var(--accent); color: var(--text-inverse); }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--neutral); }
.dot--danger { background: var(--danger); }
.dot--warn { background: var(--warn); }
.dot--ok { background: var(--ok); }
.dot--info { background: var(--info); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  max-width: 100%;
  padding: 0 4px 0 8px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text);
  font-size: var(--fs-sm);
}
.chip__x {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.chip__x:hover { background: var(--surface-3); }

/* ---------- panels / cards ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
}
.panel__head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 44px;
  padding: var(--s2) var(--s4);
  border-bottom: 1px solid var(--border);
}
.panel__head h2,
.panel__head h3 { font-size: var(--fs-h3); }
.panel__title { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: var(--s2); }
.panel__body { padding: var(--s4); }
.panel__body--flush { padding: 0; }
.panel__foot {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s4);
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: var(--fs-sm);
}
.panel--sunken { background: var(--surface-2); }

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s3) var(--s4);
  min-width: 0;
}
.stat__label { font-size: var(--fs-sm); color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.stat__value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.25; }
.stat__value small { font-size: 13px; font-weight: 500; color: var(--text-2); margin-left: 2px; }
.stat__meta { font-size: var(--fs-sm); color: var(--text-3); }

.kv {
  display: grid;
  grid-template-columns: minmax(96px, max-content) minmax(0, 1fr);
  column-gap: var(--s4);
  row-gap: 6px;
  margin: 0;
  font-size: 13px;
}
.kv dt { color: var(--text-2); white-space: nowrap; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.code-block {
  margin: 0;
  padding: var(--s2) var(--s3);
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-sunken);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
}

.hash {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
}

/* ---------- tabs / segmented ---------- */
.tabs {
  display: flex;
  gap: var(--s1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 var(--s3);
  border: 0;
  background: none;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); font-weight: 600; }
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: var(--s2);
  right: var(--s2);
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.segmented button {
  height: 26px;
  padding: 0 var(--s3);
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border-strong);
}

/* ---------- table ---------- */
.table-wrap {
  position: relative;
  overflow: auto;
  max-width: 100%;
  border-radius: inherit;
}
.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-table);
  font-variant-numeric: tabular-nums;
}
.tbl th,
.tbl td {
  height: var(--row-h);
  padding: 0 var(--s3);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  background: var(--surface);
}
.tbl th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 34px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  user-select: none;
}
.tbl th.is-num,
.tbl td.is-num { text-align: right; }
.tbl th.is-center,
.tbl td.is-center { text-align: center; }
.tbl td.is-wrap { white-space: normal; min-width: 200px; }
.tbl td .cell-ellipsis { display: block; overflow: hidden; text-overflow: ellipsis; max-width: var(--cell-max, 280px); }
.tbl .is-sticky { position: sticky; z-index: 1; }
.tbl th.is-sticky { z-index: 3; }
.tbl .is-sticky-last { box-shadow: inset -1px 0 0 var(--border); }
.tbl tbody tr { cursor: default; }
.tbl tbody tr.is-clickable { cursor: pointer; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl tbody tr.is-active td { background: var(--accent-soft); }
.tbl tbody tr.is-active td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.tbl tbody tr.is-selected td { background: var(--accent-soft); }
.tbl tbody tr.is-muted td { color: var(--text-3); }
.tbl tbody tr.is-struck td { color: var(--text-3); text-decoration: line-through; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  padding: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.th-sort .icon { opacity: 0.35; }
.th-sort[data-dir] .icon { opacity: 1; color: var(--accent); }
.th-sort:hover .icon { opacity: 0.8; }
.tbl--compact td { height: 28px; }
.tbl--flush th:first-child,
.tbl--flush td:first-child { padding-left: var(--s4); }
.tbl--flush th:last-child,
.tbl--flush td:last-child { padding-right: var(--s4); }
.tbl-foot {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s4);
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--text-3);
}

/* ---------- filter bar ---------- */
.filterbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s2);
  padding: var(--s2) var(--s4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.filterbar__search { width: 240px; }
.filterbar__group { display: inline-flex; align-items: center; gap: 6px; }
.filterbar__label { font-size: var(--fs-sm); color: var(--text-2); white-space: nowrap; }
.filterbar__spacer { flex: 1 1 auto; }
.filterbar__count { font-size: var(--fs-sm); color: var(--text-3); white-space: nowrap; }

/* ---------- empty / error / skeleton ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: var(--s10) var(--s6);
  text-align: center;
  color: var(--text-2);
}
.empty__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-3);
  margin-bottom: var(--s1);
}
.empty__title { font-size: var(--fs-body); font-weight: 600; color: var(--text); }
.empty__body { max-width: 440px; font-size: 13px; }
.empty--compact { padding: var(--s6) var(--s4); }
.empty--error .empty__icon { background: var(--danger-soft); color: var(--danger); }

.error-box {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s1) var(--s3);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--danger-border);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius);
  background: var(--danger-soft);
  font-size: 13px;
}
.error-box > .icon { color: var(--danger); margin-top: 2px; }
.error-box__title { font-weight: 600; color: var(--danger); }
.error-box dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 2px var(--s3); }
.error-box dt { color: var(--text-2); }
.error-box dd { margin: 0; }
.error-box ul { margin: 0; padding-left: 18px; }

.callout {
  display: flex;
  gap: var(--s2);
  align-items: flex-start;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--info-border);
  border-radius: var(--radius);
  background: var(--info-soft);
  font-size: 13px;
}
.callout > .icon { color: var(--info); margin-top: 2px; }
.callout--warn { border-color: var(--warn-border); background: var(--warn-soft); }
.callout--warn > .icon { color: var(--warn); }
.callout--ok { border-color: var(--ok-border); background: var(--ok-soft); }
.callout--ok > .icon { color: var(--ok); }
.callout--danger { border-color: var(--danger-border); background: var(--danger-soft); }
.callout--danger > .icon { color: var(--danger); }

.skel {
  display: block;
  height: 12px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: skel 1.4s ease-in-out infinite;
}
.skel--title { height: 18px; width: 40%; }
.skel--block { height: 120px; border-radius: var(--radius); }
.skel-table { display: flex; flex-direction: column; }
.skel-table__row { display: flex; gap: var(--s4); align-items: center; height: var(--row-h); padding: 0 var(--s4); border-bottom: 1px solid var(--border); }
@keyframes skel {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- drawer ---------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-drawer);
  background: var(--overlay);
  animation: fade 120ms ease-out;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: calc(var(--z-drawer) + 1);
  display: flex;
  flex-direction: column;
  width: min(var(--drawer-w), 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border-strong);
  animation: slide-in 160ms ease-out;
}
.drawer--wide { width: min(760px, 100vw); }
.drawer__head {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
}
.drawer__titles { flex: 1 1 auto; min-width: 0; }
.drawer__eyebrow { font-size: var(--fs-sm); color: var(--text-3); }
.drawer__title { font-size: var(--fs-h2); overflow-wrap: anywhere; }
.drawer__body { flex: 1 1 auto; overflow: auto; padding: var(--s4); display: flex; flex-direction: column; gap: var(--s4); }
.drawer__foot { display: flex; gap: var(--s2); justify-content: flex-end; padding: var(--s3) var(--s4); border-top: 1px solid var(--border); }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- dialog ---------- */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-dialog);
  display: grid;
  place-items: center;
  padding: var(--s6);
  background: var(--overlay);
  animation: fade 120ms ease-out;
}
.dialog {
  width: min(480px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}
.dialog--wide { width: min(720px, 100%); }
.dialog__head { display: flex; align-items: center; gap: var(--s2); padding: var(--s4) var(--s4) var(--s2); }
.dialog__head h2 { flex: 1; }
.dialog__head .icon--tone-danger { color: var(--danger); }
.dialog__head .icon--tone-warn { color: var(--warn); }
.dialog__body { padding: var(--s2) var(--s4) var(--s4); overflow: auto; display: flex; flex-direction: column; gap: var(--s3); font-size: 13px; }
.dialog__foot { display: flex; gap: var(--s2); justify-content: flex-end; padding: var(--s3) var(--s4); border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- toast ---------- */
.toasts {
  position: fixed;
  right: var(--s4);
  bottom: var(--s4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  width: min(400px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--s2);
  align-items: start;
  padding: var(--s3);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--info);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  animation: slide-up 160ms ease-out;
}
.toast > .icon { margin-top: 2px; color: var(--info); }
.toast--ok { border-left-color: var(--ok); }
.toast--ok > .icon { color: var(--ok); }
.toast--warn { border-left-color: var(--warn); }
.toast--warn > .icon { color: var(--warn); }
.toast--danger { border-left-color: var(--danger); }
.toast--danger > .icon { color: var(--danger); }
.toast__title { font-weight: 600; }
.toast__body { color: var(--text-2); margin-top: 2px; }
@keyframes slide-up { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- popover / menu / tooltip ---------- */
.popover {
  position: fixed;
  z-index: var(--z-popover);
  width: 380px;
  max-width: calc(100vw - 16px);
  max-height: min(520px, calc(100vh - 16px));
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px;
  animation: fade 100ms ease-out;
}
.popover__head { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3); border-bottom: 1px solid var(--border); }
.popover__head h3 { flex: 1; font-size: 13px; }
.popover__body { padding: var(--s3); display: flex; flex-direction: column; gap: var(--s3); }
.menu {
  position: absolute;
  z-index: var(--z-popover);
  min-width: 200px;
  padding: var(--s1);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}
.menu__item {
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: 100%;
  height: 32px;
  padding: 0 var(--s2);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.menu__item:hover,
.menu__item:focus-visible { background: var(--surface-2); outline: none; }
.menu__sep { height: 1px; margin: var(--s1) 0; background: var(--border); }
.menu__label { padding: var(--s1) var(--s2); font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; }

/* ---------- value marks ---------- */
.val { display: inline-flex; align-items: baseline; gap: 2px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.val__unit { color: var(--text-2); font-size: 0.92em; margin-left: 1px; }
.val--empty { color: var(--text-3); }
.src-mark {
  display: inline-grid;
  place-items: center;
  width: 13px;
  height: 13px;
  margin-left: 2px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text-3);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  vertical-align: super;
  cursor: pointer;
  flex: none;
}
.src-mark:hover,
.src-mark[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.src-mark--edited { border-color: var(--info-border); color: var(--info); }

.redacted {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 6px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 4px, var(--surface) 4px 8px);
  color: var(--text-2);
  font-size: var(--fs-xs);
  white-space: nowrap;
  cursor: help;
}
.redacted .icon { width: 12px; height: 12px; color: var(--text-3); }

.guess-mark {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 18px;
  padding: 0 5px;
  border: 1px dashed var(--warn);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--warn);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  cursor: pointer;
}
.guess-mark:hover { background: var(--warn-soft); }

/* ---------- gauge ---------- */
.gauge { display: inline-flex; align-items: stretch; gap: var(--s2); }
.gauge svg { display: block; overflow: visible; }
.gauge__vessel { fill: var(--gauge-empty); stroke: var(--border-strong); stroke-width: 1; }
.gauge__fill { fill: var(--gauge-fill); }
.gauge__fill--low { fill: var(--gauge-fill-low); }
.gauge__line { stroke-width: 1.5; }
.gauge__line--safety { stroke: var(--danger); stroke-dasharray: 3 2; }
.gauge__line--max { stroke: var(--text-2); }
.gauge__label { fill: var(--text-2); font-size: 10px; font-family: var(--font); }
.gauge__legend { display: flex; flex-direction: column; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-2); font-variant-numeric: tabular-nums; }
.gauge__value { font-size: 13px; font-weight: 600; color: var(--text); }
.hbar { position: relative; height: 8px; border-radius: 4px; background: var(--gauge-empty); overflow: hidden; }
.hbar__fill { position: absolute; inset: 0 auto 0 0; background: var(--gauge-fill); border-radius: 4px; }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart > svg { display: block; width: 100%; overflow: visible; font-family: var(--font); }
.chart__grid { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart__axis { stroke: var(--chart-axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart__tick { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart__unit { fill: var(--text-2); font-size: 11px; font-weight: 600; }
.chart__line { fill: none; stroke: var(--chart-line); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.chart__line--projection { stroke-dasharray: 5 4; }
.chart__line--s2 { stroke: var(--chart-line-2); }
.chart__line--s3 { stroke: var(--chart-line-3); }
.chart__band { fill: var(--chart-band); stroke: none; }
.chart__band--risk { fill: var(--chart-band-risk); }
.chart__ref { stroke-width: 1.25; shape-rendering: crispEdges; }
.chart__ref--danger { stroke: var(--danger); stroke-dasharray: 4 3; }
.chart__ref--warn { stroke: var(--warn); stroke-dasharray: 4 3; }
.chart__ref--neutral { stroke: var(--text-3); stroke-dasharray: 2 3; }
.chart__ref-label { font-size: 10px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.chart__ref-label--danger { fill: var(--danger); }
.chart__ref-label--warn { fill: var(--warn); }
.chart__ref-label--neutral { fill: var(--text-2); }
.chart__now { stroke: var(--chart-now); stroke-width: 1; }
.chart__now-label { fill: var(--text); font-size: 10px; font-weight: 700; }
.chart__marker { stroke: var(--info); stroke-width: 1.5; }
.chart__marker-head { fill: var(--info); }
.chart__marker-label { fill: var(--info); font-size: 10px; font-weight: 600; }
.chart__quality--bad { fill: var(--danger); opacity: 0.18; }
.chart__quality--estimated { fill: var(--warn); opacity: 0.14; }
.chart__cursor { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 2 2; pointer-events: none; }
.chart__dot { fill: var(--surface); stroke-width: 2; pointer-events: none; }
.chart__readout {
  position: absolute;
  top: 4px;
  z-index: 2;
  min-width: 150px;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.chart__readout-row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.chart__legend { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); font-size: var(--fs-sm); color: var(--text-2); margin-top: var(--s2); }
.legend-key { display: inline-flex; align-items: center; gap: 6px; }
.legend-key svg { width: 22px; height: 10px; overflow: visible; }
.sparkline { display: block; overflow: visible; }
.sparkline path { fill: none; stroke: var(--chart-line); stroke-width: 1.5; }
.sparkline .sparkline__proj { stroke-dasharray: 3 2; }
.sparkline .sparkline__floor { stroke: var(--danger); stroke-width: 1; stroke-dasharray: 2 2; }

/* ---------- gantt ---------- */
.gantt { display: grid; grid-template-columns: 148px 1fr; font-size: var(--fs-sm); min-width: 0; }
.gantt__axis { grid-column: 2; position: relative; height: 26px; border-bottom: 1px solid var(--border); overflow: hidden; }
.gantt__tick { position: absolute; top: 4px; transform: translateX(-50%); color: var(--text-3); font-size: var(--fs-xs); white-space: nowrap; font-variant-numeric: tabular-nums; }
.gantt__tick--day { color: var(--text-2); font-weight: 600; transform: none; padding-left: 4px; overflow: hidden; text-overflow: clip; box-sizing: border-box; }
.gantt__lane-label > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt__lane-label { display: flex; align-items: center; height: 34px; padding-right: var(--s2); color: var(--text-2); border-bottom: 1px solid var(--border); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt__lane { position: relative; height: 34px; border-bottom: 1px solid var(--border); background-image: repeating-linear-gradient(90deg, transparent 0, transparent calc(var(--day-w, 100px) - 1px), var(--chart-grid) calc(var(--day-w, 100px) - 1px), var(--chart-grid) var(--day-w, 100px)); }
.gantt__bar {
  position: absolute;
  box-sizing: border-box;
  top: 6px;
  height: 22px;
  min-width: 14px; /* = MIN_BAR_PX in ui/components/gantt.js */
  padding: 0 6px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text);
  font-size: var(--fs-xs);
  line-height: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
}
.gantt__bar--danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.gantt__bar--warn { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn); }
.gantt__bar--ok { background: var(--ok-soft); border-color: var(--ok-border); color: var(--ok); }
.gantt__bar--info { background: var(--info-soft); border-color: var(--info-border); color: var(--info); }
.gantt__bar--muted { background: repeating-linear-gradient(135deg, var(--surface-2) 0 4px, var(--surface-3) 4px 8px); border-color: var(--border-strong); color: var(--text-2); }
.gantt__label { position: absolute; top: 50%; transform: translateY(-50%); font-size: var(--fs-xs); color: var(--text-2); white-space: nowrap; pointer-events: none; }
.gantt__label--danger { color: var(--danger); }
.gantt__label--warn { color: var(--warn); }
.gantt__now { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px solid var(--chart-now); z-index: 1; pointer-events: none; }
.gantt__body { grid-column: 2; position: relative; }

/* ---------- compare ---------- */
.compare td.is-best { font-weight: 600; }
.compare .rank {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-3);
  font-weight: 700;
  font-size: var(--fs-sm);
}
.compare tr.is-top .rank { background: var(--accent); color: var(--text-inverse); }
.compare-toggle { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s4); border-top: 1px solid var(--border); background: var(--surface-2); font-size: var(--fs-sm); color: var(--text-2); }

/* ---------- diff ---------- */
.diff { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-table); }
.diff th { text-align: left; font-size: var(--fs-sm); color: var(--text-2); font-weight: 600; padding: 6px var(--s3); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.diff td { padding: 6px var(--s3); border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.diff tr.is-changed td.diff__before { background: var(--danger-soft); }
.diff tr.is-changed td.diff__after { background: var(--ok-soft); }
.diff tr.is-added td.diff__after { background: var(--ok-soft); }
.diff tr.is-removed td.diff__before { background: var(--danger-soft); text-decoration: line-through; }
.diff td.diff__key { color: var(--text-2); width: 28%; white-space: nowrap; }
.diff__sign { display: inline-block; width: 12px; color: var(--text-3); font-family: var(--font-mono); }

/* ---------- lineage flow ---------- */
.flow { display: flex; align-items: stretch; gap: 0; overflow-x: auto; padding-bottom: var(--s2); }
.flow__step {
  flex: 0 0 auto;
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: var(--fs-sm);
}
.flow__step--current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.flow__step--edit { border-color: var(--info-border); }
.flow__kind { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--text-3); font-weight: 700; letter-spacing: 0.04em; }
.flow__title { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.flow__arrow { flex: 0 0 32px; display: grid; place-items: center; color: var(--text-3); }
.flow-v { display: flex; flex-direction: column; gap: 0; }
.flow-v .flow__step { width: auto; }
.flow-v .flow__arrow { height: 20px; flex-basis: 20px; }

/* ---------- misc ---------- */
.progress { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.progress__bar { height: 100%; background: var(--accent); }
.progress__bar--warn { background: var(--warn); }
.progress__bar--danger { background: var(--danger); }
.legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; }
.section-title { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); font-weight: 700; color: var(--text-2); letter-spacing: 0.02em; }
.tag-list { display: flex; flex-wrap: wrap; gap: var(--s1); }
.truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { position: relative; padding: 0 0 var(--s3) var(--s5); font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.timeline li::after { content: ""; position: absolute; left: 7px; top: 16px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline li.is-accent::before { background: var(--accent); }
