/* ============================================================
   secqr ops · COMPONENTS
   ----------------------------------------------------------------
   All components prefixed .ds-* and built on tokens from
   ds-tokens.css. Components are theme-agnostic — they pick up
   light/dark from the [data-theme] on any ancestor.
   ============================================================ */

/* ============================================================
   1. BASE TYPOGRAPHY UTILITIES
   ============================================================ */
.ds-display {
  font-family: var(--ds-font-serif);
  font-weight: 400;
  font-size: var(--ds-fs-6xl);
  line-height: var(--ds-lh-tight);
  letter-spacing: var(--ds-tr-display);
  color: var(--ds-ink);
}
.ds-display em { font-style: italic; color: var(--ds-brand-deep); }

.ds-h1 {
  font-family: var(--ds-font-sans);
  font-weight: 600;
  font-size: var(--ds-fs-4xl);
  line-height: var(--ds-lh-tight);
  letter-spacing: var(--ds-tr-head);
  color: var(--ds-ink);
}
.ds-h2 {
  font-family: var(--ds-font-sans);
  font-weight: 600;
  font-size: var(--ds-fs-3xl);
  line-height: var(--ds-lh-snug);
  letter-spacing: var(--ds-tr-head);
  color: var(--ds-ink);
}
.ds-h3 {
  font-family: var(--ds-font-sans);
  font-weight: 600;
  font-size: var(--ds-fs-xl);
  line-height: var(--ds-lh-snug);
  letter-spacing: -0.005em;
  color: var(--ds-ink);
}
.ds-h4 {
  font-family: var(--ds-font-sans);
  font-weight: 600;
  font-size: var(--ds-fs-lg);
  line-height: var(--ds-lh-snug);
  color: var(--ds-ink);
}
.ds-body {
  font-family: var(--ds-font-sans);
  font-weight: 400;
  font-size: var(--ds-fs-base);
  line-height: var(--ds-lh-base);
  color: var(--ds-ink-1);
}
.ds-body-sm {
  font-family: var(--ds-font-sans);
  font-weight: 400;
  font-size: var(--ds-fs-md);
  line-height: var(--ds-lh-base);
  color: var(--ds-ink-1);
}
.ds-caption {
  font-family: var(--ds-font-mono);
  font-weight: 500;
  font-size: var(--ds-fs-xs);
  line-height: 1.5;
  letter-spacing: var(--ds-tr-caps);
  text-transform: uppercase;
  color: var(--ds-ink-2);
}
.ds-mono {
  font-family: var(--ds-font-mono);
  font-weight: 400;
  font-size: var(--ds-fs-sm);
  letter-spacing: var(--ds-tr-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ds-ink-1);
}
.ds-num {
  font-family: var(--ds-font-mono);
  font-feature-settings: "tnum" 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
}
.ds-stat {
  font-family: var(--ds-font-serif);
  font-weight: 400;
  font-size: var(--ds-fs-5xl);
  line-height: 1;
  letter-spacing: -0.012em;
  color: var(--ds-ink);
}

/* ============================================================
   2. BUTTON
   ============================================================ */
.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ds-s-2);
  height: var(--ds-h-md);
  padding: 0 var(--ds-s-4);
  border-radius: var(--ds-r-md);
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-md);
  font-weight: 500;
  letter-spacing: -0.003em;
  white-space: nowrap;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ds-ink);
  cursor: pointer;
  transition:
    background var(--ds-dur-fast) var(--ds-ease),
    border-color var(--ds-dur-fast) var(--ds-ease),
    color var(--ds-dur-fast) var(--ds-ease),
    box-shadow var(--ds-dur-fast) var(--ds-ease),
    transform var(--ds-dur-fast) var(--ds-ease);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.ds-btn:focus-visible { outline: none; box-shadow: var(--ds-focus-ring); }
.ds-btn:active { transform: translateY(1px); }
.ds-btn[disabled],
.ds-btn[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.5;
}
.ds-btn .ds-icon { width: 14px; height: 14px; flex-shrink: 0; }
.ds-btn .kbd {
  font-family: var(--ds-font-mono);
  font-size: 10.5px;
  color: var(--ds-ink-2);
  background: var(--ds-surface-3);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: var(--ds-s-2);
}

