:root {
  color-scheme: dark;
  --bg: #080b10;
  --surface: #111822;
  --surface-strong: #172231;
  --surface-soft: #0d131b;
  --panel-bg: rgba(17, 24, 34, 0.94);
  --text: #eaf0f6;
  --muted: #96a6b7;
  --line: #273545;
  --accent: #f4cf57;
  --accent-strong: #ffe58b;
  --good: #69d48f;
  --bad: #ff7676;
  --button-active-text: #16130a;
  --input-placeholder: #657789;
  --code-bg: #070a0f;
  --code-text: #dbe7f2;
  --image-bg: #f5f7f9;
  --swatch-border: rgba(255, 255, 255, 0.35);
  --tag-text: #ccd7e3;
  --tag-type-text: #bae6fd;
  --tag-article-text: #e5edf5;
  --tag-year-text: #fde68a;
  --tag-theme-text: #ddd6fe;
  --tag-quantity-text: #bbf7d0;
  --tag-role-text: #fed7aa;
  --tag-version-text: #fbcfe8;
  --tag-color-text: #ccfbf1;
  --tag-link-text: #f8df86;
  --tag-source-text: #bfd0df;
  --tag-usage-text: #c7d2fe;
  --badge-bg: rgba(15, 23, 42, 0.9);
  --badge-border: rgba(148, 163, 184, 0.32);
  --badge-text: #f8df86;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-strong: #eef3f8;
  --surface-soft: #f8fafc;
  --panel-bg: rgba(255, 255, 255, 0.96);
  --text: #1f2933;
  --muted: #5d6b7c;
  --line: #d6e0ea;
  --accent: #d3a91b;
  --accent-strong: #846200;
  --good: #247a45;
  --bad: #be3434;
  --button-active-text: #1f2933;
  --input-placeholder: #78889a;
  --code-bg: #f3f6fa;
  --code-text: #1f2933;
  --image-bg: #f8fafc;
  --swatch-border: rgba(31, 41, 51, 0.22);
  --tag-text: #35465a;
  --tag-type-text: #075985;
  --tag-article-text: #334155;
  --tag-year-text: #7a5700;
  --tag-theme-text: #5b21b6;
  --tag-quantity-text: #146c43;
  --tag-role-text: #9a3412;
  --tag-version-text: #9d174d;
  --tag-color-text: #0f766e;
  --tag-link-text: #7a5700;
  --tag-source-text: #526276;
  --tag-usage-text: #3730a3;
  --badge-bg: rgba(255, 255, 255, 0.92);
  --badge-border: rgba(132, 98, 0, 0.24);
  --badge-text: #7a5700;
  --shadow: 0 18px 40px rgba(72, 88, 108, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4 {
  letter-spacing: 0;
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
}

h2 {
  font-size: 24px;
  line-height: 1.16;
}

h3 {
  font-size: 17px;
}

h4 {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.theme-toggle {
  align-items: center;
  align-self: end;
  background: rgba(250, 204, 21, 0.12);
  border: 1px solid rgba(250, 204, 21, 0.3);
  border-radius: 6px;
  color: var(--tag-year-text);
  display: inline-flex;
  height: 40px;
  justify-content: center;
  justify-self: start;
  min-height: 40px;
  min-width: 40px;
  padding: 0;
  width: 40px;
}

.theme-toggle svg {
  fill: none;
  height: 19px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 19px;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: 2px solid rgba(244, 207, 87, 0.18);
  outline-offset: 1px;
}

.theme-toggle[data-active-theme="light"] {
  background: rgba(129, 140, 248, 0.12);
  border-color: rgba(129, 140, 248, 0.28);
  color: var(--tag-usage-text);
}

.catalog-shell {
  margin: 0 auto;
  max-width: 1840px;
  padding: 14px clamp(12px, 3vw, 34px) 42px;
}

.search-panel,
.detail-panel,
.catalog-card,
.source-block,
.media-card,
.metric,
.kv,
.row,
.raw-item,
.source-summary-row {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.search-panel {
  margin-bottom: 16px;
  padding: 14px;
}

.search-form {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns:
    80px
    minmax(130px, 170px)
    minmax(150px, 220px)
    minmax(100px, 130px)
    minmax(140px, 190px)
    minmax(160px, 300px)
    max-content
    40px
    minmax(180px, auto);
}

.search-form button[type="submit"] {
  justify-self: start;
}

.entity-suggest-anchor {
  position: relative;
}

.entity-suggest-panel {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(8, 11, 16, 0.18);
  left: 0;
  max-height: min(420px, 70vh);
  min-width: min(360px, 92vw);
  overflow: auto;
  padding: 8px;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 90;
}

.entity-suggest-list {
  display: grid;
  gap: 8px;
}

.entity-suggest-option {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: block;
  padding: 0;
  text-align: left;
  width: 100%;
}

.entity-suggest-option:hover .entity-card,
.entity-suggest-option:focus-visible .entity-card {
  border-color: var(--accent);
}

.entity-suggest-loading {
  color: var(--muted);
  font-size: 13px;
  padding: 10px;
}

.entity-suggest-card {
  grid-template-columns: 72px minmax(0, 1fr);
}

.entity-suggest-card .entity-card-image {
  width: 72px;
}

.entity-suggest-card .entity-thumb {
  aspect-ratio: 1 / 1;
}

.search-logo-link {
  align-self: center;
  display: block;
  height: 80px;
  transform: translateY(8px);
  width: 80px;
}

.search-logo {
  display: block;
  height: 80px;
  object-fit: contain;
  width: 80px;
}

.catalog-account {
  align-items: center;
  align-self: end;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  min-width: 0;
}

.catalog-account-link {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  display: inline-flex;
  font-size: 13px;
  font-weight: 750;
  justify-content: center;
  min-height: 40px;
  max-width: 180px;
  overflow: hidden;
  padding: 8px 10px;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.catalog-account-link.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--button-active-text);
}

button.catalog-account-link {
  cursor: pointer;
}

label {
  color: var(--muted);
  display: grid;
  gap: 6px;
}

.filter-field {
  min-width: 0;
  position: relative;
}

.filter-combobox {
  min-width: 0;
  position: relative;
}

.filter-trigger {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  min-width: 0;
  padding: 7px 8px;
  text-align: left;
  width: 100%;
}

.filter-trigger.active {
  border-color: rgba(244, 207, 87, 0.42);
}

.filter-trigger-value {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.filter-trigger-value .filter-option-count {
  display: none;
}

.filter-trigger-caret {
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 14px;
  line-height: 1;
}

.filter-menu {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: none;
  gap: 4px;
  left: 0;
  max-height: min(340px, 58vh);
  min-width: min(280px, 86vw);
  overflow: auto;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
}

.filter-combobox.open .filter-menu {
  display: grid;
}

.filter-menu[hidden] {
  display: none;
}

.filter-option {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  display: grid;
  gap: 7px;
  grid-template-columns: minmax(0, 1fr) auto auto;
  min-height: 34px;
  padding: 5px;
  text-align: left;
}

.filter-option:hover,
.filter-option:focus-visible,
.filter-option.selected {
  background: var(--surface-soft);
  border-color: var(--line);
}

.filter-option-chip {
  align-items: center;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 6px;
  color: var(--tag-text);
  display: inline-flex;
  font-size: 11px;
  font-weight: 750;
  gap: 5px;
  line-height: 1.15;
  min-width: 0;
  overflow: hidden;
  padding: 4px 7px;
}

.filter-option-chip span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-option-chip .swatch {
  flex: 0 0 12px;
  height: 12px;
  width: 12px;
}

.filter-option-count {
  background: var(--badge-bg);
  border: 1px solid var(--badge-border);
  border-radius: 999px;
  color: var(--badge-text);
  font-size: 10.5px;
  font-weight: 850;
  line-height: 1;
  min-width: 26px;
  padding: 4px 7px;
  text-align: center;
}

.filter-option-mark {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
}

.filter-option-empty {
  color: var(--muted);
  font-size: 12px;
  padding: 8px;
}

input,
select,
button {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  min-height: 40px;
  min-width: 0;
  padding: 8px 10px;
}

button {
  cursor: pointer;
}

button:hover,
button:focus-visible,
input:focus,
select:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(244, 207, 87, 0.18);
  outline-offset: 1px;
}

::placeholder {
  color: var(--input-placeholder);
  opacity: 0.72;
}

.catalog-layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
}

.catalog-layout.browse-mode {
  grid-template-columns: minmax(0, 1fr);
}

.catalog-layout.browse-mode .detail-panel {
  display: none;
}

.catalog-layout.detail-mode {
  grid-template-columns: 1fr;
}

.catalog-layout.detail-mode .catalog-results-panel {
  display: none;
}

.section-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.muted,
.meta,
.breadcrumb {
  color: var(--muted);
}

.breadcrumb {
  overflow-wrap: anywhere;
}

.card-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

.catalog-sections {
  display: grid;
  gap: 18px;
}

.catalog-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.catalog-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.catalog-updates-period-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 4px;
}

.catalog-updates-day-content {
  min-height: 260px;
}

.catalog-updates-day-skeleton {
  background: var(--surface);
  border: 1px solid var(--line);
  min-height: 220px;
}

.catalog-updates-card-batch {
  display: contents;
}

.catalog-updates-render-sentinel {
  grid-column: 1 / -1;
  height: 1px;
}

.catalog-updates-all-link {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 750;
}

.catalog-update-card .entity-card-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.catalog-updates-archive {
  display: grid;
  gap: 18px;
}

.catalog-updates-archive-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.catalog-updates-archive-head h3 {
  margin: 0;
}

.catalog-updates-filter {
  flex: 0 1 350px;
  min-width: min(100%, 250px);
}

.catalog-updates-archive-pager {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.catalog-updates-page-link {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  justify-content: center;
  min-height: 38px;
  min-width: 92px;
  padding: 7px 10px;
  text-decoration: none;
}

.catalog-updates-page-link:hover,
.catalog-updates-page-link:focus-visible {
  border-color: var(--accent-strong);
  color: var(--accent-strong);
}

.catalog-updates-page-link.disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.catalog-updates-page-status {
  color: var(--muted);
  font-size: 13px;
}

.catalog-matrix {
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
}

.pager {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  grid-column: 1 / -1;
  justify-content: center;
  padding: 8px 0;
}

.pager button {
  min-width: 92px;
}

.pager button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.page-size-control {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 6px;
}

.page-size-control span {
  white-space: nowrap;
}

.page-size-control select {
  min-height: 34px;
  width: auto;
}

.catalog-card {
  cursor: pointer;
  display: grid;
  gap: 9px;
  min-height: 0;
  padding: 10px;
  text-align: left;
}

.catalog-card:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.thumb,
.placeholder {
  align-items: center;
  aspect-ratio: 4 / 3;
  background:
    linear-gradient(135deg, rgba(244, 207, 87, 0.16), rgba(87, 199, 178, 0.08)),
    var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  display: flex;
  justify-content: center;
  overflow: hidden;
  text-align: center;
}

.thumb img {
  display: block;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.placeholder {
  color: var(--muted);
  font-weight: 700;
  padding: 8px;
}

.card-title {
  display: grid;
  gap: 4px;
}

.card-title strong {
  overflow-wrap: anywhere;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  padding: 3px 8px;
}

.detail-panel {
  align-self: start;
  min-height: 560px;
  padding: 14px;
}

.entity-head {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(220px, 380px) minmax(0, 1fr);
}

.hero-thumb {
  aspect-ratio: 1 / 1;
}

.entity-head-media {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.entity-head-media-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.entity-head-media-grid.media-count-1 {
  grid-template-columns: 1fr;
}

.entity-head-media-grid.media-count-3 .entity-head-media-slot:first-child {
  grid-row: span 2;
}

.entity-head-thumb,
.entity-head-placeholder,
.entity-head-viewer {
  aspect-ratio: 1 / 1;
  border-radius: 7px;
  min-height: 0;
  width: 100%;
}

.entity-head-placeholder {
  grid-column: 1 / -1;
}

.entity-head-content {
  align-content: start;
  display: grid;
  gap: 10px;
  min-width: 0;
}

.entity-head-content h2 {
  margin: 0;
  overflow-wrap: anywhere;
}

.entity-head-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.entity-head-actions button {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--button-active-text);
  font-weight: 800;
}

.catalog-add-drawer {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-column: 1 / -1;
  padding: 14px;
}

.catalog-add-drawer[hidden] {
  display: none;
}

.catalog-add-drawer-head {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.catalog-add-drawer-head h3 {
  font-size: 17px;
}

.catalog-add-drawer-body,
.catalog-add-form,
.catalog-add-target {
  display: grid;
  gap: 10px;
}

.catalog-add-inline {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(110px, 160px) minmax(150px, 1fr);
}

.entity-head-facts {
  max-width: 100%;
}

.entity-head-facts .entity-info-tag {
  font-size: 11px;
  min-height: 24px;
}

.entity-section-nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 2px;
}

.entity-section-nav-link {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--tag-link-text);
  display: inline-flex;
  height: 36px;
  justify-content: center;
  min-height: 36px;
  padding: 0;
  width: 36px;
}

.entity-section-nav-link:hover,
.entity-section-nav-link:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: 2px solid rgba(244, 207, 87, 0.18);
  outline-offset: 1px;
  text-decoration: none;
}

.entity-section-nav-link.disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.36;
}

