:root {
    --bg: #f6f7f9;
    --card: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --brand: #111827;
    --brand-hover: #374151;
    --danger: #b91c1c;
    --green: #047857;
    --shadow: 0 18px 45px rgba(15, 23, 42, .08);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: inherit; }
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar__inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}
.brand {
    font-weight: 800;
    text-decoration: none;
    letter-spacing: -.02em;
}
.nav {
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 14px;
}
.nav a { text-decoration: none; color: var(--muted); }
.nav a:hover { color: var(--text); }
.inline-form { margin: 0; }
.link-button {
    border: 0;
    background: none;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    padding: 0;
}
.link-button:hover { color: var(--text); }
.page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 32px 24px 72px;
}
.auth-card {
    max-width: 440px;
    margin: 60px auto;
    background: var(--card);
    padding: 34px;
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}
h1 { margin: 0 0 8px; font-size: clamp(28px, 4vw, 42px); line-height: 1.05; letter-spacing: -.04em; }
h2 { margin: 0 0 18px; font-size: 20px; }
.muted { color: var(--muted); }
.small { font-size: 12px; display: block; margin-top: 3px; }
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 22px;
}
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 24px;
    box-shadow: 0 8px 26px rgba(15, 23, 42, .04);
    margin-bottom: 22px;
}
.grid { display: grid; gap: 22px; margin-bottom: 22px; }
.grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-stack { display: grid; gap: 16px; }
label { display: grid; gap: 7px; font-weight: 700; font-size: 14px; }
input, select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    font: inherit;
    background: white;
}
input:focus, select:focus {
    outline: 2px solid rgba(17, 24, 39, .16);
    border-color: #9ca3af;
}
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    background: var(--brand);
    color: white;
    padding: 12px 18px;
    min-height: 44px;
    text-decoration: none;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}
