:root {
  --bg0: #07141a;
  --bg1: #0d2430;
  --ink: #e8f2f4;
  --muted: #8aa4ad;
  --line: rgba(232, 242, 244, 0.12);
  --panel: rgba(10, 28, 36, 0.78);
  --accent: #e2a35a;
  --accent-2: #3db8a8;
  --danger: #e57373;
  --ok: #5dcb8a;
  --pending: #e2a35a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --font-display: "Syne", "Noto Sans SC", sans-serif;
  --font-body: "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg0);
  line-height: 1.55;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { color: #7ad9cc; }

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(1200px 700px at 12% -10%, rgba(61, 184, 168, 0.28), transparent 55%),
    radial-gradient(900px 600px at 95% 10%, rgba(226, 163, 90, 0.22), transparent 50%),
    linear-gradient(160deg, #061017 0%, #0b2230 45%, #102a28 100%);
  animation: drift 18s ease-in-out infinite alternate;
}

.noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.08;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@keyframes drift {
  from { transform: scale(1) translate(0, 0); }
  to { transform: scale(1.05) translate(-1.5%, 1%); }
}

.reveal {
  opacity: 0;
  transform: translateY(18px);
  animation: rise 0.7s ease forwards;
}
.delay-1 { animation-delay: 0.12s; }
.delay-2 { animation-delay: 0.24s; }

@keyframes rise {
  to { opacity: 1; transform: none; }
}

/* Auth */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 2rem;
  align-items: center;
  padding: 4rem clamp(1.25rem, 5vw, 5rem);
}

.auth-brand .brand-mark,
.logo {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: 1.35rem;
  color: var(--ink);
}

.auth-brand h1 {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 4vw, 3.4rem);
  line-height: 1.12;
  margin: 1rem 0 0.8rem;
  max-width: 12ch;
}

.brand-lead,
.muted { color: var(--muted); }

.auth-panel,
.panel,
.hero-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.auth-panel {
  padding: 2rem;
  max-width: 440px;
  width: 100%;
  justify-self: end;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  padding: 0.3rem;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
}

.auth-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 0.7rem 0.5rem;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}

.auth-tab.active {
  background: rgba(226, 163, 90, 0.18);
  color: var(--ink);
}

.tab-pane { display: none; }
.tab-pane.active { display: grid; }

.tiny { font-size: 0.86rem; margin: 0; }

#account, #manage, #create, #api {
  scroll-margin-top: 5rem;
}

.panel-head h2,
.panel h2,
.page-intro h1,
.hero-card h1 {
  font-family: var(--font-display);
  margin: 0 0 0.4rem;
}

.panel-head p { margin: 0 0 1.4rem; color: var(--muted); }

.stack-form {
  display: grid;
  gap: 0.95rem;
}

.stack-form label {
  display: grid;
  gap: 0.4rem;
  font-size: 0.92rem;
}

.stack-form span { color: var(--muted); }

input, select, button, textarea {
  font: inherit;
}

input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus {
  border-color: rgba(61, 184, 168, 0.7);
  box-shadow: 0 0 0 3px rgba(61, 184, 168, 0.18);
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 0.55rem;
  grid-template-columns: none !important;
}

.check-row input { width: auto; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0.8rem 1.1rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s, border-color 0.2s, color 0.2s;
  text-decoration: none;
  color: var(--ink);
  background: transparent;
}

