:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-soft: #f2f5f8;
  --text: #18212d;
  --muted: #697586;
  --line: #dce3ea;
  --line-strong: #b9c5d0;
  --accent: #167c6b;
  --accent-strong: #0e5c51;
  --warning: #a86612;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(31, 45, 61, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 78% 0%, rgba(22, 124, 107, 0.11), transparent 30rem),
    linear-gradient(180deg, #fbfcfd 0%, var(--bg) 42%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  padding: clamp(42px, 10vh, 96px) 28px 28px;
  background:
    radial-gradient(circle at 78% 0%, rgba(22, 124, 107, 0.1), transparent 30rem),
    #ffffff;
  transition:
    opacity 360ms ease,
    visibility 360ms ease;
}

.is-ready .boot-screen {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.boot-panel {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 0;
}

.boot-topline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.boot-topline {
  justify-content: space-between;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.boot-identity {
  padding: 46px 0 30px;
}

.boot-identity h1,
.brand h1,
.toolbar p,
.section-heading h2 {
  margin: 0;
}

.boot-identity h1 {
  max-width: 780px;
  font-size: clamp(34px, 5.6vw, 58px);
  line-height: 1.08;
  letter-spacing: 0;
}

.boot-scanner {
  position: relative;
  overflow: hidden;
  width: min(620px, 100%);
  height: 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 1px rgba(24, 33, 45, 0.04);
}

.boot-sweep {
  position: absolute;
  inset: 0 auto 0 0;
  width: 44%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #8edccc);
  animation: scan 1.25s ease-in-out infinite;
}

.boot-status {
  margin-top: 20px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

@keyframes scan {
  0% {
    transform: translateX(-105%);
  }
  100% {
    transform: translateX(245%);
  }
}

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

.app-header {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px);
}

.header-inner,
.content-inner {
  width: min(1120px, calc(100vw - 40px));
  margin: 0 auto;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  min-width: 74px;
  height: 46px;
  padding: 0 10px;
  place-items: center;
  border-radius: 8px;
  background: #17202a;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.brand h1 {
  margin-top: 3px;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.08;
  letter-spacing: 0;
}

.content {
  padding: 26px 0 42px;
}

.content-inner {
  display: grid;
  gap: 18px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  align-items: end;
  gap: 16px;
}

.search-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.search-field input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  box-shadow: 0 1px 2px rgba(31, 45, 61, 0.04);
}

.search-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 124, 107, 0.12);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.toolbar-actions button {
  height: 46px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.toolbar-actions button:hover {
  border-color: var(--line-strong);
}

.route-notice {
  max-width: 360px;
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.route-notice.error {
  color: var(--danger);
}

.status-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 10px 28px rgba(31, 45, 61, 0.05);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.section-heading span {
  color: var(--muted);
  font-size: 13px;
}

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

.adapter-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.adapter-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
}

.adapter-value {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-width: 70px;
  height: 24px;
  justify-content: center;
  padding: 0 9px;
  border-radius: 999px;
  background: #e4f6f1;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.pending {
  background: #fff4dd;
  color: var(--warning);
}

.status-pill.error {
  background: #ffe8e5;
  color: var(--danger);
}

.service-section {
  min-width: 0;
}

.service-list {
  display: grid;
  gap: 10px;
}

.service-row {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 30px rgba(31, 45, 61, 0.06);
}

.service-main {
  display: grid;
  grid-template-columns: minmax(160px, 1.1fr) minmax(220px, 1.4fr) auto;
  align-items: center;
  gap: 16px;
  padding: 16px;
}

.service-title {
  min-width: 0;
}

.service-title h3 {
  overflow: hidden;
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.service-id {
  overflow: hidden;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-link {
  min-width: 0;
}

.selected-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
}

.selected-label span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-url {
  overflow: hidden;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.selected-dot.unavailable {
  background: var(--danger);
}

.service-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.secondary-action,
.primary-action,
.link-row button {
  height: 36px;
  padding: 0 13px;
  border-radius: 8px;
  font-weight: 700;
}

.secondary-action {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.secondary-action:hover {
  border-color: var(--line-strong);
}

.primary-action,
.link-row button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.primary-action:hover,
.link-row button:hover {
  background: var(--accent-strong);
}

.primary-action:disabled,
.link-row button:disabled {
  cursor: not-allowed;
  border-color: #bbc4d0;
  background: #bbc4d0;
}

.link-list {
  display: grid;
  gap: 8px;
  padding: 0 16px 16px;
}

.link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.link-row.disabled {
  opacity: 0.58;
}

.link-info {
  min-width: 0;
}

.link-label {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-url,
.link-condition {
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state,
.error-state {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.error-state {
  color: var(--danger);
}

@media (max-width: 820px) {
  .header-inner,
  .content-inner {
    width: min(100vw - 28px, 1120px);
  }

  .header-inner,
  .toolbar {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .header-inner {
    display: flex;
  }

  .toolbar-actions {
    justify-content: flex-start;
  }

  .toolbar-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .route-notice {
    text-align: left;
  }

  .service-main {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .service-actions {
    justify-content: flex-start;
  }
}
