:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --line: #d7e0dc;
  --text: #17211d;
  --muted: #69766f;
  --green: #28735f;
  --green-dark: #1d5a4a;
  --blue: #2563eb;
  --amber: #b45309;
  --red: #b42318;
  --shadow: 0 18px 48px rgba(22, 33, 29, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.sprite {
  display: none;
}

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

.sidebar {
  background: #fbfcfb;
  border-right: 1px solid var(--line);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #1c332c;
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
}

.nav-item svg,
.button svg,
.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.nav-item.active,
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.sidebar-footer {
  margin-top: auto;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  flex: 0 0 auto;
}

.dot.online {
  background: var(--green);
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  min-height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
  line-height: 1.25;
}

.topbar p {
  color: var(--muted);
  margin-top: 6px;
}

.top-actions,
.session,
.auth-actions,
.inline-form,
.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.session {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 6px 0 12px;
}

#userName {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 14px;
}

.button,
.icon-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
}

.button {
  padding: 0 14px;
  font-weight: 650;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.button.primary {
  background: var(--green);
  border-color: var(--green);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--green-dark);
}

.button.ghost:hover,
.icon-button:hover {
  background: var(--surface-2);
}

.auth-panel,
.panel,
.metric,
.alert {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 18px;
  padding: 18px;
  margin-bottom: 18px;
}

.auth-panel.hidden,
.hidden {
  display: none;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select {
  min-height: 38px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 0 10px;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.3);
  outline-offset: 2px;
}

.inline-form {
  margin-top: 8px;
}

.inline-form input {
  min-width: min(520px, 54vw);
}

.alert {
  padding: 12px 14px;
  margin-bottom: 18px;
  color: var(--red);
  border-color: rgba(180, 35, 24, 0.26);
  box-shadow: none;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

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

.metric {
  min-height: 96px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.metric strong {
  font-size: 30px;
  line-height: 1;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.7fr);
  gap: 18px;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel-header {
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-header select {
  width: min(260px, 48vw);
}

.topology {
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(40, 115, 95, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 99, 235, 0.06) 1px, transparent 1px),
    #fbfcfb;
  background-size: 32px 32px;
  overflow: hidden;
}

.topology svg {
  display: block;
  width: 100%;
  height: 420px;
}

.topology .link {
  stroke: rgba(40, 115, 95, 0.42);
  stroke-width: 2;
}

.topology .node {
  fill: #ffffff;
  stroke: var(--green);
  stroke-width: 2;
}

.topology .node.self {
  stroke: var(--blue);
}

.topology text {
  fill: var(--text);
  font-size: 13px;
}

.empty-state {
  height: 420px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.form {
  display: grid;
  gap: 12px;
}

.form .button {
  justify-self: start;
  margin-top: 4px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

td {
  font-size: 14px;
}

.mono {
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e7f0ed;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 700;
  margin: 0 4px 4px 0;
}

pre {
  min-height: 220px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111815;
  color: #e9f5ef;
  padding: 14px;
  font-size: 13px;
  line-height: 1.55;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 12px;
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }

  .brand span,
  .sidebar-footer {
    display: none;
  }

  .nav {
    display: flex;
    overflow-x: auto;
  }

  .nav-item {
    width: auto;
    flex: 0 0 auto;
  }

  .main {
    padding: 16px;
  }

  .metrics,
  .workspace-grid,
  .auth-panel {
    grid-template-columns: 1fr;
  }

  .auth-actions,
  .inline-form,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-form input {
    min-width: 0;
  }

  .top-actions {
    justify-content: space-between;
  }
}

@media (max-width: 560px) {
  .brand strong {
    display: none;
  }

  .nav-item span {
    display: none;
  }

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

  .metric {
    min-height: 82px;
  }

  .metric strong {
    font-size: 24px;
  }

  h1 {
    font-size: 24px;
  }
}
