:root {
  --ink: #17211e;
  --ink-soft: #37433f;
  --muted: #68736f;
  --line: #dfe5e2;
  --line-strong: #cbd4d0;
  --paper: #f4f7f5;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --teal: #087f6a;
  --teal-dark: #056452;
  --teal-soft: #e5f4ef;
  --amber: #a96513;
  --amber-soft: #fff3de;
  --red: #b42318;
  --red-soft: #fff1f0;
  --blue: #356c9b;
  --blue-soft: #edf4fa;
  --shadow: 0 12px 32px rgba(18, 37, 31, 0.08);
  --radius: 8px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-width: 1180px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(8, 127, 106, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(8, 127, 106, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  font-family: "Avenir Next", "Noto Sans SC", ui-sans-serif, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.agent-item:focus-visible {
  outline: 3px solid rgba(8, 127, 106, 0.18);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.large-icon {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.brand-lockup,
.topbar-meta,
.title-row,
.agent-subline,
.head-actions,
.live-state,
.form-actions,
.browser-controls {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 13px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: var(--radius);
  color: #fff;
  background: var(--teal);
  font-size: 12px;
  font-weight: 800;
}

.brand-lockup h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 750;
}

.topbar-meta {
  gap: 10px;
}

.test-chip,
.count-chip,
.keyboard-hint {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface-soft);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 650;
  white-space: nowrap;
}

.live-state {
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.live-state > span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
}

.live-state.online > span {
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(8, 127, 106, 0.12);
}

.workspace {
  display: grid;
  width: min(1500px, calc(100vw - 40px));
  min-height: calc(100vh - 104px);
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 16px;
  margin: 20px auto 40px;
}

.agent-rail,
.content-shell {
  min-width: 0;
}

.agent-rail {
  position: sticky;
  top: 92px;
  align-self: start;
  max-height: calc(100vh - 112px);
  padding: 18px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.rail-head,
.surface-head,
.agent-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.rail-head h2,
.agent-head h2,
.surface-head h3,
.no-agent-view h2 {
  margin: 0;
  letter-spacing: 0;
}

.rail-head h2 {
  font-size: 18px;
}

.count-chip {
  min-width: 28px;
  justify-content: center;
  color: var(--teal);
  background: var(--teal-soft);
}

.fleet-summary {
  display: flex;
  gap: 14px;
  margin: 17px 0 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.fleet-summary strong {
  color: var(--ink);
  font-size: 12px;
}

.agent-list {
  display: grid;
  gap: 8px;
}

.agent-item {
  display: grid;
  width: 100%;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  text-align: left;
  background: var(--surface);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.agent-item:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.agent-item:active {
  transform: translateY(1px);
}

.agent-item.active {
  border-color: rgba(8, 127, 106, 0.45);
  background: var(--teal-soft);
}

.agent-item strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-item small {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.agent-item .agent-item-status {
  align-self: start;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.agent-item .agent-item-status.online {
  color: var(--teal);
}

.rail-empty,
.no-agent-view,
.panel-empty,
.browser-empty {
  color: var(--muted);
  text-align: center;
}

.rail-empty {
  display: grid;
  justify-items: center;
  gap: 9px;
  padding: 44px 10px;
  font-size: 12px;
}

.rail-empty strong {
  color: var(--ink);
}

.empty-glyph {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--teal);
  background: var(--surface-soft);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 750;
}

.content-shell {
  min-height: 620px;
}

.no-agent-view {
  display: grid;
  min-height: 520px;
  place-content: center;
  padding: 30px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
}

.no-agent-view h2 {
  margin: 8px 0 6px;
  color: var(--ink);
  font-size: 24px;
}

.no-agent-view p {
  max-width: 400px;
  margin: 0;
  line-height: 1.7;
}

.agent-view {
  display: grid;
  gap: 14px;
}

.agent-head {
  padding: 20px 22px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface);
}

.agent-identity,
.title-row,
.head-actions,
.browser-controls {
  gap: 10px;
}

.agent-identity {
  display: flex;
  min-width: 0;
  align-items: center;
}

.agent-monogram {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--teal);
  background: var(--surface-soft);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 800;
}

.agent-head h2 {
  font-size: 21px;
}

.status-badge {
  display: inline-flex;
  min-height: 23px;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--muted);
  background: #eef2f0;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8d9893;
  content: "";
}

.status-badge.online {
  color: #075e4f;
  background: var(--teal-soft);
}

.status-badge.online::before {
  background: var(--teal);
}

.status-badge.offline {
  color: #76521a;
  background: var(--amber-soft);
}

.status-badge.offline::before {
  background: var(--amber);
}

.agent-subline {
  gap: 7px;
  margin-top: 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.separator {
  width: 1px;
  height: 11px;
  background: var(--line);
}

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink);
  font-weight: 650;
  white-space: nowrap;
  transition: background 150ms ease, border-color 150ms ease, opacity 150ms ease;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.button.primary {
  color: #fff;
  background: var(--teal);
}

.button.primary:hover:not(:disabled) {
  background: var(--teal-dark);
}

.button.ghost {
  border-color: var(--line);
  background: var(--surface);
}

.button.ghost:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.button.compact {
  min-height: 32px;
  padding: 0 10px;
  font-size: 11px;
}

.button.square {
  width: 36px;
  min-height: 36px;
  padding: 0;
}

.endpoint-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-top: -1px;
  padding: 11px 22px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-soft);
  font-family: var(--mono);
  font-size: 10px;
}

.endpoint-strip code {
  overflow: hidden;
  color: var(--ink-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.endpoint-seen {
  white-space: nowrap;
}

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

.metric {
  min-width: 0;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric span,
.metric small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric strong {
  display: block;
  margin: 8px 0 4px;
  overflow: hidden;
  font-size: 20px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.tab {
  min-height: 34px;
  flex: 1;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 650;
}

.tab:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

.tab.active {
  color: var(--ink);
  background: var(--teal-soft);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.surface {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.surface-head {
  margin-bottom: 18px;
}

.surface-head h3 {
  font-size: 17px;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.9fr);
  gap: 14px;
}

.command-surface form {
  display: grid;
  gap: 14px;
}

.proxy-controls {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

.proxy-controls legend {
  padding: 0 5px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
}

.proxy-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.proxy-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--teal);
}

.proxy-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 10px;
}

.proxy-grid input:disabled {
  color: var(--muted);
  background: #eef2f0;
}

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

label > span {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
}

input,
select {
  height: 40px;
  padding: 0 11px;
}

textarea {
  min-height: 190px;
  padding: 11px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--line-strong);
}

.form-actions {
  justify-content: space-between;
  gap: 12px;
}

.form-hint {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.response-surface {
  display: grid;
  min-height: 386px;
  grid-template-rows: auto 1fr;
}

.response-status {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--muted);
  background: #eef2f0;
  font-family: var(--mono);
  font-size: 10px;
}

.response-status.success {
  color: #075e4f;
  background: var(--teal-soft);
}

.response-status.error {
  color: var(--red);
  background: var(--red-soft);
}

.response-code {
  min-height: 0;
  margin: 0;
  padding: 16px;
  overflow: auto;
  border-radius: 7px;
  color: #dce9e4;
  background: #17211e;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.panel-empty {
  display: grid;
  min-height: 180px;
  place-content: center;
  padding: 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  background: var(--surface-soft);
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.container-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  font-size: 12px;
}

.container-table th,
.container-table td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.container-table th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 10px;
  font-weight: 700;
}

.container-table tr:last-child td {
  border-bottom: 0;
}

.container-name {
  font-weight: 650;
}

.container-name code,
.container-ports {
  font-family: var(--mono);
  font-size: 10px;
}

.container-image {
  max-width: 250px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.container-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.container-status::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8d9893;
  content: "";
}

.container-status.running {
  color: var(--teal);
}

.container-status.running::before {
  background: var(--teal);
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
}

.table-action {
  display: inline-flex;
  min-height: 29px;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 10px;
}

.table-action:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.table-action.danger {
  color: var(--red);
}

.browser-head {
  align-items: flex-end;
}

.browser-controls {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 7px;
}

.inline-field > span {
  white-space: nowrap;
}

.inline-field input {
  width: min(300px, 34vw);
  height: 36px;
  font-family: var(--mono);
  font-size: 10px;
}

.browser-stage {
  position: relative;
  display: grid;
  min-height: 540px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #e9efec;
}

.browser-stage iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.browser-empty,
.browser-loading {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  background: var(--surface-soft);
  font-size: 12px;
}

.browser-empty strong {
  color: var(--ink);
  font-size: 15px;
}

.browser-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  animation: pulse 1.2s ease-in-out infinite;
}

.browser-session-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 11px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.browser-session-bar code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-list {
  display: grid;
  gap: 8px;
}

.audit-item {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.audit-item summary {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  cursor: pointer;
  list-style: none;
}

.audit-item summary::-webkit-details-marker {
  display: none;
}

.audit-direction {
  display: inline-flex;
  min-height: 21px;
  align-items: center;
  padding: 0 6px;
  border-radius: 5px;
  color: var(--blue);
  background: var(--blue-soft);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
}

.audit-direction.outbound {
  color: var(--amber);
  background: var(--amber-soft);
}

.audit-endpoint {
  overflow: hidden;
  font-family: var(--mono);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-time {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.audit-payload {
  margin: 0;
  padding: 0 12px 12px;
  overflow: auto;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  padding: 11px 14px;
  border: 1px solid rgba(8, 127, 106, 0.25);
  border-radius: 7px;
  color: #064f42;
  background: #e9f7f2;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-color: rgba(180, 35, 24, 0.25);
  color: var(--red);
  background: var(--red-soft);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.5;
    transform: scale(0.85);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

@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;
  }
}