/* variants */
.ds-btn--primary {
  background: var(--ds-brand);
  color: #15170F;
  border-color: var(--ds-brand-deep);
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.12);
}
.ds-btn--primary:hover { background: var(--ds-brand-deep); color: #FFFFFF; }
[data-theme="dark"] .ds-btn--primary:hover { color: #0E1013; background: var(--ds-brand-bright); }

.ds-btn--secondary {
  background: var(--ds-surface);
  color: var(--ds-ink);
  border-color: var(--ds-rule-2);
}
.ds-btn--secondary:hover { background: var(--ds-surface-2); }

.ds-btn--ghost {
  background: transparent;
  color: var(--ds-ink-1);
}
.ds-btn--ghost:hover { background: var(--ds-surface-2); color: var(--ds-ink); }

.ds-btn--danger {
  background: var(--ds-crit);
  color: #FFFFFF;
  border-color: rgba(0,0,0,0.15);
}
.ds-btn--danger:hover { filter: brightness(0.92); }

.ds-btn--quiet-danger {
  background: transparent;
  color: var(--ds-crit);
  border-color: transparent;
}
.ds-btn--quiet-danger:hover { background: var(--ds-crit-tint); }

/* sizes */
.ds-btn--xs { height: var(--ds-h-xs); padding: 0 var(--ds-s-2); font-size: var(--ds-fs-xs); border-radius: var(--ds-r-sm); }
.ds-btn--sm { height: var(--ds-h-sm); padding: 0 var(--ds-s-3); font-size: var(--ds-fs-sm); }
.ds-btn--lg { height: var(--ds-h-lg); padding: 0 var(--ds-s-5); font-size: var(--ds-fs-lg); }
.ds-btn--icon { width: var(--ds-h-md); padding: 0; }
.ds-btn--icon.ds-btn--sm { width: var(--ds-h-sm); }
.ds-btn--block { display: flex; width: 100%; }

.ds-btn-group {
  display: inline-flex;
  background: var(--ds-surface);
  border: 1px solid var(--ds-rule-2);
  border-radius: var(--ds-r-md);
  overflow: hidden;
}
.ds-btn-group .ds-btn {
  border-radius: 0;
  border-color: transparent;
  border-right: 1px solid var(--ds-rule);
  background: transparent;
}
.ds-btn-group .ds-btn:last-child { border-right: 0; }
.ds-btn-group .ds-btn:hover { background: var(--ds-surface-2); }

/* ============================================================
   3. INPUT / TEXTAREA / SELECT / SEARCH
   ============================================================ */
.ds-field {
  display: flex;
  flex-direction: column;
  gap: var(--ds-s-2);
}
.ds-label {
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-md);
  font-weight: 500;
  color: var(--ds-ink);
  display: flex;
  align-items: center;
  gap: var(--ds-s-2);
}
.ds-label .req { color: var(--ds-crit); }
.ds-label .opt {
  font-weight: 400;
  font-size: var(--ds-fs-sm);
  color: var(--ds-ink-2);
}
.ds-help {
  font-size: var(--ds-fs-sm);
  color: var(--ds-ink-2);
  line-height: 1.45;
}
.ds-help.error { color: var(--ds-crit); }

.ds-input {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-s-2);
  height: var(--ds-h-md);
  padding: 0 var(--ds-s-3);
  background: var(--ds-surface);
  border: 1px solid var(--ds-rule-2);
  border-radius: var(--ds-r-md);
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-md);
  color: var(--ds-ink);
  transition: border-color var(--ds-dur-fast), box-shadow var(--ds-dur-fast);
  width: 100%;
  min-width: 0;
}
.ds-input:focus-within {
  border-color: var(--ds-focus);
  box-shadow: var(--ds-focus-ring);
}
.ds-input .ds-icon { width: 14px; height: 14px; color: var(--ds-ink-2); flex-shrink: 0; }
.ds-input input,
.ds-input select,
.ds-input textarea {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  padding: 0;
}
.ds-input input::placeholder,
.ds-input textarea::placeholder { color: var(--ds-ink-3); }
.ds-input.ds-input--error { border-color: var(--ds-crit); }
.ds-input.ds-input--error:focus-within { box-shadow: 0 0 0 3px var(--ds-crit-tint); }
.ds-input.ds-input--disabled { background: var(--ds-bg-2); color: var(--ds-ink-3); }

.ds-input--sm { height: var(--ds-h-sm); padding: 0 var(--ds-s-2); font-size: var(--ds-fs-sm); }
.ds-input--lg { height: var(--ds-h-lg); padding: 0 var(--ds-s-4); font-size: var(--ds-fs-lg); }

.ds-textarea {
  display: block;
  width: 100%;
  min-height: 96px;
  padding: var(--ds-s-3);
  background: var(--ds-surface);
  border: 1px solid var(--ds-rule-2);
  border-radius: var(--ds-r-md);
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-md);
  color: var(--ds-ink);
  resize: vertical;
  line-height: 1.5;
}
.ds-textarea:focus { outline: 0; border-color: var(--ds-focus); box-shadow: var(--ds-focus-ring); }
.ds-textarea::placeholder { color: var(--ds-ink-3); }

.ds-select-native {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ds-ink-2) 50%),
    linear-gradient(135deg, var(--ds-ink-2) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 10px) 50%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
  padding-right: 28px !important;
}

/* ============================================================
   4. CHECKBOX / RADIO / TOGGLE
   ============================================================ */
