:root{
  --bg:#0b0c10;
  --card:#11131a;
  --muted:#9aa3b2;
  --text:#eef1f6;
  --line:#23283a;
  --accent:#7c5cff;
  --warn:#f59e0b;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 20% 0%, #14162b, var(--bg));
  color:var(--text);
}
.topbar{
  position:sticky; top:0; z-index:10;
  display:flex; gap:16px; align-items:center; justify-content:space-between;
  padding:14px 18px;
  background: rgba(10,11,16,.8);
  backdrop-filter: blur(10px);
  border-bottom:1px solid var(--line);
}
.brand{display:flex; gap:12px; align-items:center}
.logo{
  width:42px; height:42px; border-radius:14px;
  display:grid; place-items:center;
  background: linear-gradient(135deg, var(--accent), #2dd4bf);
  color:#0b0c10; font-weight:800; letter-spacing:.5px;
}
.title{font-weight:700}
.subtitle{font-size:12px; color:var(--muted); margin-top:2px}
.wrap{max-width:1180px; margin:18px auto; padding:0 16px 40px}
.card{
  background: rgba(17,19,26,.9);
  border:1px solid var(--line);
  border-radius:18px;
  padding:16px 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
  margin:14px 0;
}
.card h2{margin:0 0 12px; font-size:15px}
.row{display:flex; gap:12px; align-items:center; flex-wrap:wrap}
.meta{color:var(--muted); font-size:13px}
.hint{color:var(--muted); font-size:12px; margin-top:8px}
.mono{font-family: ui-monospace, Menlo, Consolas, monospace}
.grid2{display:grid; grid-template-columns:1.2fr 1fr; gap:12px}
.grid3{display:grid; grid-template-columns:1fr 1fr 1fr; gap:12px}
@media (max-width: 980px){
  .grid2,.grid3{grid-template-columns:1fr}
}
.field{
  display:flex; flex-direction:column; gap:6px;
  padding:10px; border:1px solid var(--line); border-radius:14px;
  background: rgba(255,255,255,.02);
}
.field span{font-size:12px; color:var(--muted)}
.field input,.field select{
  width:100%;
  padding:10px 10px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.25);
  color:var(--text);
  outline:none;
}
.field small{color:var(--muted); font-size:11px}
.inline{display:flex; gap:8px}
.inline select{width:42%}
.inline input{width:58%}

.toolbar{
  display:flex; align-items:center; justify-content:space-between;
  gap:12px; margin-top:12px; flex-wrap:wrap;
}
.left,.right{display:flex; gap:10px; align-items:center; flex-wrap:wrap}

.btn{
  padding:10px 14px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
  color:var(--text);
  cursor:pointer;
}
.btn.primary{
  border-color: rgba(124,92,255,.7);
  background: rgba(124,92,255,.18);
}
.btn.ghost{background: transparent}
.btn:disabled{opacity:.45; cursor:not-allowed}

.tableWrap{
  border:1px solid var(--line);
  border-radius:14px;
  overflow:auto;
  max-height: 62vh;
  background: rgba(0,0,0,.14);
}
table{
  width:100%;
  border-collapse:collapse;
  min-width: 980px;
}
thead th{
  position: sticky;
  top: 0;
  background: rgba(17,19,26,.98);
  border-bottom:1px solid var(--line);
  font-size:12px;
  color:var(--muted);
  text-align:left;
  padding:10px 10px;
  white-space:nowrap;
}
tbody td{
  border-bottom:1px solid rgba(255,255,255,.06);
  padding:9px 10px;
  font-size:13px;
  vertical-align:top;
  white-space:nowrap;
}
tbody tr:hover{background: rgba(124,92,255,.08)}
tbody tr.selected{background: rgba(34,197,94,.10)}
.cellWrap{max-width:380px; overflow:hidden; text-overflow:ellipsis}

.qty{
  width:72px;
  padding:7px 8px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.25);
  color:var(--text);
}

