/* Dashboard refinement — scoped only to #dashboard */
#dashboard{
  gap:18px;
}

/* Preserve the app tab system: dashboard must exist only when selected. */
#dashboard.tab:not(.active){
  display:none !important;
}

#dashboard.tab.active{
  display:grid;
}

#dashboard .grid4{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:14px;
}

#dashboard .grid4 + .grid4{
  margin-top:0 !important;
}

#dashboard .cols{
  display:grid;
  grid-template-columns:minmax(0,1.15fr) minmax(320px,.85fr);
  gap:14px;
  margin-top:0;
}

#dashboard .card{
  position:relative;
  min-width:0;
  padding:18px;
  overflow:hidden;
  border:1px solid #e2eaf5;
  border-radius:18px;
  background:#fff;
  box-shadow:0 8px 24px rgba(6,52,130,.055);
}

#dashboard .grid4 > .card{
  min-height:158px;
  display:flex;
  flex-direction:column;
  justify-content:flex-start;
}

#dashboard .grid4 > .card::before{
  content:"";
  position:absolute;
  left:0;
  right:0;
  top:0;
  height:4px;
  background:#c8d6ea;
}

#dashboard .grid4:first-of-type > .card:nth-child(1)::before,
#dashboard .grid4:first-of-type > .card:nth-child(4)::before{
  background:#0865F5;
}

#dashboard .grid4:first-of-type > .card:nth-child(2)::before{
  background:#e0a128;
}

#dashboard .grid4:first-of-type > .card:nth-child(3)::before,
#dashboard .grid4:nth-of-type(2) > .card:nth-child(1)::before{
  background:#d85a67;
}

#dashboard .grid4:nth-of-type(2) > .card:nth-child(2)::before{
  background:#0752C7;
}

#dashboard .kpiLabel{
  margin:2px 0 13px;
  color:#6f7f9f;
  font-size:11px;
  line-height:1.25;
  font-weight:800;
  letter-spacing:.055em;
}

#dashboard .kpiValue{
  margin:0;
  color:#063482;
  font-size:clamp(30px,3vw,40px);
  line-height:1;
  font-weight:850;
  letter-spacing:-.045em;
}

#dashboard .kpiSub,
#dashboard .metricNote{
  margin-top:auto;
  padding-top:14px;
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  gap:10px;
  color:#73829d;
  font-size:11px;
  line-height:1.45;
  font-weight:600;
}

#dashboard .kpiSub.ok{color:#2d7b5d}
#dashboard .kpiSub.warn{color:#a66c00}
#dashboard .kpiSub.danger{color:#b84b58}

#dashboard .dashboardDrillCard{
  transition:border-color .16s ease,box-shadow .16s ease,transform .16s ease;
}

#dashboard .dashboardDrillCard:hover{
  transform:translateY(-2px);
  border-color:#c7d8ef;
  box-shadow:0 14px 34px rgba(6,52,130,.09);
}

#dashboard .dashboardDrillHint{
  display:inline-flex !important;
  align-items:center;
  justify-content:center;
  width:auto;
  max-width:100%;
  margin-top:0 !important;
  padding:7px 10px;
  border:1px solid #d8e6f8;
  border-radius:9px;
  background:#f5f9ff;
  color:#0752C7 !important;
  font-size:10px !important;
  line-height:1;
  font-weight:800 !important;
  text-decoration:none;
  letter-spacing:0 !important;
  white-space:nowrap;
}

#dashboard .dashboardDrillCard:hover .dashboardDrillHint{
  border-color:#c4d9f5;
  background:#edf5ff;
}

#dashboard .cols > .card{
  padding:19px 20px 16px;
}

#dashboard .panelTitle{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:8px;
  padding-bottom:13px;
  border-bottom:1px solid #edf2f8;
}

#dashboard .panelTitle h3{
  margin:0;
  color:#063482;
  font-size:15px;
  line-height:1.25;
  font-weight:800;
  letter-spacing:-.015em;
}

#dashboard .pill{
  padding:5px 9px;
  border:1px solid #d7e4f6;
  background:#f3f8ff;
  color:#0752C7;
  font-size:10px;
  font-weight:800;
}

#dashboard .pill.red{
  border-color:#f0d1d6;
  background:#fff5f6;
  color:#b84b58;
}

#dashboard .list{
  display:grid;
}

#dashboard .row{
  min-height:46px;
  padding:12px 2px;
  border-bottom:1px solid #eef3f9;
  color:#5d6e89;
  font-size:12.5px;
}

#dashboard .row:last-child{
  border-bottom:0;
}