.ds-check, .ds-radio {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--ds-s-2);
  cursor: pointer;
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-md);
  color: var(--ds-ink);
  line-height: 18px;
}
.ds-check input, .ds-radio input { position: absolute; opacity: 0; pointer-events: none; }
.ds-check .box,
.ds-radio .box {
  width: 16px;
  height: 16px;
  border: 1px solid var(--ds-rule-2);
  background: var(--ds-surface);
  flex-shrink: 0;
  position: relative;
  margin-top: 1px;
  transition: background var(--ds-dur-fast), border-color var(--ds-dur-fast);
}
.ds-check .box { border-radius: 3px; }
.ds-radio .box { border-radius: 50%; }
.ds-check input:checked + .box {
  background: var(--ds-brand);
  border-color: var(--ds-brand-deep);
}
.ds-check input:checked + .box::after {
  content: "";
  position: absolute;
  left: 4px; top: 1px;
  width: 5px; height: 9px;
  border: solid #15170F;
  border-width: 0 1.6px 1.6px 0;
  transform: rotate(45deg);
}
.ds-radio input:checked + .box { border-color: var(--ds-brand-deep); }
.ds-radio input:checked + .box::after {
  content: "";
  position: absolute;
  inset: 3px;
  background: var(--ds-brand-deep);
  border-radius: 50%;
}
.ds-check input:focus-visible + .box,
.ds-radio input:focus-visible + .box { box-shadow: var(--ds-focus-ring); }

.ds-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-s-2);
  cursor: pointer;
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-md);
  color: var(--ds-ink);
}
.ds-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.ds-toggle .track {
  width: 30px;
  height: 18px;
  border-radius: 999px;
  background: var(--ds-rule-2);
  position: relative;
  transition: background var(--ds-dur-fast);
}
.ds-toggle .track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #FFFFFF;
  border-radius: 50%;
  transition: transform var(--ds-dur) var(--ds-ease-spring);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.ds-toggle input:checked + .track { background: var(--ds-brand-deep); }
.ds-toggle input:checked + .track::after { transform: translateX(12px); }
.ds-toggle input:focus-visible + .track { box-shadow: var(--ds-focus-ring); }

/* ============================================================
   5. SEGMENTED / TABS
   ============================================================ */
.ds-segmented {
  display: inline-flex;
  background: var(--ds-surface-2);
  border: 1px solid var(--ds-rule);
  border-radius: var(--ds-r-md);
  padding: 2px;
  gap: 2px;
}
.ds-segmented > button {
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-sm);
  font-weight: 500;
  padding: 5px 10px;
  border: 0;
  background: transparent;
  color: var(--ds-ink-2);
  cursor: pointer;
  border-radius: var(--ds-r-sm);
  transition: background var(--ds-dur-fast), color var(--ds-dur-fast);
}
.ds-segmented > button:hover { color: var(--ds-ink); }
.ds-segmented > button.is-active {
  background: var(--ds-surface);
  color: var(--ds-ink);
  box-shadow: var(--ds-shadow-1);
}

.ds-tabs {
  display: inline-flex;
  gap: var(--ds-s-1);
  border-bottom: 1px solid var(--ds-rule);
  padding-bottom: 0;
}
.ds-tabs > button,
.ds-tabs > a {
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-md);
  font-weight: 500;
  color: var(--ds-ink-2);
  padding: var(--ds-s-2) var(--ds-s-3);
  border: 0;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--ds-dur-fast), border-color var(--ds-dur-fast);
  text-decoration: none;
}
.ds-tabs > button:hover,
.ds-tabs > a:hover { color: var(--ds-ink); }
.ds-tabs > button.is-active,
.ds-tabs > a.is-active { color: var(--ds-ink); border-bottom-color: var(--ds-brand); }
.ds-tabs > button .count,
.ds-tabs > a .count {
  font-family: var(--ds-font-mono);
  font-size: var(--ds-fs-xs);
  color: var(--ds-ink-2);
  margin-left: var(--ds-s-1);
  background: var(--ds-surface-2);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ============================================================
   6. BADGE / STATUS / CITE
   ============================================================ */
.ds-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-s-1);
  height: var(--ds-h-xs);
  padding: 0 var(--ds-s-2);
  border-radius: var(--ds-r-full);
  font-family: var(--ds-font-sans);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0;
  background: var(--ds-surface-2);
  color: var(--ds-ink-1);
  border: 1px solid var(--ds-rule);
  white-space: nowrap;
}
.ds-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.7; }
.ds-badge--ok { background: var(--ds-ok-tint); color: var(--ds-ok); border-color: rgba(74, 139, 44, 0.2); }
.ds-badge--warn { background: var(--ds-warn-tint); color: var(--ds-warn); border-color: rgba(198, 138, 20, 0.25); }
.ds-badge--crit { background: var(--ds-crit-tint); color: var(--ds-crit); border-color: rgba(192, 57, 43, 0.22); }
.ds-badge--info { background: var(--ds-info-tint); color: var(--ds-info); border-color: rgba(42, 111, 182, 0.22); }
.ds-badge--brand { background: var(--ds-brand-tint); color: var(--ds-brand-deep); border-color: rgba(94, 132, 26, 0.22); }

