:root {
  --bg-primary: #f5f7fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0f2f5;
  --bg-elevated: #ffffff;

  --accent-primary: #e30613;
  --accent-secondary: #c00510;
  --accent-glow: rgba(227, 6, 19, 0.08);
  --accent-glow-strong: rgba(227, 6, 19, 0.15);

  --text-primary: #1a1a2e;
  --text-secondary: #5a6370;
  --text-muted: #8a919c;

  --border-color: #e0e4e8;
  --border-subtle: #eaedf0;

  --success: #00a67d;
  --warning: #e6940a;
  --error: #dc3545;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* Form controls do not inherit font in all browsers; keep UI on --font-sans */
button,
input,
select,
optgroup,
textarea {
  font-family: inherit;
}

/* ── Header ─────────────────────────────────────── */

.app-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  flex-shrink: 0;
}

.app-title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.title-separator {
  color: var(--border-color);
  font-weight: 300;
  margin: 0 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-lang {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.header-lang-select {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  padding: 3px 18px 3px 6px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.2;
  color: var(--text-secondary);
  background-color: var(--surface-elevated, rgba(255, 255, 255, 0.06));
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 16 16' fill='none' stroke='%238a919c' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  background-size: 8px 8px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  cursor: pointer;
  min-width: 3rem;
  max-width: 4rem;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.header-lang-select:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.header-lang-select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-glow-strong);
}

.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;
}

.header-user {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ── Main Content ───────────────────────────────── */

.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px 40px;
}

/* ── Toolbar ────────────────────────────────────── */

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.toolbar-row--top {
  align-items: stretch;
}

.toolbar-search-fav {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 280px;
  min-width: 0;
}

.toolbar-search-wrap {
  flex: 1 1 200px;
  min-width: 0;
}

.toolbar-hitlist-primary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}

.toolbar-hitlist-favorites {
  flex-shrink: 0;
  margin-left: auto;
}

.toolbar-row--hitlist {
  align-items: flex-start;
}

.toolbar-segment {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar-segment--export {
  flex-shrink: 0;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.toolbar-segment--hitlist {
  flex: 1 1 320px;
  min-width: 0;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  align-items: center;
}

.toolbar-segment--browse {
  flex-shrink: 0;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
}

.toolbar-labeled-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.toolbar-filter-select--unit-type {
  min-width: 140px;
  max-width: min(240px, 36vw);
}

.toolbar-label-text {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
}

.toolbar-filter-select--narrow {
  min-width: 4.5rem;
  max-width: 5.5rem;
}

.hit-page-nav {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.hit-page-nav.hidden {
  display: none;
}

/* Compact < page # > cluster (chevrons slightly smaller than modal prev/next) */
.hit-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  min-height: 26px;
  padding: 2px 4px;
  line-height: 0;
}

.hit-page-btn .hit-page-arrow {
  display: block;
  flex-shrink: 0;
  width: 12px;
  height: 12px;
}

.hit-page-indicator {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 0;
  padding: 0 3px;
  text-align: center;
}

.table-container {
  position: relative;
}

.list-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 247, 250, 0.82);
  backdrop-filter: blur(3px);
  border-radius: inherit;
}

.list-loading-overlay.hidden {
  display: none;
}

/* Shared loading card (overlay, modal, inline hit list) */
.app-loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 32px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.app-loading-card-label {
  text-align: center;
  max-width: 16rem;
  line-height: 1.35;
}

.hierarchy-loading-card-progress {
  gap: 10px;
}

.hierarchy-load-progress {
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.app-loading-card--modal {
  box-shadow: none;
  border: none;
  background: transparent;
  padding: 20px 24px;
}

.app-loading-card--compact {
  padding: 16px 22px;
  gap: 10px;
}

.hitlist-inline-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  min-height: 160px;
}

/* ── Buttons ────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  transition: all 0.2s ease;
  line-height: 1.4;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: #ffffff;
  box-shadow: 0 4px 16px var(--accent-glow-strong);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(227, 6, 19, 0.25);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-ghost {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--accent-glow);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.btn-ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.75rem;
}

/* ── Search ─────────────────────────────────────── */

/* Border/background live on the wrapper so the clear control is clearly inside the field, not beside the app title row */
.search-box {
  position: relative;
  display: flex;
  align-items: stretch;
  width: 280px;
  max-width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  z-index: 1;
}

.input-search {
  font-size: 0.85rem;
  flex: 1;
  min-width: 0;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  /* Room for magnifier (left) and clear control (right) */
  padding: 10px 38px 10px 36px;
  color: var(--text-primary);
  transition: color 0.2s ease;
}

.input-search:focus {
  outline: none;
}

.input-search::placeholder {
  color: var(--text-muted);
}

.search-clear {
  position: absolute;
  right: 2px;
  top: 2px;
  bottom: 2px;
  z-index: 2;
  width: 32px;
  box-sizing: border-box;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  border-radius: 0 calc(var(--radius-sm) - 1px) calc(var(--radius-sm) - 1px) 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

.search-clear:hover {
  color: var(--accent-primary);
  background: var(--accent-glow);
}

.search-clear:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent-primary);
}

.toolbar-filter-select {
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.toolbar-filter-select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* ── Card ───────────────────────────────────────── */

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* ── Table ──────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  animation: viewFadeIn 0.35s ease;
}

