:root {
  --ink: #13221d;
  --muted: #65736c;
  --paper: #f3f1e9;
  --panel: #fffef9;
  --forest: #164f3f;
  --forest-dark: #0d342b;
  --lime: #d7ef63;
  --line: #d8ddd4;
  --danger: #9c392c;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.hero {
  color: white;
  background:
    radial-gradient(circle at 78% 15%, rgba(215,239,99,.25), transparent 26rem),
    var(--forest-dark);
  border-bottom: 3px solid var(--lime);
}
.hero__inner {
  max-width: 1180px;
  margin: auto;
  padding: 12px 24px 11px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}
.eyebrow {
  margin: 0 0 2px;
  font-size: .58rem;
  font-weight: 750;
  letter-spacing: .15em;
  text-transform: uppercase;
}
h1 { margin: 0; font-size: clamp(1.7rem, 3.5vw, 2.45rem); line-height: .9; letter-spacing: -.045em; }
.lede { max-width: 680px; margin: 5px 0 0; color: #d4e4dd; font-size: .82rem; }
.button {
  border: 0;
  border-radius: 999px;
  padding: 13px 20px;
  font-weight: 750;
  white-space: nowrap;
}
.button--light { background: var(--lime); color: var(--forest-dark); padding: 7px 13px; font-size: .78rem; }
.button--primary { background: var(--forest); color: white; }
.button--secondary { border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
.button:disabled { opacity: .55; cursor: wait; }

.shell { max-width: 1180px; margin: 0 auto; padding: 0 24px 60px; }
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: -1px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 0;
}
.stats article { padding: 8px 16px; border-right: 1px solid var(--line); }
.stats article:last-child { border: 0; }
.stats strong { display: block; font-size: 1.15rem; letter-spacing: -.03em; }
.stats span { color: var(--muted); font-size: .62rem; text-transform: uppercase; letter-spacing: .07em; }
.scan-state strong { font-size: .8rem; padding: 1px 0; }

.toolbar { margin: 10px 0 12px; display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: end; }
.search span { display: block; margin-bottom: 4px; font-size: .7rem; font-weight: 750; }
.search input {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel);
  padding: 8px 11px;
  outline: none;
}
.search input:focus { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(22,79,63,.12); }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { border: 0; border-bottom: 3px solid transparent; background: transparent; padding: 14px 16px; color: var(--muted); }
.tab.is-active { color: var(--ink); border-bottom-color: var(--forest); font-weight: 750; }
.view-controls { display: flex; align-items: end; gap: 16px; }
.display-toggle { display: flex; padding: 3px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; }
.display-button { border: 0; border-radius: 999px; padding: 9px 13px; background: transparent; color: var(--muted); font-size: .78rem; font-weight: 700; }
.display-button.is-active { background: var(--forest); color: white; }