/* sharp/mono variant for technical UI */
.ds-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-s-1);
  height: 22px;
  padding: 0 7px;
  border-radius: var(--ds-r-xs);
  font-family: var(--ds-font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: transparent;
  color: var(--ds-ink-1);
  border: 1px solid var(--ds-rule-2);
}
.ds-tag--ok { color: var(--ds-ok); border-color: var(--ds-ok); background: var(--ds-ok-tint); }
.ds-tag--warn { color: var(--ds-warn); border-color: var(--ds-warn); background: var(--ds-warn-tint); }
.ds-tag--crit { color: var(--ds-crit); border-color: var(--ds-crit); background: var(--ds-crit-tint); }
.ds-tag--info { color: var(--ds-info); border-color: var(--ds-info); background: var(--ds-info-tint); }
.ds-tag .x { margin-left: var(--ds-s-1); cursor: pointer; opacity: 0.6; }
.ds-tag .x:hover { opacity: 1; }

/* citation chip — signature element */
.ds-cite {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-s-1);
  font-family: var(--ds-font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 3px 7px;
  border-radius: var(--ds-r-xs);
  background: var(--ds-surface-2);
  color: var(--ds-ink-1);
  border: 1px solid var(--ds-rule);
  text-decoration: none;
  transition: background var(--ds-dur-fast);
}
.ds-cite::before {
  content: "§";
  color: var(--ds-brand-deep);
  font-family: var(--ds-font-serif);
  font-size: 13px;
  line-height: 0;
  font-style: italic;
}
.ds-cite:hover { background: var(--ds-brand-tint); color: var(--ds-brand-deep); border-color: rgba(94, 132, 26, 0.3); }

/* ============================================================
   7. RISK SCORE — conic ring + value
   ============================================================ */
.ds-risk {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-s-3);
  padding: var(--ds-s-1) var(--ds-s-3) var(--ds-s-1) var(--ds-s-2);
  border-radius: var(--ds-r-full);
  background: var(--ds-surface);
  border: 1px solid var(--ds-rule-2);
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-md);
  font-weight: 500;
  color: var(--ds-ink);
  white-space: nowrap;
}
.ds-risk .ring {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: conic-gradient(var(--ds-ok) 0 var(--p, 72%), var(--ds-rule) var(--p, 72%) 100%);
  position: relative;
  flex-shrink: 0;
}
.ds-risk .ring::after {
  content: "";
  position: absolute;
  inset: 3px;
  background: var(--ds-surface);
  border-radius: 50%;
}
.ds-risk--warn .ring { background: conic-gradient(var(--ds-warn) 0 var(--p, 52%), var(--ds-rule) var(--p, 52%) 100%); }
.ds-risk--crit .ring { background: conic-gradient(var(--ds-crit) 0 var(--p, 28%), var(--ds-rule) var(--p, 28%) 100%); }
.ds-risk .label { color: var(--ds-ink-2); }
.ds-risk .val {
  font-family: var(--ds-font-mono);
  font-weight: 500;
  color: var(--ds-ink);
}

/* Large risk ring for asset/site detail */
.ds-risk-lg {
  display: inline-flex; align-items: center; gap: var(--ds-s-4);
}
.ds-risk-lg .ring-lg {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: conic-gradient(var(--ds-ok) 0 var(--p, 72%), var(--ds-rule) var(--p, 72%) 100%);
  display: grid; place-items: center;
  position: relative;
}
.ds-risk-lg .ring-lg::after {
  content: "";
  position: absolute;
  inset: 5px;
  background: var(--ds-surface);
  border-radius: 50%;
}
.ds-risk-lg .ring-lg .num {
  position: relative;
  font-family: var(--ds-font-serif);
  font-size: var(--ds-fs-3xl);
  letter-spacing: -0.02em;
  color: var(--ds-ink);
}
.ds-risk-lg--warn .ring-lg { background: conic-gradient(var(--ds-warn) 0 var(--p, 52%), var(--ds-rule) var(--p, 52%) 100%); }
.ds-risk-lg--crit .ring-lg { background: conic-gradient(var(--ds-crit) 0 var(--p, 28%), var(--ds-rule) var(--p, 28%) 100%); }
.ds-risk-lg .meta-label { font-family: var(--ds-font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ds-ink-2); }
.ds-risk-lg .meta-val { font-family: var(--ds-font-sans); font-size: var(--ds-fs-lg); font-weight: 500; }

/* ============================================================
   8. CARD / PANEL
   ============================================================ */
.ds-card {
  background: var(--ds-surface);
  border: 1px solid var(--ds-rule);
  border-radius: var(--ds-r-lg);
  padding: var(--ds-s-5);
  display: flex;
  flex-direction: column;
  gap: var(--ds-s-3);
}
.ds-card--inset { background: var(--ds-bg-2); }
.ds-card--flat { box-shadow: none; }
.ds-card--elev { box-shadow: var(--ds-shadow-2); }
.ds-card-eyebrow {
  font-family: var(--ds-font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ds-ink-2);
  margin: 0;
}
.ds-card-title {
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-lg);
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 0;
  color: var(--ds-ink);
}

