/* Equal tab widths keep the navigation on one toolbar row. */
.result-table-tabs.toolbar {
  flex-wrap: nowrap;
}

.result-table-tabs .result-table-tab-list {
  flex: 1 1 auto;
  min-width: 0;
}

.result-table-tabs .result-table-tab-choice {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 165px;
  width: max-content;
  min-width: max-content;
  align-items: stretch;
}

.result-table-tabs .result-table-tab.scope-btn {
  width: 165px;
  min-width: 165px;
  max-width: 165px;
  flex: 0 0 165px;
}

.result-table-tabs .result-table-tab.scope-btn .scope-text {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-table-tabs .toolbar-actions {
  flex: 0 0 auto;
  min-width: 0;
  margin-left: 0;
}

.result-table-tabs .workspace-status {
  position: absolute;
  top: 100%;
  left: 0;
  width: auto;
  min-width: 0;
  height: auto;
  margin: 0;
  flex: none;
}

@media (max-width: 900px) {
  .result-table-tabs .result-table-tab-list {
    flex: 1 1 auto;
  }
}

@media (max-width: 700px) {
  .result-table-tabs .result-table-tab-list,
  .result-table-tabs .toolbar-actions {
    width: auto;
    max-width: none;
  }
}

#data-tab > .ingredient-lookup-panel.active {
  box-sizing: border-box;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--shell-border);
  border-top: 0;
  border-radius: 0;
  background: var(--color-surface);
}

.ingredient-lookup-fit-content {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  gap: 14px;
}

#data-tab > .ingredient-lookup-panel.active.ingredient-lookup-fit {
  position: relative;
  padding: 0;
  overflow: hidden !important;
}

#data-tab > .ingredient-lookup-panel.active.ingredient-lookup-fit > .ingredient-lookup-fit-content {
  position: absolute;
  top: 0;
  left: 0;
  box-sizing: border-box;
  width: var(--ingredient-lookup-fit-content-width, 100%);
  height: var(--ingredient-lookup-fit-content-height, auto);
  max-width: none;
  padding: 16px;
  transform: scale(var(--ingredient-lookup-fit-scale, 1));
  transform-origin: top left;
}

#data-tab > .ingredient-lookup-panel.active.ingredient-lookup-fit .ingredient-lookup-results {
  flex: 1 1 360px;
}

#data-tab:has(.ingredient-lookup-panel.active) + .legacy-pagination { visibility: hidden; }

