/* ─────────────────────────────────────────────────────────────────────────
   AI Ops — design tokens + base styles
   Bloomberg-terminal-leaning: deep neutrals, functional accents, monospace
   for data, sans for body.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  /* surfaces — cool slate */
  --bg:           oklch(0.165 0.006 250);
  --bg-1:         oklch(0.195 0.007 250);
  --bg-2:         oklch(0.225 0.008 250);
  --bg-3:         oklch(0.265 0.009 250);
  --line:         oklch(0.300 0.010 250);
  --line-soft:    oklch(0.245 0.008 250);

  /* text */
  --fg:           oklch(0.965 0.004 250);
  --fg-1:         oklch(0.820 0.007 250);
  --fg-2:         oklch(0.640 0.009 250);
  --fg-3:         oklch(0.480 0.010 250);
  --fg-4:         oklch(0.360 0.008 250);

  /* functional accents — all share ~0.76 L / ~0.16 C, only hue varies */
  --ok:           oklch(0.78 0.15 152);   /* optimal / green */
  --ok-dim:       oklch(0.78 0.15 152 / 0.16);
  --warn:         oklch(0.82 0.14 78);    /* improve / amber */
  --warn-dim:     oklch(0.82 0.14 78 / 0.16);
  --bad:          oklch(0.70 0.18 25);    /* replace / red */
  --bad-dim:      oklch(0.70 0.18 25 / 0.16);
  --info:         oklch(0.76 0.13 240);   /* neutral signal / blue */
  --info-dim:     oklch(0.76 0.13 240 / 0.16);
  --accent:       oklch(0.78 0.14 188);   /* primary action / teal */
  --accent-dim:   oklch(0.78 0.14 188 / 0.18);

  /* type */
  --sans:  "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono:  "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* rhythm */
  --r-sm: 4px;
  --r:    6px;
  --r-lg: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button { font-family: inherit; color: inherit; }

/* utility primitives ─────────────────────────────────────────────────────── */

.mono { font-family: var(--mono); font-feature-settings: "tnum" 1, "zero" 1; }
.tnum { font-variant-numeric: tabular-nums; }
.eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-3);
  font-weight: 500;
}
.rule { height: 1px; background: var(--line-soft); }

/* status dot — used everywhere */
.dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--fg-3);
  flex: none;
}
.dot.ok   { background: var(--ok);   box-shadow: 0 0 0 3px var(--ok-dim); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-dim); }
.dot.bad  { background: var(--bad);  box-shadow: 0 0 0 3px var(--bad-dim); }
.dot.info { background: var(--info); box-shadow: 0 0 0 3px var(--info-dim); }

/* impact tag */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  height: 20px; padding: 0 7px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--r-sm);
  background: var(--bg-2);
  color: var(--fg-1);
  border: 1px solid var(--line-soft);
  white-space: nowrap;
}
.tag.ok   { color: var(--ok);   background: var(--ok-dim);   border-color: transparent; }
.tag.warn { color: var(--warn); background: var(--warn-dim); border-color: transparent; }
.tag.bad  { color: var(--bad);  background: var(--bad-dim);  border-color: transparent; }
.tag.info { color: var(--info); background: var(--info-dim); border-color: transparent; }
.tag.accent { color: var(--accent); background: var(--accent-dim); border-color: transparent; }

/* button */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  height: 28px;
  padding: 0 11px;
  border-radius: var(--r);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  letter-spacing: 0.005em;
  transition: background 0.08s ease, border-color 0.08s ease, transform 0.08s ease;
}
.btn:hover  { background: var(--bg-3); border-color: var(--line); }
.btn:active { transform: translateY(0.5px); }
.btn.primary {
  background: var(--accent);
  color: oklch(0.18 0.02 188);
  border-color: transparent;
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--fg-2); }
.btn.ghost:hover { background: var(--bg-2); color: var(--fg); }
.btn.sm { height: 24px; padding: 0 8px; font-size: 11.5px; }
.btn.icon { width: 28px; padding: 0; justify-content: center; }

/* card */
.card {
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
}
.card.hov { cursor: pointer; transition: border-color 0.1s ease, background 0.1s ease, transform 0.1s ease; }
.card.hov:hover { border-color: var(--line); background: var(--bg-2); }

/* tool monogram */
.tool {
  width: 28px; height: 28px;
  border-radius: var(--r);
  background: var(--bg-3);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  color: var(--fg);
  flex: none;
  letter-spacing: 0;
  border: 1px solid var(--line-soft);
}
.tool.lg { width: 36px; height: 36px; font-size: 12px; border-radius: 8px; }
.tool.sm { width: 22px; height: 22px; font-size: 9.5px; border-radius: 4px; }

/* tool hue variants — desaturated, distinct enough to read at a glance */
.tool.t-claude  { background: oklch(0.32 0.06  40); color: oklch(0.90 0.08  60); }
.tool.t-gpt     { background: oklch(0.30 0.05 160); color: oklch(0.88 0.10 160); }
.tool.t-codex   { background: oklch(0.30 0.05 280); color: oklch(0.88 0.09 280); }
.tool.t-perp    { background: oklch(0.30 0.05 220); color: oklch(0.88 0.10 220); }
.tool.t-cursor  { background: oklch(0.30 0.02 250); color: oklch(0.92 0.01 250); }
.tool.t-gem     { background: oklch(0.30 0.05 250); color: oklch(0.88 0.09 250); }
.tool.t-mid     { background: oklch(0.30 0.05 320); color: oklch(0.88 0.10 320); }