/* Panel — used inside dashboards/screens */
.ds-panel {
  background: var(--ds-surface);
  border: 1px solid var(--ds-rule);
  border-radius: var(--ds-r-lg);
  overflow: hidden;
}
.ds-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--ds-s-3) var(--ds-s-4);
  border-bottom: 1px solid var(--ds-rule);
}
.ds-panel-head h3 {
  margin: 0;
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-base);
  font-weight: 600;
  color: var(--ds-ink);
}
.ds-panel-body { padding: var(--ds-s-4); }
.ds-panel-body--flush { padding: 0; }

/* KPI tile */
.ds-kpi {
  background: var(--ds-surface);
  border: 1px solid var(--ds-rule);
  border-radius: var(--ds-r-lg);
  padding: var(--ds-s-4);
  display: flex; flex-direction: column; gap: var(--ds-s-2);
}
.ds-kpi-lbl {
  font-family: var(--ds-font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ds-ink-2);
}
.ds-kpi-val {
  font-family: var(--ds-font-serif);
  font-size: var(--ds-fs-4xl);
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--ds-ink);
}
.ds-kpi-val .unit { font-size: var(--ds-fs-xl); color: var(--ds-ink-2); }
.ds-kpi-delta {
  font-family: var(--ds-font-mono);
  font-size: var(--ds-fs-xs);
  color: var(--ds-ok);
}
.ds-kpi-delta--down { color: var(--ds-crit); }
.ds-kpi-delta--flat { color: var(--ds-ink-2); }

/* ============================================================
   9. TABLE
   ============================================================ */
.ds-table-wrap {
  border: 1px solid var(--ds-rule);
  border-radius: var(--ds-r-lg);
  overflow: hidden;
  background: var(--ds-surface);
}
.ds-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-md);
}
.ds-table thead th {
  font-family: var(--ds-font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ds-ink-2);
  text-align: left;
  padding: 10px var(--ds-s-4);
  border-bottom: 1px solid var(--ds-rule);
  background: var(--ds-bg);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.ds-table thead th.sortable { cursor: pointer; user-select: none; }
.ds-table thead th.sortable::after {
  content: " \2195";
  color: var(--ds-ink-3);
  font-size: 11px;
}
.ds-table thead th.sort-asc::after { content: " \2191"; color: var(--ds-ink); }
.ds-table thead th.sort-desc::after { content: " \2193"; color: var(--ds-ink); }
.ds-table tbody td {
  padding: var(--ds-s-3) var(--ds-s-4);
  border-bottom: 1px solid var(--ds-rule);
  vertical-align: middle;
  color: var(--ds-ink);
}
.ds-table tbody tr:hover td { background: var(--ds-surface-2); }
.ds-table tbody tr:last-child td { border-bottom: 0; }
.ds-table tbody tr.is-selected td { background: var(--ds-brand-tint); }
.ds-table .col-num {
  font-family: var(--ds-font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.ds-table .col-title { font-weight: 500; color: var(--ds-ink); }
.ds-table .col-sub { display: block; font-size: 11.5px; color: var(--ds-ink-2); margin-top: 2px; }

/* density variants */
.ds-table--dense tbody td { padding: var(--ds-s-2) var(--ds-s-3); font-size: var(--ds-fs-sm); }
.ds-table--dense thead th { padding: 6px var(--ds-s-3); }
.ds-table--cozy tbody td { padding: var(--ds-s-4); }

/* ============================================================
   10. DIALOG / MODAL / SHEET
   ============================================================ */
.ds-modal-scrim {
  position: fixed; inset: 0;
  background: rgba(15, 18, 12, 0.45);
  backdrop-filter: blur(2px);
  z-index: var(--ds-z-overlay);
  display: grid;
  place-items: center;
  padding: var(--ds-s-6);
  animation: ds-fade-in var(--ds-dur) var(--ds-ease);
}
.ds-modal {
  background: var(--ds-surface);
  border: 1px solid var(--ds-rule);
  border-radius: var(--ds-r-xl);
  box-shadow: var(--ds-shadow-3);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: var(--ds-z-modal);
  animation: ds-rise var(--ds-dur-slow) var(--ds-ease-out);
}
.ds-modal-head { padding: var(--ds-s-5) var(--ds-s-5) 0; display:flex; align-items: flex-start; justify-content: space-between; gap: var(--ds-s-3); }
.ds-modal-title { font-family: var(--ds-font-sans); font-size: var(--ds-fs-xl); font-weight: 600; letter-spacing: -0.005em; margin: 0; }
.ds-modal-body { padding: var(--ds-s-4) var(--ds-s-5); overflow: auto; }
.ds-modal-foot { padding: var(--ds-s-4) var(--ds-s-5); border-top: 1px solid var(--ds-rule); display: flex; justify-content: flex-end; gap: var(--ds-s-2); background: var(--ds-bg); }

/* Sheet (drawer from right) */
.ds-sheet {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(420px, 100%);
  background: var(--ds-surface);
  border-left: 1px solid var(--ds-rule);
  box-shadow: var(--ds-shadow-3);
  display: flex; flex-direction: column;
  z-index: var(--ds-z-modal);
  animation: ds-slide-in-right var(--ds-dur-slow) var(--ds-ease-out);
}

@keyframes ds-fade-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes ds-rise { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: translateY(0) } }
@keyframes ds-slide-in-right { from { transform: translateX(100%) } to { transform: translateX(0) } }

/* ============================================================
   11. POPOVER / TOOLTIP / MENU
   ============================================================ */
.ds-popover {
  background: var(--ds-surface);
  border-radius: var(--ds-r-md);
  box-shadow: var(--ds-shadow-popover);
  padding: var(--ds-s-1);
  display: inline-block;
  min-width: 200px;
}
.ds-popover-item {
  display: flex; align-items: center; gap: var(--ds-s-2);
  padding: 7px var(--ds-s-3);
  border-radius: var(--ds-r-sm);
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-md);
  color: var(--ds-ink);
  cursor: pointer;
  user-select: none;
}
.ds-popover-item:hover { background: var(--ds-surface-2); }
.ds-popover-item .ds-icon { color: var(--ds-ink-2); width: 14px; height: 14px; flex-shrink: 0; }
.ds-popover-item .shortcut { margin-left: auto; font-family: var(--ds-font-mono); font-size: 10.5px; color: var(--ds-ink-3); }
.ds-popover-item--danger { color: var(--ds-crit); }
.ds-popover-item--danger:hover { background: var(--ds-crit-tint); }
.ds-popover-sep { height: 1px; background: var(--ds-rule); margin: var(--ds-s-1) 0; }
.ds-popover-section {
  font-family: var(--ds-font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ds-ink-2);
  padding: 6px var(--ds-s-3) 4px;
}

.ds-tooltip {
  display: inline-block;
  background: var(--ds-ink);
  color: var(--ds-ink-inv);
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-sm);
  padding: 5px 9px;
  border-radius: var(--ds-r-sm);
  box-shadow: var(--ds-shadow-2);
}
[data-theme="dark"] .ds-tooltip { background: var(--ds-surface-3); color: var(--ds-ink); }

