:root {
  --bg: #eeeeee;
  --surface: #ffffff;
  --surface-soft: #f2f3f5;
  --surface-tint: #f7f9fb;
  --line: #d7dbe3;
  --line-soft: #e5e6eb;
  --text: #1d2129;
  --muted: #6b7280;
  --disabled: #a8aeb9;
  --primary: #1687df;
  --primary-deep: #0d67b5;
  --ok: #1f7a4d;
  --warning: #9a6700;
  --danger: #a63242;
  --ink-soft: #4b5563;
  --nav: #147bd1;
  --nav-hover: #259cfc;
  --shadow: 0 8px 20px rgba(22, 27, 34, 0.14);
  --radius: 6px;
  --font: "PingFang SC", "Microsoft YaHei", Arial, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100%;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font);
  font-size: 12px;
  letter-spacing: 0;
  overflow: hidden;
}

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

button { cursor: pointer; }

button:disabled {
  cursor: not-allowed;
}

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

.login-view {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(242, 243, 245, 0.92)),
    var(--bg);
  padding: 24px;
}

.login-panel {
  width: min(360px, 100%);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(22, 27, 34, 0.12);
  padding: 22px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.login-brand__logo {
  width: 44px;
  height: 44px;
  border-radius: 8px;
}

.login-brand__name {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

.login-brand__meta {
  color: var(--muted);
  margin-top: 3px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--ink-soft);
}

.field input {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  outline: none;
}

.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22, 135, 223, 0.12);
}

.login-error {
  min-height: 18px;
  color: var(--danger);
  margin: 2px 0 8px;
}

.login-note {
  margin: 10px 0 0;
  color: var(--muted);
  text-align: center;
}

.primary-btn {
  width: 100%;
  height: 34px;
  border: 0;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.primary-btn:hover {
  background: var(--primary-deep);
}

.secondary-btn,
.ghost-btn {
  min-height: 32px;
  border-radius: 4px;
  padding: 0 12px;
}

.secondary-btn {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
}

.secondary-btn:hover {
  background: var(--primary-deep);
  border-color: var(--primary-deep);
}

.ghost-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
}

.ghost-btn:hover {
  background: var(--surface-soft);
}

