:root {
  --bg: #f4efe7;
  --panel: #fffaf2;
  --panel-strong: #fff;
  --text: #231a12;
  --muted: #6b5848;
  --line: #dccdbb;
  --accent: #8c4b2f;
  --accent-soft: #e8c9a8;
  --shadow: 0 18px 45px rgba(53, 34, 19, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(196, 143, 95, 0.2), transparent 35%),
    linear-gradient(180deg, #f8f2ea 0%, var(--bg) 100%);
}

a {
  color: inherit;
}

.layout {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.site-header {
  margin-bottom: 24px;
  padding: 20px 22px;
  background:
    linear-gradient(180deg, rgba(255, 250, 242, 0.98) 0%, rgba(252, 244, 233, 0.96) 100%);
  border: 1px solid rgba(140, 75, 47, 0.12);
  box-shadow: var(--shadow);
  border-radius: 24px;
}

.site-header-row {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.site-brand-block {
  min-width: 0;
}

.site-brand-surface {
  display: grid;
  gap: 18px;
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(244, 229, 210, 0.72) 100%);
  border: 1px solid rgba(140, 75, 47, 0.1);
}

.site-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, #9a5736 0%, #6e3923 100%);
  color: #fff7ee;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.site-brand-text {
  font-size: 22px;
  font-weight: 700;
}

.site-brand-copy {
  display: grid;
  gap: 3px;
}

.site-brand-subtitle {
  color: var(--muted);
  font-size: 14px;
}

.site-current-page {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 249, 242, 0.82);
  border: 1px solid rgba(140, 75, 47, 0.12);
  color: #5b311f;
  font-size: 14px;
}

.site-current-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.site-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.site-nav-group {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 16px;
  min-width: 0;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(140, 75, 47, 0.1);
}

.site-nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.site-nav-description {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.site-nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.site-nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 999px;
  text-decoration: none;
  background: rgba(232, 201, 168, 0.32);
  border: 1px solid rgba(140, 75, 47, 0.12);
  color: #5b311f;
  transition: background 0.18s ease, transform 0.18s ease;
}

.site-nav-link:hover {
  background: rgba(232, 201, 168, 0.56);
  transform: translateY(-1px);
}

.site-nav-link.is-active {
  background: var(--accent);
  color: #fff9f2;
  box-shadow: 0 10px 20px rgba(110, 57, 35, 0.2);
}

.hero,
.page-head,
.table-panel,
.alert {
  background: rgba(255, 250, 242, 0.92);
  border: 1px solid rgba(140, 75, 47, 0.12);
  box-shadow: var(--shadow);
  border-radius: 24px;
}

.hero,
.page-head {
  padding: 28px;
  margin-bottom: 24px;
}

.hero-copy {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.55;
}

.hero-actions {
  margin: 18px 0 0;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-size: 12px;
}

h1,
h2 {
  margin: 0;
}

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

.entity-card {
  display: block;
  text-decoration: none;
  padding: 20px;
  border-radius: 22px;
  background: linear-gradient(180deg, var(--panel-strong) 0%, var(--panel) 100%);
  border: 1px solid rgba(140, 75, 47, 0.16);
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.entity-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 22px 48px rgba(53, 34, 19, 0.18);
}

.entity-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.entity-card p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #5b311f;
  font-size: 12px;
  font-weight: 700;
}

.button-link,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff9f2;
  text-decoration: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.button-link:hover,
.primary-button:hover {
  filter: brightness(1.05);
}

.alert {
  padding: 18px 20px;
  margin-bottom: 24px;
  border-color: rgba(161, 47, 47, 0.2);
}

.alert-success {
  border-color: rgba(53, 124, 66, 0.22);
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
}

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

.search-box {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.search-box input {
  width: min(320px, 100%);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
}

.table-panel {
  padding: 20px;
}

.migrate-panel {
  margin-bottom: 24px;
}

.migrate-card h2 {
  margin-bottom: 10px;
}

.migrate-card p {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.55;
}

.table-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
}

.table-entity-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.table-entity-link:hover,
.detail-inline-link:hover,
.stat-card:hover {
  text-decoration: underline;
}

.table-entity-link-muted {
  font-weight: 400;
}

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

.data-table th,
.data-table td {
  padding: 12px 14px;
  vertical-align: top;
  border-bottom: 1px solid #eee2d3;
  text-align: left;
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: #f9f1e7;
  z-index: 1;
}

.data-table tbody tr:nth-child(even) {
  background: #fffaf5;
}

.cell-muted {
  color: #9b8a79;
  font-style: italic;
}

.cell-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
}

.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 28px;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.95fr);
  gap: 24px;
}

.detail-main,
.detail-sidebar,
.related-groups,
.stat-grid,
.asset-list {
  display: grid;
  gap: 18px;
}

.detail-section {
  padding: 22px;
  background: rgba(255, 250, 242, 0.92);
  border: 1px solid rgba(140, 75, 47, 0.12);
  box-shadow: var(--shadow);
  border-radius: 24px;
}

.detail-hero-card {
  gap: 18px;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.detail-meta-item {
  color: var(--muted);
  font-size: 14px;
}

.detail-richtext {
  color: var(--text);
  line-height: 1.7;
  white-space: normal;
}

.detail-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.detail-section-head h2,
.related-group h3 {
  margin: 0;
}

.detail-prompt {
  margin: 0;
  padding: 18px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Consolas, Monaco, monospace;
  font-size: 13px;
  line-height: 1.65;
}

.detail-empty {
  margin: 0;
  color: var(--muted);
}

.related-group {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(140, 75, 47, 0.1);
}

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

.detail-inline-link {
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

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

.related-item {
  padding-top: 12px;
  border-top: 1px solid rgba(140, 75, 47, 0.12);
}

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

.related-item p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.stat-grid {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.stat-card {
  display: grid;
  gap: 6px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(140, 75, 47, 0.1);
  text-decoration: none;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.stat-value {
  font-size: 26px;
}

.asset-item {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(140, 75, 47, 0.1);
}

.asset-label {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 900px) {
  .layout {
    width: min(100% - 20px, 1380px);
  }

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

  .site-nav {
    grid-template-columns: 1fr;
  }

  .site-nav-group {
    padding: 14px;
  }

  .page-head {
    align-items: stretch;
    flex-direction: column;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .search-box input {
    width: 100%;
  }
}
