:root {
  --bg: #0b0d0f;
  --surface: #121519;
  --surface-2: #171b20;
  --line: #282e35;
  --line-soft: #20252b;
  --text: #f4f6f8;
  --muted: #8e98a4;
  --muted-2: #69737e;
  --accent: #b9f56a;
  --accent-strong: #99e446;
  --accent-dark: #14220b;
  --danger: #ff6b6b;
  --warning: #ffca67;
  --success: #82e67e;
  --shadow: 0 24px 90px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 82% -15%, rgba(185, 245, 106, 0.11), transparent 36%),
    radial-gradient(circle at -10% 45%, rgba(104, 159, 255, 0.07), transparent 32%),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  z-index: 10;
  background-image:
    linear-gradient(90deg, transparent 49%, rgba(255, 255, 255, 0.2) 50%, transparent 51%),
    linear-gradient(transparent 49%, rgba(255, 255, 255, 0.16) 50%, transparent 51%);
  background-size: 7px 7px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(185, 245, 106, 0.55);
  border-radius: 14px;
  color: var(--accent);
  background: linear-gradient(145deg, rgba(185, 245, 106, 0.14), rgba(185, 245, 106, 0.03));
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 21px;
  font-weight: 800;
  box-shadow: inset 0 0 24px rgba(185, 245, 106, 0.06);
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 18px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 490px);
  padding: 46px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(18, 21, 25, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-card .brand-mark {
  margin-bottom: 30px;
}

.login-card h1 {
  margin: 0;
  font-size: clamp(32px, 7vw, 48px);
  letter-spacing: -0.045em;
}

.login-form {
  margin-top: 30px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.login-form label,
.field > span {
  display: block;
  margin-bottom: 9px;
  color: #cbd1d7;
  font-size: 13px;
  font-weight: 650;
}

.password-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input,
select {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  color: var(--text);
  background: #0e1114;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input {
  padding: 0 14px;
}

select {
  padding: 0 38px 0 14px;
}

input:focus,
select:focus {
  border-color: rgba(185, 245, 106, 0.65);
  box-shadow: 0 0 0 3px rgba(185, 245, 106, 0.08);
}

.button {
  min-height: 42px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  background: transparent;
  font-weight: 680;
  transition: transform 130ms ease, background 130ms ease, border-color 130ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.5;
  cursor: wait;
  transform: none;
}

.button.primary {
  color: #10150b;
  background: var(--accent);
}

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

.button.ghost {
  border-color: var(--line);
  color: #d6dbe0;
  background: rgba(255, 255, 255, 0.018);
}

.button.large {
  min-height: 48px;
  padding-inline: 22px;
}

.form-error {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.status-dot {
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-right: 8px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 12px rgba(130, 230, 126, 0.7);
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1320px) / 2));
  border-bottom: 1px solid var(--line-soft);
  background: rgba(11, 13, 15, 0.78);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand,
.top-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.brand .eyebrow {
  margin-bottom: 3px;
  font-size: 9px;
}

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

.workspace {
  width: min(1320px, calc(100% - 48px));
  margin: 0 auto;
  padding: 64px 0 80px;
}

.hero {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
}

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

.stat-card {
  min-height: 142px;
  padding: 20px;
  border: 1px solid var(--line-soft);
  border-radius: 15px;
  background: rgba(18, 21, 25, 0.82);
}

.stat-card p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 12px;
}

.stat-card strong {
  display: block;
  margin-bottom: 9px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 31px;
  letter-spacing: -0.05em;
}

.stat-card span {
  color: var(--muted-2);
  font-size: 11px;
}

.endpoint-card strong {
  overflow: hidden;
  color: var(--accent);
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.registry-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(18, 21, 25, 0.9);
  overflow: hidden;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.18);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-header h3 {
  margin: 0;
  font-size: 17px;
}

.panel-header p {
  margin: 7px 0 0;
  color: var(--muted-2);
  font-size: 12px;
}

.filter-row {
  display: flex;
  gap: 9px;
}

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

.search-box span {
  position: absolute;
  left: 13px;
  top: 10px;
  color: var(--muted-2);
}

.search-box input {
  padding-left: 36px;
}

.filter-row select {
  width: 126px;
}

.mapping-list {
  display: grid;
}

.mapping-item {
  display: grid;
  grid-template-columns: minmax(200px, 0.9fr) minmax(260px, 1.4fr) 130px 140px auto;
  gap: 18px;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line-soft);
}

.mapping-item:last-child {
  border-bottom: 0;
}