.pager{
  display:flex; justify-content:space-between; align-items:center;
  gap:12px; flex-wrap:wrap;
  margin-top:12px;
}
.pagerLeft,.pagerRight{display:flex; gap:10px; align-items:center; flex-wrap:wrap}
.chip{
  display:inline-flex; align-items:center; justify-content:center;
  min-width:38px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.20);
  font-size:12px;
}
.status{
  margin-top:12px;
  padding:12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.22);
  font-size:13px;
}
.warn{
  margin-top:10px;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(245,158,11,.35);
  background: rgba(245,158,11,.10);
  color:#ffd79a;
  font-size:13px;
}
.foot{display:flex; justify-content:space-between; gap:10px; margin-top:16px; color:var(--muted); font-size:12px}

/* Tabs */
.tabs{display:flex; gap:10px; margin:10px 0 16px}
.tab{
  padding:10px 14px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.03);
  color:var(--text);
  cursor:pointer;
}
.tab.active{
  border-color: rgba(124,92,255,.7);
  background: rgba(124,92,255,.18);
}
.panel{display:none}
.panel.active{display:block}

/* Compare KPIs */
.grid4{display:grid; grid-template-columns:repeat(4,1fr); gap:12px}
@media (max-width: 980px){ .grid4{grid-template-columns:repeat(2,1fr)} }
.kpi{
  padding:12px;
  border-radius:16px;
  border:1px solid var(--line);
  background: rgba(0,0,0,.18);
}
.kpiTitle{font-size:12px; color:var(--muted)}
.kpiVal{font-size:22px; font-weight:800; margin-top:6px}

/* Labels (Avery 5167) */
.labelPreviewWrap{ overflow:auto; border:1px solid var(--line); border-radius:16px; padding:12px; background: rgba(0,0,0,.12); }
.labelSheet{
  width: 8.5in;
  height: 11in;
  background: rgba(255,255,255,.04);
  border: 1px dashed rgba(255,255,255,.18);
  position: relative;
  transform-origin: top left;
}
.labelGrid{
  position:absolute;
  left: 0.25in;  /* Left margin */
  top: 0.5in;    /* Top margin */
  width: 8.0in;
  height: 10.0in;
  display:grid;
  grid-template-columns: repeat(4, 1.75in);
  grid-template-rows: repeat(20, 0.5in);
  column-gap: 0.333333in;
  row-gap: 0in;
}
.labelCell{
  box-sizing:border-box;
  padding: 0.06in 0.08in;
  overflow:hidden;
  display:flex;
  align-items:center;
}
.labelText{
  font-weight:700;
  line-height:1.05;
  white-space:pre-line;
}

/* Labels alignment + barcode */
.labelCell{ justify-content:center; }
.labelText{ text-align:center; width:100%; display:flex; flex-direction:column; gap:2px; }
.labelLine{ font-family: Arial, sans-serif; }
.labelBarcode{ font-family: "Libre Barcode 128", "Libre Barcode 128 Text", monospace; line-height:1; }

