:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --line: #d9e0e7;
  --ink: #17212b;
  --muted: #607080;
  --blue: #1f6feb;
  --green: #237a4b;
  --amber: #a15c00;
  --red: #b42318;
  --sidebar: #182230;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
button, .button {
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: white;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
}
button.secondary, .button.secondary { background: #e8edf3; color: var(--ink); }
button.danger { background: var(--red); }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
  background: white;
}
textarea { resize: vertical; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 236px;
  background: var(--sidebar);
  color: white;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
}
.brand { font-size: 20px; font-weight: 800; margin-bottom: 26px; }
.sidebar nav { display: grid; gap: 8px; }
.sidebar nav a {
  color: #cbd5e1;
  padding: 11px 12px;
  border-radius: 6px;
}
.sidebar nav a.active, .sidebar nav a:hover { color: white; background: rgba(255,255,255,.12); }
.userbox {
  margin-top: auto;
  display: grid;
  gap: 8px;
  color: #cbd5e1;
}
.userbox a { color: white; }

.content {
  margin-left: 236px;
  padding: 30px;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}
.head-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.page-head h1 { margin-bottom: 4px; font-size: 28px; letter-spacing: 0; }
.page-head p, .muted, small { color: var(--muted); }

.panel, .metric, .login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.panel { padding: 20px; margin-bottom: 18px; }
.panel h2 { font-size: 18px; margin-bottom: 14px; }
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.metric { padding: 18px; display: grid; gap: 4px; }
.metric strong { font-size: 26px; }
.metric span { color: var(--muted); }
.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}
.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.list { display: grid; gap: 10px; }
.list-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: white;
}
.list-row div { display: grid; gap: 4px; min-width: 0; }
.list-row span, .list-row small {
  color: var(--muted);
  overflow-wrap: anywhere;
}
.list-row.static { cursor: default; }
.compact .list-row { padding: 10px; }
.priority { border-radius: 999px; padding: 4px 8px; background: #eef2f7; }
.priority.高 { color: var(--red); }
.priority.中 { color: var(--amber); }
.priority.低 { color: var(--green); }

.table { display: grid; gap: 8px; }
.tr {
  display: grid;
  grid-template-columns: 1.4fr .8fr .7fr .7fr .9fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}
.tr.th {
  background: #edf2f7;
  font-weight: 800;
  color: #344054;
}
.tr small { display: block; margin-top: 3px; }
.revisions .tr { grid-template-columns: .7fr 1fr 1fr 1.4fr .9fr; }
.graph-nodes .tr { grid-template-columns: .8fr .8fr .6fr 1.2fr; }
.audit-table .tr { grid-template-columns: .9fr 1fr 1.2fr 1.2fr .7fr .9fr; }
.api-table .tr { grid-template-columns: 1fr 1.2fr .6fr .9fr; }

.form-stack { display: grid; gap: 14px; }
.inline-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr auto;
  gap: 12px;
}
.graph-filter {
  grid-template-columns: minmax(180px, 260px) auto auto;
  justify-content: start;
}
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-panel {
  width: min(440px, 100%);
  padding: 28px;
}
.auth-link {
  margin: 16px 0 0;
  color: var(--muted);
}
.auth-link a {
  color: var(--blue);
  font-weight: 800;
}
.notice {
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 14px;
}
.notice.success {
  background: #e7f6ed;
  color: var(--green);
}
.notice.danger {
  background: #fff0ee;
  color: var(--red);
}

.profile {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px 14px;
  margin: 0;
}
.compact-profile { margin-top: 14px; }
.profile dt { color: var(--muted); }
.profile dd { margin: 0; overflow-wrap: anywhere; }
.advice {
  border-left: 4px solid var(--blue);
  padding: 10px 12px;
  background: #eef5ff;
  border-radius: 0 6px 6px 0;
}
.raw-log {
  white-space: pre-wrap;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
}
.match-box, .update-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  padding: 14px;
}
.match-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.match-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 10px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.section-head h2 { margin-bottom: 0; }
.batch-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.check-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}
.check-label input, .update-select input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}
.updates { display: grid; gap: 12px; }
.update-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1.4fr) minmax(280px, .9fr);
  gap: 14px;
}
.update-select {
  display: flex;
  align-items: flex-start;
  padding-top: 3px;
}
.update-main, .decision-form { display: grid; gap: 8px; }
.update-row.已接受 { border-color: #9fd3b5; }
.update-row.已拒绝 { border-color: #f0b4ae; opacity: .72; }
.decision-form {
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
}
.empty { color: var(--muted); margin: 0; }
.graph-panel { overflow-x: auto; }
.relationship-svg {
  width: 100%;
  min-width: 760px;
  height: auto;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.edge { stroke: #8da2b6; stroke-width: 2; }
.edge-转介绍 { stroke: var(--blue); stroke-width: 3; }
.edge-家庭成员 { stroke: var(--red); stroke-width: 3; }
.edge-同事 { stroke: var(--green); stroke-width: 3; }
.edge-同行, .edge-同属相, .edge-同好 { stroke-dasharray: 7 5; }
.edge-label {
  fill: #475467;
  font-size: 13px;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #f8fafc;
  stroke-width: 5px;
  stroke-linejoin: round;
}
.node {
  fill: white;
  stroke: var(--blue);
  stroke-width: 3;
}
.priority-高 { stroke: var(--red); }
.priority-中 { stroke: var(--amber); }
.priority-低 { stroke: var(--green); }
.node-name {
  fill: var(--ink);
  font-size: 14px;
  font-weight: 800;
  text-anchor: middle;
}
.node-meta {
  fill: var(--muted);
  font-size: 11px;
  text-anchor: middle;
}
.prompt-list {
  display: grid;
  gap: 18px;
}
.prompt-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}
.prompt-head h2 { margin-bottom: 4px; }
.prompt-head p { color: var(--muted); margin: 0; }
.active-pill, .muted-pill {
  border-radius: 999px;
  padding: 5px 10px;
  white-space: nowrap;
}
.active-pill {
  background: #e7f6ed;
  color: var(--green);
}
.muted-pill {
  background: #edf2f7;
  color: var(--muted);
}
.prompt-content {
  max-height: 460px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 14px;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(13, 22, 33, .46);
  backdrop-filter: blur(3px);
}
.loading-overlay.show { display: grid; }
.loading-card {
  width: min(420px, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
  box-shadow: 0 24px 80px rgba(15, 23, 42, .22);
}
.loading-card strong { font-size: 18px; }
.loading-card p {
  margin: 0;
  color: var(--muted);
}
.loading-spinner {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 4px solid #d7e0ea;
  border-top-color: var(--blue);
  animation: spin .8s linear infinite;
}
.progress-bar {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6edf5;
}
.progress-bar span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  animation: progress-slide 1.4s ease-in-out infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes progress-slide {
  0% { transform: translateX(-110%); }
  50% { transform: translateX(70%); }
  100% { transform: translateX(240%); }
}

@media (max-width: 880px) {
  .sidebar { position: static; width: auto; }
  .content { margin-left: 0; padding: 18px; }
  .two-col, .profile-grid, .metric-grid, .inline-form, .graph-filter, .update-row, .decision-form, .match-form { grid-template-columns: 1fr; }
  .section-head { display: grid; }
  .page-head { display: grid; }
  .head-actions { justify-content: start; }
  .tr, .revisions .tr, .graph-nodes .tr, .audit-table .tr, .api-table .tr { grid-template-columns: 1fr; }
}
