:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --bg-2: #0f141b;
  --panel: rgba(17, 24, 32, 0.9);
  --panel-solid: #111820;
  --line: rgba(148, 163, 184, 0.18);
  --line-strong: rgba(148, 163, 184, 0.34);
  --text: #e5e7eb;
  --muted: #94a3b8;
  --teal: #3b82f6;
  --success: #22c55e;
  --amber: #f59e0b;
  --rose: #8b5cf6;
  --danger: #ef4444;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.08), transparent 22rem),
    linear-gradient(140deg, #0b0f14 0%, #0f141b 48%, #0b0f14 100%);
}

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

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
}

.site-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 0 max(20px, calc((100vw - 1120px) / 2));
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(11, 15, 20, 0.78);
  backdrop-filter: blur(18px);
}

.console-header {
  justify-content: center;
  padding: 0 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  font-size: 1.05rem;
  font-weight: 800;
  white-space: nowrap;
}

.brand::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid var(--teal);
  border-radius: 50%;
  box-shadow: 0 0 22px rgba(59, 130, 246, 0.65);
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  color: var(--muted);
  font-size: 0.95rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.32) transparent;
}

.console-header .nav-links {
  flex: 0 1 auto;
  scrollbar-width: none;
}

.console-header .nav-links::-webkit-scrollbar {
  display: none;
}

.nav-links::-webkit-scrollbar {
  height: 6px;
}

.nav-links::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.32);
}

.nav-links a:hover,
.nav-button:hover {
  color: var(--text);
}

.nav-links a.active {
  color: var(--text);
  border-color: rgba(59, 130, 246, 0.4);
  background: rgba(59, 130, 246, 0.12);
}

.nav-links a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  white-space: nowrap;
}

.nav-button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  color: #ffffff;
  background: linear-gradient(135deg, #2563eb, var(--teal));
  box-shadow: 0 12px 32px rgba(37, 99, 235, 0.25);
}

.button-secondary,
.button-ghost {
  color: var(--text);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
}

.hero-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 760px;
  pointer-events: none;
  opacity: 0.72;
}

.hero {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(320px, 0.68fr);
  gap: 56px;
  align-items: center;
  min-height: calc(100vh - 76px);
  padding: 74px 0 96px;
}

.hero-copy {
  max-width: 720px;
}

.eyebrow {
  margin: 0 0 16px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 20px;
  font-size: 4.9rem;
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  font-size: 1.18rem;
  letter-spacing: 0;
}

.hero-lead,
.auth-copy p,
.console-title p {
  color: #bac6d3;
  font-size: 1.12rem;
  line-height: 1.8;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 32px;
}

.signal-panel,
.auth-form,
.panel,
.stat-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.signal-panel {
  padding: 26px;
}

.signal-row,
.panel-heading,
.secret-row,
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.signal-row span,
.metric-grid span,
.stat-card span,
.list-meta,
.muted {
  color: var(--muted);
}

.signal-row strong {
  color: var(--teal);
}

.signal-path {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 32px 0;
}

.signal-path::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.8), transparent);
}