/* scrollbars (subtle) */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--bg-3);
  border-radius: 999px;
  border: 2px solid var(--bg);
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: var(--line); background-clip: content-box; }

/* focus ring */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r); }

/* density modifier — applied on body */
body.density-compact { font-size: 12.5px; }
body.density-comfy   { font-size: 13.5px; }
body.density-compact .card { border-radius: 8px; }
body.density-compact .pad-card { padding: 12px 14px !important; }
body.density-comfy   .pad-card { padding: 20px 22px !important; }

/* fade-in for view swaps — transform-only so content is always visible
   even when the page is in a background tab (browsers pause opacity anim) */
@keyframes fadein { from { transform: translateY(4px); } to { transform: none; } }
.fade { animation: fadein 0.18s ease-out forwards; }

/* fresh-signal pulse — for newly-arrived recs */
@keyframes signalPulse {
  0%   { box-shadow: 0 0 0 0 var(--accent-dim), inset 0 0 0 1px transparent; }
  60%  { box-shadow: 0 0 0 6px transparent,     inset 0 0 0 1px var(--accent); }
  100% { box-shadow: 0 0 0 0 transparent,       inset 0 0 0 1px transparent; }
}
.fresh-pulse { animation: signalPulse 2.4s ease-out 1; position: relative; }
body.no-pulse .fresh-pulse { animation: none; }
body.no-pulse .fresh-pulse::after { display: none; }
.fresh-pulse::after {
  content: 'NEW';
  position: absolute; top: 8px; right: 12px;
  font-family: var(--mono); font-size: 9px; font-weight: 600; letter-spacing: 0.1em;
  padding: 2px 5px; border-radius: 3px;
  background: var(--accent); color: oklch(0.18 0.02 188);
  animation: fadein 0.3s ease-out;
}

/* shimmer for animated values */
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.blink { animation: blink 1.4s ease-in-out infinite; }

/* ticker marquee */
.ticker {
  display: flex;
  align-items: center;
  gap: 0;
  height: 28px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-1);
  overflow: hidden;
  position: relative;
}
.ticker-label {
  flex: none;
  padding: 0 12px;
  height: 100%;
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-2);
  border-right: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--fg-1);
}
.ticker-viewport {
  flex: 1; overflow: hidden;
  position: relative;
  mask-image: linear-gradient(90deg, transparent 0, black 28px, black calc(100% - 28px), transparent 100%);
}
.ticker-track {
  display: flex; gap: 24px;
  white-space: nowrap;
  padding: 0 16px;
}
.ticker-item {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11.5px;
  color: var(--fg-1);
}

/* drawer */
.drawer-scrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.42);
  backdrop-filter: blur(2px);
  z-index: 90;
  animation: fadein 0.18s ease-out;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 560px; max-width: 92vw;
  background: var(--bg-1);
  border-left: 1px solid var(--line);
  box-shadow: -24px 0 48px rgba(0,0,0,0.4);
  z-index: 91;
  display: flex; flex-direction: column;
  animation: drawerIn 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes drawerIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* toast */
.toast-stack {
  position: fixed; left: 50%; bottom: 22px;
  transform: translateX(-50%);
  z-index: 95;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 10px 14px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.32);
  font-size: 12.5px;
  animation: toastIn 0.18s ease-out;
  min-width: 320px;
}
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* command palette */
.cmdk-scrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
  animation: fadein 0.12s ease-out;
}
.cmdk {
  width: 560px; max-width: 92vw;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.55);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.cmdk-input {
  appearance: none; border: none; outline: none;
  background: transparent; color: var(--fg);
  font-family: var(--sans); font-size: 14px;
  padding: 14px 16px; width: 100%;
  border-bottom: 1px solid var(--line-soft);
}
.cmdk-input::placeholder { color: var(--fg-3); }
.cmdk-list { max-height: 360px; overflow-y: auto; }
.cmdk-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 12.5px;
}
.cmdk-item.active { background: var(--bg-2); }
.cmdk-section {
  padding: 8px 14px 4px;
  font-family: var(--mono); font-size: 9.5px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--fg-3);
}
.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  background: var(--bg-3); color: var(--fg-1);
  border: 1px solid var(--line-soft); border-bottom-width: 2px;
  border-radius: 4px;
}

/* tooltip */
.tip {
  position: absolute;
  z-index: 80;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11.5px;
  color: var(--fg-1);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  pointer-events: none;
  animation: fadein 0.12s ease-out;
  min-width: 220px;
  max-width: 280px;
}

/* checkbox */
.chk {
  appearance: none;
  width: 14px; height: 14px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: 3px;
  cursor: pointer;
  display: inline-grid; place-items: center;
  flex: none;
}
.chk:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.chk:checked::after {
  content: '';
  width: 7px; height: 4px;
  border-left: 1.5px solid oklch(0.18 0.02 188);
  border-bottom: 1.5px solid oklch(0.18 0.02 188);
  transform: rotate(-45deg) translate(0, -1px);
}

/* focus-mode pattern map cell (zoomed) */
.cell-focus {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 50;
  animation: fadein 0.2s ease-out;
}
