.lab {
  container: inventory / inline-size;
  inline-size: 100%;
  box-sizing: border-box;
  min-inline-size: 0;
  color: var(--rl-text);
  background: var(--rl-surface);
  border: 1px solid var(--rl-line);
  border-radius: 22px;
  overflow: clip;
  font-family: var(--rl-font);
  box-shadow: var(--rl-shadow);
}

.lab-header, .lab-breadcrumb, .lab-live, .lab-heading, .lab-toolbar, .lab-product, .lab-footer, .lab-footer > span:last-child {
  display: flex;
  align-items: center;
}

.lab-header {
  justify-content: space-between;
  border-bottom: 1px solid var(--rl-line);
  padding: 12px 18px;
  gap: 12px;
  font-size: 13px;
  color: var(--rl-muted);
}

.lab-breadcrumb { gap: 9px; }
.lab-breadcrumb span:last-child { color: var(--rl-text); font-weight: 550; }
.lab-workspace {
  display: grid;
  place-items: center;
  width: 22px;
  aspect-ratio: 1;
  border-radius: 7px;
  background: var(--rl-raised);
  color: var(--rl-text);
  font-weight: 700;
  font-size: 11px;
}
.lab-slash { color: var(--rl-muted); }
.lab-live { gap: 7px; white-space: nowrap; font-size: 11px; }
.lab-live i, .lab-footer i {
  display: inline-block;
  width: 6px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #22a575;
  box-shadow: 0 0 0 3px #22a57522;
}

.lab-body { padding: clamp(14px, 3vw, 25px); }
.lab-heading { justify-content: space-between; gap: 10px; }
.lab-heading h2 { margin: 0; color: var(--rl-text); font-size: clamp(1.35rem, 2.5vw, 1.75rem); letter-spacing: -.05em; line-height: 1.1; font-weight: 650; }
.lab-heading p { margin: 5px 0 0; color: var(--rl-muted); font-size: 13px; }
.rl-button.lab-add { background: var(--rl-primary); color: var(--rl-primary-ink); border: 0; min-height: 36px; font-weight: 600; border-radius: 999px; padding: 6px 13px; font-size: 12px; white-space: nowrap; gap: 6px; }
.rl-button.lab-add:hover { background: color-mix(in srgb, var(--rl-primary), var(--rl-primary-ink) 16%); }

.lab-toolbar { margin: 18px 0 12px; gap: 8px; }
.lab-search, .lab-filter {
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid var(--rl-line);
  border-radius: 11px;
  background: var(--rl-raised);
  color: var(--rl-muted);
  min-height: 36px;
  font-size: 13px;
}
.lab-search { flex: 1 1 auto; gap: 9px; padding: 0 10px; min-width: 0; }
.lab-search:focus-within, .lab-filter:focus-within { outline: 2px solid var(--rl-accent); outline-offset: 1px; }
.lab-search input, .lab-filter select { outline: 0; background-color: transparent; border: 0; color: var(--rl-text); font: inherit; min-height: 34px; min-width: 0; }
.lab-search input { width: 100%; padding: 0; }
.lab-search input::placeholder { color: var(--rl-muted); }
.lab-filter select { width: auto; max-width: 100%; padding-block: 0; padding-inline-start: .65rem; }