.mapping-item:hover {
  background: rgba(255, 255, 255, 0.012);
}

.route-name {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.route-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--accent);
  background: var(--accent-dark);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.route-name strong,
.source-path code {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-name strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

.route-name small,
.source-path span,
.check-status span {
  display: block;
  margin-top: 5px;
  color: var(--muted-2);
  font-size: 10px;
}

.source-path {
  min-width: 0;
}

.source-path code {
  color: #bcc4cc;
  font-size: 11px;
}

.mode-pill,
.health-pill {
  width: fit-content;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.018);
  font-size: 10px;
}

.health-pill.ok {
  color: var(--success);
  border-color: rgba(130, 230, 126, 0.25);
  background: rgba(130, 230, 126, 0.06);
}

.health-pill.error {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.28);
  background: rgba(255, 107, 107, 0.06);
}

.item-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.mini-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
}

.mini-button:hover {
  color: var(--text);
  border-color: #3b444e;
  background: var(--surface-2);
}

.mini-button.danger:hover {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.4);
}

.switch {
  position: relative;
  width: 37px;
  height: 22px;
  border: 0;
  border-radius: 99px;
  background: #30363d;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #89939d;
  transition: transform 150ms ease, background 150ms ease;
}

.switch.on {
  background: rgba(185, 245, 106, 0.25);
}

.switch.on::after {
  transform: translateX(15px);
  background: var(--accent);
}

.empty-state {
  padding: 80px 24px;
  text-align: center;
}

.empty-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  border: 1px solid rgba(185, 245, 106, 0.32);
  border-radius: 15px;
  color: var(--accent);
  background: var(--accent-dark);
  font-size: 23px;
}

.empty-state h4 {
  margin: 0;
  font-size: 18px;
}

.empty-state p {
  margin: 10px auto 22px;
  color: var(--muted);
  font-size: 13px;
}

dialog {
  width: min(680px, calc(100% - 30px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(2, 3, 4, 0.76);
  backdrop-filter: blur(7px);
}

.dialog-card {
  padding: 28px;
}

.dialog-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 26px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 25px;
  letter-spacing: -0.035em;
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-size: 22px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

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

.field small,
.toggle-field small {
  display: block;
  margin-top: 7px;
  color: var(--muted-2);
  font-size: 10px;
  line-height: 1.45;
}

.toggle-field {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #0e1114;
}

.toggle-field strong {
  display: block;
  font-size: 13px;
}

.toggle-field small {
  max-width: 220px;
  margin-top: 4px;
}

.toggle-field input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-ui {
  position: relative;
  width: 40px;
  height: 23px;
  flex: 0 0 auto;
  border-radius: 99px;
  background: #30363d;
  transition: background 150ms ease;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #89939d;
  transition: transform 150ms ease, background 150ms ease;
}

.toggle-field input:checked + .toggle-ui {
  background: rgba(185, 245, 106, 0.25);
}

.toggle-field input:checked + .toggle-ui::after {
  transform: translateX(17px);
  background: var(--accent);
}

.preview-box {
  margin-top: 20px;
  padding: 13px 15px;
  border: 1px dashed #343c45;
  border-radius: 11px;
  background: #0d1013;
}

.preview-box span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted-2);
  font-size: 10px;
}

.preview-box code {
  display: block;
  overflow: hidden;
  color: var(--accent);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 22px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(420px, calc(100% - 48px));
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  opacity: 0;
  transform: translateY(12px);
  color: var(--text);
  background: #181c21;
  box-shadow: var(--shadow);
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
  z-index: 20;
  font-size: 13px;
}

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

.toast.error {
  border-color: rgba(255, 107, 107, 0.4);
  color: #ffb0b0;
}

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

  .mapping-item {
    grid-template-columns: minmax(180px, 1fr) minmax(230px, 1.4fr) 110px auto;
  }

  .check-status {
    display: none;
  }
}

@media (max-width: 720px) {
  .topbar {
    height: 72px;
    padding-inline: 18px;
  }

  .brand .eyebrow,
  .live-state {
    display: none;
  }

  .workspace {
    width: min(100% - 28px, 1320px);
    padding-top: 38px;
  }

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

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

  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-row {
    flex-direction: column;
  }

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

  .filter-row select {
    width: 100%;
  }

  .mapping-item {
    grid-template-columns: 1fr auto;
    gap: 13px;
  }

  .source-path,
  .mode-pill {
    grid-column: 1 / -1;
  }

  .item-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

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

  .field.full {
    grid-column: auto;
  }

  .login-card {
    padding: 30px 24px;
  }
}
