:root {
  color-scheme: dark;
  --bg: #07090d;
  --bg-elevated: #0a0e14;
  --sidebar: #0b0f16;
  --panel: #101620;
  --panel-strong: #151d29;
  --panel-soft: #0d121a;
  --line: #273142;
  --line-strong: #37445a;
  --text: #f4f7fb;
  --muted: #91a0b5;
  --muted-strong: #b7c3d4;
  --accent: #7c5cff;
  --accent-strong: #9f7cff;
  --accent-soft: #221b44;
  --success: #20d3a7;
  --success-soft: #11352d;
  --warning: #ffb84d;
  --warning-soft: #382a13;
  --danger: #ff5c7a;
  --danger-soft: #3b1823;
  --sidebar-width: 292px;
  --header-height: 112px;
  --content-width: 1480px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% 0%, rgba(124, 92, 255, 0.13), transparent 32rem),
    var(--bg);
  color: var(--text);
}

body.app-page {
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  padding: 0.7rem 1rem;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel-strong);
  color: var(--text);
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

button:hover:not(:disabled) {
  border-color: #596780;
  background: #1a2432;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(124, 92, 255, 0.45);
  outline-offset: 2px;
}

.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  font-weight: 800;
}

.primary:hover:not(:disabled) {
  border-color: transparent;
  background: linear-gradient(135deg, #8768ff, #ad8cff);
}

.secondary {
  background: #18212e;
}

.ghost {
  background: transparent;
}

.full {
  width: 100%;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-150%);
  transition: transform 120ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-frame {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.app-sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 640px;
  padding: 1.15rem;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(124, 92, 255, 0.08), transparent 13rem),
    var(--sidebar);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: 66px;
  padding: 0.55rem 0.55rem 1.15rem;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 15px;
  background: linear-gradient(135deg, var(--accent), #3c2a7d);
  box-shadow: 0 12px 30px rgba(82, 55, 178, 0.3);
  font-weight: 950;
  letter-spacing: 0.08em;
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand strong {
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.sidebar-brand div > span {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.side-nav {
  flex: 1;
  min-height: 0;
  padding: 0.8rem 0.15rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.nav-group + .nav-group {
  margin-top: 1.15rem;
}

.nav-label {
  margin: 0 0 0.42rem;
  padding: 0 0.65rem;
  color: #6f7c90;
  font-size: 0.66rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.nav-item {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  min-height: 58px;
  margin: 0.22rem 0;
  padding: 0.62rem 0.7rem;
  border-color: transparent;
  background: transparent;
  color: var(--muted-strong);
  text-align: left;
}

.nav-item:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.04);
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
  border-color: rgba(124, 92, 255, 0.28);
  background: linear-gradient(90deg, rgba(124, 92, 255, 0.18), rgba(124, 92, 255, 0.06));
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-item svg {
  width: 21px;
  height: 21px;
  margin: auto;
  fill: currentColor;
  color: #7f8ca0;
}

.nav-item.active svg {
  color: #b6a6ff;
}

.nav-item strong,
.nav-item small {
  display: block;
  min-width: 0;
}

.nav-item strong {
  font-size: 0.88rem;
  font-weight: 760;
}

.nav-item small {
  margin-top: 0.13rem;
  overflow: hidden;
  color: #758399;
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item.active small {
  color: #a4afbf;
}

.sidebar-footer {
  display: grid;
  gap: 0.7rem;
  padding: 0.85rem 0.15rem 0;
  border-top: 1px solid var(--line);
}

.sidebar-runtime,
.session-card {
  display: flex;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.025);
}

.sidebar-runtime {
  gap: 0.7rem;
  padding: 0.7rem 0.8rem;
}

.sidebar-runtime small,
.sidebar-runtime strong,
.session-card small,
.session-card strong {
  display: block;
}

.sidebar-runtime small,
.session-card small {
  color: var(--muted);
  font-size: 0.68rem;
}

.sidebar-runtime strong,
.session-card strong {
  max-width: 150px;
  margin-top: 0.1rem;
  overflow: hidden;
  font-size: 0.79rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-card {
  gap: 0.65rem;
  padding: 0.6rem;
}

.session-card > div {
  flex: 1;
  min-width: 0;
}

.session-card form {
  flex: 0 0 auto;
}

.session-avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 35px;
  height: 35px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: #c7bbff;
  font-size: 0.8rem;
  font-weight: 900;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.signout-button {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.sidebar-scrim {
  display: none;
}

.app-main {
  min-width: 0;
}

.workspace-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  min-height: var(--header-height);
  padding: 1.25rem clamp(1rem, 3vw, 2.4rem);
  border-bottom: 1px solid rgba(39, 49, 66, 0.88);
  background: rgba(8, 11, 16, 0.87);
  backdrop-filter: blur(18px);
}

.menu-button {
  display: none;
  margin-right: 0.85rem;
}

.workspace-context {
  min-width: 0;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: #718097;
  font-size: 0.7rem;
  font-weight: 720;
  letter-spacing: 0.04em;
}

.breadcrumbs strong {
  color: #a99aff;
  font-weight: 800;
}

.workspace-context h1 {
  margin: 0.25rem 0 0;
  font-size: clamp(1.45rem, 2.3vw, 2rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.workspace-context p {
  max-width: 720px;
  margin: 0.35rem 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-status {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-left: 1rem;
}

.runtime-pill,
.version-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.48rem;
  min-height: 34px;
  padding: 0.42rem 0.72rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted-strong);
  font-size: 0.73rem;
  font-weight: 780;
  white-space: nowrap;
}

.version-chip {
  color: #b7aaff;
}

.runtime-pill.good {
  border-color: #246e5d;
  background: rgba(17, 53, 45, 0.78);
  color: #7be8cc;
}

.runtime-pill.warning {
  border-color: #735323;
  background: rgba(56, 42, 19, 0.78);
  color: #ffd18a;
}

.runtime-pill.bad {
  border-color: #743449;
  background: rgba(59, 24, 35, 0.78);
  color: #ff9aae;
}

.status-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #667386;
  box-shadow: 0 0 0 4px rgba(102, 115, 134, 0.12);
}

.status-dot.good {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(32, 211, 167, 0.12);
}

.status-dot.warning {
  background: var(--warning);
  box-shadow: 0 0 0 4px rgba(255, 184, 77, 0.12);
}

.status-dot.bad {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 92, 122, 0.12);
}

.workspace-shell {
  width: min(100%, var(--content-width));
  min-height: calc(100vh - var(--header-height));
  margin: 0 auto;
  padding: clamp(1.1rem, 3vw, 2.25rem);
  outline: none;
}

.tab {
  display: none;
  animation: page-enter 180ms ease-out;
}

.tab.active {
  display: block;
}

@keyframes page-enter {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hero,
.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(145deg, var(--panel-strong), var(--panel-soft));
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.27);
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 210px;
  padding: clamp(1.4rem, 3vw, 2.15rem);
}

.command-hero {
  overflow: hidden;
  background:
    radial-gradient(circle at 88% 50%, rgba(124, 92, 255, 0.22), transparent 24rem),
    linear-gradient(145deg, #151c29, #0d1118);
}

.hero h2 {
  margin: 0.35rem 0;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.eyebrow {
  color: var(--success);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.status {
  min-height: 112px;
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: linear-gradient(145deg, #111823, #0d1219);
}

.status strong,
.status span {
  display: block;
}

.status strong {
  margin-bottom: 0.45rem;
  font-size: 0.88rem;
  letter-spacing: 0.05em;
}

.status span {
  color: var(--muted);
  font-size: 0.82rem;
}

.status.up {
  border-color: #206b5b;
  box-shadow: inset 0 3px 0 rgba(32, 211, 167, 0.35);
}

.status.down {
  border-color: #623044;
  box-shadow: inset 0 3px 0 rgba(255, 92, 122, 0.3);
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 1rem;
}

.section-head h2 {
  margin: 0.28rem 0;
  font-size: clamp(1.4rem, 2vw, 1.85rem);
  letter-spacing: -0.025em;
}

.section-head p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 1rem;
}

.card {
  padding: 1.35rem;
}

.card h3 {
  margin-top: 0;
}

.grid {
  display: grid;
  gap: 1rem;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.span-two {
  grid-column: 1 / -1;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  color: #d9e1ed;
  font-size: 0.88rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.78rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: #090d13;
  color: var(--text);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--line-strong);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

textarea {
  min-height: 118px;
  resize: vertical;
}

.field-row {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
}

.field-row label {
  flex: 1;
}

.hint {
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.45;
}

.configured {
  color: var(--success);
  font-size: 0.77rem;
}

.toggle {
  flex-direction: row;
  align-items: center;
  align-self: end;
  min-height: 44px;
}

.toggle input {
  width: auto;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr);
  gap: 1rem;
}

pre {
  max-height: 620px;
  padding: 1rem;
  overflow: auto;
  border: 1px solid #171f2b;
  border-radius: 12px;
  background: #05070a;
  color: #b9c7d9;
  white-space: pre-wrap;
  word-break: break-word;
}

.audit-item {
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
}

.audit-item:last-child {
  border-bottom: 0;
}

.audit-item time,
.audit-item small {
  display: block;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 70;
  display: none;
  max-width: min(430px, calc(100vw - 2rem));
  padding: 0.95rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #18212e;
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.5);
}

.toast.show {
  display: block;
  animation: toast-enter 160ms ease-out;
}

.toast.error {
  border-color: var(--danger);
}

@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.auth-page {
  display: grid;
  min-height: 100vh;
  padding: 2rem;
  place-items: center;
}

.auth-card {
  width: min(460px, 100%);
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.35);
}

.auth-card.wide {
  width: min(900px, 100%);
}

.auth-card section {
  margin: 2rem 0;
}

.auth-card h2 {
  color: var(--muted);
  font-size: 1rem;
}

.auth-card form > label {
  margin: 1rem 0;
}

.alert {
  margin: 1rem 0;
  padding: 0.9rem;
  border-radius: 10px;
}

.alert.error {
  background: #3a1620;
  color: #ffb7c5;
}

.operations-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.metric-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 126px;
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(145deg, #151b27, #0d1118);
}

.metric-card > span:first-child {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.metric-card > strong {
  font-size: 1.35rem;
}

.operations-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.operations-block {
  margin-top: 1rem;
}

.operations-empty h3 {
  margin: 0.5rem 0;
}

.operations-empty p {
  margin-bottom: 0;
  color: var(--muted);
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-title-row h3 {
  margin: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  max-width: 100%;
  padding: 0.28rem 0.58rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 820;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
}

.badge.good {
  border-color: #246e5d;
  background: var(--success-soft);
  color: #7be8cc;
}

.badge.warning {
  border-color: #735323;
  background: var(--warning-soft);
  color: #ffd18a;
}

.badge.bad {
  border-color: #743449;
  background: var(--danger-soft);
  color: #ff9aae;
}

.badge.neutral {
  background: #171e29;
  color: var(--muted-strong);
}

.detail-list {
  margin-top: 1rem;
}

.detail-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.72rem 0;
  border-bottom: 1px solid var(--line);
}

.detail-row:last-child {
  border-bottom: 0;
}

.detail-row > span:first-child {
  color: var(--muted);
  font-size: 0.84rem;
}

.detail-row > strong {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

code {
  padding: 0.15rem 0.35rem;
  border: 1px solid #242d3d;
  border-radius: 6px;
  background: #0a0e14;
  color: #c9bcff;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.table-wrap {
  margin-top: 1rem;
  overflow: auto;
}

.operations-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.operations-table th,
.operations-table td {
  padding: 0.78rem 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.operations-table th {
  color: var(--muted);
  font-size: 0.69rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.operations-table tbody tr:last-child td {
  border-bottom: 0;
}

.empty-cell {
  padding: 1.5rem !important;
  color: var(--muted);
  text-align: center !important;
}

.operations-log {
  max-height: 360px;
  margin: 1rem 0 0;
  border-color: #202a39;
}

.danger-text {
  color: #ff9aae;
}

.operations-empty[hidden],
#operations-content[hidden] {
  display: none;
}

@media (max-width: 1180px) {
  .operations-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .operations-layout,
  .split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  :root {
    --header-height: 104px;
  }

  .app-frame {
    display: block;
  }

  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(var(--sidebar-width), calc(100vw - 3rem));
    min-height: 100vh;
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  body.nav-open {
    overflow: hidden;
  }

  body.nav-open .app-sidebar {
    transform: translateX(0);
  }

  .sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(2, 4, 9, 0.72);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  body.nav-open .sidebar-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .menu-button {
    display: inline-grid;
  }

  .workspace-bar {
    padding-inline: 1rem;
  }

  .workspace-status .version-chip {
    display: none;
  }
}

@media (max-width: 680px) {
  :root {
    --header-height: 96px;
  }

  .workspace-bar {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: flex-start;
  }

  .workspace-context p,
  .breadcrumbs > span:first-child,
  .workspace-status {
    display: none;
  }

  .workspace-context h1 {
    margin-top: 0.38rem;
  }

  .workspace-shell {
    padding: 1rem;
  }

  .hero,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-head > button,
  .section-head > .actions,
  .hero > .actions {
    width: 100%;
  }

  .section-head > button,
  .actions button {
    flex: 1;
  }

  .grid.two {
    grid-template-columns: 1fr;
  }

  .span-two {
    grid-column: auto;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .operations-summary {
    grid-template-columns: 1fr;
  }

  .detail-row {
    flex-direction: column;
    gap: 0.35rem;
  }

  .detail-row > strong {
    text-align: left;
  }

  .toast {
    right: 1rem;
    bottom: 1rem;
    left: 1rem;
    max-width: none;
  }
}

@media (max-width: 440px) {
  .workspace-context h1 {
    font-size: 1.3rem;
  }

  .hero {
    min-height: 190px;
  }

  .hero h2 {
    font-size: 2.2rem;
  }

  .card,
  .metric-card {
    padding: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
