:root {
  color-scheme: dark;
  --bg: #07131b;
  --bg-accent: #0d2430;
  --panel: rgba(9, 29, 39, 0.88);
  --panel-strong: rgba(7, 22, 31, 0.96);
  --line: rgba(113, 176, 190, 0.18);
  --line-strong: rgba(113, 176, 190, 0.34);
  --text: #eef6f7;
  --muted: #91abb3;
  --teal: #4fd6cf;
  --gold: #f7c065;
  --danger: #ff8577;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  --radius: 22px;
  --radius-sm: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(79, 214, 207, 0.12), transparent 28%),
    radial-gradient(circle at bottom right, rgba(247, 192, 101, 0.1), transparent 24%),
    linear-gradient(180deg, #08161f 0%, #050d13 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.is-hidden {
  display: none !important;
}

.login-screen {
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.login-card {
  width: min(100%, 460px);
  padding: 32px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(9, 29, 39, 0.96), rgba(7, 22, 31, 0.96));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  gap: 22px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(79, 214, 207, 0.12);
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

h2 {
  font-size: 1.06rem;
}

h3 {
  font-size: 0.94rem;
}

.lead,
.muted-copy,
.helper-text,
.user-chip span,
.row-card small,
.detail-stack span,
.panel-card p,
.map-status,
.login-error {
  color: var(--muted);
}

.stack-form,
.compact-form,
.inline-form {
  display: grid;
  gap: 12px;
}

.compact-form {
  gap: 10px;
}

.inline-form {
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
}

input,
select {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(79, 214, 207, 0.12);
}

.primary-button,
.secondary-button,
.ghost-button,
.action-link,
.nav-tab,
.logout-button,
.refresh-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--teal), #2ba6c8);
  color: #032531;
  font-weight: 700;
}

.secondary-button {
  background: rgba(79, 214, 207, 0.12);
  color: var(--teal);
  border: 1px solid rgba(79, 214, 207, 0.18);
}

.ghost-button,
.action-link,
.refresh-button,
.logout-button,
.nav-tab {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border: 1px solid var(--line);
}

.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.nav-tab.is-active {
  background: rgba(79, 214, 207, 0.12);
  border-color: rgba(79, 214, 207, 0.28);
  color: var(--teal);
}

.portal-app {
  height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
}

.sidebar {
  padding: 24px 20px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(9, 29, 39, 0.92), rgba(7, 22, 31, 0.96));
  display: grid;
  grid-template-rows: auto auto auto 1fr auto auto;
  gap: 18px;
  overflow: hidden;
}

.brand-block {
  display: grid;
  gap: 8px;
}

.brand-mark {
  font-size: 2rem;
  letter-spacing: -0.05em;
}

.role-badge {
  display: inline-flex;
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(247, 192, 101, 0.12);
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 700;
}

.user-chip {
  display: grid;
  gap: 4px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.secret-panel {
  display: grid;
  gap: 10px;
  min-height: 0;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.secret-meta {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
}

.secret-output,
.map-details,
code {
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.main-shell {
  min-width: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(3, 11, 16, 0.28);
}

.view-root {
  min-height: 0;
  overflow: auto;
  padding: 24px 28px 28px;
}

.panel-grid {
  display: grid;
  gap: 18px;
}

.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-grid {
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
}

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

.panel-card,
.metric-card,
.sub-card {
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.panel-card,
.sub-card {
  padding: 18px;
  display: grid;
  gap: 16px;
}

.metric-card {
  padding: 18px;
  display: grid;
  gap: 6px;
}

.metric-card strong {
  font-size: 1.8rem;
  letter-spacing: -0.05em;
}

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

.list-stack,
.table-stack {
  display: grid;
  gap: 10px;
  min-height: 0;
}

.tall-stack {
  max-height: calc(100vh - 280px);
  overflow: auto;
  padding-right: 4px;
}

.row-card,
.list-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.list-item {
  width: 100%;
  text-align: left;
  color: inherit;
}

.list-item.is-selected {
  border-color: rgba(79, 214, 207, 0.42);
  background: rgba(79, 214, 207, 0.08);
}

.row-card > div,
.list-item {
  display: grid;
  gap: 4px;
}

.detail-stack {
  display: grid;
  gap: 12px;
}

.detail-stack div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.empty-state,
.empty-inline {
  padding: 18px;
  border-radius: 16px;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}

.plain-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
  color: var(--muted);
}

.ordered-list {
  list-style: decimal;
  display: block;
  padding-left: 20px;
}

.ordered-list li + li {
  margin-top: 10px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.integration-grid {
  align-items: start;
}

.integration-span {
  grid-column: 1 / -1;
}

.code-block {
  margin: 0;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  overflow: auto;
}

.manifest-block {
  max-height: 220px;
}

.tall-code {
  max-height: 420px;
}

.map-view-shell {
  height: calc(100vh - 152px);
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  overflow: hidden;
}

.map-sidebar {
  min-height: 0;
  display: grid;
  gap: 18px;
  align-content: start;
  overflow: auto;
}

.map-stage {
  min-width: 0;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.portal-map {
  width: 100%;
  height: 100%;
}

.map-status[data-kind="error"] {
  color: var(--danger);
}

.map-status[data-kind="warn"] {
  color: var(--gold);
}

.login-error {
  min-height: 20px;
}

@media (max-width: 1180px) {
  .portal-app {
    grid-template-columns: 280px minmax(0, 1fr);
  }

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

  .two-up,
  .admin-grid,
  .map-view-shell {
    grid-template-columns: 1fr;
  }

  .map-view-shell {
    height: auto;
  }

  .portal-map {
    min-height: 420px;
  }
}

@media (max-width: 860px) {
  body,
  html {
    overflow: auto;
  }

  .portal-app {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
  }

  .sidebar,
  .main-shell,
  .view-root {
    height: auto;
    overflow: visible;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
