:root {
  --bg: #f3f0e8;
  --panel: #fffdf8;
  --ink: #1f2620;
  --muted: #667067;
  --line: #d9d1c3;
  --accent: #184a45;
  --accent-soft: #d7ebe7;
  --danger: #7a2e2e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background: linear-gradient(180deg, #ebe4d7 0%, var(--bg) 30%, #f8f6f1 100%);
  min-height: 100vh;
}

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

a:hover {
  text-decoration: underline;
}

.container {
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto;
}

main.container {
  min-height: calc(100vh - 84px);
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.92);
  backdrop-filter: blur(8px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
}

.brand {
  font-size: 1.35rem;
  font-weight: 700;
}

.nav {
  display: flex;
  gap: 1rem;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.6rem 0 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 10px 30px rgba(31, 38, 32, 0.05);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.table th,
.table td {
  padding: 0.85rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.sources-scroll {
  max-height: calc(100vh - 280px);
  overflow-y: auto;
  overflow-x: auto;
  padding: 0;
}

.sources-table {
  border: none;
  border-radius: 0;
  min-width: 1380px;
}

.table th {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: #f5efe4;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0.65rem 0.95rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: white;
  background: var(--accent);
  cursor: pointer;
  font: inherit;
}

.button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.button.secondary,
.button.subtle {
  color: var(--accent);
  background: white;
}

.button.active {
  background: #0f2f2c;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.82rem;
}

.badge.success {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.muted-badge {
  background: #ece7dc;
  color: var(--muted);
}

.filters-grid,
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.filters-grid label,
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.full {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.75rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  color: var(--ink);
  font: inherit;
}

.checkbox {
  flex-direction: row;
  align-items: center;
}

.checkbox input {
  width: auto;
}

.actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.align-end {
  align-self: end;
}

.wrap-actions {
  flex-wrap: wrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.meta {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0.55rem 1rem;
}

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

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

.mono {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.86rem;
}

.wrap {
  max-width: 28rem;
  word-break: break-word;
}

.text-block {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 32rem;
  overflow: auto;
  padding-top: 1rem;
}

.related-list {
  margin: 0;
  padding-left: 1rem;
}

.notice {
  margin-bottom: 1rem;
}

.notice.warn {
  background: #fff8e7;
  border: 1px solid #e7cf8b;
}

.notice.error,
.badge.danger {
  background: #f6e5e5;
  color: var(--danger);
}

.narrow-form {
  max-width: 48rem;
}

.test-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.test-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem;
  background: #fffdfa;
}

.compact {
  max-height: 14rem;
  padding-top: 0.5rem;
  font-size: 0.9rem;
}

.stack {
  margin: 0.75rem 0 0;
  padding: 0.75rem;
  border-radius: 12px;
  background: #201b1b;
  color: #f6efef;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
}

@media (max-width: 860px) {
  .page-head,
  .topbar-inner,
  .actions,
  .nav,
  .detail-grid,
  .filters-grid,
  .form-grid,
  .test-grid {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .meta {
    grid-template-columns: 1fr;
  }

  .table {
    display: block;
    overflow-x: auto;
  }
}
