:root {
  color-scheme: dark;
  --bg: #111318;
  --band: #171b22;
  --panel: #1e232c;
  --panel-2: #242a34;
  --line: #343c49;
  --text: #edf1f7;
  --muted: #9ca8b8;
  --ok: #3fb984;
  --active: #4f9cff;
  --warning: #d7a545;
  --critical: #e35d6a;
  --chip: #303846;
}

* {
  box-sizing: border-box;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 19, 24, 0.96);
  backdrop-filter: blur(10px);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  font-weight: 700;
}

h2 {
  font-size: 15px;
  font-weight: 700;
}

#subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px 22px 36px;
}

.toolbar,
.filterBar {
  display: flex;
  align-items: center;
  gap: 8px;
}

button,
.toggle {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

button {
  padding: 0 12px;
  cursor: pointer;
}

button:hover,
.filter.active {
  border-color: var(--active);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  color: var(--muted);
}

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

.metric,
.panel,
.sessionItem,
.agentRow {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric {
  min-height: 82px;
  padding: 14px;
}

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

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  line-height: 1;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 12px;
  margin-bottom: 12px;
}

.panel {
  margin-bottom: 12px;
  overflow: hidden;
}

.panelHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--band);
}

.agentList,
.priorityList,
.gatewayBox,
.logsList {
  padding: 12px;
}

.agentList {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.agentRow {
  padding: 12px;
}

.agentTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.agentName {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agentStats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.chip,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--chip);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.status {
  border: 1px solid transparent;
}

.status.ok {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
}

.status.active {
  color: var(--active);
  border-color: color-mix(in srgb, var(--active) 40%, transparent);
}

.status.warning {
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 50%, transparent);
}

.status.critical {
  color: var(--critical);
  border-color: color-mix(in srgb, var(--critical) 50%, transparent);
}

.priorityList {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
}

.sessionItem {
  padding: 12px;
  border-left: 4px solid var(--line);
}

.sessionItem.critical {
  border-left-color: var(--critical);
}

.sessionItem.warning {
  border-left-color: var(--warning);
}

.sessionItem.active {
  border-left-color: var(--active);
}

.sessionTitle {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.sessionTitle strong {
  overflow-wrap: anywhere;
  font-size: 14px;
  min-width: 0;
}

.sessionMeta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  min-width: 0;
}

.sessionMeta .chip {
  max-width: 100%;
  white-space: normal;
}

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

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

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

td {
  overflow-wrap: anywhere;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.gatewayLine {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.gatewayLine:last-child {
  border-bottom: 0;
}

.logBlock {
  margin-bottom: 10px;
}

.logBlock:last-child {
  margin-bottom: 0;
}

.logTitle {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

pre {
  max-height: 220px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #0d0f13;
  color: #c9d2de;
  font-size: 12px;
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  .topbar,
  .panelHead {
    align-items: flex-start;
    flex-direction: column;
  }

  .metrics,
  .split {
    grid-template-columns: 1fr;
  }

  main {
    padding: 12px;
  }

  .topbar {
    padding: 14px 12px;
  }
}
