@import url("https://fonts.googleapis.com/css2?family=Unbounded:wght@400;500;600;700;800&display=swap");
@import url("https://cdn.jsdelivr.net/npm/geist@1.3.1/dist/fonts/geist-sans/style.min.css");

:root {
  --bg: #050505;
  --card: #0f0f0f;
  --card-2: #121212;
  --line: rgba(255, 255, 255, 0.08);
  --text: #fafafa;
  --muted: #a1a1aa;
  --muted-2: #71717a;
  --accent: #fafafa;
  --good: #22c55e;
  --bad: #ef4444;
  --warn: #eab308;
  --radius: 20px;
  --font-display: "Unbounded", system-ui, sans-serif;
  --font-body: "Geist Sans", "Geist", system-ui, sans-serif;
  --text-sm: 15px;
  --text-base: 16px;
  --text-lg: 18px;
}

html { font-size: 16px; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text);
  background: #050505 radial-gradient(circle at 50% -20%, #202020 0%, #050505 55%);
  -webkit-font-smoothing: antialiased;
}

.cursor-glow {
  position: fixed;
  width: 480px;
  height: 480px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.06) 0%, transparent 65%);
  transform: translate(-50%, -50%);
  transition: opacity 0.4s;
  opacity: 0;
}
body.is-active .cursor-glow { opacity: 1; }

svg.ico {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  display: block;
}

.noise-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  padding: 20px 16px 0;
  pointer-events: none;
}

.nav-pill {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(100%, 1120px);
  padding: 10px 12px 10px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(18, 18, 18, 0.82);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s;
}
body.is-scrolled .nav-pill {
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

.brand {
  color: #fff;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.04em;
  white-space: nowrap;
  margin-right: 8px;
  transition: opacity 0.2s;
}
.brand:hover { opacity: 0.85; }

.nav-pill nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-pill nav::-webkit-scrollbar { display: none; }

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #a1a1aa;
  text-decoration: none;
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s, transform 0.15s;
}
.nav-item:hover { color: #fafafa; background: rgba(255, 255, 255, 0.06); transform: translateY(-1px); }
.nav-item.is-active { color: #fafafa; background: rgba(255, 255, 255, 0.12); }
.nav-item:active { transform: scale(0.97); }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.who {
  text-align: right;
  line-height: 1.2;
  display: none;
}
.who span { display: block; font-size: 14px; font-weight: 600; }
.who small { color: var(--muted); font-size: 13px; }

@media (min-width: 900px) {
  .who { display: block; }
}

.btn-auth {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background:
    linear-gradient(rgba(18, 18, 18, 0.95), rgba(18, 18, 18, 0.95)) padding-box,
    linear-gradient(135deg, rgba(255,255,255,0.35), rgba(255,255,255,0.06)) border-box;
  color: #fafafa;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, transform 0.2s;
}
.btn-auth:hover { background: rgba(255,255,255,0.08); transform: translateY(-1px); }

.logout-form { margin: 0; }
.logout-form button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background:
    linear-gradient(rgba(18, 18, 18, 0.95), rgba(18, 18, 18, 0.95)) padding-box,
    linear-gradient(135deg, rgba(255,255,255,0.35), rgba(255,255,255,0.06)) border-box;
  color: #fafafa;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.logout-form button:hover { background: rgba(255,255,255,0.08); transform: translateY(-1px); }

.main {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 120px 24px 48px;
}

.page-head {
  margin-bottom: 48px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 15px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  font-family: var(--font-body);
}

.page-head h1, .auth-card h1, .hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 52px);
  letter-spacing: -0.04em;
  line-height: 1.05;
  font-weight: 700;
}

.page-sub {
  margin: 16px auto 0;
  max-width: 520px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

.section-label {
  text-align: center;
  margin-bottom: 28px;
}
.section-label h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.section-label p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}

.stat, .panel-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  animation: rise 0.55s ease both;
}

.stat {
  padding: 32px 24px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
  cursor: default;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.3s, box-shadow 0.3s;
}
.stat::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,0.06), transparent 60%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.stat:hover::before { opacity: 1; }
.stat:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.stat:nth-child(2) { animation-delay: 0.05s; }
.stat:nth-child(3) { animation-delay: 0.1s; }
.stat:nth-child(4) { animation-delay: 0.15s; }

.stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 700;
  letter-spacing: -0.04em;
  margin: 0 0 12px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat span {
  display: block;
  color: #fafafa;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}
.stat em {
  font-style: normal;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.panel-card {
  padding: 28px;
  margin-bottom: 20px;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.panel-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}
.panel-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.muted { color: var(--muted); line-height: 1.6; font-size: 16px; }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.split { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 20px; }

.tabs { display: flex; gap: 6px; }
.tabs button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s, background 0.2s, transform 0.15s, border-color 0.2s;
}
.tabs button:hover:not(.is-on) {
  color: #fafafa;
  border-color: rgba(255,255,255,0.15);
  transform: translateY(-1px);
}
.tabs button.is-on {
  color: #09090b;
  background: #fafafa;
  border-color: #fafafa;
  font-weight: 600;
  transform: scale(1.02);
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s;
}
tbody tr:hover td { background: rgba(255,255,255,0.03); }
th { color: var(--muted); font-weight: 500; font-size: 14px; }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  transition: transform 0.15s;
}
tbody tr:hover .pill { transform: scale(1.04); }
.pill.created { background: rgba(255,255,255,0.08); color: #d4d4d8; }
.pill.passed { background: rgba(34,197,94,0.12); color: #86efac; }
.pill.failed, .pill.expired { background: rgba(239,68,68,0.12); color: #fca5a5; }

.kv {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 14px 20px;
  margin: 20px 0;
}
.kv dt { color: var(--muted); font-size: 15px; }
.kv dd { margin: 0; font-size: 16px; }

.btn-primary, .auth-card button[type="submit"], #saveFlow, #rotateKey, #addBlock, #helpClose, #profileForm button {
  border: 0;
  cursor: pointer;
  font: inherit;
  background: #fafafa;
  color: #09090b;
  border-radius: 999px;
  padding: 13px 24px;
  font-weight: 600;
  font-size: 15px;
  transition: transform 0.2s, opacity 0.2s, box-shadow 0.2s;
}
.btn-primary:hover, .auth-card button[type="submit"]:hover, #saveFlow:hover, #rotateKey:hover, #addBlock:hover, #profileForm button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255,255,255,0.12);
}
.btn-primary:active, #saveFlow:active, #rotateKey:active { transform: scale(0.97); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: #fafafa;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 18px;
  font-weight: 500;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.btn-ghost:hover { border-color: rgba(255,255,255,0.2); background: rgba(255,255,255,0.04); }
.btn-ghost svg { width: 14px; height: 14px; }

.actions-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }

label {
  display: block;
  margin: 16px 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}
input, select, textarea {
  width: 100%;
  margin-top: 8px;
  background: #0a0a0a;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 16px;
  font: inherit;
  font-size: 16px;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
input:hover, select:hover, textarea:hover {
  border-color: rgba(255,255,255,0.14);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(255,255,255,0.2);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.04);
}

.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  color: #d4d4d8;
  font-weight: 500;
  margin: 18px 0 8px;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.switch-box {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid rgba(255,255,255,0.15);
  background: #0a0a0a;
  display: grid;
  place-items: center;
  transition: background 0.2s, border-color 0.2s;
  flex: 0 0 20px;
}
.switch-box svg {
  width: 12px;
  height: 12px;
  color: #09090b;
  opacity: 0;
  transform: scale(0.6);
  transition: 0.18s ease;
}
.switch input:checked + .switch-box {
  background: #fafafa;
  border-color: #fafafa;
}
.switch input:checked + .switch-box svg { opacity: 1; transform: scale(1); }

.form-grid { max-width: 480px; }
.alert {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.22);
  color: #fecaca;
  padding: 12px 14px;
  border-radius: 12px;
  margin: 16px 0;
  font-size: 15px;
}
.alert.warn {
  background: rgba(234,179,8,0.06);
  border-color: rgba(234,179,8,0.22);
  color: #fde68a;
}
code {
  font-family: ui-monospace, "Geist Mono", Consolas, monospace;
  font-size: 14px;
  background: rgba(255,255,255,0.05);
  padding: 3px 8px;
  border-radius: 6px;
}