.table-wrap .data-table tbody tr {
  animation: rowSlideIn 0.4s cubic-bezier(0.25, 1, 0.5, 1) both;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table thead th {
  background: var(--bg-tertiary);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 500;
  padding: 14px 20px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 2;
}

.data-table tbody td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background 0.15s ease;
}

.data-table tbody tr:hover {
  background: var(--accent-glow);
}

.data-table tbody tr.selected {
  background: rgba(227, 6, 19, 0.08);
  box-shadow: inset 3px 0 0 var(--accent-primary);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.cell-gtin {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--accent-primary);
}

.cell-gln {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.cell-gpc {
  font-size: 0.8rem;
  white-space: nowrap;
}

.gpc-code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.gpc-name {
  font-size: 0.8rem;
  color: var(--text-primary);
  white-space: normal;
}

.cell-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.cell-market {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  white-space: nowrap;
}

.cell-descriptor {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.cell-brand {
  font-weight: 500;
}

.cell-rownum {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: right;
  width: 40px;
}

/* ── Grid / Tile View ──────────────────────────── */

.grid-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 20px;
  animation: viewFadeIn 0.35s ease;
}

.tile {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  animation: tilePopIn 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.tile:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.tile.selected {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-glow-strong);
}

.tile-img-wrap {
  height: 180px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border-subtle);
  overflow: hidden;
  position: relative;
}

.tile-img-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.tile-img-overlay-stack {
  position: absolute;
  bottom: 6px;
  right: 6px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-width: calc(100% - 12px);
  pointer-events: none;
}

.tile-img-overlay-stack .tile-hierarchy-btn {
  pointer-events: auto;
  flex-shrink: 0;
}

.tile-descriptor-overlay {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  padding: 2px 6px;
  line-height: 1.3;
  pointer-events: none;
}

.tile-placeholder {
  color: var(--text-muted);
  opacity: 0.35;
}

.tile-no-image {
  position: absolute;
  bottom: 28px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.65rem;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  opacity: 0.6;
}

.tile-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

/* ── Favorites ──────────────────────────────────── */

.fav-star {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--border-color);
  transition: color 0.15s, transform 0.15s;
  padding: 0;
  line-height: 1;
}

.fav-star:hover {
  transform: scale(1.25);
}

.fav-star.fav-active {
  color: #f0a500;
}

.tile > .fav-star {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  font-size: 1.2rem;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}

.tile {
  position: relative;
}

.fav-star-row {
  font-size: 0.95rem;
}

.fav-star-modal {
  font-size: 1.3rem;
}

/* Narrow control columns: same width + centering as thead (see `.data-table thead th.th-*`) */
.data-table tbody td.cell-check,
.data-table tbody td.cell-fav {
  width: 28px;
  max-width: 28px;
  text-align: center;
  padding: 0 4px !important;
  vertical-align: middle;
}

/* Must beat `.data-table thead th { text-align: left }` so bulk controls line up with body cells */
.data-table thead th.th-check,
.data-table thead th.th-fav {
  width: 28px;
  max-width: 28px;
  padding: 0 4px !important;
  vertical-align: middle;
  text-align: center;
  letter-spacing: normal;
  font-size: inherit;
}

.data-table thead th.th-check .hit-list-check-all,
.data-table thead th.th-fav .hit-list-fav-bulk {
  vertical-align: middle;
}

.item-checkbox {
  cursor: pointer;
  accent-color: var(--accent-primary);
}

.tile-corner-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
}

.tile-hierarchy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-secondary);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.tile-hierarchy-btn:hover {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  background: var(--bg-secondary);
}

.tile-checkbox {
  position: static;
  width: 16px;
  height: 16px;
  margin: 0;
}


.btn-fav-active {
  background: rgba(40, 167, 69, 0.14) !important;
  border-color: #28a745 !important;
  color: #28a745 !important;
}

.input-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.search-box:has(.input-search.input-disabled) {
  opacity: 0.45;
  pointer-events: none;
}