.app-shell {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

.sidebar {
  position: relative;
  z-index: 40;
  width: 60px;
  flex: 0 0 60px;
  overflow: visible;
}

.module-rail {
  width: 60px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: var(--nav);
  color: #fff;
  overflow-y: auto;
  scrollbar-width: none;
}

.module-rail::-webkit-scrollbar {
  display: none;
}

.module-logo {
  flex: 0 0 52px;
  width: 60px;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  display: grid;
  place-items: center;
  padding: 0;
}

.module-logo__image {
  width: 34px;
  height: 34px;
  border-radius: 6px;
}

.module-item {
  min-height: 56px;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: #fff;
  padding: 6px 4px;
  text-align: center;
  line-height: 1.28;
  white-space: normal;
}

.module-item:hover,
.module-item.is-active {
  background: var(--nav-hover);
}

.module-item.is-active {
  border-left-color: #fff;
}

.module-item.is-disabled {
  color: rgba(255, 255, 255, 0.58);
  background: rgba(0, 0, 0, 0.08);
}

.module-item.is-disabled:hover {
  background: rgba(0, 0, 0, 0.08);
}

.module-item--bottom {
  margin-top: auto;
}

.module-panel {
  position: fixed;
  z-index: 40;
  left: 60px;
  top: 0;
  bottom: 0;
  width: 248px;
  max-width: calc(100vw - 60px);
  min-height: 0;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: #fff;
  box-shadow: 8px 0 22px rgba(22, 27, 34, 0.12);
  padding: 16px 14px;
  transform: translateX(-10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
}

.sidebar.is-open .module-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.menu-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
}

.menu-grid--empty {
  min-height: 1px;
}

.menu-section {
  margin-bottom: 14px;
}

.menu-section__title {
  margin-bottom: 4px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.nav-item {
  width: 100%;
  min-height: 29px;
  display: flex;
  align-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  padding: 0 8px;
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  background: #edf5ff;
  color: var(--primary-deep);
}

.nav-item.is-muted {
  color: var(--disabled);
  background: transparent;
}

.nav-item__badge {
  margin-left: auto;
  color: var(--warning);
  font-size: 11px;
}

.menu-scrim {
  position: fixed;
  inset: 0 0 0 60px;
  z-index: 30;
  display: none;
  border: 0;
  background: rgba(29, 33, 41, 0.12);
}

.menu-scrim.is-visible {
  display: block;
}

.main-shell {
  min-width: 0;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 34px;
  flex: 0 0 34px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  overflow: visible;
}

.workspace-tabs {
  height: 100%;
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: stretch;
  overflow: hidden;
}

.workspace-tab {
  position: relative;
  flex: 0 0 132px;
  max-width: 132px;
  height: 30px;
  margin-top: 3px;
  min-width: 0;
  display: flex;
  align-items: center;
  border: 0;
  border-right: 1px solid var(--line-soft);
  border-bottom: 2px solid transparent;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 0 26px 0 10px;
  overflow: hidden;
}

.workspace-tab:hover,
.workspace-tab.is-active {
  background: #fff;
  color: var(--primary-deep);
}

.workspace-tab.is-active {
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.workspace-tab.is-dragging {
  opacity: 0.55;
}

.workspace-tab--fixed {
  flex-basis: 86px;
  max-width: 86px;
  padding-right: 10px;
}

.workspace-tab__label {
  min-width: 0;
  flex: 1;
  height: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-tab__close,
.tab-more__close {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--disabled);
  padding: 0;
  line-height: 18px;
}

.workspace-tab__close {
  position: absolute;
  right: 4px;
  top: 5px;
}

.workspace-tab__close:hover,
.tab-more__close:hover {
  background: #e5edf7;
  color: var(--text);
}

.tab-more {
  position: relative;
  flex: 0 0 64px;
  max-width: 64px;
  z-index: 20;
}

.workspace-tab--more {
  width: 64px;
  max-width: 64px;
  justify-content: center;
  padding: 0 8px;
}

.workspace-tab--more::after {
  content: "▾";
  margin-left: 4px;
  font-size: 10px;
}

.tab-more__menu {
  position: absolute;
  top: 34px;
  right: 0;
  display: none;
  min-width: 168px;
  border: 1px solid var(--line-soft);
  border-radius: 0 0 4px 4px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 6px 0;
  z-index: 30;
}

.tab-more:hover .tab-more__menu,
.tab-more:focus-within .tab-more__menu {
  display: block;
}

.tab-more__row {
  display: flex;
  align-items: center;
}

.tab-more__item {
  min-width: 0;
  flex: 1;
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0 12px;
  text-align: left;
}

.tab-more__row:hover,
.tab-more__row.is-active {
  background: #edf5ff;
  color: var(--primary-deep);
}

.topbar-tools {
  height: 100%;
  flex: 0 0 auto;
  min-width: 164px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 0 8px;
  border-left: 1px solid var(--line-soft);
}

.tool-btn {
  min-width: 24px;
  height: 24px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  padding: 0 6px;
  white-space: nowrap;
}

.tool-btn:hover {
  background: #e6edf5;
}

.tool-btn--icon {
  display: grid;
  place-items: center;
  padding: 0;
}

.tool-btn--text {
  max-width: 96px;
  overflow: hidden;
  color: var(--ink-soft);
  text-overflow: ellipsis;
}

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

.content {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: #fff;
  color: var(--ink-soft);
  padding: 0 7px;
  white-space: nowrap;
}

.status-pill--ready {
  border-color: #addcc5;
  color: var(--ok);
  background: #f0fbf5;
}

.page {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 14px;
}

.page--internal {
  display: flex;
  flex-direction: column;
  padding: 0;
  background: #fff;
}

.blank-workspace {
  min-height: calc(100vh - 84px);
  border: 1px dashed transparent;
}

.feature-page {
  min-height: calc(100vh - 84px);
  display: flex;
}

.feature-page--bridge {
  min-height: calc(100vh - 84px);
  flex-direction: column;
  background: #fff;
}

.feature-page--bridge-state {
  min-height: calc(100vh - 84px);
  display: grid;
  place-items: center;
  background: #f7f9fb;
}

.feature-frame {
  width: 100%;
  min-height: calc(100vh - 84px);
  border: 0;
  background: #fff;
}

.feature-frame--bridge {
  min-height: 0;
  flex: 1;
}

.bridge-toolbar {
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line-soft);
  background: #f7fbff;
  color: var(--ink-soft);
  padding: 0 12px;
}

.bridge-toolbar__meta {
  margin-left: auto;
  color: var(--muted);
}

.bridge-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--disabled);
}

.bridge-dot--ok {
  background: var(--ok);
}

.bridge-state {
  width: min(520px, calc(100% - 32px));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 8px 18px rgba(22, 27, 34, 0.08);
  padding: 28px;
  text-align: center;
}

.bridge-state__icon {
  width: 34px;
  height: 34px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: #dbeafe;
}

