:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  color: #f2f3ee;
  background: #151815;
  --canvas: #151815;
  --surface: #1d211e;
  --surface-raised: #232924;
  --line: #343c35;
  --text: #f2f3ee;
  --muted: #aab3a8;
  --dim: #929e93;
  --lime: #c3ef89;
  --lime-hover: #d4ffa1;
  --lime-ink: #223014;
  --amber: #f0c081;
  --rose: #ef9eaa;
  --violet: #c9bbf8;
  --radius: 15px;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
body { min-width: 280px; margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
svg { display: block; flex: none; }
[hidden] { display: none !important; }

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 4;
  transform: translateY(-200%);
  opacity: 0;
  padding: 9px 13px;
  border-radius: 7px;
  color: var(--lime-ink);
  background: var(--lime);
}

.skip-link:focus { transform: translateY(0); opacity: 1; }

.app-shell {
  min-height: 100vh;
  background: radial-gradient(ellipse 95% 42% at 85% 0%, #242b22, transparent 68%), var(--canvas);
}

.topbar { border-bottom: 1px solid var(--line); background: #171b18; }

.topbar-inner {
  display: flex;
  align-items: center;
  gap: clamp(20px, 3vw, 48px);
  width: min(100%, 1472px);
  min-height: 72px;
  margin-inline: auto;
  padding: 10px clamp(20px, 3.75vw, 54px);
}

.brand {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 740;
  letter-spacing: -.035em;
  line-height: 1.15;
}

.brand-mark {
  display: grid;
  flex: none;
  place-items: center;
  width: 37px;
  height: 37px;
  border: 1px solid #d5ffa6;
  border-radius: 10px;
  color: var(--lime-ink);
  background: var(--lime);
  box-shadow: 0 2px 12px rgb(195 239 137 / 15%);
}

.brand-mark .icon { width: 23px; height: 23px; stroke-width: 1.8; }
.brand-copy { display: grid; gap: 2px; }
.brand-label { color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: 0; }

.top-nav { display: flex; align-items: center; gap: 19px; }

.top-nav a {
  display: flex;
  align-items: center;
  min-height: 35px;
  border-radius: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.top-nav a:hover, .top-nav a[aria-current], .top-nav .is-current { color: var(--lime); }
.topbar-actions { display: flex; align-items: center; gap: 11px; margin-left: auto; }

.simulation-badge {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 3px 8px;
  border: 1px solid #4a523c;
  border-radius: 999px;
  color: #d3e8b5;
  background: #263122;
  font-size: 11px;
  font-weight: 690;
  white-space: nowrap;
}

.simulation-badge .icon { width: 13px; height: 13px; }

.button, .primary-button {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 7px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  font-size: 13px;
  font-weight: 680;
  line-height: 1.25;
  text-decoration: none;
}

.button .icon, .primary-button .icon { width: 15px; height: 15px; }
.button-secondary { border-color: #435044; background: #202622; }
.button-secondary:hover { border-color: #677663; background: #2a342b; }
.primary-button, .button-primary { border-color: var(--lime); color: var(--lime-ink); background: var(--lime); }
.primary-button:hover:not(:disabled), .button-primary:hover:not(:disabled) { background: var(--lime-hover); }
.primary-button:disabled, .button-primary:disabled { border-color: #465247; color: #a1aaa0; background: #272f29; }

.main-content {
  width: min(100%, 1472px);
  margin-inline: auto;
  padding: clamp(24px, 4vw, 47px) clamp(20px, 3.75vw, 54px) 40px;
}

#overview, #inventory, #preview { scroll-margin-top: 18px; }

.page-intro {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 25px;
}

.page-intro h1 {
  max-width: 840px;
  font-size: clamp(32px, 4vw, 54px);
  font-weight: 750;
  letter-spacing: -.065em;
  line-height: 1.02;
  text-wrap: balance;
}

.page-intro p {
  max-width: 72ch;
  margin-top: 11px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
  margin-bottom: 22px;
}

.metric-card {
  min-width: 0;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(150deg, #242b24, #1d221e 70%);
}

.metric-heading { display: flex; align-items: center; gap: 10px; min-height: 33px; }
.metric-heading h2 { color: #ccd3c9; font-size: 13px; font-weight: 630; line-height: 1.3; }

.metric-icon, .selection-icon, .library-icon {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 9px;
}

.metric-icon .icon { width: 17px; height: 17px; }

.tone-violet, .library-icon.is-kontakt, .selection-icon.is-kontakt { border-color: #4d435f; color: var(--violet); background: #332c42; }
.tone-green, .library-icon.is-ample, .selection-icon.is-ample { border-color: #43543d; color: var(--lime); background: #293729; }
.tone-amber { border-color: #624e36; color: var(--amber); background: #3e3325; }
.tone-red { border-color: #603f47; color: var(--rose); background: #3c2a2f; }

.metric-value {
  margin-top: 10px;
  color: var(--text);
  font-size: clamp(27px, 3.2vw, 37px);
  font-weight: 720;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.055em;
  line-height: 1;
}

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.58fr) minmax(330px, 1fr); align-items: start; gap: 18px; }
.detail-stack { display: grid; min-width: 0; gap: 18px; }

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 3px 10px rgb(0 0 0 / 8%);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 11px;
  min-height: 62px;
  padding: 14px 17px;
}

.panel-heading h2 { font-size: 18px; font-weight: 720; letter-spacing: -.036em; line-height: 1.2; }
.panel-heading p { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.4; }

.inventory-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 0 17px 14px; }

.search-field {
  display: flex;
  flex: 1 1 180px;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 39px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--dim);
  background: #171c18;
}

.search-field > .icon { width: 15px; height: 15px; }

.search-field input {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 13px;
}

.search-field input::placeholder { color: var(--dim); }
.search-field:focus-within { border-color: #a6cb77; box-shadow: 0 0 0 2px rgb(195 239 137 / 15%); }
.status-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }

.filter-button {
  min-height: 35px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.filter-button:hover { color: var(--text); background: var(--surface-raised); }
.filter-button[aria-pressed="true"] { border-color: #47573d; color: var(--lime); background: #28352a; }

.table-scroll { overflow: auto; }
.table-scroll:focus-visible { outline-offset: -2px; }
.library-table { width: 100%; border-collapse: collapse; table-layout: fixed; text-align: left; }

.library-table thead th {
  padding: 10px 11px;
  border-block: 1px solid var(--line);
  color: #b3bdb1;
  background: #202621;
  font-size: 11px;
  font-weight: 680;
  line-height: 1.25;
  white-space: nowrap;
}

.library-table tbody :is(th, td) {
  height: 61px;
  padding: 9px 11px;
  border-bottom: 1px solid #303930;
  text-align: left;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
}

.library-table tr > :first-child { width: 43%; padding-left: 17px; }
.library-table tr > :nth-child(2) { width: 172px; }
.library-table tr > :last-child { width: 34px; padding-inline: 0 12px; }
.library-table tbody tr:last-child :is(th, td) { border-bottom: 0; }
.library-row:hover { background: #242e25; }
.library-row.is-selected { background: #29372a; }
.library-row.is-selected > :first-child { box-shadow: inset 3px 0 var(--lime); }

.library-button {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  color: inherit;
  background: transparent;
  text-align: left;
}

.library-button:hover .library-name { color: var(--lime); }
.library-identity { display: flex; align-items: center; gap: 9px; min-width: 0; }

.library-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 750;
  line-height: 1;
}

.library-icon svg { width: 17px; height: 17px; }
.library-label { min-width: 0; }
.library-name { display: block; color: var(--text); font-weight: 680; overflow-wrap: anywhere; }
.library-ecosystem { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-chip svg { width: 13px; height: 13px; }
.status-chip.is-matched { border-color: #506647; color: #bfe398; background: #2c392a; }
.status-chip.is-review { border-color: #69533c; color: #f4c58a; background: #413528; }
.status-chip.is-missing { border-color: #65424b; color: #f2a6b2; background: #412c32; }

.recorded-path {
  display: block;
  overflow: hidden;
  color: #b7c1b5;
  font: 11px/1.55 var(--mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-arrow { display: grid; place-items: center; color: var(--dim); }
.row-arrow svg, svg.row-arrow { width: 15px; height: 15px; }
.library-row.is-selected .row-arrow { color: var(--lime); }

.table-footer {
  min-height: 41px;
  padding: 11px 17px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.empty-state { padding: 22px 17px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.selected-library { padding: 0 17px 17px; }
.selection-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 13px; }
.selection-icon { width: 43px; height: 43px; border-radius: 11px; color: var(--lime); background: #293729; font-size: 13px; font-weight: 760; }
.selection-icon svg { width: 22px; height: 22px; }
.selection-copy { flex: 1; min-width: 0; }
.selection-copy h3 { font-size: 17px; font-weight: 700; letter-spacing: -.028em; line-height: 1.2; overflow-wrap: anywhere; }
.selection-meta { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.45; }

.detail-note {
  margin-bottom: 12px;
  padding: 9px 10px;
  border: 1px solid #43553e;
  border-radius: 8px;
  color: #cadfc1;
  background: #28342a;
  font-size: 12px;
  line-height: 1.5;
}

.detail-note.is-review { border-color: #5b4835; color: #f1cca0; background: #362e23; }
.detail-note.is-missing { border-color: #5a3f47; color: #edb0ba; background: #35282e; }
.location-compare { display: grid; gap: 5px; }
.compare-arrow { display: grid; justify-content: center; color: var(--dim); }
.compare-arrow svg { width: 15px; height: 15px; transform: rotate(90deg); }
.location-block.is-proposed { border-color: #485b40; background: #1d271e; }

.location-block {
  display: grid;
  min-width: 0;
  gap: 4px;
  padding: 9px 10px;
  border: 1px solid #354037;
  border-radius: 8px;
  background: #181e19;
}

.location-label { color: #b5bfb3; font-size: 11px; font-weight: 680; line-height: 1.3; }
.location-name { color: var(--text); font-size: 13px; line-height: 1.25; overflow-wrap: anywhere; }

.location-path, .candidate-copy small, .preview-path {
  display: block;
  min-width: 0;
  color: #b7c2b7;
  font: 11px/1.55 var(--mono);
  overflow-wrap: anywhere;
}

.candidate-group { display: grid; min-width: 0; gap: 7px; padding: 0; margin: 12px 0 0; border: 0; }
.candidate-group :is(legend, h4) { margin: 0 0 7px; padding: 0; color: var(--muted); font-size: 12px; font-weight: 680; }

.candidate-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #425045;
  border-radius: 8px;
  background: #202722;
  cursor: pointer;
}

.candidate-option:hover, .candidate-option:has(input:checked) { border-color: #708b59; background: #29362b; }
.candidate-option input { flex: none; margin: 3px 0 0; accent-color: var(--lime); }
.candidate-copy { min-width: 0; }
.candidate-copy strong { display: block; margin-bottom: 2px; color: var(--text); font-size: 13px; line-height: 1.3; overflow-wrap: anywhere; }
.selection-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 13px; }
.preview-only { color: var(--muted); font-size: 11px; }

.preview-count {
  display: inline-flex;
  flex: none;
  align-items: center;
  min-height: 23px;
  padding: 2px 7px;
  border: 1px solid #465443;
  border-radius: 999px;
  color: #c6d8bd;
  background: #28332a;
  font-size: 11px;
  font-weight: 650;
}

.preview-list { display: grid; gap: 8px; padding: 0 17px; }

.preview-empty {
  padding: 12px 10px;
  border: 1px dashed #465047;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}

.preview-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 4px 9px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #181e19;
}

.preview-file { display: block; color: var(--text); font-size: 13px; font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
.preview-entry-copy { min-width: 0; }
.preview-entry .preview-path { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 8px; margin: 6px 0 0; }
.preview-path dt { color: #d6e0d4; font-weight: 650; }
.preview-path dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.remove-preview {
  display: inline-grid;
  place-items: center;
  min-width: 31px;
  min-height: 31px;
  padding: 4px 7px;
  border: 1px solid #526052;
  border-radius: 7px;
  color: #c8d1c7;
  background: #232b24;
  font-size: 11px;
  font-weight: 660;
}

.remove-preview svg { width: 14px; height: 14px; }
.remove-preview:hover { border-color: #946670; color: #f5b4be; background: #382930; }
.preview-entry > .remove-preview { grid-area: 1 / 2 / span 2; }

.risk-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 11px 17px 17px;
  padding: 9px 10px;
  border: 1px solid #5c4b36;
  border-radius: 8px;
  color: #e4c9a4;
  background: #332b21;
  font-size: 12px;
  line-height: 1.5;
}

.risk-note .icon { width: 15px; height: 15px; margin-top: 2px; color: var(--amber); }
.risk-note strong { color: #f3d6ae; }

.activity-message:not(:empty) {
  position: fixed;
  z-index: 3;
  right: 17px;
  bottom: 17px;
  max-width: min(380px, 100% - 34px);
  padding: 10px 13px;
  border: 1px solid #587847;
  border-radius: 8px;
  color: #e6f8d8;
  background: #283b2c;
  box-shadow: 0 5px 22px rgb(0 0 0 / 25%);
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 1060px) {
  .topbar-inner { gap: 20px; }
  .top-nav { gap: 12px; }
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .library-table tr > :first-child { width: 36%; }
}

@media (max-width: 800px) {
  .topbar-inner { flex-wrap: wrap; gap: 8px 14px; min-height: 65px; padding-block: 9px; }
  .top-nav { order: 3; width: 100%; gap: 18px; }
  .top-nav a { min-height: 29px; }
  .detail-stack { grid-template-columns: minmax(0, 1fr); }
  .metric-card { padding-inline: 12px; }
  .metric-heading { gap: 7px; }
  .page-intro h1 { text-wrap: initial; }
}

@media (max-width: 600px) {
  .main-content, .topbar-inner { padding-inline: 14px; }
  .topbar-inner { gap: 7px 10px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .button { min-height: 39px; font-size: 12px; }
  .page-intro { margin-bottom: 17px; }
  .page-intro p { margin-top: 8px; font-size: 14px; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 15px; }
  .metric-card { padding: 11px; }
  .metric-heading h2 { font-size: 12px; }
  .metric-value { font-size: 29px; }
  .metric-icon { width: 29px; height: 29px; }
  .metric-icon .icon { width: 15px; height: 15px; }
  .dashboard-grid, .detail-stack { gap: 13px; }
  .panel-heading { min-height: 54px; padding-inline: 12px; }
  .panel-heading h2 { font-size: 17px; }
  .inventory-controls { flex-direction: column; align-items: stretch; gap: 7px; padding: 0 12px 10px; }
  .search-field { flex: auto; }
  .search-field input { font-size: 16px; }
  .filter-button { min-height: 34px; }
  .library-table, .library-table tbody { display: block; }
  .library-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .library-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto 16px; align-items: center; gap: 4px 8px; padding: 8px 12px; border-top: 1px solid var(--line); }
  .library-table tbody .library-row > :is(th, td) { width: auto; min-width: 0; height: auto; padding: 0; border: 0; box-shadow: none; }
  .library-row.is-selected { box-shadow: inset 3px 0 var(--lime); }
  .library-table .library-row.is-selected > :first-child { box-shadow: none; }
  .library-table tbody tr > :nth-child(3) { grid-area: 2 / 1 / 3 / -1; }
  .library-table tbody tr > :last-child { grid-area: 1 / 3; }
  .library-button { min-height: 42px; }
  .library-icon { width: 29px; height: 29px; }
  .preview-list, .selected-library, .table-footer { padding-inline: 12px; }
  .risk-note { margin-inline: 12px; }
  .remove-preview { min-width: 36px; min-height: 36px; }
}

@media (max-width: 470px) {
  .topbar-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .brand { min-width: 0; font-size: 14px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-mark .icon { width: 20px; height: 20px; }
  .brand-copy { min-width: 0; white-space: normal; }
  .topbar-actions { display: contents; }
  .topbar-actions .button { grid-area: 1 / 2; justify-self: end; }
  .simulation-badge { grid-area: 2 / 1; justify-self: start; }
  .top-nav { grid-area: 2 / 1 / 3 / -1; width: auto; justify-content: flex-end; gap: 9px; padding-left: 102px; }
  .top-nav a { font-size: 12px; }
}

@media (max-width: 355px) {
  .top-nav { grid-area: 3 / 1 / 4 / -1; justify-content: flex-start; padding-left: 0; }
  .brand { font-size: 13px; }
  .topbar-actions .button { padding-inline: 8px; }
  .metric-heading { gap: 6px; }
  .library-table tbody tr { grid-template-columns: minmax(0, 1fr) auto; }
  .library-table tbody tr > :last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