.tile-pk {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-pk .tile-gtin {
  color: var(--accent-primary);
  font-weight: 500;
}

.tile-desc {
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile-brand {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.tile-provider {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.btn-toggle-active {
  background: var(--accent-glow) !important;
  border-color: var(--accent-primary) !important;
  color: var(--accent-primary) !important;
}

/* ── Empty State ────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  text-align: center;
  gap: 12px;
}

.empty-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.empty-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Loading Skeleton ───────────────────────────── */

.skeleton-row td {
  position: relative;
  overflow: hidden;
}

.skeleton-bar {
  height: 14px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  position: relative;
  overflow: hidden;
}

.skeleton-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ── Toast Notifications ────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 14px 20px;
  font-size: 0.85rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 420px;
  animation: slideInUp 0.3s ease;
  border-left: 4px solid var(--border-color);
}

.toast.toast-error {
  border-left-color: var(--error);
}

.toast.toast-success {
  border-left-color: var(--success);
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideOutDown {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(16px);
  }
}

/* ── Image lightbox (overview hero & grid) ─────── */

body.image-lightbox-open {
  overflow: hidden;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  box-sizing: border-box;
  background: rgba(8, 10, 14, 0.92);
  backdrop-filter: blur(6px);
  animation: imageLightboxFadeIn 0.28s ease both;
}

.image-lightbox.hidden {
  display: none !important;
}

@keyframes imageLightboxFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.image-lightbox-close {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 2001;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.image-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(1.06);
}

.image-lightbox-inner {
  position: relative;
  max-width: min(96vw, 1680px);
  max-height: min(90vh, 1200px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-lightbox-inner img {
  display: block;
  max-width: 100%;
  max-height: min(88vh, 1180px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.55);
  cursor: default;
  animation: imageLightboxImgIn 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes imageLightboxImgIn {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .image-lightbox {
    animation: none;
  }

  .image-lightbox-inner img {
    animation: none;
  }
}

/* ── Detail Modal ───────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
  width: 100%;
  max-width: calc(100vw - 64px);
  height: 92vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-tabs {
  display: flex;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 20px;
  gap: 0;
}

.modal-tab {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 10px 20px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  margin-bottom: -1px;
}

.modal-tab:hover {
  color: var(--text-primary);
}

.modal-tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.modal-tab-pane {
  padding: 0;
}

.modal-tab-pane--raw {
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.raw-json-view {
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.5;
  tab-size: 2;
  color: var(--text-primary);
  word-break: normal;
  overflow-wrap: normal;
}

.raw-json-root {
  min-width: min-content;
}

.modal-tab-pane--raw .json-fold {
  display: block;
  margin: 0;
}

.modal-tab-pane--raw .json-fold-summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.modal-tab-pane--raw .json-fold-summary::-webkit-details-marker {
  display: none;
}

.modal-tab-pane--raw .json-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.125rem;
  height: 1.125rem;
  color: var(--text-muted);
}

.modal-tab-pane--raw .json-caret-icon {
  display: block;
  transition: transform 0.15s ease;
  transform: rotate(0deg);
}

.modal-tab-pane--raw .json-fold[open] > .json-fold-summary .json-caret-icon {
  transform: rotate(90deg);
}

.modal-tab-pane--raw .json-fold[open] > .json-fold-summary .json-sum-collapsed {
  display: none;
}

.modal-tab-pane--raw .json-fold:not([open]) > .json-fold-summary .json-sum-open {
  display: none;
}

.modal-tab-pane--raw .json-meta {
  color: var(--text-muted);
  font-weight: 400;
}

.modal-tab-pane--raw .json-fold-body {
  padding-inline-start: 1rem;
  border-inline-start: 1px solid var(--border-color);
  margin-block: 2px 0;
}

.modal-tab-pane--raw .json-line {
  margin: 0;
  padding: 0;
}

.modal-tab-pane--raw .json-fold-close {
  padding-inline-start: 0;
  margin-top: 0;
  color: var(--text-secondary);
}

.modal-tab-pane--raw .json-key {
  color: var(--accent-secondary);
  font-weight: 500;
}

.modal-tab-pane--raw .json-colon {
  margin-right: 0.35em;
}

.modal-tab-pane--raw .json-str {
  color: #0d8050;
}

.modal-tab-pane--raw .json-lit--num {
  color: #1a6cb3;
}

.modal-tab-pane--raw .json-lit--bool,
.modal-tab-pane--raw .json-lit--null {
  color: var(--accent-primary);
  font-weight: 500;
}

.modal-tab-pane--raw .json-inline {
  color: var(--text-secondary);
}

.modal-tab-pane--hierarchy {
  padding: 0;
  min-width: 0;
  --hier-trunk: 1.625rem;
  --hier-stub: 0.875rem;
  --hier-gap-under-hbar: 1rem;
  /* All hierarchy cards share one footprint (root + every level). */
  --hier-box-width: 268px;
  --hier-box-min-height: 208px;
  /* Space between sibling columns (flex gap; avoids overlap from padding inside a fixed-width column). */
  --hier-branch-gap: 20px;
}

.hierarchy-tab-inner {
  padding: 16px 20px 24px;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  /* Single horizontal scrollport so wide trees get full scroll range (avoid nested
     overflow + flex justify center clipping the start of the content). */
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
}

.hierarchy-tab-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.hierarchy-tab-toolbar--with-lazy {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

.hierarchy-tab-toolbar__columns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
}

.hierarchy-tab-toolbar__col {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  min-width: 0;
}

.hierarchy-lazy-phase-banner--toolbar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  max-width: min(100%, 28rem);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
}

.hierarchy-lazy-phase-banner--toolbar.hierarchy-lazy-phase-banner--one-line {
  flex-direction: row;
  align-items: center;
  padding: 0;
  gap: 0;
  max-width: none;
  flex: 1 1 12rem;
  min-width: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.hierarchy-lazy-one-line {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

.hierarchy-lazy-one-line strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Full-width fallback when no mode button is shown but lazy progress still applies */
.hierarchy-tab-toolbar--with-lazy > .hierarchy-lazy-phase-banner--toolbar {
  margin-top: 10px;
  max-width: none;
}

.hierarchy--lazy-phase .hier-skeleton-scope {
  margin-top: 0.25rem;
}

.hier-skeleton-scope-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.hier-skeleton-scope-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.modal-tab-pane--hierarchy .hier-box--skeleton {
  opacity: 0.95;
  border-style: dashed;
}

.modal-tab-pane--hierarchy .hier-box--skeleton .hier-desc {
  color: var(--text-muted);
  font-style: italic;
}

/* Must chain .hierarchy.hierarchy--multi-root so this wins over the later
   .modal-tab-pane--hierarchy .hierarchy { display: block } rule (same specificity). */
.modal-tab-pane--hierarchy .hierarchy.hierarchy--multi-root {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 1.5rem 2rem;
}

.modal-tab-pane--hierarchy .hierarchy.hierarchy--multi-root .hier-root-block {
  flex: 0 1 auto;
  width: max-content;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* Root .hier-node uses min-width:100% for single-tree centering; that resolves against
   the wide .hierarchy box and forces each multi-root column to full width — undo for roots. */
.modal-tab-pane--hierarchy .hierarchy.hierarchy--multi-root .hier-root-block > .hier-node {
  min-width: 0;
}

/* ── Hierarchy tab: tree reveal FX (connectors stay default gray borders) ─ */
@keyframes hierBoxReveal {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
    filter: blur(5px);
    box-shadow: 0 0 0 0 transparent;
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
    box-shadow: var(--shadow-sm);
  }
}

@keyframes hierBranchReveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes hierQtyReveal {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-tab-pane--hierarchy .hierarchy--fx .hier-box {
  animation: hierBoxReveal 0.62s cubic-bezier(0.22, 1, 0.32, 1) backwards;
  animation-delay: calc(var(--hier-depth, 0) * 0.07s + var(--hier-sib, 0) * 0.038s);
}

.modal-tab-pane--hierarchy .hierarchy--fx .hier-branch {
  animation: hierBranchReveal 0.52s cubic-bezier(0.25, 1, 0.5, 1) backwards;
  animation-delay: calc((var(--hier-depth, 1) - 1) * 0.06s + var(--hier-sib, 0) * 0.035s);
}

.modal-tab-pane--hierarchy .hierarchy--fx .hier-qty {
  animation: hierQtyReveal 0.45s cubic-bezier(0.34, 1.2, 0.64, 1) backwards;
  animation-delay: calc(var(--hier-depth, 1) * 0.07s + var(--hier-sib, 0) * 0.04s + 0.08s);
}

@media (prefers-reduced-motion: reduce) {
  .modal-tab-pane--hierarchy .hierarchy--fx .hier-box,
  .modal-tab-pane--hierarchy .hierarchy--fx .hier-branch,
  .modal-tab-pane--hierarchy .hierarchy--fx .hier-qty {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
}

.hierarchy-tab-empty,
.hierarchy-tab-error {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.hierarchy-tab-error {
  color: var(--error);
}

/* Trade item hierarchy graph (layout adapted from GDSN_CinVisualizer hierarchy.js) */
.modal-tab-pane--hierarchy .hierarchy {
  padding: 12px 8px 20px;
  box-sizing: border-box;
  /* Wide as the tree needs; parent .hierarchy-tab-inner scrolls horizontally.
     Do not use justify-content: center on a row flex here — it offsets wide content
     and horizontal scrollLeft=0 no longer aligns with the true left edge. */
  display: block;
  overflow-x: visible;
  width: max-content;
  min-width: 100%;
}

.modal-tab-pane--hierarchy .hier-node {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: max-content;
  min-width: 100%;
  box-sizing: border-box;
}

.modal-tab-pane--hierarchy .hier-branch > .hier-node {
  flex-shrink: 0;
}

.modal-tab-pane--hierarchy .hier-children {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: var(--hier-branch-gap);
  padding-top: var(--hier-trunk);
  position: relative;
  overflow: visible;
  width: max-content;
  min-width: 100%;
  box-sizing: border-box;
}

.modal-tab-pane--hierarchy .hier-children.multi {
  align-items: stretch;
}

/* Trunk: parent centerline down through stub zone to the horizontal junction (multi)
   or through to the gap above the child (single). */
.modal-tab-pane--hierarchy .hier-children::before {
  content: '';
  position: absolute;
  z-index: 0;
  top: 0;
  height: calc(var(--hier-trunk) + var(--hier-stub));
  border-left: 2px solid var(--border-color);
  left: 50%;
  transform: translateX(-50%);
  box-sizing: border-box;
}

.modal-tab-pane--hierarchy .hier-children:not(.multi)::before {
  height: calc(var(--hier-trunk) + var(--hier-stub) + var(--hier-gap-under-hbar));
}

/*
 * Each branch column must be as wide as its subtree (box + lower rows), not a fixed
 * card width — otherwise nested .hier-children rows are wider than the column and
 * overlap sibling branches. flex-basis auto + min-width keeps cards ≥ card width.
 */
.modal-tab-pane--hierarchy .hier-children > .hier-branch {
  flex: 0 0 auto;
  min-width: var(--hier-box-width);
  width: max-content;
  max-width: none;
  box-sizing: border-box;
}

.modal-tab-pane--hierarchy .hier-branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  /* No horizontal padding: subtree width comes from content; gap is on .hier-children. */
  padding: 0;
  overflow: visible;
}

/*
 * Horizontal connector: one segment per branch. Flex gap leaves empty space between
 * columns — extend each segment by half the gap so lines meet in the middle of each gap.
 */
.modal-tab-pane--hierarchy .hier-children.multi > .hier-branch::after {
  content: '';
  position: absolute;
  z-index: 0;
  top: var(--hier-stub);
  height: 0;
  border-top: 2px solid var(--border-color);
  pointer-events: none;
  box-sizing: border-box;
}

.modal-tab-pane--hierarchy .hier-children.multi > .hier-branch:not(:first-child):not(:last-child)::after {
  left: calc(var(--hier-branch-gap) / -2);
  right: calc(var(--hier-branch-gap) / -2);
}

.modal-tab-pane--hierarchy .hier-children.multi > .hier-branch:first-child:not(:last-child)::after {
  left: 50%;
  right: calc(var(--hier-branch-gap) / -2);
}

.modal-tab-pane--hierarchy .hier-children.multi > .hier-branch:last-child:not(:first-child)::after {
  left: calc(var(--hier-branch-gap) / -2);
  right: 50%;
}

/* Vertical from horizontal bar down to qty / node (column center = branch center). */
.modal-tab-pane--hierarchy .hier-children.multi > .hier-branch::before {
  content: '';
  position: absolute;
  z-index: 0;
  top: calc(var(--hier-stub) + 2px);
  left: 50%;
  height: var(--hier-gap-under-hbar);
  border-left: 2px solid var(--border-color);
  transform: translateX(-50%);
  box-sizing: border-box;
}

.modal-tab-pane--hierarchy .hier-children:not(.multi) > .hier-branch::before {
  display: none;
}

.modal-tab-pane--hierarchy .hier-box {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  background: var(--bg-secondary);
  box-sizing: border-box;
  width: var(--hier-box-width);
  min-width: var(--hier-box-width);
  max-width: var(--hier-box-width);
  min-height: var(--hier-box-min-height);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 1;
  transition: all 0.2s ease;
}

.modal-tab-pane--hierarchy .hier-box[data-hierarchy-pk] {
  cursor: pointer;
}

.modal-tab-pane--hierarchy .hier-box[data-hierarchy-pk]:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent-primary);
}

.modal-tab-pane--hierarchy .hier-box--root[data-hierarchy-pk] {
  background: var(--bg-tertiary);
}

.modal-tab-pane--hierarchy .hier-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 56px;
  min-height: 56px;
  flex-shrink: 0;
  margin: 0 auto 8px;
}

.modal-tab-pane--hierarchy .hier-thumb-img {
  display: block;
  max-width: 72px;
  max-height: 52px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
}

.modal-tab-pane--hierarchy .hier-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.modal-tab-pane--hierarchy .hier-thumb-placeholder.hidden {
  display: none;
}

.modal-tab-pane--hierarchy .hier-thumb-placeholder svg.tile-placeholder {
  width: 48px;
  height: 48px;
  max-width: 100%;
  opacity: 0.45;
}

.modal-tab-pane--hierarchy .hier-box .hier-unit {
  display: inline-block;
  align-self: center;
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}

.modal-tab-pane--hierarchy .unit-DISPLAY_SHIPPER {
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #c4b5fd;
}

.modal-tab-pane--hierarchy .unit-PALLET {
  background: #fce7f3;
  color: #9d174d;
  border: 1px solid #f9a8d4;
}

.modal-tab-pane--hierarchy .unit-CASE {
  background: rgba(227, 6, 19, 0.08);
  color: var(--accent-primary);
  border: 1px solid rgba(227, 6, 19, 0.2);
}

.modal-tab-pane--hierarchy .unit-PACK_OR_INNER_PACK {
  background: rgba(0, 166, 125, 0.08);
  color: var(--success);
  border: 1px solid rgba(0, 166, 125, 0.2);
}

.modal-tab-pane--hierarchy .unit-BASE_UNIT_OR_EACH {
  background: rgba(230, 148, 10, 0.1);
  color: var(--warning);
  border: 1px solid rgba(230, 148, 10, 0.25);
}

.modal-tab-pane--hierarchy .unit-default {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.modal-tab-pane--hierarchy .hier-box .hier-gtin {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 2px 0;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}

.modal-tab-pane--hierarchy .hier-box .hier-desc {
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 4px;
  flex: 1;
  min-height: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
}

.modal-tab-pane--hierarchy .hier-meta-count {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 6px;
  flex-shrink: 0;
}

.modal-tab-pane--hierarchy .hier-muted {
  color: var(--text-muted);
}

.modal-tab-pane--hierarchy .hier-err {
  font-size: 0.72rem;
  color: var(--error);
  margin-top: 6px;
  flex-shrink: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.modal-tab-pane--hierarchy .hier-branch > .hier-qty {
  margin-top: calc(var(--hier-stub) + var(--hier-gap-under-hbar));
}

.modal-tab-pane--hierarchy .hier-branch > .hier-node:first-child {
  margin-top: calc(var(--hier-stub) + var(--hier-gap-under-hbar));
}

.modal-tab-pane--hierarchy .hier-branch > .hier-qty + .hier-node {
  margin-top: 0;
}

.modal-tab-pane--hierarchy .hier-qty {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 10px;
  padding: 1px 8px;
  position: relative;
  z-index: 2;
  margin-bottom: 0.35rem;
  flex-shrink: 0;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  white-space: nowrap;
}

.modal-subtitle {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--accent-glow);
  color: var(--accent-primary);
}

.modal-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  position: relative;
}

.modal-body > .modal-tab-pane:not(.hidden) {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-body > .modal-error:not(.hidden) {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.modal-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(2px);
  z-index: 5;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.modal-error {
  padding: 40px 24px;
  text-align: center;
  color: var(--error);
  font-size: 0.85rem;
}

/* ── Overview Tab ──────────────────────────────── */

.overview {
  --overview-img-size: 320px;
  padding: 28px 32px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 28px;
}

.overview-top-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.overview-carousel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.overview-img-area {
  width: var(--overview-img-size);
  height: var(--overview-img-size);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.overview-img-area img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: zoom-in;
}

@media (max-width: 640px) {
  .overview {
    --overview-img-size: min(280px, 72vw);
  }
}

.carousel-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.carousel-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  padding: 0;
}

.carousel-btn:hover:not(:disabled) {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.carousel-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.carousel-btn--grid {
  flex-shrink: 0;
}

.carousel-btn-grid-icon {
  display: block;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.carousel-btn--grid.is-expanded .carousel-btn-grid-icon {
  transform: rotate(180deg) scale(1.06);
}

.carousel-counter {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.overview-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.overview-section-text {
  font-size: 0.82rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.overview-nutrients {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin-top: 4px;
}

.overview-nutrients td {
  padding: 4px 10px 4px 0;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.overview-nutrients td:first-child {
  color: var(--text-secondary);
  font-weight: 500;
}

.overview-nutrients td:last-child {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-align: right;
}

.overview-group {
  padding: 14px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.overview-group:first-child {
  padding-top: 0;
}

.overview-group:last-child {
  border-bottom: none;
}

.overview-group-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 10px;
}

.overview-desc {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

.overview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.overview-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.overview-meta-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 500;
}

.overview-meta-value {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-primary);
}

.overview-descriptor-badge {
  text-align: center;
  margin-top: 8px;
}

.overview-hierarchy-link {
  text-align: left;
  margin-top: 8px;
}

.overview-child-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.overview-child-pk {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent-primary);
  margin: 2px 0;
}

.overview-child-pk:hover {
  text-decoration: underline;
}

.overview-back-link {
  text-align: left;
  margin-top: 10px;
}

.overview-back-btn {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.overview-back-btn:hover {
  color: var(--accent-primary);
  background: var(--bg-tertiary);
}

.overview-badge {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px 10px;
}

.overview-images-expanded {
  grid-column: 1 / -1;
  overflow: hidden;
  border-top: 1px solid transparent;
  transition:
    max-height 0.45s cubic-bezier(0.22, 1, 0.32, 1),
    opacity 0.32s ease,
    margin 0.35s ease,
    padding 0.35s ease,
    border-color 0.3s ease;
}

.overview-images-expanded:not(.is-open) {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  padding-top: 0;
  border-top-color: transparent;
  pointer-events: none;
}

.overview-images-expanded.is-open {
  max-height: 4800px;
  opacity: 1;
  margin-top: 8px;
  padding-top: 22px;
  border-top-color: var(--border-subtle);
  pointer-events: auto;
}

.overview-images-expanded .overview-images-grid {
  transition:
    opacity 0.3s ease,
    transform 0.4s cubic-bezier(0.22, 1, 0.32, 1),
    filter 0.35s ease;
}

.overview-images-expanded:not(.is-open) .overview-images-grid {
  opacity: 0;
  transform: translateY(-14px) scale(0.98);
  filter: blur(8px);
}

.overview-images-expanded.is-open .overview-images-grid {
  opacity: 1;
  transform: none;
  filter: none;
}

.overview-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 14px;
}

.overview-img-tile {
  --overview-tile-i: 0;
}

.overview-img-tile-inner {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: linear-gradient(155deg, var(--bg-tertiary) 0%, var(--bg-secondary) 48%, rgba(227, 6, 19, 0.04) 100%);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.28s ease, border-color 0.2s ease;
}

.overview-img-tile:hover .overview-img-tile-inner {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: rgba(227, 6, 19, 0.25);
}

.overview-img-tile img {
  display: block;
  width: 100%;
  height: 152px;
  object-fit: contain;
  padding: 10px;
  box-sizing: border-box;
  cursor: zoom-in;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.overview-img-tile:hover img {
  transform: scale(1.06);
}

@keyframes overviewTileReveal {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.92);
    filter: blur(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

.overview-images-expanded.is-open .overview-img-tile {
  animation: overviewTileReveal 0.55s cubic-bezier(0.22, 1, 0.32, 1) backwards;
  animation-delay: calc(var(--overview-tile-i, 0) * 50ms);
}

@media (prefers-reduced-motion: reduce) {
  .carousel-btn-grid-icon,
  .overview-img-tile-inner,
  .overview-img-tile img {
    transition: none !important;
  }

  .overview-images-expanded {
    transition: none !important;
  }

  .overview-images-expanded .overview-images-grid {
    transition: none !important;
  }

  .overview-images-expanded.is-open .overview-img-tile {
    animation: none !important;
  }

  .carousel-btn--grid.is-expanded .carousel-btn-grid-icon {
    transform: none;
  }
}

/* ── Attribute Groups ───────────────────────────── */

.attr-group {
  border-bottom: 1px solid var(--border-color);
  animation: groupFadeIn 0.35s ease both;
}

@keyframes groupFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.attr-group:last-child {
  border-bottom: none;
}

.attr-group-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  background: var(--bg-tertiary);
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-color);
  border-top: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1;
}

.attr-group-header__title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-primary);
}

.attr-group:first-child .attr-group-header {
  border-top: none;
}

.attr-hierarchy-link-missing {
  margin: 0;
  padding: 0;
  max-width: 100%;
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.45;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text-muted);
}

/* Top of Hierarchy tab when hierarchyLink is absent, unless "Show Complete Hierarchy" is shown (see app.js). */
.hierarchy-missing-hint {
  margin: 0 0 10px;
  padding: 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--text-muted);
}

/* ── Object with inline image ───────────────────── */

.obj-with-img {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
  width: 100%;
}

.attr-nested li > div {
  flex: 1;
  min-width: 0;
}

.obj-img-link {
  display: block;
}

.obj-img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.obj-img:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-md);
}

/* ── Pretty-Print Attribute Table ───────────────── */

.attr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  table-layout: fixed;
}

.attr-table tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.15s ease;
}

.attr-table tr:last-child {
  border-bottom: none;
}

.attr-table tr:hover {
  background: var(--accent-glow);
}

.attr-key {
  padding: 10px 20px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  vertical-align: top;
  width: 300px;
  min-width: 300px;
  max-width: 300px;
  background: var(--bg-tertiary);
  border-right: 1px solid var(--border-subtle);
  overflow: hidden;
  text-overflow: ellipsis;
}

.attr-val {
  padding: 10px 20px;
  color: var(--text-primary);
  word-break: break-word;
  vertical-align: top;
}

.attr-val-string {
  color: var(--text-primary);
}

.attr-val-number {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #0969da;
}

.attr-val-bool {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
}

.attr-val-bool.val-true {
  color: var(--success);
}

.attr-val-bool.val-false {
  color: var(--text-muted);
}

.attr-val-null {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-muted);
}

