:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9dee7;
  --accent: #146ef5;
  --accent-dark: #0f4fb0;
  --good: #09865f;
  --warn: #a15c00;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  padding: 28px 20px;
  background: #111827;
  color: #fff;
}

.brand {
  display: grid;
  gap: 8px;
  margin-bottom: 36px;
}

.brand strong {
  font-size: 22px;
}

.brand span {
  color: #aeb8c8;
  font-size: 13px;
  line-height: 1.5;
}

nav {
  display: grid;
  gap: 8px;
}

nav a {
  color: #d7deea;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 8px;
}

nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

main {
  margin-left: 248px;
  padding: 34px;
}

.portal-page main {
  margin-left: 0;
  max-width: 1180px;
  margin-right: auto;
  margin-left: auto;
}

.portal-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 24px;
  align-items: start;
  padding: 34px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.portal-hero h1 {
  margin-top: 8px;
}

.portal-hero p:not(.eyebrow) {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.65;
  max-width: 680px;
}

.eyebrow {
  color: var(--accent-dark);
  font-weight: 700;
  letter-spacing: 0;
}

.portal-login {
  box-shadow: none;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding: 30px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.25;
  max-width: 820px;
}

.topbar p,
.section-title p,
.item p,
dd {
  color: var(--muted);
  line-height: 1.65;
}

.topbar p {
  margin-top: 12px;
  max-width: 780px;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 11px 16px;
  font-weight: 650;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.secondary {
  background: #e7edf6;
  color: var(--ink);
}

.secondary:hover {
  background: #d7e0ee;
}

.top-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.auth-panel,
.scope-panel,
.notice {
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel {
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 380px) auto;
  gap: 16px;
  align-items: end;
}

.scope-panel {
  padding: 16px 18px;
  max-width: 420px;
}

.auth-panel h2 {
  font-size: 18px;
  margin-bottom: 6px;
}

.auth-actions {
  display: flex;
  gap: 8px;
}

.notice {
  padding: 14px 16px;
  color: #8a3b00;
  background: #fff6ea;
  border-color: #ffd39a;
}

.hidden {
  display: none !important;
}

.section {
  margin-top: 28px;
}

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

.section-title h2 {
  font-size: 22px;
  margin-bottom: 6px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 14px;
}

.metric,
.panel,
.item,
.empty {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.metric strong {
  display: block;
  font-size: 24px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.list {
  display: grid;
  gap: 12px;
}

.side-stack {
  display: grid;
  gap: 18px;
}

.ontology-map {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.ontology-column {
  display: grid;
  gap: 10px;
}

.ontology-column > h3 {
  font-size: 16px;
}

.ontology-node {
  min-height: 150px;
  align-content: space-between;
}

.lineage-node {
  min-height: 136px;
}

.compact {
  margin-top: 18px;
}

.compact-list {
  gap: 8px;
}

.ontology-warning {
  margin: 0 0 14px;
}

.ontology-warning p + p {
  margin-top: 6px;
}

.item {
  padding: 18px;
  display: grid;
  gap: 12px;
}

.proposal-group {
  display: grid;
  gap: 12px;
}

.proposal-group + .proposal-group {
  margin-top: 18px;
}

.proposal-group > h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink);
  font-size: 15px;
}

.proposal-group > h3 span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.item h3 {
  font-size: 17px;
  margin-bottom: 6px;
}

code {
  color: var(--accent-dark);
  background: #eef4ff;
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 12px;
}

ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

dl {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 8px 12px;
  margin: 0;
}

dt {
  color: var(--ink);
  font-weight: 650;
}

dd {
  margin: 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted);
  font-size: 12px;
}

.chips button {
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-actions button {
  padding: 8px 12px;
}

.secret-output {
  display: grid;
  gap: 8px;
  border: 1px solid #b7e3d3;
  background: #eefbf6;
  border-radius: 8px;
  padding: 12px;
}

.secret-output p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.audit-item pre {
  margin: 0;
  white-space: pre-wrap;
  color: var(--muted);
  font-family: inherit;
  line-height: 1.55;
}

.panel {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.panel h3 {
  font-size: 18px;
}