/* ============================================================
   12. BANNER / TOAST / ALERT
   ============================================================ */
.ds-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--ds-s-3);
  padding: var(--ds-s-3) var(--ds-s-4);
  border-radius: var(--ds-r-md);
  border: 1px solid var(--ds-rule);
  background: var(--ds-surface);
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-md);
  color: var(--ds-ink);
}
.ds-banner .ds-icon { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.ds-banner .body { flex: 1; }
.ds-banner .title { font-weight: 500; margin: 0 0 2px; }
.ds-banner .desc { color: var(--ds-ink-2); font-size: var(--ds-fs-sm); line-height: 1.5; }
.ds-banner--ok { background: var(--ds-ok-tint); border-color: rgba(74,139,44,0.25); color: var(--ds-ok); }
.ds-banner--warn { background: var(--ds-warn-tint); border-color: rgba(198,138,20,0.3); color: var(--ds-warn); }
.ds-banner--crit { background: var(--ds-crit-tint); border-color: rgba(192,57,43,0.3); color: var(--ds-crit); }
.ds-banner--info { background: var(--ds-info-tint); border-color: rgba(42,111,182,0.3); color: var(--ds-info); }
.ds-banner--ok .desc,
.ds-banner--warn .desc,
.ds-banner--crit .desc,
.ds-banner--info .desc { color: inherit; opacity: 0.8; }

.ds-toast {
  background: var(--ds-ink);
  color: var(--ds-ink-inv);
  padding: var(--ds-s-3) var(--ds-s-4);
  border-radius: var(--ds-r-md);
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-md);
  box-shadow: var(--ds-shadow-3);
  display: inline-flex;
  align-items: center;
  gap: var(--ds-s-3);
  min-width: 280px;
}
[data-theme="dark"] .ds-toast { background: var(--ds-surface-3); color: var(--ds-ink); border: 1px solid var(--ds-rule-2); }

/* ============================================================
   13. BREADCRUMB / PAGINATION
   ============================================================ */
.ds-crumbs {
  display: flex; align-items: center; gap: var(--ds-s-1);
  font-family: var(--ds-font-mono);
  font-size: var(--ds-fs-xs);
  letter-spacing: 0.04em;
  color: var(--ds-ink-2);
}
.ds-crumbs > a, .ds-crumbs > span {
  color: inherit;
  text-decoration: none;
  padding: 2px 4px;
  border-radius: var(--ds-r-xs);
}
.ds-crumbs > a:hover { color: var(--ds-ink); background: var(--ds-surface-2); }
.ds-crumbs .sep { color: var(--ds-ink-3); padding: 0 2px; }
.ds-crumbs > [aria-current="page"] { color: var(--ds-ink); }

.ds-pager {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-s-1);
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-md);
}
.ds-pager .ds-btn--icon { color: var(--ds-ink-1); }
.ds-pager .num {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  font-family: var(--ds-font-mono);
  font-size: var(--ds-fs-sm);
  color: var(--ds-ink-1);
  border-radius: var(--ds-r-sm);
  cursor: pointer;
}
.ds-pager .num:hover { background: var(--ds-surface-2); }
.ds-pager .num.is-active { background: var(--ds-ink); color: var(--ds-ink-inv); }
.ds-pager .info { font-family: var(--ds-font-mono); font-size: var(--ds-fs-sm); color: var(--ds-ink-2); margin: 0 var(--ds-s-2); }

