
/* Chemical-Mandi R61 — fixed header with no top gap + dashboard alignment */
:root{--cm-r61-header-h:78px}

html,body{
  margin:0!important;
  padding:0!important;
  width:100%!important;
  max-width:100%!important;
  overflow-x:hidden!important;
}
body{
  padding-top:var(--cm-r61-header-h)!important;
  box-sizing:border-box!important;
}

/* Force the same header behavior across every page. */
body > header.topbar,
header.topbar,
.topbar{
  position:fixed!important;
  top:0!important;
  left:0!important;
  right:0!important;
  z-index:25000!important;
  min-height:var(--cm-r61-header-h)!important;
  height:var(--cm-r61-header-h)!important;
  margin:0!important;
  padding-top:0!important;
  padding-bottom:0!important;
  box-sizing:border-box!important;
  background:#fff!important;
  border-bottom:1px solid #e2e8f0!important;
  box-shadow:0 2px 12px rgba(15,23,42,.05)!important;
}
.topbar .brand,.topbar .main-nav,.topbar .top-actions,
.topbar .topbar-actions,.topbar .header-actions{
  min-width:0!important;
}
.topbar .main-nav{
  align-items:center!important;
}
.topbar + main,
body > main{
  margin-top:0!important;
}

/* Dashboard identity strip */
.cm-r61-dashboard-identity{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:10px 16px;
  margin:0 0 14px;
  border:1px solid #fed7aa;
  border-radius:12px;
  background:linear-gradient(90deg,#fff7ed,#fff);
  color:#334155;
}
.cm-r61-dashboard-identity strong{color:#172033}
.cm-r61-dashboard-identity .cm-r61-usid{
  display:inline-flex;
  padding:5px 9px;
  border-radius:999px;
  background:#eef4ff;
  color:#355d8f;
  font-weight:800;
  white-space:nowrap;
}

/* Compact clickable summary tiles */
.dashboard-kpis{
  display:grid!important;
  grid-template-columns:repeat(3,minmax(0,1fr))!important;
  gap:14px!important;
  align-items:stretch!important;
}
.dashboard-kpis > *{
  min-width:0!important;
  min-height:112px!important;
  max-height:128px!important;
  padding:14px 16px!important;
  box-sizing:border-box!important;
  border-radius:14px!important;
}
.dashboard-kpis .readonly-field,
.dashboard-bom-tile{
  cursor:pointer!important;
  transition:transform .15s ease,box-shadow .15s ease,border-color .15s ease!important;
}
.dashboard-kpis .readonly-field:hover,
.dashboard-bom-tile:hover{
  transform:translateY(-2px);
  box-shadow:0 10px 26px rgba(15,23,42,.10)!important;
  border-color:#fb923c!important;
}
.dashboard-kpis .readonly-field input{
  font-size:1.65rem!important;
  height:auto!important;
  padding:4px 0!important;
  border:0!important;
  background:transparent!important;
  color:#9a3412!important;
  -webkit-text-fill-color:#9a3412!important;
  opacity:1!important;
  font-weight:800!important;
}

/* Smaller, perfectly equal analytics cards. */
.dashboard-composition-grid{
  display:grid!important;
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
  gap:18px!important;
  align-items:stretch!important;
}
.dashboard-composition-panel{
  min-width:0!important;
  height:340px!important;
  max-height:340px!important;
  padding:16px!important;
  box-sizing:border-box!important;
  cursor:pointer!important;
  overflow:hidden!important;
  transition:transform .15s ease,box-shadow .15s ease,border-color .15s ease!important;
}
.dashboard-composition-panel:hover{
  transform:translateY(-2px);
  box-shadow:0 12px 28px rgba(15,23,42,.10)!important;
  border-color:#fb923c!important;
}
.dashboard-composition-panel .panel-header{margin-bottom:4px!important}
.dashboard-composition-panel .chemical-pie-layout{
  display:grid!important;
  grid-template-columns:minmax(190px,.8fr) minmax(180px,1fr)!important;
  align-items:center!important;
  gap:14px!important;
  height:250px!important;
  min-height:0!important;
}
.dashboard-composition-panel canvas{
  width:220px!important;
  height:220px!important;
  max-width:100%!important;
  max-height:220px!important;
  justify-self:center!important;
}
.dashboard-composition-panel .chemical-pie-legend{
  min-width:0!important;
  max-width:100%!important;
}

/* Live Mandi alert panels */
.cm-r61-mandi-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:18px;
  align-items:stretch;
  margin:18px 0;
}
.cm-r61-mandi-panel{
  min-width:0;
  height:760px;
  max-height:760px;
  overflow:hidden;
  display:flex;
  flex-direction:column;
  border:1px solid #fdba74;
  border-radius:16px;
  background:rgba(255,255,255,.92);
  box-sizing:border-box;
}
.cm-r61-mandi-head{
  flex:0 0 auto;
  padding:15px 17px 11px;
  border-bottom:1px solid #fed7aa;
}
.cm-r61-mandi-head p{margin:0 0 4px;color:#9a3412;font-size:.78rem;font-weight:900;text-transform:uppercase;letter-spacing:.06em}
.cm-r61-mandi-head h3{margin:0;color:#334155}
.cm-r61-mandi-list{
  min-height:0;
  flex:1 1 auto;
  overflow-y:auto;
  overflow-x:hidden;
  padding:10px;
  scrollbar-gutter:stable;
}
.cm-r61-alert-item{
  min-height:62px;
  box-sizing:border-box;
  border:1px solid #e2e8f0;
  border-radius:11px;
  padding:9px 10px;
  margin:0 0 8px;
  background:#fff;
}
.cm-r61-alert-item.unread{
  background:#e9fbea;
  border-color:#86d391;
}
.cm-r61-alert-item h4{margin:0 0 4px;color:#25364d;font-size:.94rem}
.cm-r61-alert-item p{
  margin:0 0 7px;
  color:#64748b;
  font-size:.82rem;
  line-height:1.25;
  overflow-wrap:anywhere;
}
.cm-r61-alert-actions{display:flex;gap:7px;align-items:center;flex-wrap:wrap}
.cm-r61-alert-actions a,.cm-r61-alert-actions button{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:30px;
  padding:5px 10px;
  border:1px solid #fb923c;
  border-radius:8px;
  background:#fff;
  color:#9a3412;
  font-weight:800;
  font-size:.78rem;
  text-decoration:none;
  cursor:pointer;
}
.cm-r61-alert-actions a.primary{background:#c2410c;color:#fff;border-color:#c2410c}
.cm-r61-alert-empty{padding:18px;color:#64748b}

/* Current Buy/Sell operational carts — equal and contained. */
.dashboard-cart-grid{
  display:grid!important;
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
  gap:18px!important;
}
.dashboard-cart-grid > .dashboard-panel{
  min-width:0!important;
  height:420px!important;
  max-height:420px!important;
  display:flex!important;
  flex-direction:column!important;
  overflow:hidden!important;
}
#dashboardBuyCart,#dashboardSellCart{
  min-height:0!important;
  flex:1 1 auto!important;
  overflow-y:auto!important;
  overflow-x:hidden!important;
  padding:0!important;
  align-content:start!important;
}
#dashboardBuyCart > *,#dashboardSellCart > *{
  width:100%!important;
  max-width:100%!important;
  min-width:0!important;
  box-sizing:border-box!important;
  margin:0 0 8px!important;
  overflow:hidden!important;
}
#dashboardBuyCart * ,#dashboardSellCart *{
  overflow-wrap:anywhere!important;
}

/* transaction history target highlight */
.cm-r61-history-highlight{
  outline:3px solid rgba(249,115,22,.28)!important;
  outline-offset:3px!important;
}

@media(max-width:980px){
  .cm-r61-mandi-grid,
  .dashboard-composition-grid,
  .dashboard-cart-grid{grid-template-columns:1fr!important}
  .cm-r61-mandi-panel{height:660px;max-height:660px}
  .dashboard-composition-panel{height:320px!important;max-height:320px!important}
}
@media(max-width:720px){
  :root{--cm-r61-header-h:70px}
  .dashboard-kpis{grid-template-columns:1fr!important}
  .dashboard-composition-panel .chemical-pie-layout{
    grid-template-columns:1fr!important;
    height:235px!important;
  }
  .dashboard-composition-panel canvas{
    width:170px!important;height:170px!important;max-height:170px!important;
  }
  .dashboard-composition-panel .chemical-pie-legend{display:none!important}
  .cm-r61-mandi-panel{height:620px;max-height:620px}
  .cm-r61-dashboard-identity{align-items:flex-start;flex-direction:column}
}
