/* ============================================================
   catalog.css — B2B product catalog (category tree + grid + keywords)
   Design goal: professional, dense and lively. Tight gaps, lively accents.
   ============================================================ */
:root {
    --brand: #155d37;
    --brand-2: #1c7a4a;
    --accent: #f97316;
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --line-2: #eef2f6;
    --bg: #f5f7f9;
    --card: #ffffff;
    --radius: 10px;
    --gap: 14px;              /* deliberately tight — "blocks not too far apart" */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
    --shadow-md: 0 4px 10px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

body.catalog-page {
    margin: 0;
    background: var(--bg);
    color: var(--ink-2);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* ---------------- top bar ---------------- */
.cat-topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 60;
}
.cat-topbar .inner {
    max-width: 1480px;
    margin: 0 auto;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.brand-mark {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.brand-mark .ico {
    width: 34px; height: 34px;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    display: grid; place-items: center;
    font-size: 16px;
}
.brand-mark b { display: block; font-size: 14px; color: var(--ink); letter-spacing: -.2px; }
.brand-mark span { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }

.cat-topnav { display: flex; gap: 4px; margin-left: 8px; }
.cat-topnav a {
    padding: 6px 11px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
}
.cat-topnav a:hover { background: var(--line-2); color: var(--brand); }
.cat-topnav a.on { background: var(--brand); color: #fff; }

.cat-search {
    margin-left: auto;
    position: relative;
    flex: 0 1 300px;
}
.cat-search input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    background: #fff;
}
.cat-search input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(21, 93, 55, .1); }
.cat-search i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; }

.btn-quote {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 9px 16px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
}
.btn-quote:hover { filter: brightness(1.06); }

/* ---------------- hero strip ---------------- */
.cat-hero {
    background: linear-gradient(120deg, #0f3d26 0%, var(--brand) 55%, #1c7a4a 100%);
    color: #fff;
    padding: 20px 18px 18px;
}
.cat-hero .inner { max-width: 1480px; margin: 0 auto; }
.crumb { font-size: 12px; color: rgba(255, 255, 255, .68); margin-bottom: 6px; }
.crumb a:hover { color: #fff; text-decoration: underline; }
.crumb span { margin: 0 6px; opacity: .5; }
.cat-hero h1 { margin: 0 0 6px; font-size: 24px; font-weight: 800; letter-spacing: -.4px; }
.cat-hero p { margin: 0; font-size: 13px; color: rgba(255, 255, 255, .8); max-width: 780px; }
.cat-hero-stats { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.cat-hero-stats div {
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .18);
    padding: 5px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.cat-hero-stats b { font-size: 13px; }

/* ---------------- layout ---------------- */
.cat-wrap {
    max-width: 1480px;
    margin: 0 auto;
    padding: var(--gap) 18px 48px;
    display: grid;
    grid-template-columns: 258px minmax(0, 1fr);
    gap: var(--gap);
    align-items: start;
}

/* ---------------- sidebar / tree ---------------- */
.side {
    position: sticky;
    top: 66px;
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    max-height: calc(100vh - 80px);
    overflow: auto;
    padding-right: 2px;
}
.side::-webkit-scrollbar { width: 6px; }
.side::-webkit-scrollbar-thumb { background: #cfd8e3; border-radius: 3px; }

.side-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.side-card > h4 {
    margin: 0;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 1px solid var(--line-2);
    background: #fbfcfd;
    display: flex;
    align-items: center;
    gap: 7px;
}
.side-card > h4 i { color: var(--brand); }

/* tree */
.tree { padding: 6px; }
.tree-group { margin-bottom: 1px; }
.tree-row {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 8px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    transition: background .12s;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
}
.tree-row:hover { background: var(--line-2); }
.tree-row.active { background: var(--brand); color: #fff; }
.tree-row.active .cnt { background: rgba(255, 255, 255, .22); color: #fff; }
.tree-row .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.tree-row .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row .cnt {
    font-size: 11px;
    font-weight: 700;
    background: var(--line-2);
    color: var(--muted);
    border-radius: 999px;
    padding: 1px 7px;
    flex-shrink: 0;
}
.tree-row .caret {
    width: 14px;
    text-align: center;
    font-size: 9px;
    color: var(--muted);
    transition: transform .18s;
    flex-shrink: 0;
}
.tree-row.active .caret { color: #fff; }
.tree-row.open .caret { transform: rotate(90deg); }

.tree-kids { display: none; padding: 1px 0 3px 0; }
.tree-group.open .tree-kids { display: block; }
.tree-kid {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 8px 5px 24px;
    border-radius: 7px;
    font-size: 12.5px;
    color: var(--ink-2);
    position: relative;
}
.tree-kid:before {
    content: "";
    position: absolute;
    left: 11px;
    top: 50%;
    width: 5px; height: 5px;
    border-right: 1.5px solid #c3ccd8;
    border-bottom: 1.5px solid #c3ccd8;
    transform: translateY(-50%) rotate(-45deg);
}
.tree-kid:hover { background: var(--line-2); color: var(--brand); }
.tree-kid.active { background: #e8f2ec; color: var(--brand); font-weight: 700; }
.tree-kid .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-kid .cnt { font-size: 10.5px; font-weight: 700; color: var(--muted); background: var(--line-2); border-radius: 999px; padding: 0 6px; }
.tree-kid.zero { color: #94a3b8; }
.tree-kid.zero .cnt { color: #b6c0cc; }

/* sidebar keyword list */
.kw-list { padding: 8px; display: flex; flex-wrap: wrap; gap: 5px; }
.kw-list button {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--ink-2);
    transition: .12s;
}
.kw-list button:hover { border-color: var(--brand); color: var(--brand); background: #f2f8f4; }
.kw-list button.on { background: var(--brand); border-color: var(--brand); color: #fff; }

.side-help { padding: 11px 12px; font-size: 12px; color: var(--muted); }
.side-help b { color: var(--ink); display: block; margin-bottom: 3px; font-size: 12.5px; }
.side-help a { color: var(--accent); font-weight: 700; }

/* ---------------- main ---------------- */
.main { min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }

/* keyword cloud (the "nicer" version) */
.kw-panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px 13px;
    box-shadow: var(--shadow-sm);
}
.kw-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 9px;
}
.kw-head h3 { margin: 0; font-size: 13px; font-weight: 800; color: var(--ink); letter-spacing: -.1px; }
.kw-head p { margin: 0; font-size: 11.5px; color: var(--muted); }
.kw-head .clr {
    margin-left: auto;
    background: none;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 3px 9px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--muted);
}
.kw-head .clr:hover { border-color: var(--accent); color: var(--accent); }

.cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.cloud button {
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #fff, #fafbfc);
    border-radius: 999px;
    padding: 5px 12px;
    font-weight: 600;
    color: var(--ink-2);
    transition: transform .12s, box-shadow .12s, background .12s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.cloud button:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: var(--brand); color: var(--brand); }
.cloud button .n {
    font-size: 10px;
    font-weight: 800;
    background: var(--line-2);
    color: var(--muted);
    border-radius: 999px;
    padding: 0 5px;
    line-height: 15px;
}
.cloud button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.cloud button.on .n { background: rgba(255, 255, 255, .22); color: #fff; }
.cloud button.k1 { font-size: 12px; padding: 4px 10px; }
.cloud button.k2 { font-size: 13px; }
.cloud button.k3 { font-size: 14.5px; font-weight: 700; }
.cloud button.k4 { font-size: 16px; font-weight: 800; }

/* toolbar */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 8px 12px;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}
.toolbar .r-count { font-size: 12.5px; color: var(--muted); }
.toolbar .r-count b { color: var(--ink); font-size: 13.5px; }
.toolbar .spacer { margin-left: auto; }
.toolbar select {
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 5px 8px;
    font-size: 12.5px;
    color: var(--ink-2);
    background: #fff;
    outline: none;
}
.chip-on {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e8f2ec;
    color: var(--brand);
    border: 1px solid #bcdcc9;
    border-radius: 999px;
    padding: 3px 8px 3px 10px;
    font-size: 12px;
    font-weight: 700;
}
.chip-on button { background: none; border: none; color: var(--brand); font-size: 12px; padding: 0 0 0 2px; }

/* ---------------- product grid ---------------- */
.pgrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
    gap: var(--gap);
}

.pcard {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform .14s, box-shadow .14s, border-color .14s;
    position: relative;
}
.pcard:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -8px rgba(15, 23, 42, .18);
    border-color: #c9d6d0;
    z-index: 2;
}

.pcard-img {
    position: relative;
    aspect-ratio: 4 / 3;
    background: #f4f7f5;
    border-bottom: 1px solid var(--line-2);
    display: block;
    overflow: hidden;
}
.pcard-img img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s;
}
.pcard:hover .pcard-img img { transform: scale(1.045); }

.tag {
    position: absolute;
    top: 7px; left: 7px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .3px;
    padding: 3px 7px;
    border-radius: 5px;
    text-transform: uppercase;
    backdrop-filter: blur(3px);
}
.tag-cap { background: rgba(15, 23, 42, .82); color: #fff; }
.tag-hot { left: auto; right: 7px; background: var(--accent); color: #fff; }
.tag-img { left: 7px; top: auto; bottom: 7px; background: rgba(255, 255, 255, .92); color: #b45309; border: 1px solid #fde68a; }

.pcard-body { padding: 9px 10px 10px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.pcard-sku {
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .5px;
    color: var(--brand);
    text-transform: uppercase;
}
.pcard-name {
    margin: 0;
    font-size: 12.8px;
    font-weight: 700;
    line-height: 1.33;
    color: var(--ink);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 34px;
}
.pcard-specs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.pcard-specs span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--line-2);
    border-radius: 5px;
    padding: 2px 6px;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--ink-2);
}
.pcard-specs i { color: var(--brand); font-size: 9px; }
.pcard-mat {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.pcard-foot {
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--line-2);
    display: flex;
    gap: 6px;
}
.pcard-foot .q {
    flex: 1;
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: 7px;
    padding: 6px 8px;
    font-size: 11.5px;
    font-weight: 700;
    text-align: center;
}
.pcard-foot .q:hover { background: var(--brand-2); }
.pcard-foot .d {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 7px;
    padding: 6px 9px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--ink-2);
}
.pcard-foot .d:hover { border-color: var(--brand); color: var(--brand); }

/* ---------------- empty / sourcing state ---------------- */
.sourcing {
    background: #fff;
    border: 1.5px dashed #cbd5e1;
    border-radius: var(--radius);
    padding: 34px 22px;
    text-align: center;
    grid-column: 1 / -1;
}
.sourcing .ic {
    width: 46px; height: 46px;
    border-radius: 12px;
    background: #f1f5f9;
    color: var(--muted);
    display: grid; place-items: center;
    font-size: 19px;
    margin: 0 auto 12px;
}
.sourcing h3 { margin: 0 0 6px; font-size: 16px; color: var(--ink); }
.sourcing p { margin: 0 auto 14px; font-size: 13px; color: var(--muted); max-width: 520px; }
.sourcing .act { display: inline-flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.sourcing .act a {
    background: var(--brand);
    color: #fff;
    border-radius: 8px;
    padding: 8px 15px;
    font-size: 13px;
    font-weight: 700;
}
.sourcing .act a.alt { background: #fff; color: var(--brand); border: 1px solid var(--line); }

.state { padding: 40px; text-align: center; color: var(--muted); grid-column: 1 / -1; }

/* ---------------- responsive ---------------- */
@media (max-width: 1080px) {
    .cat-wrap { grid-template-columns: 1fr; }
    .side { position: static; max-height: none; flex-direction: row; flex-wrap: wrap; }
    .side .side-card { flex: 1 1 260px; }
}
@media (max-width: 640px) {
    .cat-topbar .inner { flex-wrap: wrap; }
    .cat-search { flex: 1 1 100%; margin-left: 0; order: 5; }
    .pgrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .cat-hero h1 { font-size: 20px; }
}

/* ---------------- product detail page ---------------- */
.pd-wrap { max-width: 1280px; margin: 0 auto; padding: 18px 18px 60px; }
.pd-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.pd-media { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.pd-main-img { aspect-ratio: 4 / 3; background: #f4f7f5; display: grid; place-items: center; }
.pd-main-img img { width: 100%; height: 100%; object-fit: contain; }
.pd-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 7px; padding: 9px; border-top: 1px solid var(--line-2); }
.pd-thumbs button {
    aspect-ratio: 1; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: #fff; padding: 0;
}
.pd-thumbs button.on { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(21, 93, 55, .18); }
.pd-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }

.pd-info { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.pd-info h1 { margin: 4px 0 6px; font-size: 21px; color: var(--ink); letter-spacing: -.3px; }
.pd-info .pd-sku { font-size: 11.5px; font-weight: 800; color: var(--brand); letter-spacing: .6px; }
.pd-info .pd-lead { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

.pd-spec {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 8px;
    margin: 14px 0 16px;
}
.pd-spec div { background: var(--line-2); border-radius: 8px; padding: 8px 10px; }
.pd-spec dt { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; }
.pd-spec dd { margin: 2px 0 0; font-size: 13px; font-weight: 700; color: var(--ink); }

.pd-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.pd-actions .q { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 10px 18px; font-weight: 700; font-size: 13.5px; }
.pd-actions .s { background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; font-weight: 700; font-size: 13.5px; }

.pd-block { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-top: var(--gap); }
.pd-block h2 { margin: 0 0 10px; font-size: 15px; color: var(--ink); }
.pd-block table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pd-block table th, .pd-block table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line-2); }
.pd-block table th { width: 230px; color: var(--muted); font-weight: 600; background: #fbfcfd; }
.pd-block ul { margin: 0; padding-left: 18px; }
.pd-block li { margin-bottom: 5px; }

.pd-related { margin-top: var(--gap); }
.pd-related h2 { font-size: 15px; margin: 0 0 10px; color: var(--ink); }

@media (max-width: 900px) {
    .pd-grid { grid-template-columns: 1fr; }
}
