:root {
  --bg: #f7f6f2;
  --text: #1b1b1b;
  --muted: #5a5a5a;
  --line: #cfcfc7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.5;
}

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 20px 56px;
}

header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 24px;
}

.site-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0 0 8px;
}

nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

nav a {
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}

nav a[aria-current="page"] {
  font-weight: 600;
}

main {
  min-height: 50vh;
}

h1 {
  font-size: 24px;
  margin: 0 0 12px;
  font-weight: 600;
}

h2 {
  font-size: 18px;
  margin: 24px 0 8px;
}

p {
  margin: 0 0 12px;
}

.section-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--line);
}

.section-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.section-list a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

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

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.table th,
.table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 14px;
}

.table th {
  font-weight: 600;
}

.status {
  display: inline-block;
}

.status-registered {
  opacity: 0.8;
}

.status-authorized {
  font-weight: 600;
  opacity: 0.75;
}

.status-restricted {
  opacity: 0.45;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archival-indicator {
  margin-left: 6px;
}

.record-decayed {
  opacity: 0.55;
}

.meta-list {
  margin: 16px 0 24px;
  display: grid;
  grid-template-columns: minmax(120px, 160px) 1fr;
  gap: 8px 16px;
}

.meta-list dt {
  font-weight: 600;
}

.meta-list dd {
  margin: 0;
}

footer {
  border-top: 1px solid var(--line);
  margin-top: 32px;
  padding-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.footer-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  justify-content: space-between;
}

.form {
  max-width: 720px;
  margin-top: 16px;
}

.form > div {
  margin-bottom: 16px;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 8px;
  width: 100%;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  border-radius: 4px;
}

textarea {
  resize: vertical;
  min-height: 120px;
}

button {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}

button:hover {
  background: var(--bg);
}

.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.hidden,
[hidden] {
  display: none !important;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.filter-label {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 0;
}

.filter-row select {
  width: auto;
  min-width: 160px;
}

.related-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.related-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.related-list li:last-child {
  border-bottom: none;
}

.related-list a {
  color: var(--text);
  text-decoration: none;
}

.related-list a[data-status="restricted"] {
  opacity: 0.45;
}

/* Dashboard styles */
.dashboard-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.tab-btn {
  padding: 12px 24px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.dashboard-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.dashboard-table .actions-cell {
  white-space: nowrap;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 12px;
  margin-right: 4px;
}

.btn-danger {
  color: #c00;
  border-color: #c00;
}

.btn-danger:hover {
  background: #fee;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

/* Modal styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  background: var(--bg);
  border: 1px solid var(--line);
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}

.modal-sm {
  max-width: 400px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-body {
  margin-bottom: 16px;
}

.modal-form {
  max-width: none;
}

.modal-form textarea {
  min-height: 80px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: normal;
  margin-top: 6px;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
}

@media (max-width: 640px) {
  nav ul {
    gap: 12px;
  }

  .table th,
  .table td {
    font-size: 13px;
  }

  .filter-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .filter-row select {
    width: 100%;
  }

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

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

  .modal {
    padding: 16px;
  }
}