.entity-section-nav-link.disabled:hover {
  border-color: var(--line);
  color: var(--muted);
  outline: none;
}

.entity-section-nav-icon,
.entity-section-nav-icon svg {
  display: block;
  height: 20px;
  width: 20px;
}

.entity-section-nav-icon svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.entity-fact-detail {
  display: inline-flex;
  min-width: 0;
  position: relative;
}

.entity-fact-detail > summary {
  cursor: pointer;
  display: inline-flex;
  list-style: none;
}

.entity-fact-detail > summary::-webkit-details-marker {
  display: none;
}

.entity-fact-detail[open] {
  z-index: 5;
}

.entity-fact-popover {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 12px;
  left: 0;
  line-height: 1.35;
  max-width: min(360px, 80vw);
  min-width: 180px;
  padding: 8px 10px;
  position: absolute;
  top: calc(100% + 6px);
  white-space: normal;
}

.entity-fact-popover-tags {
  max-height: 220px;
  min-width: min(260px, 74vw);
  overflow: auto;
}

.entity-fact-popover-tags .entity-info-tag {
  font-size: 11px;
}

.entity-head-media-more {
  align-self: start;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  display: inline-flex;
  font-size: 12px;
  font-weight: 750;
  padding: 5px 8px;
  width: fit-content;
}

.entity-head-media-more:hover,
.entity-head-media-more:focus-visible {
  border-color: var(--accent);
  outline: 2px solid rgba(244, 207, 87, 0.18);
  outline-offset: 1px;
  text-decoration: none;
}