/* Designer */
.designerWrap{ overflow:auto; border:1px solid var(--line); border-radius:16px; padding:12px; background: rgba(0,0,0,.12); }
.desCanvas{
  width: 1.75in; height: 0.5in;  /* will be set dynamically */
  position: relative;
  border: 1px dashed rgba(255,255,255,.28);
  background: rgba(255,255,255,.03);
}
.desItem{
  position:absolute;
  border:1px solid rgba(124,92,255,.55);
  border-radius:10px;
  background: rgba(124,92,255,.10);
  cursor: move;
  user-select:none;
  padding:2px 4px;
  box-sizing:border-box;
}
.desItem.sel{
  outline:2px solid rgba(124,92,255,.9);
}
.desItem .resize{
  position:absolute;
  width:10px; height:10px;
  right:-4px; bottom:-4px;
  border-radius:4px;
  background: rgba(124,92,255,.9);
  cursor: nwse-resize;
}
.desItem .txt{
  font-weight:700;
  line-height:1.05;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

/* Modal for Designer */
.modal{ position:fixed; inset:0; z-index:9999; display:flex; align-items:center; justify-content:center; padding:24px; }
.modalBackdrop{ position:absolute; inset:0; background: rgba(0,0,0,.65); backdrop-filter: blur(6px); }
.modalPanel{ position:relative; z-index:1; width:min(1100px, 96vw); max-height: 90vh; overflow:hidden; border-radius:24px;
  border:1px solid var(--line); background: rgba(20,20,26,.95); box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
.modalHead{ display:flex; align-items:center; justify-content:space-between; padding:14px 16px; border-bottom:1px solid var(--line); }
.modalBody{ padding:16px; overflow:auto; max-height: calc(90vh - 54px); }
.designerWrap.big{ padding:16px; }
.desHost{ display:flex; align-items:flex-start; justify-content:flex-start; }

.modalBackdrop{ pointer-events:auto; }
.modalPanel{ pointer-events:auto; }

.modalHead .btn{ padding:8px 12px; }

/* Ensure hidden modal is not displayed */
.modal[hidden]{ display:none !important; }

/* Multi Lookup results layout */
.mlResults{ overflow-x:auto; padding-bottom:6px; }
.mlResults .grid3{ grid-template-columns: repeat(3, minmax(320px, 1fr)); }
@media (max-width: 1200px){
  .mlResults .grid3{ grid-template-columns: repeat(3, minmax(340px, 1fr)); }
}
@media (max-width: 900px){
  .mlResults .grid3{ grid-template-columns: 1fr; }
  .mlResults{ overflow-x:visible; }
}

/* Full-width layout */
.container, .wrap, .page, .main, .app, .shell{
  max-width:none !important;
  width:100% !important;
}

/* Enterprise UI: popover */
.mlPopover{
  position: fixed;
  z-index: 9999;
  max-width: 560px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(20,20,24,.92);
  color: var(--text);
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
  pointer-events: none;
  white-space: pre-wrap;
  line-height: 1.25;
  font-size: 13px;
}

/* Name clamp: 2 lines, keep full text via hover/click */
.mlName{
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Multi lookup table stability */
#panelMulti .table{ table-layout: fixed; width: 100%; }
#panelMulti .table th:nth-child(1), #panelMulti .table td:nth-child(1){ width: 24%; }
#panelMulti .table th:nth-child(3), #panelMulti .table td:nth-child(3){ width: 18%; }
#panelMulti .table th:nth-child(2), #panelMulti .table td:nth-child(2){ width: auto; }
#panelMulti .table td{ vertical-align: top; }
#panelMulti .table td, #panelMulti .table th{ word-break: break-word; }

.mlRowHover td{ outline: 1px solid rgba(150,150,255,.45); }
.mlRowSelected td{ outline: 2px solid rgba(150,150,255,.75); }

/* Drawer */
.mlDrawer{
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(520px, 92vw);
  z-index: 9998;
  background: rgba(12,12,14,.98);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 48px rgba(0,0,0,.5);
  display: flex;
  flex-direction: column;
}
.mlDrawer[hidden]{ display:none !important; }
.mlDrawerHead{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.mlDrawerTitle{ font-size: 16px; font-weight: 700; }
.mlDrawerSub{ font-size: 12px; opacity: .75; margin-top: 2px; }
.mlDrawerBody{ padding: 16px; overflow:auto; }
.mlDrawerGrid{ display:grid; grid-template-columns: 1fr; gap: 12px; }
.mlDrawerCard{
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.03);
}
.mlDrawerCardHead{ font-weight: 700; margin-bottom: 8px; }
.mlDrawerRow{ display:flex; gap: 10px; margin: 6px 0; }
.mlDrawerRow .k{ width: 64px; opacity: .7; }
.mlDrawerRow .v{ flex:1; word-break: break-word; }
.mlDrawerActions{ display:flex; gap:10px; margin-top: 14px; }