.btn:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, #e2a35a, #c9843d); color: #1a1208; font-weight: 700; }
.btn-secondary { border-color: var(--line); background: rgba(255,255,255,0.04); }
.btn-ghost { border-color: transparent; color: var(--muted); }
.btn-danger { background: rgba(229, 115, 115, 0.15); color: #ffc9c9; border-color: rgba(229,115,115,0.35); }
.btn-sm { padding: 0.4rem 0.7rem; border-radius: 9px; font-size: 0.85rem; }

.panel-foot { margin-top: 1.2rem; color: var(--muted); font-size: 0.92rem; }

/* App chrome */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: 0.9rem clamp(1rem, 4vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: rgba(7, 20, 26, 0.75);
  backdrop-filter: blur(12px);
}

.topnav { display: flex; gap: 0.4rem; flex: 1; }
.topnav a {
  color: var(--muted);
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
}
.topnav a.active, .topnav a:hover {
  color: var(--ink);
  background: rgba(255,255,255,0.06);
}

.topbar-right { display: flex; align-items: center; gap: 0.6rem; }

.content {
  padding: 2rem clamp(1rem, 4vw, 2.5rem) 3.5rem;
  max-width: 1180px;
  margin: 0 auto;
}
.content.narrow { max-width: 720px; }

.page-intro { margin-bottom: 1.5rem; }
.page-intro p { color: var(--muted); margin: 0.4rem 0 0; max-width: 48ch; }

.panel { padding: 1.35rem 1.4rem; }
.hero-card { padding: 2rem; text-align: left; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  color: var(--accent);
  margin: 0 0 0.6rem;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.9rem;
  margin-bottom: 1.2rem;
}
.stat {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  background: rgba(255,255,255,0.03);
}
.stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 1.8rem;
}
.stat span { color: var(--muted); font-size: 0.88rem; }

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.kv { margin: 0 0 1.2rem; }
.kv > div {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 0.6rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
  border: 1px solid var(--line);
}
.chip-allowed { color: var(--ok); border-color: rgba(93,203,138,0.35); background: rgba(93,203,138,0.1); }
.chip-pending { color: var(--pending); border-color: rgba(226,163,90,0.35); background: rgba(226,163,90,0.1); }
.chip-blocked { color: var(--danger); border-color: rgba(229,115,115,0.35); background: rgba(229,115,115,0.1); }

.log-list { list-style: none; margin: 0; padding: 0; }
.log-list li {
  display: grid;
  gap: 0.15rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}
.log-list.compact li { font-size: 0.9rem; }
.log-action { font-weight: 600; }
.log-detail, time { color: var(--muted); font-size: 0.86rem; }

.panel-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  margin-bottom: 1rem;
}
.filter-form { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.filter-form input, .filter-form select { width: auto; min-width: 140px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 0.85rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { color: var(--muted); font-weight: 500; font-size: 0.86rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.actions form { margin: 0; }

.code-block, .token-box {
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem;
}
.code-block { overflow-x: auto; color: #d7ebe7; font-size: 0.86rem; }
.token-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin: 0.8rem 0;
}
.token-box code { word-break: break-all; }
.subhead { margin: 1.4rem 0 0.6rem; font-size: 1rem; }

.status-pulse {
  display: flex;
  gap: 0.45rem;
  margin: 1.4rem 0;
}
.status-pulse span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}
.status-pulse span:nth-child(2) { animation-delay: 0.15s; }
.status-pulse span:nth-child(3) { animation-delay: 0.3s; }

@keyframes pulse {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

.toast-stack {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  display: grid;
  gap: 0.5rem;
  max-width: min(360px, calc(100vw - 2rem));
}
.toast {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(12, 28, 34, 0.92);
  box-shadow: var(--shadow);
  animation: rise 0.35s ease;
}
.toast-success { border-color: rgba(93,203,138,0.45); }
.toast-error { border-color: rgba(229,115,115,0.5); }
.toast-info { border-color: rgba(61,184,168,0.45); }

@media (max-width: 900px) {
  .auth-shell {
    grid-template-columns: 1fr;
    padding-top: 2.5rem;
    padding-bottom: 2.5rem;
  }
  .auth-panel { justify-self: stretch; max-width: none; }
  .auth-brand h1 { max-width: none; }
  .stat-row, .split { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .topnav { display: none; }
  .stat-row, .split { grid-template-columns: 1fr; }
  .kv > div { grid-template-columns: 1fr; gap: 0.15rem; }
}
