:root {
  --navy-950: #071425;
  --navy-900: #0a2342;
  --navy-800: #123d68;
  --blue-650: #155f9f;
  --green-650: #18704f;
  --red-650: #9a2d2d;
  --ink: #172033;
  --muted: #64748b;
  --surface: #ffffff;
  --surface-low: #f4f6f9;
  --background: #eef2f6;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --focus: #8cc8ff;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.07);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.finder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 68px;
  padding: 14px clamp(18px, 5vw, 48px);
  color: #fff;
  background: var(--navy-900);
}

.finder-brand,
.back-to-builder {
  display: inline-flex;
  align-items: center;
}

.finder-brand {
  gap: 10px;
  font-size: 15px;
}

.finder-brand-icon {
  font-size: 18px;
}

.back-to-builder {
  gap: 8px;
  min-height: 38px;
  padding: 8px 14px;
  color: var(--navy-900);
  font-size: 12px;
  font-weight: 700;
  background: #fff;
  border-radius: 8px;
}

.back-to-builder:hover {
  background: #edf2f8;
}

.finder-main {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(28px, 5vw, 56px) 0 64px;
}

.finder-intro {
  text-align: center;
}

.finder-intro h1 {
  margin: 0;
  color: var(--navy-900);
  font-size: clamp(30px, 4.4vw, 44px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.finder-intro > p {
  max-width: 560px;
  margin: 10px auto 28px;
  color: var(--muted);
  font-size: 15px;
}

.finder-search {
  display: block;
  max-width: 720px;
  margin: 0 auto;
}

.finder-search-control {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 7px 10px 7px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.finder-search-control:focus-within {
  border-color: var(--blue-650);
  box-shadow: 0 0 0 4px rgba(21, 95, 159, 0.1);
}

.finder-search-control > span:first-child {
  color: #94a3b8;
  font-size: 20px;
}

.finder-search-control input {
  width: 100%;
  min-width: 0;
  padding: 10px 0;
  color: var(--ink);
  font-size: 15px;
  background: transparent;
  border: 0;
  outline: 0;
}

.finder-search-control input::placeholder {
  color: #94a3b8;
}

.finder-search-control button,
.catalogue-controls button,
.result-actions button,
.result-actions a,
.selected-lawparts-actions button,
.selected-lawpart-controls button,
.selected-lawpart-controls a,
.selected-lawpart-handle,
.selected-lawparts-close,
.selected-lawparts-toggle {
  cursor: pointer;
}

.finder-search-control button {
  min-height: 38px;
  padding: 8px 14px;
  color: #33465e;
  font-size: 11px;
  font-weight: 700;
  background: var(--surface-low);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.catalogue-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

.catalogue-controls label {
  display: block;
}

.catalogue-controls select,
.catalogue-controls button {
  min-height: 40px;
  padding: 9px 16px;
  color: #33465e;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.catalogue-controls button {
  color: var(--blue-650);
  background: #edf4fb;
  border-color: #c7d8ea;
}

.catalogue-controls button[aria-pressed="true"] {
  color: #fff;
  background: var(--blue-650);
  border-color: var(--blue-650);
}

.catalogue-controls #lawpartResultCount {
  color: #8a95a6;
  font-size: 11px;
  font-weight: 700;
}

.finder-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 22px;
  align-items: start;
  margin-top: 32px;
}

.finder-results {
  display: grid;
  gap: 18px;
}

.catalogue-category {
  min-width: 0;
}

.catalogue-category-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  padding: 0 2px;
}

.catalogue-category-heading h2 {
  margin: 0;
  color: var(--navy-900);
  font-size: 19px;
  font-weight: 800;
}

.catalogue-category-heading span {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 700;
}

.catalogue-category-grid {
  display: grid;
  gap: 14px;
}

.finder-empty {
  padding: 58px 28px;
  color: var(--muted);
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
}

.finder-empty strong {
  display: block;
  margin-bottom: 7px;
  color: var(--navy-900);
  font-size: 17px;
}

.finder-empty p {
  margin: 0;
  font-size: 12px;
}

.finder-result-card,
.selected-lawparts {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.finder-result-card {
  padding: 22px;
}

.result-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.result-category {
  display: none;
}

.result-code {
  padding: 6px 12px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  background: var(--navy-900);
  border-radius: 999px;
  white-space: nowrap;
}

.result-code.is-missing {
  color: #64748b;
  background: #eef1f5;
}

.finder-result-card h2 {
  margin: 0 0 6px;
  color: var(--navy-900);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.3;
}

.result-legislation {
  margin: 0;
  color: #37566f;
  font-size: 12px;
  font-weight: 700;
}

.result-act-filter {
  padding: 3px 9px;
  color: var(--blue-650);
  font-size: 11px;
  font-weight: 800;
  background: #edf4fb;
  border: 1px solid #c7d8ea;
  border-radius: 999px;
  cursor: pointer;
}

.result-act-filter:hover {
  color: #fff;
  background: var(--blue-650);
  border-color: var(--blue-650);
}

.result-penalties {
  margin-top: 12px;
  padding: 10px 12px;
  color: #475569;
  font-size: 11px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.result-penalties summary {
  color: var(--navy-800);
  font-weight: 800;
  cursor: pointer;
}

.result-penalties ul {
  margin: 9px 0 0;
  padding-left: 18px;
}

.result-penalties li + li {
  margin-top: 6px;
}

.result-aliases,
.result-notes {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.result-notes {
  padding: 11px 12px;
  color: #48566a;
  background: var(--surface-low);
  border-radius: 10px;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.result-actions button,
.result-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 14px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  background: var(--navy-900);
  border: 1px solid var(--navy-900);
  border-radius: 999px;
}

.result-actions .add-selected-lawpart {
  background: var(--navy-900);
  border-color: var(--navy-900);
}

.result-actions .add-selected-lawpart:disabled {
  color: #94a3b8;
  background: #eef1f5;
  border-color: #e2e8f0;
}

.result-actions .open-lawcodes,
.result-actions button.secondary {
  color: #33465e;
  background: var(--surface);
  border-color: var(--line-strong);
}

.result-actions button:disabled {
  color: #94a3b8;
  background: #eef1f5;
  border-color: #e2e8f0;
  cursor: not-allowed;
}

.selected-lawparts {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: hidden;
}

.selected-lawparts-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 14px;
}

.selected-lawparts-header h2 {
  margin: 0;
  display: inline;
  color: var(--navy-900);
  font-size: 16px;
  font-weight: 800;
}

.selected-lawparts-header span {
  display: inline;
  margin-left: 4px;
  color: #8a95a6;
  font-size: 13px;
  font-weight: 700;
}

.selected-lawparts-close {
  display: none;
  width: 32px;
  min-height: 32px;
  padding: 0;
  color: #40546c;
  font-size: 20px;
  background: var(--surface-low);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.selected-lawparts-list {
  display: grid;
  gap: 10px;
  max-height: min(440px, calc(100vh - 320px));
  padding: 0 14px 14px;
  overflow-y: auto;
}

.selected-lawparts-empty {
  margin: 0;
  padding: 22px 14px;
  color: #8a95a6;
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
  background: var(--surface-low);
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
}

.selected-lawpart-item {
  padding: 12px;
  background: var(--surface-low);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: opacity 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.selected-lawpart-item.is-dragging {
  opacity: 0.48;
}

.selected-lawpart-item.is-drag-target {
  border-color: var(--blue-650);
  transform: translateY(2px);
}

.selected-lawpart-item-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.selected-lawpart-handle {
  display: none;
}

.selected-lawpart-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.selected-lawpart-copy strong {
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
}

.selected-lawpart-copy span {
  color: #49627e;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
}

.selected-lawpart-copy small {
  display: none;
}

.selected-lawpart-code {
  padding: 5px 9px;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  background: var(--navy-900);
  border-radius: 999px;
}

.selected-lawpart-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.selected-lawpart-controls button,
.selected-lawpart-controls a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 5px 6px;
  color: var(--blue-650);
  font-size: 9px;
  font-weight: 700;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
}

.selected-lawpart-controls button[title="Move up"],
.selected-lawpart-controls button[title="Move down"] {
  display: none;
}

.selected-lawpart-controls button:disabled {
  color: #9aa5b4;
  background: #f2f4f7;
  border-color: #e0e5eb;
}

.selected-lawpart-controls .selected-lawpart-remove {
  color: var(--red-650);
  background: #fff3f2;
  border-color: #e7bab6;
}

.selected-lawparts-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  padding: 14px 14px 0;
}

.selected-lawparts-actions button {
  min-height: 36px;
  padding: 7px 8px;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  background: var(--navy-900);
  border: 1px solid var(--navy-900);
  border-radius: 8px;
}

.selected-lawparts-actions button.secondary {
  color: #33465e;
  background: #fff;
  border-color: var(--line-strong);
}

.selected-lawparts-actions button.danger {
  grid-column: 1 / -1;
  color: var(--red-650);
  background: #fff3f2;
  border-color: #e7bab6;
}

.selected-lawparts-actions button:disabled {
  color: #8b97a7;
  background: #edf1f5;
  border-color: #d8e0e9;
}

.selected-lawparts-note {
  margin: 0;
  padding: 14px 18px 18px;
  color: #94a3b8;
  font-size: 10px;
  line-height: 1.5;
}

.selected-lawparts-note strong {
  color: #64748b;
}

.selected-lawparts-note span {
  display: block;
  margin-top: 6px;
}

.selected-lawparts-toggle {
  display: none;
}

.finder-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  padding: 12px 15px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
  opacity: 0;
  background: var(--navy-900);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transform: translateY(8px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.finder-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .finder-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .selected-lawparts {
    position: fixed;
    right: 16px;
    bottom: 76px;
    left: 16px;
    z-index: 30;
    max-height: min(76vh, 680px);
    opacity: 0;
    pointer-events: none;
    transform: translateY(calc(100% + 100px));
    transition: opacity 0.18s ease, transform 0.22s ease;
  }

  .selected-lawparts.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .selected-lawparts-close {
    display: block;
  }

  .selected-lawparts-list {
    max-height: min(46vh, 420px);
  }

  .selected-lawparts-toggle {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 31;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 46px;
    padding: 10px 14px;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    background: var(--navy-900);
    border: 1px solid #244d7e;
    border-radius: 999px;
    box-shadow: var(--shadow);
  }

  .selected-lawparts-toggle span {
    display: grid;
    min-width: 24px;
    height: 24px;
    place-items: center;
    padding: 0 6px;
    color: var(--navy-900);
    background: #d7e8f6;
    border-radius: 999px;
  }
}

@media (max-width: 640px) {
  .finder-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .back-to-builder {
    width: 100%;
    justify-content: center;
  }

  .finder-main {
    width: min(100% - 24px, 1240px);
  }

  .result-code {
    width: max-content;
  }
}

@media print {
  .selected-lawparts,
  .selected-lawparts-toggle {
    display: none !important;
  }
}