.results { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.results--table { display: block; }
.card {
  min-height: 180px;
  padding: 21px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 3px;
  box-shadow: 0 8px 24px rgba(20,45,36,.04);
}
button.card { text-align: left; color: inherit; }
button.card:hover { border-color: var(--forest); transform: translateY(-2px); }
.card__top { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.card h2 { margin: 8px 0 18px; font-size: 1.3rem; letter-spacing: -.03em; }
.card--conflict { border-color: #d38a71; box-shadow: inset 4px 0 #bc4d2f; }
.card--link { color: inherit; text-decoration: none; display: block; }
.card--link:hover { border-color: var(--forest); transform: translateY(-2px); }
.article-name { min-height: 2.8em; font-size: 1rem !important; line-height: 1.4; }
.card-action { display: block; margin-top: 18px; color: var(--forest); font-size: .82rem; font-weight: 800; }
.card-actions { display: flex; justify-content: space-between; align-items: center; }
.edit-link { border: 0; padding: 4px 0; background: transparent; color: var(--forest); font-size: .78rem; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.conflict-badge {
  display: inline-block;
  margin-bottom: 10px;
  border-radius: 3px;
  padding: 5px 7px;
  background: #f8dfd7;
  color: #8b301d;
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.card__id { font-size: 1.45rem; font-weight: 800; color: var(--forest); letter-spacing: -.04em; }
.language-flag { display: inline-flex; align-items: center; gap: 5px; font-size: .85rem; font-weight: 800; white-space: nowrap; }
.document-version { margin: -9px 0 14px; color: var(--forest); font-size: .78rem; font-weight: 750; }
.document-meta-inline { display: inline-block; margin: 3px 0; }
.document-edit-link { border: 0; padding: 0; background: transparent; color: var(--forest); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.document-chip-link { cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.inline-document-link { font-size: inherit; }
.meta { margin: 4px 0; color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 17px; }
.chip { border-radius: 999px; padding: 5px 8px; background: #e8eee9; color: #274d40; font-size: .76rem; font-weight: 700; }
.card-documents { margin: 13px 0 0; }
.label { display: block; color: var(--muted); font-size: .66rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.document-chips { margin-top: 6px; }
.document-chips .chip { background: var(--lime); color: var(--forest-dark); }
.count-badge { min-width: 34px; padding: 5px 9px; border-radius: 999px; background: var(--lime); text-align: center; font-weight: 800; }
.empty { grid-column: 1 / -1; padding: 60px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); }
.message, .errors { margin-bottom: 16px; padding: 12px 15px; border-radius: 3px; }
.message { background: #e4f0e8; color: #174b39; }
.errors { background: #f7e7e3; color: var(--danger); white-space: pre-wrap; }

dialog { width: min(760px, calc(100vw - 28px)); max-height: 82vh; border: 0; border-radius: 5px; padding: 0; color: var(--ink); box-shadow: 0 30px 100px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(7,25,20,.66); }
.dialog__header { padding: 25px 28px; display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog__header h2 { margin: 0; font-size: 2rem; color: var(--forest); }
.icon-button { border: 0; background: transparent; font-size: 2rem; line-height: 1; }
#dialog-body { padding: 24px 28px 30px; }
.detail-section + .detail-section { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.detail-section h3 { margin: 0 0 12px; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; }
.detail-list { list-style: none; padding: 0; margin: 0; }
.detail-list li { padding: 8px 0; border-bottom: 1px solid #edf0eb; display: flex; justify-content: space-between; gap: 20px; }
.detail-list small { color: var(--muted); text-align: right; }
.detail-list a { color: var(--forest); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.detail-names--conflict { color: #852d1b; }
.detail-names strong { display: inline-block; margin: 3px 0; }
.conflict-text { margin: 10px 0 0; padding: 9px 11px; background: #f8dfd7; }
.article-usage { display: inline-block; margin-top: 4px; font-style: italic; text-align: left !important; }
.related--conflict { box-shadow: inset 3px 0 #bc4d2f; padding-left: 10px !important; }
.pdf-dialog { width: min(1200px, calc(100vw - 28px)); max-width: none; height: 92vh; }
.pdf-dialog .dialog__header { align-items: center; }
.pdf-dialog iframe { display: block; width: 100%; height: calc(92vh - 105px); border: 0; background: #d7d9d6; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); background: var(--panel); box-shadow: 0 8px 24px rgba(20,45,36,.04); }
.catalogue-table { width: 100%; border-collapse: collapse; min-width: 780px; text-align: left; }
.catalogue-table th {
  padding: 13px 16px;
  border-bottom: 2px solid var(--line);
  background: #e8eee9;
  color: #355047;
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.sort-button { display: inline-flex; align-items: center; gap: 6px; border: 0; padding: 0; background: transparent; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.sort-button span { color: #819088; font-size: .68rem; }
.sort-button.is-active, .sort-button:hover { color: var(--forest-dark); }
.sort-button.is-active span { color: var(--forest); }
.catalogue-table td { padding: 14px 16px; border-bottom: 1px solid #e8ece6; vertical-align: top; font-size: .86rem; }
.catalogue-table tbody tr:last-child td { border-bottom: 0; }
.catalogue-table tbody tr:hover { background: #f6f8f3; }
.catalogue-table tbody tr[data-sku] { cursor: pointer; }
.catalogue-table a { color: var(--forest); font-weight: 700; }
.table-link { border: 0; padding: 0; background: transparent; color: var(--forest); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.table-row--conflict td:first-child { box-shadow: inset 4px 0 #bc4d2f; }
.table-row--conflict { background: #fff7f3; }
.table-documents { display: flex; flex-wrap: wrap; gap: 5px; min-width: 180px; }
.table-documents .chip { background: var(--lime); color: var(--forest-dark); }
.table-actions { white-space: nowrap; }
.table-actions > * + * { margin-left: 12px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
#edit-form { padding: 24px 28px 28px; }
#edit-dialog { width: min(1120px, calc(100vw - 28px)); overflow: auto; }
.edit-fields { display: grid; gap: 17px; }
.edit-fields label { display: grid; gap: 7px; font-size: .78rem; font-weight: 800; }
.edit-fields input, .edit-fields select { width: 100%; border: 1px solid var(--line); border-radius: 3px; padding: 11px 12px; background: white; color: var(--ink); font-weight: 400; }
.edit-fields input:focus { outline: 3px solid rgba(22,79,63,.12); border-color: var(--forest); }
.edit-fields small, .form-help { color: var(--muted); font-size: .75rem; font-weight: 400; }
.edit-fields fieldset { border: 1px solid var(--line); padding: 15px; margin: 0; }
.edit-fields legend { padding: 0 7px; font-size: .78rem; font-weight: 800; }
.article-editor-row { display: grid; grid-template-columns: minmax(120px, .7fr) 1.5fr 36px; gap: 8px; margin-bottom: 8px; }
.remove-row { border: 0; background: #f1e5e1; color: var(--danger); border-radius: 3px; font-size: 1.2rem; }
.edit-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.form-error { padding: 10px 12px; background: #f8dfd7; color: var(--danger); }
.edit-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.edit-metadata { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 14px; background: #edf2ed; border-radius: 3px; }
.edit-metadata > span { display: grid; gap: 6px; }
.edit-metadata small { text-transform: uppercase; letter-spacing: .08em; }
.edit-pdf-preview { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 20px; }
.edit-preview-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.edit-preview-header h3 { margin: 0; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; }
.edit-pdf-preview iframe { display: block; width: 100%; height: 58vh; min-height: 420px; border: 1px solid var(--line); background: #d7d9d6; }

@media (max-width: 900px) {
  .results { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats article:nth-child(2) { border-right: 0; }
  .stats article { border-bottom: 1px solid var(--line); }
}
@media (max-width: 650px) {
  .hero__inner { align-items: start; flex-direction: column; padding-top: 12px; padding-bottom: 10px; }
  .toolbar { grid-template-columns: 1fr; }
  .results { grid-template-columns: 1fr; }
  .stats { margin-top: 0; }
  .stats article { padding: 8px 11px; }
  .view-controls { align-items: stretch; flex-direction: column; }
  .display-toggle { align-self: flex-start; }
  .edit-grid, .edit-metadata { grid-template-columns: 1fr; }
}