.ingredient-lookup-header {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.ingredient-lookup-icon {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  height: 44px;
  border-radius: 10px;
  background: #eff5fb;
  color: #0872d9;
}
.ingredient-lookup-header h2 {
  margin: 0 0 4px;
  color: #0c3266;
  font-size: 24px;
  line-height: 1.2;
}
.ingredient-lookup-header p { margin: 0; color: var(--color-text-secondary); font-size: 13px; }
.ingredient-lookup-header a { color: #176bbb; }

.ingredient-lookup-filters,
.ingredient-lookup-results {
  border: 1px solid var(--color-border);
  border-radius: 9px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.ingredient-lookup-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px 14px;
  padding: 16px;
  position: relative;
  z-index: 2;
}
.ingredient-lookup-mobile-filter,
.ingredient-lookup-filter-menu { display: contents; }
.ingredient-lookup-filters .ingredient-lookup-filter-trigger { display: none; }
.ingredient-lookup-field-registration { order: 1; }
.ingredient-lookup-field-drug { order: 2; }
.ingredient-lookup-field-ingredient { order: 3; }
.ingredient-lookup-field-route { order: 4; }
.ingredient-lookup-field-year { order: 5; }
.ingredient-lookup-filters label {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  color: #173d6f;
  font-size: 13px;
  font-weight: 600;
}
.ingredient-lookup-filters input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 11px;
  border: 1px solid #cbd9e7;
  border-radius: 6px;
  background: #fff;
  color: var(--color-text-primary);
  font: inherit;
  font-weight: 400;
}
.ingredient-lookup-filters input::placeholder { color: #7e9abc; }
.ingredient-lookup-filters label:focus-within { z-index: 3; }
.ingredient-lookup-suggestions {
  position: absolute;
  z-index: 4;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
}
.ingredient-lookup-suggestions[hidden] { display: none; }
.ingredient-lookup-suggestions li { padding: 9px 10px; border-radius: 6px; color: var(--color-text-primary); font-weight: 400; cursor: pointer; }
.ingredient-lookup-suggestions li:hover,
.ingredient-lookup-suggestions li[aria-selected="true"] { background: var(--color-surface-2); color: var(--color-primary-dark); }
.ingredient-lookup-suggestions strong { color: var(--color-primary-dark); background: var(--color-primary-heavy-light); }
.ingredient-lookup-filters input:focus { border: 2px solid #1680e3; outline: none; }
.ingredient-lookup-panel button:focus-visible { outline: 2px solid #1680e3; outline-offset: 2px; }
.ingredient-lookup-actions {
  order: 6;
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.ingredient-lookup-panel button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid #cbd9e7;
  border-radius: 6px;
  background: #fff;
  color: #125b9f;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.ingredient-lookup-panel button:disabled { opacity: .5; cursor: not-allowed; }
.ingredient-lookup-panel .ingredient-lookup-search {
  min-width: 116px;
  border-color: #0d6ed2;
  background: #0d6ed2;
  color: #fff;
}
.ingredient-lookup-panel button svg { width: 15px; height: 15px; }
.ingredient-lookup-results {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.ingredient-lookup-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 14px;
}
.ingredient-lookup-results-head h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: #0c3266;
  font-size: 18px;
}
.ingredient-lookup-results-head h3 svg { width: 20px; height: 20px; color: #0872d9; }
.ingredient-lookup-table-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; }
.ingredient-lookup-copy-layer { position: absolute; z-index: 40; overflow: hidden; pointer-events: none; }
.ingredient-lookup-results table {
  width: 100%;
  min-width: 1030px;
  border-collapse: collapse;
  table-layout: fixed;
  color: #203e64;
  font-size: 12.5px;
}
.ingredient-lookup-results th,
.ingredient-lookup-results td {
  box-sizing: border-box;
  height: 35px;
  padding: 6px 10px;
  border: 1px solid #e1e9f0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.ingredient-lookup-results th { position: relative; height: 38px; padding-right: 18px; background: #f1f6fb; color: #315276; font-weight: 600; }
.ingredient-lookup-results th[data-sort] { cursor: pointer; user-select: none; }
.ingredient-lookup-results th[data-sort]:hover { background: #e6f0fa; }
.ingredient-lookup-results th[data-sort].is-sorted { color: #0d6ed2; }
.ingredient-lookup-results th[data-sort]:focus-visible { outline: 2px solid #1680e3; outline-offset: -2px; }
.ingredient-lookup-col-resizer {
  position: absolute;
  z-index: 3;
  top: 0;
  right: 0;
  width: 14px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}
.ingredient-lookup-col-resizer:focus-visible { outline: 2px solid #1680e3; outline-offset: -2px; }
.ingredient-lookup-results table.is-resizing,
.ingredient-lookup-results table.is-resizing * { user-select: none; }
.ingredient-lookup-results table.is-resizing .ingredient-lookup-col-resizer { cursor: col-resize; }
.ingredient-lookup-results tbody td:not(.ingredient-lookup-message) { cursor: cell; }
.ingredient-lookup-results tbody td.cell-selected,
.ingredient-lookup-results tbody td.cell-range,
.ingredient-lookup-results tbody td.cell-active {
  background: var(--table-interaction-selected-bg);
  box-shadow: inset 0 0 0 9999px color-mix(in srgb, var(--table-interaction-selected-border) 28%, transparent);
  user-select: none;
}
.ingredient-lookup-results table:focus { outline: none; }
.ingredient-lookup-results th:nth-child(1) { width: 4%; }
.ingredient-lookup-results th:nth-child(2) { width: 8%; }
.ingredient-lookup-results th:nth-child(3) { width: 13%; }
.ingredient-lookup-results th:nth-child(4) { width: 13%; }
.ingredient-lookup-results th:nth-child(5) { width: 11%; }
.ingredient-lookup-results th:nth-child(6) { width: 9%; }
.ingredient-lookup-results th:nth-child(7) { width: 12%; }
.ingredient-lookup-results th:nth-child(8) { width: 17%; }
.ingredient-lookup-results th:nth-child(9) { width: 13%; }
.ingredient-lookup-results .ingredient-lookup-rank,
.ingredient-lookup-results th:first-child { text-align: center; }
.ingredient-lookup-results .ingredient-lookup-code { color: #0872d9; }
.ingredient-lookup-results .ingredient-lookup-percent,
.ingredient-lookup-results th:last-child { text-align: right; }
.ingredient-lookup-count-inner { display: flex; align-items: center; gap: 8px; }
.ingredient-lookup-count strong { flex: 0 0 52px; text-align: right; font-weight: 600; color: #123b72; }
.ingredient-lookup-track { display: block; flex: 1; height: 15px; border-radius: 4px; background: #edf2f7; overflow: hidden; }
.ingredient-lookup-fill { display: block; height: 100%; border-radius: 4px; background: #0d6ed2; }
.ingredient-lookup-message { height: 360px !important; text-align: center !important; color: var(--color-text-secondary); }
.ingredient-lookup-message.error { color: var(--color-error); }
.ingredient-lookup-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 6px 12px;
  color: #5d7595;
  font-size: 12px;
}
.ingredient-lookup-footer nav { display: flex; align-items: center; gap: 4px; }
.ingredient-lookup-footer button { min-width: 30px; min-height: 30px; padding: 0 7px; }
.ingredient-lookup-footer button.active { background: #e6f0fd; color: #0756b2; font-weight: 700; }

@media (max-width: 1100px) {
  .ingredient-lookup-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  #data-tab > .ingredient-lookup-panel.active {
    padding: 12px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }

  #data-tab > .ingredient-lookup-panel.active > .ingredient-lookup-fit-content {
    flex: 0 0 auto;
    min-height: 100%;
  }

  #data-tab > .ingredient-lookup-panel.active > .ingredient-lookup-fit-content > .ingredient-lookup-header,
  #data-tab > .ingredient-lookup-panel.active > .ingredient-lookup-fit-content > .ingredient-lookup-filters,
  #data-tab > .ingredient-lookup-panel.active > .ingredient-lookup-fit-content > .ingredient-lookup-results {
    flex: 0 0 auto;
  }

  .ingredient-lookup-results {
    min-height: 0;
    overflow: visible;
  }

  .ingredient-lookup-table-wrap {
    flex: 0 0 auto;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .ingredient-lookup-mobile-filter {
    position: relative;
    display: block;
    grid-column: 1 / -1;
    min-width: 0;
    z-index: 5;
  }

  .ingredient-lookup-filter-trigger {
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid #cbd9e7;
    border-radius: 6px;
    background: #fff;
    color: var(--color-text-primary);
    font: inherit;
    cursor: pointer;
  }

  .ingredient-lookup-filters .ingredient-lookup-filter-trigger {
    display: flex;
    justify-content: space-between;
  }

  .ingredient-lookup-filter-trigger span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ingredient-lookup-filter-trigger svg { width: 16px; height: 16px; flex: 0 0 16px; }

  .ingredient-lookup-filter-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 20;
    display: none;
    box-sizing: border-box;
    max-height: min(60dvh, 420px);
    overflow: auto;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow-lg);
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .ingredient-lookup-mobile-filter.is-open .ingredient-lookup-filter-menu { display: grid; }
  .ingredient-lookup-message { height: clamp(180px, 35dvh, 280px) !important; }
  .ingredient-lookup-header h2 { font-size: 19px; }
  .ingredient-lookup-filters { grid-template-columns: minmax(0, 1fr); }
  .ingredient-lookup-footer { align-items: flex-start; flex-direction: column; }
}
