:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --text: #1b2430;
  --muted: #667085;
  --line: #e3e8ef;
  --line-strong: #cbd5e1;
  --brand: #e5484d;
  --brand-dark: #b4232b;
  --blue: #2563eb;
  --green: #08875d;
  --amber: #b7791f;
  --danger: #dc2626;
  --shadow: 0 18px 45px rgba(20, 28, 38, .10);
  --radius: 8px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #eef3f8;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  background:
    linear-gradient(135deg, rgba(255, 245, 246, .96) 0%, rgba(241, 247, 255, .98) 42%, rgba(239, 252, 246, .96) 100%),
    linear-gradient(180deg, #ffffff 0%, #eef3f8 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, rgba(229, 72, 77, .12), transparent 34%),
    linear-gradient(245deg, rgba(37, 99, 235, .10), transparent 44%),
    linear-gradient(180deg, rgba(17, 24, 39, .06), transparent 260px);
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  color: #1d4ed8;
}

button,
.btn {
  --button-glow: rgba(229, 72, 77, .34);
  --button-shadow: rgba(229, 72, 77, .22);
  appearance: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  padding: 9px 14px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 18px var(--button-shadow), 0 0 0 rgba(229, 72, 77, 0);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

button:hover,
.btn:hover {
  color: #fff;
  background: var(--brand-dark);
  box-shadow: 0 14px 30px var(--button-shadow), 0 0 22px var(--button-glow);
  transform: translateY(-1px);
}

button:active,
.btn:active {
  transform: translateY(0) scale(.98);
  box-shadow: 0 6px 16px var(--button-shadow), 0 0 0 6px var(--button-glow), 0 0 34px var(--button-glow);
}

button.is-glowing,
.btn.is-glowing {
  animation: button-glow .56s ease-out;
}

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

.danger {
  --button-glow: rgba(220, 38, 38, .36);
  --button-shadow: rgba(220, 38, 38, .20);
  background: var(--danger);
}

.danger:hover {
  background: #b91c1c;
}

.secondary {
  --button-glow: rgba(71, 85, 105, .30);
  --button-shadow: rgba(71, 85, 105, .18);
  background: #475569;
}

.secondary:hover {
  background: #334155;
}

.compact {
  min-height: 30px;
  padding: 5px 9px;
  box-shadow: none;
  font-size: 12px;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 28px;
  color: #fff;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .20), rgba(255, 255, 255, 0)),
    linear-gradient(115deg, rgba(180, 35, 43, .96) 0%, rgba(229, 72, 77, .94) 34%, rgba(37, 99, 235, .90) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, .26);
  box-shadow: 0 18px 36px rgba(15, 23, 42, .20), inset 0 -1px 0 rgba(255, 255, 255, .16);
  backdrop-filter: blur(16px) saturate(1.15);
}

.topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(92deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, .18) 45%, rgba(255, 255, 255, 0) 78%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .10) 0, rgba(255, 255, 255, .10) 1px, transparent 1px, transparent 64px);
  opacity: .42;
}

.topbar > * {
  position: relative;
  z-index: 1;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
  text-shadow: 0 1px 8px rgba(15, 23, 42, .18);
}

.brand:hover {
  color: #fff;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .42);
  background: linear-gradient(135deg, rgba(255, 255, 255, .98), rgba(255, 245, 246, .84));
  color: var(--brand);
  box-shadow: 0 10px 24px rgba(15, 23, 42, .20), inset 0 -2px 0 rgba(15, 23, 42, .08);
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 7px;
  border: 1px solid transparent;
  color: rgba(255, 255, 255, .84);
  font-weight: 700;
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, color .16s ease, transform .16s ease;
}

.nav a:hover,
.nav a.active {
  color: #fff;
  border-color: rgba(255, 255, 255, .24);
  background: rgba(255, 255, 255, .18);
  box-shadow: 0 8px 22px rgba(15, 23, 42, .14), inset 0 1px 0 rgba(255, 255, 255, .18);
}

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

.user-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 999px;
  color: rgba(255, 255, 255, .90);
  background: rgba(255, 255, 255, .13);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14);
}

.user-chip:hover {
  color: rgba(255, 255, 255, .96);
}

.topbar .btn {
  --button-glow: rgba(255, 255, 255, .28);
  --button-shadow: rgba(15, 23, 42, .16);
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, .28);
  background: rgba(255, 255, 255, .16);
  box-shadow: 0 8px 20px var(--button-shadow), inset 0 1px 0 rgba(255, 255, 255, .14);
}

