@font-face {
  font-family: "Roboto Condensed";
  src: url("../fonts/RobotoCondensed-Variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --ink: #3f3f3f;
  --muted: #6d6d6d;
  --line: #dddddd;
  --line-strong: #bdbdbd;
  --surface: #ffffff;
  --surface-soft: #f5f5f5;
  --navy: #4a4a4a;
  --navy-deep: #363636;
  --teal: #b4007d;
  --teal-dark: #8d0062;
  --athena-green: #86b635;
  --athena-green-dark: #6f982a;
  --athena-blue: #007a99;
  --focus: #f49a19;
  --success: #176b4c;
  --success-bg: #e4f4ec;
  --warning: #8a5315;
  --warning-bg: #fff0d8;
  --error: #a23b3b;
  --error-bg: #fdecec;
  --shadow: 0 2px 8px rgb(0 0 0 / 10%);
  font-family: "Roboto Condensed", Arial, sans-serif;
  color: var(--ink);
  background: #f2f2f2;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background: #f2f2f2;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

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

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.7rem 1rem;
  color: #fff;
  background: var(--teal);
  border-radius: 0.15rem;
  transform: translateY(-160%);
}

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

.site-header {
  width: 100%;
  min-height: 6.5rem;
  margin: 0;
  padding: 1rem max(2rem, calc((100% - 94rem) / 2));
  display: flex;
  align-items: center;
  color: #fff;
  background: var(--athena-green);
  border-bottom: 0.55rem solid var(--navy-deep);
}

.header-copy {
  min-width: 0;
  max-width: 70rem;
}

.step-label {
  margin: 0 0 0.35rem;
  color: var(--athena-green-dark);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.site-header h1 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(1.85rem, 3.5vw, 2.75rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.lede {
  margin: 0.45rem 0 0;
  color: #31411f;
  font-size: 1rem;
  font-weight: 600;
}

.page-shell {
  width: min(94rem, calc(100% - 3rem));
  margin: 0 auto;
  padding: 1.25rem 0 4rem;
}

.panel {
  margin-bottom: 1rem;
  padding: 1.4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--athena-green);
  border-radius: 0.2rem;
  box-shadow: var(--shadow);
}

.section-heading,
.results-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.section-heading h2,
.results-toolbar h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.25rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel .step-label,
.dialog-header .step-label {
  color: var(--athena-green-dark);
}

.source-chip {
  max-width: 34rem;
  margin: 0;
  padding: 0.45rem 0.7rem;
  overflow-wrap: anywhere;
  color: var(--ink);
  background: #f0f4e8;
  border: 1px solid #bed58f;
  border-radius: 0.2rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.78rem;
}

.source-form {
  display: grid;
  grid-template-columns: minmax(18rem, 1fr) auto;
  gap: 1rem;
  align-items: end;
}

.field {
  min-width: 0;
}

.field label {
  display: block;
  margin-bottom: 0.38rem;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 750;
}

.field input,
.field select {
  width: 100%;
  min-height: 2.65rem;
  padding: 0.62rem 0.72rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 0.2rem;
}

.field input:hover,
.field select:hover {
  border-color: #777;
}

.field input:focus,
.field select:focus {
  border-color: var(--athena-green-dark);
}

.field-help {
  margin: 0.38rem 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

code,
.code-cell {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.package-field {
  max-width: 42rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.button-row,
.input-action {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.source-actions {
  align-self: start;
  flex-wrap: wrap;
  margin-top: 1.3rem;
}

.local-source-help {
  max-width: 70rem;
}

.button,
.pagination-button,
.icon-button {
  min-height: 2.55rem;
  padding: 0.58rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 0.2rem;
  font-weight: 750;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.button-primary {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

.button-primary:hover:not(:disabled) {
  background: var(--teal-dark);
}

.button-secondary {
  color: var(--ink);
  background: #fff;
  border-color: var(--line-strong);
}

.button-secondary:hover:not(:disabled) {
  background: var(--surface-soft);
  border-color: #777;
}

.button-quiet {
  min-height: auto;
  padding: 0.4rem 0.55rem;
  color: var(--athena-blue);
  background: transparent;
  border-color: transparent;
  text-decoration: underline;
  text-underline-offset: 0.2rem;
}

.query-field {
  max-width: 54rem;
}

.input-action input {
  flex: 1;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(10rem, 1fr));
  gap: 0.85rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.status-panel {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin: 0 0 1rem;
  padding: 0.9rem 1rem;
  color: var(--ink);
  background: #f0f4e8;
  border: 1px solid #bed58f;
  border-radius: 0.2rem;
}

.status-panel[hidden] {
  display: none;
}

.status-panel[data-phase="error"] {
  color: #702828;
  background: var(--error-bg);
  border-color: #edbcbc;
}

.status-panel[data-phase="unavailable"] {
  color: #66400d;
  background: var(--warning-bg);
  border-color: #eccb95;
}

.status-indicator {
  flex: 0 0 auto;
  width: 0.68rem;
  height: 0.68rem;
  margin-top: 0.28rem;
  background: var(--athena-green-dark);
  border-radius: 50%;
}

.status-panel[data-phase^="loading"] .status-indicator {
  background: transparent;
  border: 2px solid #bed58f;
  border-top-color: var(--athena-green-dark);
  animation: spin 850ms linear infinite;
}

.status-panel[data-phase="error"] .status-indicator {
  background: var(--error);
}

.status-panel[data-phase="unavailable"] .status-indicator {
  background: var(--warning);
}

.status-panel p {
  margin: 0.18rem 0 0;
  font-size: 0.88rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.results-panel {
  padding: 0;
  overflow: hidden;
}

.results-toolbar {
  margin: 0;
  padding: 1.25rem 1.4rem;
}

.results-summary {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.page-size-field {
  width: 8rem;
}

.table-frame {
  max-height: min(60vh, 44rem);
  overflow: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

table {
  width: 100%;
  min-width: 82rem;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
}

thead {
  position: sticky;
  z-index: 2;
  top: 0;
}

th {
  padding: 0;
  color: var(--ink);
  background: #eeeeee;
  border-bottom: 1px solid var(--line-strong);
  font-size: 0.72rem;
  letter-spacing: 0.025em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

th:not(:has(.sort-button)) {
  padding: 0.72rem 0.65rem;
}

td {
  max-width: 24rem;
  padding: 0.72rem 0.65rem;
  overflow-wrap: anywhere;
  vertical-align: top;
  background: #fff;
  border-bottom: 1px solid #e4eaed;
}

tbody tr:nth-child(even) td {
  background: #fafafa;
}

tbody tr:hover td,
tbody tr:focus-within td {
  background: #f4f8eb;
}

tbody tr.is-selected td {
  background: #eaf2da;
  box-shadow: inset 0 1px #b2cf79, inset 0 -1px #b2cf79;
}

.sort-button {
  width: 100%;
  padding: 0.72rem 1.25rem 0.72rem 0.65rem;
  color: inherit;
  background: transparent;
  border: 0;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  text-transform: inherit;
  white-space: nowrap;
}

.sort-button:hover {
  color: var(--athena-blue);
  background: #e4e4e4;
}

.sort-button::after {
  margin-left: 0.35rem;
  color: #78909d;
  content: "↕";
}

.sort-button[data-direction="asc"]::after {
  color: var(--athena-green-dark);
  content: "↑";
}

.sort-button[data-direction="desc"]::after {
  color: var(--athena-green-dark);
  content: "↓";
}

.concept-link,
.related-concept {
  padding: 0;
  color: var(--athena-blue);
  background: transparent;
  border: 0;
  font-weight: 750;
  text-align: left;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.concept-link:hover,
.related-concept:hover {
  color: #00566c;
}

.concept-name {
  min-width: 17rem;
  font-weight: 680;
}

.code-cell {
  color: #354a56;
}

.badge {
  display: inline-flex;
  width: max-content;
  padding: 0.18rem 0.42rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1.2;
}

.badge-success {
  color: var(--success);
  background: var(--success-bg);
}

.badge-warning {
  color: var(--warning);
  background: var(--warning-bg);
}

.badge-neutral {
  color: #235267;
  background: #e2eff3;
}

.badge-muted {
  color: #5a6570;
  background: #edf0f2;
}

.date-range {
  display: block;
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.71rem;
  white-space: nowrap;
}

.match-reason {
  color: #425963;
}

.table-message {
  padding: 3rem 1rem;
  color: var(--muted);
  text-align: center;
}

.pagination {
  display: flex;
  min-height: 4.2rem;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.8rem 1rem;
}

.pagination:empty {
  display: none;
}

.pagination-button {
  min-width: 2.55rem;
  color: var(--navy);
  background: #fff;
  border-color: var(--line);
}

.pagination-button:hover:not(:disabled),
.pagination-button.is-current {
  color: #fff;
  background: var(--athena-green-dark);
  border-color: var(--athena-green-dark);
}

.pagination-gap {
  padding: 0 0.2rem;
  color: var(--muted);
}

.concept-dialog {
  width: min(62rem, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  color: var(--ink);
  background: #fff;
  border: 0;
  border-radius: 0.2rem;
  box-shadow: 0 30px 80px rgb(0 0 0 / 30%);
}

.concept-dialog::backdrop {
  background: rgb(7 25 35 / 68%);
  backdrop-filter: blur(2px);
}

.dialog-header {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.25rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 0;
  font-size: clamp(1.2rem, 3vw, 1.65rem);
}

.icon-button {
  width: 2.55rem;
  padding: 0;
  color: #4c5b64;
  background: var(--surface-soft);
  border-color: var(--line);
  font-size: 1.7rem;
  font-weight: 400;
  line-height: 1;
}

.dialog-content {
  padding: 0 1.25rem 1.5rem;
}

.detail-section {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
}

.detail-section:last-child {
  border-bottom: 0;
}

.detail-section h3,
.hierarchy-column h4 {
  margin: 0 0 0.8rem;
  color: var(--navy-deep);
}

.detail-section h3 {
  font-size: 1.05rem;
}

.hierarchy-column h4 {
  font-size: 0.9rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(10rem, 1fr));
  gap: 0.8rem 1rem;
  margin: 0;
}

.detail-grid-compact {
  grid-template-columns: repeat(3, minmax(8rem, 1fr));
}

.detail-field {
  min-width: 0;
}

.detail-field dt {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.detail-field dd {
  margin: 0.2rem 0 0;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

.detail-list,
.relationship-list {
  max-height: 20rem;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
}

.detail-list li,
.relationship-item {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
}

.detail-list li:last-child,
.relationship-item:last-child {
  border-bottom: 0;
}

.detail-list small,
.relationship-type {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.75rem;
}

.relationship-type {
  width: min(28%, 12rem);
  font-weight: 750;
}

.external-concept {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.hierarchy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.empty-detail,
.detail-loading {
  margin: 0;
  padding: 0.8rem;
  color: var(--muted);
  background: var(--surface-soft);
  border-radius: 0.4rem;
}

.detail-error {
  margin-top: 1.25rem;
  padding: 0.9rem;
  color: #702828;
  background: var(--error-bg);
  border: 1px solid #edbcbc;
  border-radius: 0.45rem;
}

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

@media (max-width: 72rem) {
  .filter-grid {
    grid-template-columns: repeat(3, minmax(10rem, 1fr));
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(10rem, 1fr));
  }
}

@media (max-width: 48rem) {
  .page-shell {
    width: min(100% - 1.2rem, 94rem);
  }

  .site-header {
    min-height: 6rem;
    padding: 0.9rem 1.2rem;
  }

  .panel,
  .results-toolbar {
    padding: 1rem;
  }

  .section-heading,
  .results-toolbar {
    gap: 0.8rem;
  }

  .source-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .source-actions .button {
    flex: 1;
  }

  .source-actions {
    margin-top: 0;
  }

  .filter-grid {
    grid-template-columns: repeat(2, minmax(8rem, 1fr));
  }

  .table-frame {
    max-height: 62vh;
  }

  .detail-grid,
  .detail-grid-compact,
  .hierarchy-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 34rem) {
  .site-header {
    display: block;
  }

  .site-header h1 {
    font-size: 1.65rem;
    line-height: 1.05;
  }

  .lede {
    font-size: 0.92rem;
  }

  .section-heading,
  .results-toolbar {
    display: block;
  }

  .section-heading > :last-child,
  .results-toolbar > :last-child {
    margin-top: 0.8rem;
  }

  .source-chip {
    width: 100%;
    border-radius: 0.4rem;
  }

  .source-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .source-actions .button {
    width: 100%;
  }

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

  .input-action {
    align-items: stretch;
    flex-direction: column;
  }

  .page-size-field {
    width: 100%;
  }

  .pagination {
    justify-content: flex-start;
    overflow-x: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