/* ============================================================
   14. PROGRESS / SKELETON / SPINNER
   ============================================================ */
.ds-progress {
  height: 6px;
  background: var(--ds-surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.ds-progress > .fill {
  height: 100%;
  background: var(--ds-brand);
  border-radius: 3px;
  transition: width var(--ds-dur-slow) var(--ds-ease);
}
.ds-progress--warn .fill { background: var(--ds-warn); }
.ds-progress--crit .fill { background: var(--ds-crit); }
.ds-progress--indeterminate .fill {
  width: 30% !important;
  animation: ds-prog-indet 1.4s var(--ds-ease) infinite;
}
@keyframes ds-prog-indet { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }

.ds-skeleton {
  background: linear-gradient(90deg, var(--ds-surface-2) 0%, var(--ds-surface-3) 50%, var(--ds-surface-2) 100%);
  background-size: 200% 100%;
  border-radius: var(--ds-r-sm);
  animation: ds-shimmer 1.6s linear infinite;
}
@keyframes ds-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.ds-spinner {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--ds-rule-2);
  border-top-color: var(--ds-brand-deep);
  animation: ds-spin 0.7s linear infinite;
  display: inline-block;
}
.ds-spinner--lg { width: 22px; height: 22px; border-width: 2.5px; }
@keyframes ds-spin { to { transform: rotate(360deg); } }

/* pulse for live data */
@keyframes ds-pulse-out {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.6); opacity: 0; }
}
@keyframes ds-pulse-in {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.ds-pulse {
  position: relative;
  display: inline-block;
  width: 8px; height: 8px;
  flex-shrink: 0;
}
.ds-pulse::before, .ds-pulse::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background: var(--ds-ok);
}
.ds-pulse::before { animation: ds-pulse-in 1.6s ease-in-out infinite; }
.ds-pulse::after { animation: ds-pulse-out 1.6s ease-out infinite; }
.ds-pulse--warn::before, .ds-pulse--warn::after { background: var(--ds-warn); }
.ds-pulse--crit::before, .ds-pulse--crit::after { background: var(--ds-crit); }
.ds-pulse--mute::before, .ds-pulse--mute::after { background: var(--ds-ink-3); animation: none; }
.ds-pulse--sm { width: 6px; height: 6px; }

/* ============================================================
   15. AVATAR / IDENTITY
   ============================================================ */
.ds-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  background: var(--ds-surface-3);
  color: var(--ds-ink-1);
  border-radius: 50%;
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-sm);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border: 1px solid var(--ds-rule);
}
.ds-avatar--sm { width: 22px; height: 22px; font-size: 10px; }
.ds-avatar--lg { width: 40px; height: 40px; font-size: var(--ds-fs-base); }
.ds-avatar--brand { background: var(--ds-brand-tint); color: var(--ds-brand-deep); border-color: rgba(94,132,26,0.25); }
.ds-avatar-stack { display: inline-flex; }
.ds-avatar-stack .ds-avatar { margin-left: -8px; box-shadow: 0 0 0 2px var(--ds-surface); }
.ds-avatar-stack .ds-avatar:first-child { margin-left: 0; }

/* ============================================================
   16. EMPTY STATE
   ============================================================ */
.ds-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: var(--ds-s-10) var(--ds-s-6);
  gap: var(--ds-s-3);
  color: var(--ds-ink-2);
}
.ds-empty-glyph {
  width: 48px; height: 48px;
  border: 1px dashed var(--ds-rule-2);
  border-radius: var(--ds-r-md);
  display: grid; place-items: center;
  color: var(--ds-ink-3);
}
.ds-empty-title {
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-lg);
  font-weight: 600;
  color: var(--ds-ink);
  margin: 0;
}
.ds-empty-desc {
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-md);
  color: var(--ds-ink-2);
  margin: 0;
  max-width: 36ch;
  line-height: 1.5;
}

/* ============================================================
   17. KEYBOARD CHIP / CODE INLINE
   ============================================================ */
.ds-kbd {
  display: inline-block;
  font-family: var(--ds-font-mono);
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: var(--ds-r-xs);
  background: var(--ds-surface-3);
  border: 1px solid var(--ds-rule);
  color: var(--ds-ink-1);
}
.ds-code {
  font-family: var(--ds-font-mono);
  font-size: 12px;
  padding: 2px 5px;
  background: var(--ds-surface-2);
  border: 1px solid var(--ds-rule);
  border-radius: var(--ds-r-xs);
  color: var(--ds-ink-1);
}

/* ============================================================
   18. ICON STROKE BASE
   ============================================================ */
.ds-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
  flex-shrink: 0;
}
.ds-icon--sm { width: 12px; height: 12px; stroke-width: 1.5; }
.ds-icon--lg { width: 20px; height: 20px; stroke-width: 1.5; }
.ds-icon--xl { width: 24px; height: 24px; stroke-width: 1.5; }

