/* ============================================================
   Kontrolite Hub — Operations Console
   ============================================================ */

:root {
  --accent: #ef4444;
  --accent-rgb: 239, 68, 68;
  --accent-soft: rgba(239, 68, 68, 0.12);

  --ok: #22c55e;
  --warn: #f59e0b;

  /* dark (default) */
  --bg: #07070a;
  --bg-elev: #0d0d12;
  --panel: #111119;
  --panel-2: #16161f;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
  --ink: #f4f4f6;
  --ink-2: #b8b8c2;
  --ink-3: #6a6a78;
  --ink-4: #3d3d48;
  --grid-dot: rgba(255, 255, 255, 0.045);

  --r-card: 14px;
  --r-pill: 999px;
  --r-tile: 10px;

  --pad: 28px;
  --pad-tight: 20px;

  --font-display: "Space Grotesk", "Rajdhani", system-ui, sans-serif;
  --font-body: "Inter", "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace;
}

[data-theme="light"] {
  --bg: #f5f5f0;
  --bg-elev: #ffffff;
  --panel: #ffffff;
  --panel-2: #fafaf6;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.16);
  --ink: #0d0d12;
  --ink-2: #44444f;
  --ink-3: #7a7a85;
  --ink-4: #bdbdc4;
  --grid-dot: rgba(0, 0, 0, 0.05);
}

[data-density="compact"] {
  --pad: 20px;
  --pad-tight: 14px;
  --r-card: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100%;
}

body {
  background-image:
    radial-gradient(var(--grid-dot) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: 0 0;
  overflow-x: hidden;
}

::selection { background: var(--accent); color: white; }

a { color: inherit; text-decoration: none; }

/* ------------------------------------------------------------
   Spotlight that follows cursor — adds depth on dark theme
   ------------------------------------------------------------ */
.spotlight {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(
      600px circle at var(--mx, 50%) var(--my, 30%),
      rgba(var(--accent-rgb), 0.08),
      transparent 60%
    );
  transition: background 0.2s linear;
}
[data-theme="light"] .spotlight {
  background:
    radial-gradient(
      600px circle at var(--mx, 50%) var(--my, 30%),
      rgba(var(--accent-rgb), 0.04),
      transparent 60%
    );
}

/* ------------------------------------------------------------
   Shell
   ------------------------------------------------------------ */
.shell {
  position: relative;
  z-index: 1;
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px clamp(20px, 4vw, 48px) 64px;
}

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 18px;
  background: color-mix(in oklab, var(--panel) 80%, transparent);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand-mark {
  position: relative;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--bg);
  border-radius: 6px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
}
.brand-mark::before {
  content: "";
  position: absolute;
  top: -3px;
  left: -3px;
  width: 9px;
  height: 9px;
  background: var(--accent);
  border-radius: 1px;
}
.brand-mark-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}
.brand-name {
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand-name .slash { color: var(--ink-3); margin: 0 8px; font-weight: 400; }
.brand-name em { font-style: normal; color: var(--ink-2); font-weight: 500; }

.topbar-spacer { flex: 1; }

.kbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-elev);
  color: var(--ink-3);
  font-size: 13px;
  min-width: 260px;
  cursor: text;
  transition: border-color 0.15s, background 0.15s;
}
.kbar:focus-within { border-color: var(--line-strong); }
.kbar svg { width: 14px; height: 14px; opacity: 0.7; flex-shrink: 0; }
.kbar input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--ink);
  font: inherit;
}
.kbar input::placeholder { color: var(--ink-3); }
.kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel-2);
  color: var(--ink-2);
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 10px;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.15s;
}
.icon-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; }

/* ============================================================
   Hero / status panel
   ============================================================ */
.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-bottom: 32px;
}
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
}

.hero-main {
  position: relative;
  padding: var(--pad);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  overflow: hidden;
}
.hero-main::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 100% 0%, rgba(var(--accent-rgb), 0.18), transparent 45%);
}
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin-bottom: 18px;
}
.hero-eyebrow .live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.15);
  animation: livepulse 2s ease-in-out infinite;
}
@keyframes livepulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.15); }
  50%      { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(34px, 4.5vw, 56px);
  line-height: 1.02;
  letter-spacing: -0.025em;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 14px;
  text-wrap: balance;
}
.hero-title .accent { color: var(--accent); }

