/* XLUX Library — dense, dark, modern admin. Curator throughput over consumer gloss (D7). */
:root {
  --bg: #0c0d0f; --surface: #161719; --surface2: #1d1f22; --surface3: #26282c;
  --border: rgba(255,255,255,.08); --border2: rgba(255,255,255,.14);
  --text: #e8e9eb; --text2: rgba(232,233,235,.62); --text3: rgba(232,233,235,.34);
  --accent: #2e90fa; --ok: #12b76a; --warn: #f79009; --danger: #f04438;
  --zigbee: #f04438; --dmx: #2e90fa; --dali: #a855f7; --wled: #eab308; --cloud: #22d3ee;
  --row: 34px; --radius: 10px;
  font-synthesis: none; -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
}
b { font-weight: 650; }
button, input, select { font: inherit; color: inherit; }

/* ── topbar ── */
.topbar { display: flex; align-items: center; gap: 18px; padding: 0 16px; height: 52px;
  background: var(--surface); border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.brand { font-size: 15px; font-weight: 500; letter-spacing: .2px; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.brand b { font-weight: 700; }
.brand-mark { width: 14px; height: 14px; border-radius: 4px; background: linear-gradient(135deg, var(--accent), var(--dali)); box-shadow: 0 0 12px rgba(46,144,250,.5); }
.brand-logo { width: 23px; height: 23px; display: inline-block; background: currentColor; flex: 0 0 auto;
  -webkit-mask: url(/logo.svg) no-repeat center / contain; mask: url(/logo.svg) no-repeat center / contain; }
.kpis { display: flex; gap: 8px; flex: 1 1 auto; overflow-x: auto; scrollbar-width: none; }
.kpis::-webkit-scrollbar { display: none; }
.kpi { display: flex; flex-direction: column; padding: 4px 11px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 8px; white-space: nowrap; }
.kpi .v { font-size: 15px; font-weight: 680; letter-spacing: .3px; }
.kpi .l { font-size: 10.5px; color: var(--text3); text-transform: uppercase; letter-spacing: .5px; }
.kpi .v small { font-size: 11px; color: var(--text3); font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.whoami { font-size: 12px; color: var(--text2); }
.ghost-btn { background: var(--surface2); border: 1px solid var(--border); color: var(--text2);
  border-radius: 7px; padding: 5px 9px; cursor: pointer; font-size: 12px; }
.ghost-btn:hover { color: var(--text); border-color: var(--border2); }

/* ── toolbar ── */
.toolbar { display: flex; align-items: center; gap: 8px; padding: 9px 16px; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.search-wrap { position: relative; flex: 1 1 260px; min-width: 200px; }
.search-wrap input { width: 100%; height: 32px; padding: 0 12px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 8px; outline: none; }
.search-wrap input:focus { border-color: var(--accent); }
.sel { height: 32px; max-width: 190px; padding: 0 26px 0 10px; background: var(--surface2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center;
  border: 1px solid var(--border); border-radius: 8px; -webkit-appearance: none; appearance: none; cursor: pointer; color: var(--text2); }
.sel:hover { color: var(--text); }
.seg { display: flex; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--text2); padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; display: flex; align-items: center; gap: 5px; }
.seg button.is-on { background: var(--surface3); color: var(--text); }
.seg button .cnt { color: var(--text3); font-size: 11px; }
.seg button .pdot { width: 7px; height: 7px; border-radius: 50%; }
.spacer { flex: 1 1 auto; }
.viewtoggle { display: flex; gap: 2px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.vt { width: 30px; height: 26px; border: 0; background: transparent; color: var(--text3); border-radius: 6px; cursor: pointer; display: grid; place-items: center; }
.vt.is-on { background: var(--surface3); color: var(--text); }

.result-info { padding: 7px 16px; color: var(--text3); font-size: 12px; flex: 0 0 auto; border-bottom: 1px solid var(--border); }
.results { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; }

/* ── table view ── */
.table-view { display: block; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--text3);
  padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl tbody tr { height: var(--row); border-bottom: 1px solid rgba(255,255,255,.045); cursor: pointer; }
.tbl tbody tr:hover { background: rgba(255,255,255,.035); }
.tbl td { padding: 0 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; }
.tbl td.name { color: var(--text); font-weight: 500; }
.tbl td.dim { color: var(--text2); }
.thumb { width: 26px; height: 26px; border-radius: 6px; object-fit: contain; background: var(--surface2); vertical-align: middle; }
.thumb.ph { display: inline-grid; place-items: center; color: var(--text3); }

/* ── grid view ── */
.grid-view { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 10px; padding: 14px 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: border-color .12s; }
.card:hover { border-color: var(--border2); }
/* Photo tile is ALWAYS 1:1. The img fills the square and object-fit:contain centers the whole
   product without cropping. Catalog photos are shot on white → white tile background for them. */
.card .ph { aspect-ratio: 1 / 1; display: grid; place-items: center; background: var(--surface2); overflow: hidden; }
.card .ph.has-img { background: #fff; }
.card .ph img { width: 100%; height: 100%; object-fit: contain; object-position: center; padding: 9px; }
.card .ph .noimg { color: var(--text3); display: grid; place-items: center; }
.card .ph .noimg svg { opacity: .45; }
.card .meta { padding: 8px 10px; }
.card .meta .nm { font-weight: 550; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta .vn { color: var(--text2); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta .row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }

/* ── badges/chips ── */
.pdot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.proto-dali { background: var(--dali);} .proto-zigbee { background: var(--zigbee);} .proto-dmx { background: var(--dmx);} .proto-wled { background: var(--wled);}
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 1px 7px; border-radius: 5px; background: var(--surface2); color: var(--text2); border: 1px solid var(--border); }
.caps { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.cap { font-size: 10px; padding: 0 5px; border-radius: 4px; background: var(--surface3); color: var(--text2); line-height: 16px; }
.trust { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; }
.trust .b { width: 8px; height: 8px; border-radius: 50%; }
.t3 { background: var(--ok);} .t2 { background: var(--accent);} .t1 { background: var(--warn);} .t0 { background: var(--danger);}

/* ── drawer ── */
.drawer { position: fixed; inset: 0; z-index: 40; }
.drawer[hidden] { display: none; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(2px); }
.drawer-panel { position: absolute; top: 0; right: 0; height: 100%; width: min(560px, 94vw); background: var(--surface);
  border-left: 1px solid var(--border2); overflow-y: auto; box-shadow: -20px 0 50px rgba(0,0,0,.4); animation: slidein .16s ease; }
@keyframes slidein { from { transform: translateX(30px); opacity: .4; } }
.dw { padding: 18px 20px; }
.dw-head { display: flex; gap: 12px; align-items: flex-start; }
.dw-head .thumb-lg { width: 72px; height: 72px; border-radius: 10px; object-fit: contain; background: var(--surface2); flex: 0 0 auto; }
.dw-head h2 { margin: 0 0 3px; font-size: 17px; }
.dw-head .sub { color: var(--text2); font-size: 12.5px; }
.dw-close { position: absolute; top: 12px; right: 14px; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text2); cursor: pointer; display: grid; place-items: center; }
.dw-close:hover { color: var(--text); }
.dw section { margin-top: 18px; }
.dw h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text3); margin: 0 0 8px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 12px; font-size: 12.5px; }
.kv dt { color: var(--text2); } .kv dd { margin: 0; word-break: break-word; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.ev-tbl, .prof-tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.ev-tbl td, .prof-tbl td, .prof-tbl th { padding: 4px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.ev-verified { color: var(--ok); } .ev-code { color: var(--accent); } .ev-derived { color: var(--warn); }
details.raw { margin-top: 16px; } details.raw summary { cursor: pointer; color: var(--text3); font-size: 12px; }
pre.json { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; font-size: 11.5px; line-height: 1.5; color: var(--text2); max-height: 360px; }

/* ── spinner ── */
.spinner { display: flex; gap: 6px; justify-content: center; padding: 18px; }
.spinner[hidden] { display: none; }
.spinner .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: bounce 1s infinite ease-in-out; }
.spinner .dot:nth-child(2) { animation-delay: .15s; } .spinner .dot:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,80%,100% { opacity: .25; transform: translateY(0);} 40% { opacity: 1; transform: translateY(-5px);} }
.sentinel { height: 1px; }
.empty { text-align: center; color: var(--text3); padding: 60px 20px; }

/* ── login landing (premium) ── */
.login-screen { position: fixed; inset: 0; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(46,144,250,.10), transparent 60%), var(--bg); }
.login-orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .5; pointer-events: none; }
.login-orb.o1 { width: 460px; height: 460px; background: var(--accent); top: -140px; left: -90px; animation: orb1 16s ease-in-out infinite; }
.login-orb.o2 { width: 420px; height: 420px; background: var(--dali); bottom: -150px; right: -80px; animation: orb2 19s ease-in-out infinite; }
.login-orb.o3 { width: 300px; height: 300px; background: var(--cloud); top: 40%; left: 55%; opacity: .28; animation: orb1 22s ease-in-out infinite reverse; }
@keyframes orb1 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(50px,40px) scale(1.08); } }
@keyframes orb2 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-40px,-50px) scale(1.1); } }
.login-card { position: relative; z-index: 1; text-align: center; width: min(400px, 92vw); padding: 46px 44px 30px;
  background: rgba(22,23,26,.72); backdrop-filter: blur(22px) saturate(1.2); -webkit-backdrop-filter: blur(22px) saturate(1.2);
  border: 1px solid rgba(255,255,255,.10); border-radius: 22px;
  box-shadow: 0 30px 90px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.07); }
