/* Shared building blocks (spec §5), ported from the prototype: page head, status labels, chips, tiles,
   skeletons, empty state, progress bar and the select chevron. Screen files only add their own layout. */

/* ---------- page head ---------- */
.pagehead { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.pagehead h1 { font-size: 26px; }
.sub { color: var(--muted); margin-top: 2px; }
.flags { display: flex; flex-wrap: wrap; gap: 4px; }
/* Space under the page head where a screen has no tabs (sorting overview, Ontbrekend) */
.tabgap { height: 12px; }
/* A dropdown in the page head (collection filter) is as wide as its label */
.pagehead .dd-bar { width: auto; }

/* ---------- status labels ---------- */
.state { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.state.inProgress { background: var(--work-soft); color: var(--work); }
.state.complete { background: var(--ok-soft); color: var(--ok); }
.state.incomplete { background: var(--warn-soft); color: var(--warn); }
.state.notSorted { color: var(--muted); border-color: var(--line-strong); }
.state.notSorted::before { background: transparent; border: 1.5px solid currentColor; }
.state.assumedComplete { color: var(--muted); border: 1px dashed var(--line-strong); }
.state.sealed { color: var(--muted); background: var(--surface-2); border-color: var(--line); }
.state.sealed::before { border-radius: 2px; transform: rotate(45deg); }

/* ---------- chips (flags) ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 4px; font-size: 11.5px; font-weight: 500; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.chip.flag { background: var(--flag-soft); color: var(--flag); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.faint { color: var(--faint); border-style: dashed; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }

/* ---------- set tiles ---------- */
.tile { width: 52px; height: 40px; border-radius: 6px; flex: none; display: grid; place-items: center; font: 600 10.5px var(--font-mono); color: #fff; letter-spacing: .02em;
  background: linear-gradient(135deg, var(--t1), var(--t2)); box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.tile.img { display: block; overflow: hidden; background: var(--img-bg); padding: 2px; }
.tile.img img { display: block; width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; border-radius: 4px; }
/* A collection without set images */
.tile.blank { --t1: var(--line); --t2: var(--line-strong); }

/* ---------- loading skeleton ---------- */
.skel { display: block; height: 14px; border-radius: 4px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); animation: skel-pulse 1.2s ease-in-out infinite alternate; }
.pagehead .skel { display: inline-block; vertical-align: middle; }
.skel.small { height: 10px; margin-top: 6px; }
.skel.pill { width: 96px; height: 22px; border-radius: 11px; }
.tile.skel { background: var(--surface-2); }
.skel.w-totals { width: 140px; }
.skel.w30 { width: 30%; } .skel.w50 { width: 50%; } .skel.w60 { width: 60%; } .skel.w80 { width: 80%; }
@keyframes skel-pulse { from { opacity: 1; } to { opacity: .45; } }

/* ---------- breadcrumbs, set name cell, square icon button (⋯) ---------- */
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.crumbs a { color: inherit; }
.oname { min-width: 0; }
.oname a { color: var(--ink); text-decoration: none; font-weight: 600; }
.oname a:hover { text-decoration: underline; }
.oname .meta { color: var(--muted); font-size: 12.5px; }
.btn.iconsq { width: 34px; padding: 0; justify-content: center; }
.btn.iconsq svg { width: 18px; height: 18px; }

/* ---------- list card and empty state ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.list > .empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty h1, .empty h3 { font-size: 16px; color: var(--ink); margin-bottom: 4px; }

/* ---------- status line (sorting screen head, set page) ---------- */
.statusline { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 10px; font-size: 13px; color: var(--muted); }
.statusline .dot { color: var(--line-strong); }

/* ---------- progress bar and text ---------- */
.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--work); border-radius: 4px; }
.bar.ok i { background: var(--ok); }
.ptext { font-size: 12.5px; color: var(--muted); }
.ptext b { color: var(--ink); font-weight: 600; }

