/* ============================================================
   Agentegrity — Design System
   Clean enterprise SaaS · light · near-monochrome graphite ink
   Color reserved strictly for status semantics (ok/warn/crit)
   IBM Plex Sans (UI) + IBM Plex Mono (data/code/hashes)
   ============================================================ */

:root {
  /* surfaces */
  --bg:          oklch(0.984 0.003 255);
  --surface:     #ffffff;
  --surface-2:   oklch(0.976 0.004 255);
  --surface-3:   oklch(0.965 0.005 255);
  --border:      oklch(0.918 0.005 258);
  --border-2:    oklch(0.872 0.006 258);

  /* ink */
  --ink:         oklch(0.255 0.014 264);
  --ink-2:       oklch(0.468 0.012 262);
  --ink-3:       oklch(0.620 0.010 260);
  --ink-4:       oklch(0.728 0.008 260);
  --on-dark:     oklch(0.975 0.003 255);

  /* graphite accent (the one "color" of the UI chrome) */
  --accent:      oklch(0.278 0.022 266);
  --accent-2:    oklch(0.345 0.022 266);

  /* status — shared chroma/lightness family, hue varies */
  --ok:          oklch(0.605 0.130 156);
  --ok-ink:      oklch(0.430 0.110 156);
  --ok-bg:       oklch(0.955 0.040 156);
  --ok-line:     oklch(0.840 0.075 156);

  --warn:        oklch(0.715 0.140 76);
  --warn-ink:    oklch(0.520 0.120 66);
  --warn-bg:     oklch(0.960 0.055 82);
  --warn-line:   oklch(0.860 0.090 80);

  --crit:        oklch(0.585 0.180 26);
  --crit-ink:    oklch(0.510 0.175 26);
  --crit-bg:     oklch(0.957 0.040 28);
  --crit-line:   oklch(0.860 0.080 28);

  --info:        oklch(0.585 0.120 252);
  --info-ink:    oklch(0.480 0.130 256);
  --info-bg:     oklch(0.957 0.035 252);
  --info-line:   oklch(0.850 0.060 252);

  /* radii */
  --r-xs: 5px;
  --r-sm: 7px;
  --r:    10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* shadow */
  --sh-sm: 0 1px 2px oklch(0.5 0.02 264 / 0.06), 0 1px 1px oklch(0.5 0.02 264 / 0.04);
  --sh:    0 2px 6px oklch(0.5 0.02 264 / 0.07), 0 1px 2px oklch(0.5 0.02 264 / 0.05);
  --sh-lg: 0 12px 32px oklch(0.4 0.02 264 / 0.12), 0 4px 10px oklch(0.4 0.02 264 / 0.07);
  --sh-pop:0 18px 48px oklch(0.35 0.03 264 / 0.20), 0 6px 16px oklch(0.35 0.03 264 / 0.10);

  --font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --sidebar-w: 248px;
  --topbar-h: 60px;

  /* density (overridden by tweaks) */
  --density: 1;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 14px;
  line-height: 1.45;
}
#root { height: 100%; }

::selection { background: oklch(0.27 0.02 266 / 0.16); }

/* scrollbars */
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-thumb { background: oklch(0.82 0.006 260); border-radius: 9px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: oklch(0.74 0.008 260); background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- type helpers ---------- */
.mono { font-family: var(--font-mono); font-feature-settings: "zero" 1; }
.t-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--ink-3);
}
h1,h2,h3,h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
a { color: inherit; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100%; }

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 0;
}
.sb-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 17px 20px 16px;
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
}
.logo-mark {
  width: 26px; height: 26px; flex: none;
  display: flex; flex-direction: column; justify-content: center; gap: 3px;
}
.logo-mark span { display: block; height: 3.2px; border-radius: 2px; background: var(--accent); }
.logo-mark span:nth-child(1) { width: 100%; opacity: 0.32; }
.logo-mark span:nth-child(2) { width: 76%; opacity: 0.55; }
.logo-mark span:nth-child(3) { width: 52%; opacity: 1; }
.wordmark { font-size: 15.5px; font-weight: 600; letter-spacing: -0.02em; color: var(--ink); }
.wordmark b { font-weight: 600; }
.wordmark i { font-style: normal; font-weight: 500; color: var(--ink-3); }