.attr-nested {
  margin: 0;
  padding: 0;
  list-style: none;
}

.attr-nested li {
  padding: 3px 0;
  display: flex;
  gap: 8px;
}

.attr-nested-key {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.attr-nested-key::after {
  content: ':';
}

.attr-link {
  color: var(--accent-primary);
  text-decoration: none;
  word-break: break-all;
  font-size: 0.78rem;
}

.attr-link:hover {
  text-decoration: underline;
}

/* ── View Transition Animations ────────────────── */

@keyframes viewFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes tilePopIn {
  0% {
    opacity: 0;
    transform: scale(0.5) translateY(40px) rotate(-3deg);
    filter: blur(4px);
  }
  60% {
    opacity: 1;
    transform: scale(1.05) translateY(-4px) rotate(0.5deg);
    filter: blur(0);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0) rotate(0);
    filter: blur(0);
  }
}

@keyframes rowSlideIn {
  0% {
    opacity: 0;
    transform: translateX(-40px) scaleX(0.9);
  }
  70% {
    opacity: 1;
    transform: translateX(4px) scaleX(1.01);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scaleX(1);
  }
}

/* ── Split View ─────────────────────────────────── */

.split-wrap {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: calc(100vh - 180px);
  animation: splitReveal 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.split-list {
  min-height: 0;
  overflow-y: auto;
  position: relative;
  background: var(--bg-secondary);
}

.split-list::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 6px;
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.06));
  pointer-events: none;
  z-index: 1;
}