/* ============================================================
   19. APP SHELL / LAYOUT
   ============================================================ */
.ds-shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 640px;
  background: var(--ds-bg);
  color: var(--ds-ink);
  font-family: var(--ds-font-sans);
}
.ds-shell-side {
  background: var(--ds-surface);
  border-right: 1px solid var(--ds-rule);
  padding: var(--ds-s-4) var(--ds-s-3);
  display: flex; flex-direction: column;
  gap: var(--ds-s-1);
}
.ds-shell-brand {
  display: flex; align-items: center; gap: var(--ds-s-2);
  padding: var(--ds-s-1) var(--ds-s-2) var(--ds-s-4);
  font-family: var(--ds-font-mono);
  font-size: var(--ds-fs-base);
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ds-ink);
}
.ds-shell-brand img { height: 18px; width: auto; }
.ds-shell-brand .sep { color: var(--ds-ink-3); }
.ds-shell-nav-group {
  margin: var(--ds-s-4) var(--ds-s-2) var(--ds-s-1);
  font-family: var(--ds-font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ds-ink-3);
}
.ds-shell-nav-link {
  display: flex; align-items: center; gap: var(--ds-s-2);
  padding: 6px var(--ds-s-2);
  font-size: var(--ds-fs-md);
  color: var(--ds-ink-1);
  text-decoration: none;
  border-radius: var(--ds-r-sm);
  font-weight: 500;
  transition: background var(--ds-dur-fast), color var(--ds-dur-fast);
}
.ds-shell-nav-link:hover { background: var(--ds-surface-2); color: var(--ds-ink); }
.ds-shell-nav-link.is-active { background: var(--ds-brand-tint); color: var(--ds-brand-deep); }
[data-theme="dark"] .ds-shell-nav-link.is-active { color: var(--ds-brand-bright); }
.ds-shell-nav-link .count {
  margin-left: auto;
  font-family: var(--ds-font-mono);
  font-size: var(--ds-fs-xs);
  color: var(--ds-ink-3);
  padding: 0 4px;
}
.ds-shell-nav-link.is-active .count { color: var(--ds-brand-deep); }
.ds-shell-main {
  padding: var(--ds-s-6) var(--ds-s-7);
  overflow: auto;
}

/* Page header */
.ds-page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--ds-s-5);
  margin-bottom: var(--ds-s-6);
}
.ds-page-eyebrow {
  font-family: var(--ds-font-mono);
  font-size: var(--ds-fs-xs);
  letter-spacing: 0.06em;
  color: var(--ds-ink-2);
  margin-bottom: var(--ds-s-2);
}
.ds-page-title {
  font-family: var(--ds-font-sans);
  font-size: var(--ds-fs-4xl);
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ds-ink);
  margin: 0;
}
.ds-page-title--serif {
  font-family: var(--ds-font-serif);
  font-weight: 400;
  letter-spacing: -0.018em;
}
.ds-page-title em { font-style: italic; color: var(--ds-brand-deep); }
.ds-page-actions { display: flex; gap: var(--ds-s-2); align-items: center; flex-shrink: 0; }

/* Filter bar */
.ds-filter-bar {
  display: flex;
  align-items: center;
  gap: var(--ds-s-2);
  padding: var(--ds-s-3) 0 var(--ds-s-4);
  flex-wrap: wrap;
}
.ds-filter-bar .spacer { flex: 1; }

/* ============================================================
   20. SLD primitive (signature)
   ============================================================ */
.ds-sld {
  background: var(--ds-surface);
  border: 1px solid var(--ds-rule);
  border-radius: var(--ds-r-lg);
  padding: var(--ds-s-5);
  background-image:
    linear-gradient(var(--ds-rule) 1px, transparent 1px),
    linear-gradient(90deg, var(--ds-rule) 1px, transparent 1px);
  background-size: 16px 16px;
  background-position: -1px -1px;
  background-color: var(--ds-surface);
}
.ds-sld svg { display: block; width: 100%; height: auto; }
.ds-sld text { font-family: var(--ds-font-mono); font-size: 10px; fill: var(--ds-ink-1); letter-spacing: 0.04em; }
.ds-sld .bus { stroke: var(--ds-ink); stroke-width: 2.5; }
.ds-sld .line { stroke: var(--ds-ink-1); stroke-width: 1.5; fill: none; }
.ds-sld .line.live { stroke: var(--ds-brand-deep); }
.ds-sld .fill-ok { fill: var(--ds-ok-tint); stroke: var(--ds-ok); stroke-width: 1.5; }
.ds-sld .fill-paper { fill: var(--ds-surface); stroke: var(--ds-ink); stroke-width: 1.5; }
.ds-sld .fill-warn { fill: var(--ds-warn-tint); stroke: var(--ds-warn); stroke-width: 1.5; }
.ds-sld .fill-crit { fill: var(--ds-crit-tint); stroke: var(--ds-crit); stroke-width: 1.5; }