.login-mark { width: 58px; height: 58px; border-radius: 17px; margin: 0 auto 22px; display: grid; place-items: center;
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--dali)); box-shadow: 0 10px 34px rgba(46,144,250,.5); }
.login-logo { width: 34px; height: 34px; display: block; background: currentColor;
  -webkit-mask: url(/logo.svg) no-repeat center / contain; mask: url(/logo.svg) no-repeat center / contain; }
.login-title { font-size: 25px; font-weight: 300; letter-spacing: .3px; }
.login-title b { font-weight: 700; }
.login-sub { color: var(--text2); margin: 7px 0 30px; font-size: 13.5px; }
.login-btn { width: 100%; padding: 13px; font-size: 14.5px; font-weight: 650; border-radius: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 9px; color: #fff; border: 0;
  background: linear-gradient(135deg, var(--accent), #57a8ff); box-shadow: 0 10px 26px rgba(46,144,250,.4);
  transition: transform .12s ease, box-shadow .12s ease; }
.login-btn:hover { transform: translateY(-1px); box-shadow: 0 14px 32px rgba(46,144,250,.5); }
.login-btn:active { transform: translateY(0); }
.login-hint { color: var(--text3); font-size: 11.5px; margin-top: 20px; line-height: 1.6; }
.login-hint b { color: var(--text2); font-weight: 600; }
.login-foot { color: var(--text3); font-size: 11px; margin-top: 26px; opacity: .6; letter-spacing: .2px; }

/* ── drawer edit ── */
.dw-actions { display: flex; gap: 8px; margin-top: 14px; }
.btn-sm { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border2); background: var(--surface2); color: var(--text); cursor: pointer; font-size: 12.5px; }
.btn-sm:hover { border-color: var(--accent); }
.btn-sm.on { background: rgba(18,183,106,.14); border-color: var(--ok); color: var(--ok); }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text2); }
.form input, .form textarea, .form select { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; color: var(--text); font-size: 13px; outline: none; }
.form input:focus, .form textarea:focus, .form select:focus { border-color: var(--accent); }
.form textarea { resize: vertical; }
.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 0; }
.form legend { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: .5px; padding: 0 4px; }
.chk-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px 10px; }
.form .chk { flex-direction: row; align-items: center; gap: 6px; color: var(--text); cursor: pointer; }
.form .chk input { width: 15px; height: 15px; accent-color: var(--accent); }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }
.btn-primary { background: #fff; color: #000; border: 0; border-radius: 10px; padding: 9px 18px; font-weight: 650; cursor: pointer; font-size: 13px; }
.btn-primary:hover { opacity: .9; }
.btn-ghost { background: var(--surface2); color: var(--text2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 16px; cursor: pointer; }
.edit-err { color: var(--danger); font-size: 12px; margin-top: 10px; min-height: 1px; }

/* ── photo curation ── */
.photo-cur { display: flex; gap: 12px; align-items: flex-start; }
.cur-photo { width: 84px; height: 84px; flex: 0 0 auto; border-radius: 10px; background: var(--surface2); display: grid; place-items: center; overflow: hidden; color: var(--text3); }
.cur-photo.has-img { background: #fff; }
.cur-photo img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.photo-actions { flex: 1 1 auto; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.photo-actions input { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; color: var(--text); outline: none; }
.photo-actions input:focus { border-color: var(--accent); }
.pa-row { display: flex; gap: 8px; flex-wrap: wrap; }
a.btn-sm { text-decoration: none; display: inline-flex; align-items: center; }

/* ── freistellen (cutout) ── */
.card .ph { position: relative; }
.cut-btn { position: absolute; right: 6px; bottom: 6px; width: 26px; height: 26px; border-radius: 8px;
  border: 1px solid var(--border2); background: rgba(18,18,20,.82); color: #fff; cursor: pointer;
  display: grid; place-items: center; font-size: 13px; line-height: 1; backdrop-filter: blur(4px); z-index: 2; }
.cut-btn:hover { background: var(--accent); border-color: var(--accent); }
.cut-btn:disabled, .cut-btn.busy { opacity: .55; cursor: default; }
#cutoutToggle.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── bulk bar ── */
.bulkbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 20px; z-index: 30;
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; max-width: 94vw; flex-wrap: wrap;
  background: var(--surface3); border: 1px solid var(--border2); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.bulkbar[hidden] { display: none; }
.bulkbar .spacer { flex: 1 1 20px; }
.bb-count { font-weight: 650; font-size: 13px; white-space: nowrap; }
.bb-msg { color: var(--danger); font-size: 12px; }
.tbl .selcell { width: 30px; padding: 0 4px 0 12px; text-align: center; }
.tbl .selcell input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }

/* ── nav + stats view ── */
.nav button { font-weight: 500; }
.stats-view { flex: 1 1 auto; overflow-y: auto; padding: 18px 16px 60px; }
/* [hidden] must beat class display (.toolbar=flex, .table-view/.grid-view=block/grid) */
.stats-view[hidden], .toolbar[hidden], .results[hidden], .result-info[hidden], .sentinel[hidden] { display: none; }
.stats-wrap { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 12px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.sc-v { font-size: 23px; font-weight: 700; letter-spacing: .3px; }
.sc-l { font-size: 12px; color: var(--text2); margin-top: 2px; }
.sc-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }
.stat-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stat-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.stat-panel h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text3); margin: 0 0 12px; }
.stat-bar { display: grid; grid-template-columns: 155px 1fr 58px; align-items: center; gap: 10px; margin-bottom: 7px; font-size: 12px; }
.sb-label { color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-track { height: 8px; background: var(--surface3); border-radius: 5px; overflow: hidden; }
.sb-fill { height: 100%; border-radius: 5px; min-width: 2px; }
.sb-n { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.gap-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; }
.gap-card { text-align: left; background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; cursor: pointer; color: var(--text); transition: border-color .12s; }
.gap-card:hover { border-color: var(--accent); }
.gc-n { font-size: 20px; font-weight: 700; color: var(--warn); }
.gc-l { font-size: 12px; color: var(--text2); margin-top: 2px; }
.pub-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
@media (max-width: 820px) { .stat-cols { grid-template-columns: 1fr; } }