.split-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
  animation: splitRowSlideIn 0.4s cubic-bezier(0.25, 1, 0.5, 1) both;
  position: relative;
}

.split-row:hover {
  background: var(--accent-glow);
  transform: translateX(2px);
}

.split-row.selected {
  background: linear-gradient(90deg, rgba(227, 6, 19, 0.1), rgba(227, 6, 19, 0.03));
  box-shadow: inset 3px 0 0 var(--accent-primary);
}

.split-row.selected .split-gtin {
  font-weight: 600;
}

.split-row-info {
  flex: 1;
  min-width: 0;
}

.split-row-pk {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.split-row-pk .split-gtin {
  color: var(--accent-primary);
  font-weight: 500;
  transition: font-weight 0.15s;
}

.split-row-desc {
  font-size: 0.8rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.split-row-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 2px;
}

.split-row-descriptor {
  font-size: 0.6rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 1px 5px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.split-row-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.split-detail {
  overflow-y: auto;
  position: relative;
  background: var(--bg-primary);
}

.split-detail > .overview {
  animation: splitDetailFadeIn 0.35s ease both;
}

.split-detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
  animation: splitDetailFadeIn 0.4s ease both;
}

.split-detail-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
  animation: splitDetailFadeIn 0.25s ease both;
}

@keyframes splitReveal {
  0% {
    opacity: 0;
    grid-template-columns: 0px 1fr;
  }
  50% {
    opacity: 1;
    grid-template-columns: 340px 1fr;
  }
  100% {
    opacity: 1;
    grid-template-columns: 340px 1fr;
  }
}

