/* 21st.dev-inspirerad Opti systemkarta — glass, glow, gradient borders */
:root {
  --bg-deep: #05050f;
  --bg-surface: #080818;
  --bg-elevated: #0e0c19;
  --bg-glass: rgba(14, 12, 25, 0.72);
  --text-primary: #ffffff;
  --text-secondary: #c8b8e0;
  --text-muted: #7a6e90;
  --primary: #e91e8c;
  --accent: #c026d3;
  --success: #4ade80;
  --warning: #ffd075;
  --error: #f87171;
  --border-subtle: rgba(200, 184, 224, 0.1);
  --border-glow: rgba(233, 30, 140, 0.45);
  --beam: linear-gradient(90deg, transparent, var(--primary), var(--accent), transparent);
}

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

body {
  background: var(--bg-deep);
  color: var(--text-secondary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  overflow: hidden;
}

/* Aurora mesh — 21st signature background */
.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 20% 20%, rgba(233, 30, 140, 0.12), transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 70%, rgba(192, 38, 211, 0.1), transparent 45%),
    radial-gradient(ellipse 50% 30% at 50% 100%, rgba(74, 222, 128, 0.04), transparent 40%);
  animation: auroraShift 18s ease-in-out infinite alternate;
}
@keyframes auroraShift {
  0% { opacity: 0.85; transform: scale(1); }
  100% { opacity: 1; transform: scale(1.03); }
}

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto auto 1fr;
  height: 100vh;
}

/* ── Magic glass header ── */
.magic-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(24px) saturate(1.4);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.magic-header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: var(--beam);
  background-size: 200% 100%;
  animation: beamSlide 4s linear infinite;
}
@keyframes beamSlide {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.brand-block { min-width: 160px; }
.eyebrow {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
.brand-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 200px;
  flex-wrap: wrap;
}
.crumb {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 150ms;
  border: none;
  background: transparent;
  font-family: inherit;
}
.crumb:hover { color: var(--primary); background: rgba(233, 30, 140, 0.08); }
.crumb.active { color: var(--text-primary); font-weight: 600; }
.crumb-sep { color: var(--text-muted); font-size: 10px; opacity: 0.5; }

.magic-search {
  position: relative;
  min-width: 200px;
}
.magic-search input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 200ms, box-shadow 200ms;
}
.magic-search input:focus {
  border-color: var(--border-glow);
  box-shadow: 0 0 0 3px rgba(233, 30, 140, 0.12);
}
.magic-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

.health-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid;
}
.health-pill.green { background: rgba(74, 222, 128, 0.1); color: var(--success); border-color: rgba(74, 222, 128, 0.35); }
.health-pill.yellow { background: rgba(255, 208, 117, 0.1); color: var(--warning); border-color: rgba(255, 208, 117, 0.35); }
.health-pill.red { background: rgba(248, 113, 113, 0.1); color: var(--error); border-color: rgba(248, 113, 113, 0.35); }
.health-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
  animation: pulse 2s ease infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.updated-at { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

.nav-links { display: flex; gap: 8px; }
.nav-links a {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
}
.nav-links a:hover { color: var(--primary); background: rgba(233, 30, 140, 0.08); }
.nav-links a.active { color: var(--primary); }

/* ── Stats row — 21st Glowing Card (id:5328) vanilla ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  padding: 12px 20px;
}

.glow-card {
  position: relative;
  border-radius: 16px;
  padding: 1px;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.22) 0%,
    rgba(233, 30, 140, 0.18) 35%,
    rgba(255, 255, 255, 0.04) 70%,
    rgba(192, 38, 211, 0.12) 100%
  );
  overflow: hidden;
  transition: transform 220ms ease, box-shadow 220ms ease;
  --glow-x: 28%;
  --glow-y: 18%;
}
.glow-card:hover {
  transform: translateY(-3px);
  box-shadow:
    0 18px 48px rgba(0, 0, 0, 0.45),
    0 0 40px rgba(233, 30, 140, 0.12);
}

.glow-card-flare {
  position: absolute;
  inset: -40% -20% auto -20%;
  height: 120%;
  background: radial-gradient(
    ellipse 70% 55% at var(--glow-x) var(--glow-y),
    rgba(255, 255, 255, 0.14),
    rgba(233, 30, 140, 0.08) 35%,
    transparent 68%
  );
  pointer-events: none;
  z-index: 0;
  transition: opacity 200ms;
}

.glow-card-shine {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    115deg,
    transparent 0%,
    rgba(255, 255, 255, 0.06) 42%,
    transparent 58%
  );
  opacity: 0.55;
  pointer-events: none;
  z-index: 1;
  animation: cardShine 7s ease-in-out infinite;
}
@keyframes cardShine {
  0%, 100% { opacity: 0.35; transform: translateX(-8%); }
  50% { opacity: 0.7; transform: translateX(8%); }
}

.glow-card-inner {
  position: relative;
  z-index: 2;
  padding: 16px 18px 18px;
  border-radius: 15px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, transparent 28%),
    rgba(10, 10, 18, 0.72);
  backdrop-filter: blur(20px) saturate(1.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-height: 88px;
}

.glow-card-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 500;
  font-family: 'Inter Tight', 'Inter', sans-serif;
}

.glow-card-value {
  font-size: 30px;
  font-weight: 700;
  margin-top: 6px;
  line-height: 1;
  font-family: 'Inter Tight', 'Inter', sans-serif;
  letter-spacing: -0.03em;
  background: linear-gradient(180deg, #ffffff 0%, #d4d0dc 55%, #9a94a8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.15));
}

.glow-card-dot {
  position: absolute;
  left: 14px;
  bottom: 12px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.65);
  opacity: 0.85;
}

/* Healing banner */
.heal-banner {
  margin: 0 20px 8px;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(255, 208, 117, 0.08);
  border: 1px solid rgba(255, 208, 117, 0.25);
  font-size: 13px;
  color: var(--warning);
  display: none;
}
.heal-banner.visible { display: block; }

/* ── Main layout ── */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 0;
  min-height: 0;
  padding: 0 12px 12px;
}