.entity-head-media-notice {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.entity-head-media-drawer {
  border-top: 1px solid var(--line);
  grid-column: 1 / -1;
  padding-top: 12px;
}

.entity-head-media-drawer[hidden] {
  display: none;
}

.entity-head-drawer-head {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.entity-head-drawer-head h3 {
  margin: 0;
}

.entity-head-drawer-close {
  min-height: 30px;
  padding: 5px 9px;
}

.entity-head-media-drawer .media-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.detail-media {
  margin: 12px 0;
}

.detail-grid,
.row-list,
.raw-list {
  display: grid;
  gap: 8px;
}

.dense-list {
  max-height: 620px;
  overflow: auto;
}

.kv-grid,
.metric-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-top: 12px;
}

.kv-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.metric-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.metric {
  padding: 10px;
}

.metric strong {
  display: block;
  font-size: 19px;
}

.metric span {
  color: var(--muted);
}

.kv,
.row,
.raw-item,
.source-summary-row {
  box-shadow: none;
  padding: 9px;
}

.row strong,
.kv strong,
.raw-item strong {
  display: block;
  overflow-wrap: anywhere;
}

.kv span,
.row span {
  overflow-wrap: anywhere;
}

.detail-section {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 14px;
}

.detail-section h3 {
  margin-bottom: 10px;
}

.instruction-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.instruction-action {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  display: grid;
  gap: 2px;
  min-height: 40px;
  min-width: min(100%, 220px);
  padding: 8px 10px;
}

.instruction-action:hover,
.instruction-action:focus-visible {
  border-color: var(--accent);
  outline: 2px solid rgba(244, 207, 87, 0.18);
  outline-offset: 1px;
  text-decoration: none;
}

.instruction-action span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.instruction-action.primary {
  border-color: rgba(31, 93, 168, 0.45);
}

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

.instruction-viewer {
  display: grid;
  gap: 8px;
}

.instruction-crumbbar {
  font-size: 13px;
  line-height: 1.35;
  margin-bottom: 0;
}

.instruction-download,
.instruction-nav-button,
.instruction-page-submit {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 34px;
  min-width: 34px;
  padding: 0 9px;
}

.instruction-download:hover,
.instruction-download:focus-visible,
.instruction-nav-button:hover,
.instruction-nav-button:focus-visible,
.instruction-page-submit:hover,
.instruction-page-submit:focus-visible {
  border-color: var(--accent);
  outline: 2px solid rgba(244, 207, 87, 0.18);
  outline-offset: 1px;
  text-decoration: none;
}

.instruction-nav-button.disabled {
  color: var(--muted);
  opacity: 0.55;
}

.instruction-toolbar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.instruction-page-form {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  display: inline-flex;
  gap: 6px;
  min-height: 34px;
  padding: 0 4px 0 8px;
}

.instruction-page-label {
  align-items: center;
  display: inline-flex;
}

.instruction-page-input {
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  height: 28px;
  padding: 0;
  text-align: right;
  width: 5ch;
}

.instruction-page-input:focus-visible {
  outline: 2px solid rgba(244, 207, 87, 0.28);
  outline-offset: 2px;
}

.instruction-page-total {
  color: var(--muted);
  font-weight: 700;
}

.instruction-page-submit {
  font-size: 12px;
  min-height: 28px;
  min-width: 32px;
  padding: 0 7px;
}

.instruction-page-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  padding: 0 10px 10px;
  position: relative;
  touch-action: pan-y;
}

.instruction-page-shell:fullscreen,
.instruction-page-shell.is-fullscreen {
  background: #111;
  border: 0;
  border-radius: 0;
  padding: 0 12px 12px;
}

.instruction-page-shell:fullscreen .instruction-toolbar,
.instruction-page-shell.is-fullscreen .instruction-toolbar {
  background: rgba(17, 17, 17, 0.92);
  border-bottom-color: rgba(255, 255, 255, 0.18);
}

.instruction-fullscreen-close {
  display: none;
}

.instruction-page-shell:fullscreen .instruction-fullscreen-close,
.instruction-page-shell.is-fullscreen .instruction-fullscreen-close {
  display: inline-flex;
}

.instruction-viewer-main {
  align-items: start;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr);
  margin-top: 10px;
}

.instruction-outline {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 280px;
  overflow: auto;
  padding: 10px;
}

.instruction-outline strong {
  display: block;
  margin-bottom: 8px;
}

.instruction-outline ol {
  display: grid;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0 0 0 12px;
}

.instruction-outline button {
  background: transparent;
  border: 0;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  padding: 3px 0;
  text-align: left;
}

.instruction-outline button:hover,
.instruction-outline button:focus-visible {
  color: var(--accent);
  outline: 0;
}

.instruction-page-shell:fullscreen .instruction-viewer-main,
.instruction-page-shell.is-fullscreen .instruction-viewer-main {
  margin-top: 12px;
}

.instruction-page-shell:fullscreen .instruction-outline,
.instruction-page-shell.is-fullscreen .instruction-outline {
  background: rgba(17, 17, 17, 0.94);
  border-color: rgba(255, 255, 255, 0.18);
  color: #f7f7f7;
}

.instruction-page-stage {
  background: #fff;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  margin: 0 auto;
  min-height: 320px;
  overflow: hidden;
  position: relative;
}

.instruction-page-shell:fullscreen .instruction-page-stage,
.instruction-page-shell.is-fullscreen .instruction-page-stage {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.32);
  min-height: 0;
}

.instruction-page-canvas {
  display: block;
  user-select: none;
}

.instruction-pdf-text-layer {
  color-scheme: only light;
  inset: 0;
  line-height: 1;
  overflow: clip;
  position: absolute;
  text-align: initial;
  transform-origin: 0 0;
  z-index: 1;
}

.instruction-pdf-text-layer span,
.instruction-pdf-text-layer br {
  color: transparent;
  cursor: text;
  position: absolute;
  transform-origin: 0 0;
  user-select: text;
  white-space: pre;
}

.instruction-pdf-text-layer > :not(.markedContent),
.instruction-pdf-text-layer .markedContent span:not(.markedContent) {
  --font-height: 0;
  --min-font-size: 1;
  --min-font-size-inv: calc(1 / var(--min-font-size));
  --scale-x: 1;
  --rotate: 0deg;
  font-size: calc(var(--total-scale-factor) * var(--min-font-size) * var(--font-height));
  transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));
  z-index: 1;
}

.instruction-pdf-text-layer .markedContent {
  display: contents;
}

.instruction-pdf-text-layer .endOfContent {
  inset: 100% 0 0;
  position: absolute;
  user-select: none;
}

.instruction-page-status {
  align-items: center;
  background: rgba(255, 255, 255, 0.86);
  color: #222;
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 16px;
  pointer-events: none;
  position: absolute;
  text-align: center;
}

.instruction-page-status:empty {
  display: none;
}

.instruction-page-status[data-status-kind="error"] {
  color: #b91c1c;
}

.instruction-status-icon {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  display: inline-flex;
  height: 40px;
  justify-content: center;
  margin-top: 10px;
  width: 40px;
}

.instruction-status-icon svg {
  fill: none;
  height: 22px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  width: 22px;
}

.section-line {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-line h3 {
  margin-bottom: 0;
}

.tab-bar {
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-bottom: 10px;
}

.tab-button {
  min-height: 34px;
  padding: 6px 10px;
}

.tab-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--button-active-text);
  font-weight: 800;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.color-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.color-row {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: grid;
  gap: 8px;
  grid-template-columns: auto minmax(0, 1fr);
  padding: 9px;
}

.color-row .meta {
  grid-column: 2;
}

.swatch {
  border: 1px solid var(--swatch-border);
  border-radius: 50%;
  display: inline-block;
  height: 24px;
  width: 24px;
}

.id-strip {
  margin-top: 10px;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  padding: 6px 10px;
}

.tag span {
  color: var(--muted);
  margin-left: 6px;
}

.media-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.version-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.version-button {
  align-items: start;
  display: grid;
  gap: 3px;
  min-height: 48px;
  min-width: 130px;
  text-align: left;
}

.version-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--button-active-text);
  font-weight: 800;
}

.version-button span {
  color: inherit;
  font-size: 12px;
  opacity: 0.82;
}

.inventory-version-panel {
  display: none;
}

.inventory-version-panel.active {
  display: block;
}

.inventory-version-summary {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 8px 10px;
}

.inventory-version-summary span {
  color: var(--muted);
}

.inventory-role-block {
  display: grid;
  gap: 10px;
}