@keyframes splitRowSlideIn {
  0% {
    opacity: 0;
    transform: translateX(-24px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes splitDetailFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Login Dialog ──────────────────────────────── */

.login-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-backdrop.hidden {
  display: none !important;
}

.login-dialog {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
  padding: 40px 36px 36px;
  width: 100%;
  max-width: 380px;
  animation: loginSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.login-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.login-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.login-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.login-field {
  margin-bottom: 16px;
}

.login-field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.login-field input {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-field input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-error {
  font-size: 0.8rem;
  color: var(--error);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(220, 53, 69, 0.08);
  margin-bottom: 16px;
}

.login-submit {
  width: 100%;
  padding: 12px;
  font-size: 0.9rem;
  margin-top: 4px;
}

@keyframes loginSlideIn {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Utility ────────────────────────────────────── */

.hidden {
  display: none !important;
}

/* ── Responsive ─────────────────────────────────── */

@media (max-width: 1024px) {
  .search-box {
    width: 220px;
  }
}

@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-box {
    width: 100%;
  }

  .toolbar-left {
    width: 100%;
  }
}

/* ── Company Index Dialog ─────────────────────── */

.ci-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.ci-dialog {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
  width: 100%;
  max-width: 820px;
  height: 80vh;
  display: flex;
  flex-direction: column;
  animation: loginSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.ci-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.ci-header h2 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.ci-status {
  flex: 1;
  text-align: right;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.ci-status .spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  vertical-align: -2px;
  margin-right: 4px;
}

.ci-tabs {
  display: flex;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 20px;
  gap: 0;
}

.ci-tab {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 10px 20px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  margin-bottom: -1px;
}

.ci-tab:hover {
  color: var(--text-primary);
}

.ci-tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.ci-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.ci-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.ci-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-tertiary);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 500;
  padding: 10px 16px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-color);
}

.ci-refresh-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 3px 5px;
  margin-left: 4px;
  vertical-align: -2px;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s, border-color 0.15s;
}

.ci-refresh-btn:hover {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.ci-sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}

.ci-sortable:hover {
  color: var(--accent-primary);
}

.ci-table tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.ci-table tbody tr {
  transition: background 0.15s;
}

.ci-table tbody tr:hover {
  background: var(--accent-glow);
}

.ci-company-name {
  font-weight: 500;
  color: var(--text-primary);
}

.ci-gln {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent-primary);
  cursor: pointer;
  transition: text-decoration 0.15s;
}

.ci-gln:hover {
  text-decoration: underline;
}

.ci-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ci-breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 1px 0;
  font-size: 0.75rem;
  line-height: 1.4;
}