.hero-sub {
  font-size: 15px;
  color: var(--ink-2);
  max-width: 46ch;
  margin-bottom: 26px;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  border-top: 1px dashed var(--line);
  padding-top: 22px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-num {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-num .unit { font-size: 14px; color: var(--ink-3); margin-left: 4px; }
.stat-num .ok { color: var(--ok); }
.stat-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-family: var(--font-mono);
}

/* Status panel */
.hero-aside {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
}
.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: var(--pad-tight);
}
.tile-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.clock-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-mono);
}
.clock {
  font-size: 36px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.clock-date {
  font-size: 12px;
  color: var(--ink-3);
}

.health-list { display: grid; gap: 10px; margin-top: 4px; }
.health-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--ink-2);
}
.health-row .name { display: flex; align-items: center; gap: 8px; }
.health-row .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(34,197,94, 0.18);
}
.health-row .meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

/* ============================================================
   Section header
   ============================================================ */
.section {
  margin-top: 16px;
}
.section + .section { margin-top: 44px; }

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  gap: 18px;
}
.section-head-left {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}
.section-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  border: 1px solid currentColor;
}
.section-tag.prod { color: var(--ok); background: rgba(34, 197, 94, 0.08); }
.section-tag.dev  { color: var(--warn); background: rgba(245, 158, 11, 0.08); }
.section-tag::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  animation: livepulse 2s ease-in-out infinite;
}

.section-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.section-sub {
  font-size: 13px;
  color: var(--ink-3);
}
.section-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
}

/* ============================================================
   Project cards
   ============================================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.card {
  --card-accent: var(--accent);
  --card-accent-rgb: var(--accent-rgb);

  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  padding: var(--pad);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  overflow: hidden;
  cursor: pointer;
  transition:
    transform 0.25s cubic-bezier(.2,.7,.2,1),
    border-color 0.2s,
    background 0.2s;
  isolation: isolate;
  opacity: 0;
  transform: translateY(12px);
  animation: cardIn 0.6s cubic-bezier(.2,.7,.2,1) forwards;
}
@keyframes cardIn { to { opacity: 1; transform: translateY(0); } }

.card::before {
  /* accent corner glow */
  content: "";
  position: absolute;
  inset: -1px;
  pointer-events: none;
  border-radius: inherit;
  background:
    radial-gradient(220px circle at 100% 0%,
      rgba(var(--card-accent-rgb), 0.18), transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 0;
}
.card::after {
  /* accent top hairline that lights up on hover */
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg,
    transparent,
    rgba(var(--card-accent-rgb), 0.6) 30%,
    rgba(var(--card-accent-rgb), 0.6) 70%,
    transparent);
  opacity: 0;
  transition: opacity 0.25s;
  z-index: 2;
}
.card:hover {
  transform: translateY(-4px);
  border-color: rgba(var(--card-accent-rgb), 0.35);
}
.card:hover::before, .card:hover::after { opacity: 1; }
.card > * { position: relative; z-index: 1; }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.card-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}
.card-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.15;
}
.card-desc {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.55;
  margin-top: 6px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-pill.prod {
  color: var(--ok);
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.25);
}
.status-pill.dev {
  color: var(--warn);
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
}
.status-pill .pill-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  animation: livepulse 2s ease-in-out infinite;
}