.graph-wrap {
  position: relative;
  border-radius: 16px;
  background: rgba(8, 8, 24, 0.6);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  min-height: 0;
}
#cy {
  width: 100%;
  height: 100%;
  min-height: 400px;
}

.graph-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 8px;
  z-index: 5;
}
.magic-btn {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 150ms;
}
.magic-btn:hover {
  border-color: var(--border-glow);
  color: var(--primary);
}
.magic-btn.primary {
  background: rgba(233, 30, 140, 0.15);
  border-color: var(--border-glow);
  color: var(--primary);
}

/* ── Detail drawer — 21st glass panel ── */
.drawer {
  display: flex;
  flex-direction: column;
  background: var(--bg-glass);
  backdrop-filter: blur(28px) saturate(1.3);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  margin-left: 12px;
  overflow: hidden;
  min-height: 0;
}

.drawer-header {
  padding: 16px 18px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.drawer-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.drawer-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.tab-row {
  display: flex;
  gap: 4px;
  padding: 12px 18px 0;
  position: relative;
}
.tab-btn {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  transition: color 150ms;
}
.tab-btn.active {
  color: var(--primary);
  background: rgba(233, 30, 140, 0.08);
}
.tab-indicator {
  position: absolute;
  bottom: 0;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
  transition: left 200ms, width 200ms;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  min-height: 0;
}

.meta-grid {
  display: grid;
  gap: 10px;
}
.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.02);
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}
.meta-key { color: var(--text-muted); }
.meta-val { color: var(--text-primary); text-align: right; word-break: break-all; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid;
}
.chip.ok { background: rgba(74,222,128,0.12); color: var(--success); border-color: rgba(74,222,128,0.3); }
.chip.warn { background: rgba(255,208,117,0.12); color: var(--warning); border-color: rgba(255,208,117,0.3); }
.chip.err { background: rgba(248,113,113,0.12); color: var(--error); border-color: rgba(248,113,113,0.3); }
.chip.muted { background: rgba(122,110,144,0.12); color: var(--text-muted); border-color: rgba(122,110,144,0.3); }

.log-terminal {
  font-family: 'Fira Code', 'SF Mono', monospace;
  font-size: 11px;
  line-height: 1.55;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px;
  max-height: 320px;
  overflow-y: auto;
  color: #a8b4c8;
}
.log-line { margin-bottom: 6px; }
.log-line .ts { color: var(--text-muted); }
.log-line.err { color: var(--error); }

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

.wf-input {
  padding: 8px 10px;
  font-size: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-family: inherit;
}
.wf-input:focus {
  outline: none;
  border-color: var(--border-glow);
}
#wf-result {
  font-family: 'Fira Code', monospace;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px;
  color: #a8b4c8;
}

@media (max-width: 1024px) {
  .main-grid { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .drawer { margin-left: 0; margin-top: 12px; max-height: 40vh; }
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
}