/* ---------- counts and tabs ---------- */
.count { font-size: 11px; font-weight: 600; min-width: 18px; text-align: center; padding: 0 5px; border-radius: 9px; background: var(--line); color: var(--ink); font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; padding: 10px 12px; color: var(--muted); font-weight: 500; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 6px; align-items: center; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs .count.hot { background: var(--warn-soft); color: var(--warn); }
.tabs .count.flag { background: var(--flag-soft); color: var(--flag); }

/* ---------- choice cards (dialogs) ---------- */
.choice { display: grid; gap: 8px; }
.choice label { display: grid; grid-template-columns: 20px 1fr; gap: 10px; padding: 12px; border: 1px solid var(--line-strong); border-radius: 10px; cursor: pointer; }
.choice label:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--surface-2); }
.choice input { appearance: none; -webkit-appearance: none; width: 18px; height: 18px; margin: 2px 0 0; border: 1.5px solid var(--line-strong); border-radius: 50%; background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.choice input::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink); transform: scale(0); transition: transform .12s; }
.choice input:checked { border-color: var(--ink); }
.choice input:checked::before { transform: scale(1); }
.choice input:focus-visible { outline: 2px solid var(--work); outline-offset: 2px; }
.choice b { display: block; }
.choice span { color: var(--muted); font-size: 13px; }
.warnline, .modal p.warnline { font-size: 13px; color: var(--warn); }

/* ---------- select chevron ---------- */
select.sel, .field select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23565C6B' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px 16px;
}
select.sel { height: 36px; border: 1px solid var(--line-strong); background-color: var(--surface); border-radius: var(--r); padding-left: 10px; }
select.sel:hover, .field select:hover { border-color: var(--ink); }