/* Sparkline + metrics middle row */
.card-metrics {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  padding: 14px 14px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-tile);
}
.spark {
  width: 100%;
  height: 38px;
  display: block;
  overflow: visible;
}
.spark path.line {
  fill: none;
  stroke: var(--card-accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.spark path.area {
  fill: rgba(var(--card-accent-rgb), 0.14);
  stroke: none;
}
.metric-mini {
  text-align: right;
  min-width: 60px;
}
.metric-mini .v {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.metric-mini .l {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Footer */
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.card-url {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.card-url svg { width: 12px; height: 12px; flex-shrink: 0; opacity: 0.5; }
.card-arrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  transition: all 0.2s;
  flex-shrink: 0;
}
.card:hover .card-arrow {
  color: var(--card-accent);
  border-color: rgba(var(--card-accent-rgb), 0.35);
  background: rgba(var(--card-accent-rgb), 0.06);
}
.card-arrow svg { width: 12px; height: 12px; transition: transform 0.2s; }
.card:hover .card-arrow svg { transform: translateX(2px); }

.card-icon-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.card-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.card-icon img {
  width: 70%;
  height: 70%;
  object-fit: contain;
  display: block;
}

/* Empty filter state */
.empty-state {
  grid-column: 1 / -1;
  padding: 48px 24px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--r-card);
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
  margin-top: 56px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.footer-meta { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-meta span { display: inline-flex; gap: 6px; align-items: center; }

/* ============================================================
   Mac-style terminal tile
   ============================================================ */
.term-tile {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 240px;
}
.term-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: color-mix(in oklab, var(--panel-2) 85%, transparent);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}
.term-dot {
  width: 11px; height: 11px; border-radius: 50%;
  display: inline-block;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25);
}
.term-dot.red    { background: #ff5f57; }
.term-dot.yellow { background: #febc2e; }
.term-dot.green  { background: #28c840; }
.term-title {
  flex: 1;
  text-align: center;
  letter-spacing: 0.04em;
}
.term-meta {
  color: var(--ok);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.term-body {
  flex: 1;
  padding: 12px 14px 14px;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.0), rgba(0,0,0,0.15)),
    var(--bg);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  color: #c9c9d1;
  overflow: hidden;
  position: relative;
  max-height: 260px;
}
[data-theme="light"] .term-body {
  background: #0e0e14;
  color: #d4d4dc;
}
.term-line {
  display: flex;
  gap: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  opacity: 0;
  transform: translateY(4px);
  animation: termIn 0.22s cubic-bezier(.2,.7,.2,1) forwards;
}
@keyframes termIn { to { opacity: 1; transform: none; } }
.term-time { color: #5a5a66; flex-shrink: 0; }
.term-prompt { color: var(--accent); flex-shrink: 0; }
.term-ok   { color: #4ade80; }
.term-warn { color: #fbbf24; }
.term-err  { color: #f87171; }
.term-info { color: #60a5fa; }
.term-dim  { color: #6a6a78; }
.term-msg  { flex: 1; min-width: 0; }
.term-cursor {
  display: inline-block;
  width: 7px; height: 13px;
  background: var(--accent);
  vertical-align: -2px;
  margin-left: 2px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ============================================================
   Tweaks panel (vanilla)
   ============================================================ */
.tweaks {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  width: 280px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 12px 50px rgba(0,0,0,0.5);
  font-size: 13px;
  display: none;
}
.tweaks.open { display: block; }
.tweaks h4 {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 12px 0 8px;
  font-weight: 500;
}
.tweaks h4:first-child { margin-top: 0; }
.tweaks-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.tweaks-head strong {
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: -0.01em;
}
.tweaks-close {
  background: transparent;
  border: 0;
  color: var(--ink-3);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.seg {
  display: flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-elev);
}
.seg button {
  flex: 1;
  padding: 6px 8px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
}
.seg button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
}
.swatches { display: flex; gap: 6px; }
.swatches button {
  width: 28px; height: 28px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--swatch);
  cursor: pointer;
  position: relative;
}
.swatches button[aria-pressed="true"] {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 760px) {
  body { background-size: 22px 22px; }
  .shell { padding: 16px 16px 48px; }
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
  }
  .topbar-spacer { display: none; }
  .kbar { order: 10; width: 100%; min-width: 0; }
  .hero-main { padding: 22px; }
  .hero-stats { gap: 18px; }
  .stat-num { font-size: 22px; }
  .clock { font-size: 28px; }
  .card { padding: 22px; }
  .card-grid { grid-template-columns: 1fr; }
  .tweaks { right: 12px; bottom: 12px; left: 12px; width: auto; }
}
