:root{
  --green: #83B20A;
  --green-dark: #6d9508;
  --green-pale: #eef6d9;
  --ink: #16181a;
  --ink-soft: #5a6063;
  --line: #e2e2e0;
  --paper: #ffffff;
  --grey-bg: #f4f4f2;
  --red: #ff5b45;
  --radius: 4px;
}
*{box-sizing:border-box;}
body{margin:0;font-family:'Inter',system-ui,sans-serif;color:var(--ink);background:var(--paper);font-size:14.5px;}
a{cursor:pointer;color:inherit;}
button{font-family:inherit;cursor:pointer;}
input{font-family:inherit;}

.topbar{display:flex;justify-content:flex-end;gap:18px;padding:6px 32px;font-size:12px;color:var(--ink-soft);border-bottom:1px solid #eee;}
.header{background:var(--green);padding:16px 32px;display:flex;align-items:center;gap:22px;}
.logo{font-size:24px;font-weight:800;color:#fff;display:flex;align-items:center;gap:2px;}
.logo svg{width:15px;height:15px;}
.header-title{color:#fff;font-weight:600;font-size:14.5px;opacity:.95;border-left:1px solid rgba(255,255,255,.4);padding-left:22px;}

.layout{display:grid;grid-template-columns:270px 1fr;gap:0;align-items:start;}
.sidebar{padding:24px 20px;border-right:1px solid var(--line);position:sticky;top:0;max-height:100vh;overflow-y:auto;}
.filter-title{font-size:11.5px;font-weight:800;letter-spacing:.04em;color:#9a9a97;margin-bottom:14px;}
#cat-tree{font-size:13.5px;}
.tree-all{font-weight:700;margin-bottom:12px;display:block;padding:6px 8px;border-radius:3px;}
.tree-all.active{background:var(--green-pale);color:var(--green-dark);}
.tree-parent{margin-bottom:2px;}
.tree-parent-row{display:flex;justify-content:space-between;align-items:center;padding:8px 8px;border-radius:3px;font-weight:600;color:var(--ink);}
.tree-parent-row:hover{background:var(--grey-bg);}
.tree-parent-row .count{color:#a3a3a0;font-weight:500;font-size:12px;}
.tree-parent-row.active-parent{color:var(--green-dark);}
.tree-subs{padding-left:14px;display:none;margin-bottom:6px;}
.tree-subs.open{display:block;}
.tree-sub-row{display:flex;justify-content:space-between;padding:6px 8px;border-radius:3px;font-size:13px;color:var(--ink-soft);}
.tree-sub-row:hover{background:var(--grey-bg);color:var(--ink);}
.tree-sub-row.active{background:var(--green-pale);color:var(--green-dark);font-weight:700;}
.tree-sub-row .count{color:#b3b3b0;font-size:11.5px;}
.chev{font-size:11px;color:#bbb;}

.content{padding:24px 32px 90px;min-width:0;}
.toolbar{display:flex;justify-content:space-between;align-items:center;gap:20px;margin-bottom:14px;flex-wrap:wrap;}
.search-wrap{flex:1;min-width:260px;max-width:460px;position:relative;}
.search-wrap input{width:100%;padding:10px 14px 10px 36px;border:1px solid #d8d8d5;border-radius:20px;font-size:13.5px;}
.search-icon{position:absolute;left:13px;top:9px;font-size:13px;opacity:.6;}
.toolbar-right{display:flex;align-items:center;gap:18px;font-size:13px;color:var(--ink-soft);}
.check-inline{display:flex;align-items:center;gap:6px;font-size:13px;}
.result-count{font-weight:600;color:var(--ink);}

.breadcrumb{font-size:13px;color:var(--ink-soft);margin-bottom:14px;}
.breadcrumb b{color:var(--ink);}

/* ---- Filter by brand dropdown ---- */
.dropdown{position:relative;}
.filter-btn{border:1px solid #d8d8d5;background:#fff;border-radius:20px;padding:9px 16px;font-size:13px;font-weight:600;color:var(--ink);display:flex;align-items:center;gap:4px;}
.filter-btn:hover{border-color:#bbb;}
#brand-filter-count{color:var(--green-dark);font-weight:800;}
.dropdown-panel{position:absolute;top:calc(100% + 8px);right:0;width:280px;background:#fff;border:1px solid var(--line);border-radius:8px;box-shadow:0 8px 24px rgba(0,0,0,.12);z-index:40;display:none;padding:12px;}
.dropdown-panel.open{display:block;}
.brand-search-input{width:100%;padding:8px 12px;border:1px solid #ddd;border-radius:16px;font-size:13px;margin-bottom:10px;}
.brand-list{max-height:220px;overflow-y:auto;display:flex;flex-direction:column;gap:2px;}
.brand-row{display:flex;align-items:center;gap:8px;padding:6px 6px;border-radius:4px;font-size:13px;cursor:pointer;}
.brand-row:hover{background:var(--grey-bg);}
.brand-row input{accent-color:var(--green-dark);}
.brand-row .bname{flex:1;}
.brand-row .bcount{color:#aaa;font-size:11.5px;}
.brand-empty{padding:16px 4px;color:#999;font-size:13px;text-align:center;}
.dropdown-actions{display:flex;justify-content:space-between;align-items:center;margin-top:10px;padding-top:10px;border-top:1px solid #eee;}
.dropdown-actions a{font-size:12.5px;font-weight:700;text-decoration:underline;color:var(--ink-soft);}
.btn-dark-sm{border:none;background:var(--ink);color:#fff;border-radius:16px;padding:7px 16px;font-weight:700;font-size:12.5px;}

.sort-select{border:1px solid #d8d8d5;border-radius:20px;padding:9px 14px;font-size:13px;font-weight:600;color:var(--ink);background:#fff;}

.active-filters{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:6px;}
.active-filters:empty{margin-bottom:0;}
.chip{display:flex;align-items:center;gap:6px;background:var(--green-pale);color:var(--green-dark);border-radius:14px;padding:5px 10px 5px 12px;font-size:12.5px;font-weight:600;}
.chip button{border:none;background:none;color:var(--green-dark);font-weight:800;font-size:13px;line-height:1;padding:0;}

.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:14px;}
.card{border:1px solid var(--line);border-radius:var(--radius);padding:12px;position:relative;background:#fff;display:flex;flex-direction:column;transition:border-color .12s;}
.card.selected{border-color:var(--green);box-shadow:0 0 0 1px var(--green);}
.card .cb{position:absolute;top:10px;left:10px;width:19px;height:19px;z-index:2;accent-color:var(--green-dark);cursor:pointer;}
.card .thumb{height:130px;border-radius:3px;background:var(--grey-bg);display:flex;align-items:center;justify-content:center;overflow:hidden;margin-bottom:10px;}
.card .thumb img{width:100%;height:100%;object-fit:contain;}
.card .brand{font-size:11px;color:var(--ink-soft);text-transform:uppercase;letter-spacing:.02em;margin-bottom:3px;}
.card .name{font-size:13px;font-weight:600;line-height:1.35;min-height:36px;margin-bottom:6px;}
.card .cat-tag{font-size:11px;color:#9a9a97;margin-top:auto;}
.card .pid{font-size:10.5px;color:#c2c2bf;margin-top:2px;}

.pagination{display:flex;justify-content:center;align-items:center;gap:8px;margin-top:26px;}
.pagination button{border:1px solid #ddd;background:#fff;border-radius:18px;padding:8px 16px;font-size:13px;font-weight:600;}
.pagination button:disabled{opacity:.35;cursor:default;}
.pagination span{font-size:13px;color:var(--ink-soft);padding:0 6px;}

.selection-bar{position:fixed;bottom:0;left:0;right:0;background:var(--ink);color:#fff;padding:14px 32px;display:flex;justify-content:space-between;align-items:center;transform:translateY(100%);transition:transform .2s ease;z-index:50;}
.selection-bar.show{transform:translateY(0);}
.selection-info{font-size:14px;}
.selection-info b{font-weight:800;}
.selection-info a{margin-left:14px;text-decoration:underline;font-weight:600;font-size:13px;cursor:pointer;}
.selection-actions{display:flex;gap:12px;}
.btn-outline{border:1px solid #fff;background:none;color:#fff;border-radius:20px;padding:9px 18px;font-weight:600;font-size:13.5px;}
.btn-dark{border:none;background:var(--green);color:#fff;border-radius:20px;padding:9px 20px;font-weight:700;font-size:13.5px;}
.btn-dark:disabled{background:#555;color:#999;}

.modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,.45);display:none;align-items:center;justify-content:center;z-index:100;}
.modal-overlay.show{display:flex;}
.modal{background:#fff;border-radius:6px;width:640px;max-width:92vw;max-height:82vh;display:flex;flex-direction:column;}
.modal-head{display:flex;justify-content:space-between;align-items:center;padding:18px 22px;border-bottom:1px solid #eee;}
.modal-head h3{margin:0;font-size:17px;font-weight:800;}
.modal-close{border:none;background:none;font-size:16px;color:#999;}
.modal-body{overflow-y:auto;padding:10px 22px;flex:1;}
.modal-row{display:flex;align-items:center;gap:12px;padding:10px 0;border-bottom:1px solid #f2f2f0;}
.modal-row img{width:44px;height:44px;object-fit:contain;background:var(--grey-bg);border-radius:3px;}
.modal-row .info{flex:1;font-size:13px;}
.modal-row .info b{display:block;font-size:13.5px;margin-bottom:2px;}
.modal-row .info span{color:#999;font-size:11.5px;}
.modal-row .remove{border:none;background:none;color:var(--red);font-size:13px;font-weight:600;}
.modal-foot{display:flex;justify-content:flex-end;gap:12px;padding:16px 22px;border-top:1px solid #eee;}
.modal-empty{padding:40px 0;text-align:center;color:#999;font-size:13.5px;}

.toast{position:fixed;top:20px;left:50%;transform:translateX(-50%) translateY(-120%);background:var(--ink);color:#fff;padding:12px 22px;border-radius:24px;font-size:13.5px;font-weight:600;transition:transform .25s ease;z-index:200;}
.toast.show{transform:translateX(-50%) translateY(0);}

@media(max-width:800px){
  .layout{grid-template-columns:1fr;}
  .sidebar{position:static;max-height:none;border-right:none;border-bottom:1px solid var(--line);}
  .content{padding:20px 16px 90px;}
  .header,.topbar{padding-left:16px;padding-right:16px;}
}
