/* Landscape database. Builds on /cic/style.css and ../landscape.css tokens. */

:root {
  --row-hover: rgba(196, 112, 63, 0.05);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --radius: 6px;
}

.db { --page-max: 1180px; }
.db-main {
  padding: 28px 28px 80px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.muted { color: var(--text-tertiary); }
.sub {
  display: block;
  font-size: 0.78rem;
  color: var(--text-tertiary);
  line-height: 1.4;
  margin-top: 1px;
}

/* ---- Header, tabs ---- */

.db .site-nav { display: flex; }
footer a { color: var(--text-secondary); text-decoration-color: var(--border); }
footer a:hover { color: var(--terra); }
.nav-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.link-button {
  font: inherit;
  color: var(--text-secondary);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.link-button:hover { color: var(--terra); border-color: var(--terra); }

.db-tabs {
  display: flex;
  gap: 4px 22px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin: 0 0 32px;
  font-size: 0.85rem;
}
main .db-tabs a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 10px 0 9px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.2s ease, border-color 0.2s ease;
}
main .db-tabs a:hover { color: var(--text); }
main .db-tabs a.active { color: var(--text); border-bottom-color: var(--terra); font-weight: 500; }

.count-badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--terra);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  vertical-align: 1px;
}

.page-title {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 2.1rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 12px;
}
.page-title::after {
  content: '';
  display: block;
  width: 40px;
  height: 3px;
  background: var(--terra);
  border-radius: 2px;
  margin-top: 14px;
}
.db-head { margin-bottom: 26px; }
.lede {
  color: var(--text-secondary);
  font-size: 0.98rem;
  max-width: 72ch;
  margin: 0;
}

/* ---- Search row and view switch ---- */