.signal-path span {
  position: relative;
  height: 86px;
  border: 1px solid rgba(59, 130, 246, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(rgba(59, 130, 246, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59, 130, 246, 0.08) 1px, transparent 1px);
  background-size: 18px 18px;
}

.metric-grid,
.stat-grid,
.feature-grid,
.keys-layout,
.console-grid {
  display: grid;
  gap: 18px;
}

.metric-grid {
  grid-template-columns: repeat(2, 1fr);
  margin-top: 28px;
}

.metric-grid div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.metric-grid strong,
.metric-grid span {
  display: block;
}

.feature-band {
  position: relative;
  z-index: 1;
  padding: 0 0 64px;
}

.feature-grid {
  grid-template-columns: repeat(3, 1fr);
}

.feature-card {
  min-height: 210px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.feature-card p {
  color: var(--muted);
  line-height: 1.7;
}

.feature-mark {
  display: block;
  width: 32px;
  height: 4px;
  margin-bottom: 34px;
  border-radius: 999px;
  background: var(--teal);
}

.feature-mark.accent {
  background: var(--rose);
}

.feature-mark.warm {
  background: var(--amber);
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
  gap: 54px;
  align-items: center;
  min-height: calc(100vh - 76px);
  padding: 54px 0;
}

.auth-copy h1,
.console-title h1 {
  font-size: 3rem;
  line-height: 1.05;
}

.auth-form,
.panel {
  padding: 26px;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  color: #d8e0ea;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  padding: 0 14px;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  background: rgba(8, 12, 18, 0.72);
}

input {
  min-height: 46px;
}

select {
  min-height: 46px;
}

textarea {
  min-height: 132px;
  padding-block: 12px;
  line-height: 1.45;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.form-status {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--amber);
}

.key-countdown {
  min-height: 24px;
  margin: -4px 0 16px;
  color: var(--amber);
  font-weight: 750;
}

.form-status.error {
  color: var(--danger);
}

.notice-banner {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid rgba(245, 158, 11, 0.42);
  border-radius: 8px;
  color: #fed7aa;
  background: rgba(245, 158, 11, 0.1);
  line-height: 1.6;
}

.console-shell {
  padding: 42px 0 70px;
}

.console-title {
  margin-bottom: 28px;
}

.console-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.console-title-row > div:first-child {
  min-width: 0;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding-bottom: 6px;
}

.stat-grid {
  grid-template-columns: repeat(6, 1fr);
  margin-bottom: 18px;
}

.stat-card {
  min-height: 132px;
  padding: 22px;
}

.stat-card.panel {
  background:
    linear-gradient(180deg, rgba(59, 130, 246, 0.045), transparent),
    var(--panel);
}

.stat-card strong {
  display: block;
  margin-top: 18px;
  font-size: 2.1rem;
}

.console-grid {
  grid-template-columns: 0.82fr 1.18fr;
}

.usage-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
}

.dashboard-logs {
  display: grid;
  margin-top: 18px;
}

.single-panel-grid {
  display: grid;
  grid-template-columns: minmax(320px, 760px);
}

.dashboard-logs .panel {
  min-height: 360px;
}

.security-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.72fr) minmax(0, 1fr);
  gap: 18px;
}

.agent-grid {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.56fr);
  margin-bottom: 18px;
}

.keys-layout {
  grid-template-columns: minmax(300px, 0.7fr) minmax(0, 1fr);
  margin-bottom: 18px;
}

.admin-binding-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin-bottom: 18px;
}

.tab-bar {
  display: inline-flex;
  gap: 6px;
  margin-bottom: 18px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.tab-button {
  min-height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.tab-button.active {
  color: #ffffff;
  background: var(--teal);
}

.tab-panel[hidden] {
  display: none;
}

.panel-heading {
  margin-bottom: 18px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.panel-heading h2,
.key-result h2,
.key-create h2 {
  margin-bottom: 0;
}

.panel-heading a {
  color: var(--teal);
  font-weight: 750;
}

.list-view {
  display: grid;
  gap: 10px;
}

.list-item {
  min-height: 68px;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.list-item:hover {
  border-color: rgba(148, 163, 184, 0.28);
  background: rgba(255, 255, 255, 0.052);
}

.list-item > div:first-child {
  min-width: 0;
}

.agent-item {
  align-items: stretch;
  flex-direction: column;
}

.agent-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.agent-summary > div:first-child {
  min-width: 0;
}

.agent-edit-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.agent-edit-form[hidden] {
  display: none;
}

.agent-edit-form label {
  margin-bottom: 0;
}

.full-field {
  grid-column: 1 / -1;
}

.edit-actions {
  display: flex;
  gap: 10px;
}

.compact-form {
  margin-bottom: 18px;
}

.member-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.member-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.chip-button {
  border: 0;
  color: var(--danger);
  background: transparent;
  cursor: pointer;
}

.list-title {
  display: block;
  margin-bottom: 4px;
  font-weight: 800;
}

.list-meta {
  display: block;
  line-height: 1.45;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 28px;
  min-width: 52px;
  padding: 0 10px;
  border-radius: 999px;
  color: #052e16;
  background: var(--success);
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

.status-pill.revoked {
  color: #450a0a;
  background: var(--danger);
}

.key-actions {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.key-actions .button {
  min-width: 72px;
  padding-inline: 14px;
}

.danger-button {
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.38);
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.08);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 1.25rem;
  cursor: pointer;
}

.modal-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
}

.wide-dialog {
  width: min(980px, calc(100vw - 32px));
}

.modal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(6px);
}

.modal-card {
  display: grid;
  gap: 16px;
  max-height: min(760px, calc(100vh - 32px));
  margin: 0;
  padding: 24px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-solid);
  box-shadow: var(--shadow);
}

.modal-card label {
  margin-bottom: 0;
}

.modal-card .key-result {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(59, 130, 246, 0.32);
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.08);
}