.topbar .btn:hover {
  background: rgba(255, 255, 255, .24);
  box-shadow: 0 12px 26px var(--button-shadow), 0 0 22px rgba(255, 255, 255, .18);
}

.wrap {
  width: min(1120px, calc(100% - 36px));
  margin: 28px auto 44px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 18px;
}

.page-title {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
  font-weight: 800;
  color: #111827;
}

.page-subtitle {
  margin-top: 5px;
  color: var(--muted);
}

.card {
  position: relative;
  overflow-x: auto;
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid rgba(226, 232, 240, .92);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .85), var(--shadow);
}

.card h2 {
  margin: 0 0 14px;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 800;
  color: #111827;
}

.card p {
  margin: 0 0 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

label {
  display: block;
  margin: 0 0 6px;
  color: #334155;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  box-sizing: border-box;
  margin: 0 0 14px;
  padding: 10px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  outline: none;
  background: #fff;
  color: var(--text);
  font: inherit;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

textarea {
  min-height: 130px;
  resize: vertical;
  font-family: "Cascadia Mono", Consolas, "Courier New", monospace;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(229, 72, 77, .12);
}

input[type="checkbox"] {
  width: auto;
  min-height: auto;
  margin: 0 6px 0 0;
  accent-color: var(--brand);
}

input[type="file"] {
  padding: 8px;
  background: var(--surface-soft);
}

.filter-form {
  margin: 0;
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 10px;
  align-items: start;
}

.filter-row select {
  margin-bottom: 0;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  overflow: hidden;
}

.card table {
  margin: -3px 0 0;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: #475569;
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 800;
}

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

td small {
  color: var(--muted);
  word-break: break-all;
}

.binding-item {
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}

.binding-item:first-child {
  padding-top: 0;
}

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

.dependency-group {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.dependency-group:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.dependency-group:last-child {
  padding-bottom: 0;
}

.dependency-group-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.dependency-group-head h3 {
  margin: 0 0 2px;
  color: #111827;
  font-size: 16px;
}

.dependency-group-head p {
  margin: 0;
}

.dependency-table {
  margin-bottom: 12px;
}

.relation-form,
.add-relation-form {
  display: grid;
  gap: 8px;
  align-items: start;
}

.relation-form {
  grid-template-columns: minmax(100px, 130px) auto;
}

.add-relation-form {
  grid-template-columns: minmax(220px, 1fr) minmax(110px, 150px) auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.relation-form select,
.add-relation-form select {
  margin-bottom: 0;
}

.inline-action {
  margin-top: 8px;
}

.inline-action button {
  margin: 0;
}

.actions-cell {
  min-width: 100px;
}

.action-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.action-stack form {
  margin: 0;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin: 0 8px 8px 0;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  vertical-align: top;
}

.status-badge-licensed {
  color: #067647;
  border-color: #abefc6;
  background: #ecfdf3;
}

.status-badge-unbound {
  color: #b54708;
  border-color: #fedf89;
  background: #fffaeb;
}

.status-badge-expired {
  color: #b42318;
  border-color: #fecdca;
  background: #fef3f2;
}

.copy-code {
  display: inline-block;
  max-width: 100%;
  margin: 0 8px 8px 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #0f172a;
  background: #f8fafc;
  font-family: "Cascadia Mono", Consolas, "Courier New", monospace;
  font-size: 12px;
  word-break: break-all;
}

.copy-code[data-copy] {
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease;
}

.copy-code[data-copy]:hover {
  border-color: var(--brand);
  background: #eef6ff;
}

.copy-code.is-copied::after {
  content: " 已复制";
  color: #0f8b4c;
  font-family: inherit;
  font-weight: 700;
}

.copy-btn {
  min-height: 30px;
  padding: 5px 9px;
  box-shadow: none;
  font-size: 12px;
}

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

.msg {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(8, 135, 93, .18);
  border-radius: 8px;
  color: #05603a;
  background: #ecfdf3;
  box-shadow: 0 10px 25px rgba(8, 135, 93, .08);
}

.err {
  border-color: rgba(220, 38, 38, .18);
  color: #991b1b;
  background: #fef2f2;
}

.auth-page .wrap {
  width: min(460px, calc(100% - 36px));
  margin-top: 64px;
}

.auth-page .page-head {
  text-align: center;
  justify-content: center;
}

.auth-page .card {
  padding: 24px;
}

.fade-in {
  animation: fade-in .28s ease both;
}

@keyframes button-glow {
  0% {
    box-shadow: 0 8px 18px var(--button-shadow), 0 0 0 0 var(--button-glow);
  }
  45% {
    box-shadow: 0 12px 26px var(--button-shadow), 0 0 0 8px var(--button-glow), 0 0 32px var(--button-glow);
  }
  100% {
    box-shadow: 0 8px 18px var(--button-shadow), 0 0 0 16px rgba(255, 255, 255, 0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--brand);
}

@media (max-width: 760px) {
  .topbar {
    position: static;
    flex-wrap: wrap;
    align-items: flex-start;
    padding: 14px 16px;
  }

  .nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav a {
    white-space: nowrap;
  }

  .user-area {
    margin-left: auto;
  }

  .wrap {
    width: min(100% - 24px, 1120px);
    margin-top: 18px;
  }

  .page-head {
    align-items: flex-start;
  }

  .page-title {
    font-size: 22px;
  }

  .card {
    padding: 16px;
  }

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

  .dependency-group-head {
    display: block;
  }

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

.topbar-spacer {
  flex: 1;
}

.sidebar-toggle {
  display: none;
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .30);
  border-radius: 7px;
  background: rgba(255, 255, 255, .15);
  box-shadow: 0 8px 20px rgba(15, 23, 42, .14);
}

.sidebar-toggle span {
  display: block;
  width: 16px;
  height: 2px;
  margin: 2px 0;
  border-radius: 99px;
  background: #fff;
}

.layout-shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  gap: 0;
  min-height: calc(100vh - 64px);
}

.sidebar {
  position: sticky;
  top: 64px;
  align-self: start;
  height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 18px 14px;
  border-right: 1px solid rgba(203, 213, 225, .78);
  background: rgba(255, 255, 255, .84);
  box-shadow: 12px 0 34px rgba(15, 23, 42, .06);
  backdrop-filter: blur(14px) saturate(1.08);
}

.sidebar-section-title {
  margin: 10px 10px 8px;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.side-nav {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #334155;
  font-weight: 800;
  transition: background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.side-link:hover,
.side-link.active {
  color: #111827;
  border-color: rgba(229, 72, 77, .18);
  background: linear-gradient(135deg, rgba(255, 241, 242, .95), rgba(239, 246, 255, .95));
  box-shadow: 0 10px 24px rgba(15, 23, 42, .08);
}

.side-link:hover {
  transform: translateX(2px);
}

.side-link.disabled {
  cursor: not-allowed;
  opacity: .58;
}

.side-link.disabled:hover {
  transform: none;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.side-icon {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  flex: 0 0 25px;
  border-radius: 7px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--blue));
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 8px 16px rgba(37, 99, 235, .16);
}

.sidebar-backdrop {
  display: none;
}

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

.info-table th {
  width: 120px;
}

@media (min-width: 901px) {
  .app-page .wrap {
    width: min(1120px, calc(100% - 48px));
  }
}

@media (max-width: 900px) {
  .topbar {
    position: sticky;
    flex-wrap: nowrap;
    align-items: center;
    min-height: 58px;
    padding: 10px 12px;
  }

  .sidebar-toggle {
    display: inline-grid;
    place-items: center;
  }

  .brand {
    min-width: 0;
    font-size: 15px;
  }

  .brand > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .user-area {
    margin-left: 0;
    gap: 6px;
  }

  .user-chip {
    max-width: 96px;
    padding: 6px 8px;
  }

  .topbar .btn {
    min-height: 32px;
    padding: 6px 9px;
  }

  .layout-shell {
    display: block;
    min-height: auto;
  }

  .sidebar {
    position: fixed;
    inset: 58px auto 0 0;
    z-index: 30;
    width: min(82vw, 286px);
    height: auto;
    transform: translateX(-104%);
    transition: transform .2s ease;
  }

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

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 58px 0 0;
    z-index: 25;
    background: rgba(15, 23, 42, .38);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .nav {
    order: initial;
    width: auto;
    flex: 0 0 auto;
    overflow: visible;
    padding-bottom: 0;
  }

  .auth-nav {
    margin-left: auto;
  }
}

@media (max-width: 520px) {
  .topbar {
    gap: 8px;
  }

  .brand-mark {
    width: 31px;
    height: 31px;
  }

  .brand > span:last-child {
    max-width: 118px;
  }

  .user-chip {
    display: none;
  }

  .auth-nav a {
    min-height: 32px;
    padding: 6px 8px;
  }
}