.auth-body { min-height: 100vh; }
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 120px 24px 80px;
  position: relative;
  z-index: 1;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 36px 32px 32px;
  animation: rise 0.55s ease both;
}
.auth-card h1 { font-size: 28px; margin-bottom: 10px; text-align: center; }
.auth-card .eyebrow { text-align: center; }
.auth-card .muted { text-align: center; margin-bottom: 24px; font-size: 16px; }
.auth-card button[type="submit"] { width: 100%; margin-top: 8px; }

.scratch { margin-top: 24px; }
.block {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 16px 8px;
  animation: rise 0.35s ease both;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.block:hover {
  border-color: rgba(255,255,255,0.14);
  transform: translateX(4px);
  box-shadow: -4px 0 0 rgba(255,255,255,0.08);
}
.connector {
  width: 1px;
  height: 18px;
  background: rgba(255,255,255,0.12);
  margin: 0 auto;
  position: relative;
}
.connector::after {
  content: "";
  position: absolute;
  left: -4px;
  bottom: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 6px solid rgba(255,255,255,0.12);
}
.block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  color: #fafafa;
  font-weight: 600;
  font-size: 15px;
}
.block textarea { min-height: 72px; resize: vertical; }
.block-actions { display: flex; gap: 4px; }
.block-actions button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: 0.2s;
}
.block-actions button:hover { color: #fafafa; border-color: rgba(255,255,255,0.2); transform: scale(1.08); }
.scratch-add { display: flex; gap: 10px; margin: 20px 0; max-width: 440px; }
#addBlock { border-radius: 999px; }
.flow-meta { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: end; }

.preview-pane { overflow: hidden; }
.preview-frame {
  width: 100%;
  height: 620px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #050505;
  margin-top: 8px;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.preview-frame:hover {
  border-color: rgba(255,255,255,0.14);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06);
}

.chart-wrap {
  position: relative;
}
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  padding: 8px 12px;
  background: rgba(18,18,18,0.95);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s, transform 0.15s;
  z-index: 2;
}
.chart-tooltip.is-visible {
  opacity: 1;
  transform: none;
}

.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.is-visible {
  opacity: 1;
  transform: none;
}

.stat.is-refreshing {
  animation: statPulse 0.5s ease;
}
@keyframes statPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
}
.status-dot.on { background: var(--good); box-shadow: 0 0 12px rgba(34,197,94,0.5); }
.status-dot.off { background: var(--bad); }

.site-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--line);
  margin-top: 40px;
}
.footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-inner p {
  margin: 0;
  color: var(--muted-2);
  font-size: 15px;
}
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.1);
  color: #86efac;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.2s, transform 0.2s;
}
.live-pill:hover {
  background: rgba(34, 197, 94, 0.16);
  transform: scale(1.02);
}
.live-pill i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: pulse 1.8s infinite;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

@media (max-width: 1024px) {
  .cards, .split, .flow-meta, .kv { grid-template-columns: 1fr; }
  .main { padding-top: 108px; }
  .nav-item span { display: none; }
  .nav-item { padding: 8px 10px; }
}

@media (max-width: 640px) {
  .main { padding: 100px 16px 32px; }
  .nav-pill { padding: 6px 8px 6px 12px; }
  .brand { font-size: 13px; }
  .preview-frame { height: 480px; }
}

/* Account */
.account-card { max-width: 560px; }
.account-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.account-avatar {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  color: #fafafa;
  background: linear-gradient(145deg, rgba(255,255,255,0.12), rgba(255,255,255,0.04));
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  flex-shrink: 0;
}
.account-hero-text h2 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.account-hero-text p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}
.account-form { margin-top: 8px; }
.field-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin: 0 0 18px;
  cursor: text;
}
.field-badge {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: #e4e4e7;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  transition: background 0.2s, border-color 0.2s, transform 0.2s, color 0.2s;
}
.field-row:focus-within .field-badge {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.18);
  color: #fff;
  transform: scale(1.04);
}
.field-body {
  flex: 1;
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}
.field-body input { margin-top: 8px; }
.account-save { margin-top: 8px; width: 100%; }