.spare-section {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 12px;
}

.spare-section h4 {
  color: var(--text);
  font-size: 15px;
  margin: 0;
  text-transform: none;
}

.inventory-grid,
.entity-card-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
}

.entity-card-grid.technical-matrix {
  grid-template-columns: repeat(auto-fill, minmax(208px, 1fr));
}

.entity-card-grid.technical-matrix.catalog-matrix {
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
}

.inventory-card,
.entity-card {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 8px;
}

.entity-card-grid.technical-matrix .entity-card {
  grid-template-rows: auto 1fr;
}

.catalog-mini-card .entity-thumb {
  background:
    linear-gradient(135deg, rgba(245, 247, 249, 0.96), rgba(221, 228, 235, 0.96)),
    #f5f7f9;
}

.entity-card-image-link {
  color: inherit;
  display: block;
  min-width: 0;
}

.entity-card-image-link:hover {
  text-decoration: none;
}

.inventory-card:hover,
.entity-card:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.inventory-image,
.entity-card-image {
  min-width: 0;
  position: relative;
}

.inventory-thumb,
.entity-thumb {
  aspect-ratio: 1 / 1;
  background: var(--image-bg);
  min-width: 0;
}

.placeholder.entity-thumb {
  overflow-wrap: anywhere;
}

.part-color-card .entity-thumb,
.print-card .entity-thumb {
  background:
    linear-gradient(135deg, rgba(245, 247, 249, 0.96), rgba(221, 228, 235, 0.96)),
    #f5f7f9;
}

.color-thumb {
  align-items: center;
  display: flex;
  justify-content: center;
}

.color-thumb-swatch {
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(8, 11, 16, 0.18);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35), 0 8px 18px rgba(8, 11, 16, 0.18);
  display: block;
  width: 62%;
}

.qty-badge {
  background: var(--badge-bg);
  border: 1px solid var(--badge-border);
  border-radius: 6px;
  color: var(--badge-text);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 5px 7px;
  position: absolute;
  right: 6px;
  box-shadow: 0 6px 14px rgba(8, 11, 16, 0.28);
  top: 6px;
}

.inventory-resolution-badge {
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 6px;
  bottom: 6px;
  box-shadow: 0 6px 14px rgba(8, 11, 16, 0.24);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  left: 6px;
  letter-spacing: 0;
  line-height: 1;
  max-width: calc(100% - 12px);
  overflow: hidden;
  padding: 5px 7px;
  position: absolute;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-resolution-badge--error {
  background: #b42318;
}

.inventory-resolution-badge--any {
  background: #256f4a;
}

.inventory-resolution-badge--unknown {
  background: #5f6b7a;
}

.inventory-pseudo-swatch {
  border: 1px solid rgba(84, 96, 120, 0.36);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.68);
  display: inline-block;
  flex: 0 0 auto;
  height: 12px;
  width: 12px;
}

.inventory-pseudo-swatch--any {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72) 0 25%, transparent 25% 50%, rgba(255, 255, 255, 0.72) 50% 75%, transparent 75%),
    #d7e8de;
  background-size: 8px 8px;
}

.inventory-pseudo-swatch--unknown {
  background: #e5e7eb;
}