.bridge-state--degraded .bridge-state__icon {
  background: #ffe8cc;
}

.bridge-state h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.4;
}

.bridge-state p {
  margin: 8px 0 16px;
  color: var(--muted);
  line-height: 1.7;
}

.feature-placeholder {
  min-height: calc(100vh - 84px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  color: var(--ink);
}

.feature-placeholder h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.4;
}

.feature-placeholder p {
  margin: 0;
  color: var(--muted);
}

.feature-link {
  color: var(--accent);
  text-decoration: none;
}

.internal-page {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.internal-page__panel {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.internal-page__body {
  min-height: 0;
  flex: 1;
  background:
    linear-gradient(#fff, #fff) padding-box,
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 39px,
      var(--line-soft) 40px
    );
}

.page-panel {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fff;
}

.page-panel.internal-page__panel {
  border: 0;
  border-radius: 0;
}

.page-panel + .page-panel {
  margin-top: 12px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line-soft);
}

.page-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}

.page-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line-soft);
}

.status-tile {
  min-width: 0;
  padding: 12px 14px;
  border-right: 1px solid var(--line-soft);
}

.status-tile:last-child {
  border-right: 0;
}

.status-tile__label {
  color: var(--muted);
  margin-bottom: 6px;
}

.status-tile__value {
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 700;
}

.data-table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  height: 34px;
  border-bottom: 1px solid var(--line-soft);
  padding: 0 12px;
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  background: var(--surface-tint);
  color: var(--ink-soft);
  font-weight: 600;
}

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

.mapping-layout {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
}

.mapping-form {
  border-right: 1px solid var(--line-soft);
  background: #fafbfc;
  padding: 14px;
  overflow: auto;
}

.mapping-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.toggle-field {
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  margin: 4px 0 10px;
}

.mapping-table-wrap {
  min-width: 0;
  overflow: auto;
}

.mapping-table {
  min-width: 840px;
}

.table-action {
  min-height: 24px;
  border: 0;
  border-radius: 4px;
  background: #edf5ff;
  color: var(--primary-deep);
  padding: 0 8px;
}

.table-action + .table-action {
  margin-left: 6px;
}

.table-action--danger {
  background: #fff1f2;
  color: var(--danger);
}

.table-empty {
  color: var(--muted);
  text-align: center;
}

.section-body {
  padding: 12px 14px;
}

.check-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
}

.check-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--ok);
}

.menu-search-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  background: rgba(29, 33, 41, 0.26);
  padding: 7vh 18px 18px;
}

.menu-search-layer.is-open {
  display: block;
}

.search-panel {
  width: min(680px, 100%);
  margin: 0 auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.search-panel__head {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line-soft);
  padding: 10px;
}

.search-panel__head input {
  min-width: 0;
  flex: 1;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 10px;
  outline: none;
}

.search-panel__head input:focus {
  border-color: var(--primary);
}

.search-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 4px;
  background: var(--surface-soft);
}

.search-results {
  max-height: 58vh;
  overflow: auto;
  padding: 8px 10px 10px;
}

.search-result {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  padding: 0 10px;
  text-align: left;
}

.search-result:hover {
  background: #edf5ff;
}

.search-result:disabled {
  color: var(--disabled);
  background: transparent;
}

.search-result__module {
  width: 48px;
  color: var(--primary-deep);
  font-weight: 600;
}

.search-result__path {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  min-width: 180px;
  max-width: min(360px, calc(100vw - 36px));
  min-height: 34px;
  display: none;
  align-items: center;
  border: 1px solid #b7d7f4;
  border-radius: var(--radius);
  background: #eef7ff;
  color: var(--primary-deep);
  box-shadow: var(--shadow);
  padding: 8px 12px;
}

.toast.is-visible {
  display: flex;
}

@media (max-width: 760px) {
  .login-view {
    padding: 14px;
  }

  .sidebar,
  .module-rail {
    width: 56px;
    flex-basis: 56px;
  }

  .module-logo,
  .module-item {
    width: 56px;
  }

  .module-panel {
    left: 56px;
    width: calc(100vw - 56px);
    max-width: calc(100vw - 56px);
    padding: 14px;
  }

  .check-list,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .status-tile {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .status-tile:last-child {
    border-bottom: 0;
  }

  .topbar-tools {
    min-width: 116px;
    padding-right: 6px;
  }

  .tool-btn--text {
    max-width: 54px;
  }

  .page {
    padding: 10px;
  }

  .page.page--internal {
    padding: 0;
  }

  .page-header {
    flex-direction: column;
  }

  .mapping-layout {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .mapping-form {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }
}