.ci-breakdown-label {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ci-breakdown-count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-primary);
  font-weight: 500;
  flex-shrink: 0;
  text-align: right;
  min-width: 28px;
}

.ci-total {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-primary);
  font-weight: 500;
}

.ci-gpc-code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent-primary);
  cursor: pointer;
  transition: text-decoration 0.15s;
}

.ci-gpc-code:hover {
  text-decoration: underline;
}

.ci-pg-summary {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.ci-pg-category {
  border-bottom: 1px solid var(--border-color);
}

.ci-pg-category:last-child {
  border-bottom: none;
}

.ci-pg-category-header {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-primary);
  background: var(--bg-tertiary);
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 1;
  cursor: pointer;
  user-select: none;
}
.ci-pg-category-header:hover {
  background: var(--bg-secondary);
}

.ci-pg-chevron {
  display: inline-block;
  width: 12px;
  margin-right: 6px;
  transition: transform 0.2s;
}
.ci-pg-chevron::before {
  content: "▸";
}
.ci-pg-category.open > .ci-pg-category-header .ci-pg-chevron {
  transform: rotate(90deg);
}

.ci-pg-category-body {
  display: none;
}
.ci-pg-category.open > .ci-pg-category-body {
  display: block;
}

.ci-pg-category-count {
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: normal;
  text-transform: none;
}