.inventory-card-body,
.entity-card-body {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.inventory-card-body strong,
.entity-card-body strong {
  display: -webkit-box;
  font-size: 12px;
  line-height: 1.22;
  min-height: 30px;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.entity-card-identity {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  line-height: 1.2;
  min-width: 0;
}

.entity-card-title-link {
  color: var(--text);
}

.entity-card-title-link:hover {
  color: var(--accent-strong);
}

.inventory-meta,
.entity-card-meta {
  align-items: center;
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 6px;
  grid-template-columns: auto minmax(0, 1fr);
}

.inventory-meta .swatch,
.entity-card-meta .swatch {
  height: 16px;
  width: 16px;
}

.inventory-meta span,
.entity-card-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-card-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.entity-info-tags {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.entity-card-tags {
  align-content: flex-start;
}

.seo-link-facts.entity-info-tags {
  display: inline-flex;
  margin-left: 6px;
  vertical-align: middle;
}

.entity-info-tag {
  align-items: center;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 6px;
  color: var(--tag-text);
  display: inline-flex;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.15;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 4px 7px;
}

.tag-tone-0 {
  background: rgba(148, 163, 184, 0.13);
  border-color: rgba(148, 163, 184, 0.28);
}

.tag-tone-1 {
  background: rgba(156, 163, 175, 0.13);
  border-color: rgba(156, 163, 175, 0.28);
}

.tag-tone-2 {
  background: rgba(161, 161, 170, 0.13);
  border-color: rgba(161, 161, 170, 0.28);
}

.tag-tone-3 {
  background: rgba(120, 113, 108, 0.13);
  border-color: rgba(120, 113, 108, 0.28);
}

.tag-tone-4 {
  background: rgba(100, 116, 139, 0.13);
  border-color: rgba(100, 116, 139, 0.28);
}

.tag-tone-5 {
  background: rgba(115, 115, 115, 0.13);
  border-color: rgba(115, 115, 115, 0.28);
}

.entity-card-tags .entity-info-tag.type,
.entity-card-tags .entity-info-tag.article {
  font-size: 10.5px;
  padding: 3px 6px;
}

.entity-info-tag.type {
  background: rgba(56, 189, 248, 0.13);
  border-color: rgba(56, 189, 248, 0.28);
  color: var(--tag-type-text);
}

.entity-info-tag.article {
  background: rgba(226, 232, 240, 0.11);
  border-color: rgba(226, 232, 240, 0.24);
  color: var(--tag-article-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  letter-spacing: 0;
}

.entity-info-tag.year {
  background: rgba(250, 204, 21, 0.12);
  border-color: rgba(250, 204, 21, 0.3);
  color: var(--tag-year-text);
}

.entity-info-tag.theme {
  background: rgba(167, 139, 250, 0.14);
  border-color: rgba(167, 139, 250, 0.32);
  color: var(--tag-theme-text);
}

.entity-info-tag.quantity {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.28);
  color: var(--tag-quantity-text);
}

.entity-info-tag.role {
  background: rgba(251, 146, 60, 0.12);
  border-color: rgba(251, 146, 60, 0.28);
  color: var(--tag-role-text);
}

.entity-info-tag.version {
  background: rgba(244, 114, 182, 0.12);
  border-color: rgba(244, 114, 182, 0.26);
  color: var(--tag-version-text);
}

.entity-info-tag.color {
  align-items: center;
  background: rgba(45, 212, 191, 0.1);
  border-color: rgba(45, 212, 191, 0.24);
  color: var(--tag-color-text);
  display: inline-flex;
  gap: 5px;
  overflow-wrap: normal;
}

.entity-info-tag.color .swatch {
  flex: 0 0 12px;
  height: 12px;
  width: 12px;
}

.entity-info-tag.color span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-info-tag-link {
  border-color: rgba(244, 207, 87, 0.38);
  color: var(--tag-link-text);
}

.entity-info-tag-link:hover,
.entity-info-tag-link:focus-visible {
  border-color: var(--accent);
  outline: 2px solid rgba(244, 207, 87, 0.18);
  outline-offset: 1px;
  text-decoration: none;
}

.search-active-filters {
  display: inline-flex;
  margin-left: 8px;
  vertical-align: middle;
}

.entity-info-tag.source {
  background: rgba(148, 163, 184, 0.11);
  color: var(--tag-source-text);
}

.entity-info-tag.usage {
  background: rgba(129, 140, 248, 0.12);
  border-color: rgba(129, 140, 248, 0.28);
  color: var(--tag-usage-text);
}

.entity-fact-popover-tags .entity-info-tag.tag-tone-0,
.filter-option-chip.tag-tone-0 {
  background: rgba(148, 163, 184, 0.13);
  border-color: rgba(148, 163, 184, 0.28);
  color: var(--tag-text);
}

.entity-fact-popover-tags .entity-info-tag.tag-tone-1,
.filter-option-chip.tag-tone-1 {
  background: rgba(156, 163, 175, 0.13);
  border-color: rgba(156, 163, 175, 0.28);
  color: var(--tag-text);
}

.entity-fact-popover-tags .entity-info-tag.tag-tone-2,
.filter-option-chip.tag-tone-2 {
  background: rgba(161, 161, 170, 0.13);
  border-color: rgba(161, 161, 170, 0.28);
  color: var(--tag-text);
}

.entity-fact-popover-tags .entity-info-tag.tag-tone-3,
.filter-option-chip.tag-tone-3 {
  background: rgba(120, 113, 108, 0.13);
  border-color: rgba(120, 113, 108, 0.28);
  color: var(--tag-text);
}

.entity-fact-popover-tags .entity-info-tag.tag-tone-4,
.filter-option-chip.tag-tone-4 {
  background: rgba(100, 116, 139, 0.13);
  border-color: rgba(100, 116, 139, 0.28);
  color: var(--tag-text);
}

.entity-fact-popover-tags .entity-info-tag.tag-tone-5,
.filter-option-chip.tag-tone-5 {
  background: rgba(115, 115, 115, 0.13);
  border-color: rgba(115, 115, 115, 0.28);
  color: var(--tag-text);
}

.entity-info-tag.muted {
  opacity: 0.72;
}

.entity-relation-path {
  align-items: center;
  display: flex;
  flex-wrap: nowrap;
  gap: 1px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.path-node {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  display: inline-flex;
  flex: 0 0 32px;
  font-size: 10px;
  font-weight: 800;
  height: 32px;
  justify-content: center;
  line-height: 1;
  overflow: hidden;
  padding: 0;
  width: 32px;
}

.path-node .thumb,
.path-node .placeholder,
.path-node-thumb {
  aspect-ratio: 1 / 1;
  border: 0;
  border-radius: 5px;
  height: 100%;
  padding: 0;
  width: 100%;
}

.path-node-fallback {
  align-items: center;
  background:
    linear-gradient(135deg, rgba(244, 207, 87, 0.16), rgba(87, 199, 178, 0.08)),
    var(--surface-soft);
  color: var(--muted);
  display: inline-flex;
  font-size: 10px;
  height: 100%;
  justify-content: center;
  width: 100%;
}

.path-separator {
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 12px;
  line-height: 1;
  margin: 0;
}

.media-card {
  box-shadow: none;
  display: grid;
  gap: 8px;
  grid-template-rows: auto 1fr;
  padding: 8px;
}

.media-thumb {
  aspect-ratio: 1 / 1;
}

.ldraw-viewer {
  background: var(--image-bg);
  position: relative;
}

.ldraw-viewer canvas {
  display: block;
  height: 100%;
  width: 100%;
}

.ldraw-viewer-reset {
  align-items: center;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  height: 32px;
  justify-content: center;
  padding: 0;
  position: absolute;
  right: 8px;
  top: 8px;
  width: 32px;
}

.ldraw-viewer-reset svg {
  fill: var(--text);
  height: 18px;
  width: 18px;
}

.ldraw-viewer-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  left: 10px;
  position: absolute;
  top: 10px;
}

.ldraw-viewer[data-ldraw-state="ready"] .ldraw-viewer-status {
  display: none;
}

.ldraw-viewer[data-ldraw-state="error"] {
  background:
    linear-gradient(135deg, rgba(221, 80, 80, 0.12), rgba(255, 255, 255, 0.4)),
    #f5f7f9;
}

.media-body {
  display: grid;
  gap: 5px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.source-summary {
  display: grid;
  gap: 8px;
}

.source-summary-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(160px, 220px) minmax(180px, 1fr) minmax(220px, 2fr);
}

.source-list {
  display: grid;
  gap: 12px;
}

.source-block {
  box-shadow: none;
  padding: 0;
}

.source-block > summary {
  align-items: center;
  cursor: pointer;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(150px, 210px) minmax(180px, 1fr) minmax(240px, 2fr);
  padding: 12px;
}

.source-grid {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  padding: 12px;
}

.source-wide {
  grid-column: 1 / -1;
}

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

.raw-item summary {
  cursor: pointer;
}

.raw-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--code-text);
  margin: 8px 0 0;
  max-height: 360px;
  overflow: auto;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

.empty,
.error {
  color: var(--muted);
  padding: 14px 0;
}

.error {
  color: var(--bad);
}

.app-shell {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.app-shell-wide {
  align-items: stretch;
  display: block;
  justify-content: initial;
  margin: 0 auto;
  max-width: 1840px;
  padding: 14px clamp(12px, 3vw, 34px) 42px;
}

.app-panel {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
  max-width: 720px;
  padding: clamp(20px, 4vw, 34px);
  width: min(100%, 720px);
}

.app-shell-wide .app-panel {
  max-width: none;
  width: 100%;
}

.app-workspace {
  display: grid;
  gap: 12px;
  min-width: 0;
  width: 100%;
}

.app-top-nav,
.app-breadcrumbs {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.app-top-nav {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 10px;
}

.app-top-nav-link {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: inline-flex;
  min-height: 36px;
  padding: 8px 12px;
  text-decoration: none;
}

.app-top-nav-link.active {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-soft));
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  color: var(--accent-strong);
}

.app-top-nav-logout {
  margin-left: auto;
}

.app-breadcrumbs {
  color: var(--muted);
  font-size: 13px;
  padding: 0 4px;
}

.app-breadcrumbs a,
.app-breadcrumb-current {
  max-width: min(52ch, 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-breadcrumb-separator {
  color: var(--muted);
}

.auth-panel {
  max-width: 560px;
}

.app-logo-link {
  display: inline-flex;
  justify-self: start;
}

.app-panel-heading {
  display: grid;
  gap: 6px;
}

.app-auth-switch {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 4px;
}

.app-auth-switch button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  min-height: 34px;
  padding: 7px 8px;
}

.app-auth-switch button.active {
  background: var(--panel-bg);
  color: var(--text);
}

.app-form {
  display: grid;
  gap: 14px;
}

.app-field {
  color: var(--muted);
  display: grid;
  gap: 7px;
}

.app-field input,
.app-field select,
.app-field textarea,
.app-list-item-row input,
.app-list-item-row select,
.app-import-row input,
.app-import-row select {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  min-height: 42px;
  padding: 10px 12px;
  width: 100%;
}

.app-field-hint {
  color: color-mix(in srgb, var(--muted) 86%, var(--text));
  font-size: 0.9rem;
  line-height: 1.35;
}

.app-field textarea {
  line-height: 1.4;
  min-height: 180px;
  resize: vertical;
}

.app-form button,
.app-dashboard button,
.app-profile button,
.app-lists button {
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 7px;
  color: var(--button-active-text);
  cursor: pointer;
  min-height: 42px;
  padding: 10px 14px;
}

.app-password-tools {
  align-items: center;
  display: grid;
  gap: 8px 10px;
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.app-password-generate-label {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.2;
  white-space: nowrap;
}

.app-password-levels {
  display: grid;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  gap: 3px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 3px;
}

.app-password-level {
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  justify-content: center;
  min-height: 30px;
  padding: 5px 8px;
  position: relative;
  text-align: center;
}

.app-password-level input {
  cursor: pointer;
  height: 100%;
  inset: 0;
  margin: 0;
  opacity: 0;
  position: absolute;
  width: 100%;
}

.app-password-level span {
  font-size: 0.84rem;
  font-weight: 650;
  line-height: 1.2;
}

.app-password-level:has(input:checked) {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border-color: var(--accent);
  color: var(--text);
}

.app-password-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
}

.app-form .app-password-action {
  background: var(--surface-soft);
  border-color: var(--line);
  color: var(--text);
  font-size: 0.84rem;
  min-height: 32px;
  padding: 5px 9px;
  white-space: nowrap;
}

.app-auth-social {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  padding-top: 4px;
}

.app-auth-social-heading {
  display: grid;
  gap: 5px;
}

.app-auth-social-heading h2 {
  font-size: 1rem;
  margin: 0;
}

.app-auth-social-heading p {
  color: var(--muted);
  line-height: 1.4;
  margin: 0;
}

.app-social-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.app-social-provider {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  display: grid;
  gap: 6px;
  justify-items: center;
  min-height: 92px;
  padding: 10px 8px;
  text-align: center;
}

.app-social-provider:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.app-social-provider.active {
  cursor: pointer;
}

.app-social-provider.active:hover {
  border-color: var(--accent);
  color: var(--text);
}

.app-social-mark {
  align-items: center;
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  font-weight: 750;
  height: 32px;
  justify-content: center;
  width: 32px;
}

.app-social-provider small {
  color: var(--muted);
}

.app-telegram-widget {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 42px;
}

.app-telegram-widget[hidden] {
  display: none;
}

.app-telegram-widget-status {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  padding: 9px 12px;
}

.app-telegram-widget-status.bad {
  border-color: color-mix(in srgb, #d64242 60%, var(--line));
  color: #b42318;
}

.app-status {
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  padding: 10px 12px;
}

.app-status.ok {
  color: var(--good);
}

.app-status.bad {
  color: var(--bad);
}

.app-account {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-account-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.app-match-kpis {
  margin-top: 0;
}

.app-match-metric {
  min-height: 82px;
}

.app-match-metric small {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.app-match-direction-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.app-match-source-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
}

.app-match-source-title {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 10px;
}

.app-match-source-title strong {
  overflow-wrap: anywhere;
}

.app-match-status-filter {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-match-status-filter button {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  min-height: 36px;
  padding: 7px 10px;
}

.app-match-status-filter button.active {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface-soft));
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  color: var(--accent-strong);
}

.app-match-status-filter small {
  color: var(--muted);
}

.app-match-save-grid {
  align-items: end;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px) max-content;
}

.app-avatar {
  align-content: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  flex: 0 0 auto;
  gap: 1px;
  height: 56px;
  justify-items: center;
  padding-top: 5px;
  width: 56px;
}

.app-avatar-large {
  height: 96px;
  width: 96px;
}

.app-avatar-image {
  overflow: hidden;
  padding: 0;
}

.app-avatar-image img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.app-avatar-head {
  background: var(--avatar-head);
  border: 1px solid color-mix(in srgb, var(--text) 16%, transparent);
  border-radius: 8px 8px 6px 6px;
  height: 20px;
  position: relative;
  width: 24px;
}

.app-avatar-face::before,
.app-avatar-face::after {
  background: color-mix(in srgb, var(--text) 78%, transparent);
  border-radius: 50%;
  content: "";
  height: 2px;
  position: absolute;
  top: 8px;
  width: 2px;
}

.app-avatar-face::before {
  left: 7px;
}

.app-avatar-face::after {
  right: 7px;
}

.app-avatar-body {
  background: var(--avatar-torso);
  border: 1px solid color-mix(in srgb, var(--text) 16%, transparent);
  border-radius: 5px 5px 3px 3px;
  height: 20px;
  overflow: hidden;
  position: relative;
  width: 30px;
}

.app-avatar-accent {
  background: var(--avatar-accent);
  border-radius: 999px;
  height: 18px;
  left: 13px;
  opacity: 0.82;
  position: absolute;
  top: 1px;
  width: 4px;
}

.app-avatar-legs {
  background:
    linear-gradient(90deg, var(--avatar-legs) 0 45%, transparent 45% 55%, var(--avatar-legs) 55% 100%);
  border-radius: 2px 2px 4px 4px;
  height: 11px;
  width: 28px;
}

.app-profile-avatar-card {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.app-profile-avatar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-avatar-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 10px;
}

.app-avatar-editor[hidden] {
  display: none;
}

.app-avatar-editor-stage {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 260px;
  overflow: hidden;
}

.app-avatar-editor-stage img {
  display: block;
  max-height: 420px;
  max-width: 100%;
}

.app-avatar-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-dashboard-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(208px, 1fr));
}

.app-dashboard-item {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 74px;
  padding: 14px;
  text-decoration: none;
}

.app-dashboard-item.gated {
  opacity: 0.78;
}

.app-dashboard-item span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.app-dashboard-item small {
  color: var(--muted);
}

.app-dashboard-section {
  display: grid;
  gap: 10px;
}

.app-list-detail-compact {
  gap: 14px;
  padding-top: clamp(18px, 3vw, 28px);
}

.app-list-command-block,
.app-list-workbench {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.app-list-command-block {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.app-list-command-main {
  align-items: start;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  min-width: 0;
}

.app-list-command-main h1 {
  margin-bottom: 0;
}

.app-list-command-controls {
  align-items: end;
  display: grid;
  gap: 8px;
  justify-items: end;
}

.app-list-primary-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.app-icon-action,
.app-view-toggle button,
.app-list-search-actions button,
.app-list-tool-panel > summary {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.app-icon-action {
  min-height: 36px;
  padding: 7px 10px;
}

.app-icon-action small {
  color: var(--muted);
  font-size: 12px;
}

.app-action-mark {
  align-items: center;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-soft));
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: 999px;
  color: var(--accent-strong);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 760;
  height: 22px;
  justify-content: center;
  line-height: 1;
  width: 22px;
}

.app-list-workbench {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.app-list-title-row {
  align-items: center;
  display: flex;
  gap: 8px;
  min-width: 0;
}

.app-list-title-row h1 {
  min-width: 0;
}

.app-title-edit-action {
  min-height: 34px;
  min-width: 34px;
  padding: 7px;
}

.app-list-description,
.app-list-card-description {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  margin: 4px 0 0;
}

.app-list-card-description {
  display: -webkit-box;
  margin-bottom: 6px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.app-list-title-edit-panel {
  border: 1px solid var(--line);
  border-radius: 7px;
  margin-top: 8px;
}

.app-list-title-edit-panel > summary {
  height: 0;
  list-style: none;
  overflow: hidden;
  padding: 0;
}

.app-list-title-edit-panel > summary::-webkit-details-marker {
  display: none;
}

.app-inline-form {
  align-items: end;
  grid-template-columns: minmax(180px, 1fr) minmax(150px, 220px) auto;
}

.app-list-stack {
  display: grid;
  gap: 8px;
}

.app-view-toggle {
  align-items: center;
  display: inline-flex;
  gap: 4px;
  justify-self: start;
}

.app-view-toggle button {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--text);
  min-height: 36px;
  padding: 7px 12px;
}

.app-view-toggle button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--button-active-text);
}

.app-list-search-form {
  align-items: end;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.app-list-search-grid {
  grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(130px, 0.8fr));
}

.app-list-search-actions {
  justify-content: flex-start;
}

.app-list-tool-grid {
  align-items: start;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  min-width: 0;
}

.app-list-tool-panel {
  border: 1px solid var(--line);
  border-radius: 7px;
  min-width: 0;
}

.app-list-tool-panel[data-app-list-tool="history"] {
  grid-column: 1 / -1;
}

.app-list-tool-panel > summary {
  color: var(--text);
  cursor: pointer;
  display: flex;
  font-weight: 700;
  list-style: none;
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

.app-list-tool-panel > summary::-webkit-details-marker {
  display: none;
}

.app-list-tool-panel > summary small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  margin-left: auto;
}

.app-list-tool-panel[open] > summary {
  border-bottom: 1px solid var(--line);
}

.app-list-tool-content {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.app-list-tool-content .app-operation-form,
.app-list-tool-content .app-list-history {
  border-top: 0;
  padding-top: 0;
}

.app-list-tool-content .app-inline-form,
.app-list-tool-content .app-operation-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.app-list-tool-content .app-list-item-compact {
  grid-template-columns: minmax(220px, 1fr) 96px minmax(130px, 180px) auto;
}

.app-list-tool-content .app-list-settings-compact {
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 220px) auto;
}

.app-list-tool-content .app-list-item-compact,
.app-list-tool-content .app-list-settings-compact {
  align-items: end;
}

.app-list-description-field,
.app-list-batch-rows-field {
  grid-column: 1 / -1;
}

.app-list-row-actions {
  display: grid;
  gap: 12px;
}

.app-list-action-section {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  padding-top: 10px;
}

.app-list-action-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.app-list-action-section h3 {
  font-size: 15px;
  line-height: 1.25;
  margin: 0;
}

.app-list-import-action .app-secondary-action {
  justify-self: start;
}

.app-advanced-fields {
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}

.app-advanced-fields > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.app-match-current-source {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-list-history.compact {
  display: grid;
  gap: 8px;
}

.app-list-card-view {
  align-items: stretch;
}

.app-list-card-board,
.app-list-card-section {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.app-list-card-section {
  padding-block: 2px 8px;
}

.app-list-item-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  position: relative;
}

.app-list-item-card .app-list-entity-card {
  height: 100%;
}

.app-list-card-check {
  left: 10px;
  position: absolute;
  top: 10px;
  z-index: 2;
}

.app-list-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-list-card-actions button,
.app-list-card-actions .app-secondary-action {
  min-height: 34px;
  padding: 7px 10px;
}

.app-list-item-row {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: grid;
  gap: 10px;
  min-height: 54px;
  padding: 10px 12px;
  text-decoration: none;
}

.app-list-item-row div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.app-list-item-row small {
  color: var(--muted);
}

.app-list-summary-grid {
  align-items: stretch;
}

.app-list-summary-card {
  height: 100%;
}

.app-list-preview-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.app-list-preview-strip .app-list-strip-thumb {
  flex: 0 0 36px;
  width: 36px;
}

.app-import-summary {
  align-items: center;
}

.app-import-row {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(220px, 1fr) minmax(130px, 190px) 86px minmax(120px, 160px) minmax(130px, 1fr) auto auto auto;
  min-height: 62px;
  padding: 12px;
}

.app-import-row-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.app-import-row-main small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.app-import-row-field {
  color: var(--muted);
  display: grid;
  gap: 5px;
  min-width: 0;
}

.app-import-row-field.compact {
  max-width: 100%;
}

.app-list-item-row {
  grid-template-columns: 28px minmax(180px, 1fr) 86px minmax(130px, 170px) minmax(130px, 1fr) auto auto;
}

.app-list-item-check {
  align-items: center;
  display: inline-flex;
  justify-content: center;
}

.app-list-item-check input,
.app-checkbox-field input {
  min-height: 0;
  width: auto;
}

.app-panel-heading.compact {
  gap: 3px;
}

.app-panel-heading.compact h2 {
  font-size: 18px;
  margin: 0;
}

.app-operation-form,
.app-list-history {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.app-operation-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.app-checkbox-field {
  align-items: center;
  grid-auto-flow: column;
  justify-content: start;
}

.app-import-candidate-grid {
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
}

.app-import-candidate-card {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.app-import-candidate-card .app-import-entity-card {
  height: 100%;
}

.app-card-action {
  min-height: 34px;
  padding: 6px 10px;
}

/* Batch V2 is a server-owned preview/recovery surface.  Keep its layout
   namespaced so it cannot restyle the unrelated private workspace forms. */
.app-batch-v2-panel,
.app-batch-v2-import-review,
.app-batch-v2-import-recovery,
.app-batch-v2-preview {
  border: 1px solid var(--line);
  border-radius: 9px;
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
}

.app-batch-v2-panel,
.app-batch-v2-import-recovery {
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}

.app-batch-v2-import-review,
.app-batch-v2-preview {
  background: var(--surface-soft);
}

.app-batch-v2-panel:focus-visible,
.app-batch-v2-import-review:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 3px;
}

.app-batch-v2-live,
.app-batch-v2-import-boundary,
.app-batch-v2-import-lock {
  color: var(--muted);
  line-height: 1.45;
  margin: 0;
  overflow-wrap: anywhere;
}

.app-batch-v2-import-lock {
  border-left: 3px solid var(--accent);
  padding-left: 10px;
}

.app-batch-v2-review-row [aria-invalid="true"] {
  border-color: var(--bad);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--bad) 20%, transparent);
}

.app-batch-v2-review-error {
  color: var(--bad);
  font-size: 13px;
  grid-column: 1 / -1;
  line-height: 1.4;
  margin: 0;
  overflow-wrap: anywhere;
}

.app-batch-v2-panel[data-app-batch-v2-focus-state],
.app-batch-v2-import-review[data-app-batch-v2-focus-state],
.app-batch-v2-review-row [data-app-batch-v2-review-field][data-app-batch-v2-focus-state] {
  scroll-margin-block: 16px;
}

.app-batch-v2-summary,
.app-batch-v2-actions,
.app-batch-v2-import-actions {
  align-items: center;
}

.app-batch-v2-preview {
  margin-top: 2px;
}

.app-batch-v2-preview-grid {
  align-items: stretch;
}

.app-batch-v2-preview-card,
.app-batch-v2-preview-fallback {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.app-batch-v2-preview-card > .app-list-entity-card {
  height: 100%;
}

.app-batch-v2-preview-fallback {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
}

.app-batch-v2-preview-pager {
  align-items: center;
  margin: 0;
}

.app-batch-v2-import-lifecycle {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}

.app-batch-v2-import-lifecycle li {
  align-items: center;
  color: var(--muted);
  display: grid;
  font-size: 13px;
  gap: 7px;
  grid-template-columns: auto minmax(0, 1fr);
  line-height: 1.25;
  min-width: 0;
}

.app-batch-v2-import-lifecycle li > span {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 760;
  height: 24px;
  justify-content: center;
  width: 24px;
}

.app-batch-v2-import-lifecycle li.done,
.app-batch-v2-import-lifecycle li.active {
  color: var(--text);
  font-weight: 700;
}

.app-batch-v2-import-lifecycle li.done > span {
  background: color-mix(in srgb, var(--accent) 13%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
}

.app-batch-v2-import-lifecycle li.active > span {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--button-active-text);
}

.app-batch-v2-bulk-selection {
  background: var(--surface-soft);
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  padding: 8px 10px;
}

@media (max-width: 640px) {
  .app-batch-v2-panel,
  .app-batch-v2-import-review,
  .app-batch-v2-import-recovery,
  .app-batch-v2-preview {
    padding: 12px;
  }

  .app-batch-v2-import-lifecycle {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-batch-v2-preview-pager,
  .app-batch-v2-actions,
  .app-batch-v2-import-actions {
    align-items: stretch;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .app-batch-v2-preview-pager > *,
  .app-batch-v2-actions > button,
  .app-batch-v2-import-actions > button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-batch-v2-panel[data-app-batch-v2-focus-state],
  .app-batch-v2-import-review[data-app-batch-v2-focus-state],
  .app-batch-v2-review-row [data-app-batch-v2-review-field][data-app-batch-v2-focus-state] {
    scroll-behavior: auto;
    transition: none;
  }
}

.app-movement-entry {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: grid;
  gap: 10px;
  padding: 10px 12px;
}

.app-movement-heading {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.app-history-action-list {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.app-history-action {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.app-history-action-link {
  align-items: center;
  color: inherit;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 10px;
  text-decoration: none;
}

.app-history-action-link:hover,
.app-history-action-link:focus-visible {
  border-color: var(--accent);
}

.app-history-action-main {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.app-history-action-title {
  font-size: 16px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.app-history-action-open {
  color: var(--muted);
  font-size: 13px;
}

.app-history-action-card-grid {
  margin: 0;
}

.app-danger-action,
.app-lists .app-danger-action {
  background: transparent;
  border-color: var(--bad);
  color: var(--bad);
}

.app-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.app-secondary-action {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  display: inline-flex;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  text-decoration: none;
}

/* W6c transfer targets are a single server-backed owner picker shared by
   aggregate custody and whole-copy movement.  The browser displays a narrow
   DTO only; it never turns generic editable lists into destination truth. */
.app-workspace-transfer-destinations {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 14px;
}

.app-workspace-transfer-destination-search {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.app-workspace-transfer-destination-list {
  display: grid;
  gap: 8px;
}

.app-workspace-transfer-destination {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 10px 12px;
  text-align: left;
}

.app-workspace-transfer-destination > span:first-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.app-workspace-transfer-destination small,
.app-field-value {
  color: var(--muted);
}

.app-field-value {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  padding: 8px 9px;
}

.app-workspace-transfer-destination:hover,
.app-workspace-transfer-destination:focus-visible,
.app-workspace-transfer-destination.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* The persisted allocation selection may have up to 200 rows.  Keep its
   status and server-side actions reachable before the long line list; native
   details gives keyboard users a compact mobile disclosure without recreating
   a client-side selection copy. */
.app-w6cb-selection-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 14px;
  position: sticky;
  top: 12px;
  z-index: 2;
}

.app-w6cb-selection-actions {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.app-w6cb-selection-lines {
  border-top: 1px solid var(--line);
  margin-top: 2px;
  padding-top: 10px;
}

.app-w6cb-selection-lines > summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  font-weight: 700;
  gap: 8px;
  justify-content: space-between;
  min-height: 38px;
}

.app-w6cb-selection-lines-content {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

/* W6c-c keeps a physical whole-copy identity visibly separate from an
   aggregate workspace position.  These controls remain in the private app
   shell; the grid only adapts layout and never derives stock in CSS/JS. */
.app-w6cc-materialize-grid,
.app-w6cc-whole-instances {
  margin-top: 12px;
}

.app-w6cc-materialize-card,
.app-w6cc-whole-instance-card,
.app-w6cc-bom-card {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.app-w6cc-whole-instance-card > .app-list-entity-card,
.app-w6cc-materialize-card > .app-list-entity-card,
.app-w6cc-bom-card > .app-list-entity-card,
.app-w6cc-operation-set-card > .app-list-entity-card {
  height: 100%;
}

.app-w6cc-copy-actions {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  padding-top: 12px;
}

.app-w6cc-inline-form {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.app-w6cc-part-out-form {
  border-top: 1px dashed var(--line);
  display: grid;
  gap: 10px;
  padding-top: 12px;
}

.app-w6cc-attestation {
  align-items: start;
  display: grid;
  gap: 9px;
  grid-template-columns: auto minmax(0, 1fr);
  justify-content: stretch;
}

.app-w6cc-attestation input {
  margin-top: 3px;
}

.app-w6cc-operation-status:focus,
.app-w6cc-operation-status:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 4px;
}

.app-w6cc-operation-set-card {
  margin-top: 12px;
  max-width: 360px;
}

.app-w6cc-effect,
.app-w6cc-bom-pager,
.app-workspace-whole-instance-pager {
  margin-top: 12px;
}

.app-w6cc-bom {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
}

/* W6c-d is an explicit, partial physical observation.  The visual grouping
   makes the picker, entered count and immutable preview distinct from the
   normal workspace ledger and avoids presenting this surface as a balance
   editor or a warehouse screen. */
.app-w6d-picker-grid,
.app-w6d-preview-lines {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-top: 14px;
}

.app-w6d-target-card,
.app-w6d-preview-card {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.app-w6d-target-card > .app-list-entity-card,
.app-w6d-preview-card > .app-list-entity-card {
  height: 100%;
}

.app-w6d-count-form {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding-top: 16px;
}

.app-w6d-count-line {
  border: 1px solid var(--line);
  border-radius: 9px;
  display: grid;
  gap: 10px;
  margin: 0;
  min-width: 0;
  padding: 14px;
}

.app-w6d-count-line legend {
  font-weight: 700;
  padding: 0 5px;
}

.app-w6d-count-line [aria-invalid="true"] {
  border-color: var(--bad);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--bad) 20%, transparent);
}

.app-w6d-line-error {
  color: var(--bad);
  font-size: 14px;
  margin: -2px 0 2px;
}

.app-w6d-missing-confirmation {
  align-items: start;
  border-left: 3px solid var(--danger, #b0473c);
  display: grid;
  gap: 9px;
  grid-template-columns: auto minmax(0, 1fr);
  padding: 8px 10px;
}

.app-w6d-missing-confirmation input {
  margin-top: 3px;
}

.app-w6d-operation-status:focus,
.app-w6d-operation-status:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 4px;
}

@media (max-width: 640px) {
  .catalog-updates-archive-head {
    align-items: stretch;
  }

  .catalog-updates-filter {
    flex-basis: 100%;
    width: 100%;
  }

  .catalog-updates-archive-pager {
    justify-content: space-between;
  }

  .app-shell {
    align-items: stretch;
    padding: 16px;
  }

  .app-password-tools,
  .app-social-grid {
    grid-template-columns: 1fr;
  }

  .app-password-actions {
    justify-content: stretch;
  }

  .app-form .app-password-action {
    flex: 1 1 0;
  }

  .app-top-nav-link {
    flex: 1 1 auto;
    justify-content: center;
  }

  .app-top-nav-logout {
    margin-left: 0;
  }

  /* W6c-b ledgers place a quantity/reason form beside a catalog card on
     desktop.  On a narrow viewport it must become a vertical action block,
     otherwise the grid's auto column can trap the release controls offscreen. */
  .app-history-action-link {
    align-items: stretch;
    grid-template-columns: minmax(0, 1fr);
  }

  .app-history-action-link > .app-form {
    min-width: 0;
  }

  .app-w6cc-inline-form {
    align-items: stretch;
    grid-template-columns: minmax(0, 1fr);
  }

  .app-workspace-transfer-destination-search {
    align-items: stretch;
    grid-template-columns: minmax(0, 1fr);
  }

  .app-workspace-transfer-destination-search .app-actions,
  .app-workspace-transfer-destination-search button,
  .app-w6cb-selection-actions > * {
    width: 100%;
  }

  .app-w6cb-selection-panel {
    position: static;
  }

  .app-w6cb-selection-lines > summary {
    padding: 4px 0;
  }

  .app-w6cc-inline-form > button,
  .app-w6cc-part-out-form > button,
  .app-w6d-target-card > button,
  .app-w6d-count-line > button {
    width: 100%;
  }
}

@media (max-width: 1180px) {
  .catalog-layout,
  .app-dashboard-grid,
  .app-inline-form,
  .app-list-command-main,
  .app-list-search-form,
  .app-list-search-grid,
  .app-list-tool-grid,
  .app-list-tool-content .app-list-item-compact,
  .app-list-tool-content .app-list-settings-compact,
  .app-list-item-row,
  .app-operation-grid,
  .app-match-direction-grid,
  .app-match-save-grid,
  .app-import-row,
  .entity-head,
  .source-grid,
  .split-grid,
  .search-form,
  .source-summary-row,
  .source-block > summary {
    grid-template-columns: 1fr;
  }

  .search-logo-link {
    transform: none;
  }

  .catalog-account {
    justify-content: flex-start;
  }

  .app-list-command-controls {
    justify-items: start;
  }

  .app-list-primary-actions {
    justify-content: flex-start;
  }

  .app-list-tool-panel[data-app-list-tool="history"] {
    grid-column: auto;
  }

  .catalog-add-inline {
    grid-template-columns: 1fr;
  }
}