.button:hover { background: var(--brand-hover); }
.button--secondary { background: #eef0f3; color: var(--text); }
.button--secondary:hover { background: #e5e7eb; }
.button--small { min-height: 34px; padding: 8px 12px; border-radius: 10px; font-size: 13px; }
.button--danger { background: #fee2e2; color: var(--danger); }
.button--danger:hover { background: #fecaca; }
.alert { padding: 14px 16px; border-radius: 14px; margin: 16px 0; }
.alert--error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.searchbar { display: flex; gap: 10px; margin-bottom: 18px; }
.searchbar input { flex: 1; }
.meta-line { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 14px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.align-right { text-align: right !important; }
.empty { text-align: center !important; color: var(--muted); padding: 34px !important; }
.product-cell { display: flex; align-items: center; gap: 14px; min-width: 280px; }
.thumb {
    width: 54px;
    height: 54px;
    object-fit: cover;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f3f4f6;
}
.thumb--empty { display: grid; place-items: center; color: var(--muted); }
.pagination { display: flex; align-items: center; gap: 12px; justify-content: flex-end; margin-top: 18px; }
.backlink { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: 12px; }
.backlink:hover { color: var(--text); }
.definition-list { display: grid; grid-template-columns: minmax(140px, .35fr) 1fr; gap: 10px 16px; margin: 0; }
.definition-list dt { color: var(--muted); font-weight: 700; }
.definition-list dd { margin: 0; overflow-wrap: anywhere; }
.rich-text { overflow-wrap: normal; }
.rich-text p { margin: 0 0 12px; }
.rich-text p:last-child { margin-bottom: 0; }
.rich-text ul, .rich-text ol { margin: 8px 0 12px 22px; padding: 0; }
.rich-text li { margin: 4px 0; }
.rich-text h1, .rich-text h2, .rich-text h3, .rich-text h4, .rich-text h5, .rich-text h6 { margin: 16px 0 8px; letter-spacing: normal; line-height: 1.2; }
.rich-text h1 { font-size: 24px; }
.rich-text h2 { font-size: 21px; }
.rich-text h3 { font-size: 18px; }
.rich-text table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.rich-text th, .rich-text td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.rich-text img { max-width: 100%; height: auto; border-radius: 12px; }
.rich-text a { text-decoration: underline; }

.download-list { margin: 0; padding-left: 18px; }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.asset-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px;
    display: grid;
    gap: 10px;
}
.asset-preview {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    border-radius: 12px;
    background: #f9fafb;
    border: 1px solid var(--border);
}
.asset-preview--empty { display: grid; place-items: center; color: var(--muted); }
.json-block {
    background: #111827;
    color: #e5e7eb;
    padding: 18px;
    border-radius: 14px;
    overflow: auto;
    max-height: 520px;
}
.badge { display: inline-flex; padding: 5px 9px; border-radius: 999px; background: #eef0f3; color: var(--muted); font-weight: 800; font-size: 12px; }
.badge--green { background: #dcfce7; color: var(--green); }
.actions { display: flex; gap: 8px; justify-content: flex-end; }
.actions form { margin: 0; }
@media (max-width: 760px) {
    .topbar__inner, .page-head, .searchbar { flex-direction: column; align-items: stretch; }
    .grid--two { grid-template-columns: 1fr; }
    .page { padding: 22px 14px 60px; }
    .card, .auth-card { padding: 20px; border-radius: 18px; }
    .definition-list { grid-template-columns: 1fr; }
}

/* v4: thumbnails voor KatanaPIM assets */
.asset-grid--wide { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.asset-preview-link { display: block; text-decoration: none; }
.asset-card .asset-name {
    display: block;
    min-height: 2.4em;
    overflow-wrap: anywhere;
    line-height: 1.2;
}
.asset-type {
    display: block;
    font-size: 12px;
    min-height: 18px;
}
.asset-preview--file {
    display: grid;
    place-items: center;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 800;
    font-size: 13px;
    letter-spacing: .04em;
}
.asset-preview--file span {
    background: #eef0f3;
    border-radius: 999px;
    padding: 7px 10px;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* v7: productoverzicht thumbnails + openklapbare parent/child groepen + specificaties */
.group-list { display: grid; gap: 16px; }
.product-group {
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
}
.product-group > summary {
    list-style: none;
    cursor: pointer;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    background: #f9fafb;
    border-bottom: 1px solid var(--border);
}
.product-group > summary::-webkit-details-marker { display: none; }
.product-group > summary::before {
    content: '▸';
    color: var(--muted);
    margin-right: 4px;
}
.product-group[open] > summary::before { content: '▾'; }
.product-group .table-wrap { border-radius: 0; }
.product-group .table tr:last-child td { border-bottom: 0; }
.specs-list dd { font-weight: 600; }
.thumb { object-fit: contain; }

.hierarchy-list { display: grid; gap: 14px; }
.h-grand, .h-parent { border: 1px solid #e5e7eb; border-radius: 14px; background: #fff; overflow: hidden; }
.h-grand > summary, .h-parent > summary { cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; background: #f8fafc; font-weight: 800; }
.h-parent { margin: 10px 14px 14px 28px; }
.h-parent > summary { background: #fbfdff; font-weight: 700; }
.h-title { color: #0f172a; }
.h-title--parent { color: #334155; }
.children.table-wrap { margin: 0 14px 14px 14px; }
.grand-direct.table-wrap { margin: 14px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 10px; background: #e2e8f0; color: #334155; font-size: 12px; font-weight: 700; }

/* v9: duidelijke grandparent > parent > children structuur */
.hierarchy-list--nested { gap: 18px; }
.h-summary-product {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}
.h-grand > summary, .h-parent > summary {
    min-height: 72px;
}
.h-grand > summary::before, .h-parent > summary::before {
    content: '▸';
    color: var(--muted);
    font-size: 16px;
    line-height: 1;
}
.h-grand[open] > summary::before, .h-parent[open] > summary::before { content: '▾'; }
.h-grand > summary, .h-parent > summary { justify-content: flex-start; }
.h-parent { margin-left: 34px; }
.thumb--summary { width: 46px; height: 46px; flex: 0 0 46px; }
.button--summary { margin-left: auto; }
.children .table th:first-child { padding-left: 28px; }
.children .table td:first-child { padding-left: 28px; }
.children .product-cell strong { font-size: 18px; }
.children .product-cell .small { display: block; }

/* v10: overzicht alleen grandparents, varianten op productpagina */
.table--grandparents .product-cell--grandparent strong { font-size: 17px; }
.family-tree { display: grid; gap: 14px; }
.family-parent { border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: #fff; }
.family-parent > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; background: #f8fafc; }
.family-parent > summary::-webkit-details-marker { display: none; }
.family-parent > summary::before { content: '▸'; color: var(--muted); font-weight: 900; }
.family-parent[open] > summary::before { content: '▾'; }
.family-parent__main { display: inline-flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.family-parent__main strong { display: block; }
.family-children { display: grid; gap: 0; }
.family-child { display: grid; grid-template-columns: minmax(220px, 1.4fr) minmax(120px, .6fr) minmax(150px, .7fr) auto; gap: 14px; align-items: center; padding: 13px 16px 13px 58px; border-top: 1px solid var(--border); }
.family-child__name strong { font-size: 18px; }
.family-child__name .small { display: block; }
.family-empty { padding: 14px 16px 14px 58px; margin: 0; border-top: 1px solid var(--border); }
@media (max-width: 900px) {
    .family-child { grid-template-columns: 1fr; padding-left: 22px; }
    .family-parent > summary { align-items: flex-start; flex-direction: column; }
    .button--summary { margin-left: 0; }
}

.section-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.parent-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.parent-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
}

.parent-bar__left,
.parent-bar__right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.thumb--parentbar {
    width: 58px;
    height: 58px;
    object-fit: contain;
    flex: 0 0 auto;
}

@media (max-width: 720px) {
    .section-title-row,
    .parent-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .parent-bar__right {
        justify-content: space-between;
    }
}

/* v14: parent/child thumbnails, SKU/EAN en compact variant-overzicht */
.parent-bar__left { min-width: 0; }
.parent-bar__left > div { min-width: 0; }
.parent-bar__left strong { display: block; }
.variant-list { display: grid; gap: 10px; }
.variant-row {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(280px, .8fr) auto;
    gap: 16px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
}
.variant-row__left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.variant-row__meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    color: var(--muted);
    font-size: 13px;
}
.variant-row__meta strong { color: var(--text); font-size: 12px; }
.variant-row__right { display: flex; justify-content: flex-end; }
.thumb--variant {
    width: 52px;
    height: 52px;
    object-fit: contain;
    flex: 0 0 auto;
}
@media (max-width: 860px) {
    .variant-row { grid-template-columns: 1fr; }
    .variant-row__right { justify-content: flex-start; }
}