.ci-pg-family-header {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 16px 2px;
  margin-top: 4px;
}

.ci-table-grouped {
  margin: 0;
  table-layout: fixed;
}
.ci-table-grouped td:first-child {
  width: 100px;
}
.ci-table-grouped td:last-child {
  width: 60px;
}

.ci-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Product Index — Overview bar charts */
.ci-overview {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  padding: 16px 20px 24px;
  max-width: 900px;
  margin: 0 auto;
}

@media (min-width: 880px) {
  .ci-overview {
    grid-template-columns: 1fr 1fr;
    gap: 24px 32px;
    align-items: start;
  }
}

.ci-chart-panel {
  min-width: 0;
}

.ci-chart-title {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.ci-chart-sub {
  margin: 0 0 14px;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.ci-chart-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ci-bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(80px, 2fr) 3.5rem;
  align-items: center;
  gap: 10px 12px;
  font-size: 0.8rem;
}

.ci-bar-row--click {
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  margin: -4px -6px;
  transition: background 0.12s ease;
}

.ci-bar-row--click:hover {
  background: var(--bg-tertiary);
}

.ci-bar-label {
  min-width: 0;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ci-bar-track {
  height: 10px;
  border-radius: 5px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.ci-bar-fill {
  height: 100%;
  border-radius: 4px;
  min-width: 2px;
  transition: width 0.35s ease;
}

.ci-bar-fill--supplier {
  background: linear-gradient(90deg, var(--accent-primary), #ff6b6b);
}

.ci-bar-fill--gpc {
  background: linear-gradient(90deg, #3d7ea6, #5cb3d9);
}

.ci-bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.78rem;
}

.ci-chart-empty {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}