/* ---------- toolbar, keyboard hint, list head ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 0; }
.toolbar .dd-bar { width: auto; }
.hint { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 2px 0 10px; }
.hint span { display: inline-flex; gap: 4px; align-items: center; }
.hint .hcount { margin-left: auto; }
.lhead { display: grid; gap: 12px; padding: 8px 14px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.tshort { display: none; }

/* ---------- colour swatch and part image ---------- */
.sw { width: 30px; height: 30px; border-radius: 6px; flex: none; position: relative; background: var(--c, var(--surface-2)); box-shadow: inset 0 0 0 1px var(--sw-ring); }
.sw::before, .sw::after { content: ""; position: absolute; top: 7px; width: 9px; height: 9px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255,255,255,.35), rgba(255,255,255,0) 60%), var(--c, var(--surface-2)); box-shadow: 0 1px 1px rgba(0,0,0,.25); }
.sw::before { left: 5px; } .sw::after { right: 5px; }
.sw.trans { background: repeating-conic-gradient(#d9dbe0 0 25%, #fff 0 50%) 0 0/8px 8px; }
.sw.trans::before, .sw.trans::after { opacity: .75; }
.sw.trans span { position: absolute; inset: 0; border-radius: 6px; background: var(--c); opacity: .55; }
.pimg { width: 44px; height: 44px; border-radius: 6px; background: var(--img-bg); position: relative; flex: none; display: grid; place-items: center; box-shadow: inset 0 0 0 1px var(--line); }
.pimg.noimg { background: var(--surface) repeating-linear-gradient(135deg, transparent 0 5px, var(--surface-2) 5px 7px); box-shadow: inset 0 0 0 1px var(--line-strong); border-radius: 6px; }
.pimg.noimg .sw { width: 20px; height: 20px; border-radius: 4px; }
.pimg.noimg .sw::before, .pimg.noimg .sw::after { display: none; }
.pimg img { width: 40px; height: 40px; object-fit: contain; mix-blend-mode: multiply; }
.pimg[data-zoom-src] { cursor: zoom-in; }

/* ---------- part row (Onderdeelregel); the counter's .mctr gives its two cells to the grid ---------- */
.prow { display: grid; grid-template-columns: 44px 100px minmax(0, 1fr) 130px 150px 168px 34px; gap: 12px; align-items: center; padding: 5px 14px; min-height: 54px; border-top: 1px solid var(--line); }
.lhead.parts { grid-template-columns: 44px 100px minmax(0, 1fr) 130px 150px 168px 34px; }
.lhead + .prow, .prow:first-child { border-top: 0; }
.prow .mctr { display: contents; }
.prow .pn { font-size: 12.5px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.prow .co, .prow .ca { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prow .tags { display: inline-flex; gap: 4px; margin-left: 6px; vertical-align: 1px; }
.prow.sel { background: var(--sel); }
.prow.done { color: var(--faint); }
.prow.done .nm { color: var(--muted); font-weight: 400; }
.prow.done .sw { opacity: .45; }
.prow.miss .ctr output { background: var(--warn-soft); color: var(--warn); }
/* pending and loading win over miss */
.prow .mctr.is-pending .ctr output { background: color-mix(in srgb, var(--pending) 18%, var(--surface)); color: var(--pending); }
.prow .mctr.is-loading .ctr output { opacity: .5; }

/* ---------- declare bar and set line under a part (Ontbrekend; also the set page and the catalog part page) ---------- */
.banner.ask { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: space-between; padding: 12px 14px; font-size: inherit; background: var(--ok-soft); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); }
.banner.ask p { margin: 0; }
.banner.ask b { color: var(--ink); }
.banner.ask .askbtns { display: flex; gap: 8px; }
.banner.ask .askerr { display: block; margin-top: 4px; color: var(--warn); font-size: 12.5px; }
.mset { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.mset.sel { background: var(--sel); box-shadow: inset 0 0 0 1px var(--line-strong); }
.mset .tile { width: 40px; height: 30px; font-size: 8.5px; }
.mset .sname { min-width: 0; }
.mset .sname a { color: inherit; }
.mset .sname b { font-weight: 600; }
.mset .sname .meta { font-size: 12px; color: var(--muted); }

/* Search hit (top-bar list and search page; prototype .sres) */
.sres { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.sres:hover, .sres.sel { background: var(--surface-2); }
.sres.sel { box-shadow: inset 0 0 0 1px var(--line-strong); }
.sres .tile { width: 44px; height: 34px; font-size: 9px; }
.sres .st { min-width: 0; }
.sres .tt { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sres .mm { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sicon { width: 44px; height: 34px; border-radius: 6px; background: var(--img-bg); display: grid; place-items: center; color: var(--muted); overflow: hidden; position: relative; }
.sicon svg { width: 18px; height: 18px; }
.sicon > img { position: absolute; inset: 2px; width: calc(100% - 4px); height: calc(100% - 4px); object-fit: contain; mix-blend-mode: multiply; }

@media (max-width: 760px) {
  .pagehead h1 { font-size: 22px; }
  .statusline { margin-top: 6px; }
  .lhead { display: none; }
  .hint { display: none; }
  .tshort { display: inline; }
  .pglbl { display: none; }
  .prow { grid-template-columns: 44px minmax(0, 1fr) auto; grid-template-areas: "sw nm ctr" "sw meta ctr"; gap: 0 10px; padding: 8px 12px; }
  .prow .pimg { grid-area: sw; align-self: center; }
  .prow .nm { grid-area: nm; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .prow .pn { grid-area: meta; font-size: 12px; }
  .prow .co, .prow .ca, .prow .zero { display: none; }
  .prow .pn::after { content: " · " attr(data-color); font-family: var(--font-ui); }
  .prow .ctrwrap { grid-area: ctr; }
  .mset { grid-template-columns: minmax(0, 1fr) auto; }
  .mset .tile { display: none; }
  .mset > [data-slot="state"] { grid-column: 1; justify-self: start; }
  .mset .mctr { grid-column: 2; grid-row: 1 / span 2; }
  .mset .zero { display: none; }
}

/* A quiet add button under a list or form (+ Link toevoegen, + Aankoopgegevens toevoegen); [hidden] is in reset.css */
.addbuy { justify-self: start; color: var(--work); padding-left: 0; }

/* ---------- bottom sheet (phone: choices with many options) ---------- */
.sheetscrim { place-items: end stretch; padding: 0; }
.sheet { position: relative; max-height: 75vh; max-height: 75dvh; overflow: auto; background: var(--surface); border-radius: 16px 16px 0 0; box-shadow: var(--shadow); padding: 12px 12px calc(16px + env(safe-area-inset-bottom, 0px)); animation: sheetup .18s ease-out; }
@keyframes sheetup { from { transform: translateY(30%); opacity: 0; } }
.sheet-h { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 10px; }
.sheet-h h2 { font-size: 17px; }

/* ---------- a titled block on a page (set page instructions, catalog part page) ---------- */
.section { margin-top: 22px; }
.section h2 { font-size: 17px; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }

/* ---------- read-only catalog rows and facts (catalog parts, set page, minifigure page) ---------- */
.clickrow { cursor: pointer; color: inherit; text-decoration: none; }
.clickrow:hover { background: var(--surface-2); }
.prow.ro { grid-template-columns: 44px 100px minmax(0, 1fr) 130px 150px 60px; }
.prow.ro.is-skeleton { pointer-events: none; }
.prow.ro .qty { font: 600 13px var(--font-mono); text-align: right; color: var(--muted); display: flex; justify-content: flex-end; }
.prow.ro .qty svg { width: 16px; height: 16px; }
.prow.ro .pn[data-color=""]::after { content: none; }
.figrow { display: grid; grid-template-columns: 52px 110px minmax(0, 1fr) 60px; gap: 12px; align-items: center; padding: 8px 14px; border-top: 1px solid var(--line); }
.figrow:first-child { border-top: 0; }
.figrow .qty { text-align: right; color: var(--muted); font-weight: 600; font-size: 13px; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 14px 0 12px; }
.facts div { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.facts dt { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.facts dd { margin: 2px 0 0; font-weight: 500; }
.facts dd a { color: inherit; }
@media (max-width: 760px) {
  .prow.ro { grid-template-columns: 44px minmax(0, 1fr) auto; grid-template-areas: "sw nm ctr" "sw meta ctr"; }
  .prow.ro .qty { grid-area: ctr; }
  .figrow { grid-template-columns: 52px minmax(0, 1fr) auto; }
  .figrow .mono.sub { display: none; }
  .facts { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- set head and small shared blocks (set page, catalog set page, sorting) ---------- */
.spage { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.bigimg { position: relative; width: 260px; height: 200px; border-radius: 8px; background: var(--img-bg); display: grid; place-items: center; overflow: hidden; }
.bigimg > img { position: absolute; inset: 8px; width: calc(100% - 16px); height: calc(100% - 16px); object-fit: contain; mix-blend-mode: multiply; }
.bigimg[data-zoom-src] { cursor: zoom-in; }
.bigimg .tile.big { width: 120px; height: 92px; font-size: 18px; }
.sinfo { min-width: 0; }
.sinfo-top { display: flex; justify-content: space-between; gap: 12px; align-items: start; flex-wrap: wrap; }
.sinfo-name { min-width: 0; }
.sinfo h1 { font-size: 26px; margin: 2px 0 2px; }
.sinfo .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.spage.is-skeleton .bigimg { height: 200px; }
.spage.is-skeleton .sinfo { display: grid; gap: 10px; align-content: start; }
.spage.is-skeleton .skel.w60 { height: 24px; }
.tabgap16 { height: 16px; }
.figimg { width: 52px; height: 52px; border-radius: 6px; background: var(--img-bg); object-fit: contain; flex: none; box-shadow: inset 0 0 0 1px var(--line); }
.figimg[data-zoom-src] { cursor: zoom-in; }
@media (max-width: 760px) {
  .spage { grid-template-columns: minmax(0, 1fr); }
  .bigimg, .spage.is-skeleton .bigimg { width: 100%; height: 180px; }
  .sinfo .actions { justify-content: flex-start; gap: 6px; }
  .sinfo .actions .btn { height: 30px; padding: 0 9px; font-size: 13px; }
  .sinfo .actions .btn.iconsq { padding: 0; }
}