#dashboard .row strong{
  color:#063482;
  font-weight:800;
}

#dashboard .row strong.danger{
  color:#b84b58;
}

#dashboard .empty{
  color:#7a89a2;
}

@media(max-width:1120px){
  #dashboard .grid4{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}

@media(max-width:850px){
  #dashboard .cols{
    grid-template-columns:1fr;
  }
}

@media(max-width:620px){
  #dashboard{
    gap:14px;
  }

  #dashboard .grid4{
    grid-template-columns:1fr;
  }

  #dashboard .grid4 > .card{
    min-height:132px;
  }

  #dashboard .card{
    border-radius:15px;
    padding:16px;
  }

  #dashboard .kpiValue{
    font-size:34px;
  }

  #dashboard .dashboardDrillCard:hover{
    transform:none;
  }
}


/* Expiry planning — 30 day preventive view */
#dashboard .expiryDashboardCard{
  margin-top:0;
}

#dashboard .expirySummary{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:10px;
  margin:2px 0 18px;
}

#dashboard .expirySummaryItem{
  min-width:0;
  padding:12px 13px;
  border:1px solid #e4ebf5;
  border-radius:12px;
  background:#f8fbff;
}

#dashboard .expirySummaryItem strong{
  display:block;
  margin-bottom:5px;
  color:#063482;
  font-size:22px;
  line-height:1;
}

#dashboard .expirySummaryItem span{
  color:#6f7f9f;
  font-size:11px;
  line-height:1.35;
  font-weight:750;
}

#dashboard .expirySummaryItem.expired{
  border-color:#f0cdd3;
  background:#fff6f7;
}

#dashboard .expirySummaryItem.urgent{
  border-color:#f1d5d5;
  background:#fff8f8;
}

#dashboard .expirySummaryItem.attention{
  border-color:#f2dfb9;
  background:#fffaf0;
}

#dashboard .expirySummaryItem.planning{
  border-color:#d6e4f7;
  background:#f5f9ff;
}

#dashboard .expiryList{
  display:grid;
  gap:14px;
}

#dashboard .expiryGroup{
  overflow:hidden;
  border:1px solid #e7edf6;
  border-radius:13px;
  background:#fff;
}

#dashboard .expiryGroupTitle{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  border-bottom:1px solid #edf2f8;
  background:#fbfdff;
}

#dashboard .expiryGroupTitle > strong{
  color:#6f7f9f;
  font-size:12px;
}

#dashboard .expiryGroupBadge{
  display:inline-flex;
  align-items:center;
  padding:5px 8px;
  border-radius:999px;
  font-size:10px;
  line-height:1;
  font-weight:850;
}

#dashboard .expiryGroupBadge.expired,
#dashboard .expiryStatus.expired{
  background:#fff0f2;
  color:#b63f51;
}

#dashboard .expiryGroupBadge.urgent,
#dashboard .expiryStatus.urgent{
  background:#fff4f3;
  color:#b65245;
}

#dashboard .expiryGroupBadge.attention,
#dashboard .expiryStatus.attention{
  background:#fff7e8;
  color:#9a6500;
}

#dashboard .expiryGroupBadge.planning,
#dashboard .expiryStatus.planning{
  background:#eef5ff;
  color:#0752C7;
}

#dashboard .expiryRow{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  align-items:center;
  gap:14px;
  padding:12px;
  border-bottom:1px solid #eef3f9;
}

#dashboard .expiryRow:last-child{
  border-bottom:0;
}

#dashboard .expiryProduct{
  min-width:0;
}

#dashboard .expiryProduct > strong{
  display:block;
  overflow:hidden;
  color:#17345f;
  font-size:12.5px;
  text-overflow:ellipsis;
  white-space:nowrap;
}

#dashboard .expiryProduct > small{
  display:block;
  margin-top:4px;
  color:#7a89a2;
  font-size:10.5px;
  line-height:1.35;
}

#dashboard .expiryStatus{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:6px 9px;
  border-radius:999px;
  font-size:10px;
  font-weight:850;
  white-space:nowrap;
}

#dashboard #expiryDashboardJump{
  margin-top:10px;
  align-self:flex-start;
  cursor:pointer;
}

@media(max-width:850px){
  #dashboard .expirySummary{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}

@media(max-width:620px){
  #dashboard .expirySummary{
    grid-template-columns:1fr 1fr;
  }

  #dashboard .expiryRow{
    grid-template-columns:1fr;
    align-items:start;
  }

  #dashboard .expiryStatus{
    justify-self:start;
  }
}