.sb-scroll { flex: 1; overflow-y: auto; padding: 12px 12px 8px; min-height: 0; }
.sb-group { margin-bottom: 16px; }
.sb-group-label {
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-4);
  padding: 4px 10px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 13.5px; font-weight: 500;
  cursor: pointer; user-select: none; position: relative;
  transition: background .13s, color .13s;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item svg { width: 17px; height: 17px; flex: none; color: var(--ink-3); transition: color .13s; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item:hover svg { color: var(--ink-2); }
.nav-item.active { background: var(--accent); color: var(--on-dark); }
.nav-item.active svg { color: var(--on-dark); }
.nav-item .nav-count {
  margin-left: auto; font-family: var(--font-mono); font-size: 11px;
  color: var(--ink-3); background: var(--surface-2);
  padding: 1px 7px; border-radius: 20px; min-width: 22px; text-align: center;
}
.nav-item.active .nav-count { background: oklch(1 0 0 / 0.16); color: var(--on-dark); }
.nav-item .nav-dot {
  margin-left: auto; width: 7px; height: 7px; border-radius: 50%;
}

.sb-foot { border-top: 1px solid var(--border); padding: 10px 12px; }
.org-card {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--r-sm); cursor: pointer;
}
.org-card:hover { background: var(--surface-2); }
.avatar {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  display: grid; place-items: center; font-weight: 600; font-size: 12px;
  background: var(--accent); color: var(--on-dark);
}
.org-meta { min-width: 0; line-height: 1.25; }
.org-meta .nm { font-size: 12.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-meta .sub { font-size: 11px; color: var(--ink-3); }

/* ---------- main column ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: var(--topbar-h); flex: none;
  border-bottom: 1px solid var(--border);
  background: oklch(0.984 0.003 255 / 0.82);
  backdrop-filter: blur(10px);
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px; position: sticky; top: 0; z-index: 20;
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13.5px; min-width: 0; }
.crumbs .c-dim { color: var(--ink-3); }
.crumbs .c-sep { color: var(--ink-4); }
.crumbs .c-now { font-weight: 600; color: var(--ink); }
.topbar .spacer { flex: 1; }

.searchbar {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 7px 11px; width: 268px;
  color: var(--ink-3); cursor: text;
}
.searchbar svg { width: 15px; height: 15px; }
.searchbar input { border: none; background: none; outline: none; font: inherit; font-size: 13px; color: var(--ink); width: 100%; }
.searchbar .kbd { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--ink-4); border: 1px solid var(--border-2); border-radius: 5px; padding: 0 5px; }

.env-pill {
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); border-radius: 20px;
  padding: 5px 12px 5px 10px; font-size: 12.5px; font-weight: 500; color: var(--ink-2);
  cursor: pointer; background: var(--surface);
}
.env-pill:hover { border-color: var(--border-2); }
.env-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }

.live-pill {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: 0.04em;
  color: var(--ink-2); text-transform: uppercase;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 var(--ok-line);} 50% { box-shadow: 0 0 0 4px transparent; } }

.icon-btn {
  width: 34px; height: 34px; border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; }

.content { flex: 1; overflow-y: auto; min-height: 0; }
.page { padding: calc(26px * var(--density)) 30px 64px; max-width: 1320px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; gap: 18px; margin-bottom: 22px; }
.page-head .ph-titles { min-width: 0; }
.page-title { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.page-sub { color: var(--ink-3); font-size: 13.5px; margin-top: 3px; }
.page-head .ph-actions { margin-left: auto; display: flex; gap: 9px; align-items: center; }

/* ============================================================
   PRIMITIVES
   ============================================================ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-sm);
}
.card-pad { padding: calc(18px * var(--density)) 20px; }
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 14px; }
.card-head .ch-sub { font-size: 12px; color: var(--ink-3); }
.card-head .spacer { flex: 1; }

.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1080px) { .cols-3, .cols-4 { grid-template-columns: repeat(2, 1fr); } }

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  border-radius: var(--r-sm); padding: 8px 14px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); transition: background .12s, border-color .12s, transform .04s;
  white-space: nowrap; user-select: none;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(0.5px); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-dark); }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 500; padding: 2.5px 9px; border-radius: 20px;
  border: 1px solid var(--border); color: var(--ink-2); background: var(--surface);
  white-space: nowrap;
}
.badge .bdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok   { color: var(--ok-ink);   background: var(--ok-bg);   border-color: var(--ok-line); }
.badge.warn { color: var(--warn-ink); background: var(--warn-bg); border-color: var(--warn-line); }
.badge.crit { color: var(--crit-ink); background: var(--crit-bg); border-color: var(--crit-line); }
.badge.info { color: var(--info-ink); background: var(--info-bg); border-color: var(--info-line); }
.badge.mono { font-family: var(--font-mono); font-size: 11px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  padding: 3px 9px; border-radius: var(--r-xs); background: var(--surface-2);
  border: 1px solid var(--border); color: var(--ink-2); font-family: var(--font-mono);
}

/* stat */
.stat-label { font-size: 12px; color: var(--ink-3); font-weight: 500; display: flex; align-items: center; gap: 7px; }
.stat-value { font-family: var(--font-mono); font-weight: 600; letter-spacing: -0.02em; color: var(--ink); }
.stat-big { font-size: 30px; line-height: 1; }
.stat-delta { font-size: 12px; font-weight: 500; font-family: var(--font-mono); display: inline-flex; align-items: center; gap: 3px; }
.stat-delta.up { color: var(--ok-ink); }
.stat-delta.down { color: var(--crit-ink); }
.stat-delta.flat { color: var(--ink-3); }

/* table */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-4);
  padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { cursor: pointer; transition: background .1s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* progress / score bar */
.sbar { height: 6px; border-radius: 20px; background: var(--surface-3); overflow: hidden; }
.sbar > i { display: block; height: 100%; border-radius: 20px; }

/* divider */
.hr { height: 1px; background: var(--border); border: none; margin: 0; }

/* kbd */
kbd { font-family: var(--font-mono); font-size: 11px; background: var(--surface-2); border: 1px solid var(--border-2); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; color: var(--ink-2); }

/* code block */
.code {
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.65;
  background: oklch(0.22 0.012 264); color: oklch(0.92 0.01 255);
  border-radius: var(--r); padding: 16px 18px; overflow-x: auto; position: relative;
}
.code .cmt { color: oklch(0.62 0.01 255); }
.code .kw  { color: oklch(0.78 0.10 300); }
.code .fn  { color: oklch(0.80 0.11 220); }
.code .str { color: oklch(0.80 0.11 145); }
.code .num2 { color: oklch(0.82 0.10 70); }
.code .copy {
  position: absolute; top: 10px; right: 10px;
  font-family: var(--font-sans); font-size: 11.5px; color: oklch(0.78 0.01 255);
  background: oklch(1 0 0 / 0.08); border: 1px solid oklch(1 0 0 / 0.12);
  border-radius: 6px; padding: 4px 9px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
}
.code .copy:hover { background: oklch(1 0 0 / 0.14); }
.code .copy svg { width: 13px; height: 13px; }

/* empty / skeleton shimmer */
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.shimmer {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
}

/* ---------- heatmap ---------- */
.heat { display: grid; gap: 3px; }
.heat-cell {
  height: 28px; border-radius: var(--r-xs); border: 1px solid transparent;
  display: grid; place-items: center; cursor: pointer; position: relative;
  font-family: var(--font-mono); font-size: 10px; color: transparent; transition: transform .08s;
}
.heat-cell:hover { transform: scale(1.12); z-index: 4; box-shadow: var(--sh); color: var(--ink); }

/* ---------- gauge ---------- */
.gauge-wrap { position: relative; display: inline-grid; place-items: center; }
.gauge-label { position: absolute; text-align: center; }
.gauge-num { font-family: var(--font-mono); font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.gauge-cap { font-size: 11px; color: var(--ink-3); margin-top: 3px; }

/* ---------- timeline / chain ---------- */
.chain { position: relative; padding-left: 30px; }
.chain::before { content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.chain-node { position: relative; padding: 0 0 18px; }
.chain-node::before {
  content: ""; position: absolute; left: -25px; top: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--ok); box-shadow: 0 0 0 3px var(--ok-bg);
}
.chain-node.crit::before { border-color: var(--crit); box-shadow: 0 0 0 3px var(--crit-bg); }
.chain-node.warn::before { border-color: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }

/* feed row */
.feed-row {
  display: flex; gap: 13px; padding: 13px 4px; border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.feed-row:last-child { border-bottom: none; }
.feed-ic {
  width: 30px; height: 30px; border-radius: 8px; flex: none; display: grid; place-items: center;
}
.feed-ic svg { width: 15px; height: 15px; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 9px 14px; font-size: 13px; font-weight: 500; color: var(--ink-3); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; border-top: none; border-left: none; border-right: none; font-family: inherit;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }

/* segmented */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 2px; }
.seg button {
  border: none; background: none; font: inherit; font-size: 12.5px; font-weight: 500; color: var(--ink-3);
  padding: 5px 12px; border-radius: 5px; cursor: pointer;
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--sh-sm); }

/* fade-in — transform-only so a paused animation timeline never hides content */
@keyframes fadeUp { from { transform: translateY(7px); } to { transform: none; } }
.fade-up { animation: fadeUp .32s cubic-bezier(.22,1,.36,1) both; }
@keyframes fadeIn { from { transform: translateY(3px); } to { transform: none; } }
.fade-in { animation: fadeIn .25s ease both; }

/* tooltip-ish floater */
.float {
  position: absolute; z-index: 50; background: oklch(0.22 0.012 264); color: var(--on-dark);
  font-size: 11.5px; padding: 7px 10px; border-radius: 7px; box-shadow: var(--sh-lg);
  pointer-events: none; white-space: nowrap;
}
.float .fl-k { color: oklch(0.7 0.01 255); }

/* utility */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; }
.gap-12 { gap: 12px; } .gap-14 { gap: 14px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; }
.mt-4{margin-top:4px}.mt-8{margin-top:8px}.mt-12{margin-top:12px}.mt-16{margin-top:16px}.mt-20{margin-top:20px}.mt-24{margin-top:24px}
.muted { color: var(--ink-3); }
.muted-2 { color: var(--ink-4); }
.center { display: grid; place-items: center; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.nowrap { white-space: nowrap; }
.fill { flex: 1; }
.clickable { cursor: pointer; }
.txt-ok { color: var(--ok-ink); } .txt-warn { color: var(--warn-ink); } .txt-crit { color: var(--crit-ink); } .txt-info { color: var(--info-ink); }