.key-result-card {
  padding: 16px;
  border: 1px solid rgba(59, 130, 246, 0.32);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(59, 130, 246, 0.09), rgba(17, 24, 32, 0.96)),
    var(--panel-solid);
}

.key-created-dialog {
  width: min(760px, calc(100vw - 32px));
}

.key-result-card p {
  color: var(--muted);
  line-height: 1.6;
}

.modal-heading,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-heading h2 {
  margin-bottom: 0;
}

.modal-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.modal-subtitle {
  margin: -4px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.member-manager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.member-manager h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.policy-form {
  display: grid;
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.policy-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.advanced-fields {
  padding: 10px 0 0;
}

.advanced-fields summary {
  color: var(--teal);
  font-weight: 800;
  cursor: pointer;
}

.nested-policy-grid {
  margin-top: 14px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  min-height: 46px;
}

.checkbox-label input {
  width: auto;
  min-height: auto;
  margin: 0 10px 0 0;
}

.secret-row {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 12, 18, 0.72);
}

.env-block {
  max-height: 220px;
  overflow: auto;
  margin: 14px 0 0;
  padding: 12px;
  color: #d8e0ea;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 12, 18, 0.72);
  white-space: pre-wrap;
}

code {
  overflow-wrap: anywhere;
  color: var(--teal);
}

@media (max-width: 880px) {
  .shell {
    width: min(100% - 28px, 640px);
  }

  .site-header {
    min-height: auto;
    padding: 18px 14px;
  }

  .nav-links {
    gap: 10px;
    font-size: 0.88rem;
  }

  .hero,
  .auth-layout,
  .console-grid,
  .usage-grid,
  .security-grid,
  .agent-grid,
  .admin-binding-grid,
  .keys-layout {
    grid-template-columns: 1fr;
  }

  .console-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .page-actions {
    justify-content: flex-start;
    padding-bottom: 0;
  }

  .hero {
    min-height: auto;
    padding: 56px 0 40px;
  }

  h1 {
    font-size: 3.2rem;
  }

  .auth-copy h1,
  .console-title h1 {
    font-size: 2.35rem;
  }

  .feature-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .site-header,
  .nav-links,
  .hero-actions,
  .signal-row,
  .panel-heading,
  .page-actions,
  .panel-actions,
  .agent-summary,
  .secret-row,
  .list-item {
    align-items: stretch;
    flex-direction: column;
  }

  .button,
  .nav-links a,
  .nav-button,
  .key-actions {
    width: 100%;
  }

  .key-actions {
    flex-wrap: wrap;
  }

  .agent-edit-form {
    grid-template-columns: 1fr;
  }

  .tab-bar,
  .modal-actions,
  .edit-actions {
    flex-direction: column;
  }

  .tab-button,
  .member-manager,
  .policy-grid {
    width: 100%;
  }

  .member-manager,
  .policy-grid {
    grid-template-columns: 1fr;
  }
}