.lab-table-wrap { border: 1px solid var(--rl-line); border-radius: 13px; overflow: auto; }
.lab-table { font-size: 13px; min-width: 337px; background: transparent; }
.lab-table :is(th, td) { padding: 8px 10px; border-bottom: 1px solid var(--rl-line); text-align: start; color: var(--rl-muted); }
.lab-table thead th { background: var(--rl-raised); color: var(--rl-muted); font-size: 11px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.lab-table tbody th { background: transparent; }
.lab-table tbody tr:last-child > * { border-bottom: 0; }
.lab-table tbody tr:hover > * { background: color-mix(in srgb, var(--rl-raised) 72%, transparent); }
.lab-product { gap: 9px; min-width: 120px; }
.lab-product-name { display: grid; gap: 2px; }
.lab-product-name strong { color: var(--rl-text); font-size: 13px; font-weight: 600; line-height: 1.2; }
.lab-product-name small { color: var(--rl-muted); font-size: 10px; font-family: "Geist Mono", monospace; font-weight: 400; }
.lab-status { --status-tone: var(--rl-muted); display: inline-flex; align-items: center; gap: 5px; border-radius: 20px; padding: 3px 7px; font-size: 10px; font-weight: 580; white-space: nowrap; color: var(--status-tone); background: color-mix(in srgb, var(--status-tone) 11%, var(--rl-surface)); }
.lab-status::before { content: ""; width: 4px; height: 4px; background: currentColor; border-radius: 50%; }
.lab-status-live { --status-tone: var(--rl-success); }
.lab-status-draft { --status-tone: var(--rl-warning); }
.lab-row-action { width: 1%; }
.rl-button.lab-edit { border: 0; background: transparent; color: var(--rl-muted); min-height: 29px; width: 29px; padding: 0; border-radius: 8px; }
.rl-button.lab-edit:hover { color: var(--rl-text); background: var(--rl-hover); }
.lab-thumbnail { position: relative; display: grid; place-items: center; flex: 0 0 auto; width: 31px; aspect-ratio: 1; border-radius: 7px; overflow: hidden; background: linear-gradient(145deg, var(--thumb-light), var(--thumb-dark)); }
.lab-thumbnail span { display: block; background: #ffffffe0; width: 14px; height: 12px; border-radius: 6px 3px 6px 2px; box-shadow: 2px 3px #343c4240, inset 0 -2px #343c4237; transform: rotate(-18deg); }
.lab-thumbnail-lilac { --thumb-light: #e5d7bc; --thumb-dark: #a58e71; }
.lab-thumbnail-peach { --thumb-light: #f0c5b2; --thumb-dark: #bd8c73; }
.lab-thumbnail-peach span { border-radius: 12px 12px 3px 3px; height: 8px; transform: rotate(0); }
.lab-thumbnail-peach span::after { position: absolute; content: ""; width: 1px; height: 8px; left: 50%; bottom: 99%; background: #fff8; }
.lab-thumbnail-mint { --thumb-light: #c3d7c1; --thumb-dark: #7ca599; }
.lab-thumbnail-mint span { border-radius: 50%; height: 8px; width: 17px; transform: skew(-14deg) translateY(-2px); }
.lab-thumbnail-mint span::after { position: absolute; content: ""; width: 4px; height: 6px; left: 42%; top: 85%; background: #fff8; }
.lab-thumbnail-sky { --thumb-light: #cadbe9; --thumb-dark: #91a8c0; }
.lab-thumbnail-sky span { width: 10px; height: 15px; border-radius: 4px 4px 7px 7px; transform: rotate(8deg); }
.lab-thumbnail-rose { --thumb-light: #edcfca; --thumb-dark: #bf9293; }
.lab-thumbnail-rose span { width: 15px; height: 10px; border-radius: 4px; transform: rotate(18deg); }

.lab-footer { justify-content: space-between; margin-top: 12px; color: var(--rl-muted); font-size: 11px; }
.lab-footer > span:last-child { gap: 6px; }
.lab-footer i { width: 4px; box-shadow: none; background: var(--rl-accent); }
.lab-empty { display: grid; text-align: center; gap: 4px; padding: 22px 8px; }
.lab-empty strong { color: var(--rl-text); }

.lab-icon { width: 12px; height: 12px; display: inline-block; position: relative; flex: 0 0 auto; }
.lab-icon-plus::before, .lab-icon-plus::after { content: ""; position: absolute; inset: 5px 1px auto; height: 1px; background: currentColor; }
.lab-icon-plus::after { transform: rotate(90deg); }
.lab-icon-search::before { content: ""; position: absolute; width: 7px; height: 7px; left: 0; top: 0; border: 1px solid currentColor; border-radius: 50%; }
.lab-icon-search::after { content: ""; position: absolute; height: 1px; width: 4px; background: currentColor; transform: rotate(45deg); top: 9px; left: 7px; }
.lab-icon-edit::before { content: ""; position: absolute; inset: 5px 0 4px; width: 11px; border: 1px solid currentColor; border-radius: 1px; transform: rotate(-45deg); }
.lab-icon-edit::after { content: ""; position: absolute; left: 1px; bottom: 1px; width: 2px; height: 2px; border-radius: 0 0 0 1px; background: currentColor; }

.lab-expanded .lab-body { padding: clamp(14px, 4vw, 30px); }
.lab-expanded .lab-table :is(th, td) { padding: 11px; }
.lab-expanded .lab-header { padding: 13px 21px; }

.lab-dialog { width: min(94vw, 450px); }
.lab-dialog-body { color: var(--rl-text); display: block; }
.lab-dialog-head { display: flex; justify-content: space-between; align-items: start; gap: 1rem; }
.lab-dialog-body h2 { font-size: 1.6rem; letter-spacing: -.05em; margin: 0 0 .35rem; }
.lab-dialog-body p { color: var(--rl-muted); font-size: .88rem; line-height: 1.55; margin: 0; }
.lab-dialog .lab-dialog-close { min-width: 35px; min-height: 35px; padding: 0; font-size: 1.28rem; }
.lab-form { margin-top: 1.65rem; display: grid; gap: 1rem; }
.lab-field { display: grid; gap: 6px; font-size: .87rem; }
.lab-field select, .lab-field input { width: 100%; }
.lab-form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: .7rem; }
.lab-danger-zone { margin-top: 1.5rem; border-top: 1px solid var(--rl-line); padding-top: 1rem; }
.lab-dialog-body .lab-field-error, .lab-request-error { color: var(--rl-danger, #ff9ba8); }
.lab-request-error { font-size: 12px; }
.rl-button.lab-delete { color: var(--rl-danger, #ff9ba8); background: transparent; }
.rl-button.lab-delete:hover { background: color-mix(in srgb, var(--rl-danger) 12%, var(--rl-surface)); }
.rl-button.lab-delete-solid { background: color-mix(in srgb, var(--rl-danger) 14%, var(--rl-surface)); color: var(--rl-danger); }
.rl-button.lab-delete-solid:hover { background: color-mix(in srgb, var(--rl-danger) 23%, var(--rl-surface)); }
.lab-sr-only { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; }

@media (max-width: 480px) {
  .lab-heading p { max-width: 15ch; }
  .lab-toolbar { flex-wrap: wrap; }
  .lab-order { flex: 0 1 auto; }
  .lab-table { min-width: 265px; }
  .lab-table th:nth-child(3), .lab-category { display: none; }
}

/* An embedded inventory can be narrower than the viewport. Keep Edit in view. */
@container inventory (max-width: 28rem) {
  .lab-toolbar { flex-wrap: wrap; }
  .lab-table { min-width: 0; table-layout: fixed; }
  .lab-table :is(th, td), .lab-expanded .lab-table :is(th, td) { padding: .55rem .35rem; }
  .lab-table thead th:nth-child(2) { width: 4.55rem; }
  .lab-table th:nth-child(3), .lab-category { display: none; }
  .lab-table thead th:last-child { width: 2.95rem; }
  .lab-product { min-width: 0; gap: 6px; }
  .lab-product-name { min-width: 0; overflow-wrap: anywhere; white-space: normal; }
  .rl-button.lab-edit { width: 36px; min-height: 36px; }
}

@container inventory (max-width: 19rem) {
  .lab-thumbnail { display: none; }
}

.lab-scenarios { margin-block-start: 1.25rem; padding-block-start: .8rem; border-block-start: 1px solid var(--rl-line); color: var(--rl-muted); font-size: .82rem; }
.lab-scenarios summary { width: fit-content; cursor: pointer; }
.lab-scenarios label { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin: .75rem .75rem 0 0; }
.lab-scenarios .rl-select { width: auto; min-width: 9rem; }
.lab-scenarios button { margin-block-start: .6rem; }
@media (prefers-reduced-motion: no-preference) {
  .lab-table [data-inventory-updated] { animation: lab-row-updated 1.2s ease-out; }
  @keyframes lab-row-updated { from { background-color: color-mix(in srgb, var(--rl-success) 19%, transparent); } }
}
