:root {
  color: #17211f;
  background: #f5f7f6;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  font-synthesis: none;
  --ink: #17211f;
  --muted: #66736f;
  --faint: #94a09c;
  --line: #dfe5e2;
  --line-strong: #cbd4d0;
  --canvas: #f5f7f6;
  --surface: #ffffff;
  --surface-soft: #f0f4f2;
  --sidebar: #202826;
  --sidebar-muted: #9eaaa6;
  --accent: #087f6d;
  --accent-strong: #056454;
  --accent-soft: #e3f3ef;
  --blue: #3178c6;
  --blue-soft: #e7f0fa;
  --amber: #b66b12;
  --amber-soft: #fbefdc;
  --red: #b94747;
  --red-soft: #fae9e9;
  --shadow: 0 12px 28px rgba(28, 47, 41, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-width: 320px;
  background: var(--canvas);
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(8, 127, 109, 0.18);
  outline-offset: 1px;
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
  flex: 0 0 auto;
}

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

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: 232px;
  flex-direction: column;
  color: #f8fbfa;
  background: var(--sidebar);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 76px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

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

.brand strong,
.brand span {
  display: block;
  letter-spacing: 0;
}

.brand strong {
  font-size: 15px;
}

.brand span {
  margin-top: 3px;
  color: var(--sidebar-muted);
  font-size: 11px;
}

.main-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  padding: 18px 12px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  color: #bcc5c2;
  background: transparent;
  border: 0;
  border-radius: 6px;
  text-align: left;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.nav-item.is-active {
  color: #fff;
  background: var(--accent);
}

.nav-item span {
  white-space: nowrap;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px 14px 12px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.service-state {
  display: flex;
  align-items: center;
  gap: 9px;
}

.service-state strong,
.service-state span {
  display: block;
  font-size: 11px;
}

.service-state span {
  margin-top: 2px;
  color: var(--sidebar-muted);
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.status-good {
  background: #42bd8b;
  box-shadow: 0 0 0 3px rgba(66, 189, 139, 0.16);
}

.status-warn {
  background: #e69b3a;
}

.status-bad {
  background: #d95c5c;
}

.workspace {
  grid-column: 2;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  min-height: 76px;
  padding: 10px 28px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

.page-heading {
  min-width: 0;
}

.page-heading p,
.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.page-heading h1 {
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.prototype-badge {
  padding: 5px 8px;
  color: var(--amber);
  background: var(--amber-soft);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f3f6f7;
}

.login-screen.is-hidden { display: none; }

.login-panel {
  width: min(400px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(20, 40, 46, 0.12);
}

.login-brand { margin-bottom: 32px; }
.login-heading { margin-bottom: 24px; }
.login-heading h1 { margin: 0 0 7px; font-size: 24px; letter-spacing: 0; }
.login-heading p { margin: 0; color: var(--muted); }
.login-panel .form-field { margin-bottom: 16px; }
.login-submit { width: 100%; justify-content: center; margin-top: 8px; }
.form-error { min-height: 20px; margin: 0; color: var(--red); font-size: 13px; }

.empty-state {
  padding: 44px 20px;
  color: var(--muted);
  text-align: center;
}

.loading-state { padding: 64px 20px; color: var(--muted); text-align: center; }
.danger-text { color: var(--red); }
.modal .form-field small { line-height: 1.5; }

.member-config-list { display: grid; gap: 8px; }
.member-config-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 90px 90px;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.member-config-row .check-chip { align-self: center; }
.toast.is-error { background: var(--red); }

.icon-button {
  position: relative;
  display: inline-grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  color: #44514d;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.icon-button:hover {
  color: var(--accent);
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.icon-button.ghost {
  color: inherit;
  background: transparent;
  border-color: transparent;
}

.icon-button.small {
  width: 30px;
  height: 30px;
}

.icon-button.small svg {
  width: 15px;
  height: 15px;
}

.notification-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 6px;
  height: 6px;
  border: 1px solid #fff;
  border-radius: 50%;
  background: var(--red);
}

.admin-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 9px 0 5px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 6px;
}

.admin-chip:hover {
  background: var(--surface-soft);
}

.admin-chip svg {
  width: 14px;
  height: 14px;
}

.avatar {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: #fff;
  background: #49605a;
  border-radius: 6px;
  font-size: 12px;
}

.mobile-menu,
.mobile-scrim {
  display: none;
}

.page-content {
  width: 100%;
  max-width: 1540px;
  margin: 0 auto;
  padding: 24px 28px 40px;
}

.page-content:focus {
  outline: none;
}

.page-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.page-toolbar h2,
.section-heading h2,
.panel-heading h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}

.page-toolbar p,
.section-heading p,
.panel-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.toolbar-actions,
.inline-actions,
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 650;
  white-space: nowrap;
}

.button svg {
  width: 16px;
  height: 16px;
}

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

.button.primary:hover {
  background: var(--accent-strong);
}

.button.secondary {
  color: #34423e;
  background: var(--surface);
  border-color: var(--line-strong);
}

.button.secondary:hover {
  background: var(--surface-soft);
}

.button.danger {
  color: var(--red);
  background: var(--red-soft);
  border-color: #efc9c9;
}

.button.small {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  background: #e9eeec;
  border-radius: 6px;
}

.segment {
  min-height: 30px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 4px;
  font-size: 12px;
}

.segment.is-active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 3px rgba(24, 39, 34, 0.12);
}

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

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

.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.metric-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 6px;
}

.metric-icon.teal {
  color: var(--accent);
  background: var(--accent-soft);
}

.metric-icon.blue {
  color: var(--blue);
  background: var(--blue-soft);
}

.metric-icon.amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.metric-icon.red {
  color: var(--red);
  background: var(--red-soft);
}

.metric-value {
  margin-top: 12px;
  font-size: 25px;
  font-weight: 750;
  line-height: 1.1;
  letter-spacing: 0;
}

.metric-delta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.metric-delta strong {
  color: var(--accent);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(290px, 0.85fr);
  gap: 16px;
}

.stack {
  display: grid;
  gap: 16px;
}

.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 15px 17px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 {
  font-size: 14px;
}

.panel-heading p {
  font-size: 11px;
}

.panel-body {
  padding: 17px;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 11px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-line {
  width: 16px;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.legend-line.blue {
  background: var(--blue);
}

.traffic-chart {
  position: relative;
  height: 220px;
  margin: 6px 3px 0 36px;
  border-bottom: 1px solid var(--line);
  background-image: linear-gradient(to bottom, transparent calc(25% - 1px), var(--line) 25%, transparent calc(25% + 1px)),
    linear-gradient(to bottom, transparent calc(50% - 1px), var(--line) 50%, transparent calc(50% + 1px)),
    linear-gradient(to bottom, transparent calc(75% - 1px), var(--line) 75%, transparent calc(75% + 1px));
}

.chart-y-labels {
  position: absolute;
  inset: 0 auto 0 -36px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: var(--faint);
  font-size: 9px;
}

.chart-bars {
  position: absolute;
  inset: 8px 4px 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
}

.bar-pair {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  height: 100%;
  gap: 2px;
}

.bar {
  width: min(9px, 42%);
  min-height: 3px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  opacity: 0.9;
}

.bar.download {
  background: var(--blue);
  opacity: 0.78;
}

.bar-pair span {
  position: absolute;
  bottom: -20px;
  color: var(--faint);
  font-size: 9px;
}

.health-list,
.usage-list,
.activity-list {
  display: grid;
  gap: 14px;
}

.health-row,
.usage-row,
.activity-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.health-row > div,
.usage-row > div,
.activity-row > div {
  min-width: 0;
  flex: 1;
}

.health-row strong,
.usage-row strong,
.activity-row strong {
  display: block;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health-row small,
.usage-row small,
.activity-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.latency {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.progress {
  height: 6px;
  margin-top: 8px;
  overflow: hidden;
  background: #e7ecea;
  border-radius: 3px;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.progress > span.warning {
  background: var(--amber);
}

.progress > span.danger {
  background: var(--red);
}

.activity-icon {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--muted);
  background: var(--surface-soft);
  border-radius: 6px;
}

.activity-icon svg {
  width: 15px;
  height: 15px;
}

.table-panel {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 57px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.search-box {
  position: relative;
  min-width: 230px;
}

.search-box svg {
  position: absolute;
  top: 50%;
  left: 10px;
  width: 15px;
  height: 15px;
  color: var(--faint);
  transform: translateY(-50%);
}

.search-box input {
  width: 100%;
  height: 34px;
  padding: 0 10px 0 33px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
}

.select-control {
  min-height: 34px;
  padding: 0 30px 0 10px;
  color: #34423e;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

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

th {
  color: var(--muted);
  background: #fafbfa;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: #fbfdfc;
}

.entity-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 150px;
}

.entity-avatar {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 750;
}

.entity-avatar.server {
  color: var(--blue);
  background: var(--blue-soft);
}

.entity-cell strong,
.entity-cell small {
  display: block;
}

.entity-cell small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.badge,
.protocol-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.good {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.badge.warn {
  color: var(--amber);
  background: var(--amber-soft);
}

.badge.bad {
  color: var(--red);
  background: var(--red-soft);
}

.badge.neutral,
.protocol-badge {
  color: #596662;
  background: #edf1ef;
}

.protocol-list {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
}

.text-muted {
  color: var(--muted);
}

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

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.route-path {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: max-content;
}

.route-hop {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 3px 7px;
  color: #4a5753;
  background: #edf1ef;
  border: 1px solid transparent;
  border-radius: 5px;
  white-space: nowrap;
}

.route-hop.exit {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: #b7ddd4;
  font-weight: 700;
}

.route-hop small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 500;
}

.route-arrow {
  display: inline-flex;
  color: var(--faint);
}

.route-arrow svg {
  width: 14px;
  height: 14px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 50px;
  padding: 8px 14px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 11px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex: 0 0 auto;
}

.switch input {
  width: 0;
  height: 0;
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: #c9d1ce;
  transition: 0.18s ease;
}

.switch span::before {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  content: "";
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(27, 45, 39, 0.2);
  transition: 0.18s ease;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::before {
  transform: translateX(16px);
}

.rule-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 16px;
  align-items: start;
}

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

.rule-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 74px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.rule-row.is-disabled {
  opacity: 0.58;
}

.drag-handle {
  color: var(--faint);
  cursor: grab;
}

.rule-main {
  min-width: 0;
}

.rule-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.rule-title strong {
  font-size: 12px;
}

.rule-expression {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 11px;
}

.condition-token,
.action-token {
  padding: 3px 6px;
  color: #43504c;
  background: #edf1ef;
  border-radius: 4px;
}

.action-token {
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-weight: 700;
}

.rule-arrow {
  color: var(--faint);
}

.tester {
  position: sticky;
  top: 96px;
}

.tester-result {
  margin-top: 14px;
  padding: 12px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}

.tester-result strong,
.tester-result span {
  display: block;
}

.tester-result span {
  margin-top: 5px;
  color: #4f625d;
  font-size: 11px;
  line-height: 1.5;
}

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

.form-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.form-field.full {
  grid-column: 1 / -1;
}

.form-field > label,
.form-label {
  color: #35423e;
  font-size: 11px;
  font-weight: 700;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
}

.form-field textarea {
  min-height: 84px;
  resize: vertical;
}

.form-field small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.checkbox-row,
.switch-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
}

.checkbox-row {
  flex-wrap: wrap;
}

.check-chip {
  position: relative;
  display: inline-flex;
}

.check-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.check-chip span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 650;
}

.check-chip input:checked + span {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: #91cbbf;
}

.form-section {
  grid-column: 1 / -1;
  margin: 3px 0 -2px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.form-section strong {
  font-size: 12px;
}

.form-section p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.chain-hop-editor {
  border-top: 1px solid var(--line);
}

.chain-hop-row {
  display: grid;
  grid-template-columns: 28px 74px minmax(180px, 1fr) auto;
  gap: 9px;
  align-items: center;
  min-height: 52px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.hop-index {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: var(--muted);
  background: var(--surface-soft);
  border-radius: 5px;
  font-size: 10px;
  font-weight: 750;
}

.add-hop-button {
  width: max-content;
  margin-top: 9px;
}

.chain-exit-summary {
  display: flex;
  grid-column: 1 / -1;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 12px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}

.chain-exit-summary strong,
.chain-exit-summary span {
  display: block;
}

.chain-exit-summary strong {
  font-size: 11px;
}

.chain-exit-summary span {
  margin-top: 4px;
  color: #50635e;
  font-size: 10px;
  line-height: 1.45;
}

.settings-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.settings-nav {
  display: grid;
  gap: 3px;
}

.settings-nav button {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 5px;
  text-align: left;
}

.settings-nav button.is-active {
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-weight: 700;
}

.settings-section {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.settings-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.settings-section h3 {
  margin: 0 0 4px;
  font-size: 13px;
}

.settings-section > p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 11px;
}

.listener-list {
  border-top: 1px solid var(--line);
}

.listener-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(150px, 1fr) 110px 62px;
  gap: 14px;
  align-items: end;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.listener-identity {
  display: flex;
  align-items: center;
  align-self: center;
  gap: 10px;
  min-width: 0;
}

.listener-identity strong,
.listener-identity small {
  display: block;
}

.listener-identity strong {
  font-size: 12px;
}

.listener-identity small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.listener-toggle {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 12px;
  color: #70511d;
  background: var(--amber-soft);
  border: 1px solid #efd6a9;
  border-radius: 5px;
  font-size: 11px;
  line-height: 1.5;
}

.notice svg {
  margin-top: 1px;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}

.stat-strip > div {
  padding: 13px 16px;
  border-right: 1px solid var(--line);
}

.stat-strip > div:last-child {
  border-right: 0;
}

.stat-strip span,
.stat-strip strong {
  display: block;
}

.stat-strip span {
  color: var(--muted);
  font-size: 10px;
}

.stat-strip strong {
  margin-top: 4px;
  font-size: 16px;
}

.modal {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 42px);
  padding: 0;
  color: var(--ink);
  background: #fff;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(16, 24, 22, 0.54);
}

.modal form {
  display: flex;
  max-height: calc(100vh - 42px);
  flex-direction: column;
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  padding: 15px 18px;
}

.modal-header {
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  font-size: 17px;
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
}

.modal-footer {
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 15px;
  color: #fff;
  background: #26322f;
  border-radius: 6px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: 0.2s ease;
}

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

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

.empty-state svg {
  width: 32px;
  height: 32px;
  margin-bottom: 10px;
}

@media (max-width: 1120px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .rule-layout {
    grid-template-columns: 1fr;
  }

  .tester {
    position: static;
  }
}

@media (max-width: 800px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .mobile-scrim {
    position: fixed;
    inset: 0;
    z-index: 25;
    display: block;
    background: rgba(15, 23, 21, 0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .mobile-scrim.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .workspace {
    width: 100%;
  }

  .topbar {
    min-height: 64px;
    padding: 8px 14px;
  }

  .mobile-menu {
    display: inline-grid;
    margin-right: 10px;
  }

  .page-heading p,
  .prototype-badge,
  .admin-chip > span:not(.avatar) {
    display: none;
  }

  .page-heading h1 {
    font-size: 17px;
  }

  .page-content {
    padding: 18px 14px 30px;
  }

  .page-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .toolbar-actions {
    width: 100%;
  }

  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box {
    width: 100%;
    min-width: 0;
  }

  .settings-layout {
    grid-template-columns: 1fr;
  }

  .listener-row {
    grid-template-columns: minmax(170px, 1fr) minmax(140px, 1fr) 90px;
  }

  .listener-toggle {
    grid-column: 3;
    grid-row: 1;
    justify-content: flex-end;
  }

  .listener-identity {
    grid-column: 1 / 3;
  }

  .settings-nav {
    grid-template-columns: repeat(4, minmax(100px, 1fr));
    padding-bottom: 6px;
    overflow-x: auto;
  }
}

@media (max-width: 560px) {
  .topbar-actions {
    gap: 4px;
  }

  .admin-chip {
    padding-right: 4px;
  }

  .admin-chip svg {
    display: none;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .metric-value {
    font-size: 22px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .member-config-row {
    grid-template-columns: 1fr 1fr;
  }

  .member-config-row .check-chip {
    grid-column: 1 / -1;
  }

  .listener-row {
    grid-template-columns: minmax(0, 1fr) 86px;
  }

  .listener-identity {
    grid-column: 1;
  }

  .listener-toggle {
    grid-column: 2;
    grid-row: 1;
  }

  .form-field.full,
  .form-section {
    grid-column: 1;
  }

  .chain-hop-row {
    grid-template-columns: 28px minmax(0, 1fr) auto;
  }

  .chain-hop-row > .badge {
    grid-column: 2;
    grid-row: 1;
    width: max-content;
  }

  .chain-hop-row > .chain-hop-select {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .chain-hop-row > .table-actions {
    grid-column: 3;
    grid-row: 1;
  }

  .chain-exit-summary {
    grid-column: 1;
  }

  .rule-row {
    grid-template-columns: 24px minmax(0, 1fr);
  }

  .rule-row > .inline-actions {
    grid-column: 2;
  }

  .stat-strip {
    grid-template-columns: 1fr;
  }

  .stat-strip > div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stat-strip > div:last-child {
    border-bottom: 0;
  }

  .modal {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }

  .modal form {
    max-height: calc(100vh - 16px);
  }

  .toast {
    right: 12px;
    bottom: 12px;
  }
}

.log-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.log-list {
  height: calc(100vh - 300px);
  min-height: 320px;
  overflow-y: auto;
  padding: 10px 12px;
  background: var(--surface-soft);
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.45;
}

.log-entry {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 4px 6px;
  border-radius: 6px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

.log-entry:hover {
  background: rgba(8, 127, 109, 0.06);
}

.log-time {
  color: var(--faint);
  flex: 0 0 auto;
}

.log-level {
  flex: 0 0 auto;
  width: 52px;
  font-weight: 700;
  color: var(--blue);
}

.log-level:empty {
  display: none;
}

.log-message {
  color: var(--ink);
  word-break: break-all;
}

.log-attrs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  color: var(--muted);
}

.log-attr em {
  color: var(--faint);
  font-style: normal;
}

.log-entry.level-error .log-level,
.log-entry.level-error .log-message {
  color: var(--red);
}

.log-entry.level-warn .log-level,
.log-entry.level-warn .log-message {
  color: var(--amber);
}

.log-entry.level-debug .log-message {
  color: var(--faint);
}