.search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.search-row input[type="search"] {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1rem;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-row input[type="search"]:focus {
  outline: none;
  border-color: var(--terra);
  box-shadow: 0 0 0 3px var(--terra-muted);
}

.btn {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 10px 20px;
  border: 1px solid var(--terra);
  border-radius: var(--radius);
  background: var(--terra);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.btn:hover { background: var(--terra-light); border-color: var(--terra-light); }
.btn:active { transform: translateY(1px); }
.btn-small { font-size: 0.8rem; padding: 6px 14px; }
main a.btn { color: #fff; text-decoration: none; }
.btn-quiet, main a.btn-quiet {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-quiet:hover, main a.btn-quiet:hover { background: var(--cream); color: var(--terra); border-color: var(--terra); }

.view-switch {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 3px;
  margin-bottom: 26px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.82rem;
}
.view-option {
  position: relative;
  padding: 5px 15px;
  border-radius: 999px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.2s ease, box-shadow 0.25s var(--ease);
}
.view-option input { position: absolute; opacity: 0; pointer-events: none; }
.view-option:hover { color: var(--text); }
.view-option.active {
  background: #fff;
  color: var(--text);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(26, 22, 18, 0.08);
}
.view-option:has(input:focus-visible) { outline: 2px solid var(--terra); outline-offset: 1px; }

/* ---- Layout ---- */

.db-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}

/* ---- Facets ---- */

.facets { font-size: 0.85rem; position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow-y: auto; padding-right: 6px; scrollbar-width: thin; }
.filters-toggle > summary { display: none; }
.facet-note { font-size: 0.75rem; color: var(--text-tertiary); margin: 0 0 8px; }

details { interpolate-size: allow-keywords; }
details::details-content {
  height: 0;
  overflow: clip;
  opacity: 0;
  transition: height 0.22s var(--ease), opacity 0.2s ease, content-visibility 0.22s allow-discrete;
}
details[open]::details-content { height: auto; opacity: 1; }

.facet { border-bottom: 1px solid var(--border); }
.facet > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 0;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.facet > summary::-webkit-details-marker { display: none; }
.facet > summary::after {
  content: '';
  margin-left: auto;
  width: 7px; height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.22s var(--ease);
  opacity: 0.6;
}
.facet[open] > summary::after { transform: rotate(225deg) translateY(-2px); }
.facet > summary:hover { color: var(--text); }
.facet-active {
  font-size: 0.65rem;
  color: #fff;
  background: var(--terra);
  border-radius: 8px;
  padding: 0 6px;
  letter-spacing: 0;
}
.facet-body { padding: 0 0 12px; }
.facet-list { list-style: none; margin: 0; padding: 0; }
.facet-list li { margin: 0; max-width: none; line-height: 1.3; }
.facet-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  margin: 0 -6px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s ease, color 0.15s ease;
}
.facet-item:hover { background: var(--cream); }
.facet-item input { accent-color: var(--terra); margin: 0; flex: none; }
.facet-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.facet-count {
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  transition: color 0.3s ease;
}
.facet-count.bump { animation: bump 0.45s var(--ease); }
.facet-item.on { color: var(--terra); font-weight: 500; }
.facet-item.on .facet-count { color: var(--terra); }
.facet-item.zero { opacity: 0.45; }
.facet-more > summary {
  list-style: none;
  font-size: 0.78rem;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px 0;
}
.facet-more > summary::-webkit-details-marker { display: none; }
.facet-more > summary:hover { color: var(--terra); }
.facet-more[open] > summary { display: none; }

.scale label { display: block; font-size: 0.78rem; color: var(--text-secondary); margin: 8px 0 3px; }
.scale label.check { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.scale input[type="number"], .scale select { width: 100%; }

.facet-actions { display: flex; align-items: center; gap: 14px; padding: 14px 0; }
main a.clear-link { font-size: 0.8rem; color: var(--text-secondary); }
.js .apply-button { display: none; }

/* ---- Inputs (shared) ---- */

.db input[type="text"], .db input[type="number"], .db input[type="password"], .db select, .db textarea {
  font: inherit;
  font-size: 0.9rem;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  width: 100%;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.db input:focus, .db select:focus, .db textarea:focus {
  outline: none;
  border-color: var(--terra);
  box-shadow: 0 0 0 3px var(--terra-muted);
}
.db input[type="checkbox"], .db input[type="radio"] { accent-color: var(--terra); }

/* ---- Results ---- */

.results { min-width: 0; transition: opacity 0.2s ease; }
.results.loading { opacity: 0.45; }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0 0 16px; }
.chips li { margin: 0; max-width: none; }
main a.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px 3px 11px;
  border-radius: 999px;
  background: var(--terra-muted);
  color: var(--text);
  font-size: 0.78rem;
  text-decoration: none;
  animation: chip-in 0.28s var(--ease) both;
  transition: background 0.2s ease;
}
main a.chip:hover { background: rgba(196, 112, 63, 0.22); color: var(--text); }
.chip-x {
  display: inline-grid;
  place-items: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  font-size: 0.85rem;
  line-height: 1;
  color: var(--terra);
  transition: background 0.2s ease, color 0.2s ease;
}
main a.chip:hover .chip-x { background: var(--terra); color: #fff; }
main a.chip-clear { background: none; color: var(--text-tertiary); padding-right: 11px; }
main a.chip-clear:hover { background: var(--cream); color: var(--terra); }

.result-bar { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
.result-count { margin: 0; color: var(--text-secondary); font-size: 0.9rem; }
.result-count strong { font-family: var(--font-serif); font-size: 1.4rem; font-weight: 600; color: var(--text); margin-right: 2px; }
main a.export-link { font-size: 0.8rem; color: var(--text-secondary); }

.data-note {
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--cream);
  border-left: 2px solid var(--grade-b);
  padding: 8px 12px;
  margin: 8px 0 12px;
  max-width: none;
  border-radius: 0 4px 4px 0;
}

.try { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin: 10px 0 16px; font-size: 0.8rem; }
.try span { color: var(--text-tertiary); }
main .try a {
  text-decoration: none;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 11px;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
main .try a:hover { border-color: var(--terra); color: var(--terra); background: #fff; }

.table-wrap { overflow-x: auto; margin: 0 0 20px; -webkit-overflow-scrolling: touch; }
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}
.results-table th, .results-table thead th {
  background: transparent;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--text-tertiary);
  white-space: nowrap;
}
main .results-table th a { color: inherit; text-decoration: none; }
main .results-table th a:hover { color: var(--terra); }
.results-table th[aria-sort] { color: var(--text); }
.sort-arrow { margin-left: 4px; color: var(--terra); }
.results-table tbody tr:nth-child(even) td { background: transparent; }
.results-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.4;
}
.results-table tbody tr { transition: background 0.15s ease; }
.results-table tbody tr:hover { background: var(--row-hover); }
.results-table .n { text-align: right; white-space: nowrap; }
.results-table .c { text-align: center; }
.results-table .n .sub { white-space: nowrap; }
main a.row-link { font-weight: 500; color: var(--text); text-decoration: none; }
main a.row-link:hover { color: var(--terra); }
.results-table td > a:not(.row-link) { text-decoration-color: transparent; }
.results-table td > a:not(.row-link):hover { text-decoration-color: var(--terra-light); }
.source-cell { max-width: 14rem; overflow-wrap: anywhere; font-size: 0.8rem; }
.country {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
  vertical-align: 1px;
}

/* Row entrance after load or a filter change: short, capped stagger */
.results-table tbody tr { animation: row-in 0.32s var(--ease) both; }
.results-table tbody tr:nth-child(2) { animation-delay: 20ms; }
.results-table tbody tr:nth-child(3) { animation-delay: 40ms; }
.results-table tbody tr:nth-child(4) { animation-delay: 60ms; }
.results-table tbody tr:nth-child(5) { animation-delay: 80ms; }
.results-table tbody tr:nth-child(6) { animation-delay: 100ms; }
.results-table tbody tr:nth-child(7) { animation-delay: 120ms; }
.results-table tbody tr:nth-child(8) { animation-delay: 140ms; }
.results-table tbody tr:nth-child(9) { animation-delay: 160ms; }
.results-table tbody tr:nth-child(10) { animation-delay: 180ms; }
.results-table tbody tr:nth-child(11) { animation-delay: 200ms; }
.results-table tbody tr:nth-child(n+12) { animation-delay: 220ms; }

.cx { font-size: 0.8rem; white-space: nowrap; }
.cx::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
}
.cx-low::before { background: var(--grade-a); }
.cx-medium::before { background: var(--grade-b); }
.cx-high::before { background: var(--grade-c); }

.pill {
  display: inline-block;
  font-size: 0.72rem;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--sand);
  color: var(--text-secondary);
  white-space: nowrap;
  margin: 1px 0;
}
.pill-warn { background: rgba(196, 136, 79, 0.16); color: #8a5a2b; }
.status-pending { background: var(--sand); }
.status-approved { background: rgba(74, 140, 92, 0.14); color: #2f6b3e; }
.status-rejected { background: rgba(176, 106, 85, 0.14); color: #8c4a37; }
.kind-create { background: rgba(74, 140, 92, 0.14); color: #2f6b3e; }
.kind-update { background: var(--terra-muted); color: var(--terra); }

.empty { padding: 40px 0; }
.empty h2 { margin-top: 0; font-size: 1.3rem; }

.pager { display: flex; justify-content: center; gap: 20px; font-size: 0.85rem; color: var(--text-secondary); padding: 10px 0; }

/* ---- Detail pages ---- */

.detail { max-width: 900px; }
.detail-head { margin-bottom: 24px; }
.detail-actions { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0 0 24px;
}
.stat { background: var(--cream); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.stat-k { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-tertiary); }
.stat-v { font-size: 1rem; color: var(--text); }
.stat-v.num { font-family: var(--font-serif); font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 0.75rem; color: var(--text-tertiary); }

.kv-list { margin: 0 0 20px; font-size: 0.9rem; }
.kv-row { display: grid; grid-template-columns: 180px 1fr; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.kv-row dt { color: var(--text-tertiary); font-size: 0.82rem; }
.kv-row dd { margin: 0; }
.detail-notes p { color: var(--text-secondary); }
.detail h2 { font-size: 1.25rem; margin-top: 36px; }
.detail h2 .muted { font-family: var(--font-sans); font-size: 0.85rem; font-weight: 400; }

main a.tag {
  display: inline-block;
  font-size: 0.75rem;
  text-decoration: none;
  color: var(--text-secondary);
  background: var(--sand);
  border-radius: 3px;
  padding: 1px 7px;
  margin: 1px 2px 1px 0;
  transition: background 0.2s ease, color 0.2s ease;
}
main a.tag::before { content: '#'; opacity: 0.5; margin-right: 1px; }
main a.tag:hover { background: var(--terra-muted); color: var(--terra); }

.sector-list, .link-list { list-style: none; padding: 0; }
.sector-list li, .link-list li { padding: 8px 0; border-bottom: 1px solid var(--border); margin: 0; max-width: none; }

/* ---- Forms ---- */

.type-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 20px; }
main a.type-card {
  display: block;
  padding: 18px 20px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-left: 3px solid var(--terra);
  border-radius: 0 8px 8px 0;
  text-decoration: none;
  color: inherit;
  transition: background 0.2s ease, transform 0.2s var(--ease);
}
main a.type-card:hover { background: #fff; transform: translateX(2px); }
.type-card h3 { margin: 0 0 4px; font-family: var(--font-serif); font-size: 1.05rem; }
.type-card p { margin: 0; font-size: 0.85rem; color: var(--text-secondary); }

.suggest-form { max-width: 860px; }
.suggest-form fieldset { border: 0; border-top: 1px solid var(--border); padding: 18px 0 8px; margin: 0 0 8px; }
.suggest-form legend { font-family: var(--font-serif); font-size: 1.15rem; font-weight: 600; padding-right: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 20px; }
.form-group { margin-bottom: 12px; }
.form-group.wide { grid-column: 1 / -1; }
.form-group label, .edit-form label, .reject label, .login-card label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.req { font-weight: 400; color: var(--text-tertiary); font-size: 0.72rem; margin-left: 4px; }
.hint { font-size: 0.75rem; color: var(--text-tertiary); margin: 4px 0 0; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 14px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 400 !important; }
.nested { background: var(--cream); padding-left: 16px !important; padding-right: 16px !important; border-radius: var(--radius); }
.form-actions { display: flex; align-items: center; gap: 16px; margin-top: 12px; }

.form-error, .flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  max-width: none;
  animation: fade-down 0.3s var(--ease) both;
}
.form-error { background: rgba(176, 106, 85, 0.12); color: #7c3f2e; }
.flash { background: rgba(74, 140, 92, 0.12); color: #2f6b3e; }
.flash-warn { background: rgba(196, 136, 79, 0.15); color: #7a4f23; }

.login-card {
  max-width: 400px;
  margin: 40px auto;
  padding: 30px 30px 26px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-left: 3px solid var(--terra);
  border-radius: 0 8px 8px 0;
  animation: fade-up 0.4s var(--ease) both;
}
.login-card .page-title { font-size: 1.7rem; }
.login-card p { color: var(--text-secondary); font-size: 0.9rem; }
.login-card input { margin-bottom: 14px; }
.login-card .btn { width: 100%; margin-top: 4px; }

/* ---- Review queue ---- */

.queue-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; font-size: 0.8rem; }
main .queue-filter a {
  text-decoration: none;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 11px;
}
main .queue-filter a.active { border-color: var(--terra); color: var(--terra); background: #fff; }

.queue-list { list-style: none; padding: 0; margin: 0; }
.queue-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  margin: 0 0 10px;
  max-width: none;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.queue-item:hover { border-color: #cfc5b6; }
.queue-item:has(> details[open]) { box-shadow: 0 2px 10px rgba(26, 22, 18, 0.05); }
.queue-head {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 12px 16px;
  cursor: pointer;
}
.queue-head::-webkit-details-marker { display: none; }
.compact .queue-head { cursor: default; }
.queue-title { font-weight: 500; flex: 1 1 260px; min-width: 0; }
.queue-date { font-size: 0.75rem; color: var(--text-tertiary); white-space: nowrap; }
.queue-body { padding: 0 16px 16px; }
.queue-meta { font-size: 0.8rem; color: var(--text-secondary); max-width: none; }
.queue-reason { font-size: 0.85rem; color: var(--text-secondary); padding: 0 16px 12px; margin: 0; }
.just-added { animation: highlight 1.6s ease both; }

.why {
  border-left: 3px solid var(--terra);
  background: var(--cream);
  padding: 10px 14px;
  margin: 0 0 12px;
  border-radius: 0 4px 4px 0;
}
.why-k { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--terra); }
.why p { margin: 4px 0 0; font-size: 0.9rem; max-width: 80ch; }

.diff-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; margin: 6px 0 14px; }
.diff-table th, .diff-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.diff-table thead th { background: transparent; padding: 7px 10px; }
.diff-table thead th { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-tertiary); }
.diff-table tbody th { font-weight: 500; color: var(--text-secondary); width: 22%; }
.diff-table tr.changed td.proposed { animation: changed-in 0.9s ease 0.15s both; }
.diff-table tr.conflict th::after { content: ' ⚠'; color: #b07a3a; }

.review-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.review-actions > details { flex: 0 0 auto; }
.review-actions > details[open] { flex: 1 1 100%; order: 2; background: var(--cream); padding: 12px 14px; border-radius: var(--radius); }
.review-actions summary { list-style: none; }
.review-actions summary::-webkit-details-marker { display: none; }
.review-actions .edit-form, .review-actions .reject form { margin-top: 12px; }
.reject textarea { margin-bottom: 10px; }

/* ---- Keyframes ---- */

@keyframes row-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes chip-in { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: none; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade-down { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes bump { 0% { color: var(--terra); transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes changed-in { from { background: transparent; } to { background: rgba(74, 140, 92, 0.1); } }
@keyframes highlight { from { background: var(--terra-muted); } to { background: #fff; } }

/* ---- Responsive ---- */

@media (max-width: 860px) {
  .db-main { padding: 20px 20px 60px; }
  .db-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .facets { position: static; max-height: none; overflow: visible; padding: 0; }
  .filters-toggle {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    padding: 0 14px;
  }
  .filters-toggle > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
    padding: 11px 0;
    font-weight: 600;
    cursor: pointer;
  }
  .filters-toggle > summary::-webkit-details-marker { display: none; }
  .filters-toggle > summary::after {
    content: '';
    margin-left: auto;
    width: 7px; height: 7px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    transition: transform 0.22s var(--ease);
  }
  .filters-toggle[open] > summary::after { transform: rotate(225deg) translateY(-2px); }
  .page-title { font-size: 1.7rem; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .kv-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .nav-user span { display: none; }
  .view-switch { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; border-radius: 10px; }
  .view-option { text-align: center; padding: 6px 2px; border-radius: 8px; font-size: 0.76rem; }
  .search-row .btn { padding: 10px 14px; }
  .results-table { font-size: 0.82rem; }
  .results-table td, .results-table th { padding: 8px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, details::details-content {
    animation: none !important;
    transition: none !important;
  }
}

/* ---- Graph explorer ---- */

.db-graph { --page-max: 1480px; }
.graph-head { margin-bottom: 16px; }
.graph-head .lede { font-size: 0.9rem; }

.graph-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 14px;
  padding: 12px 14px;
  margin: 0 0 12px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8rem;
}
.tb-group { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tb-group label { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-tertiary); }
.db .graph-toolbar select, .db .graph-toolbar input[type="search"] { font-size: 0.82rem; padding: 5px 8px; width: auto; max-width: 15rem; }
.tb-find input[type="search"] { width: 15rem; font: inherit; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.tb-find input[type="search"]:focus { outline: none; border-color: var(--terra); box-shadow: 0 0 0 3px var(--terra-muted); }
.tb-toggle { display: flex; align-items: center; gap: 6px; padding-bottom: 6px; cursor: pointer; font-weight: 500; }
main a.tb-table { margin-left: auto; padding-bottom: 6px; font-size: 0.8rem; color: var(--text-secondary); }

.graph-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: stretch;
}
.graph-canvas {
  position: relative;
  height: max(520px, calc(100vh - 250px));
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  touch-action: none;
  outline: none;
}
.graph-canvas:focus-visible { box-shadow: 0 0 0 3px var(--terra-muted); border-color: var(--terra); }
.graph-svg { display: block; width: 100%; height: 100%; cursor: grab; user-select: none; }
.graph-svg:active { cursor: grabbing; }
.graph-loading {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--text-tertiary); font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.7);
}
.graph-loading[hidden] { display: none; }
.graph-noscript { padding: 20px; }

.g-link { stroke: #cbbfae; stroke-linecap: round; vector-effect: non-scaling-stroke; opacity: 0.75; transition: opacity 0.2s ease, stroke 0.2s ease; }
.g-link-makes { stroke: #ddd3c5; }
.g-link.unknown { stroke-dasharray: 3 3; }
.g-link.imported { stroke-dasharray: 1 3; }
.g-link.on { stroke: #6b5d4f; opacity: 0.95; }
.g-link.dim { opacity: 0.08; }

.g-node { cursor: pointer; transition: opacity 0.2s ease; }
.g-shape { stroke-width: 1.5; vector-effect: non-scaling-stroke; transition: transform 0.2s var(--ease); }
.g-node.unknown .g-shape { stroke-dasharray: 2.5 2; stroke-width: 1.4; }
.g-node:hover .g-shape { transform: scale(1.08); }
.g-node.sel .g-shape { stroke: #2c2418; stroke-width: 2.2; stroke-dasharray: none; }
.g-node.dim { opacity: 0.12; }
.g-ring { fill: none; stroke: #2c2418; vector-effect: non-scaling-stroke; pointer-events: none; }
.opp-named .g-ring { stroke-width: 1.8; }
.opp-candidate .g-ring { stroke-width: 1.1; stroke-dasharray: 2 3; opacity: 0.7; }
.g-grade, .g-fold {
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 700;
  fill: #fff;
  text-anchor: middle;
  pointer-events: none;
}
.g-grade.on-surface { fill: #2c2418; }
.g-label {
  font-family: var(--font-sans);
  fill: #2c2418;
  text-anchor: middle;
  dominant-baseline: hanging;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.g-label-supplier { font-weight: 600; }
.g-label-customer { fill: #6b5d4f; }
.g-label.dim { opacity: 0.15; }

.graph-zoom {
  position: absolute; top: 10px; right: 10px;
  display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: 0 1px 3px rgba(26, 22, 18, 0.06);
}
.graph-zoom button {
  width: 32px; height: 32px;
  border: 0; background: none; cursor: pointer;
  font-size: 1.05rem; line-height: 1; color: var(--text-secondary);
}
.graph-zoom button + button { border-top: 1px solid var(--border); }
.graph-zoom button:hover { background: var(--cream); color: var(--terra); }

.graph-legend {
  position: absolute; left: 10px; bottom: 10px;
  max-width: calc(100% - 20px);
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.72rem;
  color: var(--text-secondary);
}
.graph-legend summary { cursor: pointer; font-weight: 600; font-size: 0.68rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-tertiary); list-style: none; }
.graph-legend summary::-webkit-details-marker { display: none; }
.graph-legend summary::after { content: ' +'; }
.graph-legend details[open] summary::after { content: ' −'; }
.graph-legend details[open] summary { margin-bottom: 5px; }
.lg-items { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 3px 10px; max-width: 470px; }
.lg-items li { display: flex; align-items: center; gap: 5px; margin: 0; max-width: none; line-height: 1.2; }
.lg-size { margin-top: 6px; }
.lg-k { display: block; margin-bottom: 3px; }
.lg-circles { display: flex; align-items: flex-end; gap: 12px; }
.lg-circles span { display: flex; flex-direction: column; align-items: center; gap: 2px; font-variant-numeric: tabular-nums; }

.graph-tip {
  position: absolute; left: 0; top: 0;
  max-width: 260px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(26, 22, 18, 0.1);
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text);
  pointer-events: none;
  display: flex; flex-direction: column; gap: 1px;
  z-index: 2;
}
.graph-tip[hidden] { display: none; }
.graph-tip strong { font-size: 0.86rem; }
.graph-tip b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-type { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-tertiary); margin-bottom: 3px; }
.tip-opp { color: var(--terra); font-weight: 500; }

.graph-panel {
  height: max(520px, calc(100vh - 250px));
  overflow-y: auto;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.84rem;
  scrollbar-width: thin;
}
.graph-panel h3 { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-tertiary); margin: 18px 0 6px; }
.gp-head { display: flex; justify-content: space-between; align-items: center; }
.gp-type { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-tertiary); }
.gp-close { border: 0; background: none; font-size: 1.2rem; cursor: pointer; color: var(--text-tertiary); line-height: 1; }
.gp-close:hover { color: var(--terra); }
.gp-title { font-size: 1.2rem; margin: 4px 0 12px; line-height: 1.25; }
main .gp-title a { color: var(--text); text-decoration-color: var(--border); }
.gp-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 0 0 10px; }
.gp-stats div { background: var(--cream); padding: 8px 10px; }
.gp-stats dt { font-size: 0.66rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-tertiary); }
.gp-stats dd { margin: 0; font-family: var(--font-serif); font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.gp-opp { color: var(--terra); font-weight: 500; font-size: 0.82rem; margin: 0 0 8px; }
.gp-note { color: var(--text-secondary); font-size: 0.8rem; margin: 0 0 8px; }
.gp-list { list-style: none; padding: 0; margin: 0; }
.gp-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0; max-width: none; border-bottom: 1px solid var(--border); }
.gp-link {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 7px;
  padding: 5px 0;
  border: 0; background: none; cursor: pointer;
  font: inherit; text-align: left; color: var(--text);
}
.gp-link:hover { color: var(--terra); }
.gp-val { font-size: 0.75rem; color: var(--text-tertiary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.gp-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.gp-supplier { background: #2a78d6; border-radius: 2px; }
.gp-product { background: #eb6834; }
.gp-customer { background: #1baf7a; transform: rotate(45deg); border-radius: 1px; }
.gp-type.gp-supplier, .gp-type.gp-product, .gp-type.gp-customer { background: none; transform: none; }
.gp-fold { margin: 4px 0 2px; }
.gp-actions { margin-top: 16px; display: flex; gap: 12px; align-items: center; font-size: 0.8rem; }

@media (max-width: 960px) {
  .graph-wrap { grid-template-columns: minmax(0, 1fr); }
  .graph-canvas { height: 68vh; min-height: 420px; }
  .graph-panel { height: auto; max-height: none; }
  main a.tb-table { margin-left: 0; }
  .tb-find input[type="search"] { width: 100%; }
  .tb-find { flex: 1 1 100%; }
  .lg-items { max-width: 100%; }
}
@media (max-width: 600px) {
  .graph-legend { font-size: 0.66rem; padding: 6px 8px; }
  .lg-size { display: none; }
}
.db-graph .db-tabs { margin-bottom: 18px; }
.graph-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin-bottom: 12px; }
.graph-head .landscape-meta { flex-basis: 100%; margin: 0; }
.graph-head .page-title { font-size: 1.55rem; margin: 0; }
.graph-head .page-title::after { display: none; }
.graph-head .lede { font-size: 0.82rem; max-width: 90ch; flex: 1 1 420px; }
.graph-canvas, .graph-panel { height: max(520px, calc(100vh - 150px)); }
@media (max-width: 600px) {
  .graph-toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
  .tb-find { grid-column: 1 / -1; }
  .db .graph-toolbar select { width: 100%; max-width: none; }
  .tb-toggle, main a.tb-table { padding-bottom: 0; align-self: center; }
}